Skip to content

Commit

Permalink
addressed issue #47. none present attributes in notification entry of…
Browse files Browse the repository at this point in the history
… subs mean all attributes should be sent
  • Loading branch information
benni committed Dec 17, 2019
1 parent bd27513 commit b1a2d32
Showing 1 changed file with 34 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Entity {
private List<Property> properties;
private Object refToAccessControl;
private List<Relationship> relationships;
private List<GeoProperty> geoProperties;
private List<GeoProperty> geoProperties;
private String type;
private Long createdAt;
private Long modifiedAt;
Expand All @@ -31,6 +31,7 @@ public class Entity {
private Property createdAtProp = new Property();
private Property modifiedAtProp = new Property();
private Property observedAtProp = new Property();

public Entity(URI id, String type, List<BaseProperty> baseProps, Object refToAccessControl) {
this.id = id;
this.type = type;
Expand All @@ -39,26 +40,45 @@ public Entity(URI id, String type, List<BaseProperty> baseProps, Object refToAcc
relationships = new ArrayList<Relationship>();
properties = new ArrayList<Property>();
geoProperties = new ArrayList<GeoProperty>();
for(BaseProperty baseProp: baseProps) {
if(baseProp instanceof GeoProperty) {
if(baseProp.id.toString().equals(NGSIConstants.NGSI_LD_LOCATION)) {
for (BaseProperty baseProp : baseProps) {
if (baseProp instanceof GeoProperty) {
if (baseProp.id.toString().equals(NGSIConstants.NGSI_LD_LOCATION)) {
this.location = (GeoProperty) baseProp;
}else if(baseProp.id.toString().equals(NGSIConstants.NGSI_LD_OBSERVATION_SPACE)) {
} else if (baseProp.id.toString().equals(NGSIConstants.NGSI_LD_OBSERVATION_SPACE)) {
this.observationSpace = (GeoProperty) baseProp;
}else if(baseProp.id.toString().equals(NGSIConstants.NGSI_LD_OPERATION_SPACE)) {
} else if (baseProp.id.toString().equals(NGSIConstants.NGSI_LD_OPERATION_SPACE)) {
this.operationSpace = (GeoProperty) baseProp;
}else {
} else {
this.geoProperties.add((GeoProperty) baseProp);
}
}else if(baseProp instanceof Relationship) {
} else if (baseProp instanceof Relationship) {
this.relationships.add((Relationship) baseProp);
}else if(baseProp instanceof Property) {
this.properties.add((Property) baseProp);
} else if (baseProp instanceof Property) {
if (baseProp.id.toString().equals(NGSIConstants.NGSI_LD_CREATED_AT)) {
if (((Property) baseProp).getValue() != null) {
createdAtProp = (Property) baseProp;
createdAt = (Long) createdAtProp.getValue().get(0);
}

} else if (baseProp.id.toString().equals(NGSIConstants.NGSI_LD_MODIFIED_AT)) {
if (((Property) baseProp).getValue() != null) {
modifiedAtProp = (Property) baseProp;
modifiedAt = (Long) modifiedAtProp.getValue().get(0);
}

} else if (baseProp.id.toString().equals(NGSIConstants.NGSI_LD_OBSERVED_AT)) {
if (((Property) baseProp).getValue() != null) {
observedAtProp = (Property) baseProp;
observedAt = (Long) observedAtProp.getValue().get(0);
}
} else {
this.properties.add((Property) baseProp);
}

}
}
}



public Entity(URI id, GeoProperty location, GeoProperty observationSpace, GeoProperty operationSpace,
List<Property> properties, Object refToAccessControl, List<Relationship> relationships, String type,
List<GeoProperty> geoProperties) {
Expand Down Expand Up @@ -223,13 +243,11 @@ public void setModifiedAt(Long modifiedAt) {
modifiedAtProp.setSingleValue(modifiedAt);
this.modifiedAt = modifiedAt;
}


public List<BaseProperty> getAllBaseProperties() {
return allBaseProperties;
}


public List<GeoProperty> getGeoProperties() {
return geoProperties;
}
Expand All @@ -242,8 +260,8 @@ public void setGeoProperties(List<GeoProperty> geoProperties) {
allBaseProperties.addAll(geoProperties);
}
this.geoProperties = geoProperties;
}
}

@Override
public String toString() {
return "Entity [id=" + id + ", location=" + location + ", observationSpace=" + observationSpace
Expand Down

0 comments on commit b1a2d32

Please sign in to comment.