Skip to content

Commit

Permalink
added type conversion on DIModel generator
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarrasa committed Sep 28, 2022
1 parent 086b260 commit ff78c91
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/n10s/experimental/dimodel/DIMNodeDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Map<String, Object> getNodeSchemasAsJsonObject(){
props.forEach( (k, v) -> {
Map<String, Object> prop = new HashMap<>();
prop.put("property", k.getLocalName());
prop.put("type", v!=null?v.getLocalName():"string");
prop.put("type", v!=null?convertToDIDataType(v):"string");
prop.put("identifier", k.stringValue());
properties.add(prop);
});
Expand All @@ -64,6 +64,22 @@ public Map<String, Object> getNodeSchemasAsJsonObject(){
return map;
}

private String convertToDIDataType(IRI datatype) {
if (datatype.equals(XSD.INTEGER)||datatype.equals(XSD.INT)||datatype.equals(XSD.POSITIVE_INTEGER)||
datatype.equals(XSD.NEGATIVE_INTEGER)||datatype.equals(XSD.NON_POSITIVE_INTEGER)||
datatype.equals(XSD.NON_NEGATIVE_INTEGER)||datatype.equals(XSD.LONG)||datatype.equals(XSD.SHORT)||
datatype.equals(XSD.UNSIGNED_LONG)||datatype.equals(XSD.UNSIGNED_SHORT)){
return "integer";
} else if (datatype.equals(XSD.DECIMAL)||datatype.equals(XSD.FLOAT)||datatype.equals(XSD.DOUBLE)) {
return "float";
} else if (datatype.equals(XSD.BOOLEAN)){
return "boolean";
} else {
return "string";
}

}

public Map<String, Object> getRelSchemasAsJsonObject(){
Map<String, Object> map = new HashMap<>();
rels.forEach( (k,v) -> {
Expand Down

0 comments on commit ff78c91

Please sign in to comment.