Redesigning E/R instance definition

This commit is contained in:
Luca Frosini 2023-04-19 16:38:40 +02:00
parent 66af46bc5d
commit 746748494a
7 changed files with 51 additions and 16 deletions

View File

@ -27,10 +27,10 @@ public class PropertyElementImpl extends ElementImpl implements Property {
@JsonIgnore
protected Map<String, Object> additionalProperties;
@JsonIgnore
/**
* Used to allow to have an additional property starting with '_' or '@'
*/
@JsonIgnore
protected final Set<String> allowedAdditionalKeys;
public PropertyElementImpl() {

View File

@ -21,4 +21,5 @@ public interface IdentifiableElement extends Element {
public Metadata getMetadata();
public void setMetadata(Metadata metadata);
}

View File

@ -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);
}

View File

@ -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<S extends EntityElement, T extends EntityElemen
public static final String SOURCE_PROPERTY = "@source";
public static final String TARGET_PROPERTY = "@target";
@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);
@JsonGetter(value=SOURCE_PROPERTY)
public S getSource();

View File

@ -56,6 +56,7 @@ public interface Relation<S extends Resource, T extends Entity> extends Relation
@Override
public void setTarget(T target);
@JsonGetter(value = PROPAGATION_CONSTRAINT_PROPERTY)
@ISProperty(name = PROPAGATION_CONSTRAINT_PROPERTY)
public PropagationConstraint getPropagationConstraint();

View File

@ -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();

View File

@ -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<Metadata> metadataType = (PropertyType<Metadata>) TypeMapper.deserializeTypeDefinition(json);