From 3eb417a2a9ef39da9312babe05595d50d64a4212 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 5 Dec 2019 11:12:31 +0100 Subject: [PATCH] Added annotations to allow to define the Resource Schema refs #18213 --- .../types/annotations/ResourceSchema.java | 25 +++++++++++++ .../annotations/ResourceSchemaEntry.java | 35 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchema.java create mode 100644 src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchemaEntry.java diff --git a/src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchema.java b/src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchema.java new file mode 100644 index 0000000..e91ff70 --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchema.java @@ -0,0 +1,25 @@ +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.types.TypeBinder; +import org.gcube.informationsystem.types.reference.properties.PropertyDefinition; + +/** + * @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 ResourceSchema { + + ResourceSchemaEntry[] value(); + +} diff --git a/src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchemaEntry.java b/src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchemaEntry.java new file mode 100644 index 0000000..b622d07 --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/types/annotations/ResourceSchemaEntry.java @@ -0,0 +1,35 @@ +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.Facet; +import org.gcube.informationsystem.model.reference.relations.ConsistsOf; +import org.gcube.informationsystem.types.TypeBinder; +import org.gcube.informationsystem.types.reference.properties.PropertyDefinition; + +/** + * @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 ResourceSchemaEntry { + + @SuppressWarnings("rawtypes") + Class consistOfType() default ConsistsOf.class; + Class targetFacetType() default Facet.class; + + String description() default ""; + + int min() default 0; + int max() default -1; + + +}