From 6162719723b4df2692bd645bb9babf7b3966b287 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Wed, 15 Jan 2020 17:01:00 +0100 Subject: [PATCH] Adding the possibility to define Resource Schema refs #18213 --- .../model/reference/entities/Resource.java | 4 -- .../types/annotations/ResourceSchema.java | 3 +- .../ResourceSchemaRelatedEntry.java | 46 ------------------- .../types/impl/TypeDefinitionImpl.java | 17 ------- 4 files changed, 1 insertion(+), 69 deletions(-) delete mode 100644 src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchemaRelatedEntry.java diff --git a/src/main/java/org/gcube/informationsystem/model/reference/entities/Resource.java b/src/main/java/org/gcube/informationsystem/model/reference/entities/Resource.java index 8226a87..4180a0e 100644 --- a/src/main/java/org/gcube/informationsystem/model/reference/entities/Resource.java +++ b/src/main/java/org/gcube/informationsystem/model/reference/entities/Resource.java @@ -11,7 +11,6 @@ import org.gcube.informationsystem.model.reference.relations.IsRelatedTo; import org.gcube.informationsystem.types.annotations.Abstract; import org.gcube.informationsystem.types.annotations.ResourceSchema; import org.gcube.informationsystem.types.annotations.ResourceSchemaEntry; -import org.gcube.informationsystem.types.annotations.ResourceSchemaRelatedEntry; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -26,9 +25,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @ResourceSchema( facets={ @ResourceSchemaEntry(relation=ConsistsOf.class, facet=Facet.class, min=1, description="Any Resource consists of one or more Facets which describes the different aspects of the resource."), - }, - resources= { - @ResourceSchemaRelatedEntry(source=Resource.class, relation=IsRelatedTo.class, target=Resource.class, description="Any Resource can be related to any other resource.") } ) public interface Resource extends Entity { diff --git a/src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchema.java b/src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchema.java index 5b1b7d8..2ad0af1 100644 --- a/src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchema.java +++ b/src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchema.java @@ -13,6 +13,5 @@ import java.lang.annotation.Target; public @interface ResourceSchema { ResourceSchemaEntry[] facets() default {}; - - ResourceSchemaRelatedEntry[] resources() default {}; + } diff --git a/src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchemaRelatedEntry.java b/src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchemaRelatedEntry.java deleted file mode 100644 index 2286a98..0000000 --- a/src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchemaRelatedEntry.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.gcube.informationsystem.types.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.gcube.informationsystem.model.reference.entities.Entity; -import org.gcube.informationsystem.model.reference.entities.Resource; -import org.gcube.informationsystem.model.reference.relations.IsRelatedTo; -import org.gcube.informationsystem.types.TypeBinder; -import org.gcube.informationsystem.types.reference.properties.PropertyDefinition; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * @author Luca Frosini (ISTI - CNR) - * It is used by {@link TypeBinder} to identify which getter method are - * related to and {@link Entity} {@link PropertyDefinition}. - * The name of the property is obtained by removing "get" or "is" from method - * name and lower casing the first letter. - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface ResourceSchemaRelatedEntry { - - @JsonProperty - Class source() default Resource.class; - - @SuppressWarnings("rawtypes") - @JsonProperty - Class relation() default IsRelatedTo.class; - - @JsonProperty - Class target() default Resource.class; - - @JsonProperty - String description() default ""; - - @JsonProperty - int min() default 0; - - @JsonProperty - int max() default -1; - -} diff --git a/src/main/java/org/gcube/informationsystem/types/impl/TypeDefinitionImpl.java b/src/main/java/org/gcube/informationsystem/types/impl/TypeDefinitionImpl.java index 207b9fc..f39e86d 100644 --- a/src/main/java/org/gcube/informationsystem/types/impl/TypeDefinitionImpl.java +++ b/src/main/java/org/gcube/informationsystem/types/impl/TypeDefinitionImpl.java @@ -19,7 +19,6 @@ import org.gcube.informationsystem.types.annotations.Abstract; import org.gcube.informationsystem.types.annotations.ISProperty; import org.gcube.informationsystem.types.annotations.ResourceSchema; import org.gcube.informationsystem.types.annotations.ResourceSchemaEntry; -import org.gcube.informationsystem.types.annotations.ResourceSchemaRelatedEntry; import org.gcube.informationsystem.types.impl.entities.EntityTypeDefinitionImpl; import org.gcube.informationsystem.types.impl.properties.PropertyDefinitionImpl; import org.gcube.informationsystem.types.impl.properties.PropertyTypeDefinitionImpl; @@ -54,7 +53,6 @@ public class TypeDefinitionImpl extends ERImpl implements TypeDefinition { protected Set superClasses; protected Set properties; protected List facets; - protected List resources; protected static Set retrieveSuperClasses(Class type, Class baseClass, String topSuperClass){ Set interfaceList = new HashSet<>(); @@ -161,7 +159,6 @@ public class TypeDefinitionImpl extends ERImpl implements TypeDefinition { private void setResourceSchemaEntries(Class clz){ if(clz.isAnnotationPresent(ResourceSchema.class)) { this.facets = new ArrayList<>(); - this.resources = new ArrayList<>(); ResourceSchema[] resourceSchemaArray = clz.getAnnotationsByType(ResourceSchema.class); for(ResourceSchemaEntry resourceSchemaEntry : resourceSchemaArray[0].facets()) { ResourceEntryDefinitionImpl resourceSchemaEntryDefinition = new ResourceEntryDefinitionImpl(); @@ -173,16 +170,6 @@ public class TypeDefinitionImpl extends ERImpl implements TypeDefinition { resourceSchemaEntryDefinition.setMax(resourceSchemaEntry.max()); this.facets.add(resourceSchemaEntryDefinition); } - for(ResourceSchemaRelatedEntry resourceSchemaRelatedEntry : resourceSchemaArray[0].resources()) { - ResourceEntryDefinition resourceSchemaEntryDefinition = new ResourceEntryDefinitionImpl(); - resourceSchemaEntryDefinition.setSource(TypeBinder.getType(resourceSchemaRelatedEntry.source())); - resourceSchemaEntryDefinition.setRelation(TypeBinder.getType(resourceSchemaRelatedEntry.relation())); - resourceSchemaEntryDefinition.setTarget(TypeBinder.getType(resourceSchemaRelatedEntry.target())); - resourceSchemaEntryDefinition.setDescription(resourceSchemaRelatedEntry.description()); - resourceSchemaEntryDefinition.setMin(resourceSchemaRelatedEntry.min()); - resourceSchemaEntryDefinition.setMax(resourceSchemaRelatedEntry.max()); - this.resources.add(resourceSchemaEntryDefinition); - } } } @@ -215,8 +202,4 @@ public class TypeDefinitionImpl extends ERImpl implements TypeDefinition { return facets; } - public List getResources() { - return resources; - } - }