From 769853a11340decbb78835cff2c742614e226119 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Mon, 10 Jun 2024 11:51:30 +0200 Subject: [PATCH] Fixed code --- .../impl/properties/TemplateVariableImpl.java | 9 ++++---- .../properties/TemplateVariable.java | 23 +++++++++++++------ .../properties/PropertyDefinitionImpl.java | 3 +++ .../queries/templates/QueryTemplateTest.java | 6 ++--- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/queries/templates/impl/properties/TemplateVariableImpl.java b/src/main/java/org/gcube/informationsystem/queries/templates/impl/properties/TemplateVariableImpl.java index 07cd2f0..a69415c 100644 --- a/src/main/java/org/gcube/informationsystem/queries/templates/impl/properties/TemplateVariableImpl.java +++ b/src/main/java/org/gcube/informationsystem/queries/templates/impl/properties/TemplateVariableImpl.java @@ -39,17 +39,17 @@ public class TemplateVariableImpl extends PropertyElementImpl implements Templat public String getName() { return name; } - + @Override public void setName(String name) { this.name = name; } - + @Override public String getDescription() { return description; } - + @Override public void setDescription(String description) { this.description = description; @@ -113,7 +113,7 @@ public class TemplateVariableImpl extends PropertyElementImpl implements Templat @Override public String toString() { - return "PropertyDefinition [" + return "TemplateVariable [" + "name=" + name + ", description=" + description + ", max=" + max @@ -123,4 +123,5 @@ public class TemplateVariableImpl extends PropertyElementImpl implements Templat + ", defaultValue=" + (defaultValue == null ? "null" : defaultValue.toString()) + "]"; } + } diff --git a/src/main/java/org/gcube/informationsystem/queries/templates/reference/properties/TemplateVariable.java b/src/main/java/org/gcube/informationsystem/queries/templates/reference/properties/TemplateVariable.java index 79d2bae..76b5858 100644 --- a/src/main/java/org/gcube/informationsystem/queries/templates/reference/properties/TemplateVariable.java +++ b/src/main/java/org/gcube/informationsystem/queries/templates/reference/properties/TemplateVariable.java @@ -18,18 +18,27 @@ import org.gcube.informationsystem.utils.Version; public interface TemplateVariable extends PropertyElement, Attribute { public static final String NAME = "TemplateVariable"; // TemplateVariable.class.getSimpleName(); + - public static final String VARIABLE_NAME_PROPERTY = "name"; - public static final String VARIABLE_DESCRIPTION_PROPERTY = "description"; - public static final String VARIABLE_DEFAULT_VALUE_PROPERTY = "defaultValue"; - - @ISProperty(name = VARIABLE_NAME_PROPERTY, description = "The name of the Query Template Variable.", readonly = true, mandatory = true, nullable = false) + @ISProperty(name = Attribute.NAME_PROPERTY, description = "The name of the Query Template Variable.", readonly = true, mandatory = true, nullable = false) public String getName(); - @ISProperty(name = VARIABLE_DESCRIPTION_PROPERTY, description = "The description of the Query Template Variable.", readonly = false, mandatory = true, nullable = false) + @ISProperty(name = Attribute.DESCRIPTION_PROPERTY, readonly = false, mandatory = true, nullable = false) public String getDescription(); - @ISProperty(name = VARIABLE_DEFAULT_VALUE_PROPERTY, description = "The default value of the Query Template Variable. The default value is used as is to the query. If the value needs quotation or escaping please include them to the default value", readonly = false, mandatory = true, nullable = true) + @ISProperty(name = Attribute.MAX_PROPERTY, readonly = false, mandatory = true, nullable = false) + public Integer getMax(); + + @ISProperty(name = Attribute.MIN_PROPERTY, readonly = false, mandatory = true, nullable = false) + public Integer getMin(); + + @ISProperty(name = Attribute.REGEX_PROPERTY, readonly = false, mandatory = true, nullable = false) + public String getRegexp(); + + @ISProperty(name = Attribute.PROPERTY_TYPE_PROPERTY, readonly = false, mandatory = true, nullable = false) + public String getPropertyType(); + + @ISProperty(name = Attribute.DEFAULT_VALUE_PROPERTY, readonly = false, mandatory = false, nullable = true) public Object getDefaultValue(); } diff --git a/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java b/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java index eed8164..f1680f2 100644 --- a/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java +++ b/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java @@ -235,6 +235,9 @@ public final class PropertyDefinitionImpl implements PropertyDefinition { return "PropertyDefinition [" + "name=" + name + ", description=" + description + + ", mandatory=" + mandatory + + ", readonly=" + readonly + + ", notnull=" + notnull + ", max=" + max + ", min=" + min + ", regexpr=" + regexp diff --git a/src/test/java/org/gcube/informationsystem/queries/templates/QueryTemplateTest.java b/src/test/java/org/gcube/informationsystem/queries/templates/QueryTemplateTest.java index 910c6ad..a97669e 100644 --- a/src/test/java/org/gcube/informationsystem/queries/templates/QueryTemplateTest.java +++ b/src/test/java/org/gcube/informationsystem/queries/templates/QueryTemplateTest.java @@ -48,7 +48,7 @@ public class QueryTemplateTest { stateTemplateVariable.setName(stateVariableName); stateTemplateVariable.setDescription("StateFacet value"); stateTemplateVariable.setDefaultValue("running"); - //stateTemplateVariable.setPropertyType("String"); + stateTemplateVariable.setPropertyType("String"); queryTemplate.addTemplateVariable(stateTemplateVariable); TemplateVariable nameTemplateVariable = new TemplateVariableImpl(); @@ -56,7 +56,7 @@ public class QueryTemplateTest { nameTemplateVariable.setName(nameVariableName); nameTemplateVariable.setDescription("SoftwareFacet name"); nameTemplateVariable.setDefaultValue("resource-registry"); - //nameTemplateVariable.setPropertyType("String"); + nameTemplateVariable.setPropertyType("String"); queryTemplate.addTemplateVariable(nameTemplateVariable); TemplateVariable groupTemplateVariable = new TemplateVariableImpl(); @@ -64,7 +64,7 @@ public class QueryTemplateTest { groupTemplateVariable.setName(groupVariableName); groupTemplateVariable.setDescription("SoftwareFacet group"); groupTemplateVariable.setDefaultValue("information-system"); - //groupTemplateVariable.setPropertyType("String"); + groupTemplateVariable.setPropertyType("String"); queryTemplate.addTemplateVariable(groupTemplateVariable); String json = ElementMapper.marshal(queryTemplate);