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.IsRelatedTo;
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.properties.PropertyDefinitionImpl;
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_DEFINITION(PropertyDefinition.class, PropertyDefinition.NAME, PropertyDefinitionImpl.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),
ENTITY_ELEMENT(EntityElement.class, EntityElement.NAME, EntityElementImpl.class, null),
ENTITY_TYPE(EntityType.class, EntityType.NAME, EntityTypeImpl.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),
RESOURCE(Resource.class, Resource.NAME, ResourceImpl.class, DummyResource.class),
FACET(Facet.class, Facet.NAME, FacetImpl.class, DummyFacet.class),

View File

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

View File

@ -1,7 +1,6 @@
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;
@ -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.databind.annotation.JsonDeserialize;
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.TemplateVariable;
import org.gcube.informationsystem.types.annotations.Abstract;
@ -25,12 +25,12 @@ import org.gcube.informationsystem.utils.Version;
*/
@Abstract
@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)
@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 DESCRIPTION_PROPERTY = "description";
@ -69,7 +69,7 @@ public interface QueryTemplate extends IdentifiableElement {
public void setChangelog(Map<Version, String> changelog);
@JsonIgnore
public void addChangelog(Version typeVersion, String changeDescription);
public void addChangelog(Version version, String changeDescription);
@JsonGetter(value = CHANGELOG_PROPERTY)
@JsonInclude(Include.NON_NULL)
@ -85,18 +85,19 @@ public interface QueryTemplate extends IdentifiableElement {
@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)
public TemplateProperty getQueryTemplate();
public TemplateProperty getTemplate();
@JsonIgnore
public void setQueryTemplate(TemplateProperty templateProperty);
public void setTemplate(TemplateProperty templateProperty);
@JsonGetter(value = QUERY_TEMPLATE_DEFAULT_VALUES_PROPERTY)
public Set<TemplateVariable> getQueryTemplateDefaultValues();
public Map<String, TemplateVariable> getTemplateVariables();
@JsonIgnore
public void setQueryTemplateDefaultValues(Set<TemplateVariable> queryTemplateDefaultValues);
@JsonIgnore
public void addQueryTemplateDefaultValues(TemplateVariable queryTemplateDefaultValue);
/**
* Adding variable which already exists, the previous value will be override.
* @param templateDefaultValue
*/
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.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.reference.Change;
import org.gcube.informationsystem.types.reference.TypeMetadata;
@ -11,7 +11,7 @@ import org.gcube.informationsystem.utils.Version;
/**
* @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)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
public interface TemplateVariable extends PropertyElement {

View File

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