Annotated types to properly create type definition
This commit is contained in:
parent
e697ef2cf5
commit
5835d8c67b
|
@ -109,7 +109,7 @@ public class TypeMapper {
|
|||
if(name!=null && typeMetadataName.compareTo(name)!=0) {
|
||||
throw new RuntimeException("Name in annotation @TypeMetadata differ from annotation in @JsonTypeName for type " + classSimpleName + ". Please be coerent");
|
||||
}
|
||||
return name;
|
||||
return typeMetadataName;
|
||||
}else {
|
||||
throw new RuntimeException("Invalid Name in annotation @TypeMetadata for type " + classSimpleName);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package org.gcube.informationsystem.types.reference;
|
|||
import static java.lang.annotation.ElementType.TYPE;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.informationsystem.utils.TypeVersion;
|
||||
|
@ -12,6 +14,7 @@ import org.gcube.informationsystem.utils.TypeVersion;
|
|||
*/
|
||||
@Documented
|
||||
@Target(TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TypeMetadata {
|
||||
|
||||
String name() default "";
|
||||
|
|
|
@ -7,10 +7,15 @@ import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.impl.entities.EntityTypeImpl;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
import org.gcube.informationsystem.utils.TypeVersion;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonDeserialize(as = EntityTypeImpl.class)
|
||||
@TypeMetadata(name = EntityType.NAME, description = "This class provides information for any EntityType", version = TypeVersion.MINIMAL_VERSION_STRING)
|
||||
@Change(version = TypeVersion.MINIMAL_VERSION_STRING, description = TypeVersion.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface EntityType extends Type, EntityElement {
|
||||
|
||||
public static final String NAME = "EntityType"; //EntityType.class.getSimpleName();
|
||||
|
|
|
@ -6,11 +6,16 @@ import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.impl.entities.FacetTypeImpl;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
import org.gcube.informationsystem.utils.TypeVersion;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonDeserialize(as = FacetTypeImpl.class)
|
||||
@TypeMetadata(name = FacetType.NAME, description = "This class provides information for the definition of any FacetType", version = TypeVersion.MINIMAL_VERSION_STRING)
|
||||
@Change(version = TypeVersion.MINIMAL_VERSION_STRING, description = TypeVersion.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface FacetType extends EntityType {
|
||||
|
||||
public static final String NAME = "FacetType"; //FacetType.class.getSimpleName();
|
||||
|
|
|
@ -5,9 +5,14 @@ import java.util.List;
|
|||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.impl.entities.ResourceTypeImpl;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
import org.gcube.informationsystem.types.reference.properties.LinkedEntity;
|
||||
import org.gcube.informationsystem.utils.TypeVersion;
|
||||
|
||||
@JsonDeserialize(as=ResourceTypeImpl.class)
|
||||
@TypeMetadata(name = ResourceType.NAME, description = "This class provides information for the definition of any ResourceType", version = TypeVersion.MINIMAL_VERSION_STRING)
|
||||
@Change(version = TypeVersion.MINIMAL_VERSION_STRING, description = TypeVersion.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface ResourceType extends EntityType {
|
||||
|
||||
public static final String NAME = "ResourceType"; //ResourceType.class.getSimpleName();
|
||||
|
|
|
@ -5,12 +5,21 @@ import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.impl.properties.PropertyDefinitionImpl;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
import org.gcube.informationsystem.utils.TypeVersion;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonDeserialize(as = PropertyDefinitionImpl.class)
|
||||
@TypeMetadata(name = Changelog.NAME, description = "This class provides version information for any Type", version = TypeVersion.MINIMAL_VERSION_STRING)
|
||||
@Change(version = TypeVersion.MINIMAL_VERSION_STRING, description = TypeVersion.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface Changelog extends PropertyElement {
|
||||
|
||||
public static final String NAME = "Changelog";
|
||||
|
||||
public static final String VERSION_PROPERTY = "version";
|
||||
public static final String CHANGE_PROPERTY = "changelog";
|
||||
|
||||
|
|
|
@ -4,8 +4,16 @@ import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.impl.properties.LinkedEntityImpl;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
import org.gcube.informationsystem.utils.TypeVersion;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonDeserialize(as=LinkedEntityImpl.class)
|
||||
@TypeMetadata(name = LinkedEntity.NAME, description = "This class provides information for LinkedEntity", version = TypeVersion.MINIMAL_VERSION_STRING)
|
||||
@Change(version = TypeVersion.MINIMAL_VERSION_STRING, description = TypeVersion.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface LinkedEntity extends PropertyElement {
|
||||
|
||||
public static final String NAME = "LinkedEntity"; // LinkedEntity.class.getSimpleName();
|
||||
|
|
|
@ -5,6 +5,9 @@ import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.impl.properties.PropertyDefinitionImpl;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
import org.gcube.informationsystem.utils.TypeVersion;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -12,6 +15,8 @@ import org.gcube.informationsystem.types.impl.properties.PropertyDefinitionImpl;
|
|||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonDeserialize(as = PropertyDefinitionImpl.class)
|
||||
@TypeMetadata(name = PropertyDefinition.NAME, description = "This class provides information for the definition of any properties", version = TypeVersion.MINIMAL_VERSION_STRING)
|
||||
@Change(version = TypeVersion.MINIMAL_VERSION_STRING, description = TypeVersion.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface PropertyDefinition extends PropertyElement {
|
||||
|
||||
public static final String NAME = "PropertyDefinition"; // PropertyDefinition.class.getSimpleName();
|
||||
|
|
|
@ -9,10 +9,15 @@ import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
|||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.impl.properties.PropertyTypeImpl;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
import org.gcube.informationsystem.utils.TypeVersion;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonDeserialize(as = PropertyTypeImpl.class)
|
||||
@TypeMetadata(name = PropertyType.NAME, description = "This class provides information for any PropertyType", version = TypeVersion.MINIMAL_VERSION_STRING)
|
||||
@Change(version = TypeVersion.MINIMAL_VERSION_STRING, description = TypeVersion.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface PropertyType<P extends PropertyElement> extends PropertyElement, Type {
|
||||
|
||||
public static final String NAME = "PropertyType"; // PropertyTypeDefinition.class.getSimpleName();
|
||||
|
|
|
@ -2,13 +2,18 @@ package org.gcube.informationsystem.types.reference.relations;
|
|||
|
||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.gcube.informationsystem.types.impl.relations.ConsistsOfTypeImpl;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
import org.gcube.informationsystem.types.reference.entities.FacetType;
|
||||
import org.gcube.informationsystem.types.reference.entities.ResourceType;
|
||||
import org.gcube.informationsystem.utils.TypeVersion;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonDeserialize(as = ConsistsOfTypeImpl.class)
|
||||
@TypeMetadata(name = ConsistsOfType.NAME, description = "This class provides information for any ConsistsOfType", version = TypeVersion.MINIMAL_VERSION_STRING)
|
||||
@Change(version = TypeVersion.MINIMAL_VERSION_STRING, description = TypeVersion.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface ConsistsOfType extends RelationType<ResourceType, FacetType> {
|
||||
|
||||
public static final String NAME = "ConsistsOfType"; // ConsistsOfType.class.getSimpleName();
|
||||
|
|
|
@ -2,12 +2,17 @@ package org.gcube.informationsystem.types.reference.relations;
|
|||
|
||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.gcube.informationsystem.types.impl.relations.IsRelatedToTypeImpl;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
import org.gcube.informationsystem.types.reference.entities.ResourceType;
|
||||
import org.gcube.informationsystem.utils.TypeVersion;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonDeserialize(as = IsRelatedToTypeImpl.class)
|
||||
@TypeMetadata(name = IsRelatedToType.NAME, description = "This class provides information for any IsRelatedToType", version = TypeVersion.MINIMAL_VERSION_STRING)
|
||||
@Change(version = TypeVersion.MINIMAL_VERSION_STRING, description = TypeVersion.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface IsRelatedToType extends RelationType<ResourceType, ResourceType> {
|
||||
|
||||
public static final String NAME = "IsRelatedToType"; // IsRelatedToType.class.getSimpleName();
|
||||
|
|
|
@ -7,12 +7,17 @@ import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.impl.relations.RelationTypeImpl;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
import org.gcube.informationsystem.types.reference.entities.EntityType;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
import org.gcube.informationsystem.utils.TypeVersion;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonDeserialize(as = RelationTypeImpl.class)
|
||||
@TypeMetadata(name = RelationType.NAME, description = "This class provides information for any RelationType", version = TypeVersion.MINIMAL_VERSION_STRING)
|
||||
@Change(version = TypeVersion.MINIMAL_VERSION_STRING, description = TypeVersion.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface RelationType<S extends EntityType, T extends EntityType>
|
||||
extends Type, RelationElement<S,T> {
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
|||
*/
|
||||
public interface SchemaAction {
|
||||
|
||||
public <P extends PropertyElement> void managePropertyClass(Class<P> e) throws Exception;
|
||||
public <P extends PropertyElement> void managePropertyClass(Class<P> p) throws Exception;
|
||||
|
||||
public <E extends EntityElement> void manageEntityClass(Class<E> e) throws Exception;
|
||||
|
||||
|
|
|
@ -9,12 +9,18 @@ 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.base.reference.relations.RelationElement;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyType;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ISMDiscoveryTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ISMDiscoveryTest.class);
|
||||
|
||||
@Test
|
||||
public void testISMDIscovery() {
|
||||
ElementSpecilizationDiscovery<PropertyElement> propertyDiscovery = new ElementSpecilizationDiscovery<>(PropertyElement.class);
|
||||
|
@ -46,17 +52,23 @@ public class ISMDiscoveryTest {
|
|||
@Override
|
||||
public <R extends RelationElement<? extends EntityElement, ? extends EntityElement>> void manageRelationClass(
|
||||
Class<R> r) throws Exception {
|
||||
|
||||
Type type = TypeMapper.createTypeDefinition(r);
|
||||
Assert.assertTrue(type.getName().compareTo(r.getSimpleName())==0);
|
||||
logger.debug("{} {}", r.getSimpleName(), TypeMapper.serializeTypeDefinition(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <P extends PropertyElement> void managePropertyClass(Class<P> e) throws Exception {
|
||||
|
||||
public <P extends PropertyElement> void managePropertyClass(Class<P> p) throws Exception {
|
||||
Type type = TypeMapper.createTypeDefinition(p);
|
||||
Assert.assertTrue(type.getName().compareTo(p.getSimpleName())==0);
|
||||
logger.debug("{} {}", p.getSimpleName(), TypeMapper.serializeTypeDefinition(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends EntityElement> void manageEntityClass(Class<E> e) throws Exception {
|
||||
|
||||
Type type = TypeMapper.createTypeDefinition(e);
|
||||
Assert.assertTrue(type.getName().compareTo(e.getSimpleName())==0);
|
||||
logger.debug("{} {}", e.getSimpleName(), TypeMapper.serializeTypeDefinition(type));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue