fixing code
This commit is contained in:
parent
0c37a01339
commit
2c46cbbdc8
|
@ -31,7 +31,7 @@ public interface PropertyBasicInfo extends PropertyElement {
|
|||
|
||||
public void setDescription(String description);
|
||||
|
||||
@ISProperty(name = DEFAULT_VALUE_PROPERTY, description = "The default value of the Property/Variable. The default value is used as is. If the value needs quotation or escaping please include them to the default value", readonly = false, mandatory = true, nullable = false)
|
||||
@ISProperty(name = DEFAULT_VALUE_PROPERTY, description = "The default value of the Property/Variable. The default value is used as is. If the value needs quotation or escaping please include them to the default value. The default value of 'defaultValue' is null which is defined using the string 'null'", readonly = false, mandatory = false, nullable = true)
|
||||
public String getDefaultValue();
|
||||
|
||||
public void setDefaultValue(String defaultValue);
|
||||
|
|
|
@ -12,13 +12,14 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@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 = TemplateVariable.VERSION)
|
||||
@Changelog ({
|
||||
@Change(version = "2.0.0", description = "The type now is a subclass of @link{PropertyBasicInfo}"),
|
||||
@Change(version = TemplateVariable.VERSION, description = "The type now is a subclass of @link{PropertyBasicInfo}"),
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
})
|
||||
public interface TemplateVariable extends PropertyBasicInfo {
|
||||
|
||||
public static final String NAME = "TemplateVariable"; // TemplateVariable.class.getSimpleName();
|
||||
public static final String VERSION = "2.0.0";
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,6 @@ public @interface ISProperty {
|
|||
int min() default -1;
|
||||
int max() default -1;
|
||||
String regexpr() default "";
|
||||
String defaultValue() default "";
|
||||
String defaultValue() default "null";
|
||||
|
||||
}
|
||||
|
|
|
@ -82,6 +82,13 @@ public final class PropertyDefinitionImpl extends PropertyBasicInfoImpl implemen
|
|||
}
|
||||
}
|
||||
|
||||
public static String evaluateNullForDefaultValue(String defaultValueAsString) {
|
||||
if(defaultValueAsString==null || defaultValueAsString.compareTo("null")==0) {
|
||||
return null;
|
||||
}
|
||||
return defaultValueAsString;
|
||||
}
|
||||
|
||||
public static Object evaluateDefaultValue(BaseType baseType, String defaultValueAsString) {
|
||||
|
||||
if(defaultValueAsString==null || defaultValueAsString.compareTo("null")==0) {
|
||||
|
@ -160,7 +167,8 @@ public final class PropertyDefinitionImpl extends PropertyBasicInfoImpl implemen
|
|||
}
|
||||
|
||||
this.propertyTypeName = new PropertyTypeName(method);
|
||||
this.defaultValue = propertyAnnotation.defaultValue();
|
||||
String defaultValueString = propertyAnnotation.defaultValue();
|
||||
this.defaultValue = evaluateNullForDefaultValue(defaultValueString);
|
||||
// The default value is evaluated to test if compliant with the declared type
|
||||
PropertyDefinitionImpl.evaluateDefaultValue(propertyTypeName.getBaseType(), defaultValue);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ public interface EntityTest extends EntityParent {
|
|||
@ISProperty(nullable=false)
|
||||
public String getNotnullable();
|
||||
|
||||
@ISProperty(mandatory=true)
|
||||
@ISProperty(mandatory=true, defaultValue = "true")
|
||||
public String getMandatory();
|
||||
|
||||
@ISProperty(name="different", description="desc")
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.gcube.informationsystem.base.reference.AccessType;
|
|||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.base.reference.properties.PropertyBasicInfo;
|
||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||
|
@ -52,6 +53,16 @@ public class SerializationTest {
|
|||
TypeMapper.serializeType(EntityTest.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializePropertyDefinition() throws Exception{
|
||||
TypeMapper.serializeType(PropertyDefinition.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializePropertyBasicInfo() throws Exception{
|
||||
TypeMapper.serializeType(PropertyBasicInfo.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void makeFacetTypeDefinition() throws Exception{
|
||||
EntityType facetTypeDefinitionSelf = (EntityType) TypeMapper.createTypeDefinition(FacetType.class);
|
||||
|
|
|
@ -106,7 +106,26 @@ public class ModelKnowledgeTest{
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
tree.elaborate(new NodeElaborator<Type>() {
|
||||
|
||||
@Override
|
||||
public void elaborate(Node<Type> node, int level) throws Exception {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (int i = 0; i < level; ++i) {
|
||||
stringBuffer.append(Node.INDENTATION);
|
||||
}
|
||||
|
||||
Type type = node.getNodeElement();
|
||||
String typeName = type.getName();
|
||||
|
||||
String definition = TypeMapper.serializeTypeDefinition(type);
|
||||
|
||||
logger.info("{}- {}{} {}", stringBuffer.toString(), typeName, level==0 ? " (ROOT) " : "", definition);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue