diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java b/ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java
index 66401cc..f64b9ce 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java
@@ -3,13 +3,14 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * 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
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +18,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.rest.daoimpl;
 
 import java.util.ArrayList;
@@ -45,28 +47,28 @@
 import org.springframework.stereotype.Component;
 
 @Component
-public class PolicyValidationDaoImpl implements CommonClassDao{
+public class PolicyValidationDaoImpl implements CommonClassDao {
 
     private static final Logger LOGGER = FlexLogger.getLogger(PolicyValidationDaoImpl.class);
     private static final String DB_CONNECTION_CLOSING_ERROR = "Error While Closing Connection/Statement";
     private static final String DBTABLE_QUERY_ERROR = "Error While Querying Table";
     private static SessionFactory sessionfactory;
-    
+
+    @Autowired
+    private PolicyValidationDaoImpl(SessionFactory sessionfactory) {
+        PolicyValidationDaoImpl.sessionfactory = sessionfactory;
+    }
+
+    public PolicyValidationDaoImpl() {
+        // Default Constructor
+    }
+
     public static SessionFactory getSessionfactory() {
-          return sessionfactory;
+        return sessionfactory;
     }
 
     public static void setSessionfactory(SessionFactory sessionfactory) {
-          PolicyValidationDaoImpl.sessionfactory = sessionfactory;
-    }
-
-    @Autowired
-    private PolicyValidationDaoImpl(SessionFactory sessionfactory){
-          PolicyValidationDaoImpl.sessionfactory = sessionfactory;
-    }
-    
-    public PolicyValidationDaoImpl(){
-          //Default Constructor
+        PolicyValidationDaoImpl.sessionfactory = sessionfactory;
     }
 
     @SuppressWarnings({ "unchecked", "rawtypes" })
@@ -74,16 +76,16 @@
     public List<Object> getData(Class className) {
         Session session = sessionfactory.openSession();
         List<Object> data = null;
-        try{
+        try {
             Criteria cr = session.createCriteria(className);
             data = cr.list();
-        }catch(Exception e){
+        } catch (Exception e) {
             LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
-        }finally{
-            try{
+        } finally {
+            try {
                 session.close();
-            }catch(Exception e){
-                LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR+e);
+            } catch (Exception e) {
+                LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e);
             }
         }
         return data;
@@ -97,22 +99,22 @@
         List<Object> data = null;
         try {
             Criteria cr = session.createCriteria(className);
-            if(columnName.contains(":") && key.contains(":")){
+            if (columnName.contains(":") && key.contains(":")) {
                 String[] columns = columnName.split(":");
                 String[] keys = key.split(":");
-                for(int i=0; i < columns.length; i++){
+                for (int i = 0; i < columns.length; i++) {
                     cr.add(Restrictions.eq(columns[i], keys[i]));
                 }
-            }else{
+            } else {
                 cr.add(Restrictions.eq(columnName, key));
             }
             data = cr.list();
         } catch (Exception e) {
             LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
-        }finally{
-            try{
+        } finally {
+            try {
                 session.close();
-            }catch(Exception e1){
+            } catch (Exception e1) {
                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
             }
         }
@@ -126,12 +128,12 @@
         try {
             session.persist(entity);
             tx.commit();
-        }catch(Exception e){
-            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving data to Table"+e);
-        }finally{
-            try{
+        } catch (Exception e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving data to Table" + e);
+        } finally {
+            try {
                 session.close();
-            }catch(Exception e1){
+            } catch (Exception e1) {
                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
             }
         }
@@ -145,12 +147,12 @@
         try {
             session.delete(entity);
             tx.commit();
-        }catch(Exception e){
-            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting data from Table"+e);
-        }finally{
-            try{
+        } catch (Exception e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Deleting data from Table" + e);
+        } finally {
+            try {
                 session.close();
-            }catch(Exception e1){
+            } catch (Exception e1) {
                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
             }
         }
@@ -165,12 +167,12 @@
         try {
             session.update(entity);
             tx.commit();
-        }catch(Exception e){
-            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating data to Table"+e);
-        }finally{
-            try{
+        } catch (Exception e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating data to Table" + e);
+        } finally {
+            try {
                 session.close();
-            }catch(Exception e1){
+            } catch (Exception e1) {
                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
             }
         }
@@ -185,30 +187,31 @@
         Transaction tx = session.beginTransaction();
         List<Object> data = null;
         String[] columnNames = null;
-        if(columnName != null && columnName.contains(":")){
+        if (columnName != null && columnName.contains(":")) {
             columnNames = columnName.split(":");
         }
         String[] values = null;
-        if(value != null && value.contains(":")){
+        if (value != null && value.contains(":")) {
             values = value.split(":");
         }
         try {
             Criteria cr = session.createCriteria(className);
-            if(columnNames != null && values != null && columnNames.length == values.length){
-                for (int i = 0; i < columnNames.length; i++){
-                    cr.add(Restrictions.eq(columnNames[i],values[i]));
+            if (columnNames != null && values != null && columnNames.length == values.length) {
+                for (int i = 0; i < columnNames.length; i++) {
+                    cr.add(Restrictions.eq(columnNames[i], values[i]));
                 }
-            }else{
-                cr.add(Restrictions.eq(columnName,value));
+            } else {
+                cr.add(Restrictions.eq(columnName, value));
             }
             data = cr.list();
             tx.commit();
         } catch (Exception e) {
-            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying for Duplicate Entries for Table"+e + className);
-        }finally{
-            try{
+            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying for Duplicate Entries for Table"
+                    + e + className);
+        } finally {
+            try {
                 session.close();
-            }catch(Exception e1){
+            } catch (Exception e1) {
                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
             }
         }
@@ -223,13 +226,13 @@
         Transaction tx = session.beginTransaction();
         List<PolicyRoles> rolesData = null;
         try {
-            Criteria cr = session.createCriteria(PolicyRoles.class);
-            Disjunction disjunction = Restrictions.disjunction();
-            Conjunction conjunction1  = Restrictions.conjunction();
+            final Criteria cr = session.createCriteria(PolicyRoles.class);
+            final Disjunction disjunction = Restrictions.disjunction();
+            Conjunction conjunction1 = Restrictions.conjunction();
             conjunction1.add(Restrictions.eq("role", "admin"));
-            Conjunction conjunction2  = Restrictions.conjunction();
+            Conjunction conjunction2 = Restrictions.conjunction();
             conjunction2.add(Restrictions.eq("role", "editor"));
-            Conjunction conjunction3  = Restrictions.conjunction();
+            Conjunction conjunction3 = Restrictions.conjunction();
             conjunction3.add(Restrictions.eq("role", "guest"));
             disjunction.add(conjunction1);
             disjunction.add(conjunction2);
@@ -237,11 +240,11 @@
             rolesData = cr.add(disjunction).list();
             tx.commit();
         } catch (Exception e) {
-            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyRoles Table"+e);
-        }finally{
-            try{
+            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying PolicyRoles Table" + e);
+        } finally {
+            try {
                 session.close();
-            }catch(Exception e1){
+            } catch (Exception e1) {
                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
             }
         }
@@ -270,10 +273,9 @@
         try {
             Query hbquery = session.createQuery(query);
             for (Map.Entry<String, Object> paramPair : params.entrySet()) {
-                if(paramPair.getValue() instanceof java.lang.Long){
+                if (paramPair.getValue() instanceof java.lang.Long) {
                     hbquery.setLong(paramPair.getKey(), (long) paramPair.getValue());
-                }
-                else{
+                } else {
                     hbquery.setParameter(paramPair.getKey(), paramPair.getValue());
                 }
             }
@@ -282,10 +284,10 @@
         } catch (Exception e) {
             LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
             throw e;
-        }finally{
-            try{
+        } finally {
+            try {
                 session.close();
-            }catch(HibernateException e1){
+            } catch (HibernateException e1) {
                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
             }
         }
@@ -301,23 +303,23 @@
         Object data = null;
         try {
             Criteria cr = session.createCriteria(className);
-            if(columnName.contains(":") && key.contains(":")){
+            if (columnName.contains(":") && key.contains(":")) {
                 String[] columns = columnName.split(":");
                 String[] keys = key.split(":");
-                for(int i=0; i < columns.length; i++){
+                for (int i = 0; i < columns.length; i++) {
                     cr.add(Restrictions.eq(columns[i], keys[i]));
                 }
-            }else{
+            } else {
                 cr.add(Restrictions.eq(columnName, key));
             }
             data = cr.list().get(0);
             tx.commit();
         } catch (Exception e) {
             LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
-        }finally{
-            try{
+        } finally {
+            try {
                 session.close();
-            }catch(Exception e1){
+            } catch (Exception e1) {
                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
             }
         }
@@ -346,11 +348,11 @@
             hbquery.executeUpdate();
             tx.commit();
         } catch (Exception e) {
-            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating Database Table"+e);
-        }finally{
-            try{
+            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Updating Database Table" + e);
+        } finally {
+            try {
                 session.close();
-            }catch(Exception e1){
+            } catch (Exception e1) {
                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
             }
         }
@@ -363,16 +365,16 @@
     public List<String> getDataByColumn(Class className, String columnName) {
         Session session = sessionfactory.openSession();
         List<String> data = null;
-        try{
+        try {
             Criteria cr = session.createCriteria(className);
             cr.setProjection(Projections.property(columnName));
             data = cr.list();
-        }catch(Exception e){
+        } catch (Exception e) {
             LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
-        }finally{
-            try{
+        } finally {
+            try {
                 session.close();
-            }catch(Exception e){
+            } catch (Exception e) {
                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e);
             }
         }
@@ -391,24 +393,24 @@
             Disjunction disjunction = Restrictions.disjunction();
             List<Conjunction> conjunctionList = new ArrayList<>();
             String[] columNames = columnName.split(":");
-            for(int i =0; i < data.size(); i++){
+            for (int i = 0; i < data.size(); i++) {
                 String[] entiySplit = data.get(i).split(":");
                 Conjunction conjunction = Restrictions.conjunction();
                 conjunction.add(Restrictions.eq(columNames[0], entiySplit[0]));
                 conjunction.add(Restrictions.eq(columNames[1], entiySplit[1]));
                 conjunctionList.add(conjunction);
             }
-            for(int j =0 ; j < conjunctionList.size(); j++){
+            for (int j = 0; j < conjunctionList.size(); j++) {
                 disjunction.add(conjunctionList.get(j));
             }
             entityData = cr.add(disjunction).list();
             tx.commit();
         } catch (Exception e) {
             LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + className + e);
-        }finally{
-            try{
+        } finally {
+            try {
                 session.close();
-            }catch(Exception e1){
+            } catch (Exception e1) {
                 LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
             }
         }
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImplTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImplTest.java
index 299e800..4d9d1c5 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImplTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImplTest.java
@@ -4,6 +4,7 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * Modifications copyright (c) 2019 Nokia
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,11 +19,17 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.rest.daoimpl;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.File;
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -50,9 +57,8 @@
 import org.onap.policy.rest.jpa.UserInfo;
 import org.onap.policy.rest.jpa.WatchPolicyNotificationTable;
 import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.test.annotation.Rollback;
-
+import org.springframework.transaction.annotation.Transactional;
 
 public class PolicyValidationDaoImplTest {
 
@@ -62,55 +68,51 @@
     static Server server;
     static PolicyValidationDaoImpl commonClassDao;
 
+    /**
+     * Set up all unit tests.
+     * @throws SQLException on SQL exceptions
+     */
     @BeforeClass
-    public static void setupAll() {
-        try {
-            BasicDataSource dataSource = new BasicDataSource();
-            dataSource.setDriverClassName("org.h2.Driver");
-            // In-memory DB for testing
-            dataSource.setUrl("jdbc:h2:mem:test");
-            dataSource.setUsername("sa");
-            dataSource.setPassword("");
-            LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(dataSource);
-            sessionBuilder.scanPackages("org.onap.*", "com.*");
+    public static void setupAll() throws SQLException {
+        BasicDataSource dataSource = new BasicDataSource();
+        dataSource.setDriverClassName("org.h2.Driver");
+        // In-memory DB for testing
+        dataSource.setUrl("jdbc:h2:mem:test");
+        dataSource.setUsername("sa");
+        dataSource.setPassword("");
+        LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(dataSource);
+        sessionBuilder.scanPackages("org.onap.*", "com.*");
 
-            Properties properties = new Properties();
-            properties.put("hibernate.show_sql", "false");
-            properties.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
-            properties.put("hibernate.hbm2ddl.auto", "drop");
-            properties.put("hibernate.hbm2ddl.auto", "create");
+        Properties properties = new Properties();
+        properties.put("hibernate.show_sql", "false");
+        properties.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
+        properties.put("hibernate.hbm2ddl.auto", "drop");
+        properties.put("hibernate.hbm2ddl.auto", "create");
 
-            sessionBuilder.addProperties(properties);
-            sessionFactory = sessionBuilder.buildSessionFactory();
+        sessionBuilder.addProperties(properties);
+        sessionFactory = sessionBuilder.buildSessionFactory();
 
-            // Set up dao with SessionFactory
-            commonClassDao = new PolicyValidationDaoImpl();
-            PolicyValidationDaoImpl.setSessionfactory(sessionFactory);
-            //PolicyController.setLogTableLimit("1");
-            //HibernateSession.setSession(sessionFactory);
-            SystemLogDB data1 = new SystemLogDB();
-            data1.setDate(new Date());
-            data1.setLogtype("INFO");
-            data1.setRemote("Test");
-            data1.setSystem("Test");
-            data1.setType("Test");
-            SystemLogDB data2 = new SystemLogDB();
-            data2.setDate(new Date());
-            data2.setLogtype("error");
-            data2.setRemote("Test");
-            data2.setSystem("Test");
-            data2.setType("Test");
-            //HibernateSession.getSession().save(data1);
-            //HibernateSession.getSession().save(data2);
+        // Set up dao with SessionFactory
+        commonClassDao = new PolicyValidationDaoImpl();
+        PolicyValidationDaoImpl.setSessionfactory(sessionFactory);
+        // PolicyController.setLogTableLimit("1");
+        // HibernateSession.setSession(sessionFactory);
+        SystemLogDB data1 = new SystemLogDB();
+        data1.setDate(new Date());
+        data1.setLogtype("INFO");
+        data1.setRemote("Test");
+        data1.setSystem("Test");
+        data1.setType("Test");
+        SystemLogDB data2 = new SystemLogDB();
+        data2.setDate(new Date());
+        data2.setLogtype("error");
+        data2.setRemote("Test");
+        data2.setSystem("Test");
+        data2.setType("Test");
 
-            // Create TCP server for troubleshooting
-            server = Server.createTcpServer("-tcpAllowOthers").start();
-            System.out.println("URL: jdbc:h2:" + server.getURL() + "/mem:test");
-
-        }catch(Exception e){
-            System.err.println(e);
-            fail();
-        }
+        // Create TCP server for troubleshooting
+        server = Server.createTcpServer("-tcpAllowOthers").start();
+        System.out.println("URL: jdbc:h2:" + server.getURL() + "/mem:test");
     }
 
     @AfterClass
@@ -127,324 +129,484 @@
     @Test
     @Transactional
     @Rollback(true)
-    public void testDB(){
-        try{
-            // Add data
-            UserInfo userinfo = new UserInfo();
-            userinfo.setUserLoginId("Test");
-            userinfo.setUserName("Test");
-            commonClassDao.save(userinfo);
-            OnapName onapName = new OnapName();
-            onapName.setOnapName("Test");
-            onapName.setUserCreatedBy(userinfo);
-            onapName.setUserModifiedBy(userinfo);
-            onapName.setModifiedDate(new Date());
-            commonClassDao.save(onapName);
+    public void testDB() {
+        // Add data
+        UserInfo userinfo = new UserInfo();
+        userinfo.setUserLoginId("Test");
+        userinfo.setUserName("Test");
+        commonClassDao.save(userinfo);
+        OnapName onapName = new OnapName();
+        onapName.setOnapName("Test");
+        onapName.setUserCreatedBy(userinfo);
+        onapName.setUserModifiedBy(userinfo);
+        onapName.setModifiedDate(new Date());
+        commonClassDao.save(onapName);
 
 
-            List<Object> list = commonClassDao.getData(OnapName.class);
-            assertTrue(list.size() == 1);
-            logger.debug(list.size());
-            logger.debug(list.get(0));
-        }catch(Exception e){
-            logger.debug("Exception Occured"+e);
-            fail();
-        }
+        List<Object> list = commonClassDao.getData(OnapName.class);
+        assertTrue(list.size() == 1);
+        logger.debug(list.size());
+        logger.debug(list.get(0));
     }
 
     @Test
     @Transactional
     @Rollback(true)
-    public void testUser(){
-        try{
-            // Add data
-            UserInfo userinfo = new UserInfo();
-            String loginId_userName = "Test";
-            userinfo.setUserLoginId(loginId_userName);
-            userinfo.setUserName(loginId_userName);
-            commonClassDao.save(userinfo);
+    public void testUser() {
+        // Add data
+        UserInfo userinfo = new UserInfo();
+        String loginIdUserName = "Test";
+        userinfo.setUserLoginId(loginIdUserName);
+        userinfo.setUserName(loginIdUserName);
+        commonClassDao.save(userinfo);
 
 
-            List<Object> dataCur = commonClassDao.getDataByQuery("from UserInfo", new SimpleBindings());
+        List<Object> dataCur = commonClassDao.getDataByQuery("from UserInfo", new SimpleBindings());
 
-            assertEquals(1, dataCur.size());
-            UserInfo cur = (UserInfo) dataCur.get(0);
-            assertEquals(loginId_userName, cur.getUserLoginId());
-            assertEquals(loginId_userName, cur.getUserName());
+        assertEquals(1, dataCur.size());
+        UserInfo cur = (UserInfo) dataCur.get(0);
+        assertEquals(loginIdUserName, cur.getUserLoginId());
+        assertEquals(loginIdUserName, cur.getUserName());
 
-            assertFalse(dataCur.isEmpty());
-
-        }catch(Exception e){
-            logger.debug("Exception Occured"+e);
-            fail();
-        }
+        assertFalse(dataCur.isEmpty());
     }
 
     @Test
     @Transactional
     @Rollback(true)
-    public void getDataByQuery_DashboardController(){
-        try{
-            // Add data
-            PolicyEntity pe = new PolicyEntity();
-            String name = "TestPolicy";
-            pe.setPolicyName(name);
-            pe.setPolicyData("dummyData");
-            pe.prePersist();
-            pe.setScope("dummyScope");
-            pe.setDescription("descr");
-            pe.setDeleted(false);
-            pe.setCreatedBy("Test");
-            commonClassDao.save(pe);
+    public void getDataByQuery_DashboardController() {
+        // Add data
+        PolicyEntity pe = new PolicyEntity();
+        String name = "TestPolicy";
+        pe.setPolicyName(name);
+        pe.setPolicyData("dummyData");
+        pe.prePersist();
+        pe.setScope("dummyScope");
+        pe.setDescription("descr");
+        pe.setDeleted(false);
+        pe.setCreatedBy("Test");
+        commonClassDao.save(pe);
 
-            List<Object> dataCur = commonClassDao.getDataByQuery("from PolicyEntity", new SimpleBindings());
+        List<Object> dataCur = commonClassDao.getDataByQuery("from PolicyEntity", new SimpleBindings());
 
-            assertTrue(1 == dataCur.size());
-            assertTrue( dataCur.get(0) instanceof PolicyEntity);
-            assertEquals( name,  ((PolicyEntity)dataCur.get(0)).getPolicyName());
-            assertEquals( pe, ((PolicyEntity)dataCur.get(0)));
-
-
-        }catch(Exception e){
-            logger.debug("Exception Occured"+e);
-            fail();
-        }
+        assertTrue(1 == dataCur.size());
+        assertTrue(dataCur.get(0) instanceof PolicyEntity);
+        assertEquals(name, ((PolicyEntity) dataCur.get(0)).getPolicyName());
+        assertEquals(pe, (dataCur.get(0)));
     }
 
     @Test
     @Transactional
     @Rollback(true)
-    public void getDataByQuery_AutoPushController(){
-        try{
-            // Add data
-            PolicyVersion pv = new PolicyVersion();
-            pv.setActiveVersion(2);
-            pv.setPolicyName("myPname");
-            pv.prePersist();
-            pv.setCreatedBy("Test");
-            pv.setModifiedBy("Test");
+    public void getDataByQuery_AutoPushController() {
+        // Add data
+        PolicyVersion pv = new PolicyVersion();
+        pv.setActiveVersion(2);
+        pv.setPolicyName("myPname");
+        pv.prePersist();
+        pv.setCreatedBy("Test");
+        pv.setModifiedBy("Test");
 
-            PolicyVersion pv2 = new PolicyVersion();
-            pv2.setActiveVersion(1);
-            pv2.setPolicyName("test");
-            pv2.prePersist();
-            pv2.setCreatedBy("Test");
-            pv2.setModifiedBy("Test");
+        PolicyVersion pv2 = new PolicyVersion();
+        pv2.setActiveVersion(1);
+        pv2.setPolicyName("test");
+        pv2.prePersist();
+        pv2.setCreatedBy("Test");
+        pv2.setModifiedBy("Test");
 
-            commonClassDao.save(pv);
-            commonClassDao.save(pv2);
+        commonClassDao.save(pv);
+        commonClassDao.save(pv2);
 
-            String scope = "my";
-            scope += "%";
-            String query = "From PolicyVersion where policy_name like :scope and id > 0";
-            SimpleBindings params = new SimpleBindings();
-            params.put("scope", scope);
-            List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
+        String scope = "my";
+        scope += "%";
+        String query = "From PolicyVersion where policy_name like :scope and id > 0";
+        SimpleBindings params = new SimpleBindings();
+        params.put("scope", scope);
+        List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
 
 
-            assertTrue(1 == dataCur.size());
-            assertEquals(pv, (PolicyVersion) dataCur.get(0));
-
-        }catch(Exception e){
-            logger.debug("Exception Occured"+e);
-            fail();
-        }
+        assertTrue(1 == dataCur.size());
+        assertEquals(pv, dataCur.get(0));
     }
 
     @Test
     @Transactional
     @Rollback(true)
-    public void getDataByQuery_PolicyNotificationMail(){
-        try{
-            // Add data
-            WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
-            String policyFileName = "banana";
-            watch.setLoginIds("Test");
-            watch.setPolicyName("bananaWatch");
-            commonClassDao.save(watch);
+    public void getDataByQuery_PolicyNotificationMail() {
+        // Add data
+        WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
+        watch.setLoginIds("Test");
 
-            if(policyFileName.contains("/")){
-                policyFileName = policyFileName.substring(0, policyFileName.indexOf("/"));
-                policyFileName = policyFileName.replace("/", File.separator);
-            }
-            if(policyFileName.contains("\\")){
-                policyFileName = policyFileName.substring(0, policyFileName.indexOf("\\"));
-                policyFileName = policyFileName.replace("\\", "\\\\");
-            }
+        // Add data
+        UserInfo userinfo = new UserInfo();
+        String loginIdUserName = "Test";
+        userinfo.setUserLoginId(loginIdUserName);
+        userinfo.setUserName(loginIdUserName);
+        commonClassDao.save(userinfo);
 
 
-            // Current Implementation
-            policyFileName += "%";
-            String query = "from WatchPolicyNotificationTable where policyName like:policyFileName";
-            SimpleBindings params = new SimpleBindings();
-            params.put("policyFileName", policyFileName);
-            List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
+        List<Object> dataCur = commonClassDao.getDataByQuery("from UserInfo", new SimpleBindings());
 
-            // Assertions
-            assertTrue(dataCur.size() == 1);
-            assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable);
-            assertEquals(watch, (WatchPolicyNotificationTable) dataCur.get(0));
+        assertEquals(1, dataCur.size());
+        UserInfo cur = (UserInfo) dataCur.get(0);
+        assertEquals(loginIdUserName, cur.getUserLoginId());
+        assertEquals(loginIdUserName, cur.getUserName());
 
-        }catch(Exception e){
-            logger.debug("Exception Occured"+e);
-            fail();
+        assertFalse(dataCur.isEmpty());
+
+
+        watch.setPolicyName("bananaWatch");
+        commonClassDao.save(watch);
+
+        String policyFileName = "banana";
+        if (policyFileName.contains("/")) {
+            policyFileName = policyFileName.substring(0, policyFileName.indexOf("/"));
+            policyFileName = policyFileName.replace("/", File.separator);
         }
+        if (policyFileName.contains("\\")) {
+            policyFileName = policyFileName.substring(0, policyFileName.indexOf("\\"));
+            policyFileName = policyFileName.replace("\\", "\\\\");
+        }
+
+        // Current Implementation
+        policyFileName += "%";
+        String query = "from WatchPolicyNotificationTable where policyName like:policyFileName";
+        SimpleBindings params = new SimpleBindings();
+        params.put("policyFileName", policyFileName);
+        dataCur = commonClassDao.getDataByQuery(query, params);
+
+        // Assertions
+        assertTrue(dataCur.size() == 1);
+        assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable);
+        assertEquals(watch, dataCur.get(0));
     }
 
 
     @Test
     @Transactional
     @Rollback(true)
-    public void getDataByQuery_PolicyController(){
-        try{
-            // Add data
-            PolicyEntity pe = new PolicyEntity();
-            String name = "actionDummy";
-            pe.setPolicyName(name);
-            pe.setPolicyData("dummyData");
-            pe.prePersist();
-            pe.setScope("dummyScope");
-            pe.setDescription("descr");
-            pe.setDeleted(false);
-            pe.setCreatedBy("Test");
-            commonClassDao.save(pe);
+    public void getDataByQuery_PolicyController() {
+        // Add data
+        PolicyEntity pe = new PolicyEntity();
+        String name = "actionDummy";
+        pe.setPolicyName(name);
+        pe.setPolicyData("dummyData");
+        pe.prePersist();
+        pe.setScope("dummyScope");
+        pe.setDescription("descr");
+        pe.setDeleted(false);
+        pe.setCreatedBy("Test");
+        commonClassDao.save(pe);
 
-            String dbCheckName = "dummyScope:action";
-            String[] splitDBCheckName = dbCheckName.split(":");
+        String dbCheckName = "dummyScope:action";
+        String[] splitDbCheckName = dbCheckName.split(":");
 
+        // Current Implementation
+        String query = "FROM PolicyEntity where policyName like :splitDBCheckName1 and scope = :splitDBCheckName0";
+        SimpleBindings params = new SimpleBindings();
+        params.put("splitDBCheckName1", splitDbCheckName[1] + "%");
+        params.put("splitDBCheckName0", splitDbCheckName[0]);
+        List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
 
-            // Current Implementation
-            String query =   "FROM PolicyEntity where policyName like :splitDBCheckName1 and scope = :splitDBCheckName0";
-            SimpleBindings params = new SimpleBindings();
-            params.put("splitDBCheckName1", splitDBCheckName[1] + "%");
-            params.put("splitDBCheckName0", splitDBCheckName[0]);
-            List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
-
-            // Assertions
-            assertTrue(dataCur.size() == 1);
-            assertTrue(dataCur.get(0) instanceof PolicyEntity);
-            assertEquals(pe, (PolicyEntity) dataCur.get(0));
-
-        }catch(Exception e){
-            logger.debug("Exception Occured"+e);
-            fail();
-        }
+        // Assertions
+        assertTrue(dataCur.size() == 1);
+        assertTrue(dataCur.get(0) instanceof PolicyEntity);
+        assertEquals(pe, dataCur.get(0));
     }
 
     @Test
     @Transactional
     @Rollback(true)
-    public void getDataByQuery_PolicyNotificationController(){
-        try{
-            // Add data
-            WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
-            String finalName = "banana"; // Policy File Name
-            String userId = "Test";
-            watch.setLoginIds(userId);
-            watch.setPolicyName(finalName);
-            commonClassDao.save(watch);
+    public void getDataByQuery_PolicyNotificationController() {
+        // Add data
+        WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
+        String finalName = "banana"; // Policy File Name
+        String userId = "Test";
+        watch.setLoginIds(userId);
+        watch.setPolicyName(finalName);
+        commonClassDao.save(watch);
 
 
-            // Current Implementation
-            String query = "from WatchPolicyNotificationTable where POLICYNAME = :finalName and LOGINIDS = :userId";
-            SimpleBindings params = new SimpleBindings();
-            params.put("finalName", finalName);
-            params.put("userId", userId);
-            List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
+        // Current Implementation
+        String query = "from WatchPolicyNotificationTable where POLICYNAME = :finalName and LOGINIDS = :userId";
+        SimpleBindings params = new SimpleBindings();
+        params.put("finalName", finalName);
+        params.put("userId", userId);
+        List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
 
-            // Assertions
-            assertTrue(dataCur.size() == 1);
-            assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable);
-            assertEquals(watch, (WatchPolicyNotificationTable) dataCur.get(0) );
-
-        }catch(Exception e){
-            logger.debug("Exception Occured"+e);
-            fail();
-        }
+        // Assertions
+        assertTrue(dataCur.size() == 1);
+        assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable);
+        assertEquals(watch, dataCur.get(0));
     }
 
-
-     /* Test for SQL Injection Protection
+    /*
+     * Test for SQL Injection Protection
      */
 
     @Test
     @Transactional
     @Rollback(true)
-    public void getDataByQuery_PolicyNotificationController_Injection(){
-        try{
-            // Add data
-            WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
-            String userId = "Test";
-            watch.setLoginIds(userId);
-            watch.setPolicyName("banana");
-            commonClassDao.save(watch);
+    public void getDataByQuery_PolicyNotificationController_Injection() {
+        // Add data
+        WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable();
+        String userId = "Test";
+        watch.setLoginIds(userId);
+        watch.setPolicyName("banana");
+        commonClassDao.save(watch);
 
-            WatchPolicyNotificationTable watch2 = new WatchPolicyNotificationTable();
-            watch2.setLoginIds(userId);
-            watch2.setPolicyName("banana2");
-            commonClassDao.save(watch2);
+        WatchPolicyNotificationTable watch2 = new WatchPolicyNotificationTable();
+        watch2.setLoginIds(userId);
+        watch2.setPolicyName("banana2");
+        commonClassDao.save(watch2);
 
-            // SQL Injection attempt
-            String finalName = "banana' OR '1'='1";
+        // SQL Injection attempt
+        String finalName = "banana' OR '1'='1";
 
 
-            // Current Implementation
-            String query = "from WatchPolicyNotificationTable where POLICYNAME = :finalName and LOGINIDS = :userId";
-            SimpleBindings params = new SimpleBindings();
-            params.put("finalName", finalName);
-            params.put("userId", userId);
-            List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
+        // Current Implementation
+        String query = "from WatchPolicyNotificationTable where POLICYNAME = :finalName and LOGINIDS = :userId";
+        SimpleBindings params = new SimpleBindings();
+        params.put("finalName", finalName);
+        params.put("userId", userId);
+        List<Object> dataCur = commonClassDao.getDataByQuery(query, params);
 
-            // Assertions
-            assertTrue(dataCur.size() <= 1);
+        // Assertions
+        assertTrue(dataCur.size() <= 1);
 
-            if(dataCur.size() >= 1){
-                assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable);
-                assertFalse(watch.equals((WatchPolicyNotificationTable) dataCur.get(0)));
-                assertFalse(watch.equals((WatchPolicyNotificationTable) dataCur.get(0)));
-            }
-        }catch(Exception e){
-            logger.debug("Exception Occured"+e);
-            fail();
+        if (dataCur.size() >= 1) {
+            assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable);
+            assertFalse(watch.equals(dataCur.get(0)));
+            assertFalse(watch.equals(dataCur.get(0)));
         }
     }
 
     @Test
-    public void testCommonClassDaoImplMethods(){
-        try{
-            UserInfo userInfo = new UserInfo();
-            userInfo.setUserLoginId("TestID");
-            userInfo.setUserName("Test");
-            commonClassDao.save(userInfo);
-            List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
-            assertTrue(data.size() == 1);
-            UserInfo userInfoUpdate = (UserInfo) data.get(0);
-            userInfoUpdate.setUserName("Test1");
-            commonClassDao.update(userInfoUpdate);
-            List<String> data1 = commonClassDao.getDataByColumn(UserInfo.class, "userLoginId");
-            assertTrue(data1.size() == 1);
-            UserInfo data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId:userName", "TestID:Test1");
-            assertTrue("TestID".equals(data2.getUserLoginId()));
-            List<Object> data3 = commonClassDao.checkDuplicateEntry("TestID:Test1", "userLoginId:userName", UserInfo.class);
-            assertTrue(data3.size() == 1);
-            PolicyRoles roles = new PolicyRoles();
-            roles.setRole("admin");
-            roles.setLoginId(userInfo);
-            roles.setScope("test");
-            commonClassDao.save(roles);
-            List<PolicyRoles> roles1 = commonClassDao.getUserRoles();
-            assertTrue(roles1.size() == 1);
-            List<String> multipleData = new ArrayList<>();
-            multipleData.add("TestID:Test1");
-            List<Object> data4 = commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, "userLoginId:userName", multipleData);
-            assertTrue(data4.size() == 1);
-            commonClassDao.delete(data2);
-        }catch(Exception e){
-            logger.debug("Exception Occured"+e);
-            fail();
-        }
+    public void testCommonClassDaoImplMethods() {
+        UserInfo userInfo = new UserInfo();
+        userInfo.setUserLoginId("TestID");
+        userInfo.setUserName("Test");
+        commonClassDao.save(userInfo);
+        List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+        assertTrue(data.size() == 1);
+        UserInfo userInfoUpdate = (UserInfo) data.get(0);
+        userInfoUpdate.setUserName("Test1");
+        commonClassDao.update(userInfoUpdate);
+        List<String> data1 = commonClassDao.getDataByColumn(UserInfo.class, "userLoginId");
+        assertTrue(data1.size() == 1);
+        UserInfo data2 =
+                (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId:userName", "TestID:Test1");
+        assertTrue("TestID".equals(data2.getUserLoginId()));
+        List<Object> data3 = commonClassDao.checkDuplicateEntry("TestID:Test1", "userLoginId:userName", UserInfo.class);
+        assertTrue(data3.size() == 1);
+        PolicyRoles roles = new PolicyRoles();
+        roles.setRole("admin");
+        roles.setLoginId(userInfo);
+        roles.setScope("test");
+        commonClassDao.save(roles);
+        List<PolicyRoles> roles1 = commonClassDao.getUserRoles();
+        assertTrue(roles1.size() == 1);
+        List<String> multipleData = new ArrayList<>();
+        multipleData.add("TestID:Test1");
+        List<Object> data4 =
+                commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, "userLoginId:userName", multipleData);
+        assertTrue(data4.size() == 1);
+        commonClassDao.delete(data2);
     }
 
+    @Test
+    public void testGetDataByIdparameters() {
+        UserInfo userInfo = new UserInfo();
+        userInfo.setUserLoginId("TestID");
+        userInfo.setUserName("Test");
+        commonClassDao.save(userInfo);
+        List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+        assertTrue(data.size() == 1);
+        data = commonClassDao.getDataById(UserInfo.class, null, null);
+        assertNull(data);
+        data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", null);
+        assertNull(data);
+        data = commonClassDao.getDataById(UserInfo.class, null, "TestID:Test");
+        assertNull(data);
+        data = commonClassDao.getDataById(UserInfo.class, "userLoginIduserName", "TestID:Test");
+        assertNull(data);
+        data = commonClassDao.getDataById(UserInfo.class, "userLoginIduserName", "TestIDTest");
+        assertNull(data);
+        data = commonClassDao.getDataById(UserInfo.class, "userLoginId   data2.getUserLoginId()" + ":userName",
+                "TestIDTest");
+        assertNull(data);
+        commonClassDao.delete(data);
+    }
+
+    @Test
+    public void testGetDataByColumnParameters() {
+        UserInfo userInfo = new UserInfo();
+        userInfo.setUserLoginId("TestID");
+        userInfo.setUserName("Test");
+        commonClassDao.save(userInfo);
+        List<String> data = commonClassDao.getDataByColumn(UserInfo.class, "userLoginId");
+        assertTrue(data.size() == 1);
+        data = commonClassDao.getDataByColumn(null, null);
+        assertNull(data);
+        data = commonClassDao.getDataByColumn(UserInfo.class, null);
+        assertNull(data);
+        data = commonClassDao.getDataByColumn(null, "userLoginId");
+        assertNull(data);
+        commonClassDao.delete(data);
+    }
+
+    @Test
+    public void testGetMultipleDataOnAddingConjunctionParameters() {
+        UserInfo userInfo = new UserInfo();
+        userInfo.setUserLoginId("TestID");
+        userInfo.setUserName("Test");
+        commonClassDao.save(userInfo);
+        List<String> multipleData = new ArrayList<>();
+        multipleData.add("TestID:Test1");
+        List<Object> data =
+                commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, "userLoginId:userName", multipleData);
+        assertTrue(data.size() == 0);
+        data = commonClassDao.getMultipleDataOnAddingConjunction(null, null, null);
+        assertNull(data);
+        data = commonClassDao.getMultipleDataOnAddingConjunction(null, null, multipleData);
+        assertNull(data);
+        data = commonClassDao.getMultipleDataOnAddingConjunction(null, "userLoginId:userName", null);
+        assertNull(data);
+        data = commonClassDao.getMultipleDataOnAddingConjunction(null, "userLoginId:userName", multipleData);
+        assertNull(data);
+        data = commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, null, null);
+        assertNull(data);
+        data = commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, null, multipleData);
+        assertNull(data);
+        data = commonClassDao.getMultipleDataOnAddingConjunction(UserInfo.class, "userLoginId:userName", null);
+        assertNull(data);
+        commonClassDao.delete(data);
+    }
+
+    @Test
+    public void testCheckDuplicateEntryParameters() {
+        UserInfo userInfo = new UserInfo();
+        userInfo.setUserLoginId("TestID");
+        userInfo.setUserName("Test");
+        commonClassDao.save(userInfo);
+        List<Object> data = commonClassDao.checkDuplicateEntry("TestID:Test1", "userLoginId:userName", UserInfo.class);
+        assertTrue(data.size() == 0);
+        data = commonClassDao.checkDuplicateEntry(null, null, UserInfo.class);
+        assertNull(data);
+        data = commonClassDao.checkDuplicateEntry("userLoginId:userName", null, UserInfo.class);
+        assertNull(data);
+        data = commonClassDao.checkDuplicateEntry(null, "TestID:Test", UserInfo.class);
+        assertNull(data);
+        data = commonClassDao.checkDuplicateEntry("userLoginIduserName", "TestID:Test", UserInfo.class);
+        assertNull(data);
+        data = commonClassDao.checkDuplicateEntry("userLoginId:userName", "TestID:Test:zooby", UserInfo.class);
+        assertNull(data);
+        data = commonClassDao.checkDuplicateEntry("userLoginId:userName", "TestID", UserInfo.class);
+        assertNull(data);
+        commonClassDao.delete(data);
+    }
+
+
+    @Test
+    public void testGetEntityItemParameters() {
+        UserInfo userInfo = new UserInfo();
+        userInfo.setUserLoginId("TestID");
+        userInfo.setUserName("Test");
+        commonClassDao.save(userInfo);
+        List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+        assertTrue(data.size() == 1);
+        UserInfo userInfoUpdate = (UserInfo) data.get(0);
+        userInfoUpdate.setUserName("Test1");
+        commonClassDao.update(userInfoUpdate);
+        List<String> data1 = commonClassDao.getDataByColumn(UserInfo.class, "userLoginId");
+        assertTrue(data1.size() == 1);
+        UserInfo data2 =
+                (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId:userName", "TestID:Test1");
+        assertTrue("TestID".equals(data2.getUserLoginId()));
+        data2 = (UserInfo) commonClassDao.getEntityItem(null, null, null);
+        assertNull(data2);
+        data2 = (UserInfo) commonClassDao.getEntityItem(null, null, "TestID:Test1");
+        assertNull(data2);
+        data2 = (UserInfo) commonClassDao.getEntityItem(null, "userLoginId:userName", null);
+        assertNull(data2);
+        data2 = (UserInfo) commonClassDao.getEntityItem(null, "userLoginId:userName", "TestID:Test1");
+        assertNull(data2);
+        data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, null, null);
+        assertNull(data2);
+        data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, null, "TestID:Test1");
+        assertNull(data2);
+        data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId:userName", null);
+        assertNull(data2);
+        data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginIduserName", "TestID:Test1");
+        assertNull(data2);
+        data2 = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId:userName", "TestIDTest1");
+        assertNull(data2);
+        commonClassDao.delete(data);
+        commonClassDao.delete(data1);
+        commonClassDao.delete(data2);
+    }
+
+    @Test
+    public void testOtherMethods() {
+        UserInfo userInfo = new UserInfo();
+        userInfo.setUserLoginId("TestID");
+        userInfo.setUserName("Test");
+        commonClassDao.save(userInfo);
+        commonClassDao.deleteAll();
+        List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+        assertTrue(data.size() == 1);
+
+        data = commonClassDao.checkExistingGroupListforUpdate(null, null);
+        assertTrue(data.size() == 0);
+
+        commonClassDao.updateClAlarms(null, null);
+        commonClassDao.updateClYaml(null, null);
+        data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+        assertTrue(data.size() == 1);
+        commonClassDao.update(null);
+        assertTrue(data.size() == 1);
+        commonClassDao.getData(null);
+        assertTrue(data.size() == 1);
+        commonClassDao.delete(data);
+    }
+
+    @Test
+    public void testUpdateQuery() {
+        UserInfo userInfo = new UserInfo();
+        userInfo.setUserLoginId("TestID");
+        userInfo.setUserName("Test");
+        commonClassDao.save(userInfo);
+        commonClassDao.updateQuery("SELECT * FROM userLoginId");
+        List<Object> data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+        assertTrue(data.size() == 1);
+
+        String query = "DELETE FROM org.onap.policy.rest.jpa.FunctionDefinition";
+        commonClassDao.updateQuery(query);
+        data = commonClassDao.getDataById(UserInfo.class, "userLoginId:userName", "TestID:Test");
+        assertTrue(data.size() == 1);
+        commonClassDao.delete(data);
+    }
+
+
+    @Test
+    public void testGetDataByQueryParameters() {
+        // Add data
+        UserInfo userinfo = new UserInfo();
+        String loginIdUserName = "Test";
+        userinfo.setUserLoginId(loginIdUserName);
+        userinfo.setUserName(loginIdUserName);
+        commonClassDao.save(userinfo);
+
+        SimpleBindings bindings = new SimpleBindings();
+        bindings.put("usercode", 1L);
+
+        try {
+            commonClassDao.getDataByQuery("from UserInfo", bindings);
+            fail("test should throw an exception here");
+        } catch (Exception exc) {
+            assertTrue(exc.getMessage().contains("Parameter usercode does not exist as a named parameter"));
+        }
+    }
 
     private void truncateAllTables() {
         Session session = sessionFactory.openSession();
@@ -456,5 +618,4 @@
         transaction.commit();
         session.close();
     }
-
 }
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/AutoPushController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/AutoPushController.js
index 4832da1..264ff56 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/AutoPushController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/AutoPushController.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,8 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller('policyPushController', function ($scope, PolicyAppService, modalService, $modal, Notification,$filter){
+app.controller('policyPushController', 
+    function ($scope, PolicyAppService, modalService, $modal, Notification,$filter){
     $( "#dialog" ).hide();
 
    $scope.isDisabled = true;
@@ -32,30 +33,24 @@
         }else{
             $scope.isDisabled = false;
         }
-        console.log($scope.data);
-    },function(error){
-        console.log("failed");
     });
 
     $scope.pdpdata;
     PolicyAppService.getData('get_PDPGroupData').then(function (data) {
         var j = data;
         $scope.pdpdata = JSON.parse(j.data);
-        console.log($scope.pdpdata);
         $scope.pushTabPDPGrid.data = $scope.pdpdata;
-    }, function (error) {
-        console.log("failed");
     });
 
     $scope.getPDPData = function(){
-    	 $scope.pushTabPDPGrid.data = $scope.pdpdata;
+         $scope.pushTabPDPGrid.data = $scope.pdpdata;
     };
     $scope.filterPdpGroup;
     $scope.filterPDPGroupData = function() {
         $scope.pushTabPDPGrid.data = $filter('filter')($scope.pdpdata, $scope.filterPdpGroup, undefined);
     };
     
-    $scope.pushTabPDPGrid = {	
+    $scope.pushTabPDPGrid = {    
         onRegisterApi: function(gridApi) {
             $scope.gridApi = gridApi;
         },
@@ -78,7 +73,7 @@
             Notification.error("Policy Application has been LockDown.");
         }else{
             var modalInstance = $modal.open({
-            	backdrop: 'static', keyboard: false,
+                backdrop: 'static', keyboard: false,
                 templateUrl: 'remove_PDPGroupPolicies_popup.html',
                 controller: 'removeGroupPoliciesController',
                 resolve: {
@@ -91,7 +86,6 @@
                 }
             });
             modalInstance.result.then(function (response) {
-                console.log('response', response);
                 $scope.pdpdata = JSON.parse(response.data);
                 $scope.pushTabPDPGrid.data =  $scope.pdpdata;
             });
@@ -99,75 +93,66 @@
     };
 
     $scope.gridOptions = {
-    		data : 'policydatas',
-    		 onRegisterApi: function(gridApi) {
-    	            $scope.gridPolicyApi = gridApi;
-    	        },
-    		enableSorting: true,
-    		enableFiltering: true,
-    		showTreeExpandNoChildren: true,
-    		paginationPageSizes: [10, 20, 50, 100],
-    		paginationPageSize: 20,
-    		columnDefs: [{name: 'policyName', displayName : 'Policy Name', sort: { direction: 'asc', priority: 0 }}, 
-    		             {name: 'activeVersion', displayName : 'Version'}, 
-    		             {name: 'modifiedDate', displayName : 'Last Modified',type: 'date', cellFilter: 'date:\'yyyy-MM-dd HH:MM:ss a\'' }]
+        data : 'policydatas',
+         onRegisterApi: function(gridApi) {
+             $scope.gridPolicyApi = gridApi;
+               },
+        enableSorting: true,
+        enableFiltering: true,
+        showTreeExpandNoChildren: true,
+        paginationPageSizes: [10, 20, 50, 100],
+        paginationPageSize: 20,
+        columnDefs: [{name: 'policyName', displayName : 'Policy Name', sort: { direction: 'asc', priority: 0 }}, 
+                     {name: 'activeVersion', displayName : 'Version'}, 
+                     {name: 'modifiedDate', displayName : 'Last Modified',type: 'date', cellFilter: 'date:\'yyyy-MM-dd HH:MM:ss a\'' }]
     };
     
    
     PolicyAppService.getData('get_AutoPushPoliciesContainerData').then(function (data) {
-    	$scope.loading = false;
-    	var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.policydatas =JSON.parse($scope.data.policydatas);
-		console.log($scope.policydatas);
-       }, function (error) {
-        console.log("failed");
-    });
+        $scope.loading = false;
+        var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.policydatas =JSON.parse($scope.data.policydatas);
+       });
    
     $scope.pushPoliciesButton = function(){
-    	var policySelection = $scope.gridPolicyApi.selection.getSelectedRows();
-    	console.log(policySelection);
-    	var currentSelection = $scope.gridApi.selection.getSelectedRows();
-    	if(policySelection.length == 0 && currentSelection.length == 0){
-    		Notification.error("Please Select Policy and PDP Group to Push");
-    	}
-    	if(policySelection.length == 0 && currentSelection.length != 0){
-    		Notification.error("Please Select Policy to Push");
-    	}
-    	if(policySelection.length != 0 && currentSelection.length == 0){
-    		Notification.error("Please Select PDP Group to Push");
-    	}
-    	if(policySelection.length != 0 && currentSelection.length != 0){
-    		var finalData = {
-    				"pdpDatas": currentSelection,
-    				"policyDatas": policySelection
-    		};
-    		console.log(finalData);
-    		var uuu = "auto_Push/PushPolicyToPDP.htm";
-    		var postData={pushTabData: finalData};
-    		$.ajax({
-    			type : 'POST',
-    			url : uuu,
-    			dataType: 'json',
-    			contentType: 'application/json',
-    			data: JSON.stringify(postData),
-    			success : function(data){
-    				$scope.$apply(function(){
-    					$scope.data=data.data;
-    					$scope.pdpdata = JSON.parse(data.data);
-    					$scope.pushTabPDPGrid.data =  $scope.pdpdata;
-    					Notification.success("Policy Pushed Successfully");
-    				});
-    				console.log($scope.data);
-    			},
-    			error : function(data){
-    				Notification.error("Error Occured while Pushing Policy.");
-    			}
-    		});
+        var policySelection = $scope.gridPolicyApi.selection.getSelectedRows();
+        var currentSelection = $scope.gridApi.selection.getSelectedRows();
+        if(policySelection.length == 0 && currentSelection.length == 0){
+        Notification.error("Please Select Policy and PDP Group to Push");
+        }
+        if(policySelection.length == 0 && currentSelection.length != 0){
+        Notification.error("Please Select Policy to Push");
+        }
+        if(policySelection.length != 0 && currentSelection.length == 0){
+        Notification.error("Please Select PDP Group to Push");
+        }
+        if(policySelection.length != 0 && currentSelection.length != 0){
+        var finalData = {
+            "pdpDatas": currentSelection,
+            "policyDatas": policySelection
+        };
+        var uuu = "auto_Push/PushPolicyToPDP.htm";
+        var postData={pushTabData: finalData};
+        $.ajax({
+            type : 'POST',
+            url : uuu,
+            dataType: 'json',
+            contentType: 'application/json',
+            data: JSON.stringify(postData),
+            success : function(data){
+            $scope.$apply(function(){
+                $scope.data=data.data;
+                $scope.pdpdata = JSON.parse(data.data);
+                $scope.pushTabPDPGrid.data =  $scope.pdpdata;
+                Notification.success("Policy Pushed Successfully");
+            });
+            },
+            error : function(data){
+            Notification.error("Error Occured while Pushing Policy.");
+            }
+        });
 
-    	}
+        }
     };
-  
-
 });
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dashboardCRUDController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dashboardCRUDController.js
index ce1af6b..d3f0936 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dashboardCRUDController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dashboardCRUDController.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.
@@ -19,20 +19,18 @@
  */
 
 app.controller('policyDashboardCRUDDataController', function ($scope, PolicyAppService, modalService, $modal){
-	console.log("policyDashboardCRUDDataController called");
-	
-	$('#dashBoardAdvanceSearch').hide();
-	
+    
+    $('#dashBoardAdvanceSearch').hide();
+    
     $scope.papCRUDTableDatasTemp = [];
     
     $scope.dashboardAdsearch = { isDelected: 'both', stage: 'both',  scope: "", ttlDate_after: "", ttlDate_before: ""};
 
     PolicyAppService.getData('get_DashboardPolicyCRUDData').then(function(data){
 
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.papStatusCRUDDatas =JSON.parse($scope.data.papStatusCRUDData);
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.papStatusCRUDDatas =JSON.parse($scope.data.papStatusCRUDData);
         if($scope.papStatusCRUDDatas != null){
             for(i = 0; i < $scope.papStatusCRUDDatas.length; i++){
                 $scope.papCRUDTableDatasTemp.push($scope.papStatusCRUDDatas[i].map);
@@ -40,117 +38,106 @@
             
             $scope.papCRUDTableDatas = $scope.papCRUDTableDatasTemp;
         } 
-		
-	},function(error){
-		console.log("failed");
-	});
+        
+    });
 
-	$scope.papCRUDStatusDatas = {
-		data : 'papCRUDTableDatas',
-		enableFiltering: true,
-		columnDefs: [{ field: 'id', displayName :'id'},
-		 		 	{field: 'scope', displayName :'Scope'},
-					{field: 'policyName', displayName :'Policy Name'},
-					{field: 'version', displayName :'Version'},
-					{field: 'stage', displayName :'Stage'},
-					{field: 'createdBy', displayName :'Created By'},
-					{field: 'deleted', displayName :'Deleted'},
-					{field: 'deleteReasonCode', displayName :'Deleted Reason'},
-					{field: 'deletedBy' , displayName :'Deleted By'},
-					{field: 'modifiedBy' , displayName :'Modified By'},
-					{field: 'createdDate',  displayName :'Created Date'},
-					{field: 'modifiedDate',  displayName :'Modified Date'}
-		],
+    $scope.papCRUDStatusDatas = {
+        data : 'papCRUDTableDatas',
+        enableFiltering: true,
+        columnDefs: [{ field: 'id', displayName :'id'},
+                      {field: 'scope', displayName :'Scope'},
+                    {field: 'policyName', displayName :'Policy Name'},
+                    {field: 'version', displayName :'Version'},
+                    {field: 'stage', displayName :'Stage'},
+                    {field: 'createdBy', displayName :'Created By'},
+                    {field: 'deleted', displayName :'Deleted'},
+                    {field: 'deleteReasonCode', displayName :'Deleted Reason'},
+                    {field: 'deletedBy' , displayName :'Deleted By'},
+                    {field: 'modifiedBy' , displayName :'Modified By'},
+                    {field: 'createdDate',  displayName :'Created Date'},
+                    {field: 'modifiedDate',  displayName :'Modified Date'}
+        ],
         onRegisterApi: function(gridApi){
-        	$scope.gridApi = gridApi;
+            $scope.gridApi = gridApi;
         }
-	};
-	
+    };
+    
     $('#ttlDate_after').datepicker({
-    	dateFormat: 'yy-mm-dd',
-    	changeMonth: true,
-    	changeYear: true,
-    	onSelect: function(date) {
-    		angular.element($('#ttlDate_after')).triggerHandler('input');
-    	}
+        dateFormat: 'yy-mm-dd',
+        changeMonth: true,
+        changeYear: true,
+        onSelect: function(date) {
+            angular.element($('#ttlDate_after')).triggerHandler('input');
+        }
     });
     
     $('#ttlDate_before').datepicker({
-    	dateFormat: 'yy-mm-dd',
-    	changeMonth: true,
-    	changeYear: true,
-    	onSelect: function(date) {
-    		angular.element($('#ttlDate_before')).triggerHandler('input');
-    	}
+        dateFormat: 'yy-mm-dd',
+        changeMonth: true,
+        changeYear: true,
+        onSelect: function(date) {
+            angular.element($('#ttlDate_before')).triggerHandler('input');
+        }
     });
     
     $scope.refresh = function(){
-    	$scope.modal('advancedSearch', true);
-    	$scope.temp.policy = "";
+        $scope.modal('advancedSearch', true);
+        $scope.temp.policy = "";
     };
     
     
-	$scope.advancedSearch = function(){
+    $scope.advancedSearch = function(){
 
-		 $('#dashBoardAdvanceSearch').toggle();
-		 if($('#advancedSearchArrow').hasClass('arrowdown')){
-			 $('#advancedSearchArrow').removeClass("arrowdown");
-			 $('#advancedSearchArrow').addClass("arrowup"); 
-			 
-		 }else{
-			 $('#advancedSearchArrow').removeClass("arrowup");
-			 $('#advancedSearchArrow').addClass("arrowdown"); 
-		 }
-	}
-	
+         $('#dashBoardAdvanceSearch').toggle();
+         if($('#advancedSearchArrow').hasClass('arrowdown')){
+             $('#advancedSearchArrow').removeClass("arrowdown");
+             $('#advancedSearchArrow').addClass("arrowup"); 
+             
+         }else{
+             $('#advancedSearchArrow').removeClass("arrowup");
+             $('#advancedSearchArrow').addClass("arrowdown"); 
+         }
+    }
+    
    
     $scope.startAdvancedSearch = function(data){
-    	
-		 console.log("startAdvancedSearch called");
-		 console.log(data.isDelected);
-		 console.log(data.stage);
-		 console.log(data.scope);
-		 console.log(data.ttlDate_after);
-		 console.log(data.ttlDate_before);
-		 
-		 if(data.scope == null){
-			 return;
-		 }
-		 
+        
+         
+         if(data.scope == null){
+             return;
+         }
+         
        var uuu = "dashboardController/dashboardAdvancedSearch.htm";
         
         var postData={policyData: data};
- 		$.ajax({
- 			type : 'POST',
- 			url : uuu,
- 			dataType: 'json',
- 			contentType: 'application/json',
- 			data: JSON.stringify(postData),
- 			success : function(data){
- 				 console.log("dashboardAdvancedSearch data returned: " + data);
- 				
+         $.ajax({
+             type : 'POST',
+             url : uuu,
+             dataType: 'json',
+             contentType: 'application/json',
+             data: JSON.stringify(postData),
+             success : function(data){
+                 
                  $scope.$apply(function(){  
-                	
-     				var j = data;
-     				$scope.data = JSON.parse(j.data);
-     				console.log($scope.data);
-     				$scope.papStatusCRUDDatas =JSON.parse($scope.data.policyStatusCRUDData);
-     				
-     				$scope.papCRUDTableDatasTemp = [];
-     		       
-     	            for(i = 0; i < $scope.papStatusCRUDDatas.length; i++){
-     	                $scope.papCRUDTableDatasTemp.push($scope.papStatusCRUDDatas[i].map);
-     	            }
-     	            
-     	            $scope.papCRUDTableDatas = $scope.papCRUDTableDatasTemp;
-     	            
-     	           $scope.gridApi.grid.refresh();
+                    
+                     var j = data;
+                     $scope.data = JSON.parse(j.data);
+                     $scope.papStatusCRUDDatas =JSON.parse($scope.data.policyStatusCRUDData);
+                     
+                     $scope.papCRUDTableDatasTemp = [];
+                    
+                     for(i = 0; i < $scope.papStatusCRUDDatas.length; i++){
+                         $scope.papCRUDTableDatasTemp.push($scope.papStatusCRUDDatas[i].map);
+                     }
+                     
+                     $scope.papCRUDTableDatas = $scope.papCRUDTableDatasTemp;
+                     
+                    $scope.gridApi.grid.refresh();
                });
- 			},
- 			error : function(data){
- 				console.log("dashboardAdvancedSearch Failed: data returned as " + data);
- 			}
- 		});
+             },
+             error : function(data){
+             }
+         });
     };
 
 });
\ No newline at end of file
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 c89fe9b..98a237a 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
@@ -142,77 +142,54 @@
     PolicyAppService.getData('getDictionary/get_PrefixListDataByName').then(function (data) {
     	var j = data;
     	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
     	$scope.prefixListDictionaryDatas = JSON.parse($scope.data.prefixListDictionaryDatas);
-    	console.log($scope.prefixListDictionaryDatas);
     	for(i = 0; i < $scope.prefixListDictionaryDatas.length; i++){
 			var key  = $scope.prefixListDictionaryDatas[i];
 			$scope.groupAddresses.push(key);
 		}
-    }, function (error) {
-    	console.log("failed");
     });
 
     PolicyAppService.getData('getDictionary/get_ZoneDictionaryDataByName').then(function (data) {
     	var j = data;
     	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
     	$scope.zoneDictionaryDatas = JSON.parse($scope.data.zoneDictionaryDatas);
-    	console.log($scope.zoneDictionaryDatas);
-    }, function (error) {
-    	console.log("failed");
     });
 
     PolicyAppService.getData('getDictionary/get_AddressGroupDictionaryDataByName').then(function (data) {
     	var j = data;
     	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
     	$scope.addressGroupDictionaryDatas = JSON.parse($scope.data.addressGroupDictionaryDatas);
-    	console.log($scope.addressGroupDictionaryDatas);
     	for(i = 0; i < $scope.addressGroupDictionaryDatas.length; i++){
 			var key  = $scope.addressGroupDictionaryDatas[i];
 			$scope.groupAddresses.push(key);
 		}
-    }, function (error) {
-    	console.log("failed");
     });
 
     PolicyAppService.getData('getDictionary/get_ServiceListDictionaryDataByName').then(function (data) {
     	var j = data;
     	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
     	$scope.serviceListDictionaryDatas = JSON.parse($scope.data.serviceListDictionaryDatas);
-    	console.log($scope.serviceListDictionaryDatas);
     	for(i = 0; i < $scope.serviceListDictionaryDatas.length; i++){
 			var key  = $scope.serviceListDictionaryDatas[i];
 			$scope.groupServices.push(key);
 		}
-    }, function (error) {
-    	console.log("failed");
     });
 
     PolicyAppService.getData('getDictionary/get_ServiceGroupDictionaryDataByName').then(function (data) {
     	var j = data;
     	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
     	$scope.serviceGroupDictionaryDatas = JSON.parse($scope.data.serviceGroupDictionaryDatas);
-    	console.log($scope.serviceGroupDictionaryDatas);
     	for(i = 0; i < $scope.serviceGroupDictionaryDatas.length; i++){
 			var key  = $scope.serviceGroupDictionaryDatas[i];
 			$scope.groupServices.push(key);
 		}
     }, function (error) {
-    	console.log("failed");
     });
 
     PolicyAppService.getData('getDictionary/get_ActionListDictionaryDataByName').then(function (data) {
     	var j = data;
     	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
     	$scope.actionListDictionaryDatas = JSON.parse($scope.data.actionListDictionaryDatas);
-    	console.log($scope.actionListDictionaryDatas);
-    }, function (error) {
-    	console.log("failed");
     });
 
 	
@@ -251,7 +228,6 @@
     				if($scope.termListDictionaryDatas == "Duplicate"){
     					Notification.error("FW TermList Dictionary exists with Same Term Name.")
     				}else{      
-    					console.log($scope.termListDictionaryDatas);
     					$modalInstance.close({termListDictionaryDatas:$scope.termListDictionaryDatas});
     				}
     			},
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 8492a96..ce84afd 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
@@ -17,118 +17,91 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller('editMSHeaderDefaultValuesController' ,  function ($scope, $modalInstance, message, PolicyAppService, UserInfoServiceDS2, Notification){
-	   if(message.modelAttributeDictionaryData==null)
-	        $scope.label='Set Header Default Values'
-	    else{
-	        $scope.label='Edit Header Default Values'
-	        $scope.disableCd=true;
-	    }
+app.controller('editMSHeaderDefaultValuesController' ,  
+    function ($scope, $modalInstance, message, PolicyAppService, UserInfoServiceDS2, Notification){
+       if(message.modelAttributeDictionaryData==null)
+            $scope.label='Set Header Default Values'
+        else{
+            $scope.label='Edit Header Default Values'
+            $scope.disableCd=true;
+        }
 
-	    PolicyAppService.getData('getDictionary/get_MicroServiceHeaderDefaultsData').then(function (data) {
-	    	var j = data;
-	    	$scope.data = JSON.parse(j.data);
-	    	console.log($scope.data);
-	    	$scope.microServiceHeaderDefaultDatas = JSON.parse($scope.data.microServiceHeaderDefaultDatas);
-	    	console.log("microServiceHeaderDefaultDatas:" + $scope.microServiceHeaderDefaultDatas);
-	    }, function (error) {
-	    	console.log("failed");
-	    });
+        PolicyAppService.getData('getDictionary/get_MicroServiceHeaderDefaultsData').then(function (data) {
+            var j = data;
+            $scope.data = JSON.parse(j.data);
+            $scope.microServiceHeaderDefaultDatas = JSON.parse($scope.data.microServiceHeaderDefaultDatas);
+        });
 
-	    PolicyAppService.getData('getDictionary/get_MicroServiceModelsDataServiceVersion').then(function (data) {
-	    	var j = data;
-	    	$scope.data = JSON.parse(j.data);
-	    	console.log($scope.data);
-	    	$scope.microServiceModelsDictionaryDatas = JSON.parse($scope.data.microServiceModelsDictionaryDatas);
-	    	console.log($scope.microServiceModelsDictionaryDatas);
-	    }, function (error) {
-	    	console.log("failed");
-	    });
-	    
-		PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
-			var j = data;
-			$scope.data = JSON.parse(j.data);
-			console.log("riskTypeDictionaryDatas = " + $scope.data);
-			$scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
-			console.log($scope.riskTypeDictionaryDatas);
-		}, function (error) {
-			console.log("failed");
-		});
+        PolicyAppService.getData('getDictionary/get_MicroServiceModelsDataServiceVersion').then(function (data) {
+            var j = data;
+            $scope.data = JSON.parse(j.data);
+            $scope.microServiceModelsDictionaryDatas = JSON.parse($scope.data.microServiceModelsDictionaryDatas);
+        });
+        
+    PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
+    });
 
-		PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
-			var j = data;
-			$scope.data = JSON.parse(j.data);
-			console.log("riskTypeDictionaryDatas: " + $scope.data);
-			$scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
-			console.log($scope.riskTypeDictionaryDatas);
-		}, 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);
-			console.log($scope.onapNameDictionaryDatas);
-		}, function (error) {
-			console.log("failed");
-		});
+    PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
+    });
+    
+    PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function (data) {
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);
+    });
 
-		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");
-		});
-				
-		/*getting user info from session*/
-		var userid = null;
-		UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
-		  	.then(function (response) {	  		
-		  		userid = response.userid;	  	
-		 });
-		
-	    $scope.editHeaderDefaults = message.modelAttributeDictionaryData;
-	    $scope.editModelAttribute1 = {microservice: []};
-	    if($scope.edit){
-	    	if(message.modelAttributeDictionaryData.groupList != null){
-	    		var splitValue = message.modelAttributeDictionaryData.groupList.split(",");
-	    		console.log(splitValue);
-	    	}	
-	    }
-	    $scope.saveHeaderDefaults = function(editHeaderDefaultsData) {
-	    	console.log("editHeaderDefaultsData :" + editHeaderDefaultsData);
-	        var uuu = "saveDictionary/ms_dictionary/save_headerDefaults";
-	    	var postData={modelAttributeDictionaryData: editHeaderDefaultsData, userid: userid};
-	    	$.ajax({
-	    			type : 'POST',
-	    			url : uuu,
-	    			dataType: 'json',
-	    			contentType: 'application/json',
-	    			data: JSON.stringify(postData),
-	    			success : function(data){
-	    				$scope.$apply(function(){
-	    					$scope.microServiceHeaderDefaultDatas=data.microServiceHeaderDefaultDatas;});
-	    				    console.log("microServiceHeaderDefaultDatas returned after saved: " + $scope.microServiceHeaderDefaultDatas);
-	    				if($scope.microServiceAttributeDictionaryDatas == "Duplicate"){
-	    					Notification.error("Model Attribute Dictionary exists with Same Attribute Name.")
-	    				}else{      
-	    					console.log($scope.microServiceHeaderDefaultDatas);
-	    					$modalInstance.close({microServiceHeaderDefaultDatas:$scope.microServiceHeaderDefaultDatas});
-	    				}
-	    			},
-	    			error : function(data){
-	    				Notification.error("Error while saving.");
-	    			}
-	    	});
-	    	
-	    };
+    PolicyAppService.getData('get_DCAEPriorityValues').then(function (data) {
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.priorityDatas = JSON.parse($scope.data.priorityDatas);
+    });
+        
+    /*getting user info from session*/
+    var userid = null;
+    UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
+          .then(function (response) {          
+          userid = response.userid;          
+     });
+    
+        $scope.editHeaderDefaults = message.modelAttributeDictionaryData;
+        $scope.editModelAttribute1 = {microservice: []};
+        if($scope.edit){
+            if(message.modelAttributeDictionaryData.groupList != null){
+            var splitValue = message.modelAttributeDictionaryData.groupList.split(",");
+            }    
+        }
+        $scope.saveHeaderDefaults = function(editHeaderDefaultsData) {
+            var uuu = "saveDictionary/ms_dictionary/save_headerDefaults";
+            var postData={modelAttributeDictionaryData: editHeaderDefaultsData, userid: userid};
+            $.ajax({
+                type : 'POST',
+                url : uuu,
+                dataType: 'json',
+                contentType: 'application/json',
+                data: JSON.stringify(postData),
+                success : function(data){
+                $scope.$apply(function(){
+                    $scope.microServiceHeaderDefaultDatas=data.microServiceHeaderDefaultDatas;});
+                if($scope.microServiceAttributeDictionaryDatas == "Duplicate"){
+                    Notification.error("Model Attribute Dictionary exists with Same Attribute Name.")
+                }else{      
+                    $modalInstance.close({microServiceHeaderDefaultDatas:$scope.microServiceHeaderDefaultDatas});
+                }
+                },
+                error : function(data){
+                Notification.error("Error while saving.");
+                }
+            });
+            
+        };
 
-	    $scope.close = function() {
-	        $modalInstance.close();
-	    };
-	});
\ No newline at end of file
+        $scope.close = function() {
+            $modalInstance.close();
+        };
+    });
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSGroupPolicyScopeDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSGroupPolicyScopeDictController.js
index b456c57..6b65a59 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSGroupPolicyScopeDictController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/PSGroupPolicyScopeDictController.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,8 +17,9 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-app.controller('editPSGroupPolicyScopeController' ,  function ($scope, $modalInstance, message, PolicyAppService, UserInfoServiceDS2, Notification){
-	$scope.edit = false;
+app.controller('editPSGroupPolicyScopeController' ,  
+    function ($scope, $modalInstance, message, PolicyAppService, UserInfoServiceDS2, Notification){
+    $scope.edit = false;
     if(message.groupPolicyScopeListData==null)
         $scope.label='Add New Group Policy Scope'
     else{
@@ -26,108 +27,89 @@
         $scope.disableCd=true;
         $scope.edit = true;
     }
-		
+        
     PolicyAppService.getData('getDictionary/get_PSServiceDataByName').then(function (data) {
-    	var j = data;
-    	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
-    	$scope.psServiceDictionaryDatas = JSON.parse($scope.data.psServiceDictionaryDatas);
-    	console.log($scope.psServiceDictionaryDatas);
-    }, function (error) {
-    	console.log("failed");
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.psServiceDictionaryDatas = JSON.parse($scope.data.psServiceDictionaryDatas);
     });
 
     PolicyAppService.getData('getDictionary/get_PSTypeDataByName').then(function (data) {
-    	var j = data;
-    	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
-    	$scope.psTypeDictionaryDatas = JSON.parse($scope.data.psTypeDictionaryDatas);
-    	console.log($scope.psTypeDictionaryDatas);
-    }, function (error) {
-    	console.log("failed");
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.psTypeDictionaryDatas = JSON.parse($scope.data.psTypeDictionaryDatas);
     });
 
     PolicyAppService.getData('getDictionary/get_PSResourceDataByName').then(function (data) {
-    	var j = data;
-    	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
-    	$scope.psResourceDictionaryDatas = JSON.parse($scope.data.psResourceDictionaryDatas);
-    	console.log($scope.psResourceDictionaryDatas);
-    }, function (error) {
-    	console.log("failed");
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.psResourceDictionaryDatas = JSON.parse($scope.data.psResourceDictionaryDatas);
     });
 
     PolicyAppService.getData('getDictionary/get_PSClosedLoopDataByName').then(function (data) {
-    	var j = data;
-    	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
-    	$scope.psClosedLoopDictionaryDatas = JSON.parse($scope.data.psClosedLoopDictionaryDatas);
-    	console.log($scope.psClosedLoopDictionaryDatas);
-    }, function (error) {
-    	console.log("failed");
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.psClosedLoopDictionaryDatas = JSON.parse($scope.data.psClosedLoopDictionaryDatas);
     });
-	
-	/*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.editPSGroupPolicyScope = message.groupPolicyScopeListData;
     $scope.editPSGroupPolicyScope1 = {resource: [], type:[], service: [], closedloop: []};
     if($scope.edit){
-    	if(message.groupPolicyScopeListData.groupList != null){
-    		var splitValue = message.groupPolicyScopeListData.groupList.split(",");
-    		console.log(splitValue);
-    		$scope.splittedGroupListValues = [];
-    		var splitResource = splitValue[0].split("=");
-    		$scope.editPSGroupPolicyScope1.resource.push(splitResource[1]);
-    		var splitType = splitValue[1].split("=");
-    		$scope.editPSGroupPolicyScope1.type.push(splitType[1]);
-    		var splitService = splitValue[2].split("=");
-    		$scope.editPSGroupPolicyScope1.service.push(splitService[1]);
-    		var splitCloop = splitValue[3].split("=");
-    		$scope.editPSGroupPolicyScope1.closedloop.push(splitCloop[1]);
-    	}	
+        if(message.groupPolicyScopeListData.groupList != null){
+            var splitValue = message.groupPolicyScopeListData.groupList.split(",");
+            $scope.splittedGroupListValues = [];
+            var splitResource = splitValue[0].split("=");
+            $scope.editPSGroupPolicyScope1.resource.push(splitResource[1]);
+            var splitType = splitValue[1].split("=");
+            $scope.editPSGroupPolicyScope1.type.push(splitType[1]);
+            var splitService = splitValue[2].split("=");
+            $scope.editPSGroupPolicyScope1.service.push(splitService[1]);
+            var splitCloop = splitValue[3].split("=");
+            $scope.editPSGroupPolicyScope1.closedloop.push(splitCloop[1]);
+        }    
     }
     
     $scope.savePSGroupPolicyScope = function(groupPolicyScopeListData, groupPolicyScopeListData1) {
-    	var regex = new RegExp("^[a-zA-Z0-9_]*$");
-    	if(!regex.test(groupPolicyScopeListData.groupName)) {
-    		Notification.error("Enter Valid Policy Scope Group Name without spaces or special characters");
-    	}else{
-    		console.log(groupPolicyScopeListData1);
-    		if(groupPolicyScopeListData1.resource[0] != undefined && groupPolicyScopeListData1.type[0] != undefined && groupPolicyScopeListData1.service[0] != undefined && groupPolicyScopeListData1.closedloop[0] != undefined){
-    			var uuu = "saveDictionary/ps_dictionary/save_psGroupPolicyScope";
-    			var postData={groupPolicyScopeListData: groupPolicyScopeListData,
-    					groupPolicyScopeListData1: groupPolicyScopeListData1, userid: userid};
-    			$.ajax({
-    				type : 'POST',
-    				url : uuu,
-    				dataType: 'json',
-    				contentType: 'application/json',
-    				data: JSON.stringify(postData),
-    				success : function(data){
-    					$scope.$apply(function(){
-    						$scope.groupPolicyScopeListDatas=data.groupPolicyScopeListDatas;});
-    					if($scope.groupPolicyScopeListDatas == "Duplicate"){
-    						Notification.error("GroupPolicyScope Dictionary exists with Same Group Name.")
-    					}else if($scope.groupPolicyScopeListDatas == "DuplicateGroup"){
-    						Notification.error("GroupPolicyScope Dictionary exists with Same Group List.")
-    					}else{      
-    						console.log($scope.groupPolicyScopeListDatas);
-    						$modalInstance.close({groupPolicyScopeListDatas:$scope.groupPolicyScopeListDatas});
-    					}
-    				},
-    				error : function(data){
-    					Notification.error("Error while saving.");
-    				}
-    			});
-    		}else{
-    			Notification.error("Please Select all the required fields to Save");
-    		}
-    	}
+        var regex = new RegExp("^[a-zA-Z0-9_]*$");
+        if(!regex.test(groupPolicyScopeListData.groupName)) {
+            Notification.error("Enter Valid Policy Scope Group Name without spaces or special characters");
+        }else{
+            if(groupPolicyScopeListData1.resource[0] != undefined && groupPolicyScopeListData1.type[0] != undefined && groupPolicyScopeListData1.service[0] != undefined && groupPolicyScopeListData1.closedloop[0] != undefined){
+                var uuu = "saveDictionary/ps_dictionary/save_psGroupPolicyScope";
+                var postData={groupPolicyScopeListData: groupPolicyScopeListData,
+                        groupPolicyScopeListData1: groupPolicyScopeListData1, userid: userid};
+                $.ajax({
+                    type : 'POST',
+                    url : uuu,
+                    dataType: 'json',
+                    contentType: 'application/json',
+                    data: JSON.stringify(postData),
+                    success : function(data){
+                        $scope.$apply(function(){
+                            $scope.groupPolicyScopeListDatas=data.groupPolicyScopeListDatas;});
+                        if($scope.groupPolicyScopeListDatas == "Duplicate"){
+                            Notification.error("GroupPolicyScope Dictionary exists with Same Group Name.")
+                        }else if($scope.groupPolicyScopeListDatas == "DuplicateGroup"){
+                            Notification.error("GroupPolicyScope Dictionary exists with Same Group List.")
+                        }else{      
+                            $modalInstance.close({groupPolicyScopeListDatas:$scope.groupPolicyScopeListDatas});
+                        }
+                    },
+                    error : function(data){
+                        Notification.error("Error while saving.");
+                    }
+                });
+            }else{
+                Notification.error("Please Select all the required fields to Save");
+            }
+        }
     };
 
     $scope.close = function() {
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/MSHeaderDefaultValuesDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/MSHeaderDefaultValuesDictGridController.js
index 4e6b969..e12db92 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/MSHeaderDefaultValuesDictGridController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/MSHeaderDefaultValuesDictGridController.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.
@@ -23,51 +23,31 @@
     PolicyAppService.getData('getDictionary/get_MicroServiceHeaderDefaultsData').then(function (data) {
     	var j = data;
     	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
     	$scope.microServiceHeaderDefaultDatas = JSON.parse($scope.data.microServiceHeaderDefaultDatas);
-    	console.log("microServiceHeaderDefaultDatas: " + $scope.microServiceHeaderDefaultDatas);
-    }, 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);
     	$scope.microServiceModelsDictionaryDatas = JSON.parse($scope.data.microServiceModelsDictionaryDatas);
-    	console.log($scope.microServiceModelsDictionaryDatas);
-    }, function (error) {
-    	console.log("failed");
     });
     
 	PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
 		var j = data;
 		$scope.data = JSON.parse(j.data);
-		console.log("riskTypeDictionaryDatas: " + $scope.data);
 		$scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
-		console.log($scope.riskTypeDictionaryDatas);
-	}, 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);
-		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('get_LockDownData').then(function(data){
@@ -81,8 +61,6 @@
     		$scope.msHeaderDefaultValuesDictionaryGrid.columnDefs[0].visible = true;
     		$scope.gridApi.grid.refresh();
     	}
-    },function(error){
-    	console.log("failed");
     });
 	
     $scope.msHeaderDefaultValuesDictionaryGrid = {
@@ -116,7 +94,6 @@
             }
         });
         modalInstance.result.then(function(response){
-            console.log('response', response);
             $scope.microServiceHeaderDefaultDatas=response.microServiceHeaderDefaultDatas;
         });
     };
@@ -137,7 +114,6 @@
             }
         });
         modalInstance.result.then(function(response){
-            console.log('response', response);
             $scope.modelAttributeDictionaryDataa = response.modelAttributeDictionaryDatas;
         });
     };
@@ -157,7 +133,6 @@
                         $scope.$apply(function(){$scope.microServiceHeaderDefaultDatas=data.microServiceHeaderDefaultDatas;});
                     },
                     error : function(data){
-                        console.log(data);
                         modalService.showFailure("Fail","Error while deleting: "+ data.responseText);
                     }
                 });
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 fe55bb2..35fb3cb 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
@@ -63,46 +63,29 @@
     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);
-    }, function (error) {
-        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);
-    }, function (error) {
-        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);
-    }, 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.temp.policy.dynamicLayoutMap = {};
     $scope.addDataToFields = function(ruleName){
-        console.log(ruleName);   
         if(ruleName != null){
             var uuu = "policyController/getBRMSTemplateData.htm";
             var postData={policyData: ruleName};
@@ -116,7 +99,6 @@
                      $scope.$apply(function(){
                         $scope.temp.policy.dynamicLayoutMap = data.policyData;
                      });
-                     console.log( $scope.temp.policy.dynamicLayoutMap);
                  },
                  error : function(data){
                     Notification.error("Error While Retriving the Template Layout Pattren.");
@@ -128,7 +110,6 @@
     $scope.showbrmsrule = true;
     
     $scope.ShowRule = function(policy){
-        console.log(policy);
         var uuu = "policyController/ViewBRMSParamPolicyRule.htm";
         var postData={policyData: policy};
         $.ajax({
@@ -186,7 +167,6 @@
                         Notification.error("Policy Already Exists with Same Name in Scope.");
                     }
                 });
-                console.log($scope.data);
             },
             error : function(data){
                 Notification.error("Error Occured while saving Policy.");
@@ -196,7 +176,6 @@
     };
 
     $scope.validatePolicy = function(policy){
-        console.log(policy);
         document.getElementById("validate").innerHTML = "";
         var uuu = "policyController/validate_policy.htm";
          var postData={policyData: policy};
@@ -230,7 +209,6 @@
                          }
                          
                  });
-                 console.log($scope.data);
              },
              error : function(data){
                  Notification.error("Validation Failed.");
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js
index 3e75e05..695cb42 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/BRMSRawPolicyController.js
@@ -17,7 +17,9 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-angular.module('abs').controller('brmsRawPolicyController', ['$scope', '$window', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, $window, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) {
+angular.module('abs').controller('brmsRawPolicyController',
+    ['$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_Raw"
-    	}
+    $scope.temp.policy = {
+        policyType : "Config",
+        configPolicyType : "BRMS_Raw"
+    }
     }
     
     $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,127 +46,112 @@
     };
     
     $('#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');
+    }
     });
     
     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);
-    }, function (error) {
-    	console.log("failed");
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.brmsControllerDatas = JSON.parse($scope.data.brmsControllerDictionaryDatas);
     });
 
     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);
-    }, function (error) {
-    	console.log("failed");
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.brmsDependencyDatas = JSON.parse($scope.data.brmsDependencyDictionaryDatas);
     });
 
     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");
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
     });
 
     $scope.saveBrmsRawPolicy = 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};
-		$.ajax({
-			type : 'POST',
-			url : uuu,
-			dataType: 'json',
-			contentType: 'application/json',
-			data: JSON.stringify(postData),
-			success : function(data){
-				$scope.$apply(function(){
-					$scope.data=data.policyData;
-					if($scope.data == 'success'){
-						$scope.temp.policy.readOnly = 'true';
-						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.");
-				$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.data=data.policyData;
+        if($scope.data == 'success'){
+            $scope.temp.policy.readOnly = 'true';
+            Notification.success("Policy Saved Successfully.");	
+        }else if ($scope.data == 'PolicyExists'){
+            $scope.savebutton = true;
+            Notification.error("Policy Already Exists with Same Name in Scope.");
+        }
+        });
+    },
+    error : function(data){
+        Notification.error("Error Occured while saving Policy.");
+        $scope.savebutton = true;
+    }
+    });
     };
     
     $scope.validatePolicy = function(policy){
-    	console.log(policy);
-    	document.getElementById("validate").innerHTML = "";
+    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";
- 							}	
- 						}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.");
- 			}
- 		});
+     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";
+             }	
+             }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;
+             }
+             
+         });
+     },
+     error : function(data){
+         Notification.error("Validation Failed.");
+     }
+     });
     };
     
     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}];
     $scope.addNewChoice = function() {
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js
index 7bd04c9..a8368a0 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/ClosedLoopFaultController.js
@@ -17,26 +17,28 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-angular.module("abs").controller('clFaultController', ['$scope', '$window', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function($scope, $window, PolicyAppService, PolicyNavigator, modalService, $modal, Notification){
-	$("#dialog").hide();
+angular.module("abs").controller('clFaultController', 
+    ['$scope', '$window', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', 
+    function($scope, $window, PolicyAppService, PolicyNavigator, modalService, $modal, Notification){
+    $("#dialog").hide();
 
-	$scope.policyNavigator;
-	$scope.savebutton = true;
-	$scope.refreshCheck = false;
+    $scope.policyNavigator;
+    $scope.savebutton = true;
+    $scope.refreshCheck = false;
     
-	if(!$scope.temp.policy.editPolicy  && !$scope.temp.policy.readOnly){
-    	$scope.temp.policy = {
-    		policyType : "Config",
-    		configPolicyType : "ClosedLoop_Fault"
-    	}
+    if(!$scope.temp.policy.editPolicy  && !$scope.temp.policy.readOnly){
+        $scope.temp.policy = {
+            policyType : "Config",
+            configPolicyType : "ClosedLoop_Fault"
+        }
     }
     
     $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,780 +46,749 @@
     };
     
     $('#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.triggerTrapSignatures == undefined){
-		$scope.temp.policy.triggerTrapSignatures = [];
-		$scope.temp.policy.triggerfaultSignatures = [];
-	}
-	var trapCollection = [];
-	var faultCollection = [];
-	if($scope.varbindDictionaryDatas == undefined){
-		$scope.varbindDictionaryDatas = [];
-	}
-	
-	$scope.init = function(data){
-		if(data != undefined && $scope.temp.policy.triggerTrapSignatures.length == 0){
-			$scope.jsonData = data; 
-			if($scope.jsonData.triggerSignaturesUsedForUI != null){
-				if($scope.jsonData.triggerSignaturesUsedForUI.signatures != null){
-					$scope.temp.policy.triggerTrapSignatures = {Trap1 : [], Trap2 : [], Trap3 : [], Trap4 : [], Trap5 : [], Trap6 : []};
-					var splitTraps = $scope.jsonData.triggerSignaturesUsedForUI.signatures.split("#!?!"); 
-					if(splitTraps.length > 1){
-						$scope.triggerdisabled = false;
-						var indexId = "Trap1";
-						trapCollection.push(indexId);
-						$scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
-						$scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+1});
-						var splitTrap1 = splitTraps[0];
-						var splitEachTrap = splitTrap1.split("#!");
-						for(i = 0 ; i < splitEachTrap.length; i++){
-							var splitEachRow = splitEachTrap[i].split("@!");
-							var count = i +1;
-							if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
-								var notBox = splitEachRow[0];
-								var trigger1 = splitEachRow[1];
-								var operatorBox = splitEachRow[2];
-								var trigger2 = splitEachRow[3];
-							}else{
-								var notBox = '';
-								var trigger1 = splitEachRow[0];
-								var operatorBox = splitEachRow[1];
-								var trigger2 = splitEachRow[2]; 
-							}
-							$scope.varbindDictionaryDatas.push('A'+count);
-							$scope.temp.policy.triggerTrapSignatures["Trap1"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2}); 		 
-						}
-					}
-					if(splitTraps.length > 2){
-						var indexId = "Trap2";
-						trapCollection.push(indexId);
-						$scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
-						$scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+2});
-						var splitTrap1 = splitTraps[1]; 
-						var splitEachTrap = splitTrap1.split("#!");
-						for(i = 0 ; i < splitEachTrap.length; i++){
-							var splitEachRow = splitEachTrap[i].split("@!");
-							var count = i +1;
-							if(splitEachRow[0] == 'NOT' || splitEachRow[0] == ''){
-								var notBox = splitEachRow[0];
-								var trigger1 = splitEachRow[1];
-								var operatorBox = splitEachRow[2];
-								var trigger2 = splitEachRow[3];
-							}else{
-								var notBox = '';
-								var trigger1 = splitEachRow[0];
-								var operatorBox = splitEachRow[1];
-								var trigger2 = splitEachRow[2]; 
-							}
-							$scope.varbindDictionaryDatas.push('A'+count);
-							$scope.temp.policy.triggerTrapSignatures["Trap2"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2}); 		 
-						}
-					}
-					if(splitTraps.length > 3){
-						var indexId = "Trap3";
-						trapCollection.push(indexId);
-						$scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
-						$scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+3});
-						var splitTrap1 = splitTraps[2]; 
-						var splitEachTrap = splitTrap1.split("#!");
-						for(i = 0 ; i < splitEachTrap.length; i++){
-							var splitEachRow = splitEachTrap[i].split("@!");
-							var count = i +1;
-							if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
-								var notBox = splitEachRow[0];
-								var trigger1 = splitEachRow[1];
-								var operatorBox = splitEachRow[2];
-								var trigger2 = splitEachRow[3];
-							}else{
-								var notBox = '';
-								var trigger1 = splitEachRow[0];
-								var operatorBox = splitEachRow[1];
-								var trigger2 = splitEachRow[2]; 
-							}
-							$scope.varbindDictionaryDatas.push('A'+count);
-							$scope.temp.policy.triggerTrapSignatures["Trap3"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2}); 		 
-						}
-					}
-					if(splitTraps.length > 4){
-						var indexId = "Trap4";
-						trapCollection.push(indexId);
-						$scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
-						$scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+4});
-						var splitTrap1 = splitTraps[3]; 
-						var splitEachTrap = splitTrap1.split("#!");
-						for(i = 0 ; i < splitEachTrap.length; i++){
-							var splitEachRow = splitEachTrap[i].split("@!");
-							var count = i +1;
-							if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
-								var notBox = splitEachRow[0];
-								var trigger1 = splitEachRow[1];
-								var operatorBox = splitEachRow[2];
-								var trigger2 = splitEachRow[3];
-							}else{
-								var notBox = '';
-								var trigger1 = splitEachRow[0];
-								var operatorBox = splitEachRow[1];
-								var trigger2 = splitEachRow[2]; 
-							}
-							$scope.varbindDictionaryDatas.push('A'+count);
-							$scope.temp.policy.triggerTrapSignatures["Trap4"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2}); 		 
-						}
-					}
-					if(splitTraps.length > 5){
-						var indexId = "Trap5";
-						trapCollection.push(indexId);
-						$scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
-						$scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+5});
-						var splitTrap1 = splitTraps[4]; 
-						var splitEachTrap = splitTrap1.split("#!");
-						for(i = 0 ; i < splitEachTrap.length; i++){
-							var splitEachRow = splitEachTrap[i].split("@!");
-							var count = i +1;
-							if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
-								var notBox = splitEachRow[0];
-								var trigger1 = splitEachRow[1];
-								var operatorBox = splitEachRow[2];
-								var trigger2 = splitEachRow[3];
-							}else{
-								var notBox = '';
-								var trigger1 = splitEachRow[0];
-								var operatorBox = splitEachRow[1];
-								var trigger2 = splitEachRow[2]; 
-							}
-							$scope.varbindDictionaryDatas.push('A'+count);
-							$scope.temp.policy.triggerTrapSignatures["Trap5"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2}); 		 
-						} 
-					}
-					if(splitTraps.length > 6){
-						var indexId = "Trap6";
-						trapCollection.push(indexId);
-						$scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
-						$scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+6});
-						var splitTrap1 = splitTraps[5]; 
-						var splitEachTrap = splitTrap1.split("#!");
-						for(i = 0 ; i < splitEachTrap.length; i++){
-							var splitEachRow = splitEachTrap[i].split("@!");
-							var count = i +1;
-							if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
-								var notBox = splitEachRow[0];
-								var trigger1 = splitEachRow[1];
-								var operatorBox = splitEachRow[2];
-								var trigger2 = splitEachRow[3];
-							}else{
-								var notBox = '';
-								var trigger1 = splitEachRow[0];
-								var operatorBox = splitEachRow[1];
-								var trigger2 = splitEachRow[2]; 
-							}
-							$scope.varbindDictionaryDatas.push('A'+count);
-							$scope.temp.policy.triggerTrapSignatures["Trap6"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2}); 		 
-						}
-					}
-					if($scope.jsonData.triggerSignaturesUsedForUI.connectSignatures != null){
-						var splitConnectTraps = $scope.jsonData.triggerSignaturesUsedForUI.connectSignatures.split("#!?!"); 
-						for(i=0; i < splitConnectTraps.length; i++){
-							if(splitConnectTraps[i] != ""){
-								var newConnectTrapItemNo = i+1;
-								var connects = splitConnectTraps[i].split("@!");
-								if(connects[0] == 'NOT' || connects[0] ==''){
-									var notBox = connects[0];
-									var connectTrap1 = connects[1];
-									var trapCount1 = connects[2];
-									var operatorBox = connects[3];
-									var connectTrap2 = connects[4];
-									var trapCount2 = connects[5];
-								}else{
-									var notBox = '';
-									var connectTrap1 = connects[0];
-									var trapCount1 = connects[1];
-									var operatorBox = connects[2];
-									var connectTrap2 = connects[3];
-									var trapCount2 = connects[4]; 
-								}
-								$scope.temp.policy.connecttriggerSignatures.push({'id':'C'+newConnectTrapItemNo,'notBox' : notBox , 'connectTrap1': connectTrap1,'trapCount1' : trapCount1, 
-									'operatorBox': operatorBox, 'connectTrap2': connectTrap2,'trapCount2' : trapCount2}); 
-							}
-						}				
-					}
-				}
-			}
-			if($scope.jsonData.verificationSignaturesUsedForUI != null){
-				if($scope.jsonData.verificationSignaturesUsedForUI.signatures != null){
-					$scope.temp.policy.triggerfaultSignatures = {Fault1 : [], Fault2 : [],  Fault3 : [],  Fault4 : [],  Fault5 : [],  Fault6 : []};
-					var splitTraps = $scope.jsonData.verificationSignaturesUsedForUI.signatures.split("#!?!"); 
-					if(splitTraps.length > 1){
-						$scope.verificationdisabled = false;
-						var indexId = "Fault1";
-						faultCollection.push(indexId);
-						$scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
-						$scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+1});
-						var splitTrap1 = splitTraps[0];
-						var splitEachTrap = splitTrap1.split("#!");
-						for(i = 0 ; i < splitEachTrap.length; i++){
-							var splitEachRow = splitEachTrap[i].split("@!");
-							var count = i +1;
-							if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
-								var notBox = splitEachRow[0];
-								var trigger1 = splitEachRow[1];
-								var operatorBox = splitEachRow[2];
-								var trigger2 = splitEachRow[3];
-							}else{
-								var notBox = '';
-								var trigger1 = splitEachRow[0];
-								var operatorBox = splitEachRow[1];
-								var trigger2 = splitEachRow[2]; 
-							}
-							$scope.varbindDictionaryDatas.push('A'+count);
-							$scope.temp.policy.triggerfaultSignatures["Fault1"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2}); 		 
-						}
-					}
-					if(splitTraps.length > 2){
-						var indexId = "Fault2";
-						faultCollection.push(indexId);
-						$scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
-						$scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+2});
-						var splitTrap1 = splitTraps[1]; 
-						var splitEachTrap = splitTrap1.split("#!");
-						for(i = 0 ; i < splitEachTrap.length; i++){
-							var splitEachRow = splitEachTrap[i].split("@!");
-							var count = i +1;
-							if(splitEachRow[0] == 'NOT' || splitEachRow[0] == ''){
-								var notBox = splitEachRow[0];
-								var trigger1 = splitEachRow[1];
-								var operatorBox = splitEachRow[2];
-								var trigger2 = splitEachRow[3];
-							}else{
-								var notBox = '';
-								var trigger1 = splitEachRow[0];
-								var operatorBox = splitEachRow[1];
-								var trigger2 = splitEachRow[2]; 
-							}
-							$scope.varbindDictionaryDatas.push('A'+count);
-							$scope.temp.policy.triggerfaultSignatures["Fault2"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2}); 		 
-						}
-					}
-					if(splitTraps.length > 3){
-						var indexId = "Fault3";
-						faultCollection.push(indexId);
-						$scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
-						$scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+3});
-						var splitTrap1 = splitTraps[2]; 
-						var splitEachTrap = splitTrap1.split("#!");
-						for(i = 0 ; i < splitEachTrap.length; i++){
-							var splitEachRow = splitEachTrap[i].split("@!");
-							var count = i +1;
-							if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
-								var notBox = splitEachRow[0];
-								var trigger1 = splitEachRow[1];
-								var operatorBox = splitEachRow[2];
-								var trigger2 = splitEachRow[3];
-							}else{
-								var notBox = '';
-								var trigger1 = splitEachRow[0];
-								var operatorBox = splitEachRow[1];
-								var trigger2 = splitEachRow[2]; 
-							}
-							$scope.varbindDictionaryDatas.push('A'+count);
-							$scope.temp.policy.triggerfaultSignatures["Fault3"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2}); 		 
-						}
-					}
-					if(splitTraps.length > 4){
-						var indexId = "Fault4";
-						faultCollection.push(indexId);
-						$scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
-						$scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+4});
-						var splitTrap1 = splitTraps[3]; 
-						var splitEachTrap = splitTrap1.split("#!");
-						for(i = 0 ; i < splitEachTrap.length; i++){
-							var splitEachRow = splitEachTrap[i].split("@!");
-							var count = i +1;
-							if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
-								var notBox = splitEachRow[0];
-								var trigger1 = splitEachRow[1];
-								var operatorBox = splitEachRow[2];
-								var trigger2 = splitEachRow[3];
-							}else{
-								var notBox = '';
-								var trigger1 = splitEachRow[0];
-								var operatorBox = splitEachRow[1];
-								var trigger2 = splitEachRow[2]; 
-							}
-							$scope.varbindDictionaryDatas.push('A'+count);
-							$scope.temp.policy.triggerfaultSignatures["Fault4"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2}); 		 
-						}
-					}
-					if(splitTraps.length > 5){
-						var indexId = "Fault5";
-						faultCollection.push(indexId);
-						$scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
-						$scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+5});
-						var splitTrap1 = splitTraps[4]; 
-						var splitEachTrap = splitTrap1.split("#!");
-						for(i = 0 ; i < splitEachTrap.length; i++){
-							var splitEachRow = splitEachTrap[i].split("@!");
-							var count = i +1;
-							if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
-								var notBox = splitEachRow[0];
-								var trigger1 = splitEachRow[1];
-								var operatorBox = splitEachRow[2];
-								var trigger2 = splitEachRow[3];
-							}else{
-								var notBox = '';
-								var trigger1 = splitEachRow[0];
-								var operatorBox = splitEachRow[1];
-								var trigger2 = splitEachRow[2]; 
-							}
-							$scope.varbindDictionaryDatas.push('A'+count);
-							$scope.temp.policy.triggerfaultSignatures["Fault5"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2}); 		 
-						} 
-					}
-					if(splitTraps.length > 6){
-						var indexId = "Fault6";
-						faultCollection.push(indexId);
-						$scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
-						$scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+6});
-						var splitTrap1 = splitTraps[5]; 
-						var splitEachTrap = splitTrap1.split("#!");
-						for(i = 0 ; i < splitEachTrap.length; i++){
-							var splitEachRow = splitEachTrap[i].split("@!");
-							var count = i +1;
-							if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
-								var notBox = splitEachRow[0];
-								var trigger1 = splitEachRow[1];
-								var operatorBox = splitEachRow[2];
-								var trigger2 = splitEachRow[3];
-							}else{
-								var notBox = '';
-								var trigger1 = splitEachRow[0];
-								var operatorBox = splitEachRow[1];
-								var trigger2 = splitEachRow[2]; 
-							}
-							$scope.varbindDictionaryDatas.push('A'+count);
-							$scope.temp.policy.triggerfaultSignatures["Fault6"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2}); 		 
-						}
-					}
-
-					if($scope.jsonData.verificationSignaturesUsedForUI.connectSignatures != null){
-						var splitConnectTraps = $scope.jsonData.verificationSignaturesUsedForUI.connectSignatures.split("#!?!"); 
-						for(i=0; i < splitConnectTraps.length; i++){
-							if(splitConnectTraps[i] != ""){
-								var newConnectTrapItemNo = i+1;
-								var connects = splitConnectTraps[i].split("@!");
-								if(connects[0] == 'NOT' || connects[0] ==''){
-									var notBox = connects[0];
-									var connectTrap1 = connects[1];
-									var trapCount1 = connects[2];
-									var operatorBox = connects[3];
-									var connectTrap2 = connects[4];
-									var trapCount2 = connects[5];
-								}else{
-									var notBox = '';
-									var connectTrap1 = connects[0];
-									var trapCount1 = connects[1];
-									var operatorBox = connects[2];
-									var connectTrap2 = connects[3];
-									var trapCount2 = connects[4]; 
-								}
-								$scope.temp.policy.connectVerificationSignatures.push({'id':'C'+newConnectTrapItemNo,'notBox' : notBox , 'connectTrap1': connectTrap1,'trapCount1' : trapCount1, 
-									'operatorBox': operatorBox, 'connectTrap2': connectTrap2,'trapCount2' : trapCount2}); 
-							}
-						}				
-					}
-				}
-			}
-		}
-
-	};
-
-	if($scope.temp.policy.readOnly){
-		$scope.triggerdisabled = true;
-		$scope.verificationdisabled = true;
-	}else{
-		$scope.triggerdisabled = false;
-		$scope.verificationdisabled = 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('getDictionary/get_PEPOptionsDataByName').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.pepOptionsDictionaryDatas = JSON.parse($scope.data.pepOptionsDictionaryDatas);
-		console.log($scope.pepOptionsDictionaryDatas);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	PolicyAppService.getData('getDictionary/get_PEPOptionsData').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.pepOptionsDictionaryDataEntity = JSON.parse($scope.data.pepOptionsDictionaryDatas);
-		console.log($scope.pepOptionsDictionaryDataEntity);
-	}, function (error) {
-		console.log("failed");
-	});
-
-	PolicyAppService.getData('getDictionary/get_VarbindDictionaryDataByName').then(function (data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.varbindDictionaryDatas = JSON.parse($scope.data.varbindDictionaryDatas);
-		console.log($scope.varbindDictionaryDatas);
-	}, 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);
-		console.log($scope.vnfTypeDictionaryDatas);
-	}, 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);
-		console.log($scope.vsclActionDictionaryDatas);
-	}, 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.pepActionDictionaryDatas = [];
+    if($scope.temp.policy.triggerTrapSignatures == undefined){
+        $scope.temp.policy.triggerTrapSignatures = [];
+        $scope.temp.policy.triggerfaultSignatures = [];
+    }
+    var trapCollection = [];
+    var faultCollection = [];
+    if($scope.varbindDictionaryDatas == undefined){
+        $scope.varbindDictionaryDatas = [];
+    }
+    
+    $scope.init = function(data){
+        if(data != undefined && $scope.temp.policy.triggerTrapSignatures.length == 0){
+            $scope.jsonData = data; 
+            if($scope.jsonData.triggerSignaturesUsedForUI != null){
+                if($scope.jsonData.triggerSignaturesUsedForUI.signatures != null){
+                    $scope.temp.policy.triggerTrapSignatures = {Trap1 : [], Trap2 : [], Trap3 : [], Trap4 : [], Trap5 : [], Trap6 : []};
+                    var splitTraps = $scope.jsonData.triggerSignaturesUsedForUI.signatures.split("#!?!"); 
+                    if(splitTraps.length > 1){
+                        $scope.triggerdisabled = false;
+                        var indexId = "Trap1";
+                        trapCollection.push(indexId);
+                        $scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
+                        $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+1});
+                        var splitTrap1 = splitTraps[0];
+                        var splitEachTrap = splitTrap1.split("#!");
+                        for(i = 0 ; i < splitEachTrap.length; i++){
+                            var splitEachRow = splitEachTrap[i].split("@!");
+                            var count = i +1;
+                            if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+                                var notBox = splitEachRow[0];
+                                var trigger1 = splitEachRow[1];
+                                var operatorBox = splitEachRow[2];
+                                var trigger2 = splitEachRow[3];
+                            }else{
+                                var notBox = '';
+                                var trigger1 = splitEachRow[0];
+                                var operatorBox = splitEachRow[1];
+                                var trigger2 = splitEachRow[2]; 
+                            }
+                            $scope.varbindDictionaryDatas.push('A'+count);
+                            $scope.temp.policy.triggerTrapSignatures["Trap1"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});          
+                        }
+                    }
+                    if(splitTraps.length > 2){
+                        var indexId = "Trap2";
+                        trapCollection.push(indexId);
+                        $scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
+                        $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+2});
+                        var splitTrap1 = splitTraps[1]; 
+                        var splitEachTrap = splitTrap1.split("#!");
+                        for(i = 0 ; i < splitEachTrap.length; i++){
+                            var splitEachRow = splitEachTrap[i].split("@!");
+                            var count = i +1;
+                            if(splitEachRow[0] == 'NOT' || splitEachRow[0] == ''){
+                                var notBox = splitEachRow[0];
+                                var trigger1 = splitEachRow[1];
+                                var operatorBox = splitEachRow[2];
+                                var trigger2 = splitEachRow[3];
+                            }else{
+                                var notBox = '';
+                                var trigger1 = splitEachRow[0];
+                                var operatorBox = splitEachRow[1];
+                                var trigger2 = splitEachRow[2]; 
+                            }
+                            $scope.varbindDictionaryDatas.push('A'+count);
+                            $scope.temp.policy.triggerTrapSignatures["Trap2"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});          
+                        }
+                    }
+                    if(splitTraps.length > 3){
+                        var indexId = "Trap3";
+                        trapCollection.push(indexId);
+                        $scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
+                        $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+3});
+                        var splitTrap1 = splitTraps[2]; 
+                        var splitEachTrap = splitTrap1.split("#!");
+                        for(i = 0 ; i < splitEachTrap.length; i++){
+                            var splitEachRow = splitEachTrap[i].split("@!");
+                            var count = i +1;
+                            if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+                                var notBox = splitEachRow[0];
+                                var trigger1 = splitEachRow[1];
+                                var operatorBox = splitEachRow[2];
+                                var trigger2 = splitEachRow[3];
+                            }else{
+                                var notBox = '';
+                                var trigger1 = splitEachRow[0];
+                                var operatorBox = splitEachRow[1];
+                                var trigger2 = splitEachRow[2]; 
+                            }
+                            $scope.varbindDictionaryDatas.push('A'+count);
+                            $scope.temp.policy.triggerTrapSignatures["Trap3"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});          
+                        }
+                    }
+                    if(splitTraps.length > 4){
+                        var indexId = "Trap4";
+                        trapCollection.push(indexId);
+                        $scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
+                        $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+4});
+                        var splitTrap1 = splitTraps[3]; 
+                        var splitEachTrap = splitTrap1.split("#!");
+                        for(i = 0 ; i < splitEachTrap.length; i++){
+                            var splitEachRow = splitEachTrap[i].split("@!");
+                            var count = i +1;
+                            if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+                                var notBox = splitEachRow[0];
+                                var trigger1 = splitEachRow[1];
+                                var operatorBox = splitEachRow[2];
+                                var trigger2 = splitEachRow[3];
+                            }else{
+                                var notBox = '';
+                                var trigger1 = splitEachRow[0];
+                                var operatorBox = splitEachRow[1];
+                                var trigger2 = splitEachRow[2]; 
+                            }
+                            $scope.varbindDictionaryDatas.push('A'+count);
+                            $scope.temp.policy.triggerTrapSignatures["Trap4"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});          
+                        }
+                    }
+                    if(splitTraps.length > 5){
+                        var indexId = "Trap5";
+                        trapCollection.push(indexId);
+                        $scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
+                        $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+5});
+                        var splitTrap1 = splitTraps[4]; 
+                        var splitEachTrap = splitTrap1.split("#!");
+                        for(i = 0 ; i < splitEachTrap.length; i++){
+                            var splitEachRow = splitEachTrap[i].split("@!");
+                            var count = i +1;
+                            if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+                                var notBox = splitEachRow[0];
+                                var trigger1 = splitEachRow[1];
+                                var operatorBox = splitEachRow[2];
+                                var trigger2 = splitEachRow[3];
+                            }else{
+                                var notBox = '';
+                                var trigger1 = splitEachRow[0];
+                                var operatorBox = splitEachRow[1];
+                                var trigger2 = splitEachRow[2]; 
+                            }
+                            $scope.varbindDictionaryDatas.push('A'+count);
+                            $scope.temp.policy.triggerTrapSignatures["Trap5"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});          
+                        } 
+                    }
+                    if(splitTraps.length > 6){
+                        var indexId = "Trap6";
+                        trapCollection.push(indexId);
+                        $scope.temp.policy.triggerTrapSignatures[indexId.replace(/['"]+/g, '')] = [];
+                        $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+6});
+                        var splitTrap1 = splitTraps[5]; 
+                        var splitEachTrap = splitTrap1.split("#!");
+                        for(i = 0 ; i < splitEachTrap.length; i++){
+                            var splitEachRow = splitEachTrap[i].split("@!");
+                            var count = i +1;
+                            if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+                                var notBox = splitEachRow[0];
+                                var trigger1 = splitEachRow[1];
+                                var operatorBox = splitEachRow[2];
+                                var trigger2 = splitEachRow[3];
+                            }else{
+                                var notBox = '';
+                                var trigger1 = splitEachRow[0];
+                                var operatorBox = splitEachRow[1];
+                                var trigger2 = splitEachRow[2]; 
+                            }
+                            $scope.varbindDictionaryDatas.push('A'+count);
+                            $scope.temp.policy.triggerTrapSignatures["Trap6"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});          
+                        }
+                    }
+                    if($scope.jsonData.triggerSignaturesUsedForUI.connectSignatures != null){
+                        var splitConnectTraps = $scope.jsonData.triggerSignaturesUsedForUI.connectSignatures.split("#!?!"); 
+                        for(i=0; i < splitConnectTraps.length; i++){
+                            if(splitConnectTraps[i] != ""){
+                                var newConnectTrapItemNo = i+1;
+                                var connects = splitConnectTraps[i].split("@!");
+                                if(connects[0] == 'NOT' || connects[0] ==''){
+                                    var notBox = connects[0];
+                                    var connectTrap1 = connects[1];
+                                    var trapCount1 = connects[2];
+                                    var operatorBox = connects[3];
+                                    var connectTrap2 = connects[4];
+                                    var trapCount2 = connects[5];
+                                }else{
+                                    var notBox = '';
+                                    var connectTrap1 = connects[0];
+                                    var trapCount1 = connects[1];
+                                    var operatorBox = connects[2];
+                                    var connectTrap2 = connects[3];
+                                    var trapCount2 = connects[4]; 
+                                }
+                                $scope.temp.policy.connecttriggerSignatures.push({'id':'C'+newConnectTrapItemNo,'notBox' : notBox , 'connectTrap1': connectTrap1,'trapCount1' : trapCount1, 
+                                    'operatorBox': operatorBox, 'connectTrap2': connectTrap2,'trapCount2' : trapCount2}); 
+                            }
+                        }                
+                    }
+                }
+            }
+            if($scope.jsonData.verificationSignaturesUsedForUI != null){
+                if($scope.jsonData.verificationSignaturesUsedForUI.signatures != null){
+                    $scope.temp.policy.triggerfaultSignatures = {Fault1 : [], Fault2 : [],  Fault3 : [],  Fault4 : [],  Fault5 : [],  Fault6 : []};
+                    var splitTraps = $scope.jsonData.verificationSignaturesUsedForUI.signatures.split("#!?!"); 
+                    if(splitTraps.length > 1){
+                        $scope.verificationdisabled = false;
+                        var indexId = "Fault1";
+                        faultCollection.push(indexId);
+                        $scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
+                        $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+1});
+                        var splitTrap1 = splitTraps[0];
+                        var splitEachTrap = splitTrap1.split("#!");
+                        for(i = 0 ; i < splitEachTrap.length; i++){
+                            var splitEachRow = splitEachTrap[i].split("@!");
+                            var count = i +1;
+                            if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+                                var notBox = splitEachRow[0];
+                                var trigger1 = splitEachRow[1];
+                                var operatorBox = splitEachRow[2];
+                                var trigger2 = splitEachRow[3];
+                            }else{
+                                var notBox = '';
+                                var trigger1 = splitEachRow[0];
+                                var operatorBox = splitEachRow[1];
+                                var trigger2 = splitEachRow[2]; 
+                            }
+                            $scope.varbindDictionaryDatas.push('A'+count);
+                            $scope.temp.policy.triggerfaultSignatures["Fault1"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});          
+                        }
+                    }
+                    if(splitTraps.length > 2){
+                        var indexId = "Fault2";
+                        faultCollection.push(indexId);
+                        $scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
+                        $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+2});
+                        var splitTrap1 = splitTraps[1]; 
+                        var splitEachTrap = splitTrap1.split("#!");
+                        for(i = 0 ; i < splitEachTrap.length; i++){
+                            var splitEachRow = splitEachTrap[i].split("@!");
+                            var count = i +1;
+                            if(splitEachRow[0] == 'NOT' || splitEachRow[0] == ''){
+                                var notBox = splitEachRow[0];
+                                var trigger1 = splitEachRow[1];
+                                var operatorBox = splitEachRow[2];
+                                var trigger2 = splitEachRow[3];
+                            }else{
+                                var notBox = '';
+                                var trigger1 = splitEachRow[0];
+                                var operatorBox = splitEachRow[1];
+                                var trigger2 = splitEachRow[2]; 
+                            }
+                            $scope.varbindDictionaryDatas.push('A'+count);
+                            $scope.temp.policy.triggerfaultSignatures["Fault2"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});          
+                        }
+                    }
+                    if(splitTraps.length > 3){
+                        var indexId = "Fault3";
+                        faultCollection.push(indexId);
+                        $scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
+                        $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+3});
+                        var splitTrap1 = splitTraps[2]; 
+                        var splitEachTrap = splitTrap1.split("#!");
+                        for(i = 0 ; i < splitEachTrap.length; i++){
+                            var splitEachRow = splitEachTrap[i].split("@!");
+                            var count = i +1;
+                            if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+                                var notBox = splitEachRow[0];
+                                var trigger1 = splitEachRow[1];
+                                var operatorBox = splitEachRow[2];
+                                var trigger2 = splitEachRow[3];
+                            }else{
+                                var notBox = '';
+                                var trigger1 = splitEachRow[0];
+                                var operatorBox = splitEachRow[1];
+                                var trigger2 = splitEachRow[2]; 
+                            }
+                            $scope.varbindDictionaryDatas.push('A'+count);
+                            $scope.temp.policy.triggerfaultSignatures["Fault3"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});          
+                        }
+                    }
+                    if(splitTraps.length > 4){
+                        var indexId = "Fault4";
+                        faultCollection.push(indexId);
+                        $scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
+                        $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+4});
+                        var splitTrap1 = splitTraps[3]; 
+                        var splitEachTrap = splitTrap1.split("#!");
+                        for(i = 0 ; i < splitEachTrap.length; i++){
+                            var splitEachRow = splitEachTrap[i].split("@!");
+                            var count = i +1;
+                            if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+                                var notBox = splitEachRow[0];
+                                var trigger1 = splitEachRow[1];
+                                var operatorBox = splitEachRow[2];
+                                var trigger2 = splitEachRow[3];
+                            }else{
+                                var notBox = '';
+                                var trigger1 = splitEachRow[0];
+                                var operatorBox = splitEachRow[1];
+                                var trigger2 = splitEachRow[2]; 
+                            }
+                            $scope.varbindDictionaryDatas.push('A'+count);
+                            $scope.temp.policy.triggerfaultSignatures["Fault4"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});          
+                        }
+                    }
+                    if(splitTraps.length > 5){
+                        var indexId = "Fault5";
+                        faultCollection.push(indexId);
+                        $scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
+                        $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+5});
+                        var splitTrap1 = splitTraps[4]; 
+                        var splitEachTrap = splitTrap1.split("#!");
+                        for(i = 0 ; i < splitEachTrap.length; i++){
+                            var splitEachRow = splitEachTrap[i].split("@!");
+                            var count = i +1;
+                            if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+                                var notBox = splitEachRow[0];
+                                var trigger1 = splitEachRow[1];
+                                var operatorBox = splitEachRow[2];
+                                var trigger2 = splitEachRow[3];
+                            }else{
+                                var notBox = '';
+                                var trigger1 = splitEachRow[0];
+                                var operatorBox = splitEachRow[1];
+                                var trigger2 = splitEachRow[2]; 
+                            }
+                            $scope.varbindDictionaryDatas.push('A'+count);
+                            $scope.temp.policy.triggerfaultSignatures["Fault5"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});          
+                        } 
+                    }
+                    if(splitTraps.length > 6){
+                        var indexId = "Fault6";
+                        faultCollection.push(indexId);
+                        $scope.temp.policy.triggerfaultSignatures[indexId.replace(/['"]+/g, '')] = [];
+                        $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+6});
+                        var splitTrap1 = splitTraps[5]; 
+                        var splitEachTrap = splitTrap1.split("#!");
+                        for(i = 0 ; i < splitEachTrap.length; i++){
+                            var splitEachRow = splitEachTrap[i].split("@!");
+                            var count = i +1;
+                            if(splitEachRow[0] == 'NOT' || splitEachRow[0] ==''){
+                                var notBox = splitEachRow[0];
+                                var trigger1 = splitEachRow[1];
+                                var operatorBox = splitEachRow[2];
+                                var trigger2 = splitEachRow[3];
+                            }else{
+                                var notBox = '';
+                                var trigger1 = splitEachRow[0];
+                                var operatorBox = splitEachRow[1];
+                                var trigger2 = splitEachRow[2]; 
+                            }
+                            $scope.varbindDictionaryDatas.push('A'+count);
+                            $scope.temp.policy.triggerfaultSignatures["Fault6"].push({'id':'A'+count, 'notBox' : notBox , 'trigger1': trigger1 , 'operatorBox' : operatorBox, 'trigger2': trigger2});          
+                        }
+                    }
 
-	$scope.getPepActionValues = function(pepOptionValue){
-		for (var i = 0; i < $scope.pepOptionsDictionaryDataEntity.length; ++i) {
-    	    var obj = $scope.pepOptionsDictionaryDataEntity[i];
-    	    if (obj.pepName == pepOptionValue){
-    	    	var splitAlarm = obj.actions.split(':#@');
-    	    	for (var j = 0; j < splitAlarm.length; ++j) {
-    	    		$scope.pepActionDictionaryDatas.push(splitAlarm[j].split('=#@')[0]);
-    	    	}
-    	    }
-    	}
-	};
+                    if($scope.jsonData.verificationSignaturesUsedForUI.connectSignatures != null){
+                        var splitConnectTraps = $scope.jsonData.verificationSignaturesUsedForUI.connectSignatures.split("#!?!"); 
+                        for(i=0; i < splitConnectTraps.length; i++){
+                            if(splitConnectTraps[i] != ""){
+                                var newConnectTrapItemNo = i+1;
+                                var connects = splitConnectTraps[i].split("@!");
+                                if(connects[0] == 'NOT' || connects[0] ==''){
+                                    var notBox = connects[0];
+                                    var connectTrap1 = connects[1];
+                                    var trapCount1 = connects[2];
+                                    var operatorBox = connects[3];
+                                    var connectTrap2 = connects[4];
+                                    var trapCount2 = connects[5];
+                                }else{
+                                    var notBox = '';
+                                    var connectTrap1 = connects[0];
+                                    var trapCount1 = connects[1];
+                                    var operatorBox = connects[2];
+                                    var connectTrap2 = connects[3];
+                                    var trapCount2 = connects[4]; 
+                                }
+                                $scope.temp.policy.connectVerificationSignatures.push({'id':'C'+newConnectTrapItemNo,'notBox' : notBox , 'connectTrap1': connectTrap1,'trapCount1' : trapCount1, 
+                                    'operatorBox': operatorBox, 'connectTrap2': connectTrap2,'trapCount2' : trapCount2}); 
+                            }
+                        }                
+                    }
+                }
+            }
+        }
 
-	function trapData(){
-		var data = {};
-		if($scope.temp.policy.triggerTrapSignatures.length == 1 || $scope.temp.policy.triggerTrapSignatures["Trap1"] != null){
-			 data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1 }
-		}
-		if($scope.temp.policy.triggerTrapSignatures.length == 2 || $scope.temp.policy.triggerTrapSignatures["Trap2"] != null){
-			 data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1,  trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2}
-		}
-		if($scope.temp.policy.triggerTrapSignatures.length == 3 || $scope.temp.policy.triggerTrapSignatures["Trap3"] != null){
-			 data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1,  trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2,
-					trap3 : $scope.temp.policy.triggerTrapSignatures.Trap3}
-		}
-		if($scope.temp.policy.triggerTrapSignatures.length == 4 || $scope.temp.policy.triggerTrapSignatures["Trap4"] != null){
-			 data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1,  trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2,
-					trap3 : $scope.temp.policy.triggerTrapSignatures.Trap3,   trap4 : $scope.temp.policy.triggerTrapSignatures.Trap4}
-		}
-		if($scope.temp.policy.triggerTrapSignatures.length == 5 || $scope.temp.policy.triggerTrapSignatures["Trap5"] != null){
-			 data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1,  trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2,
-					trap3 : $scope.temp.policy.triggerTrapSignatures.Trap3,   trap4 : $scope.temp.policy.triggerTrapSignatures.Trap4,
-					trap5 : $scope.temp.policy.triggerTrapSignatures.Trap5}
-		}
-		if($scope.temp.policy.triggerTrapSignatures.length == 6 || $scope.temp.policy.triggerTrapSignatures["Trap6"] != null){
-			 data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1,  trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2,
-					trap3 : $scope.temp.policy.triggerTrapSignatures.Trap3,   trap4 : $scope.temp.policy.triggerTrapSignatures.Trap4,
-					trap5 : $scope.temp.policy.triggerTrapSignatures.Trap5, trap6 : $scope.temp.policy.triggerTrapSignatures.Trap6}
-		}	
-		return data;
-	}
-	
-	function faultDatas(){
-		var faultData = {};
-		if($scope.temp.policy.triggerfaultSignatures.length == 1 || $scope.temp.policy.triggerfaultSignatures["Fault1"] != null){
-			 faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1 }
-		}
-		if($scope.temp.policy.triggerfaultSignatures.length == 2 || $scope.temp.policy.triggerfaultSignatures["Fault2"] != null){
-			 faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1,  trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2}
-		}
-		if($scope.temp.policy.triggerfaultSignatures.length == 3 || $scope.temp.policy.triggerfaultSignatures["Fault3"] != null){
-			 faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1,  trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2,
-					trap3 : $scope.temp.policy.triggerfaultSignatures.Fault3}
-		}
-		if($scope.temp.policy.triggerTrapSignatures.length == 4 || $scope.temp.policy.triggerfaultSignatures["Fault4"] != null){
-			 faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1,  trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2,
-					trap3 : $scope.temp.policy.triggerfaultSignatures.Fault3,   trap4 : $scope.temp.policy.triggerfaultSignatures.Fault4}
-		}
-		if($scope.temp.policy.triggerfaultSignatures.length == 5 || $scope.temp.policy.triggerfaultSignatures["Fault5"] != null){
-			 faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1,  trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2,
-					trap3 : $scope.temp.policy.triggerfaultSignatures.Fault3,   trap4 : $scope.temp.policy.triggerfaultSignatures.Fault4,
-					trap5 : $scope.temp.policy.triggerfaultSignatures.Fault5}
-		}
-		if($scope.temp.policy.triggerfaultSignatures.length == 6 || $scope.temp.policy.triggerfaultSignatures["Fault6"] != null){
-			 faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1,  trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2,
-					trap3 : $scope.temp.policy.triggerfaultSignatures.Fault3,   trap4 : $scope.temp.policy.triggerfaultSignatures.Fault4,
-					trap5 : $scope.temp.policy.triggerfaultSignatures.Fault5, trap6 : $scope.temp.policy.triggerfaultSignatures.Fault6}
-		}
-		return faultData;
-	}
-	
-	$scope.saveFaultPolicy = function(policy){
-		if(policy.itemContent != undefined){
-    		$scope.refreshCheck = true; 
-        	$scope.policyNavigator = policy.itemContent;
-        	policy.itemContent = "";
-    	}
-		$scope.savebutton = false;
-		var data = trapData();
-		var faultData = faultDatas();
-		var uuu = "policycreation/save_policy";
-		var postData={policyData: policy,
-				trapData : data,
-				faultData : faultData
-		};
-		$.ajax({
-			type : 'POST',
-			url : uuu,
-			dataType: 'json',
-			contentType: 'application/json',
-			data: JSON.stringify(postData),
-			success : function(data){
-				$scope.$apply(function(){
-					$scope.data=data.policyData;
-					if($scope.data == 'success'){
-						$scope.temp.policy.readOnly = 'true';
-						$scope.pushStatus=data.policyData.split("&")[1];
-						if($scope.pushStatus=="successPush"){
-							Notification.success("Policy pushed successfully");
-						}
-						$scope.triggerdisabled = true;
-						$scope.verificationdisabled = true;
-						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.");
-			}
-		});
-	};
+    };
 
-	$scope.validatePolicy = function(policy){
-		console.log(policy);
-		document.getElementById("validate").innerHTML = "";
-		var uuu = "policyController/validate_policy.htm";
-		var data = trapData();
-		var faultData = faultDatas();
-		var postData={policyData: policy, trapData : data, faultData : faultData};
-		$.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";
-							}
-					}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;
-					}
+    if($scope.temp.policy.readOnly){
+        $scope.triggerdisabled = true;
+        $scope.verificationdisabled = true;
+    }else{
+        $scope.triggerdisabled = false;
+        $scope.verificationdisabled = false;
+    }
+    
 
-				});
-				console.log($scope.data);
-			},
-			error : function(data){
-				Notification.error("Validation Failed.");
-				$scope.savebutton = true;
-			}
-		});
-	};
-	if($scope.connectTriggerTrapsList == undefined){
-		$scope.connectTriggerTrapsList = [];
-	}
-	if($scope.temp.policy.traptriggerSignatures == undefined){
-		$scope.temp.policy.traptriggerSignatures = [];
-	}
-	
-	$scope.ItemNo = 0;
-	$scope.TriggerSignatureDatas = [{"triggerSignatures" : $scope.temp.policy.traptriggerSignatures}];
-	$scope.addTriggerButton = function() {
-		$scope.triggerdisabled = false;
-		var newItemNo = $scope.temp.policy.traptriggerSignatures.length+1;
-		$scope.ItemNo = newItemNo;
-		$scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+newItemNo});
-		$scope.connectTriggerTrapsList.push('Trap'+newItemNo);
-	};
-	$scope.removeTriggerButton = function() {
-		var lastItem = $scope.temp.policy.traptriggerSignatures.length-1;
-		$scope.temp.policy.traptriggerSignatures.splice(lastItem);
-		$scope.connectTriggerTrapsList.splice('Trap'+lastItem);
-	};
+    PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function (data) {
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);
+    });
 
-	
-	$scope.trapItemNo = 0;
-	$scope.TrapTriggerSignatureDatas = [{"triggermainSignatures" : $scope.temp.policy.triggerTrapSignatures}];
-	$scope.addTrapTriggerButton = function(indexId) {
-		if(trapCollection.indexOf(indexId) === -1){
-			$scope.temp.policy.triggerTrapSignatures[indexId] = [];
-			trapCollection.push(indexId);
-		}	
-		var newTrapItemNo = $scope.temp.policy.triggerTrapSignatures[indexId].length+1;
-		$scope.trapItemNo = newTrapItemNo;
-		$scope.temp.policy.triggerTrapSignatures.push($scope.temp.policy.triggerTrapSignatures[indexId].push({'id':'A'+newTrapItemNo}));
-		if(newTrapItemNo > 1){
-			var count = newTrapItemNo-1;
-			$scope.varbindDictionaryDatas.push('A'+count);
-		}
-	};
-	$scope.removeTrapTriggerButton = function(indexId) {
-		var lastTrapItem = $scope.temp.policy.triggerTrapSignatures[indexId].length-1;
-		var checkLastTrapItem = lastTrapItem;
-		if(checkLastTrapItem == 0){
-			trapCollection.splice(indexId);
-		}
-		$scope.temp.policy.triggerTrapSignatures[indexId].splice(lastTrapItem);
-	};
+    PolicyAppService.getData('getDictionary/get_PEPOptionsDataByName').then(function (data) {
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.pepOptionsDictionaryDatas = JSON.parse($scope.data.pepOptionsDictionaryDatas);
+    });
 
-	if($scope.temp.policy.connecttriggerSignatures == undefined){
-		$scope.temp.policy.connecttriggerSignatures = [];
-	}
-	
-	$scope.connecttrapItemNo = 0;
-	$scope.TrapConnectTriggerSignatureDatas = [{"connecttriggerSignatures" : $scope.temp.policy.connecttriggerSignatures}];
-	$scope.addTriggerConnectButton = function() {
-		var newConnectTrapItemNo = $scope.temp.policy.connecttriggerSignatures.length+1;
-		$scope.connecttrapItemNo = newConnectTrapItemNo;
-		$scope.temp.policy.connecttriggerSignatures.push({'id':'C'+newConnectTrapItemNo});
-		if(newConnectTrapItemNo >1){
-			var count = newConnectTrapItemNo-1;
-			$scope.connectTriggerTrapsList.push('C'+count);
-		}      
-	};
-	$scope.removeTriggerConnectButton = function() {
-		var lastConnectTrapItem = $scope.temp.policy.connecttriggerSignatures.length-1;
-		$scope.temp.policy.connecttriggerSignatures.splice(lastConnectTrapItem);
-		if(lastConnectTrapItem  < 1){
-			var count = lastConnectTrapItem-1;
-			$scope.connectTriggerTrapsList.splice('C'+count);
-		}
-	};
-	if($scope.connectTriggerFaultsList == undefined){
-		$scope.connectTriggerFaultsList = [];
-	}
-	if($scope.temp.policy.faulttriggerSignatures == undefined){
-		$scope.temp.policy.faulttriggerSignatures = [];
-	}
-	
-	$scope.FaultItemNo = 0;
-	$scope.FaultSignatureDatas = [{"verificationmainSignatures" : $scope.temp.policy.faulttriggerSignatures}];
-	$scope.addVerFaultButton = function() {
-		var newFaultItemNo = $scope.temp.policy.faulttriggerSignatures.length+1;
-		$scope.FaultItemNo = newFaultItemNo;
-		$scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+newFaultItemNo});
-		$scope.connectTriggerFaultsList.push('Fault'+newFaultItemNo);
-	};
-	$scope.removeVerFaultButton = function() {
-		var lastFaultItem = $scope.temp.policy.faulttriggerSignatures.length-1;
-		$scope.temp.policy.faulttriggerSignatures.splice(lastFaultItem);
-		$scope.connectTriggerFaultsList.splice('Fault'+lastFaultItem);
-	};
-	if($scope.temp.policy.triggerfaultSignatures == undefined){
-		$scope.temp.policy.triggerfaultSignatures = [];
-	}
-	
-	$scope.faultItemNo1 = 0;
-	$scope.FaultTriggerSignatureDatas = [{"verificationSignatures" : $scope.temp.policy.triggerfaultSignatures}];
-	$scope.addVerTriggerButton = function(indexId) {
-		$scope.verificationdisabled = false;
-		if(faultCollection.indexOf(indexId) === -1){
-			$scope.temp.policy.triggerfaultSignatures[indexId] = [];
-			faultCollection.push(indexId);
-		}	
-		var newFaultItemNo1 = $scope.temp.policy.triggerfaultSignatures[indexId].length+1;
-		$scope.faultItemNo1 = newFaultItemNo1; 
-		$scope.temp.policy.triggerfaultSignatures.push($scope.temp.policy.triggerfaultSignatures[indexId].push({'id':'A'+newFaultItemNo1}));
-		if(newFaultItemNo1 > 1){
-			var count = newFaultItemNo1-1;
-			$scope.varbindDictionaryDatas.push('A'+count);
-		}
-	};
-	$scope.removeVerTriggerButton = function(indexId) {
-		var lastFaultItem1 = $scope.temp.policy.triggerfaultSignatures[indexId].length-1;
-		var checkLastFaultItem = lastFaultItem1;
-		if(checkLastFaultItem == 0){
-			faultCollection.splice(indexId);
-		}
-		$scope.temp.policy.triggerfaultSignatures[indexId].splice(lastFaultItem1);
-	};
+    PolicyAppService.getData('getDictionary/get_PEPOptionsData').then(function (data) {
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.pepOptionsDictionaryDataEntity = JSON.parse($scope.data.pepOptionsDictionaryDatas);
+    });
 
-	if($scope.temp.policy.connectVerificationSignatures == undefined){
-		$scope.temp.policy.connectVerificationSignatures = [];
-	}
-	
-	$scope.connectFaultItemNo = 0;
-	$scope.FaultConnectTriggerSignatureDatas = [{"connectVerificationSignatures" : $scope.temp.policy.connectVerificationSignatures}];
-	$scope.addFaultConnectButton = function() {
-		var newConnectFaultItemNo = $scope.temp.policy.connectVerificationSignatures.length+1;
-		$scope.connectFaultItemNo = newConnectFaultItemNo;
-		$scope.temp.policy.connectVerificationSignatures.push({'id':'C'+newConnectFaultItemNo});
-		if(newConnectFaultItemNo >1){
-			var count = newConnectFaultItemNo-1;
-			$scope.connectTriggerFaultsList.push('C'+count);
-		}  
-	};
-	$scope.removeFaultConnectButton = function() {
-		var lastConnectFaultItem = $scope.temp.policy.connectVerificationSignatures.length-1;
-		$scope.temp.policy.connectVerificationSignatures.splice(lastConnectFaultItem);
-		if(lastConnectFaultItem  < 1){
-			var count = lastConnectFaultItem-1;
-			$scope.connectTriggerFaultsList.splice('C'+count);
-		}
-	};
+    PolicyAppService.getData('getDictionary/get_VarbindDictionaryDataByName').then(function (data) {
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.varbindDictionaryDatas = JSON.parse($scope.data.varbindDictionaryDatas);
+    });
+
+    PolicyAppService.getData('getDictionary/get_VNFTypeDataByName').then(function (data) {
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.vnfTypeDictionaryDatas = JSON.parse($scope.data.vnfTypeDictionaryDatas);
+    });
+
+    PolicyAppService.getData('getDictionary/get_VSCLActionDataByName').then(function (data) {
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.vsclActionDictionaryDatas = JSON.parse($scope.data.vsclActionDictionaryDatas);
+    });
+
+    PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
+    });
+    
+    $scope.pepActionDictionaryDatas = [];
+
+    $scope.getPepActionValues = function(pepOptionValue){
+        for (var i = 0; i < $scope.pepOptionsDictionaryDataEntity.length; ++i) {
+            var obj = $scope.pepOptionsDictionaryDataEntity[i];
+            if (obj.pepName == pepOptionValue){
+                var splitAlarm = obj.actions.split(':#@');
+                for (var j = 0; j < splitAlarm.length; ++j) {
+                    $scope.pepActionDictionaryDatas.push(splitAlarm[j].split('=#@')[0]);
+                }
+            }
+        }
+    };
+
+    function trapData(){
+        var data = {};
+        if($scope.temp.policy.triggerTrapSignatures.length == 1 || $scope.temp.policy.triggerTrapSignatures["Trap1"] != null){
+             data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1 }
+        }
+        if($scope.temp.policy.triggerTrapSignatures.length == 2 || $scope.temp.policy.triggerTrapSignatures["Trap2"] != null){
+             data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1,  trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2}
+        }
+        if($scope.temp.policy.triggerTrapSignatures.length == 3 || $scope.temp.policy.triggerTrapSignatures["Trap3"] != null){
+             data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1,  trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2,
+                    trap3 : $scope.temp.policy.triggerTrapSignatures.Trap3}
+        }
+        if($scope.temp.policy.triggerTrapSignatures.length == 4 || $scope.temp.policy.triggerTrapSignatures["Trap4"] != null){
+             data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1,  trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2,
+                    trap3 : $scope.temp.policy.triggerTrapSignatures.Trap3,   trap4 : $scope.temp.policy.triggerTrapSignatures.Trap4}
+        }
+        if($scope.temp.policy.triggerTrapSignatures.length == 5 || $scope.temp.policy.triggerTrapSignatures["Trap5"] != null){
+             data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1,  trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2,
+                    trap3 : $scope.temp.policy.triggerTrapSignatures.Trap3,   trap4 : $scope.temp.policy.triggerTrapSignatures.Trap4,
+                    trap5 : $scope.temp.policy.triggerTrapSignatures.Trap5}
+        }
+        if($scope.temp.policy.triggerTrapSignatures.length == 6 || $scope.temp.policy.triggerTrapSignatures["Trap6"] != null){
+             data = {trap1 : $scope.temp.policy.triggerTrapSignatures.Trap1,  trap2 : $scope.temp.policy.triggerTrapSignatures.Trap2,
+                    trap3 : $scope.temp.policy.triggerTrapSignatures.Trap3,   trap4 : $scope.temp.policy.triggerTrapSignatures.Trap4,
+                    trap5 : $scope.temp.policy.triggerTrapSignatures.Trap5, trap6 : $scope.temp.policy.triggerTrapSignatures.Trap6}
+        }    
+        return data;
+    }
+    
+    function faultDatas(){
+        var faultData = {};
+        if($scope.temp.policy.triggerfaultSignatures.length == 1 || $scope.temp.policy.triggerfaultSignatures["Fault1"] != null){
+             faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1 }
+        }
+        if($scope.temp.policy.triggerfaultSignatures.length == 2 || $scope.temp.policy.triggerfaultSignatures["Fault2"] != null){
+             faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1,  trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2}
+        }
+        if($scope.temp.policy.triggerfaultSignatures.length == 3 || $scope.temp.policy.triggerfaultSignatures["Fault3"] != null){
+             faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1,  trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2,
+                    trap3 : $scope.temp.policy.triggerfaultSignatures.Fault3}
+        }
+        if($scope.temp.policy.triggerTrapSignatures.length == 4 || $scope.temp.policy.triggerfaultSignatures["Fault4"] != null){
+             faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1,  trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2,
+                    trap3 : $scope.temp.policy.triggerfaultSignatures.Fault3,   trap4 : $scope.temp.policy.triggerfaultSignatures.Fault4}
+        }
+        if($scope.temp.policy.triggerfaultSignatures.length == 5 || $scope.temp.policy.triggerfaultSignatures["Fault5"] != null){
+             faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1,  trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2,
+                    trap3 : $scope.temp.policy.triggerfaultSignatures.Fault3,   trap4 : $scope.temp.policy.triggerfaultSignatures.Fault4,
+                    trap5 : $scope.temp.policy.triggerfaultSignatures.Fault5}
+        }
+        if($scope.temp.policy.triggerfaultSignatures.length == 6 || $scope.temp.policy.triggerfaultSignatures["Fault6"] != null){
+             faultData = {trap1 : $scope.temp.policy.triggerfaultSignatures.Fault1,  trap2 : $scope.temp.policy.triggerfaultSignatures.Fault2,
+                    trap3 : $scope.temp.policy.triggerfaultSignatures.Fault3,   trap4 : $scope.temp.policy.triggerfaultSignatures.Fault4,
+                    trap5 : $scope.temp.policy.triggerfaultSignatures.Fault5, trap6 : $scope.temp.policy.triggerfaultSignatures.Fault6}
+        }
+        return faultData;
+    }
+    
+    $scope.saveFaultPolicy = function(policy){
+        if(policy.itemContent != undefined){
+            $scope.refreshCheck = true; 
+            $scope.policyNavigator = policy.itemContent;
+            policy.itemContent = "";
+        }
+        $scope.savebutton = false;
+        var data = trapData();
+        var faultData = faultDatas();
+        var uuu = "policycreation/save_policy";
+        var postData={policyData: policy,
+                trapData : data,
+                faultData : faultData
+        };
+        $.ajax({
+            type : 'POST',
+            url : uuu,
+            dataType: 'json',
+            contentType: 'application/json',
+            data: JSON.stringify(postData),
+            success : function(data){
+                $scope.$apply(function(){
+                    $scope.data=data.policyData;
+                    if($scope.data == 'success'){
+                        $scope.temp.policy.readOnly = 'true';
+                        $scope.pushStatus=data.policyData.split("&")[1];
+                        if($scope.pushStatus=="successPush"){
+                            Notification.success("Policy pushed successfully");
+                        }
+                        $scope.triggerdisabled = true;
+                        $scope.verificationdisabled = true;
+                        Notification.success("Policy Saved Successfully.");    
+                    }else if ($scope.data == 'PolicyExists'){
+                        $scope.savebutton = true;
+                        Notification.error("Policy Already Exists with Same Name in Scope.");
+                    }
+                });
+            },
+            error : function(data){
+                Notification.error("Error Occured while saving Policy.");
+            }
+        });
+    };
+
+    $scope.validatePolicy = function(policy){
+        document.getElementById("validate").innerHTML = "";
+        var uuu = "policyController/validate_policy.htm";
+        var data = trapData();
+        var faultData = faultDatas();
+        var postData={policyData: policy, trapData : data, faultData : faultData};
+        $.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";
+                            }
+                    }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;
+                    }
+
+                });
+            },
+            error : function(data){
+                Notification.error("Validation Failed.");
+                $scope.savebutton = true;
+            }
+        });
+    };
+    if($scope.connectTriggerTrapsList == undefined){
+        $scope.connectTriggerTrapsList = [];
+    }
+    if($scope.temp.policy.traptriggerSignatures == undefined){
+        $scope.temp.policy.traptriggerSignatures = [];
+    }
+    
+    $scope.ItemNo = 0;
+    $scope.TriggerSignatureDatas = [{"triggerSignatures" : $scope.temp.policy.traptriggerSignatures}];
+    $scope.addTriggerButton = function() {
+        $scope.triggerdisabled = false;
+        var newItemNo = $scope.temp.policy.traptriggerSignatures.length+1;
+        $scope.ItemNo = newItemNo;
+        $scope.temp.policy.traptriggerSignatures.push({'id':'Trap'+newItemNo});
+        $scope.connectTriggerTrapsList.push('Trap'+newItemNo);
+    };
+    $scope.removeTriggerButton = function() {
+        var lastItem = $scope.temp.policy.traptriggerSignatures.length-1;
+        $scope.temp.policy.traptriggerSignatures.splice(lastItem);
+        $scope.connectTriggerTrapsList.splice('Trap'+lastItem);
+    };
+
+    
+    $scope.trapItemNo = 0;
+    $scope.TrapTriggerSignatureDatas = [{"triggermainSignatures" : $scope.temp.policy.triggerTrapSignatures}];
+    $scope.addTrapTriggerButton = function(indexId) {
+        if(trapCollection.indexOf(indexId) === -1){
+            $scope.temp.policy.triggerTrapSignatures[indexId] = [];
+            trapCollection.push(indexId);
+        }    
+        var newTrapItemNo = $scope.temp.policy.triggerTrapSignatures[indexId].length+1;
+        $scope.trapItemNo = newTrapItemNo;
+        $scope.temp.policy.triggerTrapSignatures.push($scope.temp.policy.triggerTrapSignatures[indexId].push({'id':'A'+newTrapItemNo}));
+        if(newTrapItemNo > 1){
+            var count = newTrapItemNo-1;
+            $scope.varbindDictionaryDatas.push('A'+count);
+        }
+    };
+    $scope.removeTrapTriggerButton = function(indexId) {
+        var lastTrapItem = $scope.temp.policy.triggerTrapSignatures[indexId].length-1;
+        var checkLastTrapItem = lastTrapItem;
+        if(checkLastTrapItem == 0){
+            trapCollection.splice(indexId);
+        }
+        $scope.temp.policy.triggerTrapSignatures[indexId].splice(lastTrapItem);
+    };
+
+    if($scope.temp.policy.connecttriggerSignatures == undefined){
+        $scope.temp.policy.connecttriggerSignatures = [];
+    }
+    
+    $scope.connecttrapItemNo = 0;
+    $scope.TrapConnectTriggerSignatureDatas = [{"connecttriggerSignatures" : $scope.temp.policy.connecttriggerSignatures}];
+    $scope.addTriggerConnectButton = function() {
+        var newConnectTrapItemNo = $scope.temp.policy.connecttriggerSignatures.length+1;
+        $scope.connecttrapItemNo = newConnectTrapItemNo;
+        $scope.temp.policy.connecttriggerSignatures.push({'id':'C'+newConnectTrapItemNo});
+        if(newConnectTrapItemNo >1){
+            var count = newConnectTrapItemNo-1;
+            $scope.connectTriggerTrapsList.push('C'+count);
+        }      
+    };
+    $scope.removeTriggerConnectButton = function() {
+        var lastConnectTrapItem = $scope.temp.policy.connecttriggerSignatures.length-1;
+        $scope.temp.policy.connecttriggerSignatures.splice(lastConnectTrapItem);
+        if(lastConnectTrapItem  < 1){
+            var count = lastConnectTrapItem-1;
+            $scope.connectTriggerTrapsList.splice('C'+count);
+        }
+    };
+    if($scope.connectTriggerFaultsList == undefined){
+        $scope.connectTriggerFaultsList = [];
+    }
+    if($scope.temp.policy.faulttriggerSignatures == undefined){
+        $scope.temp.policy.faulttriggerSignatures = [];
+    }
+    
+    $scope.FaultItemNo = 0;
+    $scope.FaultSignatureDatas = [{"verificationmainSignatures" : $scope.temp.policy.faulttriggerSignatures}];
+    $scope.addVerFaultButton = function() {
+        var newFaultItemNo = $scope.temp.policy.faulttriggerSignatures.length+1;
+        $scope.FaultItemNo = newFaultItemNo;
+        $scope.temp.policy.faulttriggerSignatures.push({'id':'Fault'+newFaultItemNo});
+        $scope.connectTriggerFaultsList.push('Fault'+newFaultItemNo);
+    };
+    $scope.removeVerFaultButton = function() {
+        var lastFaultItem = $scope.temp.policy.faulttriggerSignatures.length-1;
+        $scope.temp.policy.faulttriggerSignatures.splice(lastFaultItem);
+        $scope.connectTriggerFaultsList.splice('Fault'+lastFaultItem);
+    };
+    if($scope.temp.policy.triggerfaultSignatures == undefined){
+        $scope.temp.policy.triggerfaultSignatures = [];
+    }
+    
+    $scope.faultItemNo1 = 0;
+    $scope.FaultTriggerSignatureDatas = [{"verificationSignatures" : $scope.temp.policy.triggerfaultSignatures}];
+    $scope.addVerTriggerButton = function(indexId) {
+        $scope.verificationdisabled = false;
+        if(faultCollection.indexOf(indexId) === -1){
+            $scope.temp.policy.triggerfaultSignatures[indexId] = [];
+            faultCollection.push(indexId);
+        }    
+        var newFaultItemNo1 = $scope.temp.policy.triggerfaultSignatures[indexId].length+1;
+        $scope.faultItemNo1 = newFaultItemNo1; 
+        $scope.temp.policy.triggerfaultSignatures.push($scope.temp.policy.triggerfaultSignatures[indexId].push({'id':'A'+newFaultItemNo1}));
+        if(newFaultItemNo1 > 1){
+            var count = newFaultItemNo1-1;
+            $scope.varbindDictionaryDatas.push('A'+count);
+        }
+    };
+    $scope.removeVerTriggerButton = function(indexId) {
+        var lastFaultItem1 = $scope.temp.policy.triggerfaultSignatures[indexId].length-1;
+        var checkLastFaultItem = lastFaultItem1;
+        if(checkLastFaultItem == 0){
+            faultCollection.splice(indexId);
+        }
+        $scope.temp.policy.triggerfaultSignatures[indexId].splice(lastFaultItem1);
+    };
+
+    if($scope.temp.policy.connectVerificationSignatures == undefined){
+        $scope.temp.policy.connectVerificationSignatures = [];
+    }
+    
+    $scope.connectFaultItemNo = 0;
+    $scope.FaultConnectTriggerSignatureDatas = [{"connectVerificationSignatures" : $scope.temp.policy.connectVerificationSignatures}];
+    $scope.addFaultConnectButton = function() {
+        var newConnectFaultItemNo = $scope.temp.policy.connectVerificationSignatures.length+1;
+        $scope.connectFaultItemNo = newConnectFaultItemNo;
+        $scope.temp.policy.connectVerificationSignatures.push({'id':'C'+newConnectFaultItemNo});
+        if(newConnectFaultItemNo >1){
+            var count = newConnectFaultItemNo-1;
+            $scope.connectTriggerFaultsList.push('C'+count);
+        }  
+    };
+    $scope.removeFaultConnectButton = function() {
+        var lastConnectFaultItem = $scope.temp.policy.connectVerificationSignatures.length-1;
+        $scope.temp.policy.connectVerificationSignatures.splice(lastConnectFaultItem);
+        if(lastConnectFaultItem  < 1){
+            var count = lastConnectFaultItem-1;
+            $scope.connectTriggerFaultsList.splice('C'+count);
+        }
+    };
 
 
 }]);
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 08f0aa7..873bdb1 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
@@ -71,60 +71,38 @@
     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 = [];
@@ -135,55 +113,37 @@
     }
     }
     $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); 
@@ -196,8 +156,6 @@
                 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;
             }
@@ -255,8 +213,6 @@
         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);
@@ -301,7 +257,6 @@
      
     
      removeChoice = function(value) {
-     console.log(value);
      if(value != undefined){
      var c = document.getElementById("div."+value).childElementCount;
      
@@ -329,7 +284,6 @@
     }
      
      $scope.pullVersion = function(serviceName) {
-     console.log(serviceName);
      if(serviceName != undefined){
      var uuu = "policyController/getModelServiceVersioneData.htm";
      var postData={policyData: serviceName};
@@ -369,7 +323,6 @@
             var uuu = "policyController/getDCAEMSTemplateData.htm";
             var postData={policyData: service};
             
-            console.log("service: " +service);
             
             var dataOrderInfo = "";
             
@@ -392,19 +345,12 @@
                     $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;
@@ -440,7 +386,6 @@
                                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)
@@ -464,7 +409,6 @@
                     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) {
@@ -492,7 +436,6 @@
                                 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);
                             }
                             }
@@ -506,7 +449,6 @@
                             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*";
                             }
@@ -531,7 +473,6 @@
                                 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
@@ -635,7 +576,6 @@
     
     function getList(attribute) {
         var enumName = attribute;
-        console.log("In getList: attribute => " + attribute);
         if(attribute){
            if(attribute.includes(":")){
                enumName = attribute.split(":")[0];
@@ -705,7 +645,6 @@
     
         for (key in layOutData) {
         array = isArray(layOutData[key]);
-        console.log("key: " + key , "value: " + layOutData[key]);
         
         if (!!layOutData[key] && typeof(layOutData[key])=="object") {
             
@@ -783,7 +722,6 @@
             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;
@@ -801,7 +739,6 @@
                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]){
@@ -898,14 +835,11 @@
     
     
         $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;
                 }
@@ -947,7 +881,6 @@
                 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};
@@ -978,8 +911,6 @@
                   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);
                                     
@@ -1167,8 +1098,6 @@
         }
     }
     }
-    console.log('firstChild_Id: ' + firstChild_Id);
-    console.log('divID: ' + divID);
     
     if(dataType != "boolean" && defaultValue.length > 0){    
     if(defaultValue.includes(":")){
@@ -1217,7 +1146,6 @@
     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){
@@ -1390,7 +1318,6 @@
     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');
@@ -1398,8 +1325,6 @@
         option.appendChild(document.createTextNode($scope.listDictionarys[i]));
         listField.appendChild(option);
         }
-    }, function (error) {
-        console.log("failed");
     });
 
     }
@@ -1511,7 +1436,6 @@
     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){
@@ -1537,7 +1461,6 @@
                 }
             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++){                
@@ -1553,7 +1476,6 @@
             } 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++){                
@@ -1594,7 +1516,6 @@
             Notification.error("Policy Already Exists with Same Name in Scope.");
         }
                 });
-                console.log($scope.data);
             },
             error : function(data){
             Notification.error("Error Occured while saving Policy.");
@@ -1610,7 +1531,6 @@
     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){
@@ -1656,16 +1576,13 @@
            
                  
         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){
@@ -1720,7 +1637,6 @@
              }
              
          });
-         console.log($scope.data);    
      },
      error : function(data){
          Notification.error("Validation Failed.");
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
index 9596d0f..4d63dbe 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
@@ -17,438 +17,411 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-angular.module('abs').controller('decisionPolicyController', [ '$scope', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', '$http', function($scope, PolicyAppService, PolicyNavigator, modalService, $modal, Notification, $http) {
-	$("#dialog").hide();
+angular.module('abs').controller('decisionPolicyController', 
+    [ '$scope', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', '$http', 
+    function($scope, PolicyAppService, PolicyNavigator, modalService, $modal, Notification, $http) {
+    $("#dialog").hide();
 
-	$scope.policyNavigator;
-	$scope.savebutton = true;
-	$scope.refreshCheck = false;
-	$scope.disableOnCreate = false;
-	$scope.notRawPolicy = true;
+    $scope.policyNavigator;
+    $scope.savebutton = true;
+    $scope.refreshCheck = false;
+    $scope.disableOnCreate = false;
+    $scope.notRawPolicy = true;
 
-	if (!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly) {
-		$scope.disableOnCreate = true;
-		$scope.temp.policy = {
-			policyType : "Decision"
-		}
-	}
+    if (!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly) {
+    $scope.disableOnCreate = true;
+    $scope.temp.policy = {
+        policyType : "Decision"
+    }
+    }
 
-	$scope.refresh = function() {
-		if ($scope.refreshCheck) {
-			$scope.policyNavigator.refresh();
-		}
-		$scope.modal('createNewPolicy', true);
-		$scope.temp.policy = "";
-	};
+    $scope.refresh = function() {
+    if ($scope.refreshCheck) {
+        $scope.policyNavigator.refresh();
+    }
+    $scope.modal('createNewPolicy', true);
+    $scope.temp.policy = "";
+    };
 
-	$scope.modal = function(id, hide) {
-		return $('#' + id).modal(hide ? 'hide' : 'show');
-	};
+    $scope.modal = function(id, hide) {
+    return $('#' + id).modal(hide ? 'hide' : 'show');
+    };
 
-	if ($scope.temp.policy.ruleProvider == undefined) {
-		$scope.temp.policy.ruleProvider = "Custom";
-	}
+    if ($scope.temp.policy.ruleProvider == undefined) {
+    $scope.temp.policy.ruleProvider = "Custom";
+    }
 
-	if ($scope.temp.policy.blackListEntryType == undefined) {
-		$scope.temp.policy.blackListEntryType = "Use Manual Entry";
-	}
+    if ($scope.temp.policy.blackListEntryType == undefined) {
+    $scope.temp.policy.blackListEntryType = "Use Manual Entry";
+    }
 
-	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('getDictionary/get_OnapNameDataByName').then(function(data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);
+    });
 
-	PolicyAppService.getData('getDictionary/get_SettingsDictionaryDataByName').then(function(data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.settingsDictionaryDatas = JSON.parse($scope.data.settingsDictionaryDatas);
-		console.log($scope.settingsDictionaryDatas);
-	}, function(error) {
-		console.log("failed");
-	});
+    PolicyAppService.getData('getDictionary/get_SettingsDictionaryDataByName').then(function(data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.settingsDictionaryDatas = JSON.parse($scope.data.settingsDictionaryDatas);
+    });
 
-	PolicyAppService.getData('get_FunctionDefinitionDataByName').then(function(data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.functionDefinitionDatas = JSON.parse($scope.data.functionDefinitionDatas);
-		console.log($scope.functionDefinitionDatas);
-	}, function(error) {
-		console.log("failed");
-	});
+    PolicyAppService.getData('get_FunctionDefinitionDataByName').then(function(data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.functionDefinitionDatas = JSON.parse($scope.data.functionDefinitionDatas);
+    });
 
-	PolicyAppService.getData('getDictionary/get_AttributeDatabyAttributeName').then(function(data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.attributeDictionaryDatas = JSON.parse($scope.data.attributeDictionaryDatas);
-		console.log($scope.attributeDictionaryDatas);
-	}, function(error) {
-		console.log("failed");
-	});
+    PolicyAppService.getData('getDictionary/get_AttributeDatabyAttributeName').then(function(data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.attributeDictionaryDatas = JSON.parse($scope.data.attributeDictionaryDatas);
+    });
 
-	PolicyAppService.getData('getDictionary/get_RainyDayDictionaryDataByName').then(function(data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.rainyDayDictionaryDatas = JSON.parse($scope.data.rainyDayDictionaryDatas);
-		console.log($scope.rainyDayDictionaryDatas);
-	}, function(error) {
-		console.log("failed");
-	});
+    PolicyAppService.getData('getDictionary/get_RainyDayDictionaryDataByName').then(function(data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.rainyDayDictionaryDatas = JSON.parse($scope.data.rainyDayDictionaryDatas);
+    });
 
-	PolicyAppService.getData('getDictionary/get_RainyDayDictionaryData').then(function(data) {
-		var j = data;
-		$scope.data = JSON.parse(j.data);
-		console.log($scope.data);
-		$scope.rainyDayDictionaryDataEntity = JSON.parse($scope.data.rainyDayDictionaryDatas);
-		console.log($scope.rainyDayDictionaryDatasEntity);
-	}, function(error) {
-		console.log("failed");
-	});
+    PolicyAppService.getData('getDictionary/get_RainyDayDictionaryData').then(function(data) {
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.rainyDayDictionaryDataEntity = JSON.parse($scope.data.rainyDayDictionaryDatas);
+    });
 
-	$scope.saveDecisionPolicy = function(policy) {
-		if (policy.itemContent != undefined) {
-			$scope.refreshCheck = true;
-			$scope.policyNavigator = policy.itemContent;
-			policy.itemContent = "";
-		}
-		$scope.savebutton = false;
-		console.log(policy);
-		var uuu = "policycreation/save_policy";
-		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.data = data.policyData;
-					if ($scope.data == 'success') {
-						$scope.temp.policy.readOnly = 'true';
-						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);
+    $scope.saveDecisionPolicy = function(policy) {
+    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
+    };
+    $.ajax({
+        type : 'POST',
+        url : uuu,
+        dataType : 'json',
+        contentType : 'application/json',
+        data : JSON.stringify(postData),
+        success : function(data) {
+        $scope.$apply(function() {
+            $scope.data = data.policyData;
+            if ($scope.data == 'success') {
+            $scope.temp.policy.readOnly = 'true';
+            Notification.success("Policy Saved Successfully.");
+            } else if ($scope.data == 'PolicyExists') {
+            $scope.savebutton = true;
+            Notification.error("Policy Already Exists with Same Name in Scope.");
+            }
+        });
 
-			},
-			error : function(data) {
-				Notification.error("Error Occured while saving Policy.");
-			}
-		});
-	};
+        },
+        error : function(data) {
+        Notification.error("Error Occured while saving Policy.");
+        }
+    });
+    };
 
-	$scope.validatePolicy = function(policy) {
-		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;
-					if ($scope.data == '"success"') {
-						Notification.success("Validation Success.");
-						$scope.savebutton = 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;
-					}
+    $scope.validatePolicy = function(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;
+            if ($scope.data == '"success"') {
+            Notification.success("Validation Success.");
+            $scope.savebutton = 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;
-			}
-		});
-	};
+        });
+        },
+        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.settings = [];
-		$scope.temp.policy.ruleAlgorithmschoices = [];
-		if (!$scope.temp.policy.yamlparams) {
-			$scope.temp.policy.yamlparams = {};
-		}
-		if (!$scope.temp.policy.yamlparams.targets) {
-			$scope.temp.policy.yamlparams.targets = [];
-		}
-		if (!$scope.temp.policy.yamlparams.blackList) {
-			$scope.temp.policy.yamlparams.blackList = [];
-		}
-		if (!$scope.temp.policy.rainyday) {
-			$scope.temp.policy.rainyday = {};
-		}
-		if (!$scope.temp.policy.rainyday.treatmentTableChoices) {
-			$scope.temp.policy.rainyday.treatmentTableChoices = [];
-		}
+    if (!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly) {
+    $scope.temp.policy.attributes = [];
+    $scope.temp.policy.settings = [];
+    $scope.temp.policy.ruleAlgorithmschoices = [];
+    if (!$scope.temp.policy.yamlparams) {
+        $scope.temp.policy.yamlparams = {};
+    }
+    if (!$scope.temp.policy.yamlparams.targets) {
+        $scope.temp.policy.yamlparams.targets = [];
+    }
+    if (!$scope.temp.policy.yamlparams.blackList) {
+        $scope.temp.policy.yamlparams.blackList = [];
+    }
+    if (!$scope.temp.policy.rainyday) {
+        $scope.temp.policy.rainyday = {};
+    }
+    if (!$scope.temp.policy.rainyday.treatmentTableChoices) {
+        $scope.temp.policy.rainyday.treatmentTableChoices = [];
+    }
 
-	} else if ($scope.temp.policy.ruleProvider == "Custom") {
-		if ($scope.temp.policy.attributes.length == 0) {
-			$scope.temp.policy.attributes = [];
-		}
-		if ($scope.temp.policy.settings.length == 0) {
-			$scope.temp.policy.settings = [];
-		}
-		if ($scope.temp.policy.ruleAlgorithmschoices == null || $scope.temp.policy.ruleAlgorithmschoices.length == 0) {
-			$scope.temp.policy.ruleAlgorithmschoices = [];
-		}
-	} else if ($scope.temp.policy.ruleProvider == "GUARD_BL_YAML") {
-		if ($scope.temp.policy.yamlparams.blackList == null || $scope.temp.policy.yamlparams.blackList.length == 0) {
-			$scope.temp.policy.yamlparams.blackList = [];
-		}
-		if ($scope.temp.policy.blackListEntries == null || $scope.temp.policy.blackListEntries.length == 0) {
-			$scope.temp.policy.blackListEntries = [];
-		}
-		$scope.blackListEntries = [];
-		$scope.temp.policy.appendBlackListEntries = [];
-		$scope.blackListEntries = arrayUnique($scope.temp.policy.blackListEntries.concat($scope.temp.policy.yamlparams.blackList));
-		
+    } else if ($scope.temp.policy.ruleProvider == "Custom") {
+    if ($scope.temp.policy.attributes.length == 0) {
+        $scope.temp.policy.attributes = [];
+    }
+    if ($scope.temp.policy.settings.length == 0) {
+        $scope.temp.policy.settings = [];
+    }
+    if ($scope.temp.policy.ruleAlgorithmschoices == null || $scope.temp.policy.ruleAlgorithmschoices.length == 0) {
+        $scope.temp.policy.ruleAlgorithmschoices = [];
+    }
+    } else if ($scope.temp.policy.ruleProvider == "GUARD_BL_YAML") {
+    if ($scope.temp.policy.yamlparams.blackList == null || $scope.temp.policy.yamlparams.blackList.length == 0) {
+        $scope.temp.policy.yamlparams.blackList = [];
+    }
+    if ($scope.temp.policy.blackListEntries == null || $scope.temp.policy.blackListEntries.length == 0) {
+        $scope.temp.policy.blackListEntries = [];
+    }
+    $scope.blackListEntries = [];
+    $scope.temp.policy.appendBlackListEntries = [];
+    $scope.blackListEntries = arrayUnique($scope.temp.policy.blackListEntries.concat($scope.temp.policy.yamlparams.blackList));
+    
     }else if($scope.temp.policy.ruleProvider=="GUARD_YAML" || $scope.temp.policy.ruleProvider=="GUARD_MIN_MAX"){
-    	if($scope.temp.policy.yamlparams.targets.length==0){
- 		   $scope.temp.policy.yamlparams.targets = [];
- 	   	}
-	} else if ($scope.temp.policy.ruleProvider == "Rainy_Day") {
-		if ($scope.temp.policy.rainyday.treatmentTableChoices == null || $scope.temp.policy.rainyday.treatmentTableChoices.length == 0) {
-			$scope.temp.policy.rainyday.treatmentTableChoices = [];
-		}
-	}
-	$scope.attributeDatas = [ {
-		"attributes" : $scope.temp.policy.attributes
-	} ];
-	$scope.addNewChoice = function() {
-		var newItemNo = $scope.temp.policy.attributes.length + 1;
-		$scope.temp.policy.attributes.push({
-			'id' : 'choice' + newItemNo
-		});
-	};
-	$scope.removeChoice = function() {
-		var lastItem = $scope.temp.policy.attributes.length - 1;
-		$scope.temp.policy.attributes.splice(lastItem);
-	};
+        if($scope.temp.policy.yamlparams.targets.length==0){
+        $scope.temp.policy.yamlparams.targets = [];
+            }
+    } else if ($scope.temp.policy.ruleProvider == "Rainy_Day") {
+    if ($scope.temp.policy.rainyday.treatmentTableChoices == null || $scope.temp.policy.rainyday.treatmentTableChoices.length == 0) {
+        $scope.temp.policy.rainyday.treatmentTableChoices = [];
+    }
+    }
+    $scope.attributeDatas = [ {
+    "attributes" : $scope.temp.policy.attributes
+    } ];
+    $scope.addNewChoice = function() {
+    var newItemNo = $scope.temp.policy.attributes.length + 1;
+    $scope.temp.policy.attributes.push({
+        'id' : 'choice' + newItemNo
+    });
+    };
+    $scope.removeChoice = function() {
+    var lastItem = $scope.temp.policy.attributes.length - 1;
+    $scope.temp.policy.attributes.splice(lastItem);
+    };
 
-	$scope.settingsDatas = [ {
-		"settings" : $scope.temp.policy.settings
-	} ];
-	$scope.addNewSettingsChoice = function() {
-		var newItemNo = $scope.temp.policy.settings.length + 1;
-		$scope.temp.policy.settings.push({
-			'id' : 'choice' + newItemNo
-		});
-	};
-	$scope.removeSettingsChoice = function() {
-		var lastItem = $scope.temp.policy.settings.length - 1;
-		$scope.temp.policy.settings.splice(lastItem);
-	};
+    $scope.settingsDatas = [ {
+    "settings" : $scope.temp.policy.settings
+    } ];
+    $scope.addNewSettingsChoice = function() {
+    var newItemNo = $scope.temp.policy.settings.length + 1;
+    $scope.temp.policy.settings.push({
+        'id' : 'choice' + newItemNo
+    });
+    };
+    $scope.removeSettingsChoice = function() {
+    var lastItem = $scope.temp.policy.settings.length - 1;
+    $scope.temp.policy.settings.splice(lastItem);
+    };
 
-	$scope.addNewTarget = function() {
-		$scope.temp.policy.yamlparams.targets.push('');
-	};
-	$scope.removeTarget = function() {
-		var lastItem = $scope.temp.policy.yamlparams.targets.length - 1;
-		$scope.temp.policy.yamlparams.targets.splice(lastItem);
-	};
+    $scope.addNewTarget = function() {
+    $scope.temp.policy.yamlparams.targets.push('');
+    };
+    $scope.removeTarget = function() {
+    var lastItem = $scope.temp.policy.yamlparams.targets.length - 1;
+    $scope.temp.policy.yamlparams.targets.splice(lastItem);
+    };
 
-	$scope.addNewBL = function() {
-		$scope.temp.policy.yamlparams.blackList.push('');
-	};
+    $scope.addNewBL = function() {
+    $scope.temp.policy.yamlparams.blackList.push('');
+    };
     
     $scope.removeBL = function(id) {
-    	$scope.temp.policy.yamlparams.blackList = $scope.temp.policy.yamlparams.blackList.filter(function (obj){
-			return obj !== id;
-		});
-	};
+        $scope.temp.policy.yamlparams.blackList = $scope.temp.policy.yamlparams.blackList.filter(function (obj){
+        return obj !== id;
+    });
+    };
 
-	$scope.treatmentDatas = [ {
-		"treatmentValues" : $scope.temp.policy.rainyday.treatmentTableChoices
-	} ];
-	
-	$scope.addNewTreatment = function() {
-		$scope.temp.policy.rainyday.treatmentTableChoices.push({});
-	};
-	
-	$scope.removeTreatment = function() {
-		var lastItem = $scope.temp.policy.rainyday.treatmentTableChoices.length - 1;
-		$scope.temp.policy.rainyday.treatmentTableChoices.splice(lastItem);
-	};
+    $scope.treatmentDatas = [ {
+    "treatmentValues" : $scope.temp.policy.rainyday.treatmentTableChoices
+    } ];
+    
+    $scope.addNewTreatment = function() {
+    $scope.temp.policy.rainyday.treatmentTableChoices.push({});
+    };
+    
+    $scope.removeTreatment = function() {
+    var lastItem = $scope.temp.policy.rainyday.treatmentTableChoices.length - 1;
+    $scope.temp.policy.rainyday.treatmentTableChoices.splice(lastItem);
+    };
 
-	$scope.workstepDictionaryDatas = [];
-	$scope.getWorkstepValues = function(bbidValue) {
-		for (var i = 0; i < $scope.rainyDayDictionaryDataEntity.length; ++i) {
-			var obj = $scope.rainyDayDictionaryDataEntity[i];
-			if (obj.bbid == bbidValue) {
-				$scope.workstepDictionaryDatas.push(obj.workstep);
-			}
-		}
-	};
+    $scope.workstepDictionaryDatas = [];
+    $scope.getWorkstepValues = function(bbidValue) {
+    for (var i = 0; i < $scope.rainyDayDictionaryDataEntity.length; ++i) {
+        var obj = $scope.rainyDayDictionaryDataEntity[i];
+        if (obj.bbid == bbidValue) {
+        $scope.workstepDictionaryDatas.push(obj.workstep);
+        }
+    }
+    };
 
-	$scope.allowedTreatmentsDatas = [];
-	$scope.getTreatmentValues = function(bbidValue, workstepValue) {
-		for (var i = 0; i < $scope.rainyDayDictionaryDataEntity.length; ++i) {
-			var obj = $scope.rainyDayDictionaryDataEntity[i];
-			if (obj.bbid == bbidValue && obj.workstep == workstepValue) {
-				var splitAlarm = obj.treatments.split(',');
-				for (var j = 0; j < splitAlarm.length; ++j) {
-					$scope.allowedTreatmentsDatas.push(splitAlarm[j]);
-				}
-			}
-		}
-	};
+    $scope.allowedTreatmentsDatas = [];
+    $scope.getTreatmentValues = function(bbidValue, workstepValue) {
+    for (var i = 0; i < $scope.rainyDayDictionaryDataEntity.length; ++i) {
+        var obj = $scope.rainyDayDictionaryDataEntity[i];
+        if (obj.bbid == bbidValue && obj.workstep == workstepValue) {
+        var splitAlarm = obj.treatments.split(',');
+        for (var j = 0; j < splitAlarm.length; ++j) {
+            $scope.allowedTreatmentsDatas.push(splitAlarm[j]);
+        }
+        }
+    }
+    };
 
-	$scope.ItemNo = 0;
-	$scope.ruleAlgorithmDatas = [ {
-		"ruleAlgorithms" : $scope.temp.policy.ruleAlgorithmschoices
-	} ];
+    $scope.ItemNo = 0;
+    $scope.ruleAlgorithmDatas = [ {
+    "ruleAlgorithms" : $scope.temp.policy.ruleAlgorithmschoices
+    } ];
 
-	$scope.addNewRuleAlgorithm = function() {
-		if ($scope.temp.policy.ruleAlgorithmschoices != null) {
-			var newItemNo = $scope.temp.policy.ruleAlgorithmschoices.length + 1;
-		} else {
-			var newItemNo = 1;
-		}
-		if (newItemNo > 1) {
-			var value = newItemNo - 1;
-			$scope.attributeDictionaryDatas.push('A' + value);
-		}
-		$scope.temp.policy.ruleAlgorithmschoices.push({
-			'id' : 'A' + newItemNo
-		});
-	};
+    $scope.addNewRuleAlgorithm = function() {
+    if ($scope.temp.policy.ruleAlgorithmschoices != null) {
+        var newItemNo = $scope.temp.policy.ruleAlgorithmschoices.length + 1;
+    } else {
+        var newItemNo = 1;
+    }
+    if (newItemNo > 1) {
+        var value = newItemNo - 1;
+        $scope.attributeDictionaryDatas.push('A' + value);
+    }
+    $scope.temp.policy.ruleAlgorithmschoices.push({
+        'id' : 'A' + newItemNo
+    });
+    };
 
-	$scope.removeRuleAlgorithm = function() {
-		var lastItem = $scope.temp.policy.ruleAlgorithmschoices.length - 1;
-		$scope.temp.policy.ruleAlgorithmschoices.splice(lastItem);
-	};
+    $scope.removeRuleAlgorithm = function() {
+    var lastItem = $scope.temp.policy.ruleAlgorithmschoices.length - 1;
+    $scope.temp.policy.ruleAlgorithmschoices.splice(lastItem);
+    };
 
-	$scope.providerListener = function(ruleProvider) {
-		if (ruleProvider != "Custom") {
-			$scope.temp.policy.ruleAlgorithmschoices = [];
-			$scope.temp.policy.settings = [];
-			$scope.temp.policy.attributes = [];
-		}
-		if (ruleProvider === "Raw") {
-			$scope.notRawPolicy = false;
-		}
-	};
+    $scope.providerListener = function(ruleProvider) {
+    if (ruleProvider != "Custom") {
+        $scope.temp.policy.ruleAlgorithmschoices = [];
+        $scope.temp.policy.settings = [];
+        $scope.temp.policy.attributes = [];
+    }
+    if (ruleProvider === "Raw") {
+        $scope.notRawPolicy = false;
+    }
+    };
 
-	$scope.importButton = true;
-	var fd;
-	$scope.uploadBLFile = function(files) {
-		fd = new FormData();
-		fd.append("file", files[0]);
-		var fileExtension = files[0].name.split(".")[1];
-		if (fileExtension == "xls") {
-			$scope.importButton = false;
-			$scope.$apply();
-		} else {
-			Notification.error("Upload the BlackList file which extends with .xls format.");
-		}
-	};
+    $scope.importButton = true;
+    var fd;
+    $scope.uploadBLFile = function(files) {
+    fd = new FormData();
+    fd.append("file", files[0]);
+    var fileExtension = files[0].name.split(".")[1];
+    if (fileExtension == "xls") {
+        $scope.importButton = false;
+        $scope.$apply();
+    } else {
+        Notification.error("Upload the BlackList file which extends with .xls format.");
+    }
+    };
 
-	function arrayUnique(array) {
-		var a = array.concat();
-		for (var i = 0; i < a.length; ++i) {
-			for (var j = i + 1; j < a.length; ++j) {
-				if (a[i] === a[j])
-					a.splice(j--, 1);
-			}
-		}
-		return a;
-	}
+    function arrayUnique(array) {
+    var a = array.concat();
+    for (var i = 0; i < a.length; ++i) {
+        for (var j = i + 1; j < a.length; ++j) {
+        if (a[i] === a[j])
+            a.splice(j--, 1);
+        }
+    }
+    return a;
+    }
 
-	$scope.submitUpload = function() {
-		$http.post("policycreation/importBlackListForDecisionPolicy", fd, {
-			withCredentials : false,
-			headers : {
-				'Content-Type' : undefined
-			},
-			transformRequest : angular.identity
-		}).success(function(data) {
-			$scope.data = JSON.parse(data.data);
-			$scope.temp.policy.blackListEntries = $scope.data.blackListEntries;
-			if ($scope.temp.policy.blackListEntries[0] !== "error") {
-				$scope.blackListEntries = arrayUnique($scope.temp.policy.blackListEntries.concat($scope.temp.policy.yamlparams.blackList));
-				$scope.temp.policy.appendBlackListEntries = $scope.data.appendBlackListEntries;
-				$scope.blackListEntries = $scope.blackListEntries.filter(function(obj) {
-					return !$scope.temp.policy.appendBlackListEntries.includes(obj);
-				});
-				if ($scope.blackListEntries.length == 0) {
-					$scope.validateButton = true;
-					Notification.error("Black Lists are empty. Minimum one entry required.");
-				} else {
-					$scope.temp.policy.blackListEntries = $scope.blackListEntries;
-					Notification.success("Blacklist File Uploaded Successfully.");
-					$scope.validateButton = false;
-					$scope.importButton = true;
-				}
-			} else {
-				Notification.error("Blacklist File Upload Failed." + $scope.temp.policy.blackListEntries[1]);
-			}
-		}).error(function(data) {
-			Notification.error("Blacklist File Upload Failed.");
-		});
-	};
+    $scope.submitUpload = function() {
+    $http.post("policycreation/importBlackListForDecisionPolicy", fd, {
+        withCredentials : false,
+        headers : {
+        'Content-Type' : undefined
+        },
+        transformRequest : angular.identity
+    }).success(function(data) {
+        $scope.data = JSON.parse(data.data);
+        $scope.temp.policy.blackListEntries = $scope.data.blackListEntries;
+        if ($scope.temp.policy.blackListEntries[0] !== "error") {
+        $scope.blackListEntries = arrayUnique($scope.temp.policy.blackListEntries.concat($scope.temp.policy.yamlparams.blackList));
+        $scope.temp.policy.appendBlackListEntries = $scope.data.appendBlackListEntries;
+        $scope.blackListEntries = $scope.blackListEntries.filter(function(obj) {
+            return !$scope.temp.policy.appendBlackListEntries.includes(obj);
+        });
+        if ($scope.blackListEntries.length == 0) {
+            $scope.validateButton = true;
+            Notification.error("Black Lists are empty. Minimum one entry required.");
+        } else {
+            $scope.temp.policy.blackListEntries = $scope.blackListEntries;
+            Notification.success("Blacklist File Uploaded Successfully.");
+            $scope.validateButton = false;
+            $scope.importButton = true;
+        }
+        } else {
+        Notification.error("Blacklist File Upload Failed." + $scope.temp.policy.blackListEntries[1]);
+        }
+    }).error(function(data) {
+        Notification.error("Blacklist File Upload Failed.");
+    });
+    };
 
-	$scope.initializeBlackList = function() {
-		if ($scope.temp.policy.blackListEntryType === "Use File Upload") {
-			$scope.validateButton = true;
-		} else {
-			$scope.validateButton = false;
-		}
-		$("#importFile").val('');
-	};
+    $scope.initializeBlackList = function() {
+    if ($scope.temp.policy.blackListEntryType === "Use File Upload") {
+        $scope.validateButton = true;
+    } else {
+        $scope.validateButton = false;
+    }
+    $("#importFile").val('');
+    };
 
-	$scope.exportBlackListEntries = function() {
-		var uuu = "policycreation/exportDecisionBlackListEntries";
-		var postData = {
-			policyData : $scope.temp.policy,
-			date : $scope.temp.model.modifiedDate,
-			version : $scope.temp.model.version
-		};
-		$.ajax({
-			type : 'POST',
-			url : uuu,
-			dataType : 'json',
-			contentType : 'application/json',
-			data : JSON.stringify(postData),
-			success : function(data) {
-				$scope.$apply(function() {
-					$scope.data = data.data;
-					var url = '../' + $scope.data;
-					window.location = url;
-					Notification.success("BlackList Entries Exported Successfully.");
-				});
-				console.log($scope.data);
-			},
-			error : function(data) {
-				Notification.error("Error Occured while Exporting BlackList Entries.");
-			}
-		});
-	};
+    $scope.exportBlackListEntries = function() {
+    var uuu = "policycreation/exportDecisionBlackListEntries";
+    var postData = {
+        policyData : $scope.temp.policy,
+        date : $scope.temp.model.modifiedDate,
+        version : $scope.temp.model.version
+    };
+    $.ajax({
+        type : 'POST',
+        url : uuu,
+        dataType : 'json',
+        contentType : 'application/json',
+        data : JSON.stringify(postData),
+        success : function(data) {
+        $scope.$apply(function() {
+            $scope.data = data.data;
+            var url = '../' + $scope.data;
+            window.location = url;
+            Notification.success("BlackList Entries Exported Successfully.");
+        });
+        },
+        error : function(data) {
+        Notification.error("Error Occured while Exporting BlackList Entries.");
+        }
+    });
+    };
 } ]);
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js
index 1d39c4f..b62f91d 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/FirewallPolicyController.js
@@ -17,7 +17,9 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-angular.module('abs').controller('fwPolicyController', ['$scope', '$window', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, $window, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) {
+angular.module('abs').controller('fwPolicyController', 
+    ['$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 : "Firewall Config"
-    	}
+    $scope.temp.policy = {
+        policyType : "Config",
+        configPolicyType : "Firewall Config"
+    }
     };
     
     $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,76 +46,51 @@
     };
     
     $('#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');
+    }
     });
-		
+    
     PolicyAppService.getData('getDictionary/get_SecurityZoneDataByName').then(function (data) {
-    	var j = data;
-    	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
-    	$scope.securityZoneDictionaryDatas = JSON.parse($scope.data.securityZoneDictionaryDatas);
-    	console.log($scope.securityZoneDictionaryDatas);
-    }, function (error) {
-    	console.log("failed");
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.securityZoneDictionaryDatas = JSON.parse($scope.data.securityZoneDictionaryDatas);
     });
 
     PolicyAppService.getData('getDictionary/get_TermListDataByName').then(function (data) {
-    	var j = data;
-    	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
-    	$scope.termListDictionaryDatas = JSON.parse($scope.data.termListDictionaryDatas);
-    	console.log($scope.termListDictionaryDatas);
-    }, function (error) {
-    	console.log("failed");
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.termListDictionaryDatas = JSON.parse($scope.data.termListDictionaryDatas);
     });
 
     PolicyAppService.getData('getDictionary/get_FWDictionaryListDataByName').then(function (data) {
-    	var j = data;
-    	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
-    	$scope.fwDictListDictionaryDatas = JSON.parse($scope.data.fwDictListDictionaryDatas);
-    	console.log($scope.fwDictListDictionaryDatas);
-    }, function (error) {
-    	console.log("failed");
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.fwDictListDictionaryDatas = JSON.parse($scope.data.fwDictListDictionaryDatas);
     });
 
     PolicyAppService.getData('getDictionary/get_FWParentListDataByName').then(function (data) {
-    	var j = data;
-    	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
-    	$scope.fwParentListDictionaryDatas = JSON.parse($scope.data.fwParentListDictionaryDatas);
-    	console.log($scope.fwParentListDictionaryDatas);
-    }, function (error) {
-    	console.log("failed");
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.fwParentListDictionaryDatas = JSON.parse($scope.data.fwParentListDictionaryDatas);
     });
 
     PolicyAppService.getData('getDictionary/get_TagPickerNameByName').then(function (data) {
-    	var j = data;
-    	$scope.data = JSON.parse(j.data);
-    	console.log($scope.data);
-    	$scope.fwTagPickerDictionaryDatas = JSON.parse($scope.data.fwTagPickerDictionaryDatas);
-    	console.log($scope.fwTagPickerDictionaryDatas);
-    }, function (error) {
-    	console.log("failed");
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.fwTagPickerDictionaryDatas = JSON.parse($scope.data.fwTagPickerDictionaryDatas);
     });
 
     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");
+    var j = data;
+    $scope.data = JSON.parse(j.data);
+    $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
     });
 
     $scope.viewFWRule = function(policy){
-        console.log(policy);
         var uuu = "policyController/ViewFWPolicyRule.htm";
         var postData={policyData: policy};
         $.ajax({
@@ -124,110 +101,106 @@
             data: JSON.stringify(postData),
             success : function(data){
                 $scope.$apply(function(){
-                	window.alert(data.policyData);
+                window.alert(data.policyData);
                 });
             },
             error : function(data){
-            	Notification.error("Error Occured while Showing Rule.");
+            Notification.error("Error Occured while Showing Rule.");
             }
         });
     };
     
     
     $scope.saveFWPolicy = function(policy){
-    	if(policy.itemContent != undefined){
-    		$scope.refreshCheck = true; 
-        	$scope.policyNavigator = policy.itemContent;
-        	policy.itemContent = "";
-    	}
-    	$scope.savebutton = false;
-        console.log(policy);
+    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};
-		$.ajax({
-			type : 'POST',
-			url : uuu,
-			dataType: 'json',
-			contentType: 'application/json',
-			data: JSON.stringify(postData),
-			success : function(data){
-				$scope.$apply(function(){
-					$scope.data=data.policyData;
-					if($scope.data == 'success'){
-						$scope.temp.policy.readOnly = 'true';
-						$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.");
-			}
-		});
+    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.data=data.policyData;
+        if($scope.data == 'success'){
+            $scope.temp.policy.readOnly = 'true';
+            $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.");
+        }
+        });
+    },
+    error : function(data){
+        Notification.error("Error Occured while saving Policy.");
+    }
+    });
     };
     
     $scope.validatePolicy = function(policy){
-    	console.log(policy);
-    	document.getElementById("validate").innerHTML = "";
+    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";
- 							}	
- 						}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";
+             }	
+             }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;
+             }
+             
+         });
+         
+     },
+     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.fwattributes = [];
+    $scope.temp.policy.attributes = [];
+    $scope.temp.policy.fwattributes = [];
     }else{
 	   if($scope.temp.policy.attributes.length == 0){
-		   $scope.temp.policy.attributes = [];
+       $scope.temp.policy.attributes = [];
 	   }
 	   if($scope.temp.policy.fwPolicyType == 'Parent Policy'){
-		   if($scope.temp.policy.fwattributes.length == 0){
-			   $scope.temp.policy.fwattributes = [];
-		   }
+       if($scope.temp.policy.fwattributes.length == 0){
+       $scope.temp.policy.fwattributes = [];
+       }
 	   }
    }
     
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 2727925..58594bc 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
@@ -68,27 +68,18 @@
     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 = [];
@@ -99,26 +90,18 @@
     }
     }
     $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.','');
@@ -237,7 +220,6 @@
     }
      
      $scope.removeChoice = function(value) {
-     console.log(value);
      if(value != undefined){
      var c = document.getElementById("div."+value).childElementCount;
      
@@ -250,7 +232,6 @@
      };
      
      $scope.pullVersion = function(serviceName) {
-     console.log(serviceName);
      if(serviceName != undefined){
      var uuu = "policyController/getModelServiceVersionData.htm";
      var postData={policyData: serviceName};
@@ -301,20 +282,6 @@
                     $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;
@@ -357,7 +324,6 @@
                                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)
@@ -413,7 +379,6 @@
                                 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);
                             }
                             }
@@ -426,13 +391,11 @@
                             //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++){
@@ -521,7 +484,6 @@
     
     function getList(attribute) {
     var enumName = attribute;
-    console.log("In getList: attribute => " + attribute);
     if(attribute){
        if(attribute.includes(":")){
            enumName = attribute.split(":")[0];
@@ -592,7 +554,6 @@
     
         for (key in layOutData) {
         array = isArray(layOutData[key]);
-        console.log("key: " + key , "value: " + layOutData[key]);
        
         if (!!layOutData[key] && typeof(layOutData[key])=="object") {
             
@@ -666,7 +627,6 @@
             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]){
@@ -752,14 +712,11 @@
     }  
 
     $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;
             }
@@ -801,7 +758,6 @@
        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};
@@ -831,7 +787,6 @@
                      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);
@@ -966,8 +921,6 @@
         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(":")){
@@ -1016,7 +969,6 @@
     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){
@@ -1218,7 +1170,6 @@
     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];
         
@@ -1243,12 +1194,10 @@
                 }
             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;
                 }
             }
@@ -1282,7 +1231,6 @@
             Notification.error("Policy Already Exists with Same Name in Scope.");
         }
                 });
-                console.log($scope.data);
             },
             error : function(data){
             Notification.error("Error Occured while saving Policy.");
@@ -1298,7 +1246,6 @@
     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'){
@@ -1365,7 +1312,6 @@
              }
              
          });
-         console.log($scope.data);    
      },
      error : function(data){
          Notification.error("Validation Failed.");
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 3a926c4..c4ec75c 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
@@ -18,326 +18,307 @@
  * ============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;
+    }
+    }, function(error) {
+    });
 
-          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);
+    $scope.descriptiveScopeDictionaryDatas = JSON.parse($scope.data.descriptiveScopeDictionaryDatas);
+    });
 
-          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);
+    $scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);
+    });
 
-          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);
+    $scope.vsclActionDictionaryDatas = JSON.parse($scope.data.vsclActionDictionaryDatas);
+    });
 
-          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);
+    $scope.vnfTypeDictionaryDatas = JSON.parse($scope.data.vnfTypeDictionaryDatas);	
+    });
 
 
-          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);
+    $scope.userRolesDatas = JSON.parse($scope.data.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; 
+        }
+    });
 
-          $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.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.");
-                    }
-              });
+        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);
+        },
+        error : function(data) {
+      Notification.error("Error while saving.");
+        }
+        });
          };
 
          $scope.refresh = function() {
-              $scope.policyNavigator.refresh();
+        $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.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.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.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.remove = function(item) {
-                item.remove().then(function() {
-                     $scope.policyNavigator.refresh();
-                     $scope.modal('delete', true);
-                });
-          };
+    $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.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.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.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.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.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.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.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.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();
+    $scope.isWindows = $scope.getQueryParam('server') === 'Windows';
+    $scope.policyNavigator.refresh();
      }]);
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policySearchManager.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policySearchManager.js
index 42e6796..edca7e4 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policySearchManager.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/js/controllers/policySearchManager.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.
@@ -18,194 +18,176 @@
  * ============LICENSE_END=========================================================
  */
 app.controller('PolicySearchController', [
-        '$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', '$q', '$window', '$cookies', 'policyManagerConfig', 'item', 'policyNavigator', 'policyUploader', 'Notification','PolicyAppService',
+    function($scope, $q, $Window, $cookies, policyManagerConfig, Item, PolicyNavigator, PolicyUploader, Notification, PolicyAppService ) {
         
-        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");
-        });
+    $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;
+        }
+    },function(error){
+    });
+    
+    PolicyAppService.getData('getDictionary/get_DescriptiveScopeByName').then(function(data){
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.descriptiveScopeDictionaryDatas = JSON.parse($scope.data.descriptiveScopeDictionaryDatas);    
+    });
 
-        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);
+        $scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);    
+    });
 
-        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);
+        $scope.vsclActionDictionaryDatas = JSON.parse($scope.data.vsclActionDictionaryDatas);    
+    });
 
-        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);
+        $scope.vnfTypeDictionaryDatas = JSON.parse($scope.data.vnfTypeDictionaryDatas);    
+    });
 
-        
-        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.createPolicyId = true; 
-        		$scope.editPolicyId = true;
-        		$scope.describePolicyId = true;
-        		$scope.viewPolicyId = true;
-        	}else if($scope.userRolesDatas[0] == 'super-editor' || $scope.userRolesDatas[0] == 'editor' || $scope.userRolesDatas[0] == 'admin'){
-        		$scope.editPolicyId = true;
-        		$scope.createPolicyId = true;
-        		$scope.describePolicyId = true;
-        		$scope.viewPolicyId = true;
-        	}else if($scope.userRolesDatas[0] == 'super-guest' || $scope.userRolesDatas[0] == 'guest'){
-        		$scope.describePolicyId = true;
-        		$scope.viewPolicyId = 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;
-        };
+    
+    PolicyAppService.getData('get_UserRolesData').then(function (data) {
+        var j = data;
+        $scope.data = JSON.parse(j.data);
+        $scope.userRolesDatas = JSON.parse($scope.data.userRolesDatas);
+        if($scope.userRolesDatas[0] == 'super-admin'){
+            $scope.superAdminId = true;
+            $scope.createPolicyId = true; 
+            $scope.editPolicyId = true;
+            $scope.describePolicyId = true;
+            $scope.viewPolicyId = true;
+        }else if($scope.userRolesDatas[0] == 'super-editor' || $scope.userRolesDatas[0] == 'editor' || $scope.userRolesDatas[0] == 'admin'){
+            $scope.editPolicyId = true;
+            $scope.createPolicyId = true;
+            $scope.describePolicyId = true;
+            $scope.viewPolicyId = true;
+        }else if($scope.userRolesDatas[0] == 'super-guest' || $scope.userRolesDatas[0] == 'guest'){
+            $scope.describePolicyId = true;
+            $scope.viewPolicyId = true;
+        }
+    });
+    
+    $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.query = '';
+    $scope.temp = new Item();
+    $scope.policyNavigator = new PolicyNavigator();
 
-        $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.touch = function(item) {
+    item = item instanceof Item ? item : new Item();
+    item.revert();
+    $scope.temp = item;
+    };
 
-        $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.isInThisPath = function(path) {
+    var currentPath = $scope.policyNavigator.currentPath.join('/');
+    return currentPath.indexOf(path) !== -1;
+    };
        
-        $scope.searchPolicy = function(searchContent){
-        	if(searchContent != undefined){
-        		var uuu = "searchPolicy";
-        		var postData = {searchdata : searchContent};
-        		$.ajax({
-        			type : 'POST',
-        			url : uuu,
-        			dataType: 'json',
-        			contentType: 'application/json',
-        			data: JSON.stringify(postData),
-        			success : function(data){
-        				$scope.$apply(function(){
-        					var searchdata = data.result;
-        					if(searchdata.length > 0){
-        						if(searchdata[0] == "Exception"){
-        							Notification.error(searchdata[1]);
-        						}else{
-        							$scope.policyNavigator.searchrefresh(searchdata);  
-        						}
-        					}else{
-        						Notification.info("No Matches Found with your Search");
-        					}
-        				});     
-        			},
-        			error : function(data){
-        				Notification.error("Error while Searching.");
-        			}
-        		});
-        	}else{
-        		Notification.error("No data has been entered or selected to search");
-        	}
-        };
-       
-       $scope.refresh = function(searchData){
-    	   $scope.policyNavigator.searchrefresh(null);
-       };
-         
-        $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.searchPolicy = function(searchContent){
+        if(searchContent != undefined){
+            var uuu = "searchPolicy";
+            var postData = {searchdata : searchContent};
+            $.ajax({
+                type : 'POST',
+                url : uuu,
+                dataType: 'json',
+                contentType: 'application/json',
+                data: JSON.stringify(postData),
+                success : function(data){
+                    $scope.$apply(function(){
+                        var searchdata = data.result;
+                        if(searchdata.length > 0){
+                            if(searchdata[0] == "Exception"){
+                                Notification.error(searchdata[1]);
+                            }else{
+                                $scope.policyNavigator.searchrefresh(searchdata);  
+                            }
+                        }else{
+                            Notification.info("No Matches Found with your Search");
+                        }
+                    });     
+                },
+                error : function(data){
+                    Notification.error("Error while Searching.");
                 }
             });
-            return found;
-        };
+        }else{
+            Notification.error("No data has been entered or selected to search");
+        }
+    };
+       
+       $scope.refresh = function(searchData){
+           $scope.policyNavigator.searchrefresh(null);
+       };
+     
+    $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.searchrefresh(null);
-        $scope.policyNavigator.setSearchModalActiveStatus();
+    $scope.isWindows = $scope.getQueryParam('server') === 'Windows';
+    $scope.policyNavigator.searchrefresh(null);
+    $scope.policyNavigator.setSearchModalActiveStatus();
     }]);
