Merge "support legacy enumeration mapping"
authorDan Timoney <dt5972@att.com>
Wed, 25 Jul 2018 14:48:58 +0000 (14:48 +0000)
committerGerrit Code Review <gerrit@onap.org>
Wed, 25 Jul 2018 14:48:58 +0000 (14:48 +0000)
1  2 
sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java

@@@ -50,7 -50,12 +50,12 @@@ public class MdsalHelper 
  
      private static final Logger LOG = LoggerFactory.getLogger(MdsalHelper.class);
      private static Properties yangMappingProperties = new Properties();
+     protected static boolean useLegacyEnumerationMapping = false;
+     
+     public static void useLegacyEnumerationMapping(Boolean bool) {
+         useLegacyEnumerationMapping = bool;
+     }
+     
      @Deprecated
      public static void setProperties(Properties input) {
          setYangMappingProperties(input);
                                  }
                                  if (retValue != null) {
                                      String propName = propNamePfx + "." + fieldName;
-                                     Method method = retValue.getClass().getMethod("getName");
-                                     String yangValue = (String) method.invoke(retValue);
-                                     props.setProperty(propName, yangValue);
+                                     if(useLegacyEnumerationMapping) {
+                                         propVal = retValue.toString();
+                                         props.setProperty(propName, mapEnumeratedValue(fieldName, propVal));
+                                     }else {
+                                         Method method = retValue.getClass().getMethod("getName");
+                                         String yangValue = (String) method.invoke(retValue);
+                                         props.setProperty(propName, yangValue);
+                                     }
                                  }
                              } catch (Exception e) {
                                  LOG.error(
                      Class returnClass = m.getReturnType();
  
                      String fieldName = toLowerHyphen(m.getName().substring(3));
 -                    fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1);
 -
 +                    if(fieldName!=null) {
 +                        fieldName = fieldName.substring(0, 1).toLowerCase() + fieldName.substring(1);
 +                    }else {
 +                        fieldName="";
 +                    }
                      String propName = propNamePfx + "." + fieldName;
  
                      // Is the return type a yang generated class?
      }
  
      public static boolean isYangGenerated(Class c) {
 -        if (c == null) {
 -            return (false);
 -        } else {
 +        if (c != null) {
              return (c.getName().startsWith("org.opendaylight.yang.gen."));
          }
 +        return false;
      }
  
      public static boolean isIpPrefix(Class c) {