Added SchemaMixedElement interface to identify element supporting

additional properties
This commit is contained in:
Luca Frosini 2020-02-11 10:10:07 +01:00
parent 9858c50c99
commit dc2d5cece3
3 changed files with 36 additions and 40 deletions

View File

@ -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<String,Object> getAdditionalProperties();
public void setAdditionalProperties(Map<String,Object> additionalProperties);
public Object getAdditionalProperty(String key);
public void setAdditionalProperty(String key, Object value);
}

View File

@ -2,6 +2,7 @@ package org.gcube.informationsystem.model.reference.entities;
import java.util.Map; import java.util.Map;
import org.gcube.informationsystem.base.reference.SchemaMixedElement;
import org.gcube.informationsystem.types.annotations.Abstract; import org.gcube.informationsystem.types.annotations.Abstract;
import org.gcube.informationsystem.utils.AdditionalPropertiesSerializer; import org.gcube.informationsystem.utils.AdditionalPropertiesSerializer;
@ -15,40 +16,25 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
*/ */
@Abstract @Abstract
// @JsonDeserialize(as=FacetImpl.class) Do not uncomment to manage subclasses // @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 NAME = "Facet"; //Facet.class.getSimpleName();
public static final String DESCRIPTION = "This is the base class for Facets"; public static final String DESCRIPTION = "This is the base class for Facets";
public static final String VERSION = "1.0.0"; 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 @JsonAnyGetter
@JsonSerialize(using = AdditionalPropertiesSerializer.class) @JsonSerialize(using = AdditionalPropertiesSerializer.class)
@Override
public Map<String,Object> getAdditionalProperties(); public Map<String,Object> getAdditionalProperties();
/** @Override
* Set all properties, replacing existing ones
*/
public void setAdditionalProperties(Map<String,Object> additionalProperties); public void setAdditionalProperties(Map<String,Object> additionalProperties);
/** @Override
* Return the value of the given property.
* @param key the key of the requested property
* @return the value of the given property
*/
public Object getAdditionalProperty(String key); 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 @JsonAnySetter
@Override
public void setAdditionalProperty(String key, Object value); public void setAdditionalProperty(String key, Object value);
} }

View File

@ -5,6 +5,7 @@ package org.gcube.informationsystem.model.reference.relations;
import java.util.Map; import java.util.Map;
import org.gcube.informationsystem.base.reference.SchemaMixedElement;
import org.gcube.informationsystem.base.reference.relations.RelationElement; import org.gcube.informationsystem.base.reference.relations.RelationElement;
import org.gcube.informationsystem.model.reference.entities.Entity; import org.gcube.informationsystem.model.reference.entities.Entity;
import org.gcube.informationsystem.model.reference.entities.Resource; import org.gcube.informationsystem.model.reference.entities.Resource;
@ -26,7 +27,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
*/ */
@Abstract @Abstract
// @JsonDeserialize(as=RelationImpl.class) Do not uncomment to manage subclasses // @JsonDeserialize(as=RelationImpl.class) Do not uncomment to manage subclasses
public interface Relation<S extends Resource, T extends Entity> extends RelationElement<S,T> { public interface Relation<S extends Resource, T extends Entity> extends RelationElement<S,T>, SchemaMixedElement {
public static final String NAME = "Relation"; //Relation.class.getSimpleName(); public static final String NAME = "Relation"; //Relation.class.getSimpleName();
@ -34,48 +35,37 @@ public interface Relation<S extends Resource, T extends Entity> extends Relation
@JsonIgnoreProperties({Resource.CONSISTS_OF_PROPERTY, Resource.IS_RELATED_TO_PROPERTY}) @JsonIgnoreProperties({Resource.CONSISTS_OF_PROPERTY, Resource.IS_RELATED_TO_PROPERTY})
@JsonGetter(value = SOURCE_PROPERTY) @JsonGetter(value = SOURCE_PROPERTY)
@Override
public S getSource(); public S getSource();
@JsonIgnore @JsonIgnore
@Override
public void setSource(S source); public void setSource(S source);
@JsonGetter(value = TARGET_PROPERTY) @JsonGetter(value = TARGET_PROPERTY)
@Override
public T getTarget(); public T getTarget();
@JsonIgnore @JsonIgnore
@Override
public void setTarget(T target); public void setTarget(T target);
@ISProperty(name = PROPAGATION_CONSTRAINT) @ISProperty(name = PROPAGATION_CONSTRAINT)
public PropagationConstraint getPropagationConstraint(); 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 @JsonAnyGetter
@JsonSerialize(using = AdditionalPropertiesSerializer.class) @JsonSerialize(using = AdditionalPropertiesSerializer.class)
@Override
public Map<String,Object> getAdditionalProperties(); public Map<String,Object> getAdditionalProperties();
/** @Override
* Set all properties, replacing existing ones
*/
public void setAdditionalProperties(Map<String,Object> additionalProperties); public void setAdditionalProperties(Map<String,Object> additionalProperties);
/** @Override
* Return the value of the given property.
* @param key the key of the requested property
* @return the value of the given property
*/
public Object getAdditionalProperty(String key); 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 @JsonAnySetter
@Override
public void setAdditionalProperty(String key, Object value); public void setAdditionalProperty(String key, Object value);
} }