diff --git a/src/main/java/org/gcube/informationsystem/base/impl/ElementImpl.java b/src/main/java/org/gcube/informationsystem/base/impl/ElementImpl.java index 236d702..2c71561 100644 --- a/src/main/java/org/gcube/informationsystem/base/impl/ElementImpl.java +++ b/src/main/java/org/gcube/informationsystem/base/impl/ElementImpl.java @@ -8,6 +8,7 @@ import java.io.StringWriter; import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName; import org.gcube.informationsystem.base.reference.Element; import org.gcube.informationsystem.serialization.ElementMapper; +import org.gcube.informationsystem.utils.TypeUtility; /** * @author Luca Frosini (ISTI - CNR) @@ -30,4 +31,10 @@ public class ElementImpl implements Element { return super.toString(); } } + + @Override + public String getTypeName() { + return TypeUtility.getTypeName(this.getClass()); + } + } diff --git a/src/main/java/org/gcube/informationsystem/base/reference/Element.java b/src/main/java/org/gcube/informationsystem/base/reference/Element.java index 31d9a92..72f57dc 100644 --- a/src/main/java/org/gcube/informationsystem/base/reference/Element.java +++ b/src/main/java/org/gcube/informationsystem/base/reference/Element.java @@ -32,4 +32,6 @@ public interface Element extends Serializable { */ public static final String DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS Z"; + public String getTypeName(); + } diff --git a/src/main/java/org/gcube/informationsystem/types/impl/TypeImpl.java b/src/main/java/org/gcube/informationsystem/types/impl/TypeImpl.java index 2f54793..bd8b19d 100644 --- a/src/main/java/org/gcube/informationsystem/types/impl/TypeImpl.java +++ b/src/main/java/org/gcube/informationsystem/types/impl/TypeImpl.java @@ -32,6 +32,7 @@ import org.gcube.informationsystem.types.impl.properties.PropertyTypeImpl; import org.gcube.informationsystem.types.impl.relations.RelationTypeImpl; import org.gcube.informationsystem.types.reference.Type; import org.gcube.informationsystem.types.reference.properties.PropertyDefinition; +import org.gcube.informationsystem.utils.TypeUtility; import org.gcube.informationsystem.utils.Version; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -288,5 +289,10 @@ public class TypeImpl implements Type { public AccessType getAccessType() { return null; } + + @Override + public String getTypeName() { + return TypeUtility.getTypeName(this.getClass()); + } } diff --git a/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java b/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java index 33d720e..4369a93 100644 --- a/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java +++ b/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java @@ -12,6 +12,7 @@ import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName; import org.gcube.informationsystem.types.PropertyTypeName; import org.gcube.informationsystem.types.annotations.ISProperty; import org.gcube.informationsystem.types.reference.properties.PropertyDefinition; +import org.gcube.informationsystem.utils.TypeUtility; import org.gcube.informationsystem.utils.Version; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -281,4 +282,9 @@ public final class PropertyDefinitionImpl implements PropertyDefinition { } + @Override + public String getTypeName() { + return TypeUtility.getTypeName(this.getClass()); + } + } diff --git a/src/main/java/org/gcube/informationsystem/utils/TypeUtility.java b/src/main/java/org/gcube/informationsystem/utils/TypeUtility.java index fb6a6d9..a439bf1 100644 --- a/src/main/java/org/gcube/informationsystem/utils/TypeUtility.java +++ b/src/main/java/org/gcube/informationsystem/utils/TypeUtility.java @@ -24,10 +24,6 @@ public class TypeUtility { return getTypeName(jsonNode); } - public static String getTypeName(Element element){ - return getTypeName(element.getClass()); - } - public static String getTypeName(Class clz){ return TypeMapper.getType(clz); }