Fixing TypeBinder for resource serialization

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/information-system-model@129865 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-07-04 13:29:44 +00:00
parent 2eeb056a59
commit 03e671643e
1 changed files with 14 additions and 16 deletions

View File

@ -122,28 +122,28 @@ public class TypeBinder {
protected static Property getProperty(ISProperty propertyAnnotation, Method method){
String name = propertyAnnotation.name().isEmpty()?getPropertyNameFromMethodName(method):propertyAnnotation.name();
Property prop = new Property();
prop.name = name;
prop.description = propertyAnnotation.description();
prop.mandatory= propertyAnnotation.mandatory();
prop.notnull = !propertyAnnotation.nullable();
prop.readonly = propertyAnnotation.readonly();
if(propertyAnnotation.max()>0) prop.max = propertyAnnotation.max();
if(propertyAnnotation.max()>=propertyAnnotation.min() && propertyAnnotation.min()>0) prop.min = propertyAnnotation.min();
if(!propertyAnnotation.regexpr().isEmpty()) prop.regexpr = propertyAnnotation.regexpr();
Property property = new Property();
property.name = name;
property.description = propertyAnnotation.description();
property.mandatory= propertyAnnotation.mandatory();
property.notnull = !propertyAnnotation.nullable();
property.readonly = propertyAnnotation.readonly();
if(propertyAnnotation.max()>0) property.max = propertyAnnotation.max();
if(propertyAnnotation.max()>=propertyAnnotation.min() && propertyAnnotation.min()>0) property.min = propertyAnnotation.min();
if(!propertyAnnotation.regexpr().isEmpty()) property.regexpr = propertyAnnotation.regexpr();
logger.trace("Looking for property type type {}", method.getReturnType());
Class<?> type = method.getReturnType();
if(Embedded.class.isAssignableFrom(type)){
prop.linkedClass = getStaticStringFieldByName(type, NAME, type.getSimpleName());
prop.type = OType.EMBEDDED.getIntValue();
property.linkedClass = getStaticStringFieldByName(type, NAME, type.getSimpleName());
property.type = OType.EMBEDDED.getIntValue();
}else if (Type.getTypeByClass(type)!=null) {
prop.type = Type.getTypeByClass(type).getIntValue();
property.type = Type.getTypeByClass(type).getIntValue();
} else {
throw new RuntimeException("Type " + type.getSimpleName() + " not reconized");
}
return prop;
return property;
}
@ -209,12 +209,10 @@ public class TypeBinder {
return properties;
}
}
@JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY)
public static class Property{
public static class Property {
private String name= "";
private String description= "";