Fix Wrong Data Names 53/42553/1
authorWang,Frank(gw1218) <gw1218@att.com>
Thu, 12 Apr 2018 16:59:00 +0000 (11:59 -0500)
committerWang,Frank(gw1218) <gw1218@att.com>
Thu, 12 Apr 2018 16:59:16 +0000 (11:59 -0500)
Fix wrong data names due to reponse changes

Issue-ID: POLICY-740
Change-Id: I28db745f88ccecd67f3daa30adf70cc69645b496
Signed-off-by: Wang,Frank(gw1218) <gw1218@att.com>
ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSHeaderDefaultValuesDictController.js
POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/MSHeaderDefaultValuesDictGridController.js
POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js

index 91e7626..7db16bd 100644 (file)
@@ -96,6 +96,7 @@ public class MSModelUtils {
        public static final String STRING="string";
        public static final String INTEGER="integer";
        public static final String LIST="list";
+       public static final String MAP="map";
        public static final String DEFAULT=".default";
        public static final String MANYFALSE=":MANY-false";
        public static final String MANYTRUE=":MANY-true";
@@ -1075,7 +1076,7 @@ public class MSModelUtils {
                                        attributeIndividualStringBuilder.append(requiredValue+MANYFALSE);
                                        dataMapForJson.put(uniqueDataKey, attributeIndividualStringBuilder.toString());         
                                }
-                               else if(typeValue != null && typeValue.equalsIgnoreCase(LIST)){
+                               else if(LIST.equalsIgnoreCase(typeValue) || MAP.equalsIgnoreCase(typeValue)){
                                        logger.info("requiredValue is:"+ requiredValue);
                                        String findList= DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+".entry_schema.type";
                                        String listValue=map.get(findList);
@@ -1091,7 +1092,11 @@ public class MSModelUtils {
                                                }//Its string
                                                else{
                                                        StringBuilder stringListItems= new StringBuilder();
-                                                       stringListItems.append(uniqueDataKeySplit[1].toUpperCase()+REQUIREDVALUE+requiredValue +MANYFALSE);
+                                                       if(LIST.equalsIgnoreCase(typeValue)){
+                                                           stringListItems.append(uniqueDataKeySplit[1].toUpperCase()+":required-"+requiredValue +":MANY-false");
+                                                       }else if( MAP.equalsIgnoreCase(typeValue)){
+                                                               stringListItems.append(uniqueDataKeySplit[1].toUpperCase()+":required-"+requiredValue +":MANY-true");
+                                                       }
                                                        dataMapForJson.put(uniqueDataKey, stringListItems.toString());
                                                        dataListBuffer.append(uniqueDataKeySplit[1].toUpperCase()+"=[");
                                                        for(int i=0;i<10;i++){
index 883ac25..960d76b 100644 (file)
@@ -112,12 +112,13 @@ app.controller('editMSHeaderDefaultValuesController' ,  function ($scope, $modal
                                data: JSON.stringify(postData),
                                success : function(data){
                                        $scope.$apply(function(){
-                                               $scope.microServiceAttributeDictionaryDatas=data.microServiceHeaderDefaultDatas;});
+                                               $scope.microServiceHeaderDefaultDatas=data.microServiceHeaderDefaultDatas;});
+                                           console.log("microServiceHeaderDefaultDatas returned after saved: " + $scope.microServiceHeaderDefaultDatas);
                                        if($scope.microServiceAttributeDictionaryDatas == "Duplicate"){
                                                Notification.error("Model Attribute Dictionary exists with Same Attribute Name.")
                                        }else{      
-                                               console.log($scope.microServiceAttributeDictionaryDatas);
-                                               $modalInstance.close({microServiceAttributeDictionaryDatas:$scope.microServiceAttributeDictionaryDatas});
+                                               console.log($scope.microServiceHeaderDefaultDatas);
+                                               $modalInstance.close({microServiceHeaderDefaultDatas:$scope.microServiceHeaderDefaultDatas});
                                        }
                                },
                                error : function(data){
index 5a86c14..4e6b969 100644 (file)
@@ -143,7 +143,7 @@ app.controller('msHeaderDefaultValuesDictGridController', function ($scope, Poli
     };
 
     $scope.deleteModelAttribute = function(data) {
-        modalService.popupConfirmWin("Confirm","You are about to delete the Header Default Values :  "+data.name+". Do you want to continue?",
+        modalService.popupConfirmWin("Confirm","You are about to delete the Header Default Values :  "+data.modelName+". Do you want to continue?",
             function(){
                 var uuu =  "deleteDictionary/ms_dictionary/remove_headerDefaults";
                 var postData={data: data};
index 1b43370..2105ab2 100644 (file)
@@ -748,23 +748,32 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
                                
                                var subAttributes = $scope.dcaeModelData.sub_attributes;
                                
-                               if(subAttributes){                                      
-                                       var jsonObject = JSON.parse(subAttributes);                                     
-                                       var allkeys = Object.keys(jsonObject);
-                                       if(allkeys){
-                                               for (var k = 0; k < allkeys.length; k++) {
-                                                       var keyValue = allkeys[k];
-                                                       console.log(" keyValue:jsonObject["+keyValue+ "]: " + jsonObject[keyValue]);
-                                                       if(jsonObject[keyValue]){
-                                                               var tempObject = jsonObject[keyValue];
-                                                               if(tempObject && tempObject[key]){
-                                                               if (tempObject[key].includes('required-true')){
+                               if(subAttributes){                                      
+                                       var jsonObject = JSON.parse(subAttributes);     
+                                       
+                                   var lablInfo = findVal(jsonObject, attributekey);
+                                       console.log("deconstructJSON:findValue : " + attributekey +": "+ lablInfo);
+                                       if (lablInfo){
+                                               if(lablInfo.includes('required-true')){
+                                                       isRequired = true;
+                                               }       
+                                       }else{                                  
+                                          var allkeys = Object.keys(jsonObject);
+                                          if(allkeys){
+                                                  for (var k = 0; k < allkeys.length; k++) {
+                                                         var keyValue = allkeys[k];
+                                                         console.log(" keyValue:jsonObject["+keyValue+ "]: " + jsonObject[keyValue]);
+                                                         if(jsonObject[keyValue]){
+                                                                var tempObject = jsonObject[keyValue];
+                                                                if(tempObject && tempObject[key]){
+                                                                if (tempObject[key].includes('required-true')){
                                                                        isRequired = true;
-                                                               }       
-                                                               }
-                                                       }
-                                               }                                               
-                                       }                                       
+                                                                }      
+                                                                }
+                                                         }
+                                                  }                                            
+                                          }                                    
+                                       } 
                                }
                                
                                var elementObject = {};