diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java index 5cd8f6c..5a4bb42 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java @@ -396,8 +396,8 @@ public abstract class ElementManagement { objectNode.put(Element.TYPE_PROPERTY, getTypeName()); - Collection superClasses = getCachedType().getSuperTypes(); - ArrayNode arrayNode = objectMapper.valueToTree(superClasses); + Collection supertypes = getCachedType().getSuperTypes(); + ArrayNode arrayNode = objectMapper.valueToTree(supertypes); objectNode.replace(Element.SUPERTYPES_PROPERTY, arrayNode); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/utils/MetadataOrient.java b/src/main/java/org/gcube/informationsystem/resourceregistry/utils/MetadataOrient.java index c2bb2c1..0a860ab 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/utils/MetadataOrient.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/utils/MetadataOrient.java @@ -1,9 +1,16 @@ package org.gcube.informationsystem.resourceregistry.utils; +import java.util.ArrayList; import java.util.Date; +import java.util.List; import java.util.Map; +import org.gcube.informationsystem.base.reference.properties.PropertyElement; import org.gcube.informationsystem.model.reference.properties.Metadata; +import org.gcube.informationsystem.model.reference.properties.Property; +import org.gcube.informationsystem.resourceregistry.types.CachedType; +import org.gcube.informationsystem.resourceregistry.types.TypesCache; +import org.gcube.informationsystem.types.reference.properties.PropertyType; import org.gcube.informationsystem.utils.TypeUtility; import com.orientechnologies.orient.core.record.impl.ODocument; @@ -21,6 +28,25 @@ public class MetadataOrient extends ODocument implements Metadata { super(iClassName); } + @Override + public String getTypeName() { + return TypeUtility.getTypeName(this.getClass()); + } + + @Override + public List getSupertypes() { + TypesCache typesCache = TypesCache.getInstance(); + @SuppressWarnings("unchecked") + CachedType> cachedType = (CachedType>) typesCache.getCachedType(getTypeName()); + try { + return cachedType.getSuperTypes(); + } catch (Exception e) { + List list = new ArrayList<>(); + list.add(TypeUtility.getTypeName(Property.class)); + return list; + } + } + @Override public String getCreatedBy() { return this.field(Metadata.CREATED_BY_PROPERTY); @@ -86,9 +112,4 @@ public class MetadataOrient extends ODocument implements Metadata { return ret; } - @Override - public String getTypeName() { - return TypeUtility.getTypeName(this.getClass()); - } - } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/utils/PropagationConstraintOrient.java b/src/main/java/org/gcube/informationsystem/resourceregistry/utils/PropagationConstraintOrient.java index 77dfd07..121ccd4 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/utils/PropagationConstraintOrient.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/utils/PropagationConstraintOrient.java @@ -1,8 +1,15 @@ package org.gcube.informationsystem.resourceregistry.utils; +import java.util.ArrayList; +import java.util.List; import java.util.Map; +import org.gcube.informationsystem.base.reference.properties.PropertyElement; import org.gcube.informationsystem.model.reference.properties.PropagationConstraint; +import org.gcube.informationsystem.model.reference.properties.Property; +import org.gcube.informationsystem.resourceregistry.types.CachedType; +import org.gcube.informationsystem.resourceregistry.types.TypesCache; +import org.gcube.informationsystem.types.reference.properties.PropertyType; import org.gcube.informationsystem.utils.TypeUtility; import com.orientechnologies.orient.core.record.impl.ODocument; @@ -10,7 +17,7 @@ import com.orientechnologies.orient.core.record.impl.ODocument; /** * @author Luca Frosini (ISTI - CNR) */ -public class PropagationConstraintOrient extends ODocument implements org.gcube.informationsystem.model.reference.properties.PropagationConstraint { +public class PropagationConstraintOrient extends ODocument implements PropagationConstraint { public PropagationConstraintOrient() { super(PropagationConstraint.NAME); @@ -19,7 +26,36 @@ public class PropagationConstraintOrient extends ODocument implements org.gcube. protected PropagationConstraintOrient(String iClassName) { super(iClassName); } + + @Override + public String getTypeName() { + return TypeUtility.getTypeName(this.getClass()); + } + + @Override + public List getSupertypes() { + TypesCache typesCache = TypesCache.getInstance(); + @SuppressWarnings("unchecked") + CachedType> cachedType = (CachedType>) typesCache.getCachedType(getTypeName()); + try { + return cachedType.getSuperTypes(); + } catch (Exception e) { + List list = new ArrayList<>(); + list.add(TypeUtility.getTypeName(Property.class)); + return list; + } + } + @Override + public AddConstraint getAddConstraint() { + return AddConstraint.valueOf((String) this.field(PropagationConstraint.ADD_PROPERTY)); + } + + @Override + public void setAddConstraint(AddConstraint addConstraint) { + this.field(PropagationConstraint.ADD_PROPERTY, addConstraint.name()); + } + @Override public DeleteConstraint getDeleteConstraint() { return DeleteConstraint.valueOf((String) this.field(PropagationConstraint.DELETE_PROPERTY)); @@ -40,16 +76,6 @@ public class PropagationConstraintOrient extends ODocument implements org.gcube. this.field(PropagationConstraint.REMOVE_PROPERTY, removeConstraint.name()); } - @Override - public AddConstraint getAddConstraint() { - return AddConstraint.valueOf((String) this.field(PropagationConstraint.ADD_PROPERTY)); - } - - @Override - public void setAddConstraint(AddConstraint addConstraint) { - this.field(PropagationConstraint.ADD_PROPERTY, addConstraint.name()); - } - @Override public Map getAdditionalProperties() { return null; @@ -77,9 +103,4 @@ public class PropagationConstraintOrient extends ODocument implements org.gcube. return ret; } - @Override - public String getTypeName() { - return TypeUtility.getTypeName(this.getClass()); - } - }