Improved IS Model Organization

This commit is contained in:
Luca Frosini 2023-05-12 17:47:58 +02:00
parent 05787952be
commit c48eae1355
31 changed files with 151 additions and 115 deletions

View File

@ -4,7 +4,6 @@
package org.gcube.informationsystem.base.impl;
import java.io.StringWriter;
import java.util.List;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.informationsystem.base.reference.Element;
@ -22,24 +21,12 @@ public class ElementImpl implements Element {
*/
private static final long serialVersionUID = 7338083489551084860L;
protected List<String> supertypes;
protected String expectedtype;
@Override
public String getTypeName() {
return TypeUtility.getTypeName(this.getClass());
}
@Override
public List<String> getSupertypes() {
return this.supertypes;
}
@Override
public String getExpectedtype() {
return this.expectedtype;
}
@Override
public String toString(){
StringWriter stringWriter = new StringWriter();

View File

@ -2,6 +2,7 @@ package org.gcube.informationsystem.base.impl.properties;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -24,6 +25,9 @@ public class PropertyElementImpl extends ElementImpl implements Property {
*/
private static final long serialVersionUID = 1396998430221747445L;
protected List<String> supertypes;
protected String expectedtype;
@JsonIgnore
protected Map<String, Object> additionalProperties;
@ -39,6 +43,17 @@ public class PropertyElementImpl extends ElementImpl implements Property {
this.allowedAdditionalKeys = new HashSet<>();
this.allowedAdditionalKeys.add(SUPERTYPES_PROPERTY);
}
@Override
public List<String> getSupertypes() {
return this.supertypes;
}
@Override
public String getExpectedtype() {
return this.expectedtype;
}
@Override
public Map<String, Object> getAdditionalProperties() {

View File

@ -4,12 +4,8 @@
package org.gcube.informationsystem.base.reference;
import java.io.Serializable;
import java.util.List;
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.gcube.informationsystem.types.annotations.Abstract;
@ -21,7 +17,7 @@ import org.gcube.informationsystem.utils.Version;
* @author Luca Frosini (ISTI - CNR)
*/
@Abstract
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, Element.EXPECTED_TYPE_PROPERTY })
@JsonPropertyOrder({ Element.TYPE_PROPERTY })
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = Element.TYPE_PROPERTY)
// @JsonTypeIdResolver(ElementTypeIdResolver.class)
@TypeMetadata(name = Element.NAME, description = "This is the base type for Element", version = Version.MINIMAL_VERSION_STRING)
@ -32,15 +28,6 @@ public interface Element extends Serializable {
public static final String TYPE_PROPERTY = "type";
public static final String SUPERTYPES_PROPERTY = "supertypes";
/*
* This is the key used by the deserializer to indicate the expected type
* which instead has been deserialized using the best available
* supertype
*/
public static final String EXPECTED_TYPE_PROPERTY = "expectedtype";
/**
* DateTime Pattern to be used to serialize Dates in every element
*/
@ -49,12 +36,4 @@ public interface Element extends Serializable {
@JsonIgnore
public String getTypeName();
@JsonInclude(Include.NON_EMPTY)
@JsonGetter(value = SUPERTYPES_PROPERTY)
public List<String> getSupertypes();
@JsonInclude(Include.NON_EMPTY)
@JsonGetter(value = EXPECTED_TYPE_PROPERTY)
public String getExpectedtype();
}

View File

@ -14,7 +14,7 @@ import org.gcube.informationsystem.model.reference.properties.Metadata;
*
* @author Luca Frosini (ISTI - CNR)
*/
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, Element.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY })
@JsonPropertyOrder({ Element.TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY })
public interface IdentifiableElement extends Element {
public static final String ID_PROPERTY = "id";

View File

@ -18,7 +18,7 @@ import org.gcube.informationsystem.utils.Version;
*/
@Abstract
@JsonIgnoreProperties(ignoreUnknown=true)
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, Element.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY })
@JsonPropertyOrder({ Element.TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY })
//@JsonDeserialize(as=EntityElementImpl.class) Do not uncomment to manage subclasses
@TypeMetadata(name = EntityElement.NAME, description = "This is the base type for any EntityElement", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)

View File

@ -3,6 +3,7 @@
*/
package org.gcube.informationsystem.model.impl.entities;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -23,12 +24,24 @@ public abstract class EntityImpl extends EntityElementImpl implements Entity {
*/
private static final long serialVersionUID = -4488771434017342703L;
protected List<String> supertypes;
protected String expectedtype;
protected Map<UUID,String> contexts;
protected EntityImpl(){
super();
this.metadata = null;
}
@Override
public List<String> getSupertypes() {
return this.supertypes;
}
@Override
public String getExpectedtype() {
return this.expectedtype;
}
public Map<UUID,String> getContexts(){
return this.contexts;

View File

@ -11,6 +11,7 @@ import java.util.Set;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.model.reference.ModelElement;
import org.gcube.informationsystem.model.reference.entities.Facet;
import org.gcube.informationsystem.model.reference.properties.Property;
import org.gcube.informationsystem.serialization.ElementMapper;
@ -39,7 +40,8 @@ public abstract class FacetImpl extends EntityImpl implements Facet {
super();
this.additionalProperties = new HashMap<>();
this.allowedAdditionalKeys = new HashSet<>();
this.allowedAdditionalKeys.add(SUPERTYPES_PROPERTY);
this.allowedAdditionalKeys.add(ModelElement.SUPERTYPES_PROPERTY);
this.allowedAdditionalKeys.add(ModelElement.EXPECTED_TYPE_PROPERTY);
}
@Override

View File

@ -5,6 +5,7 @@ package org.gcube.informationsystem.model.impl.relations;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@ -34,6 +35,8 @@ public abstract class RelationImpl<S extends Resource, T extends Entity>
*/
private static final long serialVersionUID = -6249979476879235053L;
protected List<String> supertypes;
protected String expectedtype;
protected Map<UUID,String> contexts;
protected PropagationConstraint propagationConstraint;
@ -61,6 +64,17 @@ public abstract class RelationImpl<S extends Resource, T extends Entity>
this.propagationConstraint = propagationConstraint;
}
@Override
public List<String> getSupertypes() {
return this.supertypes;
}
@Override
public String getExpectedtype() {
return this.expectedtype;
}
public Map<UUID,String> getContexts(){
return this.contexts;
}

View File

@ -5,8 +5,8 @@ import java.util.UUID;
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.base.reference.IdentifiableElement;
@ -16,8 +16,8 @@ import org.gcube.informationsystem.base.reference.IdentifiableElement;
*
* @author Luca Frosini (ISTI - CNR)
*/
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, Element.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, ERElement.CONTEXTS_PROPERTY })
public interface ERElement extends IdentifiableElement {
@JsonPropertyOrder({ Element.TYPE_PROPERTY, ModelElement.SUPERTYPES_PROPERTY, ModelElement.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, ERElement.CONTEXTS_PROPERTY })
public interface ERElement extends IdentifiableElement, ModelElement {
/**
* Used when requested to include contexts in metadata.
@ -27,5 +27,5 @@ public interface ERElement extends IdentifiableElement {
@JsonInclude(Include.NON_NULL)
@JsonGetter(value = CONTEXTS_PROPERTY)
public Map<UUID,String> getContexts();
public Map<UUID,String> getContexts();
}

View File

@ -0,0 +1,34 @@
package org.gcube.informationsystem.model.reference;
import java.util.List;
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.gcube.informationsystem.base.reference.Element;
/**
* @author Luca Frosini (ISTI - CNR)
*/
@JsonPropertyOrder({ Element.TYPE_PROPERTY, ModelElement.SUPERTYPES_PROPERTY, ModelElement.EXPECTED_TYPE_PROPERTY })
public interface ModelElement extends Element {
public static final String SUPERTYPES_PROPERTY = "supertypes";
/*
* This is the key used by the deserializer to indicate the expected type
* which instead has been deserialized using the best available
* supertype
*/
public static final String EXPECTED_TYPE_PROPERTY = "expectedtype";
@JsonInclude(Include.NON_EMPTY)
@JsonGetter(value = SUPERTYPES_PROPERTY)
public List<String> getSupertypes();
@JsonInclude(Include.NON_EMPTY)
@JsonGetter(value = EXPECTED_TYPE_PROPERTY)
public String getExpectedtype();
}

View File

@ -8,6 +8,7 @@ import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.base.reference.IdentifiableElement;
import org.gcube.informationsystem.base.reference.entities.EntityElement;
import org.gcube.informationsystem.model.reference.ERElement;
import org.gcube.informationsystem.model.reference.ModelElement;
import org.gcube.informationsystem.types.annotations.Abstract;
import org.gcube.informationsystem.types.reference.Change;
import org.gcube.informationsystem.types.reference.TypeMetadata;
@ -19,7 +20,7 @@ import org.gcube.informationsystem.utils.Version;
* @author Luca Frosini (ISTI - CNR)
*/
@Abstract
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, Element.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, ERElement.CONTEXTS_PROPERTY })
@JsonPropertyOrder({ Element.TYPE_PROPERTY, ModelElement.SUPERTYPES_PROPERTY, ModelElement.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, ERElement.CONTEXTS_PROPERTY })
//@JsonDeserialize(as=EntityImpl.class) Do not uncomment to manage subclasses
@TypeMetadata(name = Entity.NAME, description = "This is the base type for any Entity", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)

View File

@ -12,12 +12,13 @@ import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.base.reference.IdentifiableElement;
import org.gcube.informationsystem.model.reference.ERElement;
import org.gcube.informationsystem.model.reference.ModelElement;
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
import org.gcube.informationsystem.types.annotations.Abstract;
import org.gcube.informationsystem.types.annotations.RelatedResourcesEntry;
import org.gcube.informationsystem.types.annotations.ResourceSchema;
import org.gcube.informationsystem.types.annotations.ResourceSchemaEntry;
import org.gcube.informationsystem.types.annotations.RelatedResourcesEntry;
import org.gcube.informationsystem.types.reference.Change;
import org.gcube.informationsystem.types.reference.TypeMetadata;
import org.gcube.informationsystem.utils.Version;
@ -29,7 +30,7 @@ import org.gcube.informationsystem.utils.Version;
*/
@Abstract
@JsonIgnoreProperties(ignoreUnknown=true)
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, Element.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, ERElement.CONTEXTS_PROPERTY, Resource.CONSISTS_OF_PROPERTY, Resource.IS_RELATED_TO_PROPERTY })
@JsonPropertyOrder({ Element.TYPE_PROPERTY, ModelElement.SUPERTYPES_PROPERTY, ModelElement.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, ERElement.CONTEXTS_PROPERTY, Resource.CONSISTS_OF_PROPERTY, Resource.IS_RELATED_TO_PROPERTY })
// @JsonDeserialize(as=ResourceImpl.class) Do not uncomment to manage subclasses
@ResourceSchema(
facets={

View File

@ -14,6 +14,7 @@ import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.base.reference.SchemaMixedElement;
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
import org.gcube.informationsystem.model.impl.properties.PropertyImpl;
import org.gcube.informationsystem.model.reference.ModelElement;
import org.gcube.informationsystem.serialization.AdditionalPropertiesSerializer;
import org.gcube.informationsystem.types.reference.Change;
import org.gcube.informationsystem.types.reference.TypeMetadata;
@ -26,11 +27,11 @@ import org.gcube.informationsystem.utils.Version;
* @author Luca Frosini (ISTI - CNR)
*/
// @JsonIgnoreProperties(ignoreUnknown=true)
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, Element.EXPECTED_TYPE_PROPERTY })
@JsonPropertyOrder({ Element.TYPE_PROPERTY, ModelElement.SUPERTYPES_PROPERTY, ModelElement.EXPECTED_TYPE_PROPERTY })
@JsonDeserialize(as=PropertyImpl.class)
@TypeMetadata(name = Property.NAME, description = "This is the base type for any Property", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public interface Property extends PropertyElement, SchemaMixedElement {
public interface Property extends PropertyElement, SchemaMixedElement, ModelElement {
public static final String NAME = "Property"; //Property.class.getSimpleName();

View File

@ -19,6 +19,7 @@ import org.gcube.informationsystem.base.reference.IdentifiableElement;
import org.gcube.informationsystem.base.reference.SchemaMixedElement;
import org.gcube.informationsystem.base.reference.relations.RelationElement;
import org.gcube.informationsystem.model.reference.ERElement;
import org.gcube.informationsystem.model.reference.ModelElement;
import org.gcube.informationsystem.model.reference.entities.Entity;
import org.gcube.informationsystem.model.reference.entities.Resource;
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
@ -35,7 +36,7 @@ import org.gcube.informationsystem.utils.Version;
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#Relation
*/
@Abstract
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, Element.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, ERElement.CONTEXTS_PROPERTY, Relation.PROPAGATION_CONSTRAINT_PROPERTY })
@JsonPropertyOrder({ Element.TYPE_PROPERTY, ModelElement.SUPERTYPES_PROPERTY, ModelElement.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, ERElement.CONTEXTS_PROPERTY, Relation.PROPAGATION_CONSTRAINT_PROPERTY })
// @JsonDeserialize(as=RelationImpl.class) Do not uncomment to manage subclasses
@TypeMetadata(name = Relation.NAME, description = "This is the base type for any Relation", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)

View File

@ -24,6 +24,7 @@ import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
import org.gcube.com.fasterxml.jackson.databind.node.TextNode;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.model.reference.ModelElement;
import org.gcube.informationsystem.types.TypeMapper;
/**
@ -60,13 +61,13 @@ public class ElementDeserializer<ISM extends Element> extends StdDeserializer<IS
List<TextNode> toBeKeepSuperClasses = new ArrayList<>();
ObjectNode objectNode = (ObjectNode) treeNode;
if(!objectNode.has(Element.EXPECTED_TYPE_PROPERTY)) {
objectNode.set(Element.EXPECTED_TYPE_PROPERTY, objectNode.get(Element.TYPE_PROPERTY));
if(!objectNode.has(ModelElement.EXPECTED_TYPE_PROPERTY)) {
objectNode.set(ModelElement.EXPECTED_TYPE_PROPERTY, objectNode.get(Element.TYPE_PROPERTY));
}
try {
JsonNode superClassesTreeNode = objectNode
.get(Element.SUPERTYPES_PROPERTY);
.get(ModelElement.SUPERTYPES_PROPERTY);
if (superClassesTreeNode != null
&& superClassesTreeNode.isArray()) {
ArrayNode arrayNode = (ArrayNode) superClassesTreeNode;

View File

@ -30,6 +30,7 @@ import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.discovery.Discovery;
import org.gcube.informationsystem.discovery.knowledge.Knowledge;
import org.gcube.informationsystem.model.reference.ModelElement;
import org.gcube.informationsystem.types.TypeMapper;
import org.gcube.informationsystem.types.reference.Type;
import org.slf4j.Logger;
@ -195,14 +196,14 @@ public abstract class ElementMapper {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(unknownType);
stringBuffer.append(" is an unknown type. Please provide ");
stringBuffer.append(Element.SUPERTYPES_PROPERTY);
stringBuffer.append(ModelElement.SUPERTYPES_PROPERTY);
stringBuffer.append(" property as string array to allow to instantiate the most appropriated class.");
return stringBuffer;
}
protected static ObjectNode setTypeToBestAvailable(ObjectNode objectNode) {
String unknownType = objectNode.get(Element.TYPE_PROPERTY).asText();
ArrayNode arrayNode = (ArrayNode) objectNode.get(Element.SUPERTYPES_PROPERTY);
ArrayNode arrayNode = (ArrayNode) objectNode.get(ModelElement.SUPERTYPES_PROPERTY);
String candidatedSupertype = null;
for(int i = 0; i < arrayNode.size(); i++) {
@ -227,11 +228,11 @@ public abstract class ElementMapper {
}
if(candidatedSupertype!=null) {
if(!objectNode.has(Element.EXPECTED_TYPE_PROPERTY)) {
objectNode.set(Element.EXPECTED_TYPE_PROPERTY, objectNode.get(Element.TYPE_PROPERTY));
if(!objectNode.has(ModelElement.EXPECTED_TYPE_PROPERTY)) {
objectNode.set(ModelElement.EXPECTED_TYPE_PROPERTY, objectNode.get(Element.TYPE_PROPERTY));
}
objectNode.set(Element.TYPE_PROPERTY, new TextNode(candidatedSupertype));
objectNode.remove(Element.SUPERTYPES_PROPERTY);
objectNode.remove(ModelElement.SUPERTYPES_PROPERTY);
return objectNode;
}
@ -305,6 +306,9 @@ public abstract class ElementMapper {
try {
return mapper.readValue(reader, clz);
} catch (JsonMappingException e) {
if(!ModelElement.class.isAssignableFrom(clz)) {
throw e;
}
JsonNode jsonNode = mapper.readTree(reader);
jsonNode = analizeTypes((ObjectNode) jsonNode);
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
@ -326,6 +330,9 @@ public abstract class ElementMapper {
try {
return mapper.readValue(stream, clz);
} catch (JsonMappingException e) {
if(!ModelElement.class.isAssignableFrom(clz)) {
throw e;
}
JsonNode jsonNode = mapper.readTree(stream);
jsonNode = analizeTypes((ObjectNode) jsonNode);
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
@ -346,6 +353,9 @@ public abstract class ElementMapper {
try {
return mapper.readValue(string, clz);
} catch (JsonMappingException e) {
if(!ModelElement.class.isAssignableFrom(clz)) {
throw e;
}
JsonNode jsonNode = mapper.readTree(string);
jsonNode = analizeTypes((ObjectNode) jsonNode);
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
@ -358,6 +368,9 @@ public abstract class ElementMapper {
try {
return mapper.readValue(string, type);
} catch (JsonMappingException e) {
if(!ModelElement.class.isAssignableFrom(clz)) {
throw e;
}
List<El> ret = new ArrayList<>();
ArrayNode arrayNode = (ArrayNode) mapper.readTree(string);
for(JsonNode jsonNode : arrayNode) {

View File

@ -5,7 +5,6 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.TypeVariable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
@ -62,8 +61,6 @@ public class TypeImpl implements Type {
protected UUID uuid;
protected Metadata metadata;
protected List<String> supertypes;
protected String expectedtype;
protected String name;
protected String description;
@ -78,7 +75,7 @@ public class TypeImpl implements Type {
@JsonProperty(value = FINAL_PROPERTY)
protected boolean finalClass;
protected Set<String> typeSuperTypes;
protected Set<String> extendedTypes;
protected Set<PropertyDefinition> properties;
@ -278,8 +275,8 @@ public class TypeImpl implements Type {
}
@Override
public Set<String> getTypeSuperTypes() {
return typeSuperTypes;
public Set<String> getExtendedTypes() {
return extendedTypes;
}
@JsonInclude(Include.NON_EMPTY)
@ -297,15 +294,5 @@ public class TypeImpl implements Type {
public String getTypeName() {
return TypeUtility.getTypeName(this.getClass());
}
@Override
public List<String> getSupertypes() {
return this.supertypes;
}
@Override
public String getExpectedtype() {
return this.expectedtype;
}
}

View File

@ -66,17 +66,17 @@ public class EntityTypeImpl extends TypeImpl implements EntityType {
if(EntityType.class.isAssignableFrom(clz)){
@SuppressWarnings("unchecked")
Class<? extends EntityType> c = (Class<? extends EntityType>) clz;
this.typeSuperTypes = retrieveSuperClasses(c, EntityType.class, EntityElement.NAME);
this.extendedTypes = retrieveSuperClasses(c, EntityType.class, EntityElement.NAME);
} else if(Context.class.isAssignableFrom(clz)){
@SuppressWarnings("unchecked")
Class<? extends Context> c = (Class<? extends Context>) clz;
this.typeSuperTypes = retrieveSuperClasses(c, Context.class, EntityElement.NAME);
this.extendedTypes = retrieveSuperClasses(c, Context.class, EntityElement.NAME);
} else if(QueryTemplate.class.isAssignableFrom(clz)){
@SuppressWarnings("unchecked")
Class<? extends QueryTemplate> c = (Class<? extends QueryTemplate>) clz;
this.typeSuperTypes = retrieveSuperClasses(c, QueryTemplate.class, EntityElement.NAME);
this.extendedTypes = retrieveSuperClasses(c, QueryTemplate.class, EntityElement.NAME);
} else if(EntityElement.class.isAssignableFrom(clz)){
this.typeSuperTypes = retrieveSuperClasses(clz, EntityElement.class, null);
this.extendedTypes = retrieveSuperClasses(clz, EntityElement.class, null);
} else {
throw new RuntimeException("Type Hierachy Error for class " + clz.getSimpleName());
}

View File

@ -29,7 +29,7 @@ public final class FacetTypeImpl extends EntityTypeImpl implements FacetType {
public FacetTypeImpl(Class<? extends Facet> clz) {
super(clz);
this.typeSuperTypes = retrieveSuperClasses(clz, Facet.class, Entity.NAME);
this.extendedTypes = retrieveSuperClasses(clz, Facet.class, Entity.NAME);
this.properties = retrieveListOfProperties(clz);
}

View File

@ -37,7 +37,7 @@ public final class ResourceTypeImpl extends EntityTypeImpl implements ResourceTy
public ResourceTypeImpl(Class<? extends Resource> clz) {
super(clz);
this.typeSuperTypes = retrieveSuperClasses(clz, Resource.class, Entity.NAME);
this.extendedTypes = retrieveSuperClasses(clz, Resource.class, Entity.NAME);
setResourceSchemaEntries(clz);
}

View File

@ -3,7 +3,6 @@ package org.gcube.informationsystem.types.impl.properties;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
@ -36,9 +35,6 @@ public final class PropertyDefinitionImpl implements PropertyDefinition {
public final static String URI_REGEX = null;
public final static String URL_REGEX = null;
protected List<String> supertypes;
protected String expectedtype;
private String name= "";
private String description= "";
private boolean mandatory = false;
@ -291,14 +287,4 @@ public final class PropertyDefinitionImpl implements PropertyDefinition {
return TypeUtility.getTypeName(this.getClass());
}
@Override
public List<String> getSupertypes() {
return this.supertypes;
}
@Override
public String getExpectedtype() {
return this.expectedtype;
}
}

View File

@ -45,7 +45,7 @@ public final class PropertyTypeImpl<P extends PropertyElement> extends TypeImpl
public PropertyTypeImpl(Class<P> clz) {
super(clz);
this.typeSuperTypes = retrieveSuperClasses(clz, PropertyElement.class,
this.extendedTypes = retrieveSuperClasses(clz, PropertyElement.class,
clz == PropertyElement.class ? null : PropertyElement.NAME);
this.properties = retrieveListOfProperties(clz);

View File

@ -33,7 +33,7 @@ public final class ConsistsOfTypeImpl extends RelationTypeImpl<ResourceType, Fac
public ConsistsOfTypeImpl(Class<? extends ConsistsOf<? extends Resource, ? extends Facet>> clz) {
super(clz);
this.typeSuperTypes = retrieveSuperClasses(clz, ConsistsOf.class, Relation.NAME);
this.extendedTypes = retrieveSuperClasses(clz, ConsistsOf.class, Relation.NAME);
this.properties = retrieveListOfProperties(clz);

View File

@ -30,7 +30,7 @@ public final class IsRelatedToTypeImpl extends RelationTypeImpl<ResourceType, Re
public IsRelatedToTypeImpl(Class<? extends IsRelatedTo<? extends Resource, ? extends Resource>> clz) {
super(clz);
this.typeSuperTypes = retrieveSuperClasses(clz, IsRelatedTo.class, Relation.NAME);
this.extendedTypes = retrieveSuperClasses(clz, IsRelatedTo.class, Relation.NAME);
this.properties = retrieveListOfProperties(clz);

View File

@ -58,13 +58,13 @@ public class RelationTypeImpl<S extends EntityType, T extends EntityType>
if(RelationType.class.isAssignableFrom(clz)) {
@SuppressWarnings({"unchecked"})
Class<RelationType<?,?>> c = (Class<RelationType<?,?>>) clz;
this.typeSuperTypes = retrieveSuperClasses(c, RelationType.class, RelationElement.NAME);
this.extendedTypes = retrieveSuperClasses(c, RelationType.class, RelationElement.NAME);
} else if(IsParentOf.class.isAssignableFrom(clz)) {
@SuppressWarnings("unchecked")
Class<? extends IsParentOf> c = (Class<? extends IsParentOf>) clz;
this.typeSuperTypes = retrieveSuperClasses(c, IsParentOf.class, RelationElement.NAME);
this.extendedTypes = retrieveSuperClasses(c, IsParentOf.class, RelationElement.NAME);
} else if(RelationElement.class.isAssignableFrom(clz)) {
this.typeSuperTypes = retrieveSuperClasses(clz, RelationElement.class, null);
this.extendedTypes = retrieveSuperClasses(clz, RelationElement.class, null);
} else {
throw new RuntimeException("Type Hierachy Error");
}

View File

@ -22,13 +22,13 @@ import org.gcube.informationsystem.utils.Version;
*/
@Abstract
@JsonIgnoreProperties(ignoreUnknown=true)
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY })
@JsonPropertyOrder({ Element.TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY })
@TypeMetadata(name = Type.NAME, description = "This is the base type to define any Type", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
//@JsonDeserialize(as=TypeImpl.class) Do not uncomment to manage subclasses
public interface Type extends IdentifiableElement {
public static final String NAME = "Type"; //Type.class.getSimpleName();
public static final String NAME = "Type"; // Type.class.getSimpleName();
public static final String NAME_PROPERTY = "name";
public static final String DESCRIPTION_PROPERTY = "description";
@ -37,7 +37,7 @@ public interface Type extends IdentifiableElement {
public static final String ABSTRACT_PROPERTY = "abstract";
public static final String FINAL_PROPERTY = "final";
/* Cannot use 'supertypes' which conflicts with Element */
public static final String TYPE_SUPER_TYPES_PROPERTY = "typeSuperTypes";
public static final String EXTENDED_TYPES_PROPERTY = "extendedTypes";
public static final String PROPERTIES_PROPERTY = "properties";
@JsonGetter(value = ID_PROPERTY)
@ -78,8 +78,8 @@ public interface Type extends IdentifiableElement {
@JsonGetter(value = FINAL_PROPERTY)
public boolean isFinal();
@JsonGetter(value = TYPE_SUPER_TYPES_PROPERTY)
public Set<String> getTypeSuperTypes();
@JsonGetter(value = EXTENDED_TYPES_PROPERTY)
public Set<String> getExtendedTypes();
public Set<PropertyDefinition> getProperties();

View File

@ -38,8 +38,8 @@ public interface EntityType extends Type, EntityElement {
public boolean isAbstract();
@Override
@ISProperty(name = Type.TYPE_SUPER_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
public Set<String> getTypeSuperTypes();
@ISProperty(name = Type.EXTENDED_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
public Set<String> getExtendedTypes();
/* Type is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */

View File

@ -62,8 +62,8 @@ public interface PropertyType<P extends PropertyElement> extends PropertyElement
public boolean isAbstract();
@Override
@ISProperty(name = Type.TYPE_SUPER_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
public Set<String> getTypeSuperTypes();
@ISProperty(name = Type.EXTENDED_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
public Set<String> getExtendedTypes();
@ISProperty(name = Type.PROPERTIES_PROPERTY, readonly = false, mandatory = true, nullable = false)
public Set<PropertyDefinition> getProperties();

View File

@ -41,8 +41,8 @@ public interface RelationType<S extends EntityType, T extends EntityType>
public boolean isAbstract();
@Override
@ISProperty(name = Type.TYPE_SUPER_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
public Set<String> getTypeSuperTypes();
@ISProperty(name = Type.EXTENDED_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
public Set<String> getExtendedTypes();
@Override
@ISProperty(name = Type.PROPERTIES_PROPERTY, readonly = false, mandatory = true, nullable = false)

View File

@ -41,8 +41,8 @@ public class DiscoveryTest {
Assert.assertTrue(type.getDescription().compareTo(expected.getDescription())==0);
Assert.assertTrue(type.isAbstract() == expected.isAbstract());
Assert.assertTrue(type.getTypeSuperTypes().containsAll(expected.getTypeSuperTypes()));
Assert.assertTrue(expected.getTypeSuperTypes().containsAll(type.getTypeSuperTypes()));
Assert.assertTrue(type.getExtendedTypes().containsAll(expected.getExtendedTypes()));
Assert.assertTrue(expected.getExtendedTypes().containsAll(type.getExtendedTypes()));
Map<Version, String> typeChangelog = type.getChangelog();

View File

@ -4,6 +4,7 @@ import java.util.Calendar;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.base.reference.IdentifiableElement;
import org.gcube.informationsystem.model.reference.ERElement;
import org.gcube.informationsystem.model.reference.entities.Facet;
import org.gcube.informationsystem.model.reference.entities.Resource;
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
@ -78,7 +79,7 @@ public class PropagationConstraintTest {
DeleteConstraint deleteConstraint = DeleteConstraint.keep;
String marshalled = "{\"" +
Element.TYPE_PROPERTY + "\":\"MyPropagationConstraint\",\"" +
Element.SUPERTYPES_PROPERTY + "\":[\"" + PropagationConstraint.NAME + "\", \"" + Property.NAME + "\"],\"" +
ERElement.SUPERTYPES_PROPERTY + "\":[\"" + PropagationConstraint.NAME + "\", \"" + Property.NAME + "\"],\"" +
PropagationConstraint.ADD_PROPERTY + "\":\""+ addConstraint + "\",\""+
PropagationConstraint.REMOVE_PROPERTY + "\":\"" + removeConstraint + "\",\""+
PropagationConstraint.DELETE_PROPERTY + "\":\"" + deleteConstraint +
@ -109,7 +110,7 @@ public class PropagationConstraintTest {
String pcString = "{" +
"\"" + Element.TYPE_PROPERTY + "\":\"My" + PropagationConstraint.NAME + "\"," +
"\"" + Element.SUPERTYPES_PROPERTY + "\":[\"" + PropagationConstraint.NAME + "\", \"" + Property.NAME + "\"],\"" +
"\"" + ERElement.SUPERTYPES_PROPERTY + "\":[\"" + PropagationConstraint.NAME + "\", \"" + Property.NAME + "\"],\"" +
PropagationConstraint.ADD_PROPERTY + "\":\""+ addConstraint + "\",\"" +
PropagationConstraint.REMOVE_PROPERTY + "\":\"" + removeConstraint + "\",\"" +
PropagationConstraint.DELETE_PROPERTY + "\":\"" + deleteConstraint + "\"" +
@ -132,13 +133,13 @@ public class PropagationConstraintTest {
"\"" + ConsistsOf.SOURCE_PROPERTY + "\":{" +
"\"" + IdentifiableElement.ID_PROPERTY + "\":\"4a971915-ca90-48cf-9975-63ee2dd28605\"," +
"\"" + Element.TYPE_PROPERTY + "\":\"MyEService\"," +
"\"" + Element.SUPERTYPES_PROPERTY + "\":[\"EService\", \"Service\", \"Resource\"]," +
"\"" + ERElement.SUPERTYPES_PROPERTY + "\":[\"EService\", \"Service\", \"Resource\"]," +
"\"" + ConsistsOf.METADATA_PROPERTY + "\": " + hString +
"}," +
"\"" + ConsistsOf.TARGET_PROPERTY + "\":{" +
"\"" + IdentifiableElement.ID_PROPERTY + "\":\"3ace4bd0-e5cd-49a3-97a8-a0a9468ce6d4\"," +
"\"" + Element.TYPE_PROPERTY + "\":\"MySoftwareFacet\"," +
"\"" + Element.SUPERTYPES_PROPERTY + "\":[\"SoftwareFacet\", \"Facet\"]," +
"\"" + ERElement.SUPERTYPES_PROPERTY + "\":[\"SoftwareFacet\", \"Facet\"]," +
"\"" + ConsistsOf.METADATA_PROPERTY + "\": " + hString + "," +
"\"name\":\"WhnManager\"," +
"\"group\":\"VREManagement\"," +