Fixing types

This commit is contained in:
Luca Frosini 2021-10-21 11:56:01 +02:00
parent 66fead0851
commit c0b5908960
5 changed files with 38 additions and 50 deletions

View File

@ -34,6 +34,12 @@ import org.gcube.informationsystem.model.reference.properties.Property;
import org.gcube.informationsystem.model.reference.relations.ConsistsOf; import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo; import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
import org.gcube.informationsystem.model.reference.relations.Relation; import org.gcube.informationsystem.model.reference.relations.Relation;
import org.gcube.informationsystem.querytemplates.impl.entities.QueryTemplateImpl;
import org.gcube.informationsystem.querytemplates.impl.properties.TemplatePropertyImpl;
import org.gcube.informationsystem.querytemplates.impl.properties.TemplateVariableImpl;
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.types.impl.entities.EntityTypeImpl; import org.gcube.informationsystem.types.impl.entities.EntityTypeImpl;
import org.gcube.informationsystem.types.impl.properties.PropertyDefinitionImpl; import org.gcube.informationsystem.types.impl.properties.PropertyDefinitionImpl;
import org.gcube.informationsystem.types.impl.properties.PropertyTypeImpl; import org.gcube.informationsystem.types.impl.properties.PropertyTypeImpl;
@ -55,11 +61,14 @@ public enum AccessType {
PROPERTY_ELEMENT(PropertyElement.class, PropertyElement.NAME, PropertyElementImpl.class, null), PROPERTY_ELEMENT(PropertyElement.class, PropertyElement.NAME, PropertyElementImpl.class, null),
PROPERTY_DEFINITION(PropertyDefinition.class, PropertyDefinition.NAME, PropertyDefinitionImpl.class, null), PROPERTY_DEFINITION(PropertyDefinition.class, PropertyDefinition.NAME, PropertyDefinitionImpl.class, null),
PROPERTY_TYPE(PropertyType.class, PropertyType.NAME, PropertyTypeImpl.class, null), PROPERTY_TYPE(PropertyType.class, PropertyType.NAME, PropertyTypeImpl.class, null),
TEMPLATE_PROPERTY(TemplateProperty.class, TemplateProperty.NAME, TemplatePropertyImpl.class, null),
TEMPLATE_VARIABLE(TemplateVariable.class, TemplateVariable.NAME, TemplateVariableImpl.class, null),
PROPERTY(Property.class, Property.NAME, PropertyImpl.class, null), PROPERTY(Property.class, Property.NAME, PropertyImpl.class, null),
ENTITY_ELEMENT(EntityElement.class, EntityElement.NAME, EntityElementImpl.class, null), ENTITY_ELEMENT(EntityElement.class, EntityElement.NAME, EntityElementImpl.class, null),
ENTITY_TYPE(EntityType.class, EntityType.NAME, EntityTypeImpl.class, null), ENTITY_TYPE(EntityType.class, EntityType.NAME, EntityTypeImpl.class, null),
CONTEXT(Context.class, Context.NAME, ContextImpl.class, null), CONTEXT(Context.class, Context.NAME, ContextImpl.class, null),
QUERY_TEMPLATE(QueryTemplate.class, QueryTemplate.NAME, QueryTemplateImpl.class, null),
ENTITY(Entity.class, Entity.NAME, EntityImpl.class, null), ENTITY(Entity.class, Entity.NAME, EntityImpl.class, null),
RESOURCE(Resource.class, Resource.NAME, ResourceImpl.class, DummyResource.class), RESOURCE(Resource.class, Resource.NAME, ResourceImpl.class, DummyResource.class),
FACET(Facet.class, Facet.NAME, FacetImpl.class, DummyFacet.class), FACET(Facet.class, Facet.NAME, FacetImpl.class, DummyFacet.class),

View File

@ -1,14 +1,12 @@
package org.gcube.informationsystem.querytemplates.impl.entities; package org.gcube.informationsystem.querytemplates.impl.entities;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude; import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include; import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty; import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
import org.gcube.informationsystem.model.reference.properties.Header; import org.gcube.informationsystem.base.impl.entities.EntityElementImpl;
import org.gcube.informationsystem.querytemplates.reference.entities.QueryTemplate; import org.gcube.informationsystem.querytemplates.reference.entities.QueryTemplate;
import org.gcube.informationsystem.querytemplates.reference.properties.TemplateProperty; import org.gcube.informationsystem.querytemplates.reference.properties.TemplateProperty;
import org.gcube.informationsystem.querytemplates.reference.properties.TemplateVariable; import org.gcube.informationsystem.querytemplates.reference.properties.TemplateVariable;
@ -17,15 +15,13 @@ import org.gcube.informationsystem.utils.Version;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */
public class QueryTemplatesImpl implements QueryTemplate { public class QueryTemplateImpl extends EntityElementImpl implements QueryTemplate {
/** /**
* Generated Serial version UID * Generated Serial version UID
*/ */
private static final long serialVersionUID = -1096809036997782113L; private static final long serialVersionUID = -1096809036997782113L;
protected Header header;
protected String name; protected String name;
protected String description; protected String description;
protected Version version; protected Version version;
@ -34,23 +30,13 @@ public class QueryTemplatesImpl implements QueryTemplate {
protected Map<Version, String> changelog; protected Map<Version, String> changelog;
protected TemplateProperty templateProperty; protected TemplateProperty templateProperty;
protected Set<TemplateVariable> templateDefaultValues; protected Map<String, TemplateVariable> templateDefaultValues;
public QueryTemplatesImpl() { public QueryTemplateImpl() {
this.changelog = new HashMap<>(); this.changelog = new HashMap<>();
this.templateDefaultValues = new HashSet<>(); this.templateDefaultValues = new HashMap<>();
} }
@Override
public Header getHeader() {
return header;
}
@Override
public void setHeader(Header header) {
this.header = header;
}
@Override @Override
public String getName() { public String getName() {
return name; return name;
@ -77,8 +63,8 @@ public class QueryTemplatesImpl implements QueryTemplate {
} }
@Override @Override
public void setVersion(Version typeVersion) { public void setVersion(Version version) {
this.version = typeVersion; this.version = version;
} }
@Override @Override
@ -133,28 +119,24 @@ public class QueryTemplatesImpl implements QueryTemplate {
} }
@Override @Override
public TemplateProperty getQueryTemplate() { public TemplateProperty getTemplate() {
return templateProperty; return templateProperty;
} }
@Override @Override
public void setQueryTemplate(TemplateProperty templateProperty) { public void setTemplate(TemplateProperty templateProperty) {
this.templateProperty = templateProperty; this.templateProperty = templateProperty;
} }
@Override @Override
public Set<TemplateVariable> getQueryTemplateDefaultValues() { public Map<String, TemplateVariable> getTemplateVariables() {
return templateDefaultValues; return templateDefaultValues;
} }
@Override @Override
public void setQueryTemplateDefaultValues(Set<TemplateVariable> queryTemplateDefaultValues) { public void addTemplateVariable(TemplateVariable templateVariable) {
this.templateDefaultValues = queryTemplateDefaultValues; String name = templateVariable.getName();
} this.templateDefaultValues.put(name, templateVariable);
@Override
public void addQueryTemplateDefaultValues(TemplateVariable queryTemplateDefaultValue) {
this.templateDefaultValues.add(queryTemplateDefaultValue);
} }
} }

View File

@ -1,7 +1,6 @@
package org.gcube.informationsystem.querytemplates.reference.entities; package org.gcube.informationsystem.querytemplates.reference.entities;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter; import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore; import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
@ -11,7 +10,8 @@ import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
import org.gcube.com.fasterxml.jackson.annotation.JsonSetter; import org.gcube.com.fasterxml.jackson.annotation.JsonSetter;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize; import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.base.reference.IdentifiableElement; import org.gcube.informationsystem.base.reference.IdentifiableElement;
import org.gcube.informationsystem.querytemplates.impl.entities.QueryTemplatesImpl; import org.gcube.informationsystem.base.reference.entities.EntityElement;
import org.gcube.informationsystem.querytemplates.impl.entities.QueryTemplateImpl;
import org.gcube.informationsystem.querytemplates.reference.properties.TemplateProperty; import org.gcube.informationsystem.querytemplates.reference.properties.TemplateProperty;
import org.gcube.informationsystem.querytemplates.reference.properties.TemplateVariable; import org.gcube.informationsystem.querytemplates.reference.properties.TemplateVariable;
import org.gcube.informationsystem.types.annotations.Abstract; import org.gcube.informationsystem.types.annotations.Abstract;
@ -25,12 +25,12 @@ import org.gcube.informationsystem.utils.Version;
*/ */
@Abstract @Abstract
@JsonIgnoreProperties(ignoreUnknown=true) @JsonIgnoreProperties(ignoreUnknown=true)
@JsonDeserialize(as=QueryTemplatesImpl.class) @JsonDeserialize(as=QueryTemplateImpl.class)
@TypeMetadata(name = QueryTemplate.NAME, description = "The type used to store Query Templates", version = Version.MINIMAL_VERSION_STRING) @TypeMetadata(name = QueryTemplate.NAME, description = "The type used to store Query Templates", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION) @Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public interface QueryTemplate extends IdentifiableElement { public interface QueryTemplate extends IdentifiableElement, EntityElement {
public static final String NAME = "QueryTemplates"; //QueryTemplates.class.getSimpleName(); public static final String NAME = "QueryTemplate"; //QueryTemplate.class.getSimpleName();
public static final String NAME_PROPERTY = "name"; public static final String NAME_PROPERTY = "name";
public static final String DESCRIPTION_PROPERTY = "description"; public static final String DESCRIPTION_PROPERTY = "description";
@ -69,7 +69,7 @@ public interface QueryTemplate extends IdentifiableElement {
public void setChangelog(Map<Version, String> changelog); public void setChangelog(Map<Version, String> changelog);
@JsonIgnore @JsonIgnore
public void addChangelog(Version typeVersion, String changeDescription); public void addChangelog(Version version, String changeDescription);
@JsonGetter(value = CHANGELOG_PROPERTY) @JsonGetter(value = CHANGELOG_PROPERTY)
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@ -85,18 +85,19 @@ public interface QueryTemplate extends IdentifiableElement {
@JsonGetter(value = QUERY_TEMPLATE_PROPERTY) @JsonGetter(value = QUERY_TEMPLATE_PROPERTY)
@ISProperty(name = QUERY_TEMPLATE_PROPERTY, description = "The Query Template. It can contains QueryVariable to be replaced to obtain a runnable query.", readonly = false, mandatory = true, nullable = false) @ISProperty(name = QUERY_TEMPLATE_PROPERTY, description = "The Query Template. It can contains QueryVariable to be replaced to obtain a runnable query.", readonly = false, mandatory = true, nullable = false)
public TemplateProperty getQueryTemplate(); public TemplateProperty getTemplate();
@JsonIgnore @JsonIgnore
public void setQueryTemplate(TemplateProperty templateProperty); public void setTemplate(TemplateProperty templateProperty);
@JsonGetter(value = QUERY_TEMPLATE_DEFAULT_VALUES_PROPERTY) @JsonGetter(value = QUERY_TEMPLATE_DEFAULT_VALUES_PROPERTY)
public Set<TemplateVariable> getQueryTemplateDefaultValues(); public Map<String, TemplateVariable> getTemplateVariables();
@JsonIgnore @JsonIgnore
public void setQueryTemplateDefaultValues(Set<TemplateVariable> queryTemplateDefaultValues); /**
* Adding variable which already exists, the previous value will be override.
@JsonIgnore * @param templateDefaultValue
public void addQueryTemplateDefaultValues(TemplateVariable queryTemplateDefaultValue); */
public void addTemplateVariable(TemplateVariable templateVariable);
} }

View File

@ -2,7 +2,7 @@ package org.gcube.informationsystem.querytemplates.reference.properties;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize; import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.base.reference.properties.PropertyElement; import org.gcube.informationsystem.base.reference.properties.PropertyElement;
import org.gcube.informationsystem.querytemplates.impl.properties.TemplatePropertyImpl; import org.gcube.informationsystem.querytemplates.impl.properties.TemplateVariableImpl;
import org.gcube.informationsystem.types.annotations.ISProperty; import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.reference.Change; import org.gcube.informationsystem.types.reference.Change;
import org.gcube.informationsystem.types.reference.TypeMetadata; import org.gcube.informationsystem.types.reference.TypeMetadata;
@ -11,7 +11,7 @@ import org.gcube.informationsystem.utils.Version;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */
@JsonDeserialize(as=TemplatePropertyImpl.class) @JsonDeserialize(as=TemplateVariableImpl.class)
@TypeMetadata(name = TemplateVariable.NAME, description = "This is the class used to define the a TemplateVariable", version = Version.MINIMAL_VERSION_STRING) @TypeMetadata(name = TemplateVariable.NAME, description = "This is the class used to define the a TemplateVariable", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION) @Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public interface TemplateVariable extends PropertyElement { public interface TemplateVariable extends PropertyElement {

View File

@ -51,10 +51,6 @@ public class TypeMapper {
mapper.registerSubtypes(PropertyType.class); mapper.registerSubtypes(PropertyType.class);
mapper.registerSubtypes(PropertyDefinition.class); mapper.registerSubtypes(PropertyDefinition.class);
mapper.registerSubtypes(LinkedEntity.class); mapper.registerSubtypes(LinkedEntity.class);
// TODO
// mapper.registerSubtypes(LinkedResource.class);
// mapper.registerSubtypes(LinkedFacet.class);
} }
public static String serializeTypeDefinition(Type type) throws Exception{ public static String serializeTypeDefinition(Type type) throws Exception{