Enum Annotations. Decimal precision fields.

This commit is contained in:
michaelpede 2021-05-13 13:00:58 -07:00
parent ba6f8a6f50
commit e7d6496cea
3 changed files with 54 additions and 19 deletions

View File

@ -73,7 +73,8 @@ public class EnumFieldInfo extends FieldInfo
{
if (values.size()==0)
{
loadValues();
EnumValueInfo sampleValue = new EnumValueInfo("Sample"+lookupName+"EnumValue");
values.add(sampleValue);
}
return values;
@ -85,14 +86,13 @@ public class EnumFieldInfo extends FieldInfo
{
if (values.size()==0)
{
loadValues();
getValues();
}
if (values.size()>0)
{
return new FullQualifiedName("org.reso.metadata.enums." + lookupName);
}
LOG.info("No values for lookup: "+lookupName);
return super.getType();
}

View File

@ -15,6 +15,8 @@ public class FieldInfo
private String fieldName = null;
private FullQualifiedName type = null;
private Integer maxLength = null;
private Integer precision = null;
private Integer scale = null;
private ArrayList<CsdlAnnotation> annotations = null;
@ -73,12 +75,47 @@ public class FieldInfo
this.maxLength = maxLength;
}
/**
* Set the Decimal Precision.
*
* @param precision The value to set the attribute to.
*/
public void setPrecision(Integer precision)
{
this.precision = precision;
}
/**
* Set the Decimal Scale.
*
* @param scale The value to set the attribute to.
*/
public void setScale(Integer scale)
{
this.scale = scale;
}
public Integer getMaxLength()
{
return maxLength;
}
public Integer getPrecision()
{
return precision;
}
public Integer getScale()
{
return scale;
}
public boolean isCollection()
{
return false;

View File

@ -61,6 +61,18 @@ public class RESOedmProvider extends CsdlAbstractEdmProvider
property.setMaxLength(maxLength);
}
Integer precision = field.getPrecision();
if (null!=precision)
{
property.setPrecision(precision);
}
Integer scale = field.getScale();
if (null!=scale)
{
property.setScale(scale);
}
ArrayList<CsdlAnnotation> annotations = field.getAnnotations();
if (annotations!=null)
{
@ -162,7 +174,7 @@ public class RESOedmProvider extends CsdlAbstractEdmProvider
enumSchema.setNamespace(NAMESPACE+".enums");
// add EntityTypes
List<CsdlEntityType> entityTypes = new ArrayList<CsdlEntityType>();
List<CsdlEntityType> entityTypes = new ArrayList<>();
HashMap<String, Boolean> enumList = new HashMap<>();
@ -214,25 +226,11 @@ public class RESOedmProvider extends CsdlAbstractEdmProvider
schema.setEntityContainer(getEntityContainer());
// finally
List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
List<CsdlSchema> schemas = new ArrayList<>();
schemas.add(schema);
/**
// Example of how to create enum types.
CsdlEnumType type = new CsdlEnumType();
type.setMembers(Arrays.asList(
new CsdlEnumMember().setName("LOW"),
new CsdlEnumMember().setName("MEDIUM").setValue("1")
));
type.setName("EnumTest");
type.setUnderlyingType(EdmPrimitiveTypeKind.Int64.getFullQualifiedName());
enumSchema.getEnumTypes().add(type);
/**/
schemas.add(enumSchema);
return schemas;
}