Adding Query Templates
This commit is contained in:
parent
b454e52e67
commit
18b9124e86
|
@ -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<TypeVersion, String> 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<TypeVersion, String> getChangelog() {
|
||||
return changelog;
|
||||
}
|
||||
|
||||
@JsonGetter(value = CHANGELOG_PROPERTY)
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
public Map<String, String> getChangelogWithVersionAsString() {
|
||||
Map<String, String> 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<String, String> 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<TemplateVariable> getQueryVariables() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String setName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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<TypeVersion, String> 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<String, String> 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<TemplateVariable> getQueryVariables();
|
||||
|
||||
}
|
|
@ -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();
|
||||
|
||||
}
|
|
@ -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";
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue