Merge "More JUnit additions for PAP-REST"
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();
}]);