public Attribute.Type getAttributeType(String attributeName) { for (Attribute attribute : attributeList) { if (attribute.getName().equals(attributeName)) { return attribute.getType(); } } throw new AttributeNotExistException("Cannot find attribute type as '" + attributeName + "' does not exist in" + " '" + id + "'; " + this.toString()); }
public StreamDefinition attribute(String attributeName, Attribute.Type type) { checkAttribute(attributeName); this.attributeList.add(new Attribute(attributeName, type)); return this; }
protected void checkAttribute(String attributeName) { for (Attribute attribute : attributeList) { if (attribute.getName().equals(attributeName)) { throw new DuplicateAttributeException("'" + attributeName + "' is already defined for with type '" + attribute.getType() + "' for '" + id + "'; " + this.toString(), attribute.getQueryContextStartIndex(), attribute.getQueryContextEndIndex()); } } }
public String[] getAttributeNameArray() { int attributeListSize = attributeList.size(); String[] attributeNameArray = new String[attributeListSize]; for (int i = 0; i < attributeListSize; i++) { attributeNameArray[i] = attributeList.get(i).getName(); } return attributeNameArray; }
List<Object> result = new ArrayList<>(); for (int i = 0; i < attributeList.size(); i++) { switch (attributeList.get(i).getType()) { case BOOL: result.add(rs.getBoolean(i + 1));
public int getAttributePosition(String attributeName) { for (int i = 0, attributeListSize = attributeList.size(); i < attributeListSize; i++) { Attribute attribute = attributeList.get(i); if (attribute.getName().equals(attributeName)) { return i; } } throw new AttributeNotExistException("Cannot get attribute position as '" + attributeName + "' does not exist" + " in '" + id + "'; " + this.toString()); }
protected void checkAttribute(String attributeName) { for (Attribute attribute : attributeList) { if (attribute.getName().equals(attributeName)) { throw new DuplicateAttributeException("'" + attributeName + "' is already defined for with type '" + attribute.getType() + "' for '" + id + "'; " + this.toString(), attribute.getQueryContextStartIndex(), attribute.getQueryContextEndIndex()); } } }
public static <T extends Tuple> TypeInformation<T> getTupleTypeInformation(AbstractDefinition definition) { List<TypeInformation> types = new ArrayList<>(); for (Attribute attribute : definition.getAttributeList()) { types.add(TypeInformation.of(getJavaType(attribute.getType()))); } try { return Types.TUPLE(types.toArray(new TypeInformation[0])); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("Unable to parse ", ex); } }
protected String toString(String type) { StringBuilder definitionBuilder = new StringBuilder(); if (annotations != null && annotations.size() > 0) { for (Annotation annotation : annotations) { definitionBuilder.append(annotation.toString()); } } definitionBuilder.append("define ").append(type).append(" ").append(id).append(" ("); boolean isFirst = true; for (Attribute attribute : attributeList) { if (!isFirst) { definitionBuilder.append(", "); } else { isFirst = false; } definitionBuilder.append(attribute.getName()).append(" "). append(attribute.getType().toString().toLowerCase(Locale.getDefault())); } definitionBuilder.append(")"); return definitionBuilder.toString(); } @Override
public String[] getAttributeNameArray() { int attributeListSize = attributeList.size(); String[] attributeNameArray = new String[attributeListSize]; for (int i = 0; i < attributeListSize; i++) { attributeNameArray[i] = attributeList.get(i).getName(); } return attributeNameArray; }
public static <T extends Tuple> TypeInformation<T> getTupleTypeInformation(AbstractDefinition definition) { int tupleSize = definition.getAttributeList().size(); TypeInformation[] typeInformations = new TypeInformation[tupleSize]; List<Attribute> attributes = definition.getAttributeList(); try { for (int i = 0; i < attributes.size() ; i++) { Class<?> clazz = getJavaType(attributes.get(i).getType()); typeInformations[i] = TypeInformation.of(clazz); } return Types.TUPLE(typeInformations); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("Failed to get Type Information.", ex); } }
public TableDefinition attribute(String attributeName, Attribute.Type type) { checkAttribute(attributeName); this.attributeList.add(new Attribute(attributeName, type)); return this; }
private List<ColumnNameTypeValue> castToColumnNameTypeValue(List<Attribute> attributeList) { List<ColumnNameTypeValue> result = new ArrayList<>(); for (Attribute attribute : attributeList) { result.add(new ColumnNameTypeValue(attribute.getName(), getStreamingType(attribute.getType()), null)); } return result; }
private int findDefaultMappingPosition(String key) { for (int i = 0; i < streamAttributes.size(); i++) { String attributeName = streamAttributes.get(i).getName(); if (attributeName.equals(key)) { return i; } } return -1; }
Object[] eventArray = new Object[columnCount]; for (int i = 0; i < columnCount; i++) { switch (tableDefinition.getAttributeList().get(i).getType()) { case INT: eventArray[i] = results.getInt(i + 1);
public TableDefinition attribute(String attributeName, Attribute.Type type) { checkAttribute(attributeName); this.attributeList.add(new Attribute(attributeName, type)); return this; }
public static org.wso2.carbon.databridge.commons.Attribute convertToDatabridgeAttribute( Attribute attribute, String prefixToDrop) { AttributeType type; switch (attribute.getType()) { case LONG: type = AttributeType.LONG; break; case INT: type = AttributeType.INT; break; case FLOAT: type = AttributeType.FLOAT; break; case DOUBLE: type = AttributeType.DOUBLE; break; case BOOL: type = AttributeType.BOOL; break; default: type = AttributeType.STRING; break; } String name = (prefixToDrop != null) ? attribute.getName().replaceFirst(prefixToDrop, "") : attribute.getName(); return new org.wso2.carbon.databridge.commons.Attribute(name, type); }
private String insertColumnNames() { StringBuilder columnNames = new StringBuilder(); for (int i = 0; i < attributes.size(); i++) { columnNames.append(attributes.get(i).getName()).append(WHITESPACE).append(SEPARATOR); } //Deleting the last two characters to remove the WHITESPACE and SEPARATOR columnNames.delete(columnNames.length() - 2, columnNames.length() - 1); return insertQuery.replace(PLACEHOLDER_COLUMNS, columnNames.toString()); }
randomAttrGenerators.add(attrGeneratorFactory.createRandomAttrGenerator( sourceConfig.getJSONArray(EventSimulatorConstants.ATTRIBUTE_CONFIGURATION). getJSONObject(i), streamAttributes.get(i).getType()));
public StreamDefinition attribute(String attributeName, Attribute.Type type) { checkAttribute(attributeName); this.attributeList.add(new Attribute(attributeName, type)); return this; }