From e7d6496cea2ce09b197247fc39e72fe52ef55270 Mon Sep 17 00:00:00 2001 From: michaelpede Date: Thu, 13 May 2021 13:00:58 -0700 Subject: [PATCH] Enum Annotations. Decimal precision fields. --- .../reso/service/data/meta/EnumFieldInfo.java | 6 +-- .../org/reso/service/data/meta/FieldInfo.java | 37 +++++++++++++++++++ .../service/edmprovider/RESOedmProvider.java | 30 +++++++-------- 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/reso/service/data/meta/EnumFieldInfo.java b/src/main/java/org/reso/service/data/meta/EnumFieldInfo.java index 12f0597..fb2dbbd 100644 --- a/src/main/java/org/reso/service/data/meta/EnumFieldInfo.java +++ b/src/main/java/org/reso/service/data/meta/EnumFieldInfo.java @@ -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(); } diff --git a/src/main/java/org/reso/service/data/meta/FieldInfo.java b/src/main/java/org/reso/service/data/meta/FieldInfo.java index 9ba8309..db70955 100644 --- a/src/main/java/org/reso/service/data/meta/FieldInfo.java +++ b/src/main/java/org/reso/service/data/meta/FieldInfo.java @@ -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 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; diff --git a/src/main/java/org/reso/service/edmprovider/RESOedmProvider.java b/src/main/java/org/reso/service/edmprovider/RESOedmProvider.java index da5f9d0..e8ed982 100644 --- a/src/main/java/org/reso/service/edmprovider/RESOedmProvider.java +++ b/src/main/java/org/reso/service/edmprovider/RESOedmProvider.java @@ -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 annotations = field.getAnnotations(); if (annotations!=null) { @@ -162,7 +174,7 @@ public class RESOedmProvider extends CsdlAbstractEdmProvider enumSchema.setNamespace(NAMESPACE+".enums"); // add EntityTypes - List entityTypes = new ArrayList(); + List entityTypes = new ArrayList<>(); HashMap enumList = new HashMap<>(); @@ -214,25 +226,11 @@ public class RESOedmProvider extends CsdlAbstractEdmProvider schema.setEntityContainer(getEntityContainer()); // finally - List schemas = new ArrayList(); + List 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; }