diff --git a/src/main/java/org/gcube/informationsystem/base/reference/SchemaMixedElement.java b/src/main/java/org/gcube/informationsystem/base/reference/SchemaMixedElement.java new file mode 100644 index 0000000..f916445 --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/base/reference/SchemaMixedElement.java @@ -0,0 +1,20 @@ +package org.gcube.informationsystem.base.reference; + +import java.util.Map; + +/** + * This interfaces is an helper to identify elements supporting Schema Mixed. + * i.e. elements which instances could have additional properties in respect to the ones defined in the schema + * @author Luca Frosini (ISTI - CNR) + */ +public interface SchemaMixedElement extends Element { + + public Map getAdditionalProperties(); + + public void setAdditionalProperties(Map additionalProperties); + + public Object getAdditionalProperty(String key); + + public void setAdditionalProperty(String key, Object value); + +} diff --git a/src/main/java/org/gcube/informationsystem/model/reference/entities/Facet.java b/src/main/java/org/gcube/informationsystem/model/reference/entities/Facet.java index 46634e6..fb5ce13 100644 --- a/src/main/java/org/gcube/informationsystem/model/reference/entities/Facet.java +++ b/src/main/java/org/gcube/informationsystem/model/reference/entities/Facet.java @@ -2,6 +2,7 @@ package org.gcube.informationsystem.model.reference.entities; import java.util.Map; +import org.gcube.informationsystem.base.reference.SchemaMixedElement; import org.gcube.informationsystem.types.annotations.Abstract; import org.gcube.informationsystem.utils.AdditionalPropertiesSerializer; @@ -15,40 +16,25 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; */ @Abstract // @JsonDeserialize(as=FacetImpl.class) Do not uncomment to manage subclasses -public interface Facet extends Entity { +public interface Facet extends Entity, SchemaMixedElement { public static final String NAME = "Facet"; //Facet.class.getSimpleName(); public static final String DESCRIPTION = "This is the base class for Facets"; public static final String VERSION = "1.0.0"; - /** - * Return all properties. The returned Map is a copy of - * the internal representation. Any modification to the returned Map MUST - * not affect the object - * @return a Map containing the properties - */ @JsonAnyGetter @JsonSerialize(using = AdditionalPropertiesSerializer.class) + @Override public Map getAdditionalProperties(); - /** - * Set all properties, replacing existing ones - */ + @Override public void setAdditionalProperties(Map additionalProperties); - /** - * Return the value of the given property. - * @param key the key of the requested property - * @return the value of the given property - */ + @Override public Object getAdditionalProperty(String key); - /** - * Set the value of the given property. - * @param key the key of the requested property - * @param value the value of the given resource property - */ @JsonAnySetter + @Override public void setAdditionalProperty(String key, Object value); } diff --git a/src/main/java/org/gcube/informationsystem/model/reference/relations/Relation.java b/src/main/java/org/gcube/informationsystem/model/reference/relations/Relation.java index 1cdf89b..66db264 100644 --- a/src/main/java/org/gcube/informationsystem/model/reference/relations/Relation.java +++ b/src/main/java/org/gcube/informationsystem/model/reference/relations/Relation.java @@ -5,6 +5,7 @@ package org.gcube.informationsystem.model.reference.relations; import java.util.Map; +import org.gcube.informationsystem.base.reference.SchemaMixedElement; import org.gcube.informationsystem.base.reference.relations.RelationElement; import org.gcube.informationsystem.model.reference.entities.Entity; import org.gcube.informationsystem.model.reference.entities.Resource; @@ -26,7 +27,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; */ @Abstract // @JsonDeserialize(as=RelationImpl.class) Do not uncomment to manage subclasses -public interface Relation extends RelationElement { +public interface Relation extends RelationElement, SchemaMixedElement { public static final String NAME = "Relation"; //Relation.class.getSimpleName(); @@ -34,48 +35,37 @@ public interface Relation extends Relation @JsonIgnoreProperties({Resource.CONSISTS_OF_PROPERTY, Resource.IS_RELATED_TO_PROPERTY}) @JsonGetter(value = SOURCE_PROPERTY) + @Override public S getSource(); @JsonIgnore + @Override public void setSource(S source); @JsonGetter(value = TARGET_PROPERTY) + @Override public T getTarget(); @JsonIgnore + @Override public void setTarget(T target); @ISProperty(name = PROPAGATION_CONSTRAINT) public PropagationConstraint getPropagationConstraint(); - /** - * Return all properties. The returned Map is a copy of - * the internal representation. Any modification to the returned Map MUST - * not affect the object - * @return a Map containing the properties - */ @JsonAnyGetter @JsonSerialize(using = AdditionalPropertiesSerializer.class) + @Override public Map getAdditionalProperties(); - /** - * Set all properties, replacing existing ones - */ + @Override public void setAdditionalProperties(Map additionalProperties); - /** - * Return the value of the given property. - * @param key the key of the requested property - * @return the value of the given property - */ + @Override public Object getAdditionalProperty(String key); - /** - * Set the value of the given property. - * @param key the key of the requested property - * @param value the value of the given resource property - */ @JsonAnySetter + @Override public void setAdditionalProperty(String key, Object value); }