information-system-model/src/main/java/org/gcube/informationsystem/model/reference/relations/Relation.java

97 lines
3.2 KiB
Java
Raw Normal View History

/**
*
*/
package org.gcube.informationsystem.model.reference.relations;
import java.util.Map;
import org.gcube.informationsystem.model.reference.ER;
import org.gcube.informationsystem.model.reference.entities.Context;
import org.gcube.informationsystem.model.reference.entities.Entity;
import org.gcube.informationsystem.model.reference.entities.Resource;
import org.gcube.informationsystem.model.reference.properties.Header;
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.utils.AdditionalPropertiesSerializer;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
/**
* @author Luca Frosini (ISTI - CNR)
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#Relations
*/
// @JsonDeserialize(as=RelationImpl.class) Do not uncomment to manage subclasses
public interface Relation<Out extends Entity, In extends Entity> extends ER {
public static final String NAME = "Relation"; //Relation.class.getSimpleName();
public static final String SOURCE_PROPERTY = "source";
public static final String TARGET_PROPERTY = "target";
public static final String PROPAGATION_CONSTRAINT = "propagationConstraint";
/* Overriding getHeader method to create Header property in type */
@ISProperty(name=HEADER_PROPERTY, mandatory=true, nullable=false)
@Override
public Header getHeader();
// @JsonBackReference
// @JsonIgnore
@JsonIgnoreProperties({
Resource.CONSISTS_OF_PROPERTY, Resource.IS_RELATED_TO_PROPERTY,
Context.PARENT_PROPERTY, Context.CHILDREN_PROPERTY
})
@JsonGetter(value=SOURCE_PROPERTY)
public Out getSource();
@JsonIgnore
public void setSource(Out source);
@JsonIgnoreProperties({ Context.PARENT_PROPERTY, Context.CHILDREN_PROPERTY })
@JsonGetter(value=TARGET_PROPERTY)
public In getTarget();
@JsonIgnore
public void setTarget(In 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)
public Map<String, Object> getAdditionalProperties();
/**
* Set all properties, replacing existing ones
*/
public void setAdditionalProperties(Map<String, Object> additionalProperties);
/**
* 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);
/**
* 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
public void setAdditionalProperty(String key, Object value);
}