Improved IS Model Organization
This commit is contained in:
parent
05787952be
commit
c48eae1355
|
@ -4,7 +4,6 @@
|
||||||
package org.gcube.informationsystem.base.impl;
|
package org.gcube.informationsystem.base.impl;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
import org.gcube.informationsystem.base.reference.Element;
|
||||||
|
@ -22,24 +21,12 @@ public class ElementImpl implements Element {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 7338083489551084860L;
|
private static final long serialVersionUID = 7338083489551084860L;
|
||||||
|
|
||||||
protected List<String> supertypes;
|
|
||||||
protected String expectedtype;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTypeName() {
|
public String getTypeName() {
|
||||||
return TypeUtility.getTypeName(this.getClass());
|
return TypeUtility.getTypeName(this.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getSupertypes() {
|
|
||||||
return this.supertypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getExpectedtype() {
|
|
||||||
return this.expectedtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
StringWriter stringWriter = new StringWriter();
|
StringWriter stringWriter = new StringWriter();
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.informationsystem.base.impl.properties;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -24,6 +25,9 @@ public class PropertyElementImpl extends ElementImpl implements Property {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1396998430221747445L;
|
private static final long serialVersionUID = 1396998430221747445L;
|
||||||
|
|
||||||
|
protected List<String> supertypes;
|
||||||
|
protected String expectedtype;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
protected Map<String, Object> additionalProperties;
|
protected Map<String, Object> additionalProperties;
|
||||||
|
|
||||||
|
@ -40,6 +44,17 @@ public class PropertyElementImpl extends ElementImpl implements Property {
|
||||||
this.allowedAdditionalKeys.add(SUPERTYPES_PROPERTY);
|
this.allowedAdditionalKeys.add(SUPERTYPES_PROPERTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getSupertypes() {
|
||||||
|
return this.supertypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExpectedtype() {
|
||||||
|
return this.expectedtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getAdditionalProperties() {
|
public Map<String, Object> getAdditionalProperties() {
|
||||||
return additionalProperties;
|
return additionalProperties;
|
||||||
|
|
|
@ -4,12 +4,8 @@
|
||||||
package org.gcube.informationsystem.base.reference;
|
package org.gcube.informationsystem.base.reference;
|
||||||
|
|
||||||
import java.io.Serializable;
|
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.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.JsonPropertyOrder;
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeInfo;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||||
|
@ -21,7 +17,7 @@ import org.gcube.informationsystem.utils.Version;
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@Abstract
|
@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)
|
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = Element.TYPE_PROPERTY)
|
||||||
// @JsonTypeIdResolver(ElementTypeIdResolver.class)
|
// @JsonTypeIdResolver(ElementTypeIdResolver.class)
|
||||||
@TypeMetadata(name = Element.NAME, description = "This is the base type for Element", version = Version.MINIMAL_VERSION_STRING)
|
@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 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
|
* DateTime Pattern to be used to serialize Dates in every element
|
||||||
*/
|
*/
|
||||||
|
@ -49,12 +36,4 @@ public interface Element extends Serializable {
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public String getTypeName();
|
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();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
*
|
*
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @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 interface IdentifiableElement extends Element {
|
||||||
|
|
||||||
public static final String ID_PROPERTY = "id";
|
public static final String ID_PROPERTY = "id";
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.gcube.informationsystem.utils.Version;
|
||||||
*/
|
*/
|
||||||
@Abstract
|
@Abstract
|
||||||
@JsonIgnoreProperties(ignoreUnknown=true)
|
@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
|
//@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)
|
@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)
|
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.informationsystem.model.impl.entities;
|
package org.gcube.informationsystem.model.impl.entities;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -23,6 +24,8 @@ public abstract class EntityImpl extends EntityElementImpl implements Entity {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -4488771434017342703L;
|
private static final long serialVersionUID = -4488771434017342703L;
|
||||||
|
|
||||||
|
protected List<String> supertypes;
|
||||||
|
protected String expectedtype;
|
||||||
protected Map<UUID,String> contexts;
|
protected Map<UUID,String> contexts;
|
||||||
|
|
||||||
protected EntityImpl(){
|
protected EntityImpl(){
|
||||||
|
@ -30,6 +33,16 @@ public abstract class EntityImpl extends EntityElementImpl implements Entity {
|
||||||
this.metadata = null;
|
this.metadata = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getSupertypes() {
|
||||||
|
return this.supertypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExpectedtype() {
|
||||||
|
return this.expectedtype;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<UUID,String> getContexts(){
|
public Map<UUID,String> getContexts(){
|
||||||
return this.contexts;
|
return this.contexts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Set;
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
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.entities.Facet;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||||
|
@ -39,7 +40,8 @@ public abstract class FacetImpl extends EntityImpl implements Facet {
|
||||||
super();
|
super();
|
||||||
this.additionalProperties = new HashMap<>();
|
this.additionalProperties = new HashMap<>();
|
||||||
this.allowedAdditionalKeys = new HashSet<>();
|
this.allowedAdditionalKeys = new HashSet<>();
|
||||||
this.allowedAdditionalKeys.add(SUPERTYPES_PROPERTY);
|
this.allowedAdditionalKeys.add(ModelElement.SUPERTYPES_PROPERTY);
|
||||||
|
this.allowedAdditionalKeys.add(ModelElement.EXPECTED_TYPE_PROPERTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.informationsystem.model.impl.relations;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -34,6 +35,8 @@ public abstract class RelationImpl<S extends Resource, T extends Entity>
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -6249979476879235053L;
|
private static final long serialVersionUID = -6249979476879235053L;
|
||||||
|
|
||||||
|
protected List<String> supertypes;
|
||||||
|
protected String expectedtype;
|
||||||
protected Map<UUID,String> contexts;
|
protected Map<UUID,String> contexts;
|
||||||
|
|
||||||
protected PropagationConstraint propagationConstraint;
|
protected PropagationConstraint propagationConstraint;
|
||||||
|
@ -61,6 +64,17 @@ public abstract class RelationImpl<S extends Resource, T extends Entity>
|
||||||
this.propagationConstraint = propagationConstraint;
|
this.propagationConstraint = propagationConstraint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getSupertypes() {
|
||||||
|
return this.supertypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExpectedtype() {
|
||||||
|
return this.expectedtype;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<UUID,String> getContexts(){
|
public Map<UUID,String> getContexts(){
|
||||||
return this.contexts;
|
return this.contexts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
|
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.JsonInclude.Include;
|
||||||
|
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||||
*
|
*
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @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 })
|
@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 {
|
public interface ERElement extends IdentifiableElement, ModelElement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used when requested to include contexts in metadata.
|
* Used when requested to include contexts in metadata.
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||||
import org.gcube.informationsystem.model.reference.ERElement;
|
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.annotations.Abstract;
|
||||||
import org.gcube.informationsystem.types.reference.Change;
|
import org.gcube.informationsystem.types.reference.Change;
|
||||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||||
|
@ -19,7 +20,7 @@ import org.gcube.informationsystem.utils.Version;
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@Abstract
|
@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
|
//@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)
|
@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)
|
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||||
|
|
|
@ -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.Element;
|
||||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||||
import org.gcube.informationsystem.model.reference.ERElement;
|
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.ConsistsOf;
|
||||||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
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.ResourceSchema;
|
||||||
import org.gcube.informationsystem.types.annotations.ResourceSchemaEntry;
|
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.Change;
|
||||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||||
import org.gcube.informationsystem.utils.Version;
|
import org.gcube.informationsystem.utils.Version;
|
||||||
|
@ -29,7 +30,7 @@ import org.gcube.informationsystem.utils.Version;
|
||||||
*/
|
*/
|
||||||
@Abstract
|
@Abstract
|
||||||
@JsonIgnoreProperties(ignoreUnknown=true)
|
@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
|
// @JsonDeserialize(as=ResourceImpl.class) Do not uncomment to manage subclasses
|
||||||
@ResourceSchema(
|
@ResourceSchema(
|
||||||
facets={
|
facets={
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.base.reference.SchemaMixedElement;
|
import org.gcube.informationsystem.base.reference.SchemaMixedElement;
|
||||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||||
import org.gcube.informationsystem.model.impl.properties.PropertyImpl;
|
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.serialization.AdditionalPropertiesSerializer;
|
||||||
import org.gcube.informationsystem.types.reference.Change;
|
import org.gcube.informationsystem.types.reference.Change;
|
||||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||||
|
@ -26,11 +27,11 @@ import org.gcube.informationsystem.utils.Version;
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
// @JsonIgnoreProperties(ignoreUnknown=true)
|
// @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)
|
@JsonDeserialize(as=PropertyImpl.class)
|
||||||
@TypeMetadata(name = Property.NAME, description = "This is the base type for any Property", version = Version.MINIMAL_VERSION_STRING)
|
@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)
|
@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();
|
public static final String NAME = "Property"; //Property.class.getSimpleName();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||||
import org.gcube.informationsystem.base.reference.SchemaMixedElement;
|
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.ERElement;
|
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.Entity;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
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
|
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#Relation
|
||||||
*/
|
*/
|
||||||
@Abstract
|
@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
|
// @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)
|
@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)
|
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||||
|
|
|
@ -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.com.fasterxml.jackson.databind.node.TextNode;
|
||||||
import org.gcube.informationsystem.base.reference.AccessType;
|
import org.gcube.informationsystem.base.reference.AccessType;
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
import org.gcube.informationsystem.base.reference.Element;
|
||||||
|
import org.gcube.informationsystem.model.reference.ModelElement;
|
||||||
import org.gcube.informationsystem.types.TypeMapper;
|
import org.gcube.informationsystem.types.TypeMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,13 +61,13 @@ public class ElementDeserializer<ISM extends Element> extends StdDeserializer<IS
|
||||||
List<TextNode> toBeKeepSuperClasses = new ArrayList<>();
|
List<TextNode> toBeKeepSuperClasses = new ArrayList<>();
|
||||||
|
|
||||||
ObjectNode objectNode = (ObjectNode) treeNode;
|
ObjectNode objectNode = (ObjectNode) treeNode;
|
||||||
if(!objectNode.has(Element.EXPECTED_TYPE_PROPERTY)) {
|
if(!objectNode.has(ModelElement.EXPECTED_TYPE_PROPERTY)) {
|
||||||
objectNode.set(Element.EXPECTED_TYPE_PROPERTY, objectNode.get(Element.TYPE_PROPERTY));
|
objectNode.set(ModelElement.EXPECTED_TYPE_PROPERTY, objectNode.get(Element.TYPE_PROPERTY));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JsonNode superClassesTreeNode = objectNode
|
JsonNode superClassesTreeNode = objectNode
|
||||||
.get(Element.SUPERTYPES_PROPERTY);
|
.get(ModelElement.SUPERTYPES_PROPERTY);
|
||||||
if (superClassesTreeNode != null
|
if (superClassesTreeNode != null
|
||||||
&& superClassesTreeNode.isArray()) {
|
&& superClassesTreeNode.isArray()) {
|
||||||
ArrayNode arrayNode = (ArrayNode) superClassesTreeNode;
|
ArrayNode arrayNode = (ArrayNode) superClassesTreeNode;
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.gcube.informationsystem.base.reference.AccessType;
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.discovery.Discovery;
|
import org.gcube.informationsystem.discovery.Discovery;
|
||||||
import org.gcube.informationsystem.discovery.knowledge.Knowledge;
|
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.TypeMapper;
|
||||||
import org.gcube.informationsystem.types.reference.Type;
|
import org.gcube.informationsystem.types.reference.Type;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -195,14 +196,14 @@ public abstract class ElementMapper {
|
||||||
StringBuffer stringBuffer = new StringBuffer();
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
stringBuffer.append(unknownType);
|
stringBuffer.append(unknownType);
|
||||||
stringBuffer.append(" is an unknown type. Please provide ");
|
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.");
|
stringBuffer.append(" property as string array to allow to instantiate the most appropriated class.");
|
||||||
return stringBuffer;
|
return stringBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static ObjectNode setTypeToBestAvailable(ObjectNode objectNode) {
|
protected static ObjectNode setTypeToBestAvailable(ObjectNode objectNode) {
|
||||||
String unknownType = objectNode.get(Element.TYPE_PROPERTY).asText();
|
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;
|
String candidatedSupertype = null;
|
||||||
for(int i = 0; i < arrayNode.size(); i++) {
|
for(int i = 0; i < arrayNode.size(); i++) {
|
||||||
|
@ -227,11 +228,11 @@ public abstract class ElementMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(candidatedSupertype!=null) {
|
if(candidatedSupertype!=null) {
|
||||||
if(!objectNode.has(Element.EXPECTED_TYPE_PROPERTY)) {
|
if(!objectNode.has(ModelElement.EXPECTED_TYPE_PROPERTY)) {
|
||||||
objectNode.set(Element.EXPECTED_TYPE_PROPERTY, objectNode.get(Element.TYPE_PROPERTY));
|
objectNode.set(ModelElement.EXPECTED_TYPE_PROPERTY, objectNode.get(Element.TYPE_PROPERTY));
|
||||||
}
|
}
|
||||||
objectNode.set(Element.TYPE_PROPERTY, new TextNode(candidatedSupertype));
|
objectNode.set(Element.TYPE_PROPERTY, new TextNode(candidatedSupertype));
|
||||||
objectNode.remove(Element.SUPERTYPES_PROPERTY);
|
objectNode.remove(ModelElement.SUPERTYPES_PROPERTY);
|
||||||
return objectNode;
|
return objectNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,6 +306,9 @@ public abstract class ElementMapper {
|
||||||
try {
|
try {
|
||||||
return mapper.readValue(reader, clz);
|
return mapper.readValue(reader, clz);
|
||||||
} catch (JsonMappingException e) {
|
} catch (JsonMappingException e) {
|
||||||
|
if(!ModelElement.class.isAssignableFrom(clz)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
JsonNode jsonNode = mapper.readTree(reader);
|
JsonNode jsonNode = mapper.readTree(reader);
|
||||||
jsonNode = analizeTypes((ObjectNode) jsonNode);
|
jsonNode = analizeTypes((ObjectNode) jsonNode);
|
||||||
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
|
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
|
||||||
|
@ -326,6 +330,9 @@ public abstract class ElementMapper {
|
||||||
try {
|
try {
|
||||||
return mapper.readValue(stream, clz);
|
return mapper.readValue(stream, clz);
|
||||||
} catch (JsonMappingException e) {
|
} catch (JsonMappingException e) {
|
||||||
|
if(!ModelElement.class.isAssignableFrom(clz)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
JsonNode jsonNode = mapper.readTree(stream);
|
JsonNode jsonNode = mapper.readTree(stream);
|
||||||
jsonNode = analizeTypes((ObjectNode) jsonNode);
|
jsonNode = analizeTypes((ObjectNode) jsonNode);
|
||||||
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
|
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
|
||||||
|
@ -346,6 +353,9 @@ public abstract class ElementMapper {
|
||||||
try {
|
try {
|
||||||
return mapper.readValue(string, clz);
|
return mapper.readValue(string, clz);
|
||||||
} catch (JsonMappingException e) {
|
} catch (JsonMappingException e) {
|
||||||
|
if(!ModelElement.class.isAssignableFrom(clz)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
JsonNode jsonNode = mapper.readTree(string);
|
JsonNode jsonNode = mapper.readTree(string);
|
||||||
jsonNode = analizeTypes((ObjectNode) jsonNode);
|
jsonNode = analizeTypes((ObjectNode) jsonNode);
|
||||||
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
|
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
|
||||||
|
@ -358,6 +368,9 @@ public abstract class ElementMapper {
|
||||||
try {
|
try {
|
||||||
return mapper.readValue(string, type);
|
return mapper.readValue(string, type);
|
||||||
} catch (JsonMappingException e) {
|
} catch (JsonMappingException e) {
|
||||||
|
if(!ModelElement.class.isAssignableFrom(clz)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
List<El> ret = new ArrayList<>();
|
List<El> ret = new ArrayList<>();
|
||||||
ArrayNode arrayNode = (ArrayNode) mapper.readTree(string);
|
ArrayNode arrayNode = (ArrayNode) mapper.readTree(string);
|
||||||
for(JsonNode jsonNode : arrayNode) {
|
for(JsonNode jsonNode : arrayNode) {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.TypeVariable;
|
import java.lang.reflect.TypeVariable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
@ -62,8 +61,6 @@ public class TypeImpl implements Type {
|
||||||
|
|
||||||
protected UUID uuid;
|
protected UUID uuid;
|
||||||
protected Metadata metadata;
|
protected Metadata metadata;
|
||||||
protected List<String> supertypes;
|
|
||||||
protected String expectedtype;
|
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
protected String description;
|
protected String description;
|
||||||
|
@ -78,7 +75,7 @@ public class TypeImpl implements Type {
|
||||||
@JsonProperty(value = FINAL_PROPERTY)
|
@JsonProperty(value = FINAL_PROPERTY)
|
||||||
protected boolean finalClass;
|
protected boolean finalClass;
|
||||||
|
|
||||||
protected Set<String> typeSuperTypes;
|
protected Set<String> extendedTypes;
|
||||||
|
|
||||||
protected Set<PropertyDefinition> properties;
|
protected Set<PropertyDefinition> properties;
|
||||||
|
|
||||||
|
@ -278,8 +275,8 @@ public class TypeImpl implements Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getTypeSuperTypes() {
|
public Set<String> getExtendedTypes() {
|
||||||
return typeSuperTypes;
|
return extendedTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonInclude(Include.NON_EMPTY)
|
@JsonInclude(Include.NON_EMPTY)
|
||||||
|
@ -298,14 +295,4 @@ public class TypeImpl implements Type {
|
||||||
return TypeUtility.getTypeName(this.getClass());
|
return TypeUtility.getTypeName(this.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getSupertypes() {
|
|
||||||
return this.supertypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getExpectedtype() {
|
|
||||||
return this.expectedtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,17 +66,17 @@ public class EntityTypeImpl extends TypeImpl implements EntityType {
|
||||||
if(EntityType.class.isAssignableFrom(clz)){
|
if(EntityType.class.isAssignableFrom(clz)){
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<? extends EntityType> c = (Class<? extends EntityType>) clz;
|
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)){
|
} else if(Context.class.isAssignableFrom(clz)){
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<? extends Context> c = (Class<? extends Context>) clz;
|
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)){
|
} else if(QueryTemplate.class.isAssignableFrom(clz)){
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<? extends QueryTemplate> c = (Class<? extends QueryTemplate>) clz;
|
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)){
|
} else if(EntityElement.class.isAssignableFrom(clz)){
|
||||||
this.typeSuperTypes = retrieveSuperClasses(clz, EntityElement.class, null);
|
this.extendedTypes = retrieveSuperClasses(clz, EntityElement.class, null);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Type Hierachy Error for class " + clz.getSimpleName());
|
throw new RuntimeException("Type Hierachy Error for class " + clz.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public final class FacetTypeImpl extends EntityTypeImpl implements FacetType {
|
||||||
|
|
||||||
public FacetTypeImpl(Class<? extends Facet> clz) {
|
public FacetTypeImpl(Class<? extends Facet> clz) {
|
||||||
super(clz);
|
super(clz);
|
||||||
this.typeSuperTypes = retrieveSuperClasses(clz, Facet.class, Entity.NAME);
|
this.extendedTypes = retrieveSuperClasses(clz, Facet.class, Entity.NAME);
|
||||||
this.properties = retrieveListOfProperties(clz);
|
this.properties = retrieveListOfProperties(clz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public final class ResourceTypeImpl extends EntityTypeImpl implements ResourceTy
|
||||||
public ResourceTypeImpl(Class<? extends Resource> clz) {
|
public ResourceTypeImpl(Class<? extends Resource> clz) {
|
||||||
super(clz);
|
super(clz);
|
||||||
|
|
||||||
this.typeSuperTypes = retrieveSuperClasses(clz, Resource.class, Entity.NAME);
|
this.extendedTypes = retrieveSuperClasses(clz, Resource.class, Entity.NAME);
|
||||||
|
|
||||||
setResourceSchemaEntries(clz);
|
setResourceSchemaEntries(clz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package org.gcube.informationsystem.types.impl.properties;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
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 URI_REGEX = null;
|
||||||
public final static String URL_REGEX = null;
|
public final static String URL_REGEX = null;
|
||||||
|
|
||||||
protected List<String> supertypes;
|
|
||||||
protected String expectedtype;
|
|
||||||
|
|
||||||
private String name= "";
|
private String name= "";
|
||||||
private String description= "";
|
private String description= "";
|
||||||
private boolean mandatory = false;
|
private boolean mandatory = false;
|
||||||
|
@ -291,14 +287,4 @@ public final class PropertyDefinitionImpl implements PropertyDefinition {
|
||||||
return TypeUtility.getTypeName(this.getClass());
|
return TypeUtility.getTypeName(this.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getSupertypes() {
|
|
||||||
return this.supertypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getExpectedtype() {
|
|
||||||
return this.expectedtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public final class PropertyTypeImpl<P extends PropertyElement> extends TypeImpl
|
||||||
|
|
||||||
public PropertyTypeImpl(Class<P> clz) {
|
public PropertyTypeImpl(Class<P> clz) {
|
||||||
super(clz);
|
super(clz);
|
||||||
this.typeSuperTypes = retrieveSuperClasses(clz, PropertyElement.class,
|
this.extendedTypes = retrieveSuperClasses(clz, PropertyElement.class,
|
||||||
clz == PropertyElement.class ? null : PropertyElement.NAME);
|
clz == PropertyElement.class ? null : PropertyElement.NAME);
|
||||||
|
|
||||||
this.properties = retrieveListOfProperties(clz);
|
this.properties = retrieveListOfProperties(clz);
|
||||||
|
|
|
@ -33,7 +33,7 @@ public final class ConsistsOfTypeImpl extends RelationTypeImpl<ResourceType, Fac
|
||||||
public ConsistsOfTypeImpl(Class<? extends ConsistsOf<? extends Resource, ? extends Facet>> clz) {
|
public ConsistsOfTypeImpl(Class<? extends ConsistsOf<? extends Resource, ? extends Facet>> clz) {
|
||||||
super(clz);
|
super(clz);
|
||||||
|
|
||||||
this.typeSuperTypes = retrieveSuperClasses(clz, ConsistsOf.class, Relation.NAME);
|
this.extendedTypes = retrieveSuperClasses(clz, ConsistsOf.class, Relation.NAME);
|
||||||
|
|
||||||
this.properties = retrieveListOfProperties(clz);
|
this.properties = retrieveListOfProperties(clz);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public final class IsRelatedToTypeImpl extends RelationTypeImpl<ResourceType, Re
|
||||||
public IsRelatedToTypeImpl(Class<? extends IsRelatedTo<? extends Resource, ? extends Resource>> clz) {
|
public IsRelatedToTypeImpl(Class<? extends IsRelatedTo<? extends Resource, ? extends Resource>> clz) {
|
||||||
super(clz);
|
super(clz);
|
||||||
|
|
||||||
this.typeSuperTypes = retrieveSuperClasses(clz, IsRelatedTo.class, Relation.NAME);
|
this.extendedTypes = retrieveSuperClasses(clz, IsRelatedTo.class, Relation.NAME);
|
||||||
|
|
||||||
this.properties = retrieveListOfProperties(clz);
|
this.properties = retrieveListOfProperties(clz);
|
||||||
|
|
||||||
|
|
|
@ -58,13 +58,13 @@ public class RelationTypeImpl<S extends EntityType, T extends EntityType>
|
||||||
if(RelationType.class.isAssignableFrom(clz)) {
|
if(RelationType.class.isAssignableFrom(clz)) {
|
||||||
@SuppressWarnings({"unchecked"})
|
@SuppressWarnings({"unchecked"})
|
||||||
Class<RelationType<?,?>> c = (Class<RelationType<?,?>>) clz;
|
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)) {
|
} else if(IsParentOf.class.isAssignableFrom(clz)) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<? extends IsParentOf> c = (Class<? extends IsParentOf>) clz;
|
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)) {
|
} else if(RelationElement.class.isAssignableFrom(clz)) {
|
||||||
this.typeSuperTypes = retrieveSuperClasses(clz, RelationElement.class, null);
|
this.extendedTypes = retrieveSuperClasses(clz, RelationElement.class, null);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Type Hierachy Error");
|
throw new RuntimeException("Type Hierachy Error");
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.gcube.informationsystem.utils.Version;
|
||||||
*/
|
*/
|
||||||
@Abstract
|
@Abstract
|
||||||
@JsonIgnoreProperties(ignoreUnknown=true)
|
@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)
|
@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)
|
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||||
//@JsonDeserialize(as=TypeImpl.class) Do not uncomment to manage subclasses
|
//@JsonDeserialize(as=TypeImpl.class) Do not uncomment to manage subclasses
|
||||||
|
@ -37,7 +37,7 @@ public interface Type extends IdentifiableElement {
|
||||||
public static final String ABSTRACT_PROPERTY = "abstract";
|
public static final String ABSTRACT_PROPERTY = "abstract";
|
||||||
public static final String FINAL_PROPERTY = "final";
|
public static final String FINAL_PROPERTY = "final";
|
||||||
/* Cannot use 'supertypes' which conflicts with Element */
|
/* 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";
|
public static final String PROPERTIES_PROPERTY = "properties";
|
||||||
|
|
||||||
@JsonGetter(value = ID_PROPERTY)
|
@JsonGetter(value = ID_PROPERTY)
|
||||||
|
@ -78,8 +78,8 @@ public interface Type extends IdentifiableElement {
|
||||||
@JsonGetter(value = FINAL_PROPERTY)
|
@JsonGetter(value = FINAL_PROPERTY)
|
||||||
public boolean isFinal();
|
public boolean isFinal();
|
||||||
|
|
||||||
@JsonGetter(value = TYPE_SUPER_TYPES_PROPERTY)
|
@JsonGetter(value = EXTENDED_TYPES_PROPERTY)
|
||||||
public Set<String> getTypeSuperTypes();
|
public Set<String> getExtendedTypes();
|
||||||
|
|
||||||
public Set<PropertyDefinition> getProperties();
|
public Set<PropertyDefinition> getProperties();
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,8 @@ public interface EntityType extends Type, EntityElement {
|
||||||
public boolean isAbstract();
|
public boolean isAbstract();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ISProperty(name = Type.TYPE_SUPER_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
@ISProperty(name = Type.EXTENDED_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||||
public Set<String> getTypeSuperTypes();
|
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 */
|
/* Type is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,8 @@ public interface PropertyType<P extends PropertyElement> extends PropertyElement
|
||||||
public boolean isAbstract();
|
public boolean isAbstract();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ISProperty(name = Type.TYPE_SUPER_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
@ISProperty(name = Type.EXTENDED_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||||
public Set<String> getTypeSuperTypes();
|
public Set<String> getExtendedTypes();
|
||||||
|
|
||||||
@ISProperty(name = Type.PROPERTIES_PROPERTY, readonly = false, mandatory = true, nullable = false)
|
@ISProperty(name = Type.PROPERTIES_PROPERTY, readonly = false, mandatory = true, nullable = false)
|
||||||
public Set<PropertyDefinition> getProperties();
|
public Set<PropertyDefinition> getProperties();
|
||||||
|
|
|
@ -41,8 +41,8 @@ public interface RelationType<S extends EntityType, T extends EntityType>
|
||||||
public boolean isAbstract();
|
public boolean isAbstract();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ISProperty(name = Type.TYPE_SUPER_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
@ISProperty(name = Type.EXTENDED_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||||
public Set<String> getTypeSuperTypes();
|
public Set<String> getExtendedTypes();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ISProperty(name = Type.PROPERTIES_PROPERTY, readonly = false, mandatory = true, nullable = false)
|
@ISProperty(name = Type.PROPERTIES_PROPERTY, readonly = false, mandatory = true, nullable = false)
|
||||||
|
|
|
@ -41,8 +41,8 @@ public class DiscoveryTest {
|
||||||
Assert.assertTrue(type.getDescription().compareTo(expected.getDescription())==0);
|
Assert.assertTrue(type.getDescription().compareTo(expected.getDescription())==0);
|
||||||
Assert.assertTrue(type.isAbstract() == expected.isAbstract());
|
Assert.assertTrue(type.isAbstract() == expected.isAbstract());
|
||||||
|
|
||||||
Assert.assertTrue(type.getTypeSuperTypes().containsAll(expected.getTypeSuperTypes()));
|
Assert.assertTrue(type.getExtendedTypes().containsAll(expected.getExtendedTypes()));
|
||||||
Assert.assertTrue(expected.getTypeSuperTypes().containsAll(type.getTypeSuperTypes()));
|
Assert.assertTrue(expected.getExtendedTypes().containsAll(type.getExtendedTypes()));
|
||||||
|
|
||||||
|
|
||||||
Map<Version, String> typeChangelog = type.getChangelog();
|
Map<Version, String> typeChangelog = type.getChangelog();
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Calendar;
|
||||||
|
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
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.Facet;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
||||||
|
@ -78,7 +79,7 @@ public class PropagationConstraintTest {
|
||||||
DeleteConstraint deleteConstraint = DeleteConstraint.keep;
|
DeleteConstraint deleteConstraint = DeleteConstraint.keep;
|
||||||
String marshalled = "{\"" +
|
String marshalled = "{\"" +
|
||||||
Element.TYPE_PROPERTY + "\":\"MyPropagationConstraint\",\"" +
|
Element.TYPE_PROPERTY + "\":\"MyPropagationConstraint\",\"" +
|
||||||
Element.SUPERTYPES_PROPERTY + "\":[\"" + PropagationConstraint.NAME + "\", \"" + Property.NAME + "\"],\"" +
|
ERElement.SUPERTYPES_PROPERTY + "\":[\"" + PropagationConstraint.NAME + "\", \"" + Property.NAME + "\"],\"" +
|
||||||
PropagationConstraint.ADD_PROPERTY + "\":\""+ addConstraint + "\",\""+
|
PropagationConstraint.ADD_PROPERTY + "\":\""+ addConstraint + "\",\""+
|
||||||
PropagationConstraint.REMOVE_PROPERTY + "\":\"" + removeConstraint + "\",\""+
|
PropagationConstraint.REMOVE_PROPERTY + "\":\"" + removeConstraint + "\",\""+
|
||||||
PropagationConstraint.DELETE_PROPERTY + "\":\"" + deleteConstraint +
|
PropagationConstraint.DELETE_PROPERTY + "\":\"" + deleteConstraint +
|
||||||
|
@ -109,7 +110,7 @@ public class PropagationConstraintTest {
|
||||||
|
|
||||||
String pcString = "{" +
|
String pcString = "{" +
|
||||||
"\"" + Element.TYPE_PROPERTY + "\":\"My" + PropagationConstraint.NAME + "\"," +
|
"\"" + 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.ADD_PROPERTY + "\":\""+ addConstraint + "\",\"" +
|
||||||
PropagationConstraint.REMOVE_PROPERTY + "\":\"" + removeConstraint + "\",\"" +
|
PropagationConstraint.REMOVE_PROPERTY + "\":\"" + removeConstraint + "\",\"" +
|
||||||
PropagationConstraint.DELETE_PROPERTY + "\":\"" + deleteConstraint + "\"" +
|
PropagationConstraint.DELETE_PROPERTY + "\":\"" + deleteConstraint + "\"" +
|
||||||
|
@ -132,13 +133,13 @@ public class PropagationConstraintTest {
|
||||||
"\"" + ConsistsOf.SOURCE_PROPERTY + "\":{" +
|
"\"" + ConsistsOf.SOURCE_PROPERTY + "\":{" +
|
||||||
"\"" + IdentifiableElement.ID_PROPERTY + "\":\"4a971915-ca90-48cf-9975-63ee2dd28605\"," +
|
"\"" + IdentifiableElement.ID_PROPERTY + "\":\"4a971915-ca90-48cf-9975-63ee2dd28605\"," +
|
||||||
"\"" + Element.TYPE_PROPERTY + "\":\"MyEService\"," +
|
"\"" + Element.TYPE_PROPERTY + "\":\"MyEService\"," +
|
||||||
"\"" + Element.SUPERTYPES_PROPERTY + "\":[\"EService\", \"Service\", \"Resource\"]," +
|
"\"" + ERElement.SUPERTYPES_PROPERTY + "\":[\"EService\", \"Service\", \"Resource\"]," +
|
||||||
"\"" + ConsistsOf.METADATA_PROPERTY + "\": " + hString +
|
"\"" + ConsistsOf.METADATA_PROPERTY + "\": " + hString +
|
||||||
"}," +
|
"}," +
|
||||||
"\"" + ConsistsOf.TARGET_PROPERTY + "\":{" +
|
"\"" + ConsistsOf.TARGET_PROPERTY + "\":{" +
|
||||||
"\"" + IdentifiableElement.ID_PROPERTY + "\":\"3ace4bd0-e5cd-49a3-97a8-a0a9468ce6d4\"," +
|
"\"" + IdentifiableElement.ID_PROPERTY + "\":\"3ace4bd0-e5cd-49a3-97a8-a0a9468ce6d4\"," +
|
||||||
"\"" + Element.TYPE_PROPERTY + "\":\"MySoftwareFacet\"," +
|
"\"" + Element.TYPE_PROPERTY + "\":\"MySoftwareFacet\"," +
|
||||||
"\"" + Element.SUPERTYPES_PROPERTY + "\":[\"SoftwareFacet\", \"Facet\"]," +
|
"\"" + ERElement.SUPERTYPES_PROPERTY + "\":[\"SoftwareFacet\", \"Facet\"]," +
|
||||||
"\"" + ConsistsOf.METADATA_PROPERTY + "\": " + hString + "," +
|
"\"" + ConsistsOf.METADATA_PROPERTY + "\": " + hString + "," +
|
||||||
"\"name\":\"WhnManager\"," +
|
"\"name\":\"WhnManager\"," +
|
||||||
"\"group\":\"VREManagement\"," +
|
"\"group\":\"VREManagement\"," +
|
||||||
|
|
Loading…
Reference in New Issue