diff --git a/src/main/java/org/gcube/informationsystem/querytemplates/impl/entities/QueryTemplatesImpl.java b/src/main/java/org/gcube/informationsystem/querytemplates/impl/entities/QueryTemplatesImpl.java new file mode 100644 index 0000000..37acca3 --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/querytemplates/impl/entities/QueryTemplatesImpl.java @@ -0,0 +1,114 @@ +package org.gcube.informationsystem.querytemplates.impl.entities; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +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.JsonProperty; +import org.gcube.com.fasterxml.jackson.annotation.JsonSetter; +import org.gcube.informationsystem.model.reference.properties.Header; +import org.gcube.informationsystem.querytemplates.reference.entities.QueryTemplate; +import org.gcube.informationsystem.querytemplates.reference.properties.TemplateProperty; +import org.gcube.informationsystem.querytemplates.reference.properties.TemplateVariable; +import org.gcube.informationsystem.utils.TypeVersion; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public class QueryTemplatesImpl implements QueryTemplate { + + /** + * Generated Serial version UID + */ + private static final long serialVersionUID = -1096809036997782113L; + + protected Header header; + + protected String name; + protected String description; + protected TypeVersion version; + + @JsonProperty(value = CHANGELOG_PROPERTY, required = false) + @JsonInclude(Include.NON_NULL) + protected Map changelog; + + @Override + public Header getHeader() { + return header; + } + + @Override + public void setHeader(Header header) { + this.header = header; + } + + @Override + public String getName() { + return name; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public TypeVersion getVersion() { + return version; + } + + @JsonGetter(value = VERSION_PROPERTY) + public String getVersionAsString() { + return version.toString(); + } + + @JsonSetter(value = VERSION_PROPERTY) + public void setVersion(String version) { + this.version = new TypeVersion(version); + } + + @Override + public Map getChangelog() { + return changelog; + } + + @JsonGetter(value = CHANGELOG_PROPERTY) + @JsonInclude(Include.NON_NULL) + public Map getChangelogWithVersionAsString() { + Map map = new HashMap<>(); + for (TypeVersion typeVersion : changelog.keySet()) { + map.put(typeVersion.toString(), changelog.get(typeVersion)); + } + return map; + } + + @JsonSetter(value=CHANGELOG_PROPERTY) + public void setChangelog(Map changelog) { + this.changelog = new HashMap<>(); + for (String version : changelog.keySet()) { + this.changelog.put(new TypeVersion(version), changelog.get(version)); + } + } + + @Override + public TemplateProperty getQueryTemplate() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Set getQueryVariables() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String setName() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/main/java/org/gcube/informationsystem/querytemplates/impl/properties/TemplatePropertyImpl.java b/src/main/java/org/gcube/informationsystem/querytemplates/impl/properties/TemplatePropertyImpl.java new file mode 100644 index 0000000..4d865e5 --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/querytemplates/impl/properties/TemplatePropertyImpl.java @@ -0,0 +1,25 @@ +/** + * + */ +package org.gcube.informationsystem.querytemplates.impl.properties; + +import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName; +import org.gcube.informationsystem.base.impl.properties.PropertyElementImpl; +import org.gcube.informationsystem.querytemplates.reference.properties.TemplateProperty; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +@JsonTypeName(value=TemplateProperty.NAME) +public class TemplatePropertyImpl extends PropertyElementImpl implements TemplateProperty { + + /** + * Generated Serial Version UID + */ + private static final long serialVersionUID = 2628113641100130640L; + + public TemplatePropertyImpl() { + super(); + } + +} diff --git a/src/main/java/org/gcube/informationsystem/querytemplates/reference/entities/QueryTemplate.java b/src/main/java/org/gcube/informationsystem/querytemplates/reference/entities/QueryTemplate.java new file mode 100644 index 0000000..ff28928 --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/querytemplates/reference/entities/QueryTemplate.java @@ -0,0 +1,69 @@ +package org.gcube.informationsystem.querytemplates.reference.entities; + +import java.util.Map; +import java.util.Set; + +import org.gcube.com.fasterxml.jackson.annotation.JsonGetter; +import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore; +import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.gcube.informationsystem.base.reference.IdentifiableElement; +import org.gcube.informationsystem.querytemplates.impl.entities.QueryTemplatesImpl; +import org.gcube.informationsystem.querytemplates.reference.properties.TemplateProperty; +import org.gcube.informationsystem.querytemplates.reference.properties.TemplateVariable; +import org.gcube.informationsystem.types.annotations.Abstract; +import org.gcube.informationsystem.types.annotations.ISProperty; +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) + */ +@Abstract +@JsonIgnoreProperties(ignoreUnknown=true) +@JsonDeserialize(as=QueryTemplatesImpl.class) +@TypeMetadata(name = QueryTemplate.NAME, description = "The type used to store QueryTemplates", version = TypeVersion.MINIMAL_VERSION_STRING) +@Change(version = TypeVersion.MINIMAL_VERSION_STRING, description = TypeVersion.MINIMAL_VERSION_DESCRIPTION) +public interface QueryTemplate extends IdentifiableElement { + + public static final String NAME = "QueryTemplates"; //QueryTemplates.class.getSimpleName(); + + public static final String NAME_PROPERTY = "name"; + public static final String DESCRIPTION_PROPERTY = "description"; + public static final String VERSION_PROPERTY = "version"; + public static final String CHANGELOG_PROPERTY = "changelog"; + + public static final String QUERY_TEMPLATE_PROPERTY = "queryTemplate"; + public static final String QUERY_VARIABLES_PROPERTY = "queryVariables"; + + @ISProperty(name = NAME_PROPERTY, description = "The name of the JSON Query Template. Among UUID univocally identifiy the JSON Query Template.", readonly = true, mandatory = true, nullable = false) + public String getName(); + + public String setName(); + + @ISProperty(name = DESCRIPTION_PROPERTY, description = "The description of the JSON Query Template.", readonly = false, mandatory = true, nullable = false) + public String getDescription(); + + @JsonIgnore + public TypeVersion getVersion(); + + @JsonGetter(value = VERSION_PROPERTY) + @ISProperty(name = VERSION_PROPERTY, description = "The version of the JSON Query Template.", readonly = false, mandatory = true, nullable = false) + public String getVersionAsString(); + + @JsonIgnore + public Map getChangelog(); + + @JsonGetter(value = CHANGELOG_PROPERTY) + @ISProperty(name = CHANGELOG_PROPERTY, description = "Provides the changelog of changes made to the JSON Query Temaplate.", readonly = false, mandatory = true, nullable = false) + public Map getChangelogWithVersionAsString(); + + @JsonGetter(value = QUERY_TEMPLATE_PROPERTY) + @ISProperty(name = QUERY_TEMPLATE_PROPERTY, description = "The JSON Query Temaplate. It can contains QueryVariable which when evaluated", readonly = false, mandatory = true, nullable = false) + public TemplateProperty getQueryTemplate(); + + @JsonGetter(value = QUERY_VARIABLES_PROPERTY) + public Set getQueryVariables(); + +} diff --git a/src/main/java/org/gcube/informationsystem/querytemplates/reference/properties/TemplateProperty.java b/src/main/java/org/gcube/informationsystem/querytemplates/reference/properties/TemplateProperty.java new file mode 100644 index 0000000..4eee57f --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/querytemplates/reference/properties/TemplateProperty.java @@ -0,0 +1,20 @@ +package org.gcube.informationsystem.querytemplates.reference.properties; + +import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.gcube.informationsystem.base.reference.properties.PropertyElement; +import org.gcube.informationsystem.querytemplates.impl.properties.TemplatePropertyImpl; +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=TemplatePropertyImpl.class) +@TypeMetadata(name = TemplateProperty.NAME, description = "This is the class used to define the TemplateProperty", version = TypeVersion.MINIMAL_VERSION_STRING) +@Change(version = TypeVersion.MINIMAL_VERSION_STRING, description = TypeVersion.MINIMAL_VERSION_DESCRIPTION) +public interface TemplateProperty extends PropertyElement { + + public static final String NAME = "TemplateProperty"; // TemplateProperty.class.getSimpleName(); + +} diff --git a/src/main/java/org/gcube/informationsystem/querytemplates/reference/properties/TemplateVariable.java b/src/main/java/org/gcube/informationsystem/querytemplates/reference/properties/TemplateVariable.java new file mode 100644 index 0000000..160f811 --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/querytemplates/reference/properties/TemplateVariable.java @@ -0,0 +1,27 @@ +package org.gcube.informationsystem.querytemplates.reference.properties; + +import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.gcube.informationsystem.base.reference.properties.PropertyElement; +import org.gcube.informationsystem.querytemplates.impl.properties.TemplatePropertyImpl; +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=TemplatePropertyImpl.class) +@TypeMetadata(name = TemplateVariable.NAME, description = "This is the class used to define the a TemplateVariable", version = TypeVersion.MINIMAL_VERSION_STRING) +@Change(version = TypeVersion.MINIMAL_VERSION_STRING, description = TypeVersion.MINIMAL_VERSION_DESCRIPTION) +public interface TemplateVariable extends PropertyElement { + + public static final String NAME = "TemplateVariable"; // TemplateVariable.class.getSimpleName(); + + public static final String VARIABLE_NAME_PROPERTY = "name"; + public static final String VARIABLE_TYPE_PROPERTY = "type"; + public static final String VARIABLE_DESCRIPTION_PROPERTY = "description"; + public static final String VARIABLE_DEFAULT_VALUE_PROPERTY = "defaultValue"; + + + +}