Skip to content

Commit

Permalink
feat: entities aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
ranim-n committed Dec 12, 2024
1 parent 9edbeab commit 410c4c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ public NGSIEvent getEventFromFlowFile(FlowFile flowFile, final ProcessSession se
String value2 = value.getString(keyOne);
subAttrName = keyOne;
subAttrValue = value2;
hasSubAttrs = true;
if(keyOne!= "type" || keyOne != "value" || keyOne != "object") {
hasSubAttrs = true;
}
subAttributes.add(new AttributesLD(subAttrName,subAttrValue,subAttrValue,false,null));
} else if (!"value".equals(keyOne)){
JSONObject value2 = value.getJSONObject(keyOne);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,12 @@ public void initialize(Entity entity) throws Exception {
// iterate on all this context element attributes, if there are attributes
for (AttributesLD attribute : attributes) {
String attrName = attribute.getAttrName();
String subAttrName = "";
String subAttrName;
aggregation.put(attrName, new ArrayList<>());
aggregation.put(attrName + NGSIConstants.AUTOGENERATED_ATTR_TYPE, new ArrayList<>());
if (attribute.isHasSubAttrs()){
for (AttributesLD subAttribute : attribute.getSubAttrs()) {
subAttrName = subAttribute.getAttrName();
aggregation.put(attrName+ "_" + subAttrName, new ArrayList<>());
aggregation.put(attrName + "_" + subAttrName+ NGSIConstants.AUTOGENERATED_ATTR_TYPE, new ArrayList<>());
}
Expand Down Expand Up @@ -264,6 +265,7 @@ public void aggregate(Entity entity, long creationTime) {
for (AttributesLD subAttribute : attribute.getSubAttrs()) {
if (aggregation.containsKey(attrName+"_"+subAttrName)) {
subAttrValue=new JsonPrimitive(subAttribute.getAttrValue());
subAttrName= subAttribute.getAttrName();
aggregation.get(attrName + "_" + subAttrName).add(subAttrValue);
aggregation.get(attrName + "_" + subAttrName + NGSIConstants.AUTOGENERATED_ATTR_TYPE).add(new JsonPrimitive(subAttrType));
}
Expand Down

0 comments on commit 410c4c1

Please sign in to comment.