Changed '@class' to 'type'

This commit is contained in:
Luca Frosini 2023-04-26 21:39:57 +02:00
parent 4562d463e8
commit 49c04191db
23 changed files with 36 additions and 34 deletions

View File

@ -17,13 +17,13 @@ import org.gcube.informationsystem.utils.Version;
@Abstract
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = Element.CLASS_PROPERTY)
// @JsonTypeIdResolver(ElementTypeIdResolver.class)
@TypeMetadata(name = Element.NAME, description = "This is the base class for Element", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = Element.NAME, description = "This is the base type for Element", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public interface Element extends Serializable {
public static final String NAME = "Element"; //Element.class.getSimpleName();
public static final String CLASS_PROPERTY = "@class";
public static final String CLASS_PROPERTY = "type";
public static final String SUPERCLASSES_PROPERTY = "@superClasses";

View File

@ -20,7 +20,7 @@ import org.gcube.informationsystem.utils.Version;
@Abstract
@JsonIgnoreProperties(ignoreUnknown=true)
//@JsonDeserialize(as=EntityElementImpl.class) Do not uncomment to manage subclasses
@TypeMetadata(name = EntityElement.NAME, description = "This is the base class 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)
public interface EntityElement extends Element, IdentifiableElement {

View File

@ -14,7 +14,7 @@ import org.gcube.informationsystem.utils.Version;
* @author Luca Frosini (ISTI - CNR)
*/
@JsonDeserialize(as=PropertyElementImpl.class)
@TypeMetadata(name = PropertyElement.NAME, description = "This is the base class for any PropertyElement", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = PropertyElement.NAME, description = "This is the base type for any PropertyElement", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public interface PropertyElement extends Element {

View File

@ -20,7 +20,7 @@ import org.gcube.informationsystem.utils.Version;
*/
@Abstract
//@JsonDeserialize(as=RelationElementImpl.class) Do not uncomment to manage subclasses
@TypeMetadata(name = RelationElement.NAME, description = "This is the base class for any RelationElement", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = RelationElement.NAME, description = "This is the base type for any RelationElement", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public interface RelationElement<S extends EntityElement, T extends EntityElement> extends Element, IdentifiableElement {

View File

@ -25,7 +25,7 @@ import org.gcube.informationsystem.utils.Version;
* @author Luca Frosini (ISTI - CNR)
*/
@JsonDeserialize(as = ContextImpl.class)
@TypeMetadata(name = Context.NAME, description = "This class is the used to define a Context", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = Context.NAME, description = "This type is the used to define a Context", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public interface Context extends EntityElement {

View File

@ -20,7 +20,7 @@ import org.gcube.informationsystem.utils.Version;
* @author Luca Frosini (ISTI - CNR)
*/
@JsonDeserialize(as = IsParentOfImpl.class)
@TypeMetadata(name = IsParentOf.NAME, description = "This class is the used to define parental relations between Context", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = IsParentOf.NAME, description = "This type is the used to define parental relations between Context", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public interface IsParentOf extends RelationElement<Context,Context> {

View File

@ -14,7 +14,7 @@ import org.gcube.informationsystem.utils.Version;
/**
* @author Luca Frosini (ISTI - CNR)
*/
@TypeMetadata(name = Facet.NAME, description = "This is a dummy class for Facet", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = Facet.NAME, description = "This is a dummy type for Facet", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public class DummyFacet extends FacetImpl implements Facet {

View File

@ -14,7 +14,7 @@ import org.gcube.informationsystem.utils.Version;
/**
* @author Luca Frosini (ISTI - CNR)
*/
@TypeMetadata(name = Resource.NAME, description = "This is a dummy class for Resource", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = Resource.NAME, description = "This is a dummy type for Resource", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public class DummyResource extends ResourceImpl implements Resource {

View File

@ -13,7 +13,7 @@ import org.gcube.informationsystem.utils.Version;
/**
* @author Luca Frosini (ISTI - CNR)
*/
@TypeMetadata(name = IsRelatedTo.NAME, description = "This is a dummy class for IsRelatedTo", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = IsRelatedTo.NAME, description = "This is a dummy type for IsRelatedTo", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public class DummyIsRelatedTo<S extends Resource, T extends Resource>
extends IsRelatedToImpl<S, T> implements IsRelatedTo<S, T>{

View File

@ -156,12 +156,12 @@ public final class PropertyDefinitionImpl implements PropertyDefinition {
}
@Override
public String getType() {
public String getPropertyType() {
return propertyTypeName.toString();
}
@JsonSetter(value = PropertyDefinition.TYPE_PROPERTY)
public void setType(String type) {
@JsonSetter(value = PropertyDefinition.PROPERTY_TYPE_PROPERTY)
public void setPropertyType(String type) {
this.propertyTypeName = new PropertyTypeName(type);
}

View File

@ -20,7 +20,7 @@ import org.gcube.informationsystem.utils.Version;
*/
@Abstract
@JsonIgnoreProperties(ignoreUnknown=true)
@TypeMetadata(name = Type.NAME, description = "This is the base class 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)
//@JsonDeserialize(as=TypeImpl.class) Do not uncomment to manage subclasses
public interface Type extends IdentifiableElement {

View File

@ -17,7 +17,7 @@ import org.gcube.informationsystem.utils.Version;
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonDeserialize(as = EntityTypeImpl.class)
@TypeMetadata(name = EntityType.NAME, description = "This class provides information for any EntityType", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = EntityType.NAME, description = "This type provides information for any EntityType", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public interface EntityType extends Type, EntityElement {

View File

@ -18,7 +18,7 @@ import org.gcube.informationsystem.utils.Version;
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonDeserialize(as = FacetTypeImpl.class)
@TypeMetadata(name = FacetType.NAME, description = "This class provides information for the definition of any FacetType", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = FacetType.NAME, description = "This type provides information for the definition of any FacetType", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface FacetType extends EntityType {

View File

@ -15,7 +15,7 @@ import org.gcube.informationsystem.utils.Version;
* @author Luca Frosini (ISTI - CNR)
*/
@JsonDeserialize(as=ResourceTypeImpl.class)
@TypeMetadata(name = ResourceType.NAME, description = "This class provides information for the definition of any ResourceType", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = ResourceType.NAME, description = "This type provides information for the definition of any ResourceType", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface ResourceType extends EntityType {

View File

@ -15,7 +15,7 @@ import org.gcube.informationsystem.utils.Version;
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonDeserialize(as = PropertyDefinitionImpl.class)
@TypeMetadata(name = PropertyDefinition.NAME, description = "This class provides information for the definition of any properties", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = PropertyDefinition.NAME, description = "This type provides information for the definition of any properties", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface PropertyDefinition extends PropertyElement, Comparable<PropertyDefinition> {
@ -30,7 +30,7 @@ public interface PropertyDefinition extends PropertyElement, Comparable<Property
public static final String MAX_PROPERTY = "max";
public static final String MIN_PROPERTY = "min";
public static final String REGEX_PROPERTY = "regexp";
public static final String TYPE_PROPERTY = "type";
public static final String PROPERTY_TYPE_PROPERTY = "propertyType";
@ISProperty(name = NAME_PROPERTY, readonly = true, mandatory = true, nullable = false)
public String getName();
@ -56,7 +56,7 @@ public interface PropertyDefinition extends PropertyElement, Comparable<Property
@ISProperty(name = REGEX_PROPERTY, readonly = false, mandatory = true, nullable = false)
public String getRegexp();
@ISProperty(name = TYPE_PROPERTY, readonly = false, mandatory = true, nullable = false)
public String getType();
@ISProperty(name = PROPERTY_TYPE_PROPERTY, readonly = false, mandatory = true, nullable = false)
public String getPropertyType();
}

View File

@ -22,7 +22,7 @@ import org.gcube.informationsystem.utils.Version;
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonDeserialize(as = PropertyTypeImpl.class)
@TypeMetadata(name = PropertyType.NAME, description = "This class provides information for any PropertyType", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = PropertyType.NAME, description = "This type provides information for any PropertyType", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface PropertyType<P extends PropertyElement> extends PropertyElement, Type {

View File

@ -13,7 +13,7 @@ import org.gcube.informationsystem.utils.Version;
* @author Luca Frosini (ISTI - CNR)
*/
@JsonDeserialize(as = ConsistsOfTypeImpl.class)
@TypeMetadata(name = ConsistsOfType.NAME, description = "This class provides information for any ConsistsOfType", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = ConsistsOfType.NAME, description = "This type provides information for any ConsistsOfType", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface ConsistsOfType extends RelationType<ResourceType, FacetType> {

View File

@ -12,7 +12,7 @@ import org.gcube.informationsystem.utils.Version;
* @author Luca Frosini (ISTI - CNR)
*/
@JsonDeserialize(as = IsRelatedToTypeImpl.class)
@TypeMetadata(name = IsRelatedToType.NAME, description = "This class provides information for any IsRelatedToType", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = IsRelatedToType.NAME, description = "This type provides information for any IsRelatedToType", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface IsRelatedToType extends RelationType<ResourceType, ResourceType> {

View File

@ -19,7 +19,7 @@ import org.gcube.informationsystem.utils.Version;
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonDeserialize(as = RelationTypeImpl.class)
@TypeMetadata(name = RelationType.NAME, description = "This class provides information for any RelationType", version = Version.MINIMAL_VERSION_STRING)
@TypeMetadata(name = RelationType.NAME, description = "This type provides information for any RelationType", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public interface RelationType<S extends EntityType, T extends EntityType>
extends Type, RelationElement<S,T> {

View File

@ -82,7 +82,7 @@ public class DiscoveryTest {
for(PropertyDefinition propertyDefinition : type.getProperties()) {
if(propertyDefinition.getName().compareTo(PropertyType.PROPERTIES_PROPERTY)==0) {
logger.debug("{}", propertyDefinition);
Assert.assertTrue(propertyDefinition.getType().compareTo("Set<PropertyDefinition>")==0);
Assert.assertTrue(propertyDefinition.getPropertyType().compareTo("Set<PropertyDefinition>")==0);
}
}
String typeDefinitionJsonString = TypeMapper.serializeTypeDefinition(type);

View File

@ -7,6 +7,7 @@ import java.util.Map;
import org.gcube.com.fasterxml.jackson.core.JsonParseException;
import org.gcube.com.fasterxml.jackson.databind.JsonMappingException;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.model.reference.properties.Metadata;
import org.gcube.informationsystem.model.reference.properties.Property;
import org.gcube.informationsystem.serialization.ElementMapper;
@ -53,7 +54,7 @@ public class MetadataTest {
String metadataJson =
"{"
+ "\"@class\":\"Metadata\","
+ "\"" + Element.CLASS_PROPERTY + "\":\"Metadata\","
+ "\"createdBy\":\"UNKNOWN_USER\","
+ "\"lastUpdateBy\":\"UNKNOWN_USER\","
+ "\"creationTime\":\"2020-11-09 10:01:25.415 +0000\","

View File

@ -1,6 +1,7 @@
package org.gcube.informationsystem.types;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.base.reference.entities.EntityElement;
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
import org.gcube.informationsystem.contexts.reference.entities.Context;
@ -8,10 +9,10 @@ import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
import org.gcube.informationsystem.model.reference.entities.Entity;
import org.gcube.informationsystem.model.reference.entities.Facet;
import org.gcube.informationsystem.model.reference.entities.Resource;
import org.gcube.informationsystem.model.reference.properties.Encrypted;
import org.gcube.informationsystem.model.reference.properties.Metadata;
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
import org.gcube.informationsystem.model.reference.properties.Property;
import org.gcube.informationsystem.model.reference.properties.Encrypted;
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
import org.gcube.informationsystem.model.reference.relations.Relation;
@ -206,7 +207,7 @@ public class SerializationTest {
logger.debug("Version {}", typeVersion.toString());
logger.info(ElementMapper.marshal(propertyType));
String json = "{\"@class\":\"PropertyType\",\"metadata\":null,\"name\":\"Metadata\",\"description\":\"This class provides metadata per every IdentifiableElement\",\"superClasses\":[\"Property\"],\"properties\":[{\"@class\":\"PropertyDefinition\",\"name\":\"creationTime\",\"description\":\"Creation time. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"Date\"},{\"@class\":\"PropertyDefinition\",\"name\":\"lastUpdateTime\",\"description\":\"Last Update time. At creation time it assumes the same value of creationTime. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"Date\"},{\"@class\":\"PropertyDefinition\",\"name\":\"createdBy\",\"description\":\"The user that created the Entity or the Relation. It is initialized at creation time. \",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"String\"},{\"@class\":\"PropertyDefinition\",\"name\":\"uuid\",\"description\":\"This UUID is be used to identify the Entity or the Relation univocally.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":\"^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}$\",\"type\":\"String\"},{\"@class\":\"PropertyDefinition\",\"name\":\"lastUpdateBy\",\"description\":\"The user that made the last update to the Entity or the Relation. At creation time, it assumes the same value of creator.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"String\"}],\"accessType\":\"PROPERTY\",\"abstract\":false,\"version\":\"1.0.0\",\"changelog\":{\"1.0.0\":\"First Version\"}}";
String json = "{\"" + Element.CLASS_PROPERTY + "\":\"PropertyType\",\"metadata\":null,\"name\":\"Metadata\",\"description\":\"This class provides metadata per every IdentifiableElement\",\"superClasses\":[\"Property\"],\"properties\":[{\"" + Element.CLASS_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"creationTime\",\"description\":\"Creation time. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"Date\"},{\"" + Element.CLASS_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"lastUpdateTime\",\"description\":\"Last Update time. At creation time it assumes the same value of creationTime. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"Date\"},{\"" + Element.CLASS_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"createdBy\",\"description\":\"The user that created the Entity or the Relation. It is initialized at creation time. \",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"String\"},{\"" + Element.CLASS_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"uuid\",\"description\":\"This UUID is be used to identify the Entity or the Relation univocally.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":\"^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}$\",\"propertyType\":\"String\"},{\"" + Element.CLASS_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"lastUpdateBy\",\"description\":\"The user that made the last update to the Entity or the Relation. At creation time, it assumes the same value of creator.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"String\"}],\"accessType\":\"PROPERTY\",\"abstract\":false,\"version\":\"1.0.0\",\"changelog\":{\"1.0.0\":\"First Version\"}}";
logger.info(json);
@SuppressWarnings("unchecked")
PropertyType<Metadata> metadataType = (PropertyType<Metadata>) TypeMapper.deserializeTypeDefinition(json);

View File

@ -1,20 +1,20 @@
{
"@class": "EService",
"type": "EService",
"consistsOf": [
{
"@class": "ConsistsOf",
"type": "ConsistsOf",
"propagationConstraint" : {
"add": "propagate"
},
"target": {
"@class": "StateFacet",
"type": "StateFacet",
"value": "$state"
}
},
{
"@class": "IsIdentifiedBy",
"type": "IsIdentifiedBy",
"target": {
"@class": "SoftwareFacet",
"type": "SoftwareFacet",
"name": "$name",
"group": "$group"
}