diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/PolicyAddScopeRoleController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/PolicyAddScopeRoleController.js
index 051a913..7715c77 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/PolicyAddScopeRoleController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/PolicyAddScopeRoleController.js
@@ -17,7 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller('editRoleController' ,  function ($scope, PolicyAppService, $modalInstance, message){
+app.controller('editRoleController' ,  function ($scope, PolicyAppService, $modalInstance, message, Notification){
     if (message.editRoleData != null) {
         $scope.label='Edit Role'
         $scope.disableCd=true;
@@ -67,7 +67,7 @@
                 $modalInstance.close({rolesDatas:$scope.rolesDatas});
             },
             error : function(data){
-                alert("Error while saving Role.");
+                Notification.error("Error while saving Role.");
             }
         });
     };
@@ -90,7 +90,7 @@
                 $modalInstance.close({rolesDatas:$scope.rolesDatas});
             },
             error : function(data) {
-                alert("Error while Creating Mechid scopes.");
+                Notification.error("Error while Creating Mechid scopes.");
             }
         });
     };
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/BRMSControllerDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/BRMSControllerDictController.js
index 19b4732..a6de84e 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/BRMSControllerDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/BRMSControllerDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -66,7 +66,7 @@
 							}
 						},
 						error : function(data){
-							alert("Error while saving.");
+							Notification.error("Error while saving.");
 						}
 					});
 				}else{
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/BRMSDependencyDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/BRMSDependencyDictController.js
index 25a19ba..f1157e8 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/BRMSDependencyDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/BRMSDependencyDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -66,7 +66,7 @@
 							}
 						},
 						error : function(data){
-							alert("Error while saving.");
+							Notification.error("Error while saving.");
 						}
 					});
 				}else{
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLPepOptionsDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLPepOptionsDictController.js
index 9bcf8dd..da389a8 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLPepOptionsDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLPepOptionsDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -85,7 +85,7 @@
     				}	
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLServiceDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLServiceDictController.js
index b8bc0f9..b3e2fe0 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLServiceDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLServiceDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLSiteDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLSiteDictController.js
index a673df5..cd2d896 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLSiteDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLSiteDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
     				}   
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notofication.error("Error while saving.");
     			}
     		});
     	} 
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLVarbindDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLVarbindDictController.js
index 3b2a13f..44d62c5 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLVarbindDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLVarbindDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	} 
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLVnfTypeDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLVnfTypeDictController.js
index 0d03362..eb71a10 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLVnfTypeDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLVnfTypeDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLVsclActionDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLVsclActionDictController.js
index 106a824..cb78c4a 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLVsclActionDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/CLVsclActionDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DecisionRainyDayDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DecisionRainyDayDictController.js
index fa14dfd..410ef26 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DecisionRainyDayDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DecisionRainyDayDictController.js
@@ -71,7 +71,7 @@
 				}
 			},
 			error : function(data){
-				alert("Error while saving.");
+				Notification.error("Error while saving.");
 			}
 		});
     };
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DecisionSettingsDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DecisionSettingsDictController.js
index fb2dd40..99379fd 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DecisionSettingsDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DecisionSettingsDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DescriptiveSearchDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DescriptiveSearchDictController.js
index 266532a..39d4058 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DescriptiveSearchDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/DescriptiveSearchDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -86,7 +86,7 @@
 
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/EnforcerDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/EnforcerDictController.js
index 38f8f39..2c6a670 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/EnforcerDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/EnforcerDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-var editEnforcerTypeController =  function ($scope, $modalInstance, message, UserInfoServiceDS2){
+var editEnforcerTypeController =  function ($scope, $modalInstance, message, UserInfoServiceDS2, Notification){
     if(message.enforcerDictionaryData==null)
         $scope.label='Add Enforcing Type'
     else{
@@ -25,14 +25,14 @@
         $scope.disableCd=true;
     }
     $scope.editEnforcerType = message.enforcerDictionaryData;
-	
-	/*getting user info from session*/
-	var userid = null;
-	UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
-	  	.then(function (response) {	  		
-	  		userid = response.userid;	  	
-	 });
-	
+    
+    /*getting user info from session*/
+    var userid = null;
+    UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
+          .then(function (response) {              
+              userid = response.userid;          
+     });
+    
     $scope.saveEnforcerType = function(enforcerDictionaryData) {
         var uuu = "saveDictionary/enforcer_dictionary/save_enforcerType";
         var postData={enforcerDictionaryData: enforcerDictionaryData, userid: userid};
@@ -49,7 +49,7 @@
                 $modalInstance.close({enforcerDictionaryDatas:$scope.enforcerDictionaryDatas});
             },
             error : function(data){
-                alert("Error while saving.");
+                Notification.error("Error while saving.");
             }
         });
     };
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWActionListDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWActionListDictController.js
index 1eff963..9d09959 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWActionListDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWActionListDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWAddressGroupDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWAddressGroupDictController.js
index e9e4c3f..442eae9 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWAddressGroupDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWAddressGroupDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -87,7 +87,7 @@
     				}    
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWParentListDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWParentListDictController.js
index 62b4a5b..46f9976 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWParentListDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWParentListDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -111,7 +111,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWPortListDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWPortListDictController.js
index 66caf4d..99e5430 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWPortListDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWPortListDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWPrefixListDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWPrefixListDictController.js
index 1925e5f..485af3a 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWPrefixListDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWPrefixListDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@
     					}
     				},
     				error : function(data){
-    					alert("Error while saving.");
+    					Notification.error("Error while saving.");
     				}
     			});
     		}else{
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWProtocolListDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWProtocolListDictController.js
index 82b1be7..5d382c6 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWProtocolListDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWProtocolListDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});	
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWSecurityZoneDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWSecurityZoneDictController.js
index 7d8da9d..a5238ee 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWSecurityZoneDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWSecurityZoneDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,44 +24,44 @@
         $scope.label='Edit Security Zone'
         $scope.disableCd=true;
     }
-	
-	/*getting user info from session*/
-	var userid = null;
-	UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
-	  	.then(function (response) {	  		
-	  		userid = response.userid;	  	
-	 });
-	
+    
+    /*getting user info from session*/
+    var userid = null;
+    UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
+          .then(function (response) {              
+              userid = response.userid;          
+     });
+    
     $scope.editSecurityZone = message.securityZoneDictionaryData;
 
     $scope.saveSecurityZone = function(securityZoneDictionaryData) {
-    	var regex = new RegExp("^[a-zA-Z0-9_]*$");
-		if(!regex.test(securityZoneDictionaryData.zoneName)) {
-			Notification.error("Enter Valid Security Zone Name without spaces or special characters");
-		}else{
-			var uuu = "saveDictionary/fw_dictionary/save_securityZone";
-	        var postData={securityZoneDictionaryData: securityZoneDictionaryData, userid: userid};
-	        $.ajax({
-	            type : 'POST',
-	            url : uuu,
-	            dataType: 'json',
-	            contentType: 'application/json',
-	            data: JSON.stringify(postData),
-	            success : function(data){
-	                $scope.$apply(function(){
-	                    $scope.securityZoneDictionaryDatas=data.securityZoneDictionaryDatas;});
-	                if($scope.securityZoneDictionaryDatas == "Duplicate"){
-	                	Notification.error("FW SecurityZone Dictionary exists with Same Zone Name.")
-	                }else{      
-	                	console.log($scope.securityZoneDictionaryDatas);
-	                    $modalInstance.close({securityZoneDictionaryDatas:$scope.securityZoneDictionaryDatas});
-	                }
-	            },
-	            error : function(data){
-	                alert("Error while saving.");
-	            }
-	        });
-		}
+        var regex = new RegExp("^[a-zA-Z0-9_]*$");
+        if(!regex.test(securityZoneDictionaryData.zoneName)) {
+            Notification.error("Enter Valid Security Zone Name without spaces or special characters");
+        }else{
+            var uuu = "saveDictionary/fw_dictionary/save_securityZone";
+            var postData={securityZoneDictionaryData: securityZoneDictionaryData, userid: userid};
+            $.ajax({
+                type : 'POST',
+                url : uuu,
+                dataType: 'json',
+                contentType: 'application/json',
+                data: JSON.stringify(postData),
+                success : function(data){
+                    $scope.$apply(function(){
+                        $scope.securityZoneDictionaryDatas=data.securityZoneDictionaryDatas;});
+                    if($scope.securityZoneDictionaryDatas == "Duplicate"){
+                        Notification.error("FW SecurityZone Dictionary exists with Same Zone Name.")
+                    }else{      
+                        console.log($scope.securityZoneDictionaryDatas);
+                        $modalInstance.close({securityZoneDictionaryDatas:$scope.securityZoneDictionaryDatas});
+                    }
+                },
+                error : function(data){
+                    Notification.error("Error while saving.");
+                }
+            });
+        }
     };
 
     $scope.close = function() {
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWServiceGroupDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWServiceGroupDictController.js
index 43219ba..dc3ae6e 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWServiceGroupDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWServiceGroupDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -87,7 +87,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWServiceListDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWServiceListDictController.js
index 0a6e8ba..58b7be3 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWServiceListDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWServiceListDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -104,7 +104,7 @@
 					}
 				},
 				error : function(data){
-					alert("Error while saving.");
+					Notification.error("Error while saving.");
 				}
 			});
 		}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTagListDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTagListDictController.js
index c70b3dd..7596e07 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTagListDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTagListDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -75,7 +75,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTagPickerListDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTagPickerListDictController.js
index ed6571d..d813602 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTagPickerListDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTagPickerListDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -121,7 +121,7 @@
 
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTermListDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTermListDictController.js
index 7308419..c89fe9b 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTermListDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWTermListDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -256,7 +256,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWZoneDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWZoneDictController.js
index bdb10f5..4d1e605 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWZoneDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/FWZoneDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSConfigNameDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSConfigNameDictController.js
index a1b7038..743681a 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSConfigNameDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSConfigNameDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});	
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSDcaeUUIDDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSDcaeUUIDDictController.js
index 6fbb9b3..cd9a785 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSDcaeUUIDDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSDcaeUUIDDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSDictionaryController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSDictionaryController.js
index 21b8969..a3a9349 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSDictionaryController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSDictionaryController.js
@@ -59,7 +59,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});	
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSHeaderDefaultValuesDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSHeaderDefaultValuesDictController.js
index 960d76b..8492a96 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSHeaderDefaultValuesDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSHeaderDefaultValuesDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -122,7 +122,7 @@
 	    				}
 	    			},
 	    			error : function(data){
-	    				alert("Error while saving.");
+	    				Notification.error("Error while saving.");
 	    			}
 	    	});
 	    	
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSLocationDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSLocationDictController.js
index fbd8e35..198ea48 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSLocationDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSLocationDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/ModelAttributeDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/ModelAttributeDictController.js
index 242615e..c03c7de 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/ModelAttributeDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/ModelAttributeDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -84,7 +84,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSClosedLoopDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSClosedLoopDictController.js
index 8377a87..d2357ba 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSClosedLoopDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSClosedLoopDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSResourceDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSResourceDictController.js
index 7aa0283..1afdcd6 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSResourceDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSResourceDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSServiceDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSServiceDictController.js
index 53c6776..7946a14 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSServiceDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSServiceDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
     				}  
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSTypeDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSTypeDictController.js
index 9305e23..de87f13 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSTypeDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSTypeDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@
     				} 
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/RiskTypeDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/RiskTypeDictController.js
index 48ff663..5650919 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/RiskTypeDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/RiskTypeDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/SafePolicyWarningDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/SafePolicyWarningDictController.js
index e072622..5381028 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/SafePolicyWarningDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/SafePolicyWarningDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -91,7 +91,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/actionPolicyDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/actionPolicyDictController.js
index 5722119..4614ed5 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/actionPolicyDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/actionPolicyDictController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -84,7 +84,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/attributeDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/attributeDictController.js
index 663e2af..3e54dd3 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/attributeDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/attributeDictController.js
@@ -74,7 +74,7 @@
     				}
     			},
     			error : function(data){
-    				alert("Error while saving.");
+    				Notification.error("Error while saving.");
     			}
     		});
     	}	
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/onapNameEditorController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/onapNameEditorController.js
index 2a2e743..c6ae5ff 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/onapNameEditorController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/onapNameEditorController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
 					}
 				},
 				error : function(data){
-					alert("Error while saving.");
+					Notification.error("Error while saving.");
 				}
 			});
 		}
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/BRMSParamDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/BRMSParamDictGridController.js
index 50e14ea..af1c346 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/BRMSParamDictGridController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/BRMSParamDictGridController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller('brmsParamDictGridController', function ($scope, PolicyAppService,modalService, $modal){
+app.controller('brmsParamDictGridController', function ($scope, PolicyAppService,modalService, $modal, Notification){
 	$( "#dialog" ).hide();
 
 	PolicyAppService.getData('getDictionary/get_BRMSParamData').then(function (data) {
@@ -164,7 +164,7 @@
 					})}
 			},
 			error : function(data){
-				alert("Error while Searching.");
+				Notification.error("Error while Searching.");
 			}
 		});
 	};
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLPepOptionsDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLPepOptionsDictGridController.js
index cb79d6d..1292139 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLPepOptionsDictGridController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLPepOptionsDictGridController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller('pepOptionsDictGridController', function ($scope, PolicyAppService, modalService, $modal){
+app.controller('pepOptionsDictGridController', function ($scope, PolicyAppService, modalService, $modal, Notification){
 	$( "#dialog" ).hide();
 
 
@@ -189,7 +189,7 @@
 					})}
 			},
 			error : function(data){
-				alert("Error while Searching.");
+				Notification.error("Error while Searching.");
 			}
 		});
 	};
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLServiceDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLServiceDictGridController.js
index de692a4..d41e940 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLServiceDictGridController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLServiceDictGridController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller('serviceDictGridController', function ($scope, PolicyAppService, modalService, $modal){
+app.controller('serviceDictGridController', function ($scope, PolicyAppService, modalService, $modal, Notification){
 	$( "#dialog" ).hide();
 
 	PolicyAppService.getData('getDictionary/get_ClosedLoopServicesData').then(function (data) {
@@ -187,7 +187,7 @@
 					})}
 			},
 			error : function(data){
-				alert("Error while Searching.");
+				Notification.error("Error while Searching.");
 			}
 		});
 	};
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLSiteDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLSiteDictGridController.js
index abf44f8..f723752 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLSiteDictGridController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLSiteDictGridController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller('siteDictGridController', function ($scope, PolicyAppService, modalService, $modal){
+app.controller('siteDictGridController', function ($scope, PolicyAppService, modalService, $modal, Notification){
 	$( "#dialog" ).hide();
 
 	PolicyAppService.getData('getDictionary/get_ClosedLoopSiteData').then(function (data) {
@@ -187,7 +187,7 @@
 					})}
 			},
 			error : function(data){
-				alert("Error while Searching.");
+				Notification.error("Error while Searching.");
 			}
 		});
 	};
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVarbindDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVarbindDictGridController.js
index 4e13b97..e2a69bd 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVarbindDictGridController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVarbindDictGridController.js
@@ -17,7 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller('varbindDictGridController', function ($scope, PolicyAppService, modalService, $modal){
+app.controller('varbindDictGridController', function ($scope, PolicyAppService, modalService, $modal, Notification){
     $( "#dialog" ).hide();
     
     PolicyAppService.getData('getDictionary/get_VarbindDictionaryData').then(function (data) {
@@ -188,7 +188,7 @@
     				})}
     		},
     		error : function(data){
-    			alert("Error while Searching.");
+    			Notification.error("Error while Searching.");
     		}
     	});
     };
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVnfTypeDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVnfTypeDictGridController.js
index 90b77e4..22978ba 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVnfTypeDictGridController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVnfTypeDictGridController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller('vnfTypeDictGridController', function ($scope, PolicyAppService, modalService, $modal){
+app.controller('vnfTypeDictGridController', function ($scope, PolicyAppService, modalService, $modal, Notification){
     $( "#dialog" ).hide();
     
     PolicyAppService.getData('getDictionary/get_VNFTypeData').then(function (data) {
@@ -187,7 +187,7 @@
     				})}
     		},
     		error : function(data){
-    			alert("Error while Searching.");
+    			Notification.error("Error while Searching.");
     		}
     	});
     };
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVsclActionDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVsclActionDictGridController.js
index 1c26c21..7077bc5 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVsclActionDictGridController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/CLVsclActionDictGridController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller('vsclActionDictGridController', function ($scope, PolicyAppService, modalService, $modal){
+app.controller('vsclActionDictGridController', function ($scope, PolicyAppService, modalService, $modal, Notification){
     $( "#dialog" ).hide();
     
     PolicyAppService.getData('getDictionary/get_VSCLActionData').then(function (data) {
@@ -188,7 +188,7 @@
     				})}
     		},
     		error : function(data){
-    			alert("Error while Searching.");
+    			Notification.error("Error while Searching.");
     		}
     	});
     };
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/attributeDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/attributeDictGridController.js
index 7604185..7459bd6 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/attributeDictGridController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/attributeDictGridController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller('attributeDictGridController', function ($scope, PolicyAppService, modalService, $modal){
+app.controller('attributeDictGridController', function ($scope, PolicyAppService, modalService, $modal, Notification){
 	$( "#dialog" ).hide();
 
 	PolicyAppService.getData('getDictionary/get_AttributeData').then(function (data) {
@@ -198,7 +198,7 @@
 					})}
 			},
 			error : function(data){
-				alert("Error while Searching.");
+				Notification.error("Error while Searching.");
 			}
 		});
 	};
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/onapNameDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/onapNameDictGridController.js
index 4dd1df8..41f0333 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/onapNameDictGridController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/onapNameDictGridController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller('onapNameDictGridController', function ($scope, PolicyAppService, modalService, $modal, uiGridConstants,Grid){
+app.controller('onapNameDictGridController', function ($scope, PolicyAppService, modalService, $modal, uiGridConstants,Grid, Notification){
     $( "#dialog" ).hide();
     
     PolicyAppService.getData('getDictionary/get_OnapNameData').then(function (data) {
@@ -189,7 +189,7 @@
     				})}
     		},
     		error : function(data){
-    			alert("Error while Searching.");
+    			Notification.error("Error while Searching.");
     		}
     	});	
     };
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/policyAdminTabController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/policyAdminTabController.js
index 4fabc45..a0de546 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/policyAdminTabController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/policyAdminTabController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,50 +17,54 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller("policyAdminController", function($scope, PolicyAppService, modalService, $modal, Notification){
-	$( "#dialog" ).hide();
-	
+app.controller("policyAdminController", function($scope, PolicyAppService, modalService, $modal, Notification) {
+	$("#dialog").hide();
+
 	$scope.isDisabled = true;
-	PolicyAppService.getData('get_LockDownData').then(function(data){
+	PolicyAppService.getData('get_LockDownData').then(function(data) {
 		var j = data;
 		$scope.data = JSON.parse(j.data);
 		$scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
-		 if($scope.lockdowndata[0].lockdown == true){
-			 $scope.isDisabled = true;
-		 }else{
-			 $scope.isDisabled = false;
-		 }
+		if ($scope.lockdowndata[0].lockdown == true) {
+			$scope.isDisabled = true;
+		} else {
+			$scope.isDisabled = false;
+		}
 		console.log($scope.data);
-	},function(error){
+	}, function(error) {
 		console.log("failed");
 	});
-	
-	 $scope.saveLockDownValue = function(lockdownValue){
-	        console.log(lockdownValue);
-		 	if(lockdownValue == true){
-			 	Notification.success("Policy Application has been Locked Successfully");
-			 	 $scope.isDisabled = true;
-		 	}else{
-				Notification.success("Policy Application has been UnLocked Successfully");
-				$scope.isDisabled = false;
-		 	}
-	        var uuu = "adminTabController/save_LockDownValue.htm";
-			var postData={lockdowndata: {lockdown : lockdownValue}};
-			$.ajax({
-				type : 'POST',
-				url : uuu,
-				dataType: 'json',
-				contentType: 'application/json',
-				data: JSON.stringify(postData),
-				success : function(data){
-					$scope.$apply(function(){
-							$scope.data=data.data;
-					});
-					console.log($scope.data);
-				},
-				error : function(data){
-					alert("Error Occured while saving Lockdown Value.");
-				}
-			});
-	    };
+
+	$scope.saveLockDownValue = function(lockdownValue) {
+		console.log(lockdownValue);
+		if (lockdownValue == true) {
+			Notification.success("Policy Application has been Locked Successfully");
+			$scope.isDisabled = true;
+		} else {
+			Notification.success("Policy Application has been UnLocked Successfully");
+			$scope.isDisabled = false;
+		}
+		var uuu = "adminTabController/save_LockDownValue.htm";
+		var postData = {
+			lockdowndata : {
+				lockdown : lockdownValue
+			}
+		};
+		$.ajax({
+			type : 'POST',
+			url : uuu,
+			dataType : 'json',
+			contentType : 'application/json',
+			data : JSON.stringify(postData),
+			success : function(data) {
+				$scope.$apply(function() {
+					$scope.data = data.data;
+				});
+				console.log($scope.data);
+			},
+			error : function(data) {
+				Notification.error("Error Occured while saving Lockdown Value.");
+			}
+		});
+	};
 });
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/modalPopupController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/modalPopupController.js
index 7eb2b45..7b3eca2 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/modalPopupController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/main/modalPopupController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,24 +17,24 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-appDS2.controller('modalpopupController' ,  function ($scope, $modalInstance, message){
-	
-	$scope.message = message;
-	
-	
-	$scope.hello = function () {
+appDS2.controller('modalpopupController' ,  function ($scope, $modalInstance, message, Notification){
+    
+    $scope.message = message;
+    
+    
+    $scope.hello = function () {
         $modalInstance.close($scope.digitPattern);
     };
-	$modalInstance.ok = function() {
+    $modalInstance.ok = function() {
         //add the  ok functionality
-        alert("Logout");        
+        Notification.error("Logout");        
     };
     $modalInstance.cancel = function() {
         //add the cancel functionality
-        alert("Keep Log in");
+        Notification.error("Keep Log in");
     };
     $modalInstance.cancelbutton = function() {
         //add the cancel functionality
-        alert("Modal Waring popup close event");
+        Notification.error("Modal Waring popup close event");
     };
 });
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js
index 028223f..fe55bb2 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSParamPolicyController.js
@@ -17,7 +17,9 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-angular.module('abs').controller('brmsParamPolicyController', ['$scope', '$window', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, $window, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) {
+angular.module('abs').controller('brmsParamPolicyController', 
+    ['$scope', '$window', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', 
+    function ($scope, $window, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) {
     $("#dialog").hide();
 
     $scope.policyNavigator;
@@ -25,18 +27,18 @@
     $scope.refreshCheck = false;
     
     if(!$scope.temp.policy.editPolicy  && !$scope.temp.policy.readOnly){
-    	$scope.temp.policy = {
-    			policyType : "Config",
-    			configPolicyType : "BRMS_Param"
-    	}
+        $scope.temp.policy = {
+            policyType : "Config",
+            configPolicyType : "BRMS_Param"
+        }
     }
     
     $scope.refresh = function(){
-    	if($scope.refreshCheck){
-    		$scope.policyNavigator.refresh();
-    	}
-    	$scope.modal('createNewPolicy', true);
-    	$scope.temp.policy = "";
+        if($scope.refreshCheck){
+            $scope.policyNavigator.refresh();
+        }
+        $scope.modal('createNewPolicy', true);
+        $scope.temp.policy = "";
     };
     
     $scope.modal = function(id, hide) {
@@ -44,66 +46,66 @@
     };
     
     $('#ttlDate').datepicker({
-    	dateFormat: 'dd/mm/yy',
-    	changeMonth: true,
-    	changeYear: true,
-    	onSelect: function(date) {
-    		angular.element($('#ttlDate')).triggerHandler('input');
-    	}
+        dateFormat: 'dd/mm/yy',
+        changeMonth: true,
+        changeYear: true,
+        onSelect: function(date) {
+            angular.element($('#ttlDate')).triggerHandler('input');
+        }
     });
     
     $scope.validateSuccess = true;
     var readValue = $scope.temp.policy.readOnly;
     if(readValue){
-    	 $scope.validateSuccess = false;
+        $scope.validateSuccess = false;
     }
     
     PolicyAppService.getData('getDictionary/get_BRMSControllerDataByName').then(function (data) {
-    	var j = data;
-    	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
-    	$scope.brmsControllerDatas = JSON.parse($scope.data.brmsControllerDictionaryDatas);
-    	console.log($scope.brmsControllerDatas);
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        console.log($scope.data);
+        $scope.brmsControllerDatas = JSON.parse($scope.data.brmsControllerDictionaryDatas);
+        console.log($scope.brmsControllerDatas);
     }, function (error) {
-    	console.log("failed");
+        console.log("failed");
     });
 
     PolicyAppService.getData('getDictionary/get_BRMSDependencyDataByName').then(function (data) {
-    	var j = data;
-    	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
-    	$scope.brmsDependencyDatas = JSON.parse($scope.data.brmsDependencyDictionaryDatas);
-    	console.log($scope.brmsDependencyDatas);
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        console.log($scope.data);
+        $scope.brmsDependencyDatas = JSON.parse($scope.data.brmsDependencyDictionaryDatas);
+        console.log($scope.brmsDependencyDatas);
     }, function (error) {
-    	console.log("failed");
+        console.log("failed");
     });
 
     PolicyAppService.getData('getDictionary/get_BRMSParamDataByName').then(function (data) {
-    	var j = data;
-    	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
-    	$scope.brmsParamDictionaryDatas = JSON.parse($scope.data.brmsParamDictionaryDatas);
-    	console.log($scope.brmsParamDictionaryDatas);
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        console.log($scope.data);
+        $scope.brmsParamDictionaryDatas = JSON.parse($scope.data.brmsParamDictionaryDatas);
+        console.log($scope.brmsParamDictionaryDatas);
     }, function (error) {
-    	console.log("failed");
+        console.log("failed");
     });
 
     PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
-    	var j = data;
-    	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
-    	$scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
-    	console.log($scope.riskTypeDictionaryDatas);
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        console.log($scope.data);
+        $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
+        console.log($scope.riskTypeDictionaryDatas);
     }, function (error) {
-    	console.log("failed");
+        console.log("failed");
     });
     
     $scope.temp.policy.dynamicLayoutMap = {};
     $scope.addDataToFields = function(ruleName){
-    	console.log(ruleName);   
+        console.log(ruleName);   
         if(ruleName != null){
-        	 var uuu = "policyController/getBRMSTemplateData.htm";
-        	 var postData={policyData: ruleName};
+            var uuu = "policyController/getBRMSTemplateData.htm";
+            var postData={policyData: ruleName};
              $.ajax({
                  type : 'POST',
                  url : uuu,
@@ -112,12 +114,12 @@
                  data: JSON.stringify(postData),
                  success : function(data){
                      $scope.$apply(function(){
-                    	 $scope.temp.policy.dynamicLayoutMap = data.policyData;
+                        $scope.temp.policy.dynamicLayoutMap = data.policyData;
                      });
                      console.log( $scope.temp.policy.dynamicLayoutMap);
                  },
                  error : function(data){
-                     alert("Error While Retriving the Template Layout Pattren.");
+                    Notification.error("Error While Retriving the Template Layout Pattren.");
                  }
              });
         }   
@@ -136,30 +138,30 @@
             contentType: 'application/json',
             data: JSON.stringify(postData),
             success : function(data){
-            	$scope.showbrmsrule = false;
-            	$scope.validateSuccess = true;
+                $scope.showbrmsrule = false;
+                $scope.validateSuccess = true;
                 $scope.$apply(function(){
-                	$scope.datarule = data.policyData;
+                    $scope.datarule = data.policyData;
                 });
             },
             error : function(data){
-            	Notification.error("Error Occured while Showing Rule.");
+                Notification.error("Error Occured while Showing Rule.");
             }
         });
     };
     
     $scope.hideRule = function(){
-    	$scope.showbrmsrule = true;
-    	$scope.validateSuccess = false;
-    	$scope.apply();
+        $scope.showbrmsrule = true;
+        $scope.validateSuccess = false;
+        $scope.apply();
     };
     
     $scope.saveBrmsParamPolicy = function(policy){
-    	if(policy.itemContent != undefined){
-    		$scope.refreshCheck = true; 
-        	$scope.policyNavigator = policy.itemContent;
-        	policy.itemContent = "";
-    	}
+        if(policy.itemContent != undefined){
+            $scope.refreshCheck = true; 
+            $scope.policyNavigator = policy.itemContent;
+            policy.itemContent = "";
+        }
         $scope.savebutton = false;
         var uuu = "policycreation/save_policy";
         var postData={policyData: policy};
@@ -173,76 +175,76 @@
                 $scope.$apply(function(){
                     $scope.data=data.policyData;
                     if($scope.data == 'success'){
-                    	$scope.temp.policy.readOnly = 'true';
-                    	$scope.safetyChecker = data.policyData.split("#")[2];
-                    	if ($scope.safetyChecker!=undefined) {
-                    		Notification.success($scope.safetyChecker);
-                    	}
-                    	Notification.success("Policy Saved Successfully.");	
+                        $scope.temp.policy.readOnly = 'true';
+                        $scope.safetyChecker = data.policyData.split("#")[2];
+                        if ($scope.safetyChecker!=undefined) {
+                            Notification.success($scope.safetyChecker);
+                        }
+                        Notification.success("Policy Saved Successfully.");    
                     }else if ($scope.data == 'PolicyExists'){
-						$scope.savebutton = true;
-						Notification.error("Policy Already Exists with Same Name in Scope.");
-					}
+                        $scope.savebutton = true;
+                        Notification.error("Policy Already Exists with Same Name in Scope.");
+                    }
                 });
                 console.log($scope.data);
             },
             error : function(data){
-            	Notification.error("Error Occured while saving Policy.");
-            	$scope.savebutton = true;
+                Notification.error("Error Occured while saving Policy.");
+                $scope.savebutton = true;
             }
         });
     };
 
     $scope.validatePolicy = function(policy){
-    	console.log(policy);
-    	document.getElementById("validate").innerHTML = "";
+        console.log(policy);
+        document.getElementById("validate").innerHTML = "";
         var uuu = "policyController/validate_policy.htm";
- 		var postData={policyData: policy};
- 		$.ajax({
- 			type : 'POST',
- 			url : uuu,
- 			dataType: 'json',
- 			contentType: 'application/json',
- 			data: JSON.stringify(postData),
- 			success : function(data){
- 				$scope.$apply(function(){
- 					$scope.validateData = data.data.replace(/\"/g, "");
-						$scope.data=data.data.substring(1,8);
- 						var size = data.data.length;
- 						if($scope.data == 'success'){
- 							Notification.success("Validation Success.");
- 							$scope.savebutton = false;
- 							if (size > 18){
- 								var displayWarning = data.data.substring(19,size);
- 								document.getElementById("validate").innerHTML = "Safe Policy Warning Message  :  "+displayWarning;
- 								document.getElementById("validate").style.color = "white";
- 								document.getElementById("validate").style.backgroundColor = "skyblue";
- 							}	
- 							$scope.validateSuccess = false;
- 						}else{
- 							Notification.error("Validation Failed.");
- 							document.getElementById("validate").innerHTML = $scope.validateData;
- 							document.getElementById("validate").style.color = "white";
- 							document.getElementById("validate").style.backgroundColor = "red";
- 							$scope.savebutton = true;
- 						}
- 						
- 				});
- 				console.log($scope.data);
- 			},
- 			error : function(data){
- 				Notification.error("Validation Failed.");
- 				$scope.savebutton = true;
- 			}
- 		});
+         var postData={policyData: policy};
+         $.ajax({
+             type : 'POST',
+             url : uuu,
+             dataType: 'json',
+             contentType: 'application/json',
+             data: JSON.stringify(postData),
+             success : function(data){
+                 $scope.$apply(function(){
+                     $scope.validateData = data.data.replace(/\"/g, "");
+                        $scope.data=data.data.substring(1,8);
+                         var size = data.data.length;
+                         if($scope.data == 'success'){
+                             Notification.success("Validation Success.");
+                             $scope.savebutton = false;
+                             if (size > 18){
+                                 var displayWarning = data.data.substring(19,size);
+                                 document.getElementById("validate").innerHTML = "Safe Policy Warning Message  :  "+displayWarning;
+                                 document.getElementById("validate").style.color = "white";
+                                 document.getElementById("validate").style.backgroundColor = "skyblue";
+                             }    
+                             $scope.validateSuccess = false;
+                         }else{
+                             Notification.error("Validation Failed.");
+                             document.getElementById("validate").innerHTML = $scope.validateData;
+                             document.getElementById("validate").style.color = "white";
+                             document.getElementById("validate").style.backgroundColor = "red";
+                             $scope.savebutton = true;
+                         }
+                         
+                 });
+                 console.log($scope.data);
+             },
+             error : function(data){
+                 Notification.error("Validation Failed.");
+                 $scope.savebutton = true;
+             }
+         });
     };
     
     if(!$scope.temp.policy.editPolicy  && !$scope.temp.policy.readOnly){
-    	$scope.temp.policy.attributes = [];
+        $scope.temp.policy.attributes = [];
     }else{
-	   if($scope.temp.policy.attributes.length == 0){
-		   $scope.temp.policy.attributes = [];
-	   }
+      if($scope.temp.policy.attributes.length == 0){
+          $scope.temp.policy.attributes = [];
+      }
    }
     
     $scope.attributeDatas = [{"attributes" : $scope.temp.policy.attributes}];
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
index 4cee212..08f0aa7 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js
@@ -18,7 +18,9 @@
  * ============LICENSE_END=========================================================
  */
 
-angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$window', '$compile', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, $window, $compile, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) {
+angular.module('abs').controller('dcaeMicroServiceController', 
+    ['$scope', '$window', '$compile', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', 
+    function ($scope, $window, $compile, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) {
     $("#dialog").hide();
     
     $scope.policyNavigator;
@@ -29,18 +31,18 @@
     var layer = 0;
     
     if(!$scope.temp.policy.editPolicy  && !$scope.temp.policy.readOnly){
-    	$scope.temp.policy = {
-    			policyType : "Config",
-    			configPolicyType : "Micro Service"
-    	}
+    $scope.temp.policy = {
+        policyType : "Config",
+        configPolicyType : "Micro Service"
+    }
     }
     
     $scope.refresh = function(){
-    	if($scope.refreshCheck){
-    		$scope.policyNavigator.refresh();
-    	}
-    	$scope.modal('createNewPolicy', true);
-    	$scope.temp.policy = "";
+    if($scope.refreshCheck){
+        $scope.policyNavigator.refresh();
+    }
+    $scope.modal('createNewPolicy', true);
+    $scope.temp.policy = "";
     };
     
     $scope.modal = function(id, hide) {
@@ -48,322 +50,322 @@
     };
     
     $('#ttlDate').datepicker({
-    	dateFormat: 'dd/mm/yy',
-    	changeMonth: true,
-    	changeYear: true,
-    	onSelect: function(date) {
-    		angular.element($('#ttlDate')).triggerHandler('input');
-    	}
+    dateFormat: 'dd/mm/yy',
+    changeMonth: true,
+    changeYear: true,
+    onSelect: function(date) {
+        angular.element($('#ttlDate')).triggerHandler('input');
+    }
     });
     
-	if ($scope.temp.policy.editPolicy != undefined|| $scope.temp.policy.readOnly  != undefined){
-		if ($scope.temp.policy.configName == undefined){
-			$scope.isCheck = false;
-		}else{
-			$scope.isCheck = true;
-		}
-	}else {
-		$scope.isCheck = false;
-	}
-		
-	PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);
-		console.log($scope.onapNameDictionaryDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	PolicyAppService.getData('get_DCAEPriorityValues').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.priorityDatas = JSON.parse($scope.data.priorityDatas);
-		console.log($scope.priorityDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	PolicyAppService.getData('getDictionary/get_GroupPolicyScopeDataByName').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.groupPolicyScopeListDatas = JSON.parse($scope.data.groupPolicyScopeListDatas);
-		console.log($scope.groupPolicyScopeListDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	PolicyAppService.getData('getDictionary/get_MicroServiceConfigNameDataByName').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		console.log("$scope.data.microServiceConfigNameDictionaryDatas : " + $scope.data.microServiceConfigNameDictionaryDatas);
-		if($scope.data.microServiceConfigNameDictionaryDatas){
- 		    $scope.microServiceCongigNameDictionaryDatas = JSON.parse($scope.data.microServiceConfigNameDictionaryDatas);
-		}
-		console.log($scope.microServiceCongigNameDictionaryDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	PolicyAppService.getData('getDictionary/get_MicroServiceLocationDataByName').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.microServiceLocationDictionaryDatas = JSON.parse($scope.data.microServiceLocationDictionaryDatas);
-		console.log($scope.microServiceLocationDictionaryDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	PolicyAppService.getData('getDictionary/get_MicroServiceModelsDataByName').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		var inputModelList = JSON.parse($scope.data.microServiceModelsDictionaryDatas);
-		var unique = {};
-		var uniqueList = [];
-		for(var i = 0; i < inputModelList.length; i++){
-			if(typeof unique[inputModelList[i]] == "undefined"){
-				unique[inputModelList[i]] = "";
-				uniqueList.push(inputModelList[i]);
-			}
-		}
-		$scope.microServiceModelsDictionaryDatas = uniqueList;
-		console.log($scope.microServiceModelsDictionaryDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	PolicyAppService.getData('getDictionary/get_DCAEUUIDDataByName').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.dcaeUUIDDictionaryDatas = JSON.parse($scope.data.dcaeUUIDDictionaryDatas);
-		console.log($scope.dcaeUUIDDictionaryDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
-		console.log($scope.riskTypeDictionaryDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	PolicyAppService.getData('getDictionary/get_MicroServiceAttributeData').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.microServiceAttributeDictionaryDatas = JSON.parse($scope.data.microServiceAttributeDictionaryDatas);
-		console.log($scope.microServiceAttributeDictionaryDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-	    
-
-	 $scope.choices = [];
-	 $scope.attributeDatas = [{"attributes" : $scope.choices}];
-	 addNewChoice = function(value) {
-		 console.log("input key : " + value);
-		 var isFoundInRuleData = false;
-		 if(value != undefined){
-			if (value.startsWith('div.')){
-				value = value.replace('div.','');
-			}
-			
-			console.log(" document.getElementById : div."+value);
-			var parentElement = document.getElementById("div."+value);
-			console.log("parentElement : " + parentElement);
-			var div = document.getElementById(value+"@0");
-			if(div != null){
-				var clone = div.cloneNode(true); 
-				var addElement = parentElement.childElementCount;
-				clone.id = ''+value+'@'+addElement;
-				clone.value = '';
-				if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){ //if it's view or edit
-					if($scope.temp.policy.ruleData[clone.id] || $scope.temp.policy.editPolicy){  // Only append child if its value found in ruleData or edit mode
-						if($scope.temp.policy.ruleData[clone.id]){
-						    clone.value = $scope.temp.policy.ruleData[clone.id];
-						    isFoundInRuleData = true;
-						}
-						console.log("  clone.value :" +  clone.value);
-						console.log(" clone.id :" + clone.id);
-						if(!isFoundInRuleData && isInitViewEdit){
-							return;
-						}
-						if(!clone.className.includes("child_single")){
-						   clone.className += ' child_single'; //here cloned is single element
-						}
-						document.getElementById("div."+value).appendChild(clone);
-						plainAttributeKeys.push(''+value+'@'+addElement);
-					}
-				}else{ //not view or edit
-					if(!clone.className.includes("child_single")){
-					    clone.className += ' child_single'; //here cloned is single element
-					}
-					document.getElementById("div."+value).appendChild(clone);
-					plainAttributeKeys.push(''+value+'@'+addElement);
-				}
-			}else{
-				
-				if(parentElement == null){
-					return;
-				}
-				div = document.getElementById("div."+value+"@0");
-				if(div){
-					
-					if(!div.className.includes('children_group border')){
-						layer++;
-						if(layer > 4){ 
-							layer = 1
-						}
-			    	    div.className += ' children_group border' + layer; //here is div with a group of children.
-					}
-				}
-				var childElement = parentElement.firstElementChild;
-				var countParent = parentElement.childElementCount;
-				var childElementString = childElement.innerHTML;
-				var find = value+"@0";
-				var re = new RegExp(find, 'g');
-				childElementString = childElementString.replace(re,value+'@' + countParent);
-				var clone = childElement.cloneNode(true);
-				for (var ii = 0; ii < parentElement.childNodes.length; ii++){
-		            var childId = parentElement.childNodes[ii].id;
-		            if(ii = parentElement.childNodes.length){
-		            	var childnewId = childId.slice(0, -1);
-		            	var count = childId.slice(-1);
-		            }
-		        }
-				var countvalue = parseInt(count) + 1;
-				clone.id = childnewId+countvalue;
-				clone.value = '';
-				clone.innerHTML=childElementString;
-				document.getElementById("div."+value).appendChild(clone);
-				var selects = clone.getElementsByTagName("select");
-				var inputs = clone.getElementsByTagName("input");
-				var removeValues = [];
-				for(var i=0; i<inputs.length; i++){
-					if ($scope.temp.policy.ruleData!=undefined){
-						var checkValue = $scope.temp.policy.ruleData[inputs[i].id];
-						console.log("  checkValue.value :" +  checkValue);
-						console.log(" inputs["+i+"].id :" + inputs[i].id);
-						if (checkValue!=undefined && checkValue != "undefined"){
-							document.getElementById(inputs[i].id).value = checkValue;
-								plainAttributeKeys.push(inputs[i].id);
-						} else {
-							plainAttributeKeys.push(inputs[i].id);
-						}
-					}else {
-						plainAttributeKeys.push(inputs[i].id);
-					}
-				}
-				
-				for(var i=0; i<selects.length; i++){
-					if ($scope.temp.policy.ruleData!=undefined){
-						var checkValue = $scope.temp.policy.ruleData[selects[i].id];
-						if (checkValue!=undefined && checkValue!="undefined"){
-							if($scope.temp.policy.ruleData != null){
-								var checkValue = $scope.temp.policy.ruleData[selects[i].id];
-								var option = document.createElement('option');
-								option.setAttribute('value', checkValue);
-								option.appendChild(document.createTextNode(checkValue));
-								document.getElementById(selects[i].id).appendChild(option);
-								document.getElementById(selects[i].id).value = $scope.temp.policy.ruleData[selects[i].id];
-								plainAttributeKeys.push(selects[i].id);
-							}
-						} else {
-							plainAttributeKeys.push(selects[i].id);
-						}
-					}else {
-						plainAttributeKeys.push(selects[i].id);
-					}
-				}
-				
-				for (var k=0; k<removeValues.length; k++){
-					var elem = document.getElementById(removeValues[k]);
-					elem.parentNode.removeChild(elem);
-				}
-				var ele = angular.element(document.getElementById("div."+value));
-	    		$compile(ele.contents())($scope)
-			}
-		 }
-	 };
-	 
-	
-	 removeChoice = function(value) {
-		 console.log(value);
-		 if(value != undefined){
-			 var c = document.getElementById("div."+value).childElementCount;
-			 
-			 if(c == 1){
-				 Notification.error("The original one is not removable.");
-				 return;
-			 }	
-			 document.getElementById("div."+value).removeChild(document.getElementById("div."+value).lastChild);	 
-		 }
-	 };
-	 
-	 function findVal(object, key) {
-		    var value;
-		    Object.keys(object).some(function(k) {
-		        if (k === key) {
-		            value = object[k];
-		            return true;
-		        }
-		        if (object[k] && typeof object[k] === 'object') {
-		            value = findVal(object[k], key);
-		            return value !== undefined;
-		        }
-		    });
-		    return value;
-	}
-	 
-	 $scope.pullVersion = function(serviceName) {
-		 console.log(serviceName);
-		 if(serviceName != undefined){
-			 var uuu = "policyController/getModelServiceVersioneData.htm";
-			 var postData={policyData: serviceName};
-			 $.ajax({
-				 type : 'POST',
-				 url : uuu,
-				 dataType: 'json',
-				 contentType: 'application/json',
-				 data: JSON.stringify(postData),
-				 success : function(data){
-					 $scope.$apply(function(){
-						 $scope.microServiceModelsDictionaryVersionDatas = data[0].dcaeModelVersionData;
-					 });
-				 },
-				 error : function(data){
-					 alert("Error While Retriving the Template Layout Pattren.");
-				 }
-			 });		 
-		 }
-	 };
+    if ($scope.temp.policy.editPolicy != undefined|| $scope.temp.policy.readOnly  != undefined){
+    if ($scope.temp.policy.configName == undefined){
+    $scope.isCheck = false;
+    }else{
+        $scope.isCheck = true;
+    }
+    }else {
+        $scope.isCheck = false;
+    }
     
-	var splitEqual = '=';
-	var splitComma = ',';
-	var splitcolon = ':';
-	var splitEnum = "],";
-	var plainAttributeKeys = [];
-	var matching = [];
-	var enumKeyList = [];
-	var dictionaryList = [];
-	var dictionaryNameList = [];
-	var isInitViewEdit = false;
+    PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function (data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    console.log($scope.data);
+    $scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);
+    console.log($scope.onapNameDictionaryDatas);
+    }, function (error) {
+    console.log("failed");
+    });
+
+    PolicyAppService.getData('get_DCAEPriorityValues').then(function (data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    console.log($scope.data);
+    $scope.priorityDatas = JSON.parse($scope.data.priorityDatas);
+    console.log($scope.priorityDatas);
+    }, function (error) {
+    console.log("failed");
+    });
+
+    PolicyAppService.getData('getDictionary/get_GroupPolicyScopeDataByName').then(function (data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    console.log($scope.data);
+    $scope.groupPolicyScopeListDatas = JSON.parse($scope.data.groupPolicyScopeListDatas);
+    console.log($scope.groupPolicyScopeListDatas);
+    }, function (error) {
+    console.log("failed");
+    });
+
+    PolicyAppService.getData('getDictionary/get_MicroServiceConfigNameDataByName').then(function (data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    console.log($scope.data);
+    console.log("$scope.data.microServiceConfigNameDictionaryDatas : " + $scope.data.microServiceConfigNameDictionaryDatas);
+    if($scope.data.microServiceConfigNameDictionaryDatas){
+         $scope.microServiceCongigNameDictionaryDatas = JSON.parse($scope.data.microServiceConfigNameDictionaryDatas);
+    }
+    console.log($scope.microServiceCongigNameDictionaryDatas);
+    }, function (error) {
+    console.log("failed");
+    });
+
+    PolicyAppService.getData('getDictionary/get_MicroServiceLocationDataByName').then(function (data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    console.log($scope.data);
+    $scope.microServiceLocationDictionaryDatas = JSON.parse($scope.data.microServiceLocationDictionaryDatas);
+    console.log($scope.microServiceLocationDictionaryDatas);
+    }, function (error) {
+    console.log("failed");
+    });
+
+    PolicyAppService.getData('getDictionary/get_MicroServiceModelsDataByName').then(function (data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    console.log($scope.data);
+    var inputModelList = JSON.parse($scope.data.microServiceModelsDictionaryDatas);
+    var unique = {};
+    var uniqueList = [];
+    for(var i = 0; i < inputModelList.length; i++){
+    if(typeof unique[inputModelList[i]] == "undefined"){
+        unique[inputModelList[i]] = "";
+        uniqueList.push(inputModelList[i]);
+    }
+    }
+    $scope.microServiceModelsDictionaryDatas = uniqueList;
+    console.log($scope.microServiceModelsDictionaryDatas);
+    }, function (error) {
+    console.log("failed");
+    });
+
+    PolicyAppService.getData('getDictionary/get_DCAEUUIDDataByName').then(function (data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    console.log($scope.data);
+    $scope.dcaeUUIDDictionaryDatas = JSON.parse($scope.data.dcaeUUIDDictionaryDatas);
+    console.log($scope.dcaeUUIDDictionaryDatas);
+    }, function (error) {
+    console.log("failed");
+    });
+
+    PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    console.log($scope.data);
+    $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
+    console.log($scope.riskTypeDictionaryDatas);
+    }, function (error) {
+    console.log("failed");
+    });
+
+    PolicyAppService.getData('getDictionary/get_MicroServiceAttributeData').then(function (data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    console.log($scope.data);
+    $scope.microServiceAttributeDictionaryDatas = JSON.parse($scope.data.microServiceAttributeDictionaryDatas);
+    console.log($scope.microServiceAttributeDictionaryDatas);
+    }, function (error) {
+    console.log("failed");
+    });
+        
+
+     $scope.choices = [];
+     $scope.attributeDatas = [{"attributes" : $scope.choices}];
+     addNewChoice = function(value) {
+     console.log("input key : " + value);
+     var isFoundInRuleData = false;
+     if(value != undefined){
+    if (value.startsWith('div.')){
+        value = value.replace('div.','');
+    }
+    
+    console.log(" document.getElementById : div."+value);
+    var parentElement = document.getElementById("div."+value);
+    console.log("parentElement : " + parentElement);
+    var div = document.getElementById(value+"@0");
+    if(div != null){
+        var clone = div.cloneNode(true); 
+        var addElement = parentElement.childElementCount;
+        clone.id = ''+value+'@'+addElement;
+        clone.value = '';
+        if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){ //if it's view or edit
+        if($scope.temp.policy.ruleData[clone.id] || $scope.temp.policy.editPolicy){  // Only append child if its value found in ruleData or edit mode
+            if($scope.temp.policy.ruleData[clone.id]){
+                clone.value = $scope.temp.policy.ruleData[clone.id];
+                isFoundInRuleData = true;
+            }
+            console.log("  clone.value :" +  clone.value);
+            console.log(" clone.id :" + clone.id);
+            if(!isFoundInRuleData && isInitViewEdit){
+            return;
+            }
+            if(!clone.className.includes("child_single")){
+               clone.className += ' child_single'; //here cloned is single element
+            }
+            document.getElementById("div."+value).appendChild(clone);
+            plainAttributeKeys.push(''+value+'@'+addElement);
+        }
+        }else{ //not view or edit
+        if(!clone.className.includes("child_single")){
+            clone.className += ' child_single'; //here cloned is single element
+        }
+        document.getElementById("div."+value).appendChild(clone);
+        plainAttributeKeys.push(''+value+'@'+addElement);
+        }
+    }else{
+        
+        if(parentElement == null){
+        return;
+        }
+        div = document.getElementById("div."+value+"@0");
+        if(div){
+        
+        if(!div.className.includes('children_group border')){
+            layer++;
+            if(layer > 4){ 
+            layer = 1
+            }
+            div.className += ' children_group border' + layer; //here is div with a group of children.
+        }
+        }
+        var childElement = parentElement.firstElementChild;
+        var countParent = parentElement.childElementCount;
+        var childElementString = childElement.innerHTML;
+        var find = value+"@0";
+        var re = new RegExp(find, 'g');
+        childElementString = childElementString.replace(re,value+'@' + countParent);
+        var clone = childElement.cloneNode(true);
+        for (var ii = 0; ii < parentElement.childNodes.length; ii++){
+                var childId = parentElement.childNodes[ii].id;
+                if(ii = parentElement.childNodes.length){
+                var childnewId = childId.slice(0, -1);
+                var count = childId.slice(-1);
+                }
+            }
+        var countvalue = parseInt(count) + 1;
+        clone.id = childnewId+countvalue;
+        clone.value = '';
+        clone.innerHTML=childElementString;
+        document.getElementById("div."+value).appendChild(clone);
+        var selects = clone.getElementsByTagName("select");
+        var inputs = clone.getElementsByTagName("input");
+        var removeValues = [];
+        for(var i=0; i<inputs.length; i++){
+        if ($scope.temp.policy.ruleData!=undefined){
+            var checkValue = $scope.temp.policy.ruleData[inputs[i].id];
+            console.log("  checkValue.value :" +  checkValue);
+            console.log(" inputs["+i+"].id :" + inputs[i].id);
+            if (checkValue!=undefined && checkValue != "undefined"){
+            document.getElementById(inputs[i].id).value = checkValue;
+                plainAttributeKeys.push(inputs[i].id);
+            } else {
+            plainAttributeKeys.push(inputs[i].id);
+            }
+        }else {
+            plainAttributeKeys.push(inputs[i].id);
+        }
+        }
+        
+        for(var i=0; i<selects.length; i++){
+        if ($scope.temp.policy.ruleData!=undefined){
+            var checkValue = $scope.temp.policy.ruleData[selects[i].id];
+            if (checkValue!=undefined && checkValue!="undefined"){
+            if($scope.temp.policy.ruleData != null){
+                var checkValue = $scope.temp.policy.ruleData[selects[i].id];
+                var option = document.createElement('option');
+                option.setAttribute('value', checkValue);
+                option.appendChild(document.createTextNode(checkValue));
+                document.getElementById(selects[i].id).appendChild(option);
+                document.getElementById(selects[i].id).value = $scope.temp.policy.ruleData[selects[i].id];
+                plainAttributeKeys.push(selects[i].id);
+            }
+            } else {
+            plainAttributeKeys.push(selects[i].id);
+            }
+        }else {
+            plainAttributeKeys.push(selects[i].id);
+        }
+        }
+        
+        for (var k=0; k<removeValues.length; k++){
+        var elem = document.getElementById(removeValues[k]);
+        elem.parentNode.removeChild(elem);
+        }
+        var ele = angular.element(document.getElementById("div."+value));
+            $compile(ele.contents())($scope)
+    }
+     }
+     };
+     
+    
+     removeChoice = function(value) {
+     console.log(value);
+     if(value != undefined){
+     var c = document.getElementById("div."+value).childElementCount;
+     
+     if(c == 1){
+         Notification.error("The original one is not removable.");
+         return;
+     }    
+     document.getElementById("div."+value).removeChild(document.getElementById("div."+value).lastChild);     
+     }
+     };
+     
+     function findVal(object, key) {
+        var value;
+        Object.keys(object).some(function(k) {
+            if (k === key) {
+                value = object[k];
+                return true;
+            }
+            if (object[k] && typeof object[k] === 'object') {
+                value = findVal(object[k], key);
+                return value !== undefined;
+            }
+        });
+        return value;
+    }
+     
+     $scope.pullVersion = function(serviceName) {
+     console.log(serviceName);
+     if(serviceName != undefined){
+     var uuu = "policyController/getModelServiceVersioneData.htm";
+     var postData={policyData: serviceName};
+     $.ajax({
+         type : 'POST',
+         url : uuu,
+         dataType: 'json',
+         contentType: 'application/json',
+         data: JSON.stringify(postData),
+         success : function(data){
+         $scope.$apply(function(){
+             $scope.microServiceModelsDictionaryVersionDatas = data[0].dcaeModelVersionData;
+         });
+         },
+         error : function(data){
+         Notification.error("Error While Retriving the Template Layout Pattren.");
+         }
+     });     
+     }
+     };
+    
+    var splitEqual = '=';
+    var splitComma = ',';
+    var splitcolon = ':';
+    var splitEnum = "],";
+    var plainAttributeKeys = [];
+    var matching = [];
+    var enumKeyList = [];
+    var dictionaryList = [];
+    var dictionaryNameList = [];
+    var isInitViewEdit = false;
     $scope.addDataToFields = function(serviceName, version){
         if(serviceName != null && version !=null){
-        	var service=serviceName+"-v"+version;
-        	var myNode = document.getElementById("DynamicTemplate");
-        	myNode.innerHTML = '';
+        var service=serviceName+"-v"+version;
+        var myNode = document.getElementById("DynamicTemplate");
+        myNode.innerHTML = '';
             var uuu = "policyController/getDCAEMSTemplateData.htm";
             var postData={policyData: service};
             
@@ -382,214 +384,214 @@
                 contentType: 'application/json',
                 data: JSON.stringify(postData),
                 success : function(data){
-                	
-                	document.getElementById("msPolicyloader").style.visibility = "hidden";
-                	
+                
+                document.getElementById("msPolicyloader").style.visibility = "hidden";
+                
                     $scope.$apply(function(){
-                    	$scope.dcaeModelData = data[0].dcaeModelData;
-                    	$scope.dcaeJsonDate = data[0].jsonValue;
+                    $scope.dcaeModelData = data[0].dcaeModelData;
+                    $scope.dcaeJsonDate = data[0].jsonValue;
                         $scope.dataOrderInfo = null;
-                    	$scope.dataOrderInfo = data[0].dataOrderInfo;
-                    	console.log("data[0].dataOrderInfo: " + data[0].dataOrderInfo);
-                    	console.log("$scope.dataOrderInfo: " + $scope.dataOrderInfo);	
-                    	
-                    	if(data[0].allManyTrueKeys){
-	                    	console.log("$scope.allManyTrueKeys: " + $scope.allManyTrueKeys);
-                    	}
-                    	console.log("$scope.dcaeJsonDate: " + $scope.dcaeJsonDate);	
-                    	var attributes = $scope.dcaeModelData.attributes;                    	
-                    	console.log("attributes: " +attributes);                    	
-                    	var refAttributes = $scope.dcaeModelData.ref_attributes;
-                    	var subAttributes = 	$scope.dcaeModelData.sub_attributes;                    	
-                    	console.log("subAttributes: " + subAttributes);	
-                    	console.log("refAttributes: " + refAttributes);	
-                    	var headDefautlsData  = data[0].headDefautlsData;
-                    	if(headDefautlsData != null){
-	               			 $scope.temp.policy.onapName = headDefautlsData.onapName;
-	               			 $scope.temp.policy.guard = headDefautlsData.guard;
-	               			 $scope.temp.policy.riskType = headDefautlsData.riskType;
-	               			 $scope.temp.policy.riskLevel = headDefautlsData.riskLevel;
-	               			 $scope.temp.policy.priority = headDefautlsData.priority;
-                    	}
-                    	
-                       	var annotation = $scope.dcaeModelData.annotation;
-                       	var dictionary = $scope.microServiceAttributeDictionaryDatas;
+                    $scope.dataOrderInfo = data[0].dataOrderInfo;
+                    console.log("data[0].dataOrderInfo: " + data[0].dataOrderInfo);
+                    console.log("$scope.dataOrderInfo: " + $scope.dataOrderInfo);    
+                    
+                    if(data[0].allManyTrueKeys){
+                        console.log("$scope.allManyTrueKeys: " + $scope.allManyTrueKeys);
+                    }
+                    console.log("$scope.dcaeJsonDate: " + $scope.dcaeJsonDate);    
+                    var attributes = $scope.dcaeModelData.attributes;                    
+                    console.log("attributes: " +attributes);                    
+                    var refAttributes = $scope.dcaeModelData.ref_attributes;
+                    var subAttributes =     $scope.dcaeModelData.sub_attributes;                    
+                    console.log("subAttributes: " + subAttributes);    
+                    console.log("refAttributes: " + refAttributes);    
+                    var headDefautlsData  = data[0].headDefautlsData;
+                    if(headDefautlsData != null){
+                        $scope.temp.policy.onapName = headDefautlsData.onapName;
+                        $scope.temp.policy.guard = headDefautlsData.guard;
+                        $scope.temp.policy.riskType = headDefautlsData.riskType;
+                        $scope.temp.policy.riskLevel = headDefautlsData.riskLevel;
+                        $scope.temp.policy.priority = headDefautlsData.priority;
+                    }
+                    
+                       var annotation = $scope.dcaeModelData.annotation;
+                       var dictionary = $scope.microServiceAttributeDictionaryDatas;
 
-                       	if (annotation == null || annotation.length<1){
-                       		$scope.isCheck = true;
-                       	}else {
-                       		$scope.isCheck = false;
-                       		var annoationList = annotation.split(splitComma);
-                       		for (k = 0; k < annoationList.length; k++){
-                           		var splitAnnotation = annoationList[k].split(splitEqual);
-                           		if (splitAnnotation[1].includes("matching-true")){
-                           			matching.push(splitAnnotation[0].trim());
-                           		}
-                       		}
+                       if (annotation == null || annotation.length<1){
+                           $scope.isCheck = true;
+                       }else {
+                           $scope.isCheck = false;
+                           var annoationList = annotation.split(splitComma);
+                           for (k = 0; k < annoationList.length; k++){
+                               var splitAnnotation = annoationList[k].split(splitEqual);
+                               if (splitAnnotation[1].includes("matching-true")){
+                               matching.push(splitAnnotation[0].trim());
+                               }
+                           }
 
-                       	}
+                       }
 
-                       	if (dictionary!= null && dictionary.length>1){
-                       		for (m=0; m < dictionary.length; m += 1){
-                       			var valueCompare = dictionary[m].value;
-                       			var valueModel = dictionary[m].modelName;
-                       			var conpairService = serviceName;
-                       			if (valueModel.includes('-v')){
-                       				conpairService = service;
-                       			}
-                       			if(valueModel.localeCompare(conpairService) == 0){
-                       				console.log(valueCompare);	
-                       				dictionaryList.push(dictionary[m]);
-                       				if (!dictionaryNameList.includes(dictionary[m].name)){
-                       					dictionaryNameList.push(dictionary[m].name)
-                       				}
-                       			}
-                       		}
-                       	}
+                       if (dictionary!= null && dictionary.length>1){
+                           for (m=0; m < dictionary.length; m += 1){
+                           var valueCompare = dictionary[m].value;
+                           var valueModel = dictionary[m].modelName;
+                           var conpairService = serviceName;
+                           if (valueModel.includes('-v')){
+                               conpairService = service;
+                           }
+                           if(valueModel.localeCompare(conpairService) == 0){
+                               console.log(valueCompare);    
+                               dictionaryList.push(dictionary[m]);
+                               if (!dictionaryNameList.includes(dictionary[m].name)){
+                               dictionaryNameList.push(dictionary[m].name)
+                               }
+                           }
+                           }
+                       }
 
-                		$scope.temp.policy.ruleGridData = [];
-                		
-                		if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){
-                			dataOrderInfo = $scope.dataOrderInfo;
-                		}
-                		
-                		$scope.jsonLayout($scope.dcaeJsonDate);
-                		
+                    $scope.temp.policy.ruleGridData = [];
+                    
+                    if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){
+                    dataOrderInfo = $scope.dataOrderInfo;
+                    }
+                    
+                    $scope.jsonLayout($scope.dcaeJsonDate);
+                    
                     });
                     
                     if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){  // If it's veiw or edit
-                    	isInitViewEdit = true;
-                    	var checkData = [];
-                    	var data = [];
-                    	    // If ruleData contains extra elements created by clicked add button 
-                    	    console.log("$scope.temp.policy.ruleData:" + $scope.temp.policy.ruleData);
-	                    	if($scope.temp.policy.ruleData != null){
-	                    		var propNames = Object.getOwnPropertyNames($scope.temp.policy.ruleData);
-	                    		propNames.forEach(function(name) {
-	                    			data.push(name);
-	                    		});
-	                    		
-	                    		var extraElements = data;
-	                    		
-		            		    if(plainAttributeKeys != null){
-		            		    		for(var b = 0; b < plainAttributeKeys.length; b++){ // Remove already populated elements from data array
-		            		    			var newValue = plainAttributeKeys[b].split("*");
-		            		    			for(var a = 0; a < data.length; a++){
-			            		    			if(data[a] === newValue[0] || data[a] === (newValue[0]+"@0")){
-			            		    				extraElements.splice(a, 1);
-			            		    			}
-		            		    			}
-		            		    	}
-		                    		
-		            		    	//--- Populate these extra elements created by clicked add button 
-			                    	for(var a = 0; a < extraElements.length; a++){            			
-			                    		if(extraElements[a].includes("@")){
-					                    	var index = extraElements[a].lastIndexOf("@");
-					                    	if(index > 0){
-					                    	    // Get the number after @
-					                    	    var n = getNumOfDigits(extraElements[a], index+1);
-					                    				
-						                        var key = extraElements[a].substring(0, index+n+1); //include @x in key also by n+2 since x can be 1,12, etc
-						                    	console.log("key: " + key);
-						                    	checkData.push(key);
-					                    	}
-			                    		}
-			                    	}
-		                    		var unique = checkData.filter(onlyUnique);
-		                    		var parentLevelElements = [];
-		                    		if(unique){
-		                    			//--- get all root level exta elments first (only contains one "@")
-		                    			for(var i =0; i < unique.length; i++){
-			                    			var firstIndex = unique[i].indexOf("@");
-			                    			var lastIndex = unique[i].lastIndexOf("@");
-			                    			if(firstIndex == lastIndex){	
-				                    			var newKey = unique[i].substring(0, firstIndex);
-				                    			console.log("root element: " + newKey);
-				                    			parentLevelElements.push(newKey);
-				                    			unique[i] = "*processed*";
-			                    			}
-			                    		}		                    			
-		                    		}
-		                    		
-	                    			
-		              	    		for (var i = 0; i < $scope.labelManyKeys.length; i++) {
-		              	    		    var label = $scope.labelManyKeys[i];			              	    		    
-		              	    		    if(parentLevelElements){
-		              	    		    	for (var k = 0; k < parentLevelElements.length; k++){
-		              	    		    		if(label == parentLevelElements[k]){
-		              	    		    			addNewChoice(label);
-		              	    		    		}
-		              	    		    	}				              	    		    	
-		              	    		    }				             	 	    			
-		              	    		}
-		              	    		
-		                    		//if no layout order info, keep the process as before
-		                    		if(!dataOrderInfo){
-				                        for(var i =0; i < unique.length; i++){
-				                    		if(unique[i] != "*processed*"){
-					                    		var index = unique[i].lastIndexOf("@");
-					                    		var newKey = unique[i].substring(0, index);
-					                    		console.log("newKey: " + newKey);	
-					                    		
-					                    		var newElement = document.getElementById("div."+unique[j]);
-				                    			//check weather it has been created already
+                    isInitViewEdit = true;
+                    var checkData = [];
+                    var data = [];
+                        // If ruleData contains extra elements created by clicked add button 
+                        console.log("$scope.temp.policy.ruleData:" + $scope.temp.policy.ruleData);
+                        if($scope.temp.policy.ruleData != null){
+                            var propNames = Object.getOwnPropertyNames($scope.temp.policy.ruleData);
+                            propNames.forEach(function(name) {
+                            data.push(name);
+                            });
+                            
+                            var extraElements = data;
+                            
+                        if(plainAttributeKeys != null){
+                            for(var b = 0; b < plainAttributeKeys.length; b++){ // Remove already populated elements from data array
+                            var newValue = plainAttributeKeys[b].split("*");
+                            for(var a = 0; a < data.length; a++){
+                            if(data[a] === newValue[0] || data[a] === (newValue[0]+"@0")){
+                                extraElements.splice(a, 1);
+                            }
+                            }
+                        }
+                            
+                        //--- Populate these extra elements created by clicked add button 
+                        for(var a = 0; a < extraElements.length; a++){                
+                            if(extraElements[a].includes("@")){
+                            var index = extraElements[a].lastIndexOf("@");
+                            if(index > 0){
+                                // Get the number after @
+                                var n = getNumOfDigits(extraElements[a], index+1);
+                                    
+                                    var key = extraElements[a].substring(0, index+n+1); //include @x in key also by n+2 since x can be 1,12, etc
+                                console.log("key: " + key);
+                                checkData.push(key);
+                            }
+                            }
+                        }
+                            var unique = checkData.filter(onlyUnique);
+                            var parentLevelElements = [];
+                            if(unique){
+                            //--- get all root level exta elments first (only contains one "@")
+                            for(var i =0; i < unique.length; i++){
+                            var firstIndex = unique[i].indexOf("@");
+                            var lastIndex = unique[i].lastIndexOf("@");
+                            if(firstIndex == lastIndex){    
+                                var newKey = unique[i].substring(0, firstIndex);
+                                console.log("root element: " + newKey);
+                                parentLevelElements.push(newKey);
+                                unique[i] = "*processed*";
+                            }
+                            }                            
+                            }
+                            
+                            
+                          for (var i = 0; i < $scope.labelManyKeys.length; i++) {
+                              var label = $scope.labelManyKeys[i];                              
+                              if(parentLevelElements){
+                              for (var k = 0; k < parentLevelElements.length; k++){
+                                  if(label == parentLevelElements[k]){
+                                  addNewChoice(label);
+                                  }
+                              }                                  
+                              }                              
+                          }
+                          
+                            //if no layout order info, keep the process as before
+                            if(!dataOrderInfo){
+                                for(var i =0; i < unique.length; i++){
+                                if(unique[i] != "*processed*"){
+                                var index = unique[i].lastIndexOf("@");
+                                var newKey = unique[i].substring(0, index);
+                                console.log("newKey: " + newKey);    
+                                
+                                var newElement = document.getElementById("div."+unique[j]);
+                                //check weather it has been created already
                                                 if(newElement != null){
-                                                	continue;
+                                                continue;
                                                 }else{
-                                                	newElement = document.getElementById(unique[j]);
-                                                	if(newElement != null){
-                                                		continue;
-                                                	}
+                                                newElement = document.getElementById(unique[j]);
+                                                if(newElement != null){
+                                                    continue;
+                                                }
                                                 } 
                                                 
-					                    		if(newKey){
-					                    			addNewChoice(newKey);
-					                    		}
-				                    		}
-				                        }
-		            		    	}else{
-				              	    		//---reset to default
-				              	    		dataOrderInfo = [];
-				              	    		$scope.labelManyKeys = [];
-				              	    		
-		             	 	    			//---process none labels
-					              	    	for (var j = 0; j < unique.length; j++){
-					              	    		if(unique[j] != "*processed*"){
-					              	    			// if not created yet
-					              	    			if(!document.getElementById(unique[j])){
-						                    			var index = unique[j].lastIndexOf("@");
-						                    			var newKey = unique[j].substring(0, index);
-						                    			
-						                    			var newElement = document.getElementById("div."+unique[j]);
-						                    			
-						                    			//check weather it has been created already
+                                if(newKey){
+                                addNewChoice(newKey);
+                                }
+                                }
+                                }
+                        }else{
+                              //---reset to default
+                              dataOrderInfo = [];
+                              $scope.labelManyKeys = [];
+                              
+                          //---process none labels
+                          for (var j = 0; j < unique.length; j++){
+                              if(unique[j] != "*processed*"){
+                              // if not created yet
+                              if(!document.getElementById(unique[j])){
+                                    var index = unique[j].lastIndexOf("@");
+                                    var newKey = unique[j].substring(0, index);
+                                    
+                                    var newElement = document.getElementById("div."+unique[j]);
+                                    
+                                    //check weather it has been created already
                                                         if(newElement != null){
-                                                        	continue;
+                                                        continue;
                                                         }else{
-                                                        	newElement = document.getElementById(unique[j]);
-                                                        	if(newElement != null){
-                                                        		continue;
-                                                        	}
+                                                        newElement = document.getElementById(unique[j]);
+                                                        if(newElement != null){
+                                                            continue;
+                                                        }
                                                         } 
-                                                        //if not created yet, then create it.						                    				
-						                    			addNewChoice(newKey);
-			 		             	 	    		   
-					              	    			}
-					              	    		}
-					              	    	}
-			              	    		}
-		            		    }
-	                    	}
+                                                        //if not created yet, then create it.                                        
+                                    addNewChoice(newKey);
+                                  
+                              }
+                              }
+                          }
+                          }
+                        }
+                        }
 
                     }
                     var ele = angular.element(document.getElementById("DynamicTemplate"));
-            		$compile(ele.contents())($scope);
+                $compile(ele.contents())($scope);
                     $scope.$apply();
                     isInitViewEdit = false;                   
                     
                 },
                 error : function(data){
-                    alert("Error While Retriving the Template Layout Pattren.");
+                Notification.error("Error While Retriving the Template Layout Pattren.");
                 }
             });
 
@@ -597,974 +599,974 @@
     };
     
     function getNumOfDigits(str_value, index){
-		// Get the number after @
-		var str = str_value.substring(index, str_value.length);	
-		var c = '';
-		var n = 0;
-		for (var x = 0; x < str.length; x++){			                    				
-		    c = str.charAt(x);
-			    if(!isNaN(c)){ 
+    // Get the number after @
+    var str = str_value.substring(index, str_value.length);    
+    var c = '';
+    var n = 0;
+    for (var x = 0; x < str.length; x++){                                
+        c = str.charAt(x);
+        if(!isNaN(c)){ 
                 n++;                                                     
-		    }else{
+        }else{
                 break;
             }
-		}
-		return n;
+    }
+    return n;
     }
     
     function getDictionary(attribute){
-    	var dicName = attribute;
-    	if(attribute){
-    	   if(attribute.includes(":")){
-    		   dicName = attribute.split(":")[0];
-    	   }
-    	}
-	    var dictionaryRegExp = new RegExp(dicName);
-	    listemunerateValues = [];
-	    if (dictionaryRegExp.test(dictionaryNameList)) {
-			for (p=0; p < dictionaryList.length; p += 1) {
-				if (dicName == dictionaryList[p].name) {
-					listemunerateValues.push(dictionaryList[p].value);
-				}
-			}
-	    }
-	    return listemunerateValues;
+    var dicName = attribute;
+    if(attribute){
+       if(attribute.includes(":")){
+           dicName = attribute.split(":")[0];
+       }
+    }
+        var dictionaryRegExp = new RegExp(dicName);
+        listemunerateValues = [];
+        if (dictionaryRegExp.test(dictionaryNameList)) {
+    for (p=0; p < dictionaryList.length; p += 1) {
+        if (dicName == dictionaryList[p].name) {
+        listemunerateValues.push(dictionaryList[p].value);
+        }
+    }
+        }
+        return listemunerateValues;
     }
     
     function getList(attribute) {
-	    	var enumName = attribute;
-	    	console.log("In getList: attribute => " + attribute);
-	    	if(attribute){
-	    	   if(attribute.includes(":")){
-	    		   enumName = attribute.split(":")[0];
-	    	   }
-	    	}   
+        var enumName = attribute;
+        console.log("In getList: attribute => " + attribute);
+        if(attribute){
+           if(attribute.includes(":")){
+               enumName = attribute.split(":")[0];
+           }
+        }   
             var baseEnum = $scope.dcaeModelData.enumValues;
             var enumList = [];
             if(baseEnum != null){
-            	enumList = baseEnum.split(splitEnum);
+            enumList = baseEnum.split(splitEnum);
             }
-	    	var enumAttributes;
-	    	var patternTest = new RegExp(enumName);
-	    	for (k=0; k < enumList.length; k += 1){
-	    		if(patternTest.test(enumList[k]) == true){
-	    			enumAttributes = enumList[k].trim();
-    		}
-    	}
+        var enumAttributes;
+        var patternTest = new RegExp(enumName);
+        for (k=0; k < enumList.length; k += 1){
+            if(patternTest.test(enumList[k]) == true){
+            enumAttributes = enumList[k].trim();
+        }
+    }
 
          if(enumAttributes){
-	        enumAttributes = enumAttributes.replace("[", "");
-	       	enumAttributes = enumAttributes.replace("]", "");
-	       	enumAttributes = enumAttributes.replace(/ /g, '');
-			var dropListAfterCommaSplit = enumAttributes.split(splitEqual);
-			listemunerateValues  = dropListAfterCommaSplit[1].split(splitComma);
-			//enumKeyList.push(attribute); 
-	        return listemunerateValues;
+            enumAttributes = enumAttributes.replace("[", "");
+           enumAttributes = enumAttributes.replace("]", "");
+           enumAttributes = enumAttributes.replace(/ /g, '');
+    var dropListAfterCommaSplit = enumAttributes.split(splitEqual);
+    listemunerateValues  = dropListAfterCommaSplit[1].split(splitComma);
+    //enumKeyList.push(attribute); 
+            return listemunerateValues;
          }
          
             return [];
-	    }
-	    
-	    function getBooleanList(){
-	    	var booleanList = [];
-	    	booleanList.push(true);
-	    	booleanList.push(false);
-	    	return booleanList;
-	    }
-	    
+        }
+        
+        function getBooleanList(){
+        var booleanList = [];
+        booleanList.push(true);
+        booleanList.push(false);
+        return booleanList;
+        }
+        
 
-	    function isArray(arrayTest) {
-	        return Object.prototype.toString.call(arrayTest) === '[object Array]';
-	    }
-	    var lableList = [];
-	    
-	    $scope.layOutElementList = [];
-	    $scope.layOutOnlyLableList = [];
-	    
-	    var elementOrderNum = 0;
-	    
-		function deconstructJSON(layOutData, level , name) {
+        function isArray(arrayTest) {
+            return Object.prototype.toString.call(arrayTest) === '[object Array]';
+        }
+        var lableList = [];
+        
+        $scope.layOutElementList = [];
+        $scope.layOutOnlyLableList = [];
+        
+        var elementOrderNum = 0;
+        
+    function deconstructJSON(layOutData, level , name) {
 
-			 var array = false;
-			 var label = level;
-			 var stringValue = "java.lang.String";
-			 var string = "string";
-			 var intValue = "int";
-			 var integerValue = "integer";
-			 var double = "double";
-			 var boolean = "boolean";
-			 var baseLevel = level;
-			 
-			 var attributekey = "";
-			 
-			if (name.length > 1){
-				label = label + name + '.';
-			}
-			
-		    for (key in layOutData) {
-		    	array = isArray(layOutData[key]);
-		    	console.log("key: " + key , "value: " + layOutData[key]);
-	    	
-		    	if (!!layOutData[key] && typeof(layOutData[key])=="object") {
-		    		
-		    		if (array==false && key!=="0"){
-		    			
-		    			if($scope.dataOrderInfo){
-		    			    var labelObject = {"label" : key, "level" : label, "array" : array};
-		    			    //save it to the list
-		    			    $scope.layOutOnlyLableList.push(labelObject);
-		    			    
-		    			}else {
-		    				//call label layout
-		    				$scope.labelLayout(label, key, array );
-		    			}
-		    			
-		    		}
-		    		
-		    		if (array == true && key!=0){
-		    			lableList.push(key);
-		    		}
-		    		
-		    		if (lableList.length > 0){
-		    			array = true;
-		    		}
-		    		if ( key==="0"){
-		    			var newKey = lableList.pop();
-		    			
-		    			if($scope.dataOrderInfo){
-		    				
-			    			var labelObject = {"label" : newKey, "level" : baseLevel, "array" : array};
-			    			//save it to the list
-			    			$scope.layOutOnlyLableList.push(labelObject);
-			    			
-		    			}else {
-		    				//call label layout 
-		    			    $scope.labelLayout(baseLevel, newKey, array );
-		    			}
-		    			
-		    			if (array){
-		    				label = baseLevel + newKey + '@0.';
-		    			} else {
-		    				label = baseLevel + newKey + '.';
-		    			}
-		    		}
-		        	deconstructJSON(layOutData[key] , label, key);
-		        } else {
-		        	var attirbuteLabel = label;
-		        	var defaultValue='';
-		        	var description='';
-		        	var isRequired = false;
-		        	if (layOutData[key].includes('defaultValue-')){
-		        		defaultValue = layOutData[key].split('defaultValue-')[1];
-		        	}
-		        	
-		        	if (layOutData[key].includes('description-')){
-		        		description = layOutData[key].split('description-')[1];
-		        	}		        	
-		        	
-
-		        	if (key==="0"){
-		        		array = true;
-		        		attributekey = lableList.pop();
-		        		attirbuteLabel = baseLevel;
-		        	} else {
-		        		attributekey = key.split();
-		        	}
-		        	
-		        	if (layOutData[key].includes('required-true')){
-		        		isRequired = true;
-		        	}
-		    		
-		    		var subAttributes = $scope.dcaeModelData.sub_attributes;
-		    		
-		    		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;
-			        		}	
-			        		if(lablInfo.includes('defaultValue-')){
-			        			defaultValue = lablInfo.split('defaultValue-')[1];
-			        		}
-			        		
-			        		if(lablInfo.includes('description-')){
-			        			description = lablInfo.split('description-')[1];
-			        		}
-			        		
-			        	}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;
-		    				        	 }	
-		    				        	 
-		    				        	 if(tempObject[key].includes('defaultValue-')){
-		    				        		defaultValue = tempObject[key].split('defaultValue-')[1];
-		    				        	 }
-		    				        	 
-		    				        	 if(tempObject[key].includes('description-')){
-		    				        		 description = tempObject[key].split('description-')[1];
-			    				          }
-
-		    						 }
-		    					  }
-		    				   }		    				
-		    			   }		    			
-			        	} 
-		    		}
-		    		
-		    		var elementObject = {};
-		        	switch (layOutData[key].split(splitcolon)[0]){
-		        	
-		        		case stringValue:
-		        		case string:
-		        			if($scope.dataOrderInfo){		        				
-				        		elementOrderNum++;
-				        		elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue, "isRequired": isRequired, "type":"text", "description":description};
-				        		$scope.layOutElementList.push(elementObject);
-		        			}else{
-		        				$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "text");
-		        			}
-		        			break;		        			
-		        		case intValue: 
-		        		case integerValue: 
-		        			if($scope.dataOrderInfo){
-			        			elementOrderNum++;
-				        		elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"number" , "description":description};
-				        		$scope.layOutElementList.push(elementObject);
-		        			}else{
-		        				$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "number");
-		        			}
-		        			break;		        			
-		        		case double:
-		        			if($scope.dataOrderInfo){
-			        			elementOrderNum++;
-				        		elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"double",  "description":description};
-				        		$scope.layOutElementList.push(elementObject);		        				
-		        			}else{
-		        				$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "double");
-		        			}
-		        			break;
-		        		case boolean:
-		        			if($scope.dataOrderInfo){
-			        			elementOrderNum++;
-				        		elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue, "isRequired": isRequired, "type":"boolean", "description":description};
-				        		$scope.layOutElementList.push(elementObject);
-		        			}else{
-		        				$scope.dropBoxLayout(attirbuteLabel, attributekey, array, layOutData[key], getBooleanList());
-		        			}
-		        			break;
-		        		default:
-		        			if (layOutData[key].includes('dictionary-')){
-		        				var list = getDictionary(layOutData[key].split('dictionary-')[1]);
-		        			}else{
-		        				//--- get dropdown values from enumValues
-		        				var list = getList(layOutData[key]);
-		        			}
-		        			if (list.length===0){ //not dropdown element
-		        				if($scope.dataOrderInfo){
-		        					elementOrderNum++;
-					        		elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"text", "description":description};
-					        		$scope.layOutElementList.push(elementObject);
-		        					
-		        				}else{
-		        					$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "text");
-		        				}		        				
-		        			}else{
-		        				if($scope.dataOrderInfo){
-			        				elementOrderNum++;
-					        		elementObject = {"id": elementOrderNum, "attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "list":list, "type":"dropBox", "description":description};
-					        		$scope.layOutElementList.push(elementObject);		        					
-		        				}else{
-		        					$scope.dropBoxLayout(attirbuteLabel, attributekey, array, layOutData[key], list, isRequired);
-		        				}
-		        			}
-		        			break;
-		        	}
-		        }
-		    }
-		}  
-		
-		
-	    $scope.validContionalRequired = function(parentId) {
-	        console.log("ng-blur event: parentId : " + parentId);
-	        var c = document.getElementById(parentId).children;
-	        var i;
-	        var hasValue = false;
-	        for (i = 0; i < c.length; i++) {
-	        	if(c[i].getAttribute("data-conditional")){
-	        	    console.log(c[i].getAttribute("data-conditional"));
-	        	    console.log(c[i].value);
-	        	    if(c[i].value != null && c[i].value.trim() != ""){
-	        	    	hasValue = true;
-	        	    }
-	        	}
-	        }
-
-		    for (i = 0; i < c.length; i++) {
-		        if(c[i].getAttribute("data-conditional")){
-		        	if(hasValue){
-		        	    c[i].setAttribute("required", true);
-		        	}else{
-		        		c[i].removeAttribute("required");
-		        	}
-		        }
-		    }        	
-	     }
-				
-	    $scope.jsonLayout = function(layOutData){
-	    	
- 	    	   deconstructJSON(layOutData , "", "");
- 	    	   
- 	    	   var orderValue = $scope.dataOrderInfo;
- 	    	   var layOutElementList = $scope.layOutElementList;
- 	    	   var labelList = $scope.layOutOnlyLableList;
- 	    	    
- 	    	   //reset to default
- 	    	   elementOrderNum = 0;
- 	    	   $scope.layOutElementList = [];
- 	    	   $scope.layOutOnlyLableList = [];
- 	    	   
- 	    	   // Only layout in order if order info provided
- 	    	   if(orderValue){
- 	    		   
- 	    		   if(orderValue.includes("[")){
- 	    			  orderValue = orderValue.replace("[", "") ;
- 	    			  orderValue = orderValue.replace("]", "") ;
- 	    		   }
- 	    		   
- 	    		   orderValue = orderValue.split(',') ;
- 	    		   
- 	    		   for (var i = 0; i < orderValue.length; i++) {
- 	    			   console.log("orderValue["+i+"]"+  orderValue[i]);
- 	    			   var key = orderValue[i].trim();
- 	    			 
- 	    			    //--- Create labels first {"label" : newKey, "level" : baseLevel, "array" : array};
- 	    			   if(labelList){
-	 	    			   for (var k = 0; k < labelList.length; k++){
-	 	    				   
-	 	    				  var label = labelList[k].label.toString().trim();
-	 	    				  var level = labelList[k].level.toString().trim();
-	 	    				  var array = labelList[k].array;
-	 	    				  
-	 	    				  if(key == label){	 	    					  
-	 	    					 $scope.labelLayout(level, label, array);
-		 	 	  	    		 //in case to have duplicate label names
-	 	    					 labelList[k].label = "*processed*";
-	 	    					 break;
-	 	    				  }
-	 	    			   }
- 	    			   }
- 	    			   //--- then layout each element based on its order defined in YAML file
-	 	  	    	   for (var j = 0; j < layOutElementList.length; j++) { 
-	 	  	    		   
-	 	  	    		   var attributekey = layOutElementList[j].attributekey.toString().trim();	 	  	    		   
-	 	  	    		
-	 	  	    		   if(key == attributekey){ 	
-
-		 	  	    		   var attirbuteLabel = layOutElementList[j].attirbuteLabel.toString().trim();
-		 	  	    		   var defaultValue = layOutElementList[j].defaultValue.toString().trim();
-		 	  	    		   var description = layOutElementList[j].description;
-		 	  	    		   var isRequired = layOutElementList[j].isRequired;
-	 	 	  	    		   
-	 	 	  	    		   console.log("layOutElementList[" +j+ "]: id:" + layOutElementList[j].id + ", attributekey:"+ layOutElementList[j].attributekey + ", attirbuteLabel:" + layOutElementList[j].attirbuteLabel);
-	 	 	  	    		   console.log("layOutElementList[" +j+ "]: type:" + layOutElementList[j].type);
-	 	 	  	    		   if (layOutElementList[j].type == "dropBox"){ 
-	 		        				$scope.dropBoxLayout(attirbuteLabel, attributekey, layOutElementList[j].array, defaultValue, layOutElementList[j].list, isRequired, description);
-	                                
-			        		   }else{
-			        			    $scope.attributeBox(attributekey, layOutElementList[j].array, attirbuteLabel, defaultValue, isRequired, layOutElementList[j].type, description);	
-	
-			        		   }
-	 	 	  	    		   
-	 	 	  	    		   //in case to have duplicate attribute names
-	 	 	  	    		   layOutElementList[j].attributekey = "*processed*";
-	 		        		   break;
-	 	  	    		   }
-	 	  	    	   }
- 	    		   }
- 	    	   }
-	    }
-	    
-	    
-	    $scope.attributeBox = function(attibuteKey, attributeManyKey, labelValue, defaultValue, isRequired, dataType,  description){
-			$scope.temp.policy.ruleGridData.push(attibuteKey);			
-		var br = document.createElement("BR");
-		
-		var label = document.createElement("Label");
-		var labeltext = null;
-		var requiredLabName = "";
-		if (matching.includes(attibuteKey)){
-			labeltext = document.createTextNode(attibuteKey + "*!");	
-			isRequired = true;  //set required as true for matching element
-		}else {
-			if(isRequired){
-				requiredLabName = attibuteKey + " * ";
-				labeltext = document.createTextNode(requiredLabName);
-			}else{
-			    labeltext = document.createTextNode(attibuteKey);	
-			}
-		}
-
-		
-		var divID = labelValue;
-		
-		if (labelValue.length  < 1){
-			divID = "DynamicTemplate";
-		}else if (labelValue.endsWith('.')){
-			var divID = 'div.'+ labelValue.substring(0, labelValue.length-1);
-		}
-		
-		label.appendChild(labeltext);
-		
-		var textField = document.createElement("INPUT");
-		
-		textField.setAttribute("class" , "form-control");
-		if(dataType){
-			if(dataType == "double"){
-				textField.setAttribute("type" , "number");
-				textField.setAttribute("step" , "any");
-
-			}else if(dataType == "boolean"){  //gw1218 testing boolean
-				var booleanDiv = document.createElement("div");
-
-				booleanDiv.setAttribute("class" , "onoffswitch");
-
-				//var checkField = document.createElement("INPUT");
-				textField.setAttribute("type" , "checkbox");
-				textField.setAttribute("name" , "onoffswitch");
-				textField.setAttribute("class" , "onoffswitch-checkbox");
-				textField.setAttribute("id" , ''+labelValue +attibuteKey+'');
-				if(defaultValue.substring(0,defaultValue.indexOf(":")) == "true") {
-					textField.setAttribute("checked" , true);
-				}else{
-					textField.removeAttribute("checked");
-				}
-
-						var booleanlabel = document.createElement("Label");
-						booleanlabel.setAttribute("class" , "onoffswitch-label");
-						booleanlabel.setAttribute("for" , ''+labelValue +attibuteKey+'');
-					
-						var span1 = document.createElement("span");
-						span1.setAttribute("class" , "onoffswitch-inner");
-						
-						var span2 = document.createElement("span");
-						span2.setAttribute("class" , "onoffswitch-switch"); 
-						
-						
-						booleanlabel.appendChild(span1); 	
-						booleanlabel.appendChild(span2); 	
-						booleanDiv.appendChild(textField); 	
-						booleanDiv.appendChild(booleanlabel); 	 
-						
-						document.getElementById(divID).appendChild(label);  
-						document.getElementById(divID).appendChild(booleanDiv); 	
-
-						//return;
-			   } else{
-			      textField.setAttribute("type" , dataType);
-			   }
-			   
-				
-
-		}
-		
-		if(dataType != "boolean"){
-			textField.setAttribute("style" , "width:300px;");
-			textField.setAttribute("ng-disabled" , "temp.policy.readOnly");
-			if(description && description != "null"){
-				textField.setAttribute("title", description);
-			}
-		}
-
-		var checkKey;
-		var id = "";
-		if(attributeManyKey){
-			checkKey = labelValue + attibuteKey+'@0';
-			textField.setAttribute("id" , ''+labelValue + attibuteKey+'@0'+''); 
-			var divTag = document.createElement("div");
-			divTag.setAttribute("id", "div."+ labelValue +attibuteKey);
-			var addButton = document.createElement("BUTTON");
-			var buttonaddLabel = document.createTextNode("+");       
-			addButton.appendChild(buttonaddLabel); 
-			addButton.setAttribute("id", labelValue + attibuteKey);
-			addButton.setAttribute("class", "btn btn-add-remove");
-			addButton.setAttribute("onclick" ,  'addNewChoice("'+labelValue + attibuteKey+'");');
-			addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
-			var removeButton = document.createElement("BUTTON");
-			var buttonremoveLabel = document.createTextNode("-");       
-			removeButton.appendChild(buttonremoveLabel); 
-			removeButton.setAttribute("class", "btn btn-add-remove");
-			removeButton.setAttribute("onclick" ,  'removeChoice("'+labelValue + attibuteKey+'");');
-			removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
-			document.getElementById(divID).appendChild(addButton); 
-			document.getElementById(divID).appendChild(removeButton); 
-			document.getElementById(divID).appendChild(label); 
-			id = "div."+labelValue+attibuteKey;
-			//var divTag = document.createElement("div");
-			divTag.setAttribute("id", id); 
-			document.getElementById(divID).appendChild(divTag);
-			textField.className += ' first_child';	
-			if(isRequired){
-				textField.setAttribute("required", "true");
-			}	
-			
-			divTag.appendChild(textField); 			
-			document.getElementById(divID).appendChild(divTag); 
-			
-		}else if (dataType != "boolean"){
-			checkKey = labelValue + attibuteKey;
-			textField.setAttribute("id" , ''+labelValue +attibuteKey+'');
-			if(document.getElementById(divID).hasAttribute('required') || !document.getElementById(divID).hasAttribute('data-conditional')){
-				if(requiredLabName.includes("*") || isRequired){
-					textField.setAttribute("required", "true");
-				}
-			}else if (document.getElementById(divID).hasAttribute('data-conditional')){
-				if(requiredLabName.includes("*")){					
-					var requiredNode = document.createElement('span');
-					requiredNode.setAttribute("class", "mstooltip");
-					requiredNode.textContent = "?";
-					label.appendChild(requiredNode);
-					
-					var requiredNodeToolTip = document.createElement('span');
-					requiredNodeToolTip.setAttribute("class", "tooltiptext");
-					requiredNodeToolTip.textContent = "Conditional Required";
-					requiredNode.appendChild(requiredNodeToolTip);
-					
-					textField.setAttribute("data-conditional", divID);
-					textField.setAttribute("ng-blur", "validContionalRequired('"+divID+"')");
-				}
-			}
+     var array = false;
+     var label = level;
+     var stringValue = "java.lang.String";
+     var string = "string";
+     var intValue = "int";
+     var integerValue = "integer";
+     var double = "double";
+     var boolean = "boolean";
+     var baseLevel = level;
+     
+     var attributekey = "";
+     
+    if (name.length > 1){
+        label = label + name + '.';
+    }
+    
+        for (key in layOutData) {
+        array = isArray(layOutData[key]);
+        console.log("key: " + key , "value: " + layOutData[key]);
+        
+        if (!!layOutData[key] && typeof(layOutData[key])=="object") {
             
-			document.getElementById(divID).appendChild(label);  
-			document.getElementById(divID).appendChild(textField);  
-			document.getElementById(divID).appendChild(br); 
+            if (array==false && key!=="0"){
+            
+            if($scope.dataOrderInfo){
+                var labelObject = {"label" : key, "level" : label, "array" : array};
+                //save it to the list
+                $scope.layOutOnlyLableList.push(labelObject);
+                
+            }else {
+                //call label layout
+                $scope.labelLayout(label, key, array );
+            }
+            
+            }
+            
+            if (array == true && key!=0){
+            lableList.push(key);
+            }
+            
+            if (lableList.length > 0){
+            array = true;
+            }
+            if ( key==="0"){
+            var newKey = lableList.pop();
+            
+            if($scope.dataOrderInfo){
+                
+            var labelObject = {"label" : newKey, "level" : baseLevel, "array" : array};
+            //save it to the list
+            $scope.layOutOnlyLableList.push(labelObject);
+            
+            }else {
+                //call label layout 
+                $scope.labelLayout(baseLevel, newKey, array );
+            }
+            
+            if (array){
+                label = baseLevel + newKey + '@0.';
+            } else {
+                label = baseLevel + newKey + '.';
+            }
+            }
+            deconstructJSON(layOutData[key] , label, key);
+            } else {
+            var attirbuteLabel = label;
+            var defaultValue='';
+            var description='';
+            var isRequired = false;
+            if (layOutData[key].includes('defaultValue-')){
+                defaultValue = layOutData[key].split('defaultValue-')[1];
+            }
+            
+            if (layOutData[key].includes('description-')){
+                description = layOutData[key].split('description-')[1];
+            }            
+            
 
-		}
+            if (key==="0"){
+                array = true;
+                attributekey = lableList.pop();
+                attirbuteLabel = baseLevel;
+            } else {
+                attributekey = key.split();
+            }
+            
+            if (layOutData[key].includes('required-true')){
+                isRequired = true;
+            }
+            
+            var subAttributes = $scope.dcaeModelData.sub_attributes;
+            
+            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;
+                }    
+                if(lablInfo.includes('defaultValue-')){
+                defaultValue = lablInfo.split('defaultValue-')[1];
+                }
+                
+                if(lablInfo.includes('description-')){
+                description = lablInfo.split('description-')[1];
+                }
+                
+            }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;
+                         }    
+                         
+                         if(tempObject[key].includes('defaultValue-')){
+                            defaultValue = tempObject[key].split('defaultValue-')[1];
+                         }
+                         
+                         if(tempObject[key].includes('description-')){
+                             description = tempObject[key].split('description-')[1];
+                          }
 
-		if(dataType != "boolean" && divID.includes("@0") && divID.includes("div.")){
-			var firstChild_Id = divID.split("@0")[0];
-			var firstChild_element = document.getElementById(firstChild_Id);
-			if(firstChild_element){
-			
-				if(!firstChild_element.className.includes('children_group border')){
-					layer++;
-					if(layer > 4){ 
-						layer = 1
-					}
-					firstChild_element.className += ' children_group border' + layer; //here is div with a group of children.
-				}
-			}
-		}
-		console.log('firstChild_Id: ' + firstChild_Id);
-		console.log('divID: ' + divID);
-		
-		if(dataType != "boolean" && defaultValue.length > 0){	
-			if(defaultValue.includes(":")){
-				defaultValue = defaultValue.split(":")[0];
-				if(defaultValue === "NA") {
-					defaultValue = "";
-				}				
-			}
-			if(defaultValue != "undefined" && defaultValue != undefined && defaultValue != "null"){
-		    	document.getElementById(checkKey).value = defaultValue;
-			}
-		}
-		
-		if($scope.temp.policy.ruleData != null){
-			//document.getElementById(checkKey).value = $scope.temp.policy.ruleData[checkKey];
-			if (attributeManyKey){
-				var newCheckKey = checkKey.replace(attibuteKey + '@0',attibuteKey);
-				if($scope.temp.policy.ruleData[newCheckKey +'@0'] != undefined && $scope.temp.policy.ruleData[newCheckKey +'@0'] != "undefined"){
-			  	    document.getElementById(newCheckKey +'@0').value = $scope.temp.policy.ruleData[newCheckKey +'@0'];
-				}
-			}else{
-				if($scope.temp.policy.ruleData[checkKey] != undefined && $scope.temp.policy.ruleData[checkKey] != "undefined"){
-				    document.getElementById(checkKey).value = $scope.temp.policy.ruleData[checkKey];
-				}
-			}
-		} 
-		
-		if (dataType != "boolean"){
-		    plainAttributeKeys.push(labelValue + attibuteKey+'*'+attributeManyKey);	
-		}else{
-		    plainAttributeKeys.push(labelValue + attibuteKey+'*'+"boolean");	
-		}
+                     }
+                  }
+                   }                
+               }            
+            } 
+            }
+            
+            var elementObject = {};
+            switch (layOutData[key].split(splitcolon)[0]){
+            
+                case stringValue:
+                case string:
+                if($scope.dataOrderInfo){                    
+                    elementOrderNum++;
+                    elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue, "isRequired": isRequired, "type":"text", "description":description};
+                    $scope.layOutElementList.push(elementObject);
+                }else{
+                    $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "text");
+                }
+                break;                
+                case intValue: 
+                case integerValue: 
+                if($scope.dataOrderInfo){
+                elementOrderNum++;
+                    elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"number" , "description":description};
+                    $scope.layOutElementList.push(elementObject);
+                }else{
+                    $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "number");
+                }
+                break;                
+                case double:
+                if($scope.dataOrderInfo){
+                elementOrderNum++;
+                    elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"double",  "description":description};
+                    $scope.layOutElementList.push(elementObject);                    
+                }else{
+                    $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "double");
+                }
+                break;
+                case boolean:
+                if($scope.dataOrderInfo){
+                elementOrderNum++;
+                    elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue, "isRequired": isRequired, "type":"boolean", "description":description};
+                    $scope.layOutElementList.push(elementObject);
+                }else{
+                    $scope.dropBoxLayout(attirbuteLabel, attributekey, array, layOutData[key], getBooleanList());
+                }
+                break;
+                default:
+                if (layOutData[key].includes('dictionary-')){
+                    var list = getDictionary(layOutData[key].split('dictionary-')[1]);
+                }else{
+                    //--- get dropdown values from enumValues
+                    var list = getList(layOutData[key]);
+                }
+                if (list.length===0){ //not dropdown element
+                    if($scope.dataOrderInfo){
+                    elementOrderNum++;
+                    elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"text", "description":description};
+                    $scope.layOutElementList.push(elementObject);
+                    
+                    }else{
+                    $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "text");
+                    }                    
+                }else{
+                    if($scope.dataOrderInfo){
+                    elementOrderNum++;
+                    elementObject = {"id": elementOrderNum, "attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "list":list, "type":"dropBox", "description":description};
+                    $scope.layOutElementList.push(elementObject);                    
+                    }else{
+                    $scope.dropBoxLayout(attirbuteLabel, attributekey, array, layOutData[key], list, isRequired);
+                    }
+                }
+                break;
+            }
+            }
+        }
+    }  
+    
+    
+        $scope.validContionalRequired = function(parentId) {
+            console.log("ng-blur event: parentId : " + parentId);
+            var c = document.getElementById(parentId).children;
+            var i;
+            var hasValue = false;
+            for (i = 0; i < c.length; i++) {
+            if(c[i].getAttribute("data-conditional")){
+                console.log(c[i].getAttribute("data-conditional"));
+                console.log(c[i].value);
+                if(c[i].value != null && c[i].value.trim() != ""){
+                hasValue = true;
+                }
+            }
+            }
+
+        for (i = 0; i < c.length; i++) {
+            if(c[i].getAttribute("data-conditional")){
+            if(hasValue){
+                c[i].setAttribute("required", true);
+            }else{
+                c[i].removeAttribute("required");
+            }
+            }
+        }        
+         }
+        
+        $scope.jsonLayout = function(layOutData){
+        
+            deconstructJSON(layOutData , "", "");
+            
+            var orderValue = $scope.dataOrderInfo;
+            var layOutElementList = $scope.layOutElementList;
+            var labelList = $scope.layOutOnlyLableList;
+             
+            //reset to default
+            elementOrderNum = 0;
+            $scope.layOutElementList = [];
+            $scope.layOutOnlyLableList = [];
+            
+            // Only layout in order if order info provided
+            if(orderValue){
+                
+                if(orderValue.includes("[")){
+               orderValue = orderValue.replace("[", "") ;
+               orderValue = orderValue.replace("]", "") ;
+                }
+                
+                orderValue = orderValue.split(',') ;
+                
+                for (var i = 0; i < orderValue.length; i++) {
+                console.log("orderValue["+i+"]"+  orderValue[i]);
+                var key = orderValue[i].trim();
+              
+                 //--- Create labels first {"label" : newKey, "level" : baseLevel, "array" : array};
+                if(labelList){
+                    for (var k = 0; k < labelList.length; k++){
+                        
+                       var label = labelList[k].label.toString().trim();
+                       var level = labelList[k].level.toString().trim();
+                       var array = labelList[k].array;
+                       
+                       if(key == label){                       
+                      $scope.labelLayout(level, label, array);
+                 //in case to have duplicate label names
+                      labelList[k].label = "*processed*";
+                      break;
+                       }
+                    }
+                }
+                //--- then layout each element based on its order defined in YAML file
+                      for (var j = 0; j < layOutElementList.length; j++) { 
+                          
+                          var attributekey = layOutElementList[j].attributekey.toString().trim();                          
+                       
+                          if(key == attributekey){     
+
+                  var attirbuteLabel = layOutElementList[j].attirbuteLabel.toString().trim();
+                  var defaultValue = layOutElementList[j].defaultValue.toString().trim();
+                  var description = layOutElementList[j].description;
+                  var isRequired = layOutElementList[j].isRequired;
+                               
+                               console.log("layOutElementList[" +j+ "]: id:" + layOutElementList[j].id + ", attributekey:"+ layOutElementList[j].attributekey + ", attirbuteLabel:" + layOutElementList[j].attirbuteLabel);
+                               console.log("layOutElementList[" +j+ "]: type:" + layOutElementList[j].type);
+                               if (layOutElementList[j].type == "dropBox"){ 
+                         $scope.dropBoxLayout(attirbuteLabel, attributekey, layOutElementList[j].array, defaultValue, layOutElementList[j].list, isRequired, description);
+                                    
+                   }else{
+                    $scope.attributeBox(attributekey, layOutElementList[j].array, attirbuteLabel, defaultValue, isRequired, layOutElementList[j].type, description);    
+    
+                   }
+                               
+                               //in case to have duplicate attribute names
+                               layOutElementList[j].attributekey = "*processed*";
+                        break;
+                          }
+                      }
+                }
+            }
+        }
+        
+        
+        $scope.attributeBox = function(attibuteKey, attributeManyKey, labelValue, defaultValue, isRequired, dataType,  description){
+    $scope.temp.policy.ruleGridData.push(attibuteKey);    
+    var br = document.createElement("BR");
+    
+    var label = document.createElement("Label");
+    var labeltext = null;
+    var requiredLabName = "";
+    if (matching.includes(attibuteKey)){
+    labeltext = document.createTextNode(attibuteKey + "*!");    
+    isRequired = true;  //set required as true for matching element
+    }else {
+    if(isRequired){
+        requiredLabName = attibuteKey + " * ";
+        labeltext = document.createTextNode(requiredLabName);
+    }else{
+        labeltext = document.createTextNode(attibuteKey);    
+    }
+    }
+
+    
+    var divID = labelValue;
+    
+    if (labelValue.length  < 1){
+    divID = "DynamicTemplate";
+    }else if (labelValue.endsWith('.')){
+    var divID = 'div.'+ labelValue.substring(0, labelValue.length-1);
+    }
+    
+    label.appendChild(labeltext);
+    
+    var textField = document.createElement("INPUT");
+    
+    textField.setAttribute("class" , "form-control");
+    if(dataType){
+    if(dataType == "double"){
+        textField.setAttribute("type" , "number");
+        textField.setAttribute("step" , "any");
+
+    }else if(dataType == "boolean"){  //gw1218 testing boolean
+        var booleanDiv = document.createElement("div");
+
+        booleanDiv.setAttribute("class" , "onoffswitch");
+
+        //var checkField = document.createElement("INPUT");
+        textField.setAttribute("type" , "checkbox");
+        textField.setAttribute("name" , "onoffswitch");
+        textField.setAttribute("class" , "onoffswitch-checkbox");
+        textField.setAttribute("id" , ''+labelValue +attibuteKey+'');
+        if(defaultValue.substring(0,defaultValue.indexOf(":")) == "true") {
+        textField.setAttribute("checked" , true);
+        }else{
+        textField.removeAttribute("checked");
+        }
+
+            var booleanlabel = document.createElement("Label");
+            booleanlabel.setAttribute("class" , "onoffswitch-label");
+            booleanlabel.setAttribute("for" , ''+labelValue +attibuteKey+'');
+        
+            var span1 = document.createElement("span");
+            span1.setAttribute("class" , "onoffswitch-inner");
+            
+            var span2 = document.createElement("span");
+            span2.setAttribute("class" , "onoffswitch-switch"); 
+            
+            
+            booleanlabel.appendChild(span1);     
+            booleanlabel.appendChild(span2);     
+            booleanDiv.appendChild(textField);     
+            booleanDiv.appendChild(booleanlabel);      
+            
+            document.getElementById(divID).appendChild(label);  
+            document.getElementById(divID).appendChild(booleanDiv);     
+
+            //return;
+       } else{
+          textField.setAttribute("type" , dataType);
+       }
+       
+        
+
+    }
+    
+    if(dataType != "boolean"){
+    textField.setAttribute("style" , "width:300px;");
+    textField.setAttribute("ng-disabled" , "temp.policy.readOnly");
+    if(description && description != "null"){
+        textField.setAttribute("title", description);
+    }
+    }
+
+    var checkKey;
+    var id = "";
+    if(attributeManyKey){
+    checkKey = labelValue + attibuteKey+'@0';
+    textField.setAttribute("id" , ''+labelValue + attibuteKey+'@0'+''); 
+    var divTag = document.createElement("div");
+    divTag.setAttribute("id", "div."+ labelValue +attibuteKey);
+    var addButton = document.createElement("BUTTON");
+    var buttonaddLabel = document.createTextNode("+");       
+    addButton.appendChild(buttonaddLabel); 
+    addButton.setAttribute("id", labelValue + attibuteKey);
+    addButton.setAttribute("class", "btn btn-add-remove");
+    addButton.setAttribute("onclick" ,  'addNewChoice("'+labelValue + attibuteKey+'");');
+    addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+    var removeButton = document.createElement("BUTTON");
+    var buttonremoveLabel = document.createTextNode("-");       
+    removeButton.appendChild(buttonremoveLabel); 
+    removeButton.setAttribute("class", "btn btn-add-remove");
+    removeButton.setAttribute("onclick" ,  'removeChoice("'+labelValue + attibuteKey+'");');
+    removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+    document.getElementById(divID).appendChild(addButton); 
+    document.getElementById(divID).appendChild(removeButton); 
+    document.getElementById(divID).appendChild(label); 
+    id = "div."+labelValue+attibuteKey;
+    //var divTag = document.createElement("div");
+    divTag.setAttribute("id", id); 
+    document.getElementById(divID).appendChild(divTag);
+    textField.className += ' first_child';    
+    if(isRequired){
+        textField.setAttribute("required", "true");
+    }    
+    
+    divTag.appendChild(textField);     
+    document.getElementById(divID).appendChild(divTag); 
+    
+    }else if (dataType != "boolean"){
+    checkKey = labelValue + attibuteKey;
+    textField.setAttribute("id" , ''+labelValue +attibuteKey+'');
+    if(document.getElementById(divID).hasAttribute('required') || !document.getElementById(divID).hasAttribute('data-conditional')){
+        if(requiredLabName.includes("*") || isRequired){
+        textField.setAttribute("required", "true");
+        }
+    }else if (document.getElementById(divID).hasAttribute('data-conditional')){
+        if(requiredLabName.includes("*")){        
+        var requiredNode = document.createElement('span');
+        requiredNode.setAttribute("class", "mstooltip");
+        requiredNode.textContent = "?";
+        label.appendChild(requiredNode);
+        
+        var requiredNodeToolTip = document.createElement('span');
+        requiredNodeToolTip.setAttribute("class", "tooltiptext");
+        requiredNodeToolTip.textContent = "Conditional Required";
+        requiredNode.appendChild(requiredNodeToolTip);
+        
+        textField.setAttribute("data-conditional", divID);
+        textField.setAttribute("ng-blur", "validContionalRequired('"+divID+"')");
+        }
+    }
+            
+    document.getElementById(divID).appendChild(label);  
+    document.getElementById(divID).appendChild(textField);  
+    document.getElementById(divID).appendChild(br); 
+
+    }
+
+    if(dataType != "boolean" && divID.includes("@0") && divID.includes("div.")){
+    var firstChild_Id = divID.split("@0")[0];
+    var firstChild_element = document.getElementById(firstChild_Id);
+    if(firstChild_element){
+    
+        if(!firstChild_element.className.includes('children_group border')){
+        layer++;
+        if(layer > 4){ 
+            layer = 1
+        }
+        firstChild_element.className += ' children_group border' + layer; //here is div with a group of children.
+        }
+    }
+    }
+    console.log('firstChild_Id: ' + firstChild_Id);
+    console.log('divID: ' + divID);
+    
+    if(dataType != "boolean" && defaultValue.length > 0){    
+    if(defaultValue.includes(":")){
+        defaultValue = defaultValue.split(":")[0];
+        if(defaultValue === "NA") {
+        defaultValue = "";
+        }        
+    }
+    if(defaultValue != "undefined" && defaultValue != undefined && defaultValue != "null"){
+        document.getElementById(checkKey).value = defaultValue;
+    }
+    }
+    
+    if($scope.temp.policy.ruleData != null){
+    //document.getElementById(checkKey).value = $scope.temp.policy.ruleData[checkKey];
+    if (attributeManyKey){
+        var newCheckKey = checkKey.replace(attibuteKey + '@0',attibuteKey);
+        if($scope.temp.policy.ruleData[newCheckKey +'@0'] != undefined && $scope.temp.policy.ruleData[newCheckKey +'@0'] != "undefined"){
+          document.getElementById(newCheckKey +'@0').value = $scope.temp.policy.ruleData[newCheckKey +'@0'];
+        }
+    }else{
+        if($scope.temp.policy.ruleData[checkKey] != undefined && $scope.temp.policy.ruleData[checkKey] != "undefined"){
+            document.getElementById(checkKey).value = $scope.temp.policy.ruleData[checkKey];
+        }
+    }
+    } 
+    
+    if (dataType != "boolean"){
+        plainAttributeKeys.push(labelValue + attibuteKey+'*'+attributeManyKey);    
+    }else{
+        plainAttributeKeys.push(labelValue + attibuteKey+'*'+"boolean");    
+    }
     };
   
     $scope.labelManyKeys = [];
     $scope.labelLayout = function(labelValue, lableName, labelManyKey ){
-		var label = document.createElement("Label")
-		var divID = labelValue;
-		
-		if (labelValue.length  < 1){
-			divID = "DynamicTemplate";
-		} else if (labelValue.endsWith('.')){
-			var divID = 'div.'+ labelValue.substring(0, labelValue.length-1);
-		}
-		
-		var subAttributes = $scope.dcaeModelData.sub_attributes;
-	    var jsonObject = JSON.parse(subAttributes);	
-	    var lablInfo = findVal(jsonObject, lableName);
-		console.log("findValue : " + lableName +": "+ lablInfo);
-		var star = "";
-		var required = null;
-		if(lablInfo){
-			if(typeof lablInfo === 'string' ){
-			   if(lablInfo.includes("required-true")){
-				   star = " *";
-				   required = true;
-			    }else if (lablInfo.includes("required-false")){
-				   required = false
-			    }
-			}
-		}
-		
-		var labeltext = document.createTextNode(lableName + star);
-	
-		label.appendChild(labeltext);
+    var label = document.createElement("Label")
+    var divID = labelValue;
+    
+    if (labelValue.length  < 1){
+    divID = "DynamicTemplate";
+    } else if (labelValue.endsWith('.')){
+    var divID = 'div.'+ labelValue.substring(0, labelValue.length-1);
+    }
+    
+    var subAttributes = $scope.dcaeModelData.sub_attributes;
+        var jsonObject = JSON.parse(subAttributes);    
+        var lablInfo = findVal(jsonObject, lableName);
+    console.log("findValue : " + lableName +": "+ lablInfo);
+    var star = "";
+    var required = null;
+    if(lablInfo){
+    if(typeof lablInfo === 'string' ){
+       if(lablInfo.includes("required-true")){
+           star = " *";
+           required = true;
+        }else if (lablInfo.includes("required-false")){
+           required = false
+        }
+    }
+    }
+    
+    var labeltext = document.createTextNode(lableName + star);
+    
+    label.appendChild(labeltext);
 
 
-		if(labelManyKey){
-			var addButton = document.createElement("BUTTON");
-			var buttonLabel = document.createTextNode("+");       
-			addButton.appendChild(buttonLabel); 
-			addButton.setAttribute("class", "btn btn-add-remove");
-			addButton.setAttribute("onclick" ,  'addNewChoice("'+labelValue + lableName+'");');
-			addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
-			var removeButton = document.createElement("BUTTON");
-			var buttonremoveLabel = document.createTextNode("-");       
-			removeButton.appendChild(buttonremoveLabel); 
-			removeButton.setAttribute("class", "btn btn-add-remove");
-			removeButton.setAttribute("onclick" ,  'removeChoice("'+labelValue +lableName+'");');
-			removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly"); 
-			document.getElementById(divID).appendChild(addButton); 
-			document.getElementById(divID).appendChild(removeButton);
-			document.getElementById(divID).appendChild(label);
-			var id = "div."+labelValue+lableName;
-			var divTag = document.createElement("div");
-			divTag.setAttribute("id", id); 
-			document.getElementById(divID).appendChild(divTag);
-			
-			var divTag = document.createElement("div");
-			divTag.setAttribute("id", id +'@0');  
-			
-			if(!divTag.className.includes('children_group border')){
-				layer++;
-				if(layer > 4){ 
-					layer = 1
-				}
-				divTag.className += ' children_group border' + layer; //here is div with a group of children.
-			}
-			if(required){
-			   divTag.setAttribute("required", required);  
-			}else if(required == false){
-			   divTag.setAttribute("data-conditional", "yes");  
-			}
-			
-			document.getElementById(id).appendChild(divTag);
-			
-			$scope.labelManyKeys.push(lableName);
-			
-		}else{
-			var divTag = document.createElement("div");
-			divTag.setAttribute("id", "div."+labelValue+lableName);
-			
-			if(!divTag.className.includes('children_group border')){
-				layer++;
-				if(layer > 4){ 
-					layer = 1
-				}
-				divTag.className += ' children_group border' + layer; //here is div with a group of children.
-			}
-			if(required){
-			    divTag.setAttribute("required", required);  
-			}else if(required == false){
-				divTag.setAttribute("data-conditional", "yes");  
-			}  
-			document.getElementById(divID).appendChild(label);  
-			document.getElementById(divID).appendChild(divTag);			
-		}
+    if(labelManyKey){
+    var addButton = document.createElement("BUTTON");
+    var buttonLabel = document.createTextNode("+");       
+    addButton.appendChild(buttonLabel); 
+    addButton.setAttribute("class", "btn btn-add-remove");
+    addButton.setAttribute("onclick" ,  'addNewChoice("'+labelValue + lableName+'");');
+    addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+    var removeButton = document.createElement("BUTTON");
+    var buttonremoveLabel = document.createTextNode("-");       
+    removeButton.appendChild(buttonremoveLabel); 
+    removeButton.setAttribute("class", "btn btn-add-remove");
+    removeButton.setAttribute("onclick" ,  'removeChoice("'+labelValue +lableName+'");');
+    removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly"); 
+    document.getElementById(divID).appendChild(addButton); 
+    document.getElementById(divID).appendChild(removeButton);
+    document.getElementById(divID).appendChild(label);
+    var id = "div."+labelValue+lableName;
+    var divTag = document.createElement("div");
+    divTag.setAttribute("id", id); 
+    document.getElementById(divID).appendChild(divTag);
+    
+    var divTag = document.createElement("div");
+    divTag.setAttribute("id", id +'@0');  
+    
+    if(!divTag.className.includes('children_group border')){
+        layer++;
+        if(layer > 4){ 
+        layer = 1
+        }
+        divTag.className += ' children_group border' + layer; //here is div with a group of children.
+    }
+    if(required){
+       divTag.setAttribute("required", required);  
+    }else if(required == false){
+       divTag.setAttribute("data-conditional", "yes");  
+    }
+    
+    document.getElementById(id).appendChild(divTag);
+    
+    $scope.labelManyKeys.push(lableName);
+    
+    }else{
+    var divTag = document.createElement("div");
+    divTag.setAttribute("id", "div."+labelValue+lableName);
+    
+    if(!divTag.className.includes('children_group border')){
+        layer++;
+        if(layer > 4){ 
+        layer = 1
+        }
+        divTag.className += ' children_group border' + layer; //here is div with a group of children.
+    }
+    if(required){
+        divTag.setAttribute("required", required);  
+    }else if(required == false){
+        divTag.setAttribute("data-conditional", "yes");  
+    }  
+    document.getElementById(divID).appendChild(label);  
+    document.getElementById(divID).appendChild(divTag);    
+    }
     };
 
     $scope.dropBoxLayout = function(labelLevel, attributeName, many , defaultValue, listemunerateValues, isRequired, description){
-			var br = document.createElement("BR");
-		
-			if (labelLevel.length  < 1){
-					var divID = "DynamicTemplate";
-			} else if (labelLevel.endsWith('.')){
-					var divID = 'div.'+ labelLevel.substring(0, labelLevel.length-1);
-			}	
-		
-		
-			var label = document.createElement("Label")
-			
-			var refAttributes = $scope.dcaeModelData.ref_attributes;
-			if(isRequired != true && refAttributes){ //check refAttributes also		
-			   		var refAttributesList = refAttributes.split(splitComma);
-			   		for (k = 0; k < refAttributesList.length; k++){
-			       		var refAttribute = refAttributesList[k].split(splitEqual);	       		
-			       		if (attributeName == refAttribute[0].trim() && refAttribute[1].includes("required-true")){
-			       			isRequired = true;
-			       		}
-			   		}
-			}
-			
-			if (matching.includes(attributeName)){
-				var labeltext = document.createTextNode(attributeName + "*!");
-				label.appendChild(labeltext);
-				isRequired = true;  //set required as true for matching element
-			}else {
-				if(isRequired){
-				    var requiredLabName = attributeName+ " * ";
-					labeltext = document.createTextNode(requiredLabName);
-				}else{
-				    labeltext = document.createTextNode(attributeName);	
-				}
-			
-			    label.appendChild(labeltext);		
-			}
-			label.appendChild(labeltext);
-			// if this field is required, but its parent is not required
-			if(isRequired && document.getElementById(divID).hasAttribute('data-conditional')){
-			   	var requiredNode = document.createElement('span');
-				requiredNode.setAttribute("class", "mstooltip");
-				requiredNode.textContent = "?";
-				label.appendChild(requiredNode);
-					
-				var requiredNodeToolTip = document.createElement('span');
-				requiredNodeToolTip.setAttribute("class", "tooltiptext");
-				requiredNodeToolTip.textContent = "Conditional Required";
-				requiredNode.appendChild(requiredNodeToolTip);
+    var br = document.createElement("BR");
+    
+    if (labelLevel.length  < 1){
+        var divID = "DynamicTemplate";
+    } else if (labelLevel.endsWith('.')){
+        var divID = 'div.'+ labelLevel.substring(0, labelLevel.length-1);
+    }    
+    
+    
+    var label = document.createElement("Label")
+    
+    var refAttributes = $scope.dcaeModelData.ref_attributes;
+    if(isRequired != true && refAttributes){ //check refAttributes also    
+           var refAttributesList = refAttributes.split(splitComma);
+           for (k = 0; k < refAttributesList.length; k++){
+               var refAttribute = refAttributesList[k].split(splitEqual);               
+               if (attributeName == refAttribute[0].trim() && refAttribute[1].includes("required-true")){
+               isRequired = true;
+               }
+           }
+    }
+    
+    if (matching.includes(attributeName)){
+        var labeltext = document.createTextNode(attributeName + "*!");
+        label.appendChild(labeltext);
+        isRequired = true;  //set required as true for matching element
+    }else {
+        if(isRequired){
+            var requiredLabName = attributeName+ " * ";
+        labeltext = document.createTextNode(requiredLabName);
+        }else{
+            labeltext = document.createTextNode(attributeName);    
+        }
+    
+        label.appendChild(labeltext);    
+    }
+    label.appendChild(labeltext);
+    // if this field is required, but its parent is not required
+    if(isRequired && document.getElementById(divID).hasAttribute('data-conditional')){
+       var requiredNode = document.createElement('span');
+        requiredNode.setAttribute("class", "mstooltip");
+        requiredNode.textContent = "?";
+        label.appendChild(requiredNode);
+        
+        var requiredNodeToolTip = document.createElement('span');
+        requiredNodeToolTip.setAttribute("class", "tooltiptext");
+        requiredNodeToolTip.textContent = "Conditional Required";
+        requiredNode.appendChild(requiredNodeToolTip);
 
-		}
+    }
 
-		var listField = document.createElement("SELECT");
-		listField.setAttribute("class" , "form-control");
-		listField.setAttribute("style" , "width:300px;");
-		listField.setAttribute("ng-disabled" , "temp.policy.readOnly");
+    var listField = document.createElement("SELECT");
+    listField.setAttribute("class" , "form-control");
+    listField.setAttribute("style" , "width:300px;");
+    listField.setAttribute("ng-disabled" , "temp.policy.readOnly");
 
-		if(description && description != "null"){
-			listField.setAttribute("title", description);
-		}
+    if(description && description != "null"){
+    listField.setAttribute("title", description);
+    }
 
-		if(isRequired){
-			if(document.getElementById(divID).hasAttribute('data-conditional')){
-				listField.setAttribute("data-conditional", divID);
-				listField.setAttribute("ng-blur", "validContionalRequired('"+divID+"')");
-			}else{
-				listField.setAttribute("required", true);
-			}
-		}
-		if( many != true || isRequired != true){ // add an empty option for not required or not multiple select element
-			var optionFirst = document.createElement('option');
-			var optionValue = "";
-			if($scope.temp.policy.ruleData != null){
-				if($scope.temp.policy.ruleData[labelLevel + attributeName] != undefined && $scope.temp.policy.ruleData[labelLevel + attributeName] != "undefined"){
-					optionValue = $scope.temp.policy.ruleData[labelLevel + attributeName];  
-				}
-			} 
-			optionFirst.setAttribute('value', optionValue);
-			optionFirst.appendChild(document.createTextNode(optionValue));
-			listField.appendChild(optionFirst);	
-		}
-		var ruleFormationCheck = false;
-		if(listemunerateValues.length !== 0 && typeof listemunerateValues[0] == "string" && listemunerateValues[0].includes("dictionary:")) {
-			var ruleCheck = listemunerateValues[0].split("&");
-			var dictParams = ruleCheck[0].split(":");
-			var dictParamsSplit = dictParams[1].split("@");
-			if (ruleCheck[1] != undefined  && ruleCheck[1] == 'Rule') {
-				ruleFormationCheck = true;
-			}
-			PolicyAppService.getData(dictParamsSplit[0]).then(function (data) {
-				var j = data;
-				$scope.data = JSON.parse(j.data);
-				console.log($scope.data);
-				$scope.listDictionarys = JSON.parse($scope.data[dictParamsSplit[1]]);
-				for (i=0; i < $scope.listDictionarys.length; i += 1) {
-					option = document.createElement('option');
-					option.setAttribute('value', $scope.listDictionarys[i]);
-					option.appendChild(document.createTextNode($scope.listDictionarys[i]));
-					listField.appendChild(option);
-				}
-			}, function (error) {
-				console.log("failed");
-			});
+    if(isRequired){
+    if(document.getElementById(divID).hasAttribute('data-conditional')){
+        listField.setAttribute("data-conditional", divID);
+        listField.setAttribute("ng-blur", "validContionalRequired('"+divID+"')");
+    }else{
+        listField.setAttribute("required", true);
+    }
+    }
+    if( many != true || isRequired != true){ // add an empty option for not required or not multiple select element
+    var optionFirst = document.createElement('option');
+    var optionValue = "";
+    if($scope.temp.policy.ruleData != null){
+        if($scope.temp.policy.ruleData[labelLevel + attributeName] != undefined && $scope.temp.policy.ruleData[labelLevel + attributeName] != "undefined"){
+        optionValue = $scope.temp.policy.ruleData[labelLevel + attributeName];  
+        }
+    } 
+    optionFirst.setAttribute('value', optionValue);
+    optionFirst.appendChild(document.createTextNode(optionValue));
+    listField.appendChild(optionFirst);    
+    }
+    var ruleFormationCheck = false;
+    if(listemunerateValues.length !== 0 && typeof listemunerateValues[0] == "string" && listemunerateValues[0].includes("dictionary:")) {
+    var ruleCheck = listemunerateValues[0].split("&");
+    var dictParams = ruleCheck[0].split(":");
+    var dictParamsSplit = dictParams[1].split("@");
+    if (ruleCheck[1] != undefined  && ruleCheck[1] == 'Rule') {
+        ruleFormationCheck = true;
+    }
+    PolicyAppService.getData(dictParamsSplit[0]).then(function (data) {
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        console.log($scope.data);
+        $scope.listDictionarys = JSON.parse($scope.data[dictParamsSplit[1]]);
+        for (i=0; i < $scope.listDictionarys.length; i += 1) {
+        option = document.createElement('option');
+        option.setAttribute('value', $scope.listDictionarys[i]);
+        option.appendChild(document.createTextNode($scope.listDictionarys[i]));
+        listField.appendChild(option);
+        }
+    }, function (error) {
+        console.log("failed");
+    });
 
-		}
-		else{
-			for (i=0; i < listemunerateValues.length; i += 1) {
-				if(typeof listemunerateValues[i] == "string" && listemunerateValues[i].includes("equal-sign")){
-					listemunerateValues[i] = listemunerateValues[i].replace('equal-sign','=');
-				}
-				
-			    option = document.createElement('option');
-			    option.setAttribute('value', listemunerateValues[i]);
-			    option.appendChild(document.createTextNode(listemunerateValues[i]));
-			    option.setAttribute('value', listemunerateValues[i]);
-			    listField.appendChild(option);
-			}
-		}
-		listField.setAttribute("id" , ''+ labelLevel + attributeName + '');
+    }
+    else{
+    for (i=0; i < listemunerateValues.length; i += 1) {
+        if(typeof listemunerateValues[i] == "string" && listemunerateValues[i].includes("equal-sign")){
+        listemunerateValues[i] = listemunerateValues[i].replace('equal-sign','=');
+        }
+        
+        option = document.createElement('option');
+        option.setAttribute('value', listemunerateValues[i]);
+        option.appendChild(document.createTextNode(listemunerateValues[i]));
+        option.setAttribute('value', listemunerateValues[i]);
+        listField.appendChild(option);
+    }
+    }
+    listField.setAttribute("id" , ''+ labelLevel + attributeName + '');
 
-		enumKeyList.push(attributeName);
+    enumKeyList.push(attributeName);
 
-		document.getElementById(divID).appendChild(label);  
-		document.getElementById(divID).appendChild(br);	
+    document.getElementById(divID).appendChild(label);  
+    document.getElementById(divID).appendChild(br);    
 
-		if(many == true){
-			document.getElementById(divID).appendChild(listField).multiple = true;
-			plainAttributeKeys.push(labelLevel + attributeName+'*'+true);
-		}else {
-			document.getElementById(divID).appendChild(listField).multiple = false;
-			plainAttributeKeys.push(labelLevel + attributeName+'*'+false);
+    if(many == true){
+    document.getElementById(divID).appendChild(listField).multiple = true;
+    plainAttributeKeys.push(labelLevel + attributeName+'*'+true);
+    }else {
+    document.getElementById(divID).appendChild(listField).multiple = false;
+    plainAttributeKeys.push(labelLevel + attributeName+'*'+false);
 
-			if (defaultValue){
-				if(defaultValue.includes(':')){
-					defaultValue = defaultValue.split(':')[0];
-				}
-				var location = listemunerateValues.indexOf(defaultValue);
-				document.getElementById(labelLevel +attributeName).options[location+1].selected = true;
-			}
-		}
+    if (defaultValue){
+        if(defaultValue.includes(':')){
+        defaultValue = defaultValue.split(':')[0];
+        }
+        var location = listemunerateValues.indexOf(defaultValue);
+        document.getElementById(labelLevel +attributeName).options[location+1].selected = true;
+    }
+    }
 
-		if (ruleFormationCheck) {
-			var optionInput = document.createElement("INPUT");
-			optionInput.setAttribute("type" , "text");
-			optionInput.setAttribute("id" , ''+ labelLevel + attributeName + '.input');
-			optionInput.setAttribute("name" , "ruleName");
-			optionInput.setAttribute("value" , "  ");
-			optionInput.setAttribute("style" , "width:300px;");
-			optionInput.setAttribute("ng-disabled" , "temp.policy.readOnly");
-			optionInput.removeAttribute("required");
+    if (ruleFormationCheck) {
+    var optionInput = document.createElement("INPUT");
+    optionInput.setAttribute("type" , "text");
+    optionInput.setAttribute("id" , ''+ labelLevel + attributeName + '.input');
+    optionInput.setAttribute("name" , "ruleName");
+    optionInput.setAttribute("value" , "  ");
+    optionInput.setAttribute("style" , "width:300px;");
+    optionInput.setAttribute("ng-disabled" , "temp.policy.readOnly");
+    optionInput.removeAttribute("required");
 
-			document.getElementById(divID).appendChild(optionInput);
+    document.getElementById(divID).appendChild(optionInput);
 
-			var optionButton = document.createElement("BUTTON");
-			optionButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
-			var buttonLabel = document.createTextNode("+");       
-			optionButton.appendChild(buttonLabel); 
-			optionButton.setAttribute("class", "btn btn-add-remove");
-			optionButton.setAttribute("onclick" , 'addDynamicOptions("'+ labelLevel + attributeName + '");');
-			optionButton.removeAttribute("required");
+    var optionButton = document.createElement("BUTTON");
+    optionButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+    var buttonLabel = document.createTextNode("+");       
+    optionButton.appendChild(buttonLabel); 
+    optionButton.setAttribute("class", "btn btn-add-remove");
+    optionButton.setAttribute("onclick" , 'addDynamicOptions("'+ labelLevel + attributeName + '");');
+    optionButton.removeAttribute("required");
 
 
-			document.getElementById(divID).appendChild(optionButton);
-			document.getElementById(divID).appendChild(br); 
-		}
+    document.getElementById(divID).appendChild(optionButton);
+    document.getElementById(divID).appendChild(br); 
+    }
 
-		if($scope.temp.policy.ruleData != null){
-			if (many == true){
-				document.getElementById(labelLevel +attributeName).options[0].selected = false;
-				for (i=0; i < listemunerateValues.length; i += 1) {
-					var testValue = $scope.temp.policy.ruleData[labelLevel +attributeName+'@' + i];
-					if (testValue === undefined){
-						testValue = $scope.temp.policy.ruleData[labelLevel +attributeName];
-					}
-					var location = listemunerateValues.indexOf(testValue);
-					if (location!=-1){
-						document.getElementById(labelLevel +attributeName).options[location].selected = true;
-					}
-				}			
-			}else {
-				if($scope.temp.policy.ruleData[labelLevel + attributeName] != undefined && $scope.temp.policy.ruleData[labelLevel + attributeName] != "undefined"){
-					document.getElementById(labelLevel + attributeName).value = $scope.temp.policy.ruleData[labelLevel + attributeName];	
-				}
-			}
-		}
-	};
+    if($scope.temp.policy.ruleData != null){
+    if (many == true){
+        document.getElementById(labelLevel +attributeName).options[0].selected = false;
+        for (i=0; i < listemunerateValues.length; i += 1) {
+        var testValue = $scope.temp.policy.ruleData[labelLevel +attributeName+'@' + i];
+        if (testValue === undefined){
+            testValue = $scope.temp.policy.ruleData[labelLevel +attributeName];
+        }
+        var location = listemunerateValues.indexOf(testValue);
+        if (location!=-1){
+            document.getElementById(labelLevel +attributeName).options[location].selected = true;
+        }
+        }    
+    }else {
+        if($scope.temp.policy.ruleData[labelLevel + attributeName] != undefined && $scope.temp.policy.ruleData[labelLevel + attributeName] != "undefined"){
+        document.getElementById(labelLevel + attributeName).value = $scope.temp.policy.ruleData[labelLevel + attributeName];    
+        }
+    }
+    }
+    };
 
-	addDynamicOptions = function(id) { 
-		var option = document.createElement("option");
-		var value = document.getElementById(id+".input").value;
-		option.setAttribute('value', value);
-		option.appendChild(document.createTextNode(value));
-		document.getElementById(id).options.add(option);
-		document.getElementById(id+".input").value = "";
-	};
+    addDynamicOptions = function(id) { 
+    var option = document.createElement("option");
+    var value = document.getElementById(id+".input").value;
+    option.setAttribute('value', value);
+    option.appendChild(document.createTextNode(value));
+    document.getElementById(id).options.add(option);
+    document.getElementById(id+".input").value = "";
+    };
 
-	function onlyUnique(value, index, self) { 
-		return self.indexOf(value) === index;
-	}
+    function onlyUnique(value, index, self) { 
+    return self.indexOf(value) === index;
+    }
 
-	$scope.savePolicy = function(policy){
-		if(policy.itemContent != undefined){
-			$scope.refreshCheck = true; 
-			$scope.policyNavigator = policy.itemContent;
-			policy.itemContent = "";
-		}
-		$scope.savebutton = false;
-		var splitAt = '*';
-		var dot ='.';
-		var jsonPolicy = {};
-		if(plainAttributeKeys != null){
-			for(a = 0; a < plainAttributeKeys.length; a++){
-				var splitPlainAttributeKey = plainAttributeKeys[a].split(splitAt);
-				console.log("splitPlainAttributeKey: " + splitPlainAttributeKey);	
-				var searchElement = document.getElementById(splitPlainAttributeKey[0]);
-				var key = splitPlainAttributeKey[0];
-				if(searchElement == null){
-					searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
-					key = splitPlainAttributeKey[0]+'@0';
-				}else if (searchElement.nodeName == 'BUTTON'){
-					searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
-					key = splitPlainAttributeKey[0]+'@0';
-				}
-				if(searchElement != null){
-					var keySplit = key.split(dot);
-					var elumentLocation = keySplit.length;
-					var enumKey = key;
-					if (elumentLocation > 1){
-						enumKey = keySplit[keySplit.length - 1];
-					}
-					//check it is undefined or not
-					if (enumKeyList != undefined && enumKeyList.indexOf(enumKey) != -1){
-						if (splitPlainAttributeKey[1]!= undefined && splitPlainAttributeKey[1].indexOf("true") !== -1){
-							var multiSlect = [];
-							for ( var i = 0; i < searchElement.selectedOptions.length; i++) {
-								multiSlect.push(searchElement.selectedOptions[i].value);
-								}
-							jsonPolicy[key]= multiSlect;
-						}else{
-							console.log(" searchElement.value = > " + searchElement.value);
-							if(splitPlainAttributeKey[1]!= undefined && splitPlainAttributeKey[1] == "boolean"){
-								jsonPolicy[key]= false;
-								for(var i=0; i<booleanTrueElements.length; i++){									
-									if(booleanTrueElements[i] == key){
-										jsonPolicy[key]= true;
-									}
-								}
+    $scope.savePolicy = function(policy){
+    if(policy.itemContent != undefined){
+    $scope.refreshCheck = true; 
+    $scope.policyNavigator = policy.itemContent;
+    policy.itemContent = "";
+    }
+    $scope.savebutton = false;
+    var splitAt = '*';
+    var dot ='.';
+    var jsonPolicy = {};
+    if(plainAttributeKeys != null){
+    for(a = 0; a < plainAttributeKeys.length; a++){
+        var splitPlainAttributeKey = plainAttributeKeys[a].split(splitAt);
+        console.log("splitPlainAttributeKey: " + splitPlainAttributeKey);    
+        var searchElement = document.getElementById(splitPlainAttributeKey[0]);
+        var key = splitPlainAttributeKey[0];
+        if(searchElement == null){
+        searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
+        key = splitPlainAttributeKey[0]+'@0';
+        }else if (searchElement.nodeName == 'BUTTON'){
+        searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
+        key = splitPlainAttributeKey[0]+'@0';
+        }
+        if(searchElement != null){
+        var keySplit = key.split(dot);
+        var elumentLocation = keySplit.length;
+        var enumKey = key;
+        if (elumentLocation > 1){
+            enumKey = keySplit[keySplit.length - 1];
+        }
+        //check it is undefined or not
+        if (enumKeyList != undefined && enumKeyList.indexOf(enumKey) != -1){
+            if (splitPlainAttributeKey[1]!= undefined && splitPlainAttributeKey[1].indexOf("true") !== -1){
+            var multiSlect = [];
+            for ( var i = 0; i < searchElement.selectedOptions.length; i++) {
+                multiSlect.push(searchElement.selectedOptions[i].value);
+                }
+            jsonPolicy[key]= multiSlect;
+            }else{
+            console.log(" searchElement.value = > " + searchElement.value);
+            if(splitPlainAttributeKey[1]!= undefined && splitPlainAttributeKey[1] == "boolean"){
+                jsonPolicy[key]= false;
+                for(var i=0; i<booleanTrueElements.length; i++){                
+                if(booleanTrueElements[i] == key){
+                    jsonPolicy[key]= true;
+                }
+                }
 
-							}else{
-								jsonPolicy[key]= searchElement.value;
-							}
-						}
-    				} else {
-        				if(searchElement.value != null){
-        					jsonPolicy[key]= searchElement.value;        					
-							console.log(" searchElement.value = > " + searchElement.value);
-							if(splitPlainAttributeKey[1] == "boolean"){
-								jsonPolicy[key]= false;
-								for(var i=0; i<booleanTrueElements.length; i++){									
-									if(booleanTrueElements[i] == key){
-										jsonPolicy[key]= true;
-									}
-								}
-							}
-        				}
-    				}
-    			}
-    		}
-    	}
+            }else{
+                jsonPolicy[key]= searchElement.value;
+            }
+            }
+            } else {
+                if(searchElement.value != null){
+                jsonPolicy[key]= searchElement.value;                
+            console.log(" searchElement.value = > " + searchElement.value);
+            if(splitPlainAttributeKey[1] == "boolean"){
+                jsonPolicy[key]= false;
+                for(var i=0; i<booleanTrueElements.length; i++){                
+                if(booleanTrueElements[i] == key){
+                    jsonPolicy[key]= true;
+                }
+                }
+            }
+                }
+            }
+        }
+        }
+    }
         var uuu = "policycreation/save_policy";
         var postData={policyData: policy, policyJSON : jsonPolicy};
         $.ajax({
@@ -1575,191 +1577,191 @@
             data: JSON.stringify(postData),
             success : function(data){
                 $scope.$apply(function(){
-                	$scope.data=data.policyData;
-                	if($scope.data == 'success'){
-                		$scope.temp.policy.readOnly = 'true';
-                		$scope.safetyChecker = data.policyData.split("#")[2];
-                		if ($scope.safetyChecker!=undefined) {
-                			Notification.success($scope.safetyChecker);
-                		}
-                		$scope.pushStatus=data.policyData.split("&")[1];
-                		if($scope.pushStatus=="successPush"){
-                			Notification.success("Policy pushed successfully");
-                		}
-                		Notification.success("Policy Saved Successfully.");	
-                	}else if ($scope.data == 'PolicyExists'){
-						$scope.savebutton = true;
-						Notification.error("Policy Already Exists with Same Name in Scope.");
-					}
+                $scope.data=data.policyData;
+                if($scope.data == 'success'){
+                    $scope.temp.policy.readOnly = 'true';
+                    $scope.safetyChecker = data.policyData.split("#")[2];
+                    if ($scope.safetyChecker!=undefined) {
+                    Notification.success($scope.safetyChecker);
+                    }
+                    $scope.pushStatus=data.policyData.split("&")[1];
+                    if($scope.pushStatus=="successPush"){
+                    Notification.success("Policy pushed successfully");
+                    }
+                    Notification.success("Policy Saved Successfully.");    
+                }else if ($scope.data == 'PolicyExists'){
+            $scope.savebutton = true;
+            Notification.error("Policy Already Exists with Same Name in Scope.");
+        }
                 });
                 console.log($scope.data);
             },
             error : function(data){
-            	Notification.error("Error Occured while saving Policy.");
+            Notification.error("Error Occured while saving Policy.");
             }
         });
     };
     
     var booleanTrueElements = [];
     $scope.validatePolicy = function(policy){
-    	document.getElementById("validate").innerHTML = "";
-    	var splitAt = '*';
-    	var jsonPolicy = {};
-    	if(plainAttributeKeys != null){
-    		for(a = 0; a < plainAttributeKeys.length; a++){
-    			var splitPlainAttributeKey = plainAttributeKeys[a].split(splitAt);
-    			console.log(splitPlainAttributeKey[1]);	
-    			var searchElement = document.getElementById(splitPlainAttributeKey[0]);
-    			var key = splitPlainAttributeKey[0];
-    			if(searchElement == null){
-    				searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
-    				key = splitPlainAttributeKey[0]+'@0';
-    			}else if (searchElement.nodeName == 'BUTTON'){
-    				searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
-    				key = splitPlainAttributeKey[0]+'@0';
-    			}
-    			if(searchElement != null){
-    				if (enumKeyList.indexOf(key) != -1){
-						if (splitPlainAttributeKey[1].indexOf("true") !== -1){
-							var multiSlect = [];
-							for ( var i = 0; i < searchElement.selectedOptions.length; i++) {
-								multiSlect.push(searchElement.selectedOptions[i].value);
-								}
-							jsonPolicy[key]= multiSlect;
-						}else{
-							jsonPolicy[key]= searchElement.value;
-						}
-    					if(searchElement.getAttribute("required")){
-    						if(!searchElement.value){
-    							return;
-    						}
-    					} 
-    				} else {
-        				if(searchElement.value != null){
-        					jsonPolicy[key]= searchElement.value;
-        					if(searchElement.getAttribute("required")){
-        						if(!searchElement.value){
-        							return;
-        						}
-        					}        					
-        				}
-    				}
-    			}
-    		}
-    		
-    		
-    		var checkedValue = $('.onoffswitch-checkbox:checked').val();
-    		
-    	    var x = document.getElementsByClassName("onoffswitch-checkbox");
-   	    
-    	        	     
-    		if(checkedValue){
-    			console.log("checkedValue:" + checkedValue);
-    			for(var i=0; i<x.length; x++){
-        	       console.log("checkbox id: " + x[i].id);
-       			   booleanTrueElements.push(x[i].id)
-    			}    
-    		}
-    	}
+    document.getElementById("validate").innerHTML = "";
+    var splitAt = '*';
+    var jsonPolicy = {};
+    if(plainAttributeKeys != null){
+        for(a = 0; a < plainAttributeKeys.length; a++){
+        var splitPlainAttributeKey = plainAttributeKeys[a].split(splitAt);
+        console.log(splitPlainAttributeKey[1]);    
+        var searchElement = document.getElementById(splitPlainAttributeKey[0]);
+        var key = splitPlainAttributeKey[0];
+        if(searchElement == null){
+            searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
+            key = splitPlainAttributeKey[0]+'@0';
+        }else if (searchElement.nodeName == 'BUTTON'){
+            searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
+            key = splitPlainAttributeKey[0]+'@0';
+        }
+        if(searchElement != null){
+            if (enumKeyList.indexOf(key) != -1){
+            if (splitPlainAttributeKey[1].indexOf("true") !== -1){
+            var multiSlect = [];
+            for ( var i = 0; i < searchElement.selectedOptions.length; i++) {
+                multiSlect.push(searchElement.selectedOptions[i].value);
+                }
+            jsonPolicy[key]= multiSlect;
+            }else{
+            jsonPolicy[key]= searchElement.value;
+            }
+            if(searchElement.getAttribute("required")){
+                if(!searchElement.value){
+                return;
+                }
+            } 
+            } else {
+                if(searchElement.value != null){
+                jsonPolicy[key]= searchElement.value;
+                if(searchElement.getAttribute("required")){
+                    if(!searchElement.value){
+                    return;
+                    }
+                }                
+                }
+            }
+        }
+        }
+        
+        
+        var checkedValue = $('.onoffswitch-checkbox:checked').val();
+        
+        var x = document.getElementsByClassName("onoffswitch-checkbox");
+           
+                 
+        if(checkedValue){
+        console.log("checkedValue:" + checkedValue);
+        for(var i=0; i<x.length; x++){
+               console.log("checkbox id: " + x[i].id);
+              booleanTrueElements.push(x[i].id)
+        }    
+        }
+    }
         var uuu = "policyController/validate_policy.htm";
 
         console.log("$scope.isCheck:" + $scope.isCheck);
         
         if($scope.isCheck == true){
-        	if(("configName" in policy) == false){
- 				Notification.error("Validation Failed: configName is required");
- 				$scope.savebutton = true;
- 				return;
-        	}
-        	if(("location" in policy) == false){
- 				Notification.error("Validation Failed: location is required");
- 				$scope.savebutton = true;
- 				return;
-        	}
-        	if(("uuid" in policy) == false){
- 				Notification.error("Validation Failed: uuid is required");
- 				$scope.savebutton = true;
- 				return;
-        	}
-        	if(("policyScope" in policy) == false){
- 				Notification.error("Validation Failed: policyScope is required");
- 				$scope.savebutton = true;
- 				return;
-        	}
+        if(("configName" in policy) == false){
+         Notification.error("Validation Failed: configName is required");
+         $scope.savebutton = true;
+         return;
+        }
+        if(("location" in policy) == false){
+         Notification.error("Validation Failed: location is required");
+         $scope.savebutton = true;
+         return;
+        }
+        if(("uuid" in policy) == false){
+         Notification.error("Validation Failed: uuid is required");
+         $scope.savebutton = true;
+         return;
+        }
+        if(("policyScope" in policy) == false){
+         Notification.error("Validation Failed: policyScope is required");
+         $scope.savebutton = true;
+         return;
+        }
         }        
         
         var postData={policyData: policy, policyJSON : jsonPolicy};
- 		$.ajax({
- 			type : 'POST',
- 			url : uuu,
- 			dataType: 'json',
- 			contentType: 'application/json',
- 			data: JSON.stringify(postData),
- 			success : function(data){
- 				$scope.$apply(function(){
- 					$scope.validateData = data.data.replace(/\"/g, "");
-					$scope.data=data.data.substring(1,8);
-						var size = data.data.length;
-						if($scope.data == 'success'){
-							Notification.success("Validation Success.");
-							$scope.savebutton = false;
-							if (size > 18){
-								var displayWarning = data.data.substring(19,size  - 1);
-								document.getElementById("validate").innerHTML = "Safe Policy Warning Message  :  "+displayWarning;
-								document.getElementById("validate").style.color = "white";
-								document.getElementById("validate").style.backgroundColor = "skyblue";
-							}
- 						}else{
- 							Notification.error("Validation Failed.");
- 							document.getElementById("validate").innerHTML = $scope.validateData;
- 							document.getElementById("validate").style.color = "white";
- 							document.getElementById("validate").style.backgroundColor = "red";
- 							$scope.savebutton = true;
- 						}
- 						
- 				});
- 				console.log($scope.data);	
- 			},
- 			error : function(data){
- 				Notification.error("Validation Failed.");
- 				$scope.savebutton = true;
- 			}
- 		});
+     $.ajax({
+     type : 'POST',
+     url : uuu,
+     dataType: 'json',
+     contentType: 'application/json',
+     data: JSON.stringify(postData),
+     success : function(data){
+         $scope.$apply(function(){
+         $scope.validateData = data.data.replace(/\"/g, "");
+        $scope.data=data.data.substring(1,8);
+            var size = data.data.length;
+            if($scope.data == 'success'){
+            Notification.success("Validation Success.");
+            $scope.savebutton = false;
+            if (size > 18){
+                var displayWarning = data.data.substring(19,size  - 1);
+                document.getElementById("validate").innerHTML = "Safe Policy Warning Message  :  "+displayWarning;
+                document.getElementById("validate").style.color = "white";
+                document.getElementById("validate").style.backgroundColor = "skyblue";
+            }
+             }else{
+             Notification.error("Validation Failed.");
+             document.getElementById("validate").innerHTML = $scope.validateData;
+             document.getElementById("validate").style.color = "white";
+             document.getElementById("validate").style.backgroundColor = "red";
+             $scope.savebutton = true;
+             }
+             
+         });
+         console.log($scope.data);    
+     },
+     error : function(data){
+         Notification.error("Validation Failed.");
+         $scope.savebutton = true;
+     }
+     });
     };
 
-	// Switch Click
-	$('.Switch').click(function() {
-			// Check If Enabled (Has 'On' Class)
-			if ($(this).hasClass('On')){
-				// Try To Find Checkbox Within Parent Div, And Check It
-				$(this).parent().find('input:checkbox').attr('checked', true);
-				// Change Button Style - Remove On Class, Add Off Class
-				$(this).removeClass('On').addClass('Off');
-			} else { // If Button Is Disabled (Has 'Off' Class)
-				// Try To Find Checkbox Within Parent Div, And Uncheck It
-				$(this).parent().find('input:checkbox').attr('checked', false);	
-				// Change Button Style - Remove Off Class, Add On Class
-				$(this).removeClass('Off').addClass('On');	
-			}	
-		});
-	 // Loops Through Each Toggle Switch On Page
-	$('.Switch').each(function() {
-			// Search of a checkbox within the parent
-			if ($(this).parent().find('input:checkbox').length){
-				
-				// If checkbox doesnt have the show class then hide it
-				if (!$(this).parent().find('input:checkbox').hasClass("show")){
-					$(this).parent().find('input:checkbox').hide(); }
-			
-				// Look at the checkbox's checkked state
-				if ($(this).parent().find('input:checkbox').is(':checked')){
-					// Checkbox is not checked, Remove the On Class and Add the Off Class
-					$(this).removeClass('On').addClass('Off');
-				} else { 			
-					// Checkbox Is Checked Remove Off Class, and Add the On Class
-					$(this).removeClass('Off').addClass('On');
-				}
-			}
-		});
+    // Switch Click
+    $('.Switch').click(function() {
+    // Check If Enabled (Has 'On' Class)
+    if ($(this).hasClass('On')){
+        // Try To Find Checkbox Within Parent Div, And Check It
+        $(this).parent().find('input:checkbox').attr('checked', true);
+        // Change Button Style - Remove On Class, Add Off Class
+        $(this).removeClass('On').addClass('Off');
+    } else { // If Button Is Disabled (Has 'Off' Class)
+        // Try To Find Checkbox Within Parent Div, And Uncheck It
+        $(this).parent().find('input:checkbox').attr('checked', false);    
+        // Change Button Style - Remove Off Class, Add On Class
+        $(this).removeClass('Off').addClass('On');    
+    }    
+    });
+     // Loops Through Each Toggle Switch On Page
+    $('.Switch').each(function() {
+    // Search of a checkbox within the parent
+    if ($(this).parent().find('input:checkbox').length){
+        
+        // If checkbox doesnt have the show class then hide it
+        if (!$(this).parent().find('input:checkbox').hasClass("show")){
+        $(this).parent().find('input:checkbox').hide(); }
+    
+        // Look at the checkbox's checkked state
+        if ($(this).parent().find('input:checkbox').is(':checked')){
+        // Checkbox is not checked, Remove the On Class and Add the Off Class
+        $(this).removeClass('On').addClass('Off');
+        } else {     
+        // Checkbox Is Checked Remove Off Class, and Add the On Class
+        $(this).removeClass('Off').addClass('On');
+        }
+    }
+    });
 
 }]);
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/OptimizationPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/OptimizationPolicyController.js
index 8de78fc..2727925 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/OptimizationPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/OptimizationPolicyController.js
@@ -17,7 +17,9 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-angular.module('abs').controller('optimizationController', ['$scope', '$window', '$compile', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, $window, $compile, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) {
+angular.module('abs').controller('optimizationController', 
+    ['$scope', '$window', '$compile', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', 
+    function ($scope, $window, $compile, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) {
     $("#dialog").hide();
     
     $scope.policyNavigator;
@@ -26,18 +28,18 @@
     $scope.refreshCheck = false;
     
     if(!$scope.temp.policy.editPolicy  && !$scope.temp.policy.readOnly){
-    	$scope.temp.policy = {
-    			policyType : "Config",
-    			configPolicyType : "Optimization"
-    	}
+    $scope.temp.policy = {
+        policyType : "Config",
+        configPolicyType : "Optimization"
+    }
     }
     
     $scope.refresh = function(){
-    	if($scope.refreshCheck){
-    		$scope.policyNavigator.refresh();
-    	}
-    	$scope.modal('createNewPolicy', true);
-    	$scope.temp.policy = "";
+    if($scope.refreshCheck){
+        $scope.policyNavigator.refresh();
+    }
+    $scope.modal('createNewPolicy', true);
+    $scope.temp.policy = "";
     };
     
     $scope.modal = function(id, hide) {
@@ -45,245 +47,245 @@
     };
     
     $('#ttlDate').datepicker({
-    	dateFormat: 'dd/mm/yy',
-    	changeMonth: true,
-    	changeYear: true,
-    	onSelect: function(date) {
-    		angular.element($('#ttlDate')).triggerHandler('input');
-    	}
+    dateFormat: 'dd/mm/yy',
+    changeMonth: true,
+    changeYear: true,
+    onSelect: function(date) {
+        angular.element($('#ttlDate')).triggerHandler('input');
+    }
     });
     
-	if ($scope.temp.policy.editPolicy != undefined|| $scope.temp.policy.readOnly  != undefined){
-		if ($scope.temp.policy.configName == undefined){
-			$scope.isCheck = false;
-		}else{
-			$scope.isCheck = true;
-		}
-	}else {
-		$scope.isCheck = false;
-	}
-		
-	PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);
-		console.log($scope.onapNameDictionaryDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	PolicyAppService.getData('get_DCAEPriorityValues').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.priorityDatas = JSON.parse($scope.data.priorityDatas);
-		console.log($scope.priorityDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	PolicyAppService.getData('getDictionary/get_OptimizationModelsDataByName').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		var inputModelList = JSON.parse($scope.data.optimizationModelsDictionaryDatas);
-		var unique = {};
-		var uniqueList = [];
-		for(var i = 0; i < inputModelList.length; i++){
-			if(typeof unique[inputModelList[i]] == "undefined"){
-				unique[inputModelList[i]] = "";
-				uniqueList.push(inputModelList[i]);
-			}
-		}
-		$scope.optimizationModelsDictionaryDatas = uniqueList;
-		console.log($scope.optimizationModelsDictionaryDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
-		console.log($scope.riskTypeDictionaryDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	 $scope.choices = [];
-	 $scope.attributeDatas = [{"attributes" : $scope.choices}];
-	 $scope.isInitEditTemplate = true;  //just initially create the edit template, didn't click add button yet.
-	 $scope.addNewChoice = function(value) {
-		 console.log("input value : " + value);
-		 if(value != undefined){
-			if (value.startsWith('div.')){
-				value = value.replace('div.','');
-			}
-			var parentElement = document.getElementById("div."+value);
-			var div = document.getElementById(value+"@0");
-			if(div != null){
-				var clone = div.cloneNode(true); 
-				var addElement = parentElement.childElementCount;
-				clone.id = ''+value+'@'+addElement;
-				clone.value = '';
-				if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){ //if it's view or edit
-					if($scope.temp.policy.ruleData[clone.id] || ($scope.temp.policy.editPolicy && !$scope.isInitEditTemplate)){  // Only append child if its value found in ruleData or edit mode
-						if($scope.temp.policy.ruleData[clone.id]){
-						    clone.value = $scope.temp.policy.ruleData[clone.id];
-						}
-						if(!clone.className.includes("child_single")){   
-							clone.className += ' child_single'; //single element clone
-						}
-						document.getElementById("div."+value).appendChild(clone);
-						plainAttributeKeys.push(''+value+'@'+addElement);
-					}
-				}else{ //not view or edit
-					if(!clone.className.includes("child_single")){   
-						clone.className += ' child_single'; //single element clone
-					}
-					document.getElementById("div."+value).appendChild(clone);
-					plainAttributeKeys.push(''+value+'@'+addElement);
-				}
-			}else{
-				div = document.getElementById("div."+value+"@0");
-				
-				if(div){
-			    	div.className += ' children_group'; //div with a group of children.
-				}				
-				var childElement = parentElement.firstElementChild;
-				var countParent = parentElement.childElementCount;
-				var childElementString = childElement.innerHTML;
-				var find = value+"@0";
-				var re = new RegExp(find, 'g');
-				childElementString = childElementString.replace(re,value+'@' + countParent);
-				var clone = childElement.cloneNode(true);
-				for (var ii = 0; ii < parentElement.childNodes.length; ii++){
-		            var childId = parentElement.childNodes[ii].id;
-		            if(ii = parentElement.childNodes.length){
-		            	var childnewId = childId.slice(0, -1);
-		            	var count = childId.slice(-1);
-		            }
-		        }
-				var countvalue = parseInt(count) + 1;
-				clone.id = childnewId+countvalue;
-				clone.value = '';
-				clone.innerHTML=childElementString;
-				document.getElementById("div."+value).appendChild(clone);
-				var selects = clone.getElementsByTagName("select");
-				var inputs = clone.getElementsByTagName("input");
-				var removeValues = [];
-				for(var i=0; i<inputs.length; i++){
-					if ($scope.temp.policy.ruleData!=undefined){
-						var checkValue = $scope.temp.policy.ruleData[inputs[i].id];
-						if (checkValue!=undefined && checkValue != "undefined"){
-							if($scope.temp.policy.ruleData != null){
-								var checkValue = $scope.temp.policy.ruleData[inputs[i].id];
-								document.getElementById(inputs[i].id).value = $scope.temp.policy.ruleData[inputs[i].id];
-								plainAttributeKeys.push(inputs[i].id);
-							}
-						} else {
-							plainAttributeKeys.push(inputs[i].id);
-						}
-					}else {
-						plainAttributeKeys.push(inputs[i].id);
-					}
-				}
-				
-				for(var i=0; i<selects.length; i++){
-					if ($scope.temp.policy.ruleData!=undefined){
-						var checkValue = $scope.temp.policy.ruleData[selects[i].id];
-						if (checkValue!=undefined && checkValue!="undefined"){
-							if($scope.temp.policy.ruleData != null){
-								var checkValue = $scope.temp.policy.ruleData[selects[i].id];
-								document.getElementById(selects[i].id).value = $scope.temp.policy.ruleData[selects[i].id];
-								plainAttributeKeys.push(selects[i].id);
-							}
-						} else {
-							plainAttributeKeys.push(selects[i].id);
-						}
-					}else {
-						plainAttributeKeys.push(selects[i].id);
-					}
-				}
-				
-				for (var k=0; k<removeValues.length; k++){
-					var elem = document.getElementById(removeValues[k]);
-					elem.parentNode.removeChild(elem);
-				}
-				var ele = angular.element(document.getElementById("div."+value));
-	    		$compile(ele.contents())($scope);
-	            $scope.$apply();
-			}
-		 }
-	 };
-	 
-	 function findVal(object, key) {
-		    var value;
-		    Object.keys(object).some(function(k) {
-		        if (k === key) {
-		            value = object[k];
-		            return true;
-		        }
-		        if (object[k] && typeof object[k] === 'object') {
-		            value = findVal(object[k], key);
-		            return value !== undefined;
-		        }
-		    });
-		    return value;
-	}
-	 
-	 $scope.removeChoice = function(value) {
-		 console.log(value);
-		 if(value != undefined){
-			 var c = document.getElementById("div."+value).childElementCount;
-			 
-			 if(c == 1){
-				 Notification.error("The original one is not removable.");
-				 return;
-			 }	
-			 document.getElementById("div."+value).removeChild(document.getElementById("div."+value).lastChild);	 
-		 }
-	 };
-	 
-	 $scope.pullVersion = function(serviceName) {
-		 console.log(serviceName);
-		 if(serviceName != undefined){
-			 var uuu = "policyController/getModelServiceVersionData.htm";
-			 var postData={policyData: serviceName};
-			 $.ajax({
-				 type : 'POST',
-				 url : uuu,
-				 dataType: 'json',
-				 contentType: 'application/json',
-				 data: JSON.stringify(postData),
-				 success : function(data){
-					 $scope.$apply(function(){
-						 $scope.optimizationModelsDictionaryVersionDatas = data[0].optimizationModelVersionData;
-					 });
-				 },
-				 error : function(data){
-					 alert("Error While Retrieving the Template Layout Pattern.");
-				 }
-			 });		 
-		 }
-	 };
+    if ($scope.temp.policy.editPolicy != undefined|| $scope.temp.policy.readOnly  != undefined){
+    if ($scope.temp.policy.configName == undefined){
+    $scope.isCheck = false;
+    }else{
+        $scope.isCheck = true;
+    }
+    }else {
+        $scope.isCheck = false;
+    }
     
-	var splitEqual = '=';
-	var splitComma = ',';
-	var splitcolon = ':';
-	var splitEnum = "],";
-	var plainAttributeKeys = [];
-	var matching = [];
-	var enumKeyList = [];
-	var dictionaryList = [];
-	var dictionaryNameList = [];
+    PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function (data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    console.log($scope.data);
+    $scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);
+    console.log($scope.onapNameDictionaryDatas);
+    }, function (error) {
+    console.log("failed");
+    });
+
+    PolicyAppService.getData('get_DCAEPriorityValues').then(function (data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    console.log($scope.data);
+    $scope.priorityDatas = JSON.parse($scope.data.priorityDatas);
+    console.log($scope.priorityDatas);
+    }, function (error) {
+    console.log("failed");
+    });
+
+    PolicyAppService.getData('getDictionary/get_OptimizationModelsDataByName').then(function (data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    console.log($scope.data);
+    var inputModelList = JSON.parse($scope.data.optimizationModelsDictionaryDatas);
+    var unique = {};
+    var uniqueList = [];
+    for(var i = 0; i < inputModelList.length; i++){
+    if(typeof unique[inputModelList[i]] == "undefined"){
+        unique[inputModelList[i]] = "";
+        uniqueList.push(inputModelList[i]);
+    }
+    }
+    $scope.optimizationModelsDictionaryDatas = uniqueList;
+    console.log($scope.optimizationModelsDictionaryDatas);
+    }, function (error) {
+    console.log("failed");
+    });
+
+    PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    console.log($scope.data);
+    $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
+    console.log($scope.riskTypeDictionaryDatas);
+    }, function (error) {
+    console.log("failed");
+    });
+
+     $scope.choices = [];
+     $scope.attributeDatas = [{"attributes" : $scope.choices}];
+     $scope.isInitEditTemplate = true;  //just initially create the edit template, didn't click add button yet.
+     $scope.addNewChoice = function(value) {
+     console.log("input value : " + value);
+     if(value != undefined){
+    if (value.startsWith('div.')){
+        value = value.replace('div.','');
+    }
+    var parentElement = document.getElementById("div."+value);
+    var div = document.getElementById(value+"@0");
+    if(div != null){
+        var clone = div.cloneNode(true); 
+        var addElement = parentElement.childElementCount;
+        clone.id = ''+value+'@'+addElement;
+        clone.value = '';
+        if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){ //if it's view or edit
+        if($scope.temp.policy.ruleData[clone.id] || ($scope.temp.policy.editPolicy && !$scope.isInitEditTemplate)){  // Only append child if its value found in ruleData or edit mode
+            if($scope.temp.policy.ruleData[clone.id]){
+                clone.value = $scope.temp.policy.ruleData[clone.id];
+            }
+            if(!clone.className.includes("child_single")){   
+            clone.className += ' child_single'; //single element clone
+            }
+            document.getElementById("div."+value).appendChild(clone);
+            plainAttributeKeys.push(''+value+'@'+addElement);
+        }
+        }else{ //not view or edit
+        if(!clone.className.includes("child_single")){   
+            clone.className += ' child_single'; //single element clone
+        }
+        document.getElementById("div."+value).appendChild(clone);
+        plainAttributeKeys.push(''+value+'@'+addElement);
+        }
+    }else{
+        div = document.getElementById("div."+value+"@0");
+        
+        if(div){
+        div.className += ' children_group'; //div with a group of children.
+        }        
+        var childElement = parentElement.firstElementChild;
+        var countParent = parentElement.childElementCount;
+        var childElementString = childElement.innerHTML;
+        var find = value+"@0";
+        var re = new RegExp(find, 'g');
+        childElementString = childElementString.replace(re,value+'@' + countParent);
+        var clone = childElement.cloneNode(true);
+        for (var ii = 0; ii < parentElement.childNodes.length; ii++){
+                var childId = parentElement.childNodes[ii].id;
+                if(ii = parentElement.childNodes.length){
+                var childnewId = childId.slice(0, -1);
+                var count = childId.slice(-1);
+                }
+            }
+        var countvalue = parseInt(count) + 1;
+        clone.id = childnewId+countvalue;
+        clone.value = '';
+        clone.innerHTML=childElementString;
+        document.getElementById("div."+value).appendChild(clone);
+        var selects = clone.getElementsByTagName("select");
+        var inputs = clone.getElementsByTagName("input");
+        var removeValues = [];
+        for(var i=0; i<inputs.length; i++){
+        if ($scope.temp.policy.ruleData!=undefined){
+            var checkValue = $scope.temp.policy.ruleData[inputs[i].id];
+            if (checkValue!=undefined && checkValue != "undefined"){
+            if($scope.temp.policy.ruleData != null){
+                var checkValue = $scope.temp.policy.ruleData[inputs[i].id];
+                document.getElementById(inputs[i].id).value = $scope.temp.policy.ruleData[inputs[i].id];
+                plainAttributeKeys.push(inputs[i].id);
+            }
+            } else {
+            plainAttributeKeys.push(inputs[i].id);
+            }
+        }else {
+            plainAttributeKeys.push(inputs[i].id);
+        }
+        }
+        
+        for(var i=0; i<selects.length; i++){
+        if ($scope.temp.policy.ruleData!=undefined){
+            var checkValue = $scope.temp.policy.ruleData[selects[i].id];
+            if (checkValue!=undefined && checkValue!="undefined"){
+            if($scope.temp.policy.ruleData != null){
+                var checkValue = $scope.temp.policy.ruleData[selects[i].id];
+                document.getElementById(selects[i].id).value = $scope.temp.policy.ruleData[selects[i].id];
+                plainAttributeKeys.push(selects[i].id);
+            }
+            } else {
+            plainAttributeKeys.push(selects[i].id);
+            }
+        }else {
+            plainAttributeKeys.push(selects[i].id);
+        }
+        }
+        
+        for (var k=0; k<removeValues.length; k++){
+        var elem = document.getElementById(removeValues[k]);
+        elem.parentNode.removeChild(elem);
+        }
+        var ele = angular.element(document.getElementById("div."+value));
+            $compile(ele.contents())($scope);
+                $scope.$apply();
+    }
+     }
+     };
+     
+     function findVal(object, key) {
+        var value;
+        Object.keys(object).some(function(k) {
+            if (k === key) {
+                value = object[k];
+                return true;
+            }
+            if (object[k] && typeof object[k] === 'object') {
+                value = findVal(object[k], key);
+                return value !== undefined;
+            }
+        });
+        return value;
+    }
+     
+     $scope.removeChoice = function(value) {
+     console.log(value);
+     if(value != undefined){
+     var c = document.getElementById("div."+value).childElementCount;
+     
+     if(c == 1){
+         Notification.error("The original one is not removable.");
+         return;
+     }    
+     document.getElementById("div."+value).removeChild(document.getElementById("div."+value).lastChild);     
+     }
+     };
+     
+     $scope.pullVersion = function(serviceName) {
+     console.log(serviceName);
+     if(serviceName != undefined){
+     var uuu = "policyController/getModelServiceVersionData.htm";
+     var postData={policyData: serviceName};
+     $.ajax({
+         type : 'POST',
+         url : uuu,
+         dataType: 'json',
+         contentType: 'application/json',
+         data: JSON.stringify(postData),
+         success : function(data){
+         $scope.$apply(function(){
+             $scope.optimizationModelsDictionaryVersionDatas = data[0].optimizationModelVersionData;
+         });
+         },
+         error : function(data){
+         Notification.error("Error While Retrieving the Template Layout Pattern.");
+         }
+     });     
+     }
+     };
+    
+    var splitEqual = '=';
+    var splitComma = ',';
+    var splitcolon = ':';
+    var splitEnum = "],";
+    var plainAttributeKeys = [];
+    var matching = [];
+    var enumKeyList = [];
+    var dictionaryList = [];
+    var dictionaryNameList = [];
     $scope.addDataToFields = function(serviceName, version){
         if(serviceName != null && version !=null){
-        	var service=serviceName+"-v"+version;
-        	var myNode = document.getElementById("DynamicTemplate");
-        	myNode.innerHTML = '';
+        var service=serviceName+"-v"+version;
+        var myNode = document.getElementById("DynamicTemplate");
+        myNode.innerHTML = '';
             var uuu = "policyController/getOptimizationTemplateData.htm";
             var postData={policyData: service};
             var dataOrderInfo = "";
@@ -296,458 +298,458 @@
                 data: JSON.stringify(postData),
                 success : function(data){
                     $scope.$apply(function(){
-                    	$scope.optimizationModelData = data[0].optimizationModelData;
-                    	$scope.optimizationJsonDate = data[0].jsonValue;
+                    $scope.optimizationModelData = data[0].optimizationModelData;
+                    $scope.optimizationJsonDate = data[0].jsonValue;
                         $scope.dataOrderInfo = null;
-                    	$scope.dataOrderInfo = data[0].dataOrderInfo;
-                    	console.log("data[0].dataOrderInfo: " + data[0].dataOrderInfo);
-                    	console.log("$scope.dataOrderInfo: " + $scope.dataOrderInfo);	
-                    	if(data[0].allManyTrueKeys){
-	                    	console.log("$scope.allManyTrueKeys: " + $scope.allManyTrueKeys);
-                    	}
-                    	console.log("$scope.optimizationJsonDate: " + $scope.optimizationJsonDate);	
-                    	var attributes = $scope.optimizationModelData.attributes;
-                    	var refAttributes = $scope.optimizationModelData.ref_attributes;
-                    	var subAttributes = 	$scope.optimizationModelData.sub_attributes;   
-                    	console.log("attributes: " +attributes);                    	
-                    	console.log("subAttributes: " + subAttributes);	
-                    	console.log("refAttributes: " + refAttributes);	
-                    	
-                    	var headDefautlsData  = data[0].headDefautlsData;
-                    	if(headDefautlsData != null){
-	               			 $scope.temp.policy.onapName = headDefautlsData.onapName;
-	               			 $scope.temp.policy.guard = headDefautlsData.guard;
-	               			 $scope.temp.policy.riskType = headDefautlsData.riskType;
-	               			 $scope.temp.policy.riskLevel = headDefautlsData.riskLevel;
-	               			 $scope.temp.policy.priority = headDefautlsData.priority;
-	               			 
-                    	}else if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
-	               			 $scope.temp.policy.onapName = "";
-	               			 $scope.temp.policy.guard = "";
-	               			 $scope.temp.policy.riskType = "";
-	               			 $scope.temp.policy.riskLevel = "";
-	               			 $scope.temp.policy.priority = "";
-                    	}
-                    	
-                       	var annotation = $scope.optimizationModelData.annotation;
-                       	var dictionary = $scope.microServiceAttributeDictionaryDatas;
+                    $scope.dataOrderInfo = data[0].dataOrderInfo;
+                    console.log("data[0].dataOrderInfo: " + data[0].dataOrderInfo);
+                    console.log("$scope.dataOrderInfo: " + $scope.dataOrderInfo);    
+                    if(data[0].allManyTrueKeys){
+                        console.log("$scope.allManyTrueKeys: " + $scope.allManyTrueKeys);
+                    }
+                    console.log("$scope.optimizationJsonDate: " + $scope.optimizationJsonDate);    
+                    var attributes = $scope.optimizationModelData.attributes;
+                    var refAttributes = $scope.optimizationModelData.ref_attributes;
+                    var subAttributes =     $scope.optimizationModelData.sub_attributes;   
+                    console.log("attributes: " +attributes);                    
+                    console.log("subAttributes: " + subAttributes);    
+                    console.log("refAttributes: " + refAttributes);    
+                    
+                    var headDefautlsData  = data[0].headDefautlsData;
+                    if(headDefautlsData != null){
+                        $scope.temp.policy.onapName = headDefautlsData.onapName;
+                        $scope.temp.policy.guard = headDefautlsData.guard;
+                        $scope.temp.policy.riskType = headDefautlsData.riskType;
+                        $scope.temp.policy.riskLevel = headDefautlsData.riskLevel;
+                        $scope.temp.policy.priority = headDefautlsData.priority;
+                        
+                    }else if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){
+                        $scope.temp.policy.onapName = "";
+                        $scope.temp.policy.guard = "";
+                        $scope.temp.policy.riskType = "";
+                        $scope.temp.policy.riskLevel = "";
+                        $scope.temp.policy.priority = "";
+                    }
+                    
+                       var annotation = $scope.optimizationModelData.annotation;
+                       var dictionary = $scope.microServiceAttributeDictionaryDatas;
 
-                       	if (annotation == null || annotation.length<1){
-                       		$scope.isCheck = true;
-                       	}else {
-                       		$scope.isCheck = false;
-                       		var annoationList = annotation.split(splitComma);
-                       		for (k = 0; k < annoationList.length; k++){
-                           		var splitAnnotation = annoationList[k].split(splitEqual);
-                           		if (splitAnnotation[1].includes("matching-true")){
-                           			matching.push(splitAnnotation[0].trim());
-                           		}
-                       		}
+                       if (annotation == null || annotation.length<1){
+                           $scope.isCheck = true;
+                       }else {
+                           $scope.isCheck = false;
+                           var annoationList = annotation.split(splitComma);
+                           for (k = 0; k < annoationList.length; k++){
+                               var splitAnnotation = annoationList[k].split(splitEqual);
+                               if (splitAnnotation[1].includes("matching-true")){
+                               matching.push(splitAnnotation[0].trim());
+                               }
+                           }
 
-                       	}
+                       }
 
-                       	if (dictionary!= null && dictionary.length>1){
-                       		for (m=0; m < dictionary.length; m += 1){
-                       			var valueCompare = dictionary[m].value;
-                       			var valueModel = dictionary[m].modelName;
-                       			var conpairService = serviceName;
-                       			if (valueModel.includes('-v')){
-                       				conpairService = service;
-                       			}
-                       			if(valueModel.localeCompare(conpairService) == 0){
-                       				console.log(valueCompare);	
-                       				dictionaryList.push(dictionary[m]);
-                       				if (!dictionaryNameList.includes(dictionary[m].name)){
-                       					dictionaryNameList.push(dictionary[m].name)
-                       				}
-                       			}
-                       		}
-                       	}
+                       if (dictionary!= null && dictionary.length>1){
+                           for (m=0; m < dictionary.length; m += 1){
+                           var valueCompare = dictionary[m].value;
+                           var valueModel = dictionary[m].modelName;
+                           var conpairService = serviceName;
+                           if (valueModel.includes('-v')){
+                               conpairService = service;
+                           }
+                           if(valueModel.localeCompare(conpairService) == 0){
+                               console.log(valueCompare);    
+                               dictionaryList.push(dictionary[m]);
+                               if (!dictionaryNameList.includes(dictionary[m].name)){
+                               dictionaryNameList.push(dictionary[m].name)
+                               }
+                           }
+                           }
+                       }
 
-                		$scope.temp.policy.ruleGridData = [];
-                		
-                		if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){
-                			dataOrderInfo = $scope.dataOrderInfo;
-                		}
-                		
-                		$scope.jsonLayout($scope.optimizationJsonDate);
-                		
+                    $scope.temp.policy.ruleGridData = [];
+                    
+                    if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){
+                    dataOrderInfo = $scope.dataOrderInfo;
+                    }
+                    
+                    $scope.jsonLayout($scope.optimizationJsonDate);
+                    
                     });
                     
                     if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){  // If it's veiw or edit
-                    	
-                    	if($scope.temp.policy.editPolicy){
-                        	$scope.isInitEditTemplate = true;
-                    	}
-                    	
-                    	var checkData = [];
-                    	var data = [];
-                    	    // If ruleData contains extra elements created by clicked add button 
-	                    	if($scope.temp.policy.ruleData != null){
-	                    		var propNames = Object.getOwnPropertyNames($scope.temp.policy.ruleData);
-	                    		propNames.forEach(function(name) {
-	                    			data.push(name);
-	                    		});
-	                    		
-	                    		var extraElements = data;
-	                    		
-	                    		if(plainAttributeKeys != null){
-	            		    		for(b = 0; b < plainAttributeKeys.length; b++){ // Remove already populated elements from data array
-	            		    			var newValue = plainAttributeKeys[b].split("*");
-	            		    			for(a = 0; a < data.length; a++){
-		            		    			if(data[a] === newValue[0] || data[a] === (newValue[0]+"@0")){
-		            		    				extraElements.splice(a, 1);
-		            		    			}
-	            		    			}
-	            		    	
-	            		    		}
-	                    		
-		            		    	//--- Populate these extra elements created by clicked add button 
-			                    	for(a = 0; a < extraElements.length; a++){            			
-			                    		if(extraElements[a].includes("@")){
-					                    	var index = extraElements[a].lastIndexOf("@");
-					                    	if(index > 0){
-					                    	    // Get the number after @
-					                    	    var n = getNumOfDigits(extraElements[a], index+1);
-					                    				
-						                        var key = extraElements[a].substring(0, index+n+1); //include @x in key also by n+2 since x can be 1,12, etc
-						                    	console.log("key: " + key);
-						                    	checkData.push(key);
-					                    	}
-			                    		}
-			                    	}
-		                    		var unique = checkData.filter(onlyUnique);
-		                    		//if no layout order info, keep the process as before
-		                    		if(!dataOrderInfo){
-			                    		for(i =0; i < unique.length; i++){
-			                    			//remove @x and let addNewChoice add @1 or @2...
-			                    			//var newKey = unique[i].substring(0, unique[i].length-2);
-			                    			var index = unique[i].lastIndexOf("@");
-			                    			var newKey = unique[i].substring(0, index);
-			                    			console.log("newKey: " + newKey);	
-			                    			$scope.addNewChoice(newKey);
-			                    		}
-		            		    	}else{
+                    
+                    if($scope.temp.policy.editPolicy){
+                        $scope.isInitEditTemplate = true;
+                    }
+                    
+                    var checkData = [];
+                    var data = [];
+                        // If ruleData contains extra elements created by clicked add button 
+                        if($scope.temp.policy.ruleData != null){
+                            var propNames = Object.getOwnPropertyNames($scope.temp.policy.ruleData);
+                            propNames.forEach(function(name) {
+                            data.push(name);
+                            });
+                            
+                            var extraElements = data;
+                            
+                            if(plainAttributeKeys != null){
+                            for(b = 0; b < plainAttributeKeys.length; b++){ // Remove already populated elements from data array
+                            var newValue = plainAttributeKeys[b].split("*");
+                            for(a = 0; a < data.length; a++){
+                            if(data[a] === newValue[0] || data[a] === (newValue[0]+"@0")){
+                                extraElements.splice(a, 1);
+                            }
+                            }
+                        
+                            }
+                            
+                        //--- Populate these extra elements created by clicked add button 
+                        for(a = 0; a < extraElements.length; a++){                
+                            if(extraElements[a].includes("@")){
+                            var index = extraElements[a].lastIndexOf("@");
+                            if(index > 0){
+                                // Get the number after @
+                                var n = getNumOfDigits(extraElements[a], index+1);
+                                    
+                                    var key = extraElements[a].substring(0, index+n+1); //include @x in key also by n+2 since x can be 1,12, etc
+                                console.log("key: " + key);
+                                checkData.push(key);
+                            }
+                            }
+                        }
+                            var unique = checkData.filter(onlyUnique);
+                            //if no layout order info, keep the process as before
+                            if(!dataOrderInfo){
+                            for(i =0; i < unique.length; i++){
+                            //remove @x and let addNewChoice add @1 or @2...
+                            //var newKey = unique[i].substring(0, unique[i].length-2);
+                            var index = unique[i].lastIndexOf("@");
+                            var newKey = unique[i].substring(0, index);
+                            console.log("newKey: " + newKey);    
+                            $scope.addNewChoice(newKey);
+                            }
+                        }else{
 
-			              	    		for (i = 0; i < $scope.labelManyKeys.length; i++) {
-			              	    			console.log("dataOrderInfo["+i+"]"+  dataOrderInfo[i]);
-			              	    		    var label = $scope.labelManyKeys[i];
-			              	    				// first add parent/label level
-			             	 	    			for (k = 0; k < unique.length; k++){
-					                    			var newKey = unique[k].substring(0, index);
-	 		             	 	    			    if(label == newKey){
+                          for (i = 0; i < $scope.labelManyKeys.length; i++) {
+                          console.log("dataOrderInfo["+i+"]"+  dataOrderInfo[i]);
+                              var label = $scope.labelManyKeys[i];
+                              // first add parent/label level
+                          for (k = 0; k < unique.length; k++){
+                                var newKey = unique[k].substring(0, index);
+                                   if(label == newKey){
                                                         //Check this label has bee created or not
-	 		             	 	    			    	if(!document.getElementById(unique[k])){
-	 		             	 	    			    		$scope.addNewChoice(newKey);
-	 		             	 	    			    	}
-	 		             	 	    			    	unique[k] = "*processed*";
-			             	 	    					break;
-	 		             	 	    			    }
-			             	 	    			}				             	 	    			
-			              	    		}
-			              	    		
-			              	    		//---reset to default
-			              	    		dataOrderInfo = [];
-			              	    		$scope.labelManyKeys = [];
-			              	    		
-	             	 	    			//---process none labels
-				              	    	for (j = 0; j < unique.length; j++){
-				              	    		if(unique[j] != "*processed*"){
-				              	    			// if not created yet
-				              	    			if(!document.getElementById(unique[j])){
-					                    			var index = unique[j].lastIndexOf("@");
-					                    			var newKey = unique[j].substring(0, index);
-		 		             	 	    		    $scope.addNewChoice(newKey);
-				              	    			}
-				              	    		}
-				              	    	}
-		              	    		}
-	            		    }
-	                    }
-	                    
-                    	if($scope.temp.policy.editPolicy){
-                    		//clean all the events of addNewChoice
-                    		$scope.$on('$destroy', addNewChoice);
-                    	}
-	                    
+                                   if(!document.getElementById(unique[k])){
+                                       $scope.addNewChoice(newKey);
+                                   }
+                                   unique[k] = "*processed*";
+                              break;
+                                   }
+                          }                              
+                          }
+                          
+                          //---reset to default
+                          dataOrderInfo = [];
+                          $scope.labelManyKeys = [];
+                          
+                          //---process none labels
+                          for (j = 0; j < unique.length; j++){
+                              if(unique[j] != "*processed*"){
+                              // if not created yet
+                              if(!document.getElementById(unique[j])){
+                                var index = unique[j].lastIndexOf("@");
+                                var newKey = unique[j].substring(0, index);
+                                   $scope.addNewChoice(newKey);
+                              }
+                              }
+                          }
+                          }
+                        }
+                        }
+                        
+                    if($scope.temp.policy.editPolicy){
+                        //clean all the events of addNewChoice
+                        $scope.$on('$destroy', addNewChoice);
+                    }
+                        
                     }
                     var ele = angular.element(document.getElementById("DynamicTemplate"));
-            		$compile(ele.contents())($scope);
+                $compile(ele.contents())($scope);
                     $scope.$apply();
                 },
                 error : function(data){
-                    alert("Error While Retrieving the Template Layout Pattern.");
+                Notification.error("Error While Retrieving the Template Layout Pattern.");
                 }
             });
         }
     };
     
     function getNumOfDigits(str_value, index){
-		// Get the number after @
-		var str = str_value.substring(index, str_value.length);	
-		var c = '';
-		var n = 0;
-		for (var x = 0; x < str.length; x++){			                    				
-		    c = str.charAt(x);
-			    if(!isNaN(c)){ 
+    // Get the number after @
+    var str = str_value.substring(index, str_value.length);    
+    var c = '';
+    var n = 0;
+    for (var x = 0; x < str.length; x++){                                
+        c = str.charAt(x);
+        if(!isNaN(c)){ 
                 n++;                                                     
-		    }else{
+        }else{
                 break;
             }
-		}
-		return n;
+    }
+    return n;
     }
     
     function getDictionary(attribute){
-    	var dicName = attribute;
-    	if(attribute){
-    	   if(attribute.includes(":")){
-    		   dicName = attribute.split(":")[0];
-    	   }
-    	}
-	    var dictionaryRegExp = new RegExp(dicName);
-	    listemunerateValues = [];
-	    if (dictionaryRegExp.test(dictionaryNameList)) {
-			for (p=0; p < dictionaryList.length; p += 1) {
-				if (dicName == dictionaryList[p].name) {
-					listemunerateValues.push(dictionaryList[p].value);
-				}
-			}
-	    }
-	    return listemunerateValues;
+    var dicName = attribute;
+    if(attribute){
+       if(attribute.includes(":")){
+           dicName = attribute.split(":")[0];
+       }
+    }
+        var dictionaryRegExp = new RegExp(dicName);
+        listemunerateValues = [];
+        if (dictionaryRegExp.test(dictionaryNameList)) {
+    for (p=0; p < dictionaryList.length; p += 1) {
+        if (dicName == dictionaryList[p].name) {
+        listemunerateValues.push(dictionaryList[p].value);
+        }
+    }
+        }
+        return listemunerateValues;
     }
     
     function getList(attribute) {
-    	var enumName = attribute;
-    	console.log("In getList: attribute => " + attribute);
-    	if(attribute){
-    	   if(attribute.includes(":")){
-    		   enumName = attribute.split(":")[0];
-    	   }
-    	}   
+    var enumName = attribute;
+    console.log("In getList: attribute => " + attribute);
+    if(attribute){
+       if(attribute.includes(":")){
+           enumName = attribute.split(":")[0];
+       }
+    }   
         var baseEnum = $scope.optimizationModelData.enumValues;
         var enumList = [];
         if(baseEnum != null){
-        	enumList = baseEnum.split(splitEnum);
+        enumList = baseEnum.split(splitEnum);
         }
-    	var enumAttributes;
-    	var patternTest = new RegExp(enumName);
-    	for (k=0; k < enumList.length; k += 1){
-    		if(patternTest.test(enumList[k]) == true){
-    			enumAttributes = enumList[k].trim();
-    		}
-    	}
+    var enumAttributes;
+    var patternTest = new RegExp(enumName);
+    for (k=0; k < enumList.length; k += 1){
+        if(patternTest.test(enumList[k]) == true){
+        enumAttributes = enumList[k].trim();
+        }
+    }
 
-    	if(enumAttributes){
-	        enumAttributes = enumAttributes.replace("[", "");
-	       	enumAttributes = enumAttributes.replace("]", "");
-	       	enumAttributes = enumAttributes.replace(/ /g, '');
-			var dropListAfterCommaSplit = enumAttributes.split(splitEqual);
-			listemunerateValues  = dropListAfterCommaSplit[1].split(splitComma);
-	        return listemunerateValues;
-	     }
+    if(enumAttributes){
+            enumAttributes = enumAttributes.replace("[", "");
+           enumAttributes = enumAttributes.replace("]", "");
+           enumAttributes = enumAttributes.replace(/ /g, '');
+    var dropListAfterCommaSplit = enumAttributes.split(splitEqual);
+    listemunerateValues  = dropListAfterCommaSplit[1].split(splitComma);
+            return listemunerateValues;
+         }
            
          return [];
     }
-	    
+        
     function getBooleanList(){
-    	var booleanList = [];
-    	booleanList.push(true);
-    	booleanList.push(false);
-    	return booleanList;
+    var booleanList = [];
+    booleanList.push(true);
+    booleanList.push(false);
+    return booleanList;
     }
 
     function isArray(arrayTest) {
         return Object.prototype.toString.call(arrayTest) === '[object Array]';
     }
-	    
-	var lableList = [];
-	
+        
+    var lableList = [];
+    
     $scope.layOutElementList = [];
     $scope.layOutOnlyLableList = [];
     
     var elementOrderNum = 0;
-	    
-	function deconstructJSON(layOutData, level , name) {
+        
+    function deconstructJSON(layOutData, level , name) {
 
-		 var array = false;
-		 var label = level;
-		 var stringValue = "java.lang.String";
-		 var string = "string";
-		 var intValue = "int";
-		 var integerValue = "integer";
-		 var double = "double";
-		 var boolean = "boolean";
-		 var baseLevel = level;
-		 var list = "list";
-		 var String = "String";
-		 
-		 var attributekey = "";
-		 
-		if (name.length > 1){
-			label = label + name + '.';
-		}
-		
-	    for (key in layOutData) {
-	    	array = isArray(layOutData[key]);
-	    	console.log("key: " + key , "value: " + layOutData[key]);
-   	
-	    	if (!!layOutData[key] && typeof(layOutData[key])=="object") {
-	    		
-	    		if (array==false && key!=="0"){
-	    			
-	    			if($scope.dataOrderInfo){
-	    			    var labelObject = {"label" : key, "level" : label, "array" : array};
-	    			    //save it to the list
-	    			    $scope.layOutOnlyLableList.push(labelObject);
-	    			    
-	    			}else {
-	    				//call label layout
-	    				$scope.labelLayout(label, key, array );
-	    			}
-	    			
-	    		}
-	    		
-	    		if (array == true && key!=0){
-	    			lableList.push(key);
-	    		}
-	    		
-	    		if (lableList.length > 0){
-	    			array = true;
-	    		}
-	    		if ( key==="0"){
-	    			var newKey = lableList.pop();
-	    			
-	    			if($scope.dataOrderInfo){
-	    				
-		    			var labelObject = {"label" : newKey, "level" : baseLevel, "array" : array};
-		    			//save it to the list
-		    			$scope.layOutOnlyLableList.push(labelObject);
-		    			
-	    			}else {
-	    				//call label layout 
-	    			    $scope.labelLayout(baseLevel, newKey, array );
-	    			}
-	    			
-	    			if (array){
-	    				label = baseLevel + newKey + '@0.';
-	    			} else {
-	    				label = baseLevel + newKey + '.';
-	    			}
-	    		}
-	        	deconstructJSON(layOutData[key] , label, key);
-	        } else {
-	        	var attirbuteLabel = label;
-	        	var defaultValue='';
-	        	var isRequired = false;
-	        	if (layOutData[key].includes('defaultValue-')){
-	        		defaultValue = layOutData[key].split('defaultValue-')[1];
-	        	}
+     var array = false;
+     var label = level;
+     var stringValue = "java.lang.String";
+     var string = "string";
+     var intValue = "int";
+     var integerValue = "integer";
+     var double = "double";
+     var boolean = "boolean";
+     var baseLevel = level;
+     var list = "list";
+     var String = "String";
+     
+     var attributekey = "";
+     
+    if (name.length > 1){
+    label = label + name + '.';
+    }
+    
+        for (key in layOutData) {
+        array = isArray(layOutData[key]);
+        console.log("key: " + key , "value: " + layOutData[key]);
+       
+        if (!!layOutData[key] && typeof(layOutData[key])=="object") {
+            
+            if (array==false && key!=="0"){
+            
+            if($scope.dataOrderInfo){
+                var labelObject = {"label" : key, "level" : label, "array" : array};
+                //save it to the list
+                $scope.layOutOnlyLableList.push(labelObject);
+                
+            }else {
+                //call label layout
+                $scope.labelLayout(label, key, array );
+            }
+            
+            }
+            
+            if (array == true && key!=0){
+            lableList.push(key);
+            }
+            
+            if (lableList.length > 0){
+            array = true;
+            }
+            if ( key==="0"){
+            var newKey = lableList.pop();
+            
+            if($scope.dataOrderInfo){
+                
+            var labelObject = {"label" : newKey, "level" : baseLevel, "array" : array};
+            //save it to the list
+            $scope.layOutOnlyLableList.push(labelObject);
+            
+            }else {
+                //call label layout 
+                $scope.labelLayout(baseLevel, newKey, array );
+            }
+            
+            if (array){
+                label = baseLevel + newKey + '@0.';
+            } else {
+                label = baseLevel + newKey + '.';
+            }
+            }
+            deconstructJSON(layOutData[key] , label, key);
+            } else {
+            var attirbuteLabel = label;
+            var defaultValue='';
+            var isRequired = false;
+            if (layOutData[key].includes('defaultValue-')){
+                defaultValue = layOutData[key].split('defaultValue-')[1];
+            }
 
-	        	if (key==="0"){
-	        		array = true;
-	        		attributekey = lableList.pop();
-	        		attirbuteLabel = baseLevel;
-	        	} else {
-	        		attributekey = key.split();
-	        	}
-	        	
-	        	if (layOutData[key].includes('required-true')){
-	        		isRequired = true;
-	        	}
-	    		
-	    		var subAttributes = $scope.optimizationModelData.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')){
-	    				        		isRequired = true;
-	    				        	}	
-	    						}
-	    					}
-	    				}		    				
-	    			}		    			
-	    		}
-	    		
-	    		var elementObject = {};
-	        	switch (layOutData[key].split(splitcolon)[0]){
-	        	
-	        		case stringValue:
-	        		case string:
-	        			if($scope.dataOrderInfo){		        				
-			        		elementOrderNum++;
-			        		elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue, "isRequired": isRequired, "type":"text"};
-			        		$scope.layOutElementList.push(elementObject);
-	        			}else{
-	        				$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "text");
-	        			}
-	        			break;		        			
-	        		case intValue: 
-	        		case integerValue: 
-	        			if($scope.dataOrderInfo){
-		        			elementOrderNum++;
-			        		elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"number"};
-			        		$scope.layOutElementList.push(elementObject);
-	        			}else{
-	        				$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "number");
-	        			}
-	        			break;		        			
-	        		case double:
-	        			if($scope.dataOrderInfo){
-		        			elementOrderNum++;
-			        		elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"double"};
-			        		$scope.layOutElementList.push(elementObject);		        				
-	        			}else{
-	        				$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "double");
-	        			}
-	        			break;
-	        		case boolean:
-	        			if($scope.dataOrderInfo){
-		        			elementOrderNum++;
-			        		elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": layOutData[key], "list": getBooleanList, "isRequired": isRequired, "type":"dropBox"};
-			        		$scope.layOutElementList.push(elementObject);
-	        			}else{
-	        				$scope.dropBoxLayout(attirbuteLabel, attributekey, array, layOutData[key], getBooleanList());
-	        			}
-	        			break;
-	        		default:
-	        			if (layOutData[key].includes('dictionary-')){
-	        				var list = getDictionary(layOutData[key].split('dictionary-')[1]);
-	        			}else{
-	        				//--- get dropdown values from enumValues
-	        				var list = getList(layOutData[key]);
-	        			}
-	        			if (list.length===0){ //not dropdown element
-	        				if($scope.dataOrderInfo){
-	        					elementOrderNum++;
-				        		elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"text"};
-				        		$scope.layOutElementList.push(elementObject);
-	        					
-	        				}else{
-	        					$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "text");
-	        				}		        				
-	        			}else{
-	        				if($scope.dataOrderInfo){
-		        				elementOrderNum++;
-				        		elementObject = {"id": elementOrderNum, "attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": layOutData[key],"isRequired": isRequired, "list":list, "type":"dropBox"};
-				        		$scope.layOutElementList.push(elementObject);		        					
-	        				}else{
-	        					$scope.dropBoxLayout(attirbuteLabel, attributekey, array, layOutData[key], list, isRequired);
-	        				}
-	        			}
-	        			break;
-	        	}
-	        }
-	    }
-	}  
+            if (key==="0"){
+                array = true;
+                attributekey = lableList.pop();
+                attirbuteLabel = baseLevel;
+            } else {
+                attributekey = key.split();
+            }
+            
+            if (layOutData[key].includes('required-true')){
+                isRequired = true;
+            }
+            
+            var subAttributes = $scope.optimizationModelData.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')){
+                            isRequired = true;
+                        }    
+                    }
+                }
+                }                
+            }            
+            }
+            
+            var elementObject = {};
+            switch (layOutData[key].split(splitcolon)[0]){
+            
+                case stringValue:
+                case string:
+                if($scope.dataOrderInfo){                    
+                elementOrderNum++;
+                elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue, "isRequired": isRequired, "type":"text"};
+                $scope.layOutElementList.push(elementObject);
+                }else{
+                    $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "text");
+                }
+                break;                
+                case intValue: 
+                case integerValue: 
+                if($scope.dataOrderInfo){
+                elementOrderNum++;
+                elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"number"};
+                $scope.layOutElementList.push(elementObject);
+                }else{
+                    $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "number");
+                }
+                break;                
+                case double:
+                if($scope.dataOrderInfo){
+                elementOrderNum++;
+                elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"double"};
+                $scope.layOutElementList.push(elementObject);                    
+                }else{
+                    $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "double");
+                }
+                break;
+                case boolean:
+                if($scope.dataOrderInfo){
+                elementOrderNum++;
+                elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": layOutData[key], "list": getBooleanList, "isRequired": isRequired, "type":"dropBox"};
+                $scope.layOutElementList.push(elementObject);
+                }else{
+                    $scope.dropBoxLayout(attirbuteLabel, attributekey, array, layOutData[key], getBooleanList());
+                }
+                break;
+                default:
+                if (layOutData[key].includes('dictionary-')){
+                    var list = getDictionary(layOutData[key].split('dictionary-')[1]);
+                }else{
+                    //--- get dropdown values from enumValues
+                    var list = getList(layOutData[key]);
+                }
+                if (list.length===0){ //not dropdown element
+                    if($scope.dataOrderInfo){
+                    elementOrderNum++;
+                    elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"text"};
+                    $scope.layOutElementList.push(elementObject);
+                    
+                    }else{
+                    $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "text");
+                    }                    
+                }else{
+                    if($scope.dataOrderInfo){
+                    elementOrderNum++;
+                    elementObject = {"id": elementOrderNum, "attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": layOutData[key],"isRequired": isRequired, "list":list, "type":"dropBox"};
+                    $scope.layOutElementList.push(elementObject);                    
+                    }else{
+                    $scope.dropBoxLayout(attirbuteLabel, attributekey, array, layOutData[key], list, isRequired);
+                    }
+                }
+                break;
+            }
+            }
+        }
+    }  
 
     $scope.validContionalRequired = function(parentId) {
         console.log("ng-blur event: parentId : " + parentId);
@@ -755,504 +757,504 @@
         var i;
         var hasValue = false;
         for (i = 0; i < c.length; i++) {
-        	if(c[i].getAttribute("data-conditional")){
-        	    console.log(c[i].getAttribute("data-conditional"));
-        	    console.log(c[i].value);
-        	    if(c[i].value != null && c[i].value.trim() != ""){
-        	    	hasValue = true;
-        	    }
-        	}
+        if(c[i].getAttribute("data-conditional")){
+            console.log(c[i].getAttribute("data-conditional"));
+            console.log(c[i].value);
+            if(c[i].value != null && c[i].value.trim() != ""){
+            hasValue = true;
+            }
+        }
         }
 
-	    for (i = 0; i < c.length; i++) {
-	        if(c[i].getAttribute("data-conditional")){
-	        	if(hasValue){
-	        	    c[i].setAttribute("required", true);
-	        	}else{
-	        		c[i].removeAttribute("required");
-	        	}
-	        }
-	    }        	
+        for (i = 0; i < c.length; i++) {
+            if(c[i].getAttribute("data-conditional")){
+            if(hasValue){
+                c[i].setAttribute("required", true);
+            }else{
+                c[i].removeAttribute("required");
+            }
+            }
+        }        
      }
-			
+    
     $scope.jsonLayout = function(layOutData){
-    	
+    
        deconstructJSON(layOutData , "", "");
-	    	   
-	   var orderValue = $scope.dataOrderInfo;
-	   var layOutElementList = $scope.layOutElementList;
-	   var labelList = $scope.layOutOnlyLableList;
-	    
-	   //reset to default
-	   elementOrderNum = 0;
-	   $scope.layOutElementList = [];
-	   $scope.layOutOnlyLableList = [];
-	   
-	   // Only layout in order if order info provided
-	   if(orderValue){
-		   
-		   if(orderValue.includes("[")){
-			  orderValue = orderValue.replace("[", "") ;
-			  orderValue = orderValue.replace("]", "") ;
-		   }
-		   
-		   orderValue = orderValue.split(',') ;
-		   
-		   for (i = 0; i < orderValue.length; i++) {
-			   console.log("orderValue["+i+"]"+  orderValue[i]);
-			   var key = orderValue[i].trim();
-			 
-			    //--- Create labels first {"label" : newKey, "level" : baseLevel, "array" : array};
-			   if(labelList){
-				   for (k = 0; k < labelList.length; k++){
-					   
-					  var label = labelList[k].label.toString().trim();
-					  var level = labelList[k].level.toString().trim();
-					  var array = labelList[k].array;
-					  
-					  if(key == label){	 	    					  
-						 $scope.labelLayout(level, label, array);
-	 	  	    		 //in case to have duplicate label names
-						 labelList[k].label = "*processed*";
-						 break;
-					  }
-				   }
-			   }
-			   //--- then layout each element based on its order defined in YAML file
-	    	   for (j = 0; j < layOutElementList.length; j++) { 
-	    		   
-	    		   var attributekey = layOutElementList[j].attributekey.toString().trim();	 	  	    		   
-	    		
-	    		   if(key == attributekey){ 	
-	
-	  	    		   var attirbuteLabel = layOutElementList[j].attirbuteLabel.toString().trim();
-	  	    		   var defaultValue = layOutElementList[j].defaultValue.toString().trim();
-	  	    		   var isRequired = layOutElementList[j].isRequired;
-	  	    		   
-	  	    		   console.log("layOutElementList[" +j+ "]: id:" + layOutElementList[j].id + ", attributekey:"+ layOutElementList[j].attributekey + ", attirbuteLabel:" + layOutElementList[j].attirbuteLabel);
-	        		  
-	  	    		   if (layOutElementList[j].type == "dropBox"){ 
-	        				$scope.dropBoxLayout(attirbuteLabel, attributekey, layOutElementList[j].array, defaultValue, layOutElementList[j].list, isRequired);
-	                        
-	        		   }else{
-	        			    $scope.attributeBox(attributekey, layOutElementList[j].array, attirbuteLabel, defaultValue, isRequired, layOutElementList[j].type);	
-	
-	        		   }
-	  	    		   
-	  	    		   //in case to have duplicate attribute names
-	  	    		   layOutElementList[j].attributekey = "*processed*";
-	        		   break;
-	    		   }
-	    	   
-	    	   }
-		   
-		   }
-	   }
+           
+       var orderValue = $scope.dataOrderInfo;
+       var layOutElementList = $scope.layOutElementList;
+       var labelList = $scope.layOutOnlyLableList;
+        
+       //reset to default
+       elementOrderNum = 0;
+       $scope.layOutElementList = [];
+       $scope.layOutOnlyLableList = [];
+       
+       // Only layout in order if order info provided
+       if(orderValue){
+       
+       if(orderValue.includes("[")){
+      orderValue = orderValue.replace("[", "") ;
+      orderValue = orderValue.replace("]", "") ;
+       }
+       
+       orderValue = orderValue.split(',') ;
+       
+       for (i = 0; i < orderValue.length; i++) {
+       console.log("orderValue["+i+"]"+  orderValue[i]);
+       var key = orderValue[i].trim();
+     
+        //--- Create labels first {"label" : newKey, "level" : baseLevel, "array" : array};
+       if(labelList){
+           for (k = 0; k < labelList.length; k++){
+           
+          var label = labelList[k].label.toString().trim();
+          var level = labelList[k].level.toString().trim();
+          var array = labelList[k].array;
+          
+          if(key == label){                       
+             $scope.labelLayout(level, label, array);
+                        //in case to have duplicate label names
+             labelList[k].label = "*processed*";
+             break;
+          }
+           }
+       }
+       //--- then layout each element based on its order defined in YAML file
+           for (j = 0; j < layOutElementList.length; j++) { 
+               
+               var attributekey = layOutElementList[j].attributekey.toString().trim();                          
+            
+               if(key == attributekey){     
+    
+                     var attirbuteLabel = layOutElementList[j].attirbuteLabel.toString().trim();
+                     var defaultValue = layOutElementList[j].defaultValue.toString().trim();
+                     var isRequired = layOutElementList[j].isRequired;
+                     
+                     console.log("layOutElementList[" +j+ "]: id:" + layOutElementList[j].id + ", attributekey:"+ layOutElementList[j].attributekey + ", attirbuteLabel:" + layOutElementList[j].attirbuteLabel);
+                  
+                     if (layOutElementList[j].type == "dropBox"){ 
+                    $scope.dropBoxLayout(attirbuteLabel, attributekey, layOutElementList[j].array, defaultValue, layOutElementList[j].list, isRequired);
+                            
+                   }else{
+                    $scope.attributeBox(attributekey, layOutElementList[j].array, attirbuteLabel, defaultValue, isRequired, layOutElementList[j].type);    
+    
+                   }
+                     
+                     //in case to have duplicate attribute names
+                     layOutElementList[j].attributekey = "*processed*";
+                   break;
+               }
+           
+           }
+       
+       }
+       }
     }
     
     
     $scope.attributeBox = function(attibuteKey, attributeManyKey, labelValue, defaultValue, isRequired, dataType ){
-		$scope.temp.policy.ruleGridData.push(attibuteKey);			
-		var br = document.createElement("BR");
-	
-		var label = document.createElement("Label");
-		var labeltext = null;
-		var requiredLabName = "";
-		if (matching.includes(attibuteKey)){
-			labeltext = document.createTextNode(attibuteKey + "*!");	
-			isRequired = true;  //set required as true for matching element
-		}else {
-			if(isRequired){
-				requiredLabName = attibuteKey + " * ";
-				labeltext = document.createTextNode(requiredLabName);
-			}else{
-			    labeltext = document.createTextNode(attibuteKey);	
-			}
-		}
+    $scope.temp.policy.ruleGridData.push(attibuteKey);    
+    var br = document.createElement("BR");
+    
+    var label = document.createElement("Label");
+    var labeltext = null;
+    var requiredLabName = "";
+    if (matching.includes(attibuteKey)){
+    labeltext = document.createTextNode(attibuteKey + "*!");    
+    isRequired = true;  //set required as true for matching element
+    }else {
+    if(isRequired){
+        requiredLabName = attibuteKey + " * ";
+        labeltext = document.createTextNode(requiredLabName);
+    }else{
+        labeltext = document.createTextNode(attibuteKey);    
+    }
+    }
 
-	
-		var divID = labelValue;
-		
-		if (labelValue.length  < 1){
-			divID = "DynamicTemplate";
-		}else if (labelValue.endsWith('.')){
-			var divID = 'div.'+ labelValue.substring(0, labelValue.length-1);
-		}
-		
-		label.appendChild(labeltext);
-		
-		var textField = document.createElement("INPUT");
-		
-		textField.setAttribute("class" , "form-control");
-		if(dataType){
-			   if(dataType == "double"){
-				   textField.setAttribute("type" , "number");
-				   textField.setAttribute("step" , "any");
-			   }else{
-			      textField.setAttribute("type" , dataType);
-			   }
-		}
-		textField.setAttribute("style" , "width:300px;");
-		textField.setAttribute("ng-disabled" , "temp.policy.readOnly");
-		var checkKey;
-		var id = "";
-		if(attributeManyKey){
-			checkKey = labelValue + attibuteKey+'@0';
-			textField.setAttribute("id" , ''+labelValue + attibuteKey+'@0'+''); 
-			var divTag = document.createElement("div");
-			divTag.setAttribute("id", "div."+ labelValue +attibuteKey);
-			var addButton = document.createElement("BUTTON");
-			var buttonaddLabel = document.createTextNode("+");       
-			addButton.appendChild(buttonaddLabel); 
-			addButton.setAttribute("id", labelValue + attibuteKey);
-			addButton.setAttribute("class", "btn btn-add-remove");
-			addButton.setAttribute("ng-click" ,  'addNewChoice("'+labelValue + attibuteKey+'");');
-			addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
-			var removeButton = document.createElement("BUTTON");
-			var buttonremoveLabel = document.createTextNode("-");       
-			removeButton.appendChild(buttonremoveLabel); 
-			removeButton.setAttribute("class", "btn btn-add-remove");
-			removeButton.setAttribute("ng-click" ,  'removeChoice("'+labelValue + attibuteKey+'");');
-			removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
-			document.getElementById(divID).appendChild(addButton); 
-			document.getElementById(divID).appendChild(removeButton); 
-			document.getElementById(divID).appendChild(label); 
-			id = "div."+labelValue+attibuteKey;
-			divTag.setAttribute("id", id); 
-			document.getElementById(divID).appendChild(divTag);
-			textField.className += ' first_child';	
-			if(isRequired){
-				textField.setAttribute("required", "true");
-			}			
-			divTag.appendChild(textField); 			
-			document.getElementById(divID).appendChild(divTag); 
-			
-		}else{
-			checkKey = labelValue + attibuteKey;
-			textField.setAttribute("id" , ''+labelValue +attibuteKey+'');
-			if(document.getElementById(divID).hasAttribute('required') || !document.getElementById(divID).hasAttribute('data-conditional')){
-				if(requiredLabName.includes("*") || isRequired){
-					textField.setAttribute("required", "true");
-				}
-			}else if (document.getElementById(divID).hasAttribute('data-conditional')){
-				if(requiredLabName.includes("*")){					
-					var requiredNode = document.createElement('span');
-					requiredNode.setAttribute("class", "mstooltip");
-					requiredNode.textContent = "?";
-					label.appendChild(requiredNode);
-					
-					var requiredNodeToolTip = document.createElement('span');
-					requiredNodeToolTip.setAttribute("class", "tooltiptext");
-					requiredNodeToolTip.textContent = "Conditional Required";
-					requiredNode.appendChild(requiredNodeToolTip);
-					
-					textField.setAttribute("data-conditional", divID);
-					textField.setAttribute("ng-blur", "validContionalRequired('"+divID+"')");
-				}
-			}
-	        
-			document.getElementById(divID).appendChild(label);  
-			document.getElementById(divID).appendChild(textField);  
-			document.getElementById(divID).appendChild(br); 
-	
-		}
+    
+    var divID = labelValue;
+    
+    if (labelValue.length  < 1){
+    divID = "DynamicTemplate";
+    }else if (labelValue.endsWith('.')){
+    var divID = 'div.'+ labelValue.substring(0, labelValue.length-1);
+    }
+    
+    label.appendChild(labeltext);
+    
+    var textField = document.createElement("INPUT");
+    
+    textField.setAttribute("class" , "form-control");
+    if(dataType){
+       if(dataType == "double"){
+           textField.setAttribute("type" , "number");
+           textField.setAttribute("step" , "any");
+       }else{
+          textField.setAttribute("type" , dataType);
+       }
+    }
+    textField.setAttribute("style" , "width:300px;");
+    textField.setAttribute("ng-disabled" , "temp.policy.readOnly");
+    var checkKey;
+    var id = "";
+    if(attributeManyKey){
+    checkKey = labelValue + attibuteKey+'@0';
+    textField.setAttribute("id" , ''+labelValue + attibuteKey+'@0'+''); 
+    var divTag = document.createElement("div");
+    divTag.setAttribute("id", "div."+ labelValue +attibuteKey);
+    var addButton = document.createElement("BUTTON");
+    var buttonaddLabel = document.createTextNode("+");       
+    addButton.appendChild(buttonaddLabel); 
+    addButton.setAttribute("id", labelValue + attibuteKey);
+    addButton.setAttribute("class", "btn btn-add-remove");
+    addButton.setAttribute("ng-click" ,  'addNewChoice("'+labelValue + attibuteKey+'");');
+    addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+    var removeButton = document.createElement("BUTTON");
+    var buttonremoveLabel = document.createTextNode("-");       
+    removeButton.appendChild(buttonremoveLabel); 
+    removeButton.setAttribute("class", "btn btn-add-remove");
+    removeButton.setAttribute("ng-click" ,  'removeChoice("'+labelValue + attibuteKey+'");');
+    removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+    document.getElementById(divID).appendChild(addButton); 
+    document.getElementById(divID).appendChild(removeButton); 
+    document.getElementById(divID).appendChild(label); 
+    id = "div."+labelValue+attibuteKey;
+    divTag.setAttribute("id", id); 
+    document.getElementById(divID).appendChild(divTag);
+    textField.className += ' first_child';    
+    if(isRequired){
+        textField.setAttribute("required", "true");
+    }    
+    divTag.appendChild(textField);     
+    document.getElementById(divID).appendChild(divTag); 
+    
+    }else{
+    checkKey = labelValue + attibuteKey;
+    textField.setAttribute("id" , ''+labelValue +attibuteKey+'');
+    if(document.getElementById(divID).hasAttribute('required') || !document.getElementById(divID).hasAttribute('data-conditional')){
+        if(requiredLabName.includes("*") || isRequired){
+        textField.setAttribute("required", "true");
+        }
+    }else if (document.getElementById(divID).hasAttribute('data-conditional')){
+        if(requiredLabName.includes("*")){        
+        var requiredNode = document.createElement('span');
+        requiredNode.setAttribute("class", "mstooltip");
+        requiredNode.textContent = "?";
+        label.appendChild(requiredNode);
+        
+        var requiredNodeToolTip = document.createElement('span');
+        requiredNodeToolTip.setAttribute("class", "tooltiptext");
+        requiredNodeToolTip.textContent = "Conditional Required";
+        requiredNode.appendChild(requiredNodeToolTip);
+        
+        textField.setAttribute("data-conditional", divID);
+        textField.setAttribute("ng-blur", "validContionalRequired('"+divID+"')");
+        }
+    }
+            
+    document.getElementById(divID).appendChild(label);  
+    document.getElementById(divID).appendChild(textField);  
+    document.getElementById(divID).appendChild(br); 
+    
+    }
 
-		if(divID.includes("@0") && divID.includes("div.")){
-			var firstChild_Id = divID.split("@0")[0];
-			var firstChild_element = document.getElementById(firstChild_Id);
-			if(firstChild_element){
-				firstChild_element.className += ' children_group';  //here is a div with a group of children.
-			}
-		}
-		console.log('firstChild_Id: ' + firstChild_Id);
-		console.log('divID: ' + divID);
-		
-		if (defaultValue.length > 0){	
-			if(defaultValue.includes(":")){
-				defaultValue = defaultValue.split(":")[0];
-				if(defaultValue === "NA") {
-					defaultValue = "";
-				}				
-			}
-			if(defaultValue != "undefined" && defaultValue != undefined && defaultValue != "null"){
-		    	document.getElementById(checkKey).value = defaultValue;
-			}
-		}
-		
-		if($scope.temp.policy.ruleData != null){
-			if (attributeManyKey){
-				var newCheckKey = checkKey.replace(attibuteKey + '@0',attibuteKey);
-				if($scope.temp.policy.ruleData[newCheckKey +'@0'] != undefined && $scope.temp.policy.ruleData[newCheckKey +'@0'] != "undefined"){
-			  	    document.getElementById(newCheckKey +'@0').value = $scope.temp.policy.ruleData[newCheckKey +'@0'];
-				}
-			}else{
-				if($scope.temp.policy.ruleData[checkKey] != undefined && $scope.temp.policy.ruleData[checkKey] != "undefined"){
-				    document.getElementById(checkKey).value = $scope.temp.policy.ruleData[checkKey];
-				}
-			}
-		} 
-		plainAttributeKeys.push(labelValue + attibuteKey+'*'+attributeManyKey);	
+    if(divID.includes("@0") && divID.includes("div.")){
+    var firstChild_Id = divID.split("@0")[0];
+    var firstChild_element = document.getElementById(firstChild_Id);
+    if(firstChild_element){
+        firstChild_element.className += ' children_group';  //here is a div with a group of children.
+    }
+    }
+    console.log('firstChild_Id: ' + firstChild_Id);
+    console.log('divID: ' + divID);
+    
+    if (defaultValue.length > 0){    
+    if(defaultValue.includes(":")){
+        defaultValue = defaultValue.split(":")[0];
+        if(defaultValue === "NA") {
+        defaultValue = "";
+        }        
+    }
+    if(defaultValue != "undefined" && defaultValue != undefined && defaultValue != "null"){
+        document.getElementById(checkKey).value = defaultValue;
+    }
+    }
+    
+    if($scope.temp.policy.ruleData != null){
+    if (attributeManyKey){
+        var newCheckKey = checkKey.replace(attibuteKey + '@0',attibuteKey);
+        if($scope.temp.policy.ruleData[newCheckKey +'@0'] != undefined && $scope.temp.policy.ruleData[newCheckKey +'@0'] != "undefined"){
+          document.getElementById(newCheckKey +'@0').value = $scope.temp.policy.ruleData[newCheckKey +'@0'];
+        }
+    }else{
+        if($scope.temp.policy.ruleData[checkKey] != undefined && $scope.temp.policy.ruleData[checkKey] != "undefined"){
+            document.getElementById(checkKey).value = $scope.temp.policy.ruleData[checkKey];
+        }
+    }
+    } 
+    plainAttributeKeys.push(labelValue + attibuteKey+'*'+attributeManyKey);    
 
     };
     
     $scope.labelManyKeys = [];
     $scope.labelLayout = function(labelValue, lableName, labelManyKey ){
-		var label = document.createElement("Label")
-		var divID = labelValue;
-		if (labelValue.endsWith('.')){
-			var workingLabel = labelValue.substring(0, labelValue.length-1);
-		}else {
-			var workingLabel = labelValue;
-		}
-		
-		if (labelValue.length  < 1){
-			divID = "DynamicTemplate";
-		} else if (labelValue.endsWith('.')){
-			var divID = 'div.'+ labelValue.substring(0, labelValue.length-1);
-		}
-		
-		var subAttributes = $scope.optimizationModelData.subattributes;
-	    var jsonObject = JSON.parse(subAttributes);	
-	    var lablInfo = findVal(jsonObject, lableName);
-		console.log("findValue : " + lableName +": "+ lablInfo);
-		var star = "";
-		var required = null;
-		if(lablInfo){
-			if(lablInfo.includes("required-true")){
-				star = " *";
-				required = true;
-			}else if (lablInfo.includes("required-false")){
-				required = false
-			}
-		}
-		
-		var labeltext = document.createTextNode(lableName + star);
-	
-		label.appendChild(labeltext);
+    var label = document.createElement("Label")
+    var divID = labelValue;
+    if (labelValue.endsWith('.')){
+    var workingLabel = labelValue.substring(0, labelValue.length-1);
+    }else {
+    var workingLabel = labelValue;
+    }
+    
+    if (labelValue.length  < 1){
+    divID = "DynamicTemplate";
+    } else if (labelValue.endsWith('.')){
+    var divID = 'div.'+ labelValue.substring(0, labelValue.length-1);
+    }
+    
+    var subAttributes = $scope.optimizationModelData.subattributes;
+        var jsonObject = JSON.parse(subAttributes);    
+        var lablInfo = findVal(jsonObject, lableName);
+    console.log("findValue : " + lableName +": "+ lablInfo);
+    var star = "";
+    var required = null;
+    if(lablInfo){
+    if(lablInfo.includes("required-true")){
+        star = " *";
+        required = true;
+    }else if (lablInfo.includes("required-false")){
+        required = false
+    }
+    }
+    
+    var labeltext = document.createTextNode(lableName + star);
+    
+    label.appendChild(labeltext);
 
 
-		if(labelManyKey){
-			var addButton = document.createElement("BUTTON");
-			var buttonLabel = document.createTextNode("+");       
-			addButton.appendChild(buttonLabel); 
-			addButton.setAttribute("class", "btn btn-add-remove");
-			addButton.setAttribute("ng-click" ,  'addNewChoice("'+labelValue + lableName+'");');
-			addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
-			var removeButton = document.createElement("BUTTON");
-			var buttonremoveLabel = document.createTextNode("-");       
-			removeButton.appendChild(buttonremoveLabel); 
-			removeButton.setAttribute("class", "btn btn-add-remove");
-			removeButton.setAttribute("ng-click" ,  'removeChoice("'+labelValue +lableName+'");');
-			removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly"); 
-			document.getElementById(divID).appendChild(addButton); 
-			document.getElementById(divID).appendChild(removeButton);
-			document.getElementById(divID).appendChild(label);
-			var id = "div."+labelValue+lableName;
-			var divTag = document.createElement("div");
-			divTag.setAttribute("id", id); 
-			document.getElementById(divID).appendChild(divTag);
-			
-			var divTag = document.createElement("div");
-			divTag.setAttribute("id", id +'@0');  
-			
-			divTag.className += ' children_group'; //here is div with a group of children.
-			
-			if(required){
-			   divTag.setAttribute("required", required);  
-			}else if(required == false){
-			   divTag.setAttribute("data-conditional", "yes");  
-			}
-			
-			document.getElementById(id).appendChild(divTag);
-			
-			$scope.labelManyKeys.push(lableName);
-			
-		}else{
-			var divTag = document.createElement("div");
-			divTag.setAttribute("id", "div."+labelValue+lableName);
-			divTag.className += ' children_group'; //here is div with a group of children.
-			if(required){
-			    divTag.setAttribute("required", required);  
-			}else if(required == false){
-				divTag.setAttribute("data-conditional", "yes");  
-			}  
-			document.getElementById(divID).appendChild(label);  
-			document.getElementById(divID).appendChild(divTag);			
-		}
+    if(labelManyKey){
+    var addButton = document.createElement("BUTTON");
+    var buttonLabel = document.createTextNode("+");       
+    addButton.appendChild(buttonLabel); 
+    addButton.setAttribute("class", "btn btn-add-remove");
+    addButton.setAttribute("ng-click" ,  'addNewChoice("'+labelValue + lableName+'");');
+    addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
+    var removeButton = document.createElement("BUTTON");
+    var buttonremoveLabel = document.createTextNode("-");       
+    removeButton.appendChild(buttonremoveLabel); 
+    removeButton.setAttribute("class", "btn btn-add-remove");
+    removeButton.setAttribute("ng-click" ,  'removeChoice("'+labelValue +lableName+'");');
+    removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly"); 
+    document.getElementById(divID).appendChild(addButton); 
+    document.getElementById(divID).appendChild(removeButton);
+    document.getElementById(divID).appendChild(label);
+    var id = "div."+labelValue+lableName;
+    var divTag = document.createElement("div");
+    divTag.setAttribute("id", id); 
+    document.getElementById(divID).appendChild(divTag);
+    
+    var divTag = document.createElement("div");
+    divTag.setAttribute("id", id +'@0');  
+    
+    divTag.className += ' children_group'; //here is div with a group of children.
+    
+    if(required){
+       divTag.setAttribute("required", required);  
+    }else if(required == false){
+       divTag.setAttribute("data-conditional", "yes");  
+    }
+    
+    document.getElementById(id).appendChild(divTag);
+    
+    $scope.labelManyKeys.push(lableName);
+    
+    }else{
+    var divTag = document.createElement("div");
+    divTag.setAttribute("id", "div."+labelValue+lableName);
+    divTag.className += ' children_group'; //here is div with a group of children.
+    if(required){
+        divTag.setAttribute("required", required);  
+    }else if(required == false){
+        divTag.setAttribute("data-conditional", "yes");  
+    }  
+    document.getElementById(divID).appendChild(label);  
+    document.getElementById(divID).appendChild(divTag);    
+    }
     };
 
     $scope.dropBoxLayout = function(labelLevel, attributeName, many , refValue, listemunerateValues, isRequired){
-		var br = document.createElement("BR");
-	
-		if (labelLevel.length  < 1){
-				var divID = "DynamicTemplate";
-		} else if (labelLevel.endsWith('.')){
-				var divID = 'div.'+ labelLevel.substring(0, labelLevel.length-1);
-		}	
-	
-	
-		var label = document.createElement("Label")
-		
-		var refAttributes = $scope.optimizationModelData.ref_attributes;
-		if(isRequired != true && refAttributes){ //check refAttributes also		
-		   		var refAttributesList = refAttributes.split(splitComma);
-		   		for (k = 0; k < refAttributesList.length; k++){
-		       		var refAttribute = refAttributesList[k].split(splitEqual);	       		
-		       		if (attributeName == refAttribute[0].trim() && refAttribute[1].includes("required-true")){
-		       			isRequired = true;
-		       		}
-		   		}
-		}
-		
-		if (matching.includes(attributeName)){
-			var labeltext = document.createTextNode(attributeName + "*!");
-			label.appendChild(labeltext);
-			isRequired = true;  //set required as true for matching element
-		}else {
-			var labeltext = document.createTextNode(attributeName);		
-			if(isRequired){
-			    var requiredLabName = attributeName+ " * ";
-				labeltext = document.createTextNode(requiredLabName);
-			}else{
-			    labeltext = document.createTextNode(attributeName);	
-			}
-		
-		    label.appendChild(labeltext);		
-		}
-		label.appendChild(labeltext);
-		// if this field is required, but its parent is not required
-		if(isRequired && document.getElementById(divID).hasAttribute('data-conditional')){
-		   	var requiredNode = document.createElement('span');
-			requiredNode.setAttribute("class", "mstooltip");
-			requiredNode.textContent = "?";
-			label.appendChild(requiredNode);
-				
-			var requiredNodeToolTip = document.createElement('span');
-			requiredNodeToolTip.setAttribute("class", "tooltiptext");
-			requiredNodeToolTip.textContent = "Conditional Required";
-			requiredNode.appendChild(requiredNodeToolTip);
+    var br = document.createElement("BR");
+    
+    if (labelLevel.length  < 1){
+        var divID = "DynamicTemplate";
+    } else if (labelLevel.endsWith('.')){
+        var divID = 'div.'+ labelLevel.substring(0, labelLevel.length-1);
+    }    
+    
+    
+    var label = document.createElement("Label")
+    
+    var refAttributes = $scope.optimizationModelData.ref_attributes;
+    if(isRequired != true && refAttributes){ //check refAttributes also    
+           var refAttributesList = refAttributes.split(splitComma);
+           for (k = 0; k < refAttributesList.length; k++){
+               var refAttribute = refAttributesList[k].split(splitEqual);               
+               if (attributeName == refAttribute[0].trim() && refAttribute[1].includes("required-true")){
+               isRequired = true;
+               }
+           }
+    }
+    
+    if (matching.includes(attributeName)){
+    var labeltext = document.createTextNode(attributeName + "*!");
+    label.appendChild(labeltext);
+    isRequired = true;  //set required as true for matching element
+    }else {
+    var labeltext = document.createTextNode(attributeName);    
+    if(isRequired){
+        var requiredLabName = attributeName+ " * ";
+        labeltext = document.createTextNode(requiredLabName);
+    }else{
+        labeltext = document.createTextNode(attributeName);    
+    }
+    
+        label.appendChild(labeltext);    
+    }
+    label.appendChild(labeltext);
+    // if this field is required, but its parent is not required
+    if(isRequired && document.getElementById(divID).hasAttribute('data-conditional')){
+       var requiredNode = document.createElement('span');
+    requiredNode.setAttribute("class", "mstooltip");
+    requiredNode.textContent = "?";
+    label.appendChild(requiredNode);
+        
+    var requiredNodeToolTip = document.createElement('span');
+    requiredNodeToolTip.setAttribute("class", "tooltiptext");
+    requiredNodeToolTip.textContent = "Conditional Required";
+    requiredNode.appendChild(requiredNodeToolTip);
 
-		}
-	
-		var listField = document.createElement("SELECT");
-		listField.setAttribute("class" , "form-control");
-		listField.setAttribute("style" , "width:300px;");
-		listField.setAttribute("ng-disabled" , "temp.policy.readOnly");
-		
-		if(isRequired){
-		    if(document.getElementById(divID).hasAttribute('data-conditional')){
-		    	listField.setAttribute("data-conditional", divID);
-		    	listField.setAttribute("ng-blur", "validContionalRequired('"+divID+"')");
-		    }else{
-				listField.setAttribute("required", true);
-		    }
-		}
-		if( many != true || isRequired != true){ // add an empty option for not required or not multiple select element
-			var optionFirst = document.createElement('option');
-			optionFirst.setAttribute('value', "");
-			listField.appendChild(optionFirst);	
-		}
-		
-		for (var i=0; i < listemunerateValues.length; i += 1) {
-			if(typeof listemunerateValues[i] == "string" && listemunerateValues[i].includes("equal-sign")){
-				listemunerateValues[i] = listemunerateValues[i].replace('equal-sign','=');
-			}
-		    var option = document.createElement('option');
-		    option.setAttribute('value', listemunerateValues[i]);
-		    option.appendChild(document.createTextNode(listemunerateValues[i]));
-		    option.setAttribute('value', listemunerateValues[i]);
-		    listField.appendChild(option);
-		}
-		listField.setAttribute("id" , ''+ labelLevel + attributeName + '');
-		
-		enumKeyList.push(attributeName);
-		
-		document.getElementById(divID).appendChild(label);  
-		document.getElementById(divID).appendChild(br);	
-				
-		if(many == true){
-			document.getElementById(divID).appendChild(listField).multiple = true;
-			plainAttributeKeys.push(labelLevel + attributeName+'*'+true);
-		}else {
-			document.getElementById(divID).appendChild(listField).multiple = false;
-			plainAttributeKeys.push(labelLevel + attributeName+'*'+false);
-		}
-	
-		if($scope.temp.policy.ruleData != null){
-			if (many == true){
-				document.getElementById(labelLevel +attributeName).options[0].selected = false;
-				for (i=0; i < listemunerateValues.length; i += 1) {
-					var testValue = $scope.temp.policy.ruleData[labelLevel +attributeName+'@' + i];
-					if (testValue === undefined){
-						testValue = $scope.temp.policy.ruleData[labelLevel +attributeName];
-						}
-					var location = listemunerateValues.indexOf(testValue);
-					if (location!=-1){
-						document.getElementById(labelLevel +attributeName).options[location].selected = true;
-						}
-					}			
-				}else {
-					    if($scope.temp.policy.ruleData[labelLevel + attributeName] != undefined && $scope.temp.policy.ruleData[labelLevel + attributeName] != "undefined"){
-		                    document.getElementById(labelLevel + attributeName).value = $scope.temp.policy.ruleData[labelLevel + attributeName];	
-					    }
-				}
-			}
-	    };
+    }
+    
+    var listField = document.createElement("SELECT");
+    listField.setAttribute("class" , "form-control");
+    listField.setAttribute("style" , "width:300px;");
+    listField.setAttribute("ng-disabled" , "temp.policy.readOnly");
+    
+    if(isRequired){
+        if(document.getElementById(divID).hasAttribute('data-conditional')){
+        listField.setAttribute("data-conditional", divID);
+        listField.setAttribute("ng-blur", "validContionalRequired('"+divID+"')");
+        }else{
+        listField.setAttribute("required", true);
+        }
+    }
+    if( many != true || isRequired != true){ // add an empty option for not required or not multiple select element
+    var optionFirst = document.createElement('option');
+    optionFirst.setAttribute('value', "");
+    listField.appendChild(optionFirst);    
+    }
+    
+    for (var i=0; i < listemunerateValues.length; i += 1) {
+    if(typeof listemunerateValues[i] == "string" && listemunerateValues[i].includes("equal-sign")){
+        listemunerateValues[i] = listemunerateValues[i].replace('equal-sign','=');
+    }
+        var option = document.createElement('option');
+        option.setAttribute('value', listemunerateValues[i]);
+        option.appendChild(document.createTextNode(listemunerateValues[i]));
+        option.setAttribute('value', listemunerateValues[i]);
+        listField.appendChild(option);
+    }
+    listField.setAttribute("id" , ''+ labelLevel + attributeName + '');
+    
+    enumKeyList.push(attributeName);
+    
+    document.getElementById(divID).appendChild(label);  
+    document.getElementById(divID).appendChild(br);    
+        
+    if(many == true){
+    document.getElementById(divID).appendChild(listField).multiple = true;
+    plainAttributeKeys.push(labelLevel + attributeName+'*'+true);
+    }else {
+    document.getElementById(divID).appendChild(listField).multiple = false;
+    plainAttributeKeys.push(labelLevel + attributeName+'*'+false);
+    }
+    
+    if($scope.temp.policy.ruleData != null){
+    if (many == true){
+        document.getElementById(labelLevel +attributeName).options[0].selected = false;
+        for (i=0; i < listemunerateValues.length; i += 1) {
+        var testValue = $scope.temp.policy.ruleData[labelLevel +attributeName+'@' + i];
+        if (testValue === undefined){
+            testValue = $scope.temp.policy.ruleData[labelLevel +attributeName];
+            }
+        var location = listemunerateValues.indexOf(testValue);
+        if (location!=-1){
+            document.getElementById(labelLevel +attributeName).options[location].selected = true;
+            }
+        }    
+        }else {
+            if($scope.temp.policy.ruleData[labelLevel + attributeName] != undefined && $scope.temp.policy.ruleData[labelLevel + attributeName] != "undefined"){
+                        document.getElementById(labelLevel + attributeName).value = $scope.temp.policy.ruleData[labelLevel + attributeName];    
+            }
+        }
+    }
+        };
     
     function onlyUnique(value, index, self) { 
         return self.indexOf(value) === index;
     };
     
     $scope.savePolicy = function(policy){
-    	if(policy.itemContent != undefined){
-    		$scope.refreshCheck = true; 
-        	$scope.policyNavigator = policy.itemContent;
-        	policy.itemContent = "";
-    	}
-    	$scope.savebutton = false;
-    	var splitAt = '*';
-    	var dot ='.';
-    	var jsonPolicy = {};
-    	if(plainAttributeKeys != null){
-    		for(a = 0; a < plainAttributeKeys.length; a++){
-    			var splitPlainAttributeKey = plainAttributeKeys[a].split(splitAt);
-    			console.log("splitPlainAttributeKey: " + splitPlainAttributeKey);	
-    			var searchElement = document.getElementById(splitPlainAttributeKey[0]);
-    			var key = splitPlainAttributeKey[0];
-    			
+    if(policy.itemContent != undefined){
+        $scope.refreshCheck = true; 
+        $scope.policyNavigator = policy.itemContent;
+        policy.itemContent = "";
+    }
+    $scope.savebutton = false;
+    var splitAt = '*';
+    var dot ='.';
+    var jsonPolicy = {};
+    if(plainAttributeKeys != null){
+        for(a = 0; a < plainAttributeKeys.length; a++){
+        var splitPlainAttributeKey = plainAttributeKeys[a].split(splitAt);
+        console.log("splitPlainAttributeKey: " + splitPlainAttributeKey);    
+        var searchElement = document.getElementById(splitPlainAttributeKey[0]);
+        var key = splitPlainAttributeKey[0];
+        
                 if(searchElement == null || searchElement.nodeName == 'BUTTON'){
                     searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
                     key = splitPlainAttributeKey[0]+'@0';
                 }
                 
-    			if(searchElement != null){
-    				var keySplit = key.split(dot);
-    				var elumentLocation = keySplit.length;
-    				var enumKey = key;
-    				if (elumentLocation > 1){
-    					enumKey = keySplit[keySplit.length - 1];
-    				}
-    				//check it is undefined or not
-    				if (enumKeyList != undefined && enumKeyList.indexOf(enumKey) != -1){
-						if (splitPlainAttributeKey[1]!= undefined && splitPlainAttributeKey[1].indexOf("true") !== -1){
-							var multiSlect = [];
-							for ( var i = 0; i < searchElement.selectedOptions.length; i++) {
-								multiSlect.push(searchElement.selectedOptions[i].value);
-								}
-							jsonPolicy[key]= multiSlect;
-						}else{
-							console.log(" searchElement.value = > " + searchElement.value);
-							jsonPolicy[key]= searchElement.value;
-						}
-    				} else {
-        				if(searchElement.value != null){
-							console.log(" searchElement.value = > " + searchElement.value);
-        					jsonPolicy[key]= searchElement.value;
-        				}
-    				}
-    			}
-    		}
-    	}
+        if(searchElement != null){
+            var keySplit = key.split(dot);
+            var elumentLocation = keySplit.length;
+            var enumKey = key;
+            if (elumentLocation > 1){
+            enumKey = keySplit[keySplit.length - 1];
+            }
+            //check it is undefined or not
+            if (enumKeyList != undefined && enumKeyList.indexOf(enumKey) != -1){
+            if (splitPlainAttributeKey[1]!= undefined && splitPlainAttributeKey[1].indexOf("true") !== -1){
+            var multiSlect = [];
+            for ( var i = 0; i < searchElement.selectedOptions.length; i++) {
+                multiSlect.push(searchElement.selectedOptions[i].value);
+                }
+            jsonPolicy[key]= multiSlect;
+            }else{
+            console.log(" searchElement.value = > " + searchElement.value);
+            jsonPolicy[key]= searchElement.value;
+            }
+            } else {
+                if(searchElement.value != null){
+            console.log(" searchElement.value = > " + searchElement.value);
+                jsonPolicy[key]= searchElement.value;
+                }
+            }
+        }
+        }
+    }
         var uuu = "policycreation/save_policy";
         var postData={policyData: policy, policyJSON : jsonPolicy};
         $.ajax({
@@ -1263,113 +1265,113 @@
             data: JSON.stringify(postData),
             success : function(data){
                 $scope.$apply(function(){
-                	$scope.data=data.policyData;
-                	if($scope.data == 'success'){
-                		$scope.temp.policy.readOnly = 'true';
-                		$scope.safetyChecker = data.policyData.split("#")[2];
-                		if ($scope.safetyChecker!=undefined) {
-                			Notification.success($scope.safetyChecker);
-                		}
-                		$scope.pushStatus=data.policyData.split("&")[1];
-                		if($scope.pushStatus=="successPush"){
-                			Notification.success("Policy pushed successfully");
-                		}
-                		Notification.success("Policy Saved Successfully.");	
-                	}else if ($scope.data == 'PolicyExists'){
-						$scope.savebutton = true;
-						Notification.error("Policy Already Exists with Same Name in Scope.");
-					}
+                $scope.data=data.policyData;
+                if($scope.data == 'success'){
+                    $scope.temp.policy.readOnly = 'true';
+                    $scope.safetyChecker = data.policyData.split("#")[2];
+                    if ($scope.safetyChecker!=undefined) {
+                    Notification.success($scope.safetyChecker);
+                    }
+                    $scope.pushStatus=data.policyData.split("&")[1];
+                    if($scope.pushStatus=="successPush"){
+                    Notification.success("Policy pushed successfully");
+                    }
+                    Notification.success("Policy Saved Successfully.");    
+                }else if ($scope.data == 'PolicyExists'){
+            $scope.savebutton = true;
+            Notification.error("Policy Already Exists with Same Name in Scope.");
+        }
                 });
                 console.log($scope.data);
             },
             error : function(data){
-            	Notification.error("Error Occured while saving Policy.");
+            Notification.error("Error Occured while saving Policy.");
             }
         });
     };
     
     $scope.validatePolicy = function(policy){
-    	document.getElementById("validate").innerHTML = "";
-    	var splitAt = '*';
-    	var dot ='.';
-    	var jsonPolicy = {};
-    	if(plainAttributeKeys != null){
-    		for(a = 0; a < plainAttributeKeys.length; a++){
-    			var splitPlainAttributeKey = plainAttributeKeys[a].split(splitAt);
-    			console.log(splitPlainAttributeKey[1]);	
-    			var searchElement = document.getElementById(splitPlainAttributeKey[0]);
-    			var key = splitPlainAttributeKey[0];
-    			if(searchElement == null || searchElement.nodeName == 'BUTTON'){
-    				searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
-    				key = splitPlainAttributeKey[0]+'@0';
-    			}
-    			if(searchElement != null){
-    				if (enumKeyList.indexOf(key) != -1){
-						if (splitPlainAttributeKey[1].indexOf("true") !== -1){
-							var multiSlect = [];
-							for ( var i = 0; i < searchElement.selectedOptions.length; i++) {
-								multiSlect.push(searchElement.selectedOptions[i].value);
-								}
-							jsonPolicy[key]= multiSlect;
-						}else{
-							jsonPolicy[key]= searchElement.value;
-						}
-    					if(searchElement.getAttribute("required")){
-    						if(!searchElement.value){
-    							return;
-    						}
-    					} 
-    				} else {
-        				if(searchElement.value != null){
-        					jsonPolicy[key]= searchElement.value;
-        					if(searchElement.getAttribute("required")){
-        						if(!searchElement.value){
-        							return;
-        						}
-        					}        					
-        				}
-    				}
-    			}
-    		}
-    	}
+    document.getElementById("validate").innerHTML = "";
+    var splitAt = '*';
+    var dot ='.';
+    var jsonPolicy = {};
+    if(plainAttributeKeys != null){
+        for(a = 0; a < plainAttributeKeys.length; a++){
+        var splitPlainAttributeKey = plainAttributeKeys[a].split(splitAt);
+        console.log(splitPlainAttributeKey[1]);    
+        var searchElement = document.getElementById(splitPlainAttributeKey[0]);
+        var key = splitPlainAttributeKey[0];
+        if(searchElement == null || searchElement.nodeName == 'BUTTON'){
+            searchElement = document.getElementById(splitPlainAttributeKey[0]+'@0');
+            key = splitPlainAttributeKey[0]+'@0';
+        }
+        if(searchElement != null){
+            if (enumKeyList.indexOf(key) != -1){
+            if (splitPlainAttributeKey[1].indexOf("true") !== -1){
+            var multiSlect = [];
+            for ( var i = 0; i < searchElement.selectedOptions.length; i++) {
+                multiSlect.push(searchElement.selectedOptions[i].value);
+                }
+            jsonPolicy[key]= multiSlect;
+            }else{
+            jsonPolicy[key]= searchElement.value;
+            }
+            if(searchElement.getAttribute("required")){
+                if(!searchElement.value){
+                return;
+                }
+            } 
+            } else {
+                if(searchElement.value != null){
+                jsonPolicy[key]= searchElement.value;
+                if(searchElement.getAttribute("required")){
+                    if(!searchElement.value){
+                    return;
+                    }
+                }                
+                }
+            }
+        }
+        }
+    }
         var uuu = "policyController/validate_policy.htm";        
         var postData={policyData: policy, policyJSON : jsonPolicy};
- 		$.ajax({
- 			type : 'POST',
- 			url : uuu,
- 			dataType: 'json',
- 			contentType: 'application/json',
- 			data: JSON.stringify(postData),
- 			success : function(data){
- 				$scope.$apply(function(){
- 					$scope.validateData = data.data.replace(/\"/g, "");
-					$scope.data=data.data.substring(1,8);
-						var size = data.data.length;
-						if($scope.data == 'success'){
-							Notification.success("Validation Success.");
-							$scope.savebutton = false;
-							if (size > 18){
-								var displayWarning = data.data.substring(19,size  - 1);
-								document.getElementById("validate").innerHTML = "Safe Policy Warning Message  :  "+displayWarning;
-								document.getElementById("validate").style.color = "white";
-								document.getElementById("validate").style.backgroundColor = "skyblue";
-							}
- 						}else{
- 							Notification.error("Validation Failed.");
- 							document.getElementById("validate").innerHTML = $scope.validateData;
- 							document.getElementById("validate").style.color = "white";
- 							document.getElementById("validate").style.backgroundColor = "red";
- 							$scope.savebutton = true;
- 						}
- 						
- 				});
- 				console.log($scope.data);	
- 			},
- 			error : function(data){
- 				Notification.error("Validation Failed.");
- 				$scope.savebutton = true;
- 			}
- 		});
+     $.ajax({
+     type : 'POST',
+     url : uuu,
+     dataType: 'json',
+     contentType: 'application/json',
+     data: JSON.stringify(postData),
+     success : function(data){
+         $scope.$apply(function(){
+         $scope.validateData = data.data.replace(/\"/g, "");
+        $scope.data=data.data.substring(1,8);
+            var size = data.data.length;
+            if($scope.data == 'success'){
+            Notification.success("Validation Success.");
+            $scope.savebutton = false;
+            if (size > 18){
+                var displayWarning = data.data.substring(19,size  - 1);
+                document.getElementById("validate").innerHTML = "Safe Policy Warning Message  :  "+displayWarning;
+                document.getElementById("validate").style.color = "white";
+                document.getElementById("validate").style.backgroundColor = "skyblue";
+            }
+             }else{
+             Notification.error("Validation Failed.");
+             document.getElementById("validate").innerHTML = $scope.validateData;
+             document.getElementById("validate").style.color = "white";
+             document.getElementById("validate").style.backgroundColor = "red";
+             $scope.savebutton = true;
+             }
+             
+         });
+         console.log($scope.data);    
+     },
+     error : function(data){
+         Notification.error("Validation Failed.");
+         $scope.savebutton = true;
+     }
+     });
     };
 
     function extend(obj, src) {
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policyManager.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policyManager.js
index 0aec30c..3a926c4 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policyManager.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policyManager.js
@@ -8,7 +8,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * 
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *        http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -18,326 +18,326 @@
  * ============LICENSE_END=========================================================
  */
 app.controller('PolicyManagerController', [
-        '$scope', '$q', '$window', '$cookies', 'policyManagerConfig', 'item', 'policyNavigator', 'policyUploader', 'Notification','PolicyAppService',
-        function($scope, $q, $Window, $cookies, policyManagerConfig, Item, PolicyNavigator, PolicyUploader, Notification, PolicyAppService ) {
+          '$scope', '$q', '$window', '$cookies', 'policyManagerConfig', 'item', 'policyNavigator', 'policyUploader', 'Notification','PolicyAppService',
+          function($scope, $q, $Window, $cookies, policyManagerConfig, Item, PolicyNavigator, PolicyUploader, Notification, PolicyAppService ) {
 
-        $scope.isDisabled = true;
-        $scope.superAdminId = false;
-        $scope.exportPolicyId = false;
-        $scope.importPolicyId = false;
-        $scope.createScopeId = false;
-        $scope.deleteScopeId = false;
-        $scope.renameId = false;
-        $scope.createPolicyId = false;
-        $scope.cloneId = false;
-        $scope.editPolicyId = false;
-        $scope.switchVersionId = false;
-        $scope.describePolicyId = false;
-        $scope.viewPolicyId = false;
-        $scope.deletePolicyId = false;
-        PolicyAppService.getData('get_LockDownData').then(function(data) {
-            var j = data;
-            $scope.data = JSON.parse(j.data);
-            $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
-            if ($scope.lockdowndata[0].lockdown == true) {
-                $scope.isDisabled = true;
-            } else {
-                $scope.isDisabled = false;
-            }
-            console.log($scope.data);
-        }, function(error) {
-            console.log("failed");
-        });
+          $scope.isDisabled = true;
+          $scope.superAdminId = false;
+          $scope.exportPolicyId = false;
+          $scope.importPolicyId = false;
+          $scope.createScopeId = false;
+          $scope.deleteScopeId = false;
+          $scope.renameId = false;
+          $scope.createPolicyId = false;
+          $scope.cloneId = false;
+          $scope.editPolicyId = false;
+          $scope.switchVersionId = false;
+          $scope.describePolicyId = false;
+          $scope.viewPolicyId = false;
+          $scope.deletePolicyId = false;
+          PolicyAppService.getData('get_LockDownData').then(function(data) {
+                var j = data;
+                $scope.data = JSON.parse(j.data);
+                $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
+                if ($scope.lockdowndata[0].lockdown == true) {
+                     $scope.isDisabled = true;
+                } else {
+                     $scope.isDisabled = false;
+                }
+                console.log($scope.data);
+          }, function(error) {
+                console.log("failed");
+          });
 
-        PolicyAppService.getData('getDictionary/get_DescriptiveScopeByName').then(function(data) {
-            var j = data;
-            $scope.data = JSON.parse(j.data);
-            console.log($scope.data);
-            $scope.descriptiveScopeDictionaryDatas = JSON.parse($scope.data.descriptiveScopeDictionaryDatas);
-        }, function (error) {
-            console.log("failed");
-        });
+          PolicyAppService.getData('getDictionary/get_DescriptiveScopeByName').then(function(data) {
+                var j = data;
+                $scope.data = JSON.parse(j.data);
+                console.log($scope.data);
+                $scope.descriptiveScopeDictionaryDatas = JSON.parse($scope.data.descriptiveScopeDictionaryDatas);
+          }, function (error) {
+                console.log("failed");
+          });
 
-        PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function(data) {
-            var j = data;
-            $scope.data = JSON.parse(j.data);
-            console.log($scope.data);
-            $scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);
-        }, function (error) {
-        	console.log("failed");
-        });
+          PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function(data) {
+                var j = data;
+                $scope.data = JSON.parse(j.data);
+                console.log($scope.data);
+                $scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);
+          }, function (error) {
+          	console.log("failed");
+          });
 
-        PolicyAppService.getData('getDictionary/get_VSCLActionDataByName').then(function(data) {
-            var j = data;
-            $scope.data = JSON.parse(j.data);
-            console.log($scope.data);
-            $scope.vsclActionDictionaryDatas = JSON.parse($scope.data.vsclActionDictionaryDatas);
-        }, function (error) {
-            console.log("failed");
-        });
+          PolicyAppService.getData('getDictionary/get_VSCLActionDataByName').then(function(data) {
+                var j = data;
+                $scope.data = JSON.parse(j.data);
+                console.log($scope.data);
+                $scope.vsclActionDictionaryDatas = JSON.parse($scope.data.vsclActionDictionaryDatas);
+          }, function (error) {
+                console.log("failed");
+          });
 
-        PolicyAppService.getData('getDictionary/get_VNFTypeDataByName').then(function(data) {
-            var j = data;
-            $scope.data = JSON.parse(j.data);
-            console.log($scope.data);
-            $scope.vnfTypeDictionaryDatas = JSON.parse($scope.data.vnfTypeDictionaryDatas);	
-        }, function (error) {
-            console.log("failed");
-        });
+          PolicyAppService.getData('getDictionary/get_VNFTypeDataByName').then(function(data) {
+                var j = data;
+                $scope.data = JSON.parse(j.data);
+                console.log($scope.data);
+                $scope.vnfTypeDictionaryDatas = JSON.parse($scope.data.vnfTypeDictionaryDatas);	
+          }, function (error) {
+                console.log("failed");
+          });
 
 
-        PolicyAppService.getData('get_UserRolesData').then(function (data) {
-            var j = data;
-            $scope.data = JSON.parse(j.data);
-            console.log($scope.data);
-            $scope.userRolesDatas = JSON.parse($scope.data.userRolesDatas);
-            console.log($scope.userRolesDatas);
-            if ($scope.userRolesDatas[0] == 'super-admin') {
-                $scope.superAdminId = true;
-                $scope.exportPolicyId = true;
-                $scope.importPolicyId = true;
-           } else if ($scope.userRolesDatas[0] == 'super-editor' || $scope.userRolesDatas[0] == 'editor' || $scope.userRolesDatas[0] == 'admin') {
-               $scope.exportPolicyId = true;
-               $scope.importPolicyId = true; 
-           }
-        }, function (error) {
-            console.log("failed");
-        });
+          PolicyAppService.getData('get_UserRolesData').then(function (data) {
+                var j = data;
+                $scope.data = JSON.parse(j.data);
+                console.log($scope.data);
+                $scope.userRolesDatas = JSON.parse($scope.data.userRolesDatas);
+                console.log($scope.userRolesDatas);
+                if ($scope.userRolesDatas[0] == 'super-admin') {
+                     $scope.superAdminId = true;
+                     $scope.exportPolicyId = true;
+                     $scope.importPolicyId = true;
+              } else if ($scope.userRolesDatas[0] == 'super-editor' || $scope.userRolesDatas[0] == 'editor' || $scope.userRolesDatas[0] == 'admin') {
+                    $scope.exportPolicyId = true;
+                    $scope.importPolicyId = true; 
+              }
+          }, function (error) {
+                console.log("failed");
+          });
 
-        $scope.config = policyManagerConfig;
-        $scope.reverse = false;
-        $scope.predicate = ['model.type', 'model.name'];
-        $scope.order = function(predicate) {
-            $scope.reverse = ($scope.predicate[1] === predicate) ? !$scope.reverse : false;
-            $scope.predicate[1] = predicate;
-        };
+          $scope.config = policyManagerConfig;
+          $scope.reverse = false;
+          $scope.predicate = ['model.type', 'model.name'];
+          $scope.order = function(predicate) {
+                $scope.reverse = ($scope.predicate[1] === predicate) ? !$scope.reverse : false;
+                $scope.predicate[1] = predicate;
+          };
 
-        $scope.query = '';
-        $scope.temp = new Item();
-        $scope.policyNavigator = new PolicyNavigator();
-        $scope.policyUploader = PolicyUploader;
-        $scope.uploadFileList = [];
+          $scope.query = '';
+          $scope.temp = new Item();
+          $scope.policyNavigator = new PolicyNavigator();
+          $scope.policyUploader = PolicyUploader;
+          $scope.uploadFileList = [];
 
-        $scope.setTemplate = function(name) {
-            $scope.viewTemplate = $cookies.viewTemplate = name;
-        };
+          $scope.setTemplate = function(name) {
+                $scope.viewTemplate = $cookies.viewTemplate = name;
+          };
 
-        $scope.touch = function(item) {
-            item = item instanceof Item ? item : new Item();
-            item.revert();
-            $scope.temp = item;
-            $scope.createScopeId = false;
-            $scope.deleteScopeId = false;
-            $scope.renameId = false;
-            $scope.createPolicyId = false;
-            $scope.cloneId = false;
-            $scope.editPolicyId = false;
-            $scope.switchVersionId = false;
-            $scope.describePolicyId = false;
-            $scope.viewPolicyId = false;
-            $scope.deletePolicyId = false;
-            if ($scope.temp.model.roleType == 'super-admin') {
-                $scope.createScopeId = true;
-                $scope.deleteScopeId = true;
-                $scope.renameId = true;
-                $scope.createPolicyId = true;
-                $scope.cloneId = true;
-                $scope.editPolicyId = true;
-                $scope.switchVersionId = true;
-                $scope.describePolicyId = true;
-                $scope.viewPolicyId = true;
-                $scope.deletePolicyId = true; 
-            } else if ($scope.temp.model.roleType == 'super-editor' || $scope.temp.model.roleType == 'editor') {
-                $scope.cloneId = true;
-                $scope.editPolicyId = true;
-                $scope.createPolicyId = true;
-                $scope.switchVersionId = true;
-                $scope.describePolicyId = true;
-                $scope.viewPolicyId = true;
-                $scope.deletePolicyId = true; 
-            } else if ($scope.temp.model.roleType == 'super-guest' || $scope.temp.model.roleType == 'guest') {
-                $scope.describePolicyId = true;
-                $scope.viewPolicyId = true;
-            } else if ($scope.temp.model.roleType == 'admin') {
-                $scope.createScopeId = true;
-                $scope.renameId = true;
-                $scope.createPolicyId = true;
-                $scope.cloneId = true;
-                $scope.editPolicyId = true;
-                $scope.switchVersionId = true;
-                $scope.describePolicyId = true;
-                $scope.viewPolicyId = true;
-                $scope.deletePolicyId = true;  
-            }
-        };
+          $scope.touch = function(item) {
+                item = item instanceof Item ? item : new Item();
+                item.revert();
+                $scope.temp = item;
+                $scope.createScopeId = false;
+                $scope.deleteScopeId = false;
+                $scope.renameId = false;
+                $scope.createPolicyId = false;
+                $scope.cloneId = false;
+                $scope.editPolicyId = false;
+                $scope.switchVersionId = false;
+                $scope.describePolicyId = false;
+                $scope.viewPolicyId = false;
+                $scope.deletePolicyId = false;
+                if ($scope.temp.model.roleType == 'super-admin') {
+                     $scope.createScopeId = true;
+                     $scope.deleteScopeId = true;
+                     $scope.renameId = true;
+                     $scope.createPolicyId = true;
+                     $scope.cloneId = true;
+                     $scope.editPolicyId = true;
+                     $scope.switchVersionId = true;
+                     $scope.describePolicyId = true;
+                     $scope.viewPolicyId = true;
+                     $scope.deletePolicyId = true; 
+                } else if ($scope.temp.model.roleType == 'super-editor' || $scope.temp.model.roleType == 'editor') {
+                     $scope.cloneId = true;
+                     $scope.editPolicyId = true;
+                     $scope.createPolicyId = true;
+                     $scope.switchVersionId = true;
+                     $scope.describePolicyId = true;
+                     $scope.viewPolicyId = true;
+                     $scope.deletePolicyId = true; 
+                } else if ($scope.temp.model.roleType == 'super-guest' || $scope.temp.model.roleType == 'guest') {
+                     $scope.describePolicyId = true;
+                     $scope.viewPolicyId = true;
+                } else if ($scope.temp.model.roleType == 'admin') {
+                     $scope.createScopeId = true;
+                     $scope.renameId = true;
+                     $scope.createPolicyId = true;
+                     $scope.cloneId = true;
+                     $scope.editPolicyId = true;
+                     $scope.switchVersionId = true;
+                     $scope.describePolicyId = true;
+                     $scope.viewPolicyId = true;
+                     $scope.deletePolicyId = true;  
+                }
+          };
 
-        $scope.smartClick = function(item) {
-            if (item.isFolder()) {
-                return $scope.policyNavigator.folderClick(item);
-            }
-            if (item.isEditable()) {
-                return $scope.openEditItem(item);
-            }
-        };
+          $scope.smartClick = function(item) {
+                if (item.isFolder()) {
+                     return $scope.policyNavigator.folderClick(item);
+                }
+                if (item.isEditable()) {
+                     return $scope.openEditItem(item);
+                }
+          };
 
-        $scope.openEditItem = function(item) {
-            item.getContent();
-            $scope.modal('createNewPolicy');
-            return $scope.touch(item);
-        };
+          $scope.openEditItem = function(item) {
+                item.getContent();
+                $scope.modal('createNewPolicy');
+                return $scope.touch(item);
+          };
 
-        $scope.modal = function(id, hide) {
-            return $('#' + id).modal(hide ? 'hide' : 'show');
-        };
+          $scope.modal = function(id, hide) {
+                return $('#' + id).modal(hide ? 'hide' : 'show');
+          };
 
-        $scope.isInThisPath = function(path) {
-            var currentPath = $scope.policyNavigator.currentPath.join('/');
-            return currentPath.indexOf(path) !== -1;
-        };
-         
-       $scope.watchPolicy = function(item) {
-           var uuu = "watchPolicy";
-           var data = {name : item.model.name,
-                   path : item.model.path};
-           var postData={watchData: data};
-           $.ajax({
-               type : 'POST',
-               url : uuu,
-               dataType: 'json',
-               contentType: 'application/json',
-               data: JSON.stringify(postData),
-               success : function(data) {
-                   $scope.$apply(function() {
-                       $scope.watchData=data.watchData;});
-                   Notification.success($scope.watchData);
-                   console.log($scope.watchData);
-               },
-               error : function(data) {
-                   alert("Error while saving.");
-               }
-           });
-       };
-
-       $scope.refresh = function() {
-           $scope.policyNavigator.refresh();
-       };
-
-         $scope.switchVersion = function(item) {
-             if ($scope.policyNavigator.fileNameExists(item.tempModel.content.activeVersion)) {
-                 item.error = 'Invalid filename or already exists, specify another name';
-                 return false;
-             }
-             item.getSwitchVersionContent().then(function(){
-                 $scope.policyNavigator.refresh();
-                 $scope.modal('switchVersion', true);
-             });
+          $scope.isInThisPath = function(path) {
+                var currentPath = $scope.policyNavigator.currentPath.join('/');
+                return currentPath.indexOf(path) !== -1;
+          };
+            
+         $scope.watchPolicy = function(item) {
+              var uuu = "watchPolicy";
+              var data = {name : item.model.name,
+                         path : item.model.path};
+              var postData={watchData: data};
+              $.ajax({
+                    type : 'POST',
+                    url : uuu,
+                    dataType: 'json',
+                    contentType: 'application/json',
+                    data: JSON.stringify(postData),
+                    success : function(data) {
+                         $scope.$apply(function() {
+                              $scope.watchData=data.watchData;});
+                         Notification.success($scope.watchData);
+                         console.log($scope.watchData);
+                    },
+                    error : function(data) {
+                        Notification.error("Error while saving.");
+                    }
+              });
          };
 
-        $scope.copy = function(item) {
-            var samePath = item.tempModel.path.join() === item.model.path.join();
-            if (samePath && $scope.policyNavigator.fileNameExists(item.tempModel.name)) {
-                item.error = 'Invalid filename or already exists, specify another name';
-                return false;
-            }
-            item.copy().then(function() {
-                $scope.policyNavigator.refresh();
-                $scope.modal('copy', true);
-            });
-        };
+         $scope.refresh = function() {
+              $scope.policyNavigator.refresh();
+         };
 
-        $scope.remove = function(item) {
-            item.remove().then(function() {
-                $scope.policyNavigator.refresh();
-                $scope.modal('delete', true);
-            });
-        };
+            $scope.switchVersion = function(item) {
+                 if ($scope.policyNavigator.fileNameExists(item.tempModel.content.activeVersion)) {
+                      item.error = 'Invalid filename or already exists, specify another name';
+                      return false;
+                 }
+                 item.getSwitchVersionContent().then(function(){
+                      $scope.policyNavigator.refresh();
+                      $scope.modal('switchVersion', true);
+                 });
+            };
 
-        $scope.removePolicy = function(item) {
-            item.removePolicy().then(function() {
-                $scope.policyNavigator.refresh();
-                $scope.modal('deletePolicy', true);
-            });
-        };
-
-        $scope.rename = function(item) {
-            var samePath = item.tempModel.path.join() === item.model.path.join();
-            if (samePath && $scope.policyNavigator.fileNameExists(item.tempModel.name)) {
-                item.error = 'Invalid filename or already exists, specify another name';
-                return false;
-            }
-            item.rename().then(function() {
-                $scope.policyNavigator.refresh();
-                $scope.modal('rename', true);
-            });
-        };
-
-        $scope.move = function(item) {
-            var samePath = item.tempModel.path.join() === item.model.path.join();
-            if (samePath && $scope.policyNavigator.fileNameExists(item.tempModel.name)) {
-                item.error = 'Invalid filename or already exists, specify another name';
-                return false;
-            }
-            item.move().then(function() {
-                $scope.policyNavigator.refresh();
-                $scope.modal('move', true);
-            });
-        };
-
-        $scope.createFolder = function(item) {
-            var name = item.tempModel.name && item.tempModel.name.trim();
-            item.tempModel.type = 'dir';
-            item.tempModel.path = $scope.policyNavigator.currentPath;
-            if (name && !$scope.policyNavigator.fileNameExists(name)) {
-                item.createFolder().then(function() {
-                    $scope.policyNavigator.refresh();
-                    $scope.modal('newfolder', true);
-                });
-            } else {
-                item.error = 'Invalid filename or already exists, specify another name';
-                return false;
-            }
-        };
-
-        $scope.subScopeFolder = function(item) {
-            var name = item.tempModel.name +"\\" + item.tempModel.subScopename && item.tempModel.name.trim() + "\\"+item.tempModel.subScopename.trim() ;
-            item.tempModel.type = 'dir';
-            item.tempModel.path = $scope.policyNavigator.currentPath;
-            if (name && !$scope.policyNavigator.fileNameExists(name)) {
-                item.getScopeContent().then(function() {
-                    $scope.policyNavigator.refresh();
-                    $scope.modal('addSubScope', true);
-                });
-            } else {
-                item.error = 'Invalid filename or already exists, specify another name';
-                return false;
-            }
-        };
-
-        $scope.closefunction = function(fianlPath) {
-            $scope.policyNavigator.policyrefresh(fianlPath);
-        };
-
-        $scope.uploadFiles = function() {
-            $scope.policyUploader.upload($scope.uploadFileList, $scope.policyNavigator.currentPath).then(function() {
-                $scope.policyNavigator.refresh();
-                $scope.modal('uploadfile', true);
-            }, function(data) {
-                var errorMsg = data.result && data.result.error || 'Error Occured while Uploading....';
-                $scope.temp.error = errorMsg;
-            });
-        };
-
-        $scope.getQueryParam = function(param) {
-            var found;
-            window.location.search.substr(1).split('&').forEach(function(item) {
-                if (param ===  item.split('=')[0]) {
-                    found = item.split('=')[1];
-                    return false;
+          $scope.copy = function(item) {
+                var samePath = item.tempModel.path.join() === item.model.path.join();
+                if (samePath && $scope.policyNavigator.fileNameExists(item.tempModel.name)) {
+                     item.error = 'Invalid filename or already exists, specify another name';
+                     return false;
                 }
-            });
-            return found;
-        };
+                item.copy().then(function() {
+                     $scope.policyNavigator.refresh();
+                     $scope.modal('copy', true);
+                });
+          };
 
-        $scope.isWindows = $scope.getQueryParam('server') === 'Windows';
-        $scope.policyNavigator.refresh();
-    }]);
+          $scope.remove = function(item) {
+                item.remove().then(function() {
+                     $scope.policyNavigator.refresh();
+                     $scope.modal('delete', true);
+                });
+          };
+
+          $scope.removePolicy = function(item) {
+                item.removePolicy().then(function() {
+                     $scope.policyNavigator.refresh();
+                     $scope.modal('deletePolicy', true);
+                });
+          };
+
+          $scope.rename = function(item) {
+                var samePath = item.tempModel.path.join() === item.model.path.join();
+                if (samePath && $scope.policyNavigator.fileNameExists(item.tempModel.name)) {
+                     item.error = 'Invalid filename or already exists, specify another name';
+                     return false;
+                }
+                item.rename().then(function() {
+                     $scope.policyNavigator.refresh();
+                     $scope.modal('rename', true);
+                });
+          };
+
+          $scope.move = function(item) {
+                var samePath = item.tempModel.path.join() === item.model.path.join();
+                if (samePath && $scope.policyNavigator.fileNameExists(item.tempModel.name)) {
+                     item.error = 'Invalid filename or already exists, specify another name';
+                     return false;
+                }
+                item.move().then(function() {
+                     $scope.policyNavigator.refresh();
+                     $scope.modal('move', true);
+                });
+          };
+
+          $scope.createFolder = function(item) {
+                var name = item.tempModel.name && item.tempModel.name.trim();
+                item.tempModel.type = 'dir';
+                item.tempModel.path = $scope.policyNavigator.currentPath;
+                if (name && !$scope.policyNavigator.fileNameExists(name)) {
+                     item.createFolder().then(function() {
+                          $scope.policyNavigator.refresh();
+                          $scope.modal('newfolder', true);
+                     });
+                } else {
+                     item.error = 'Invalid filename or already exists, specify another name';
+                     return false;
+                }
+          };
+
+          $scope.subScopeFolder = function(item) {
+                var name = item.tempModel.name +"\\" + item.tempModel.subScopename && item.tempModel.name.trim() + "\\"+item.tempModel.subScopename.trim() ;
+                item.tempModel.type = 'dir';
+                item.tempModel.path = $scope.policyNavigator.currentPath;
+                if (name && !$scope.policyNavigator.fileNameExists(name)) {
+                     item.getScopeContent().then(function() {
+                          $scope.policyNavigator.refresh();
+                          $scope.modal('addSubScope', true);
+                     });
+                } else {
+                     item.error = 'Invalid filename or already exists, specify another name';
+                     return false;
+                }
+          };
+
+          $scope.closefunction = function(fianlPath) {
+                $scope.policyNavigator.policyrefresh(fianlPath);
+          };
+
+          $scope.uploadFiles = function() {
+                $scope.policyUploader.upload($scope.uploadFileList, $scope.policyNavigator.currentPath).then(function() {
+                     $scope.policyNavigator.refresh();
+                     $scope.modal('uploadfile', true);
+                }, function(data) {
+                     var errorMsg = data.result && data.result.error || 'Error Occured while Uploading....';
+                     $scope.temp.error = errorMsg;
+                });
+          };
+
+          $scope.getQueryParam = function(param) {
+                var found;
+                window.location.search.substr(1).split('&').forEach(function(item) {
+                     if (param ===  item.split('=')[0]) {
+                          found = item.split('=')[1];
+                          return false;
+                     }
+                });
+                return found;
+          };
+
+          $scope.isWindows = $scope.getQueryParam('server') === 'Windows';
+          $scope.policyNavigator.refresh();
+     }]);
