private static String getSampleValue(Attribute.Type attributeType) { Random rand = new Random(); switch (attributeType.name().toLowerCase()) { case Constants.ATTR_TYPE_FLOAT: { int hostIndex = rand.nextInt(5);
+ attributeTypeMap.get(key.trim()).name() + " in the stream " + streamID + " of siddhi text input mapper."); isValidEvent.set(false);
public static String generateJSONEvent(StreamDefinition streamDefinition) { JsonObject jsonEventObject = new JsonObject(); JsonObject innerParentObject = new JsonObject(); List<Attribute> attributeList = streamDefinition.getAttributeList(); if (attributeList.size() > 0) { for (Attribute attribute : attributeList) { if (attribute.getType().name().toLowerCase().equals(Constants.ATTR_TYPE_STRING)) { innerParentObject.addProperty(attribute.getName(), getSampleValue(attribute.getType())); } else if (attribute.getType().name().toLowerCase(). equals(Constants.ATTR_TYPE_BOOL)) { innerParentObject.addProperty(attribute.getName(), Boolean.parseBoolean(getSampleValue(attribute.getType()))); } else { innerParentObject.addProperty(attribute.getName(), Double.parseDouble(getSampleValue(attribute.getType()))); } } jsonEventObject.add(Constants.SAMPLE_EVENT_PARENT_TAG, innerParentObject); } return jsonEventObject.toString(); }
/** * Generates list of AttributeConfigs, with given List of Siddhi Attributes * @param attributes List of Siddhi Attribute objects * @return List of AttributeConfig objects */ public List<AttributeConfig> generateAttributeConfigList(List<Attribute> attributes) { List<AttributeConfig> attributeConfigs = new ArrayList<>(); for (Attribute attribute : attributes) { AttributeConfig attributeConfig = new AttributeConfig(attribute.getName(), attribute.getType().name()); preserveAndBindCodeSegment(attribute, attributeConfig); attributeConfigs.add(new AttributeConfig(attribute.getName(), attribute.getType().name())); } return attributeConfigs; } }