diff --git a/src/main/java/org/gcube/informationsystem/base/impl/properties/PropertyElementImpl.java b/src/main/java/org/gcube/informationsystem/base/impl/properties/PropertyElementImpl.java index 5d3cb4a..2d35a12 100644 --- a/src/main/java/org/gcube/informationsystem/base/impl/properties/PropertyElementImpl.java +++ b/src/main/java/org/gcube/informationsystem/base/impl/properties/PropertyElementImpl.java @@ -27,10 +27,10 @@ public class PropertyElementImpl extends ElementImpl implements Property { @JsonIgnore protected Map additionalProperties; - @JsonIgnore /** * Used to allow to have an additional property starting with '_' or '@' */ + @JsonIgnore protected final Set allowedAdditionalKeys; public PropertyElementImpl() { diff --git a/src/main/java/org/gcube/informationsystem/base/reference/IdentifiableElement.java b/src/main/java/org/gcube/informationsystem/base/reference/IdentifiableElement.java index 463815e..6533b00 100644 --- a/src/main/java/org/gcube/informationsystem/base/reference/IdentifiableElement.java +++ b/src/main/java/org/gcube/informationsystem/base/reference/IdentifiableElement.java @@ -21,4 +21,5 @@ public interface IdentifiableElement extends Element { public Metadata getMetadata(); public void setMetadata(Metadata metadata); + } diff --git a/src/main/java/org/gcube/informationsystem/base/reference/entities/EntityElement.java b/src/main/java/org/gcube/informationsystem/base/reference/entities/EntityElement.java index bd1d73c..eb9e116 100644 --- a/src/main/java/org/gcube/informationsystem/base/reference/entities/EntityElement.java +++ b/src/main/java/org/gcube/informationsystem/base/reference/entities/EntityElement.java @@ -2,7 +2,9 @@ package org.gcube.informationsystem.base.reference.entities; import java.util.UUID; +import org.gcube.com.fasterxml.jackson.annotation.JsonGetter; import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.gcube.com.fasterxml.jackson.annotation.JsonSetter; import org.gcube.informationsystem.base.reference.Element; import org.gcube.informationsystem.base.reference.IdentifiableElement; import org.gcube.informationsystem.model.reference.properties.Metadata; @@ -24,18 +26,22 @@ public interface EntityElement extends Element, IdentifiableElement { public static final String NAME = "EntityElement"; //Entity.class.getSimpleName(); - @ISProperty(name=METADATA_PROPERTY, mandatory=true, nullable=false, description="Metadata associated with the instance that is automatically created/updated by the system.") - @Override - public Metadata getMetadata(); - - @Override - public void setMetadata(Metadata metadata); - + @JsonGetter(value = UUID_PROPERTY) @ISProperty(name = UUID_PROPERTY, description = "This UUID is be used to identify the instance univocally.", readonly = true, mandatory = true, nullable = false) @Override public UUID getUUID(); + @JsonSetter(value = UUID_PROPERTY) @Override public void setUUID(UUID uuid); + @JsonGetter(value = METADATA_PROPERTY) + @ISProperty(name=METADATA_PROPERTY, mandatory=true, nullable=false, description="Metadata associated with the instance that is automatically created/updated by the system.") + @Override + public Metadata getMetadata(); + + @JsonSetter(value = METADATA_PROPERTY) + @Override + public void setMetadata(Metadata metadata); + } \ No newline at end of file diff --git a/src/main/java/org/gcube/informationsystem/base/reference/relations/RelationElement.java b/src/main/java/org/gcube/informationsystem/base/reference/relations/RelationElement.java index 3a2821e..a6cc5bd 100644 --- a/src/main/java/org/gcube/informationsystem/base/reference/relations/RelationElement.java +++ b/src/main/java/org/gcube/informationsystem/base/reference/relations/RelationElement.java @@ -4,6 +4,7 @@ import java.util.UUID; import org.gcube.com.fasterxml.jackson.annotation.JsonGetter; import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore; +import org.gcube.com.fasterxml.jackson.annotation.JsonSetter; import org.gcube.informationsystem.base.reference.Element; import org.gcube.informationsystem.base.reference.IdentifiableElement; import org.gcube.informationsystem.base.reference.entities.EntityElement; @@ -28,20 +29,24 @@ public interface RelationElement extends Relation @Override public void setTarget(T target); + @JsonGetter(value = PROPAGATION_CONSTRAINT_PROPERTY) @ISProperty(name = PROPAGATION_CONSTRAINT_PROPERTY) public PropagationConstraint getPropagationConstraint(); diff --git a/src/main/java/org/gcube/informationsystem/types/reference/Type.java b/src/main/java/org/gcube/informationsystem/types/reference/Type.java index 4d54c89..61da704 100644 --- a/src/main/java/org/gcube/informationsystem/types/reference/Type.java +++ b/src/main/java/org/gcube/informationsystem/types/reference/Type.java @@ -2,13 +2,17 @@ package org.gcube.informationsystem.types.reference; import java.util.Map; import java.util.Set; +import java.util.UUID; import org.gcube.com.fasterxml.jackson.annotation.JsonGetter; import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore; import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.gcube.com.fasterxml.jackson.annotation.JsonSetter; import org.gcube.informationsystem.base.reference.AccessType; import org.gcube.informationsystem.base.reference.IdentifiableElement; +import org.gcube.informationsystem.model.reference.properties.Metadata; import org.gcube.informationsystem.types.annotations.Abstract; +import org.gcube.informationsystem.types.annotations.ISProperty; import org.gcube.informationsystem.types.reference.properties.PropertyDefinition; import org.gcube.informationsystem.utils.Version; @@ -33,6 +37,24 @@ public interface Type extends IdentifiableElement { public static final String TYPE_SUPERCLASSES_PROPERTY = "superClasses"; public static final String PROPERTIES_PROPERTY = "properties"; + @JsonGetter(value = UUID_PROPERTY) + @ISProperty(name = UUID_PROPERTY, description = "This UUID is be used to identify the instance univocally.", readonly = true, mandatory = true, nullable = false) + @Override + public UUID getUUID(); + + @JsonSetter(value = UUID_PROPERTY) + @Override + public void setUUID(UUID uuid); + + @JsonGetter(value = METADATA_PROPERTY) + @ISProperty(name=METADATA_PROPERTY, mandatory=true, nullable=false, description="Metadata associated with the instance that is automatically created/updated by the system.") + @Override + public Metadata getMetadata(); + + @JsonSetter(value = METADATA_PROPERTY) + @Override + public void setMetadata(Metadata metadata); + public String getName(); public String getDescription(); diff --git a/src/test/java/org/gcube/informationsystem/types/SerializationTest.java b/src/test/java/org/gcube/informationsystem/types/SerializationTest.java index 1c2f78f..a2fda5c 100644 --- a/src/test/java/org/gcube/informationsystem/types/SerializationTest.java +++ b/src/test/java/org/gcube/informationsystem/types/SerializationTest.java @@ -206,7 +206,7 @@ public class SerializationTest { logger.debug("Version {}", typeVersion.toString()); logger.info(ElementMapper.marshal(propertyType)); - String json = "{\"@class\":\"PropertyType\",\"metadata\":null,\"name\":\"Metadata\",\"description\":\"This class provides metadata per every IdentifiableElement\",\"superClasses\":[\"Property\"],\"properties\":[{\"@class\":\"PropertyDefinition\",\"name\":\"creationTime\",\"description\":\"Creation time. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"Date\"},{\"@class\":\"PropertyDefinition\",\"name\":\"lastUpdateTime\",\"description\":\"Last Update time. At creation time it assumes the same value of creationTime. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"Date\"},{\"@class\":\"PropertyDefinition\",\"name\":\"createdBy\",\"description\":\"The user that created the Entity or the Relation. It is initialized at creation time. \",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"String\"},{\"@class\":\"PropertyDefinition\",\"name\":\"uuid\",\"description\":\"This UUID is be used to identify the Entity or the Relation univocally.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":\"^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}$\",\"type\":\"String\"},{\"@class\":\"PropertyDefinition\",\"name\":\"lastUpdateBy\",\"description\":\"The user that made the last update to the Entity or the Relation. At creation time, it assumes the same value of creator.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"String\"}],\"accessType\":\"PROPERTY\",\"abstract\":false,\"version\":\"1.0.0\",\"changelog\":{\"1.0.0\":\"First Version\"}}"; + String json = "{\"@class\":\"PropertyType\",\"@metadata\":null,\"name\":\"Metadata\",\"description\":\"This class provides metadata per every IdentifiableElement\",\"superClasses\":[\"Property\"],\"properties\":[{\"@class\":\"PropertyDefinition\",\"name\":\"creationTime\",\"description\":\"Creation time. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"Date\"},{\"@class\":\"PropertyDefinition\",\"name\":\"lastUpdateTime\",\"description\":\"Last Update time. At creation time it assumes the same value of creationTime. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"Date\"},{\"@class\":\"PropertyDefinition\",\"name\":\"createdBy\",\"description\":\"The user that created the Entity or the Relation. It is initialized at creation time. \",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"String\"},{\"@class\":\"PropertyDefinition\",\"name\":\"uuid\",\"description\":\"This UUID is be used to identify the Entity or the Relation univocally.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":\"^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}$\",\"type\":\"String\"},{\"@class\":\"PropertyDefinition\",\"name\":\"lastUpdateBy\",\"description\":\"The user that made the last update to the Entity or the Relation. At creation time, it assumes the same value of creator.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"String\"}],\"accessType\":\"PROPERTY\",\"abstract\":false,\"version\":\"1.0.0\",\"changelog\":{\"1.0.0\":\"First Version\"}}"; logger.info(json); @SuppressWarnings("unchecked") PropertyType metadataType = (PropertyType) TypeMapper.deserializeTypeDefinition(json);