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 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 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 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()); }
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; }
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; }
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()); }
/** * Method called to get the attribute object for attribute name */ private static Attribute getAttribute(DBHandler dbHandler, String attributeName) { for (Attribute attribute : dbHandler.getAttributeList()) { if (attribute.getName().equals(attributeName)) { return attribute; } } //not-possible to happen return null; }
public static boolean columnAlreadyExistsInStream(String columnName, StreamDefinition streamMetaData) { for (Attribute column : streamMetaData.getAttributeList()) { if (column.getName().equalsIgnoreCase(columnName)) { return true; } } return false; }
private static int getAttributeIndex(DBHandler dbHandler, String attributeName) { int i = 0; for (Attribute attribute : dbHandler.getAttributeList()) { if (attribute.getName().equals(attributeName)) { return i; } i++; } //not-possible to happen return 0; } }
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()); }
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; }
public String getStreamDefinitionExpression(StreamDefinition streamDefinition) { List<String> columns = new ArrayList<>(); Preconditions.checkNotNull(streamDefinition, "StreamDefinition is null"); for (Attribute attribute : streamDefinition.getAttributeList()) { columns.add(String.format("%s %s", attribute.getName(), attribute.getType().toString().toLowerCase())); } return String.format(DEFINE_STREAM_TEMPLATE, streamDefinition.getId(), StringUtils.join(columns, ",")); }
public String getStreamDefinitionExpression(StreamDefinition streamDefinition) { List<String> columns = new ArrayList<>(); Preconditions.checkNotNull(streamDefinition, "StreamDefinition is null"); for (Attribute attribute : streamDefinition.getAttributeList()) { columns.add(String.format("%s %s", attribute.getName(), attribute.getType().toString().toLowerCase())); } return String.format(DEFINE_STREAM_TEMPLATE, streamDefinition.getId(), StringUtils.join(columns, ",")); }
public String getStreamDefinitionExpression(String streamId) { StreamDefinition streamDefinition = getStreamDefinition(streamId); List<String> columns = new ArrayList<>(); Preconditions.checkNotNull(streamDefinition, "StreamDefinition is null"); for (Attribute attribute : streamDefinition.getAttributeList()) { columns.add(String.format("%s %s", attribute.getName(), attribute.getType().toString().toLowerCase())); } return String.format(DEFINE_STREAM_TEMPLATE, streamDefinition.getId(), StringUtils.join(columns, ",")); } }
public String getStreamDefinitionExpression(String streamId) { StreamDefinition streamDefinition = getStreamDefinition(streamId); List<String> columns = new ArrayList<>(); Preconditions.checkNotNull(streamDefinition, "StreamDefinition is null"); for (Attribute attribute : streamDefinition.getAttributeList()) { columns.add(String.format("%s %s", attribute.getName(), attribute.getType().toString().toLowerCase())); } return String.format(DEFINE_STREAM_TEMPLATE, streamDefinition.getId(), StringUtils.join(columns, ",")); } }
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()); }
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()); } } }
@Override public StratioStreamingMessage deserialize(Event object) { List<ColumnNameTypeValue> columns = new ArrayList<>(); for (int i = 0; i < object.getData().length; i++) { Object data = object.getData()[i]; Attribute attribute = streamMetadataService.getAttribute(object.getStreamId(), i); columns.add(new ColumnNameTypeValue(attribute.getName(), encodeSiddhiType(attribute.getType()), data)); } return new StratioStreamingMessage(object.getStreamId(), object.getTimeStamp(), columns); }