summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-09-06 00:26:31 +0000
committerGerrit Code Review <gerrit@onap.org>2018-09-06 00:26:31 +0000
commit5dfb55068e2bb88af55d6ce48c235cff7ea9b326 (patch)
treec53e0dc104935f6c3881ba2fcf2084f607f1fb9b
parent2cb76b3efe8ca385da3bc5f5afc5b26a52c6fd43 (diff)
parent9b57ecb9bfbf50d3c38e390fb61b7efd05fa049e (diff)
Merge "TOSCA model enhancements"
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java784
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js292
2 files changed, 653 insertions, 423 deletions
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
index 50628d7d5..411ecaa26 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
@@ -23,11 +23,40 @@ package org.onap.policy.rest.util;
import com.att.research.xacml.util.XACMLProperties;
import com.google.gson.Gson;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.eclipse.emf.common.util.*;
-import org.eclipse.emf.ecore.*;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.EMap;
+import org.eclipse.emf.common.util.Enumerator;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.impl.EAttributeImpl;
import org.eclipse.emf.ecore.impl.EEnumImpl;
import org.eclipse.emf.ecore.resource.Resource;
@@ -38,16 +67,12 @@ import org.json.JSONObject;
import org.onap.policy.rest.XACMLRestProperties;
import org.yaml.snakeyaml.Yaml;
-import java.io.*;
-import java.util.*;
-import java.util.Map.Entry;
-
public class MSModelUtils {
- private static final Log logger = LogFactory.getLog(MSModelUtils.class);
+ private static final Log logger = LogFactory.getLog(MSModelUtils.class);
- private HashMap<String,MSAttributeObject > classMap = new HashMap<>();
+ private HashMap<String, MSAttributeObject> classMap = new HashMap<>();
private HashMap<String, String> enumMap = new HashMap<>();
private HashMap<String, String> matchingClass = new HashMap<>();
private String configuration = "configuration";
@@ -56,45 +81,54 @@ public class MSModelUtils {
private String policy = "";
private String eProxyURI = "eProxyURI:";
private List<String> orderedElements = new ArrayList<>();
- private String dataOrderInfo = null;
- private Set<String> uniqueDataKeys= new HashSet<>();
- private Set<String> uniqueKeys= new HashSet<>();
+ private String dataOrderInfo = "";
+ private Set<String> uniqueDataKeys = new HashSet<>();
+ private Set<String> uniqueKeys = new HashSet<>();
private String listConstraints = null;
private String referenceAttributes;
private LinkedHashMap<String, Object> retmap = new LinkedHashMap<>();
- private Map<String, String> matchableValues;
- private static final String PROPERTIES=".properties.";
- public static final String DATATYPE = "data_types.policy.data.";
- public static final String TYPE=".type";
- public static final String REQUIRED=".required";
- private static final String MATCHABLE=".matchable";
- private static final String STRING="string";
- private static final String INTEGER="integer";
- private static final String LIST="list";
- public static final String MAP="map";
- private static final String DEFAULT=".default";
- private static final String MANYFALSE=":MANY-false";
- private static final String MANYTRUE=":MANY-true";
- private static final String DEFAULTVALUE=":defaultValue-";
- private static final String REQUIREDVALUE=":required-";
- private static final String MATCHABLEKEY="matchable";
- private static final String REQUIREDFALSE=":required-false";
- private static final String REQUIREDTRUE=":required-true";
- private static final String MATCHINGTRUE="matching-true";
-
- private StringBuilder dataListBuffer=new StringBuilder();
- private List<String> dataConstraints= new ArrayList <>();
+ private Map<String, String> matchableValues;
+ private static final String PROPERTIES = ".properties.";
+ private static final String DATATYPE = "data_types.policy.data.";
+ private static final String TYPE = ".type";
+ private static final String REQUIRED = ".required";
+ private static final String MATCHABLE = ".matchable";
+ private static final String STRING = "string";
+ private static final String INTEGER = "integer";
+ private static final String BOOLEAN = "boolean";
+ private static final String LIST = "list";
+ private static final String MAP = "map";
+ private static final String DEFAULT = ".default";
+ private static final String MANYFALSE = ":MANY-false";
+ private static final String DESCRIPTION = ".description";
+
+ private static final String MANYTRUE = ":MANY-true";
+ private static final String DEFAULTVALUE = ":defaultValue-";
+ private static final String REQUIREDVALUE = ":required-";
+ private static final String MATCHABLEKEY = "matchable";
+ private static final String REQUIREDFALSE = ":required-false";
+ private static final String REQUIREDTRUE = ":required-true";
+ private static final String MATCHINGTRUE = "matching-true";
+ private static final String DESCRIPTION_KEY = "description";
+ private static final String DESCRIPTION_TOKEN =":description-";
+ private static final String PROPERTIES_KEY = "properties";
+ private static final String DATA_TYPE = "data_types";
+ private static final String ERROR = "error";
+ private static final String NODE_TYPE = "node_types";
+ private static final String TOSCA_DEFINITION_VERSION = "tosca_definitions_version";
+ private StringBuilder dataListBuffer = new StringBuilder();
+ private List<String> dataConstraints = new ArrayList<>();
private String attributeString = null;
+ private boolean isDuplicatedAttributes = false;
- public MSModelUtils(){
- }
+ public MSModelUtils() {}
- public MSModelUtils(String onap, String policy){
+ public MSModelUtils(String onap, String policy) {
this.onap = onap;
this.policy = policy;
}
- private enum ANNOTATION_TYPE{
+ private enum ANNOTATION_TYPE {
MATCHING, VALIDATION, DICTIONARY
};
@@ -103,8 +137,8 @@ public class MSModelUtils {
};
- public Map<String, MSAttributeObject> processEpackage(String file, MODEL_TYPE model){
- if (model == MODEL_TYPE.XMI ){
+ public Map<String, MSAttributeObject> processEpackage(String file, MODEL_TYPE model) {
+ if (model == MODEL_TYPE.XMI) {
processXMIEpackage(file);
}
return classMap;
@@ -742,31 +776,22 @@ public class MSModelUtils {
/*
* For TOSCA Model
*/
- public String parseTosca (String fileName){
- LinkedHashMap<String,String> map= new LinkedHashMap<>();
-
+ public String parseTosca(String fileName) {
+ LinkedHashMap<String, String> map = new LinkedHashMap<>();
try {
- map=load(fileName);
-
- if(map != null){
- if(map.get("error") != null){
- return map.get("error");
- }
+ map = load(fileName);
+ if (map != null && map.get(ERROR) != null) {
+ return map.get(ERROR);
}
-
parseDataAndPolicyNodes(map);
-
- LinkedHashMap<String,String> dataMapForJson=parseDataNodes(map);
-
+ LinkedHashMap<String, String> dataMapForJson = parseDataNodes(map);
constructJsonForDataFields(dataMapForJson);
-
- LinkedHashMap<String,LinkedHashMap<String,String>> mapKey= parsePolicyNodes(map);
-
+ LinkedHashMap<String, LinkedHashMap<String, String>> mapKey = parsePolicyNodes(map);
createAttributes(mapKey);
} catch (IOException e) {
logger.error(e);
- }catch(ParserException e){
+ } catch (ParserException e) {
logger.error(e);
return e.getMessage();
}
@@ -775,16 +800,16 @@ public class MSModelUtils {
}
@SuppressWarnings("unchecked")
- public LinkedHashMap<String, String> load(String fileName) throws IOException,ParserException {
+ public LinkedHashMap<String, String> load(String fileName) throws IOException, ParserException {
File newConfiguration = new File(fileName);
- StringBuilder orderInfo = new StringBuilder("[");
+ StringBuffer orderInfo = new StringBuffer("[");
Yaml yaml = new Yaml();
LinkedHashMap<Object, Object> yamlMap = null;
- try(InputStream is = new FileInputStream(newConfiguration)){
+ try (InputStream is = new FileInputStream(newConfiguration)) {
yamlMap = (LinkedHashMap<Object, Object>) yaml.load(is);
} catch (FileNotFoundException e) {
logger.error(e);
- }catch(Exception e){
+ } catch (Exception e) {
throw new ParserException("Invalid TOSCA Model format. Please make sure it is a valid YAML file");
}
@@ -796,33 +821,35 @@ public class MSModelUtils {
String message = validations(yamlMap);
- if(message != null){
- settings.put("error", message);
+ if (message != null) {
+ settings.put(ERROR, message);
return settings;
}
findNode(yamlMap);
- orderedElements.stream().forEach((string) -> {
- orderInfo.append(string);
- orderInfo.append(",");
- logger.info("Content: " + string);
- });
+ if (!isDuplicatedAttributes && orderedElements != null && orderedElements.size() > 0) {
+ orderedElements.stream().forEach((string) -> {
+ orderInfo.append(string);
+ orderInfo.append(",");
+ logger.info("Content: " + string);
+ });
- orderInfo.append("]");
+ orderInfo.append("]");
- dataOrderInfo = orderInfo.toString();
- dataOrderInfo = dataOrderInfo.replace(",]", "]");
+ dataOrderInfo = orderInfo.toString();
+ dataOrderInfo = dataOrderInfo.replace(",]", "]");
- logger.info("dataOrderInfo :" + dataOrderInfo);
+ logger.info("dataOrderInfo :" + dataOrderInfo);
+ }
- List<String> path = new ArrayList <>();
+ List<String> path = new ArrayList<>();
serializeMap(settings, sb, path, yamlMap);
return settings;
}
@SuppressWarnings("unchecked")
- private String validations(@SuppressWarnings("rawtypes") LinkedHashMap yamlMap){
+ private String validations(@SuppressWarnings("rawtypes") LinkedHashMap yamlMap) {
boolean isNoteTypeFound = false;
boolean isDataTypeFound = false;
@@ -830,76 +857,72 @@ public class MSModelUtils {
boolean isToscaVersionValueFound = false;
@SuppressWarnings("rawtypes")
Map m1 = new HashMap();
- short order =0;
- if(yamlMap != null){
+ short order = 0;
+ if (yamlMap != null) {
// Get a set of the entries
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings("rawtypes")
Set set = yamlMap.entrySet();
- // Get an iterator
- @SuppressWarnings("rawtypes")
+ // Get an iterator
+ @SuppressWarnings("rawtypes")
Iterator i = set.iterator();
- // Display elements
- while(i.hasNext()) {
- @SuppressWarnings("rawtypes")
- Entry me = (Entry)i.next();
-
- if("tosca_definitions_version".equals(me.getKey())){
- isToscaVersionKeyFound = true;
- order++;
- m1.put("tosca_definitions_version", order);
- }
-
- if("tosca_simple_yaml_1_0_0".equals(me.getValue())){
- isToscaVersionValueFound = true;
- }
-
- if("node_types".equals(me.getKey())){
- isNoteTypeFound = true;
- order++;
- m1.put("node_types", order);
- }
+ // Display elements
+ while (i.hasNext()) {
+ @SuppressWarnings("rawtypes")
+ Map.Entry me = (Map.Entry) i.next();
+
+ if (TOSCA_DEFINITION_VERSION.equals(me.getKey())) {
+ isToscaVersionKeyFound = true;
+ order++;
+ m1.put(TOSCA_DEFINITION_VERSION, order);
+ }
- if("data_types".equals(me.getKey())){
- isDataTypeFound = true;
- order++;
- m1.put("data_types", order);
- }
+ if ("tosca_simple_yaml_1_0_0".equals(me.getValue())) {
+ isToscaVersionValueFound = true;
+ }
- }
+ if (NODE_TYPE.equals(me.getKey())) {
+ isNoteTypeFound = true;
+ order++;
+ m1.put(NODE_TYPE, order);
+ }
+ if (DATA_TYPE.equals(me.getKey())) {
+ isDataTypeFound = true;
+ order++;
+ m1.put(DATA_TYPE, order);
+ }
- if(!isDataTypeFound){
- return "data_types are missing or invalid.";
- }
+ }
- if(!isToscaVersionKeyFound || !isToscaVersionValueFound){
- return "tosca_definitions_version is missing or invalid.";
- }
+ if (!isToscaVersionKeyFound || !isToscaVersionValueFound) {
+ return "tosca_definitions_version is missing or invalid.";
+ }
- if(!isNoteTypeFound){
- return "node_types are missing or invalid.";
- }
+ if (!isNoteTypeFound) {
+ return "node_types are missing or invalid.";
+ }
- short version = (short) m1.get("tosca_definitions_version");
+ short version = (short) m1.get(TOSCA_DEFINITION_VERSION);
- if(version > 1 ){
+ if (version > 1) {
return "tosca_definitions_version should be defined first.";
- }
+ }
- short data = (short) m1.get("data_types");
- short node = (short) m1.get("node_types");
- if(node > data){
+ short data = (short) m1.get(DATA_TYPE);
+ short node = (short) m1.get(NODE_TYPE);
+ if (isDataTypeFound && node > data) {
return "node_types should be defined before data_types.";
- }
+ }
}
return null;
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private void serializeMap(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path, Map<Object, Object> yamlMap) {
- for (Entry<Object, Object> entry : yamlMap.entrySet()) {
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ private void serializeMap(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path,
+ Map<Object, Object> yamlMap) {
+ for (Map.Entry<Object, Object> entry : yamlMap.entrySet()) {
if (entry.getValue() instanceof Map) {
path.add((String) entry.getKey());
@@ -916,7 +939,8 @@ public class MSModelUtils {
}
@SuppressWarnings("unchecked")
- private void serializeList(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path, List<String> yamlList) {
+ private void serializeList(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path,
+ List<String> yamlList) {
int counter = 0;
for (Object listEle : yamlList) {
if (listEle instanceof Map) {
@@ -934,7 +958,8 @@ public class MSModelUtils {
}
}
- private void serializeValue(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path, String name, Object value) {
+ private void serializeValue(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path,
+ String name, Object value) {
if (value == null) {
return;
}
@@ -947,23 +972,20 @@ public class MSModelUtils {
}
- void parseDataAndPolicyNodes(LinkedHashMap<String,String> map){
- for(String key:map.keySet()){
- if(key.contains("policy.nodes.Root"))
- {
+ void parseDataAndPolicyNodes(LinkedHashMap<String, String> map) {
+ for (String key : map.keySet()) {
+ if (key.contains("policy.nodes.Root")) {
continue;
- }
- else if(key.contains("policy.nodes")){
+ } else if (key.contains("policy.nodes")) {
String wordToFind = "policy.nodes.";
- int indexForPolicyNode=key.indexOf(wordToFind);
- String subNodeString= key.substring(indexForPolicyNode+13, key.length());
+ int indexForPolicyNode = key.indexOf(wordToFind);
+ String subNodeString = key.substring(indexForPolicyNode + 13, key.length());
stringBetweenDots(subNodeString);
- }
- else if(key.contains("policy.data")){
- String wordToFind="policy.data.";
- int indexForPolicyNode=key.indexOf(wordToFind);
- String subNodeString= key.substring(indexForPolicyNode+12, key.length());
+ } else if (key.contains("policy.data")) {
+ String wordToFind = "policy.data.";
+ int indexForPolicyNode = key.indexOf(wordToFind);
+ String subNodeString = key.substring(indexForPolicyNode + 12, key.length());
stringBetweenDotsForDataFields(subNodeString);
}
@@ -971,12 +993,12 @@ public class MSModelUtils {
}
// Second index of dot should be returned.
- public int stringBetweenDots(String str){
- String stringToSearch=str;
- String[]ss=stringToSearch.split("\\.");
- if(ss!=null){
- int len= ss.length;
- if(len>2){
+ public int stringBetweenDots(String str) {
+ String stringToSearch = str;
+ String[] ss = stringToSearch.split("\\.");
+ if (ss != null) {
+ int len = ss.length;
+ if (len > 2) {
uniqueKeys.add(ss[2]);
}
}
@@ -985,51 +1007,50 @@ public class MSModelUtils {
}
- public void stringBetweenDotsForDataFields(String str){
- String stringToSearch=str;
- String[]ss=stringToSearch.split("\\.");
- if(ss!=null){
- int len= ss.length;
+ public void stringBetweenDotsForDataFields(String str) {
+ String stringToSearch = str;
+ String[] ss = stringToSearch.split("\\.");
+ if (ss != null) {
+ int len = ss.length;
- if(len>2){
- uniqueDataKeys.add(ss[0]+"%"+ss[2]);
+ if (len > 2) {
+ uniqueDataKeys.add(ss[0] + "%" + ss[2]);
}
}
}
- void constructJsonForDataFields(LinkedHashMap<String,String> dataMapForJson){
- LinkedHashMap<String,LinkedHashMap<String,String>> dataMapKey= new LinkedHashMap <>();
+ void constructJsonForDataFields(LinkedHashMap<String, String> dataMapForJson) {
+ LinkedHashMap<String, LinkedHashMap<String, String>> dataMapKey = new LinkedHashMap<>();
LinkedHashMap<String, String> hmSub;
- for(Entry<String, String> entry: dataMapForJson.entrySet()){
- String uniqueDataKey= entry.getKey();
- String[] uniqueDataKeySplit=uniqueDataKey.split("%");
- String value= dataMapForJson.get(uniqueDataKey);
- if(dataMapKey.containsKey(uniqueDataKeySplit[0])){
+ for (Map.Entry<String, String> entry : dataMapForJson.entrySet()) {
+ String uniqueDataKey = entry.getKey();
+ String[] uniqueDataKeySplit = uniqueDataKey.split("%");
+ String value = dataMapForJson.get(uniqueDataKey);
+ if (dataMapKey.containsKey(uniqueDataKeySplit[0])) {
hmSub = dataMapKey.get(uniqueDataKeySplit[0]);
hmSub.put(uniqueDataKeySplit[1], value);
- }
- else{
- hmSub=new LinkedHashMap <>();
+ } else {
+ hmSub = new LinkedHashMap<>();
hmSub.put(uniqueDataKeySplit[1], value);
}
dataMapKey.put(uniqueDataKeySplit[0], hmSub);
}
- JSONObject mainObject= new JSONObject();
+ JSONObject mainObject = new JSONObject();
JSONObject json;
- for(Entry<String,LinkedHashMap<String,String>> entry: dataMapKey.entrySet()){
- String s=entry.getKey();
- json= new JSONObject();
- HashMap<String,String> jsonHm=dataMapKey.get(s);
- for(Entry<String,String> entryMap:jsonHm.entrySet()){
- String key=entryMap.getKey();
+ for (Map.Entry<String, LinkedHashMap<String, String>> entry : dataMapKey.entrySet()) {
+ String s = entry.getKey();
+ json = new JSONObject();
+ HashMap<String, String> jsonHm = dataMapKey.get(s);
+ for (Map.Entry<String, String> entryMap : jsonHm.entrySet()) {
+ String key = entryMap.getKey();
json.put(key, jsonHm.get(key));
}
- mainObject.put(s,json);
+ mainObject.put(s, json);
}
Iterator<String> keysItr = mainObject.keys();
- while(keysItr.hasNext()) {
+ while (keysItr.hasNext()) {
String key = keysItr.next();
String value = mainObject.get(key).toString();
retmap.put(key, value);
@@ -1039,166 +1060,175 @@ public class MSModelUtils {
logger.info(mainObject);
logger.info("###############################################################################");
}
- LinkedHashMap<String,String> parseDataNodes(LinkedHashMap<String,String> map){
- LinkedHashMap<String,String> dataMapForJson=new LinkedHashMap <>();
- matchableValues = new HashMap <>();
- for(String uniqueDataKey: uniqueDataKeys){
- if(uniqueDataKey.contains("%")){
- String[] uniqueDataKeySplit= uniqueDataKey.split("%");
- String findType=DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+TYPE;
- String typeValue=map.get(findType);
+
+ LinkedHashMap<String, String> parseDataNodes(LinkedHashMap<String, String> map) {
+ LinkedHashMap<String, String> dataMapForJson = new LinkedHashMap<>();
+ matchableValues = new HashMap<>();
+ for (String uniqueDataKey : uniqueDataKeys) {
+ if (uniqueDataKey.contains("%")) {
+ String[] uniqueDataKeySplit = uniqueDataKey.split("%");
+ String findType = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1] + TYPE;
+ String typeValue = map.get(findType);
logger.info(typeValue);
- String findRequired=DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+REQUIRED;
- String requiredValue= map.get(findRequired);
+ String findRequired = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1] + REQUIRED;
+ String requiredValue = map.get(findRequired);
- String matchable =DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+MATCHABLE;
+ String matchable = DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1] + MATCHABLE;
- String matchableValue= map.get(matchable);
+ String matchableValue = map.get(matchable);
- if(matchableValue != null && matchableValue.equalsIgnoreCase("true")){
- if(uniqueDataKey.contains("%")){
- String[] keys= uniqueDataKey.split("%");
- String key=keys[keys.length -1];
- matchableValues.put(key, MATCHINGTRUE);
- }else{
- matchableValues.put(uniqueDataKey, MATCHINGTRUE);
- }
+ if ("true".equalsIgnoreCase(matchableValue)) {
+ String key = uniqueDataKeySplit[uniqueDataKeySplit.length - 1];
+ matchableValues.put(key, MATCHINGTRUE);
}
- if(requiredValue == null || requiredValue.isEmpty()){
+ if (requiredValue == null || requiredValue.isEmpty()) {
requiredValue = "false";
}
- if(typeValue != null && (typeValue.equalsIgnoreCase(STRING)||
- typeValue.equalsIgnoreCase(INTEGER))){
-
- String findDefault=DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+DEFAULT;
- String defaultValue= map.get(findDefault);
- logger.info("defaultValue is:"+ defaultValue);
- logger.info("requiredValue is:"+ requiredValue);
-
- StringBuilder attributeIndividualStringBuilder= new StringBuilder();
- attributeIndividualStringBuilder.append(typeValue+DEFAULTVALUE);
- attributeIndividualStringBuilder.append(defaultValue+REQUIREDVALUE);
- attributeIndividualStringBuilder.append(requiredValue+MANYFALSE);
+ if (INTEGER.equalsIgnoreCase(typeValue) || STRING.equalsIgnoreCase(typeValue)
+ || typeValue.equalsIgnoreCase(BOOLEAN)) {
+ String findDefault =
+ DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1] + DEFAULT;
+ String findDescription =
+ DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1] + DESCRIPTION;
+ String defaultValue = map.get(findDefault);
+ String descriptionDefined = map.get(findDescription);
+ logger.info("defaultValue is:" + defaultValue);
+ logger.info("requiredValue is:" + requiredValue);
+
+ StringBuilder attributeIndividualStringBuilder = new StringBuilder();
+ attributeIndividualStringBuilder.append(typeValue + DEFAULTVALUE);
+ attributeIndividualStringBuilder.append(defaultValue + REQUIREDVALUE);
+ attributeIndividualStringBuilder.append(requiredValue + MANYFALSE);
+ attributeIndividualStringBuilder.append(DESCRIPTION_TOKEN + descriptionDefined);
dataMapForJson.put(uniqueDataKey, attributeIndividualStringBuilder.toString());
- }
- else if(LIST.equalsIgnoreCase(typeValue) || MAP.equalsIgnoreCase(typeValue)){
- logger.info("requiredValue is:"+ requiredValue);
- String findList= DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+".entry_schema.type";
- String listValue=map.get(findList);
- if(listValue!=null){
- logger.info("Type of list is:"+ listValue);
- //Its userdefined
- if(listValue.contains(".")){
- String trimValue=listValue.substring(listValue.lastIndexOf('.')+1);
- StringBuilder referenceIndividualStringBuilder= new StringBuilder();
- referenceIndividualStringBuilder.append(trimValue+REQUIREDVALUE);
- referenceIndividualStringBuilder.append(requiredValue+MANYTRUE);
+ } else if (LIST.equalsIgnoreCase(typeValue) || MAP.equalsIgnoreCase(typeValue)) {
+ logger.info("requiredValue is:" + requiredValue);
+ String findList =
+ DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
+ + ".entry_schema.type";
+ String findDefaultValue =
+ DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
+ + ".entry_schema.default";
+ String findDescription =
+ DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
+ + ".entry_schema.description";
+ String listValue = map.get(findList);
+ String defaultValue = map.get(findDefaultValue);
+ String description = map.get(findDescription);
+ if (listValue != null) {
+ logger.info("Type of list is:" + listValue);
+ // Its userdefined
+ if (listValue.contains(".")) {
+ String trimValue = listValue.substring(listValue.lastIndexOf('.') + 1);
+ StringBuilder referenceIndividualStringBuilder = new StringBuilder();
+ referenceIndividualStringBuilder.append(trimValue + REQUIREDVALUE);
+ referenceIndividualStringBuilder.append(requiredValue + MANYTRUE);
+ referenceIndividualStringBuilder.append(DESCRIPTION_TOKEN + description);
dataMapForJson.put(uniqueDataKey, referenceIndividualStringBuilder.toString());
- }//Its string
- else{
- StringBuilder stringListItems= new StringBuilder();
- if(LIST.equalsIgnoreCase(typeValue)){
- stringListItems.append(uniqueDataKeySplit[1].toUpperCase()+REQUIREDVALUE+requiredValue +MANYFALSE);
- }else if( MAP.equalsIgnoreCase(typeValue)){
- stringListItems.append(uniqueDataKeySplit[1].toUpperCase()+REQUIREDVALUE+requiredValue +MANYTRUE);
+ } else { // Its string
+ StringBuilder stringListItems = new StringBuilder();
+ if (LIST.equalsIgnoreCase(typeValue)) {
+ stringListItems.append(uniqueDataKeySplit[1].toUpperCase() + DEFAULTVALUE
+ + defaultValue + REQUIREDVALUE + requiredValue + MANYFALSE + DESCRIPTION_TOKEN
+ + description);
+ } else if (MAP.equalsIgnoreCase(typeValue)) {
+ stringListItems.append(uniqueDataKeySplit[1].toUpperCase() + DEFAULTVALUE
+ + defaultValue + REQUIREDVALUE + requiredValue + MANYTRUE + DESCRIPTION_TOKEN
+ + description);
}
dataMapForJson.put(uniqueDataKey, stringListItems.toString());
- boolean isConstraintsFound = false;
- for(int i=0;i<10;i++){
- String findConstraints= DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+".entry_schema.constraints.0.valid_values."+i;
- logger.info("findConstraints => " + findConstraints);
- String constraintsValue=map.get(findConstraints);
- logger.info("constraintsValue => " + constraintsValue);
-
- if((constraintsValue==null || constraintsValue.isEmpty()) && i==0){ //if no constraints at all ( index i as 0 can tell this )
- isConstraintsFound = false;
- //if type is list but no constraints
- String newValue = dataMapForJson.get(uniqueDataKey).replace("MANY-false", "MANY-true");
- newValue = newValue.replace(uniqueDataKeySplit[1].toUpperCase()+":", "");
- dataMapForJson.put(uniqueDataKey, newValue);
+ dataListBuffer.append(uniqueDataKeySplit[1].toUpperCase() + "=[");
+ for (int i = 0; i < 10; i++) {
+ String findConstraints =
+ DATATYPE + uniqueDataKeySplit[0] + PROPERTIES + uniqueDataKeySplit[1]
+ + ".entry_schema.constraints.0.valid_values." + i;
+ String constraintsValue = map.get(findConstraints);
+ logger.info(constraintsValue);
+ if (constraintsValue == null) {
break;
- } else{
- isConstraintsFound = true;
- if(i == 0){ // only need to add one time for the same attribute
- dataListBuffer.append(uniqueDataKeySplit[1].toUpperCase()+"=[");
- }
-
- if(constraintsValue==null){
- constraintsValue = "";
- }else if (constraintsValue.contains("=")) {
+ } else {
+ System.out.println("constraintsValue => " + constraintsValue);
+ if (constraintsValue.contains("=")) {
constraintsValue = constraintsValue.replace("=", "equal-sign");
}
-
dataConstraints.add(constraintsValue);
- dataListBuffer.append(constraintsValue+",");
+ dataListBuffer.append(constraintsValue + ",");
}
}
- if(isConstraintsFound){
- dataListBuffer.append("]#");
- }
+ dataListBuffer.append("]#");
+ logger.info(dataListBuffer);
}
- }else{
- logger.info("entry_schema.type is not defined correctly");
}
- }
- else{
- String findUserDefined=DATATYPE+uniqueDataKeySplit[0]+"."+"properties"+"."+uniqueDataKeySplit[1]+TYPE;
- String userDefinedValue=map.get(findUserDefined);
- String trimValue=userDefinedValue.substring(userDefinedValue.lastIndexOf('.')+1);
- StringBuilder referenceIndividualStringBuilder= new StringBuilder();
- referenceIndividualStringBuilder.append(trimValue+REQUIREDVALUE);
- referenceIndividualStringBuilder.append(requiredValue+MANYFALSE);
+ } else {
+ String findUserDefined =
+ DATATYPE + uniqueDataKeySplit[0] + "." + PROPERTIES_KEY + "." + uniqueDataKeySplit[1]
+ + ".type";
+ String findDescription =
+ DATATYPE + uniqueDataKeySplit[0] + "." + PROPERTIES_KEY + "." + uniqueDataKeySplit[1]
+ + ".description";
+ String userDefinedValue = map.get(findUserDefined);
+ String description = map.get(findDescription);
+ // String requiredValue = map.get(required);
+ String trimValue = userDefinedValue.substring(userDefinedValue.lastIndexOf('.') + 1);
+ StringBuilder referenceIndividualStringBuilder = new StringBuilder();
+ referenceIndividualStringBuilder.append(trimValue + REQUIREDVALUE);
+ referenceIndividualStringBuilder.append(requiredValue + MANYFALSE);
+ referenceIndividualStringBuilder.append(DESCRIPTION_TOKEN + description);
dataMapForJson.put(uniqueDataKey, referenceIndividualStringBuilder.toString());
}
+ } else {
+ matchableValues.put(uniqueDataKey, MATCHINGTRUE);
}
}
return dataMapForJson;
}
+ LinkedHashMap<String, LinkedHashMap<String, String>> parsePolicyNodes(Map<String, String> map)
+ throws ParserException {
+ LinkedHashMap<String, LinkedHashMap<String, String>> mapKey = new LinkedHashMap<>();
+ for (String uniqueKey : uniqueKeys) {
+ LinkedHashMap<String, String> hm;
- LinkedHashMap<String, LinkedHashMap<String, String>> parsePolicyNodes(Map<String,String> map) throws ParserException{
- LinkedHashMap<String,LinkedHashMap<String,String>> mapKey= new LinkedHashMap <>();
- for(String uniqueKey: uniqueKeys){
- LinkedHashMap<String,String> hm;
-
- for(Entry<String,String> entry:map.entrySet()){
- String key=entry.getKey();
- if(key.contains(uniqueKey) && key.contains("policy.nodes")){
- if(mapKey.containsKey(uniqueKey)){
+ for (Entry<String, String> entry : map.entrySet()) {
+ String key = entry.getKey();
+ if (key.contains(uniqueKey) && key.contains("policy.nodes")) {
+ if (mapKey.containsKey(uniqueKey)) {
hm = mapKey.get(uniqueKey);
- String keyStr= key.substring(key.lastIndexOf('.')+1);
- String valueStr= map.get(key);
- if("type".equalsIgnoreCase(keyStr) && ((key.contains("entry_schema.0.type") || key.contains("entry_schema.type") && valueStr.contains("policy.data.")))){
- throw new ParserException("For using user defined object type, Please make sure no space between 'type:' and object " + valueStr );
+ String keyStr = key.substring(key.lastIndexOf('.') + 1);
+ String valueStr = map.get(key);
+ if ("type".equalsIgnoreCase(keyStr)
+ && key.contains("entry_schema.0.type") || key.contains("entry_schema.type")
+ && valueStr.contains("policy.data.")) {
+ throw new ParserException(
+ "For user defined object type, Please make sure no space between 'type:' and object "
+ + valueStr);
}
- if("type".equals(keyStr)){
- if(!key.contains("entry_schema"))
- {
- hm.put(keyStr,valueStr);
+ if ("type".equals(keyStr)) {
+ if (!key.contains("entry_schema")) {
+ hm.put(keyStr, valueStr);
}
- }else{
- hm.put(keyStr,valueStr);
+ } else {
+ hm.put(keyStr, valueStr);
}
} else {
- hm = new LinkedHashMap <>();
- String keyStr= key.substring(key.lastIndexOf('.')+1);
- String valueStr= map.get(key);
- if(key.contains(".objective.")){
+ hm = new LinkedHashMap<>();
+ String keyStr = key.substring(key.lastIndexOf('.') + 1);
+ String valueStr = map.get(key);
+ if (key.contains(".objective.")) {
throw new ParserException("Attribute objective is a key word. Please use a different name");
}
- if(("type").equals(keyStr)){
- if(!key.contains("entry_schema"))
- {
- hm.put(keyStr,valueStr);
+ if (("type").equals(keyStr)) {
+ if (!key.contains("entry_schema")) {
+ hm.put(keyStr, valueStr);
}
- }else{
- hm.put(keyStr,valueStr);
+ } else {
+ hm.put(keyStr, valueStr);
}
mapKey.put(uniqueKey, hm);
}
@@ -1208,92 +1238,94 @@ public class MSModelUtils {
return mapKey;
}
- void createAttributes(LinkedHashMap<String,LinkedHashMap<String,String>> mapKey){
- StringBuilder attributeStringBuilder= new StringBuilder();
- StringBuilder referenceStringBuilder= new StringBuilder();
- StringBuilder listBuffer= new StringBuilder();
- List<String> constraints= new ArrayList<>();
- for(Entry<String,LinkedHashMap<String,String>> entry: mapKey.entrySet()){
- String keySetString= entry.getKey();
- LinkedHashMap<String,String> keyValues=mapKey.get(keySetString);
- if(STRING.equalsIgnoreCase(keyValues.get("type"))||
- INTEGER.equalsIgnoreCase(keyValues.get("type"))){
- StringBuilder attributeIndividualStringBuilder= new StringBuilder();
- attributeIndividualStringBuilder.append(keySetString+"=");
- attributeIndividualStringBuilder.append(keyValues.get("type")+DEFAULTVALUE);
- attributeIndividualStringBuilder.append(keyValues.get("default")+REQUIREDVALUE);
- attributeIndividualStringBuilder.append(keyValues.get("required")+MANYFALSE);
- attributeStringBuilder.append(attributeIndividualStringBuilder+",");
- if("true".equalsIgnoreCase(keyValues.get(MATCHABLEKEY))){
+ void createAttributes(LinkedHashMap<String, LinkedHashMap<String, String>> mapKey) {
+ StringBuilder attributeStringBuilder = new StringBuilder();
+ StringBuilder referenceStringBuilder = new StringBuilder();
+ StringBuilder listBuffer = new StringBuilder();
+ List<String> constraints = new ArrayList<>();
+ for (Map.Entry<String, LinkedHashMap<String, String>> entry : mapKey.entrySet()) {
+ String keySetString = entry.getKey();
+ LinkedHashMap<String, String> keyValues = mapKey.get(keySetString);
+ if (keyValues.get("type") != null && keyValues.get("type").equalsIgnoreCase(STRING)
+ || keyValues.get("type") != null && keyValues.get("type").equalsIgnoreCase(INTEGER)
+ || keyValues.get("type") != null && keyValues.get("type").equalsIgnoreCase(BOOLEAN)) {
+ StringBuilder attributeIndividualStringBuilder = new StringBuilder();
+ attributeIndividualStringBuilder.append(keySetString + "=");
+ attributeIndividualStringBuilder.append(keyValues.get("type") + DEFAULTVALUE);
+ attributeIndividualStringBuilder.append(keyValues.get("default") + REQUIREDVALUE);
+ attributeIndividualStringBuilder.append(keyValues.get("required") + MANYFALSE);
+ attributeIndividualStringBuilder.append(DESCRIPTION_TOKEN + keyValues.get(DESCRIPTION_KEY));
+ attributeStringBuilder.append(attributeIndividualStringBuilder + ",");
+ if (keyValues.get(MATCHABLEKEY) != null && keyValues.get(MATCHABLEKEY).equalsIgnoreCase("true")) {
matchableValues.put(keySetString, MATCHINGTRUE);
}
- }
- else if(LIST.equalsIgnoreCase(keyValues.get("type"))){
+ } else if (LIST.equalsIgnoreCase(keyValues.get("type"))) {
- if(("true").equalsIgnoreCase(keyValues.get(MATCHABLEKEY))){
+ if ("true".equalsIgnoreCase(keyValues.get(MATCHABLEKEY))) {
matchableValues.put(keySetString, MATCHINGTRUE);
}
- //List Datatype
- Set<String> keys= keyValues.keySet();
- Iterator<String> itr=keys.iterator();
+ // List Datatype
+ Set<String> keys = keyValues.keySet();
+ Iterator<String> itr = keys.iterator();
boolean isDefinedType = false;
- while(itr.hasNext()){
- String key= itr.next();
- if((!("type").equals(key) ||("required").equals(key)))
- {
- String value= keyValues.get(key);
- //The "." in the value determines if its a string or a user defined type.
- if (!value.contains(".")){
- //This is string
- if(StringUtils.isNumeric(key) ){ //only integer key for the value of Constrains
+ while (itr.hasNext()) {
+ String key = itr.next();
+ if ((!("type").equals(key) || ("required").equals(key))) {
+ String value = keyValues.get(key);
+ // The "." in the value determines if its a string or a user defined type.
+ if (!value.contains(".")) {
+ // This is string
+ if (StringUtils.isNumeric(key)) { // only integer key for the value of Constrains
constraints.add(keyValues.get(key));
}
- }else{
- //This is user defined type
- String trimValue=value.substring(value.lastIndexOf('.')+1);
- StringBuilder referenceIndividualStringBuilder= new StringBuilder();
- referenceIndividualStringBuilder.append(keySetString+"="+trimValue+MANYTRUE);
- referenceStringBuilder.append(referenceIndividualStringBuilder+",");
+ } else {
+ // This is user defined type
+ String trimValue = value.substring(value.lastIndexOf('.') + 1);
+ StringBuilder referenceIndividualStringBuilder = new StringBuilder();
+ referenceIndividualStringBuilder.append(keySetString + "=" + trimValue + MANYTRUE
+ + DESCRIPTION_TOKEN + keyValues.get(DESCRIPTION_KEY));
+ referenceStringBuilder.append(referenceIndividualStringBuilder + ",");
isDefinedType = true;
}
}
}
- if(!isDefinedType && LIST.equalsIgnoreCase(keyValues.get("type"))){ //type is not user defined and is a list but no constraints defined.
- if(constraints == null || constraints.isEmpty()){
- referenceStringBuilder.append(keySetString+"=MANY-true"+",");
+ if (!isDefinedType && LIST.equalsIgnoreCase(keyValues.get("type"))) {
+ if (constraints == null || constraints.isEmpty()) {
+ referenceStringBuilder.append(keySetString + "=MANY-true" + ",");
}
}
- }else{
- //User defined Datatype.
- if("true".equalsIgnoreCase(keyValues.get(MATCHABLEKEY))){
+ } else {
+ // User defined Datatype.
+ if ("true".equalsIgnoreCase(keyValues.get(MATCHABLEKEY))) {
matchableValues.put(keySetString, MATCHINGTRUE);
}
- String value=keyValues.get("type");
- if(value != null && !value.isEmpty()){
- String trimValue=value.substring(value.lastIndexOf('.')+1);
- StringBuilder referenceIndividualStringBuilder= new StringBuilder();
- referenceIndividualStringBuilder.append(keySetString+"="+trimValue+MANYFALSE);
- referenceStringBuilder.append(referenceIndividualStringBuilder+",");
- }else{
+ String value = keyValues.get("type");
+ if (value != null && !value.isEmpty()) {
+ String trimValue = value.substring(value.lastIndexOf('.') + 1);
+ StringBuilder referenceIndividualStringBuilder = new StringBuilder();
+ referenceIndividualStringBuilder.append(keySetString + "=" + trimValue + MANYFALSE
+ + DESCRIPTION_TOKEN + keyValues.get(DESCRIPTION_KEY));
+ referenceStringBuilder.append(referenceIndividualStringBuilder + ",");
+ } else {
logger.info("keyValues.get(type) is null/empty");
}
}
- if(constraints!=null && !constraints.isEmpty()){
- //List handling.
- listBuffer.append(keySetString.toUpperCase()+"=[");
- for(String str:constraints){
- listBuffer.append(str+",");
+ if (constraints != null && constraints.isEmpty() == false) {
+ // List handling.
+ listBuffer.append(keySetString.toUpperCase() + "=[");
+ for (String str : constraints) {
+ listBuffer.append(str + ",");
}
listBuffer.append("]#");
logger.info(listBuffer);
- StringBuilder referenceIndividualStringBuilder= new StringBuilder();
- referenceIndividualStringBuilder.append(keySetString+"="+keySetString.toUpperCase()+MANYFALSE);
- referenceStringBuilder.append(referenceIndividualStringBuilder+",");
+ StringBuilder referenceIndividualStringBuilder = new StringBuilder();
+ referenceIndividualStringBuilder.append(keySetString + "=" + keySetString.toUpperCase() + MANYFALSE);
+ referenceStringBuilder.append(referenceIndividualStringBuilder + ",");
constraints.clear();
}
}
@@ -1302,47 +1334,57 @@ public class MSModelUtils {
logger.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
- logger.info("Whole attribute String is:"+attributeStringBuilder);
- logger.info("Whole reference String is:"+referenceStringBuilder);
- logger.info("List String is:"+listBuffer);
- logger.info("Data list buffer is:"+dataListBuffer);
+ logger.info("Whole attribute String is:" + attributeStringBuilder);
+ logger.info("Whole reference String is:" + referenceStringBuilder);
+ logger.info("List String is:" + listBuffer);
+ logger.info("Data list buffer is:" + dataListBuffer);
logger.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
- this.listConstraints=dataListBuffer.toString();
- this.referenceAttributes=referenceStringBuilder.toString();
- this.attributeString=attributeStringBuilder.toString();
+ this.listConstraints = dataListBuffer.toString();
+ this.referenceAttributes = referenceStringBuilder.toString();
+ this.attributeString = attributeStringBuilder.toString();
}
@SuppressWarnings("unchecked")
- public void findNode(LinkedHashMap<Object, Object> map) {
+ private void findNode(LinkedHashMap<Object, Object> map) {
- map.forEach((key,value) -> {
+ map.forEach((key, value) -> {
// if the value is properties and its type is map object, then save all the keys
- if(key.equals("properties") && value instanceof Map){
- saveNodes((LinkedHashMap<?, ?>)value);
+ if (key.equals(PROPERTIES_KEY) && value instanceof Map) {
+ saveNodes((LinkedHashMap<?, ?>) value);
+ if (isDuplicatedAttributes) {
+ orderedElements = new ArrayList<String>();
+ return;
+ }
}
- if(!key.equals("policy.nodes.Root") && value instanceof Map){
- //value is a Map object, then make a recursive call
- findNode((LinkedHashMap<Object, Object>) value);
+ if (!key.equals("policy.nodes.Root")) {
+ // value is a Map object, then make a recursive call
+ if (value instanceof Map) {
+ findNode((LinkedHashMap<Object, Object>) value);
+ }
}
});
}
- public void saveNodes(LinkedHashMap<?, ?> map) {
-
- map.forEach((key,value) -> {
+ private void saveNodes(LinkedHashMap<?, ?> map) {
- orderedElements.add((String)key);
-
- });
+ for (Entry<?, ?> entry : map.entrySet()) {
+ if (orderedElements.indexOf((String) entry.getKey()) >= 0) { // duplicated attribute names
+ isDuplicatedAttributes = true;
+ return;
+ } else {
+ orderedElements.add((String) entry.getKey());
+ }
+ }
}
public String getAttributeString() {
return attributeString;
}
+
public void setAttributeString(String attributeString) {
this.attributeString = attributeString;
}
@@ -1354,6 +1396,7 @@ public class MSModelUtils {
public void setRetmap(LinkedHashMap<String, Object> retmap) {
this.retmap = retmap;
}
+
public Map<String, String> getMatchableValues() {
return matchableValues;
}
@@ -1361,6 +1404,7 @@ public class MSModelUtils {
public void setMatchableValues(Map<String, String> matchableValues) {
this.matchableValues = matchableValues;
}
+
public String getReferenceAttributes() {
return referenceAttributes;
}
@@ -1368,6 +1412,7 @@ public class MSModelUtils {
public void setReferenceAttributes(String referenceAttributes) {
this.referenceAttributes = referenceAttributes;
}
+
public String getListConstraints() {
return listConstraints;
}
@@ -1375,6 +1420,7 @@ public class MSModelUtils {
public void setListConstraints(String listConstraints) {
this.listConstraints = listConstraints;
}
+
public String getDataOrderInfo() {
return dataOrderInfo;
}
@@ -1383,4 +1429,4 @@ public class MSModelUtils {
this.dataOrderInfo = dataOrderInfo;
}
-} \ No newline at end of file
+}
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 dca8e9166..d53a9198e 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
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$window', '$compile', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, $window, $compile, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) {
$("#dialog").hide();
@@ -170,9 +171,9 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
$scope.choices = [];
$scope.attributeDatas = [{"attributes" : $scope.choices}];
- $scope.isInitEditTemplate = true; //just initially create the edit template, didn't click add button yet.
addNewChoice = function(value) {
- console.log("input value : " + value);
+ console.log("input key : " + value);
+ var isFoundInRuleData = false;
if(value != undefined){
if (value.startsWith('div.')){
value = value.replace('div.','');
@@ -188,9 +189,15 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
clone.id = ''+value+'@'+addElement;
clone.value = '';
if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){ //if it's view or edit
- if($scope.temp.policy.ruleData[clone.id] || ($scope.temp.policy.editPolicy && !$scope.isInitEditTemplate)){ // Only append child if its value found in ruleData or edit mode
+ if($scope.temp.policy.ruleData[clone.id] || $scope.temp.policy.editPolicy){ // Only append child if its value found in ruleData or edit mode
if($scope.temp.policy.ruleData[clone.id]){
clone.value = $scope.temp.policy.ruleData[clone.id];
+ isFoundInRuleData = true;
+ }
+ console.log(" clone.value :" + clone.value);
+ console.log(" clone.id :" + clone.id);
+ if(!isFoundInRuleData && isInitViewEdit){
+ return;
}
if(!clone.className.includes("child_single")){
clone.className += ' child_single'; //here cloned is single element
@@ -246,6 +253,8 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
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);
@@ -347,6 +356,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var enumKeyList = [];
var dictionaryList = [];
var dictionaryNameList = [];
+ var isInitViewEdit = false;
$scope.addDataToFields = function(serviceName, version){
if(serviceName != null && version !=null){
var service=serviceName+"-v"+version;
@@ -358,7 +368,11 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
console.log("service: " +service);
var dataOrderInfo = "";
+
+ booleanTrueElements = [];
+ document.getElementById("msPolicyloader").style.visibility = "visible";
+
$.ajax({
type : 'POST',
url : uuu,
@@ -366,6 +380,9 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
contentType: 'application/json',
data: JSON.stringify(postData),
success : function(data){
+
+ document.getElementById("msPolicyloader").style.visibility = "hidden";
+
$scope.$apply(function(){
var plainAttributeKeys = [];
$scope.dcaeModelData = data[0].dcaeModelData;
@@ -442,14 +459,11 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
});
if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){ // If it's veiw or edit
-
- if($scope.temp.policy.editPolicy){
- $scope.isInitEditTemplate = true;
- }
-
+ isInitViewEdit = true;
var checkData = [];
var data = [];
// If ruleData contains extra elements created by clicked add button
+ console.log("$scope.temp.policy.ruleData:" + $scope.temp.policy.ruleData);
if($scope.temp.policy.ruleData != null){
var propNames = Object.getOwnPropertyNames($scope.temp.policy.ruleData);
propNames.forEach(function(name) {
@@ -497,33 +511,44 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
}
}
+
+
+ for (var i = 0; i < $scope.labelManyKeys.length; i++) {
+ var label = $scope.labelManyKeys[i];
+ if(parentLevelElements){
+ for (var k = 0; k < parentLevelElements.length; k++){
+ if(label == parentLevelElements[k]){
+ addNewChoice(label);
+ }
+ }
+ }
+ }
+
//if no layout order info, keep the process as before
if(!dataOrderInfo){
- for(var i =0; i < unique.length; i++){
- //remove @x and let addNewChoice add @1 or @2...
- //var newKey = unique[i].substring(0, unique[i].length-2);
- var index = unique[i].lastIndexOf("@");
- var newKey = unique[i].substring(0, index);
- console.log("newKey: " + newKey);
- addNewChoice(newKey);
- }
+ for(var i =0; i < unique.length; i++){
+ if(unique[i] != "*processed*"){
+ var index = unique[i].lastIndexOf("@");
+ var newKey = unique[i].substring(0, index);
+ console.log("newKey: " + newKey);
+
+ var newElement = document.getElementById("div."+unique[j]);
+ //check weather it has been created already
+ if(newElement != null){
+ continue;
+ }else{
+ newElement = document.getElementById(unique[j]);
+ if(newElement != null){
+ continue;
+ }
+ }
+
+ if(newKey){
+ addNewChoice(newKey);
+ }
+ }
+ }
}else{
-
- for (var i = 0; i < $scope.labelManyKeys.length; i++) {
- //console.log("dataOrderInfo["+i+"]"+ dataOrderInfo[i]);
- var label = $scope.labelManyKeys[i];
-
- if(parentLevelElements){
- for (var k = 0; k < parentLevelElements.length; k++){
- if(label == parentLevelElements[k]){
- addNewChoice(label);
- }
- }
-
- }
-
- }
-
//---reset to default
dataOrderInfo = [];
$scope.labelManyKeys = [];
@@ -561,6 +586,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var ele = angular.element(document.getElementById("DynamicTemplate"));
$compile(ele.contents())($scope);
$scope.$apply();
+ isInitViewEdit = false;
},
error : function(data){
@@ -729,10 +755,16 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
} else {
var attirbuteLabel = label;
var defaultValue='';
+ var description='';
var isRequired = false;
if (layOutData[key].includes('defaultValue-')){
defaultValue = layOutData[key].split('defaultValue-')[1];
}
+
+ if (layOutData[key].includes('description-')){
+ description = layOutData[key].split('description-')[1];
+ }
+
if (key==="0"){
array = true;
@@ -748,7 +780,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var subAttributes = $scope.dcaeModelData.sub_attributes;
- if(subAttributes){
+ if(subAttributes){
var jsonObject = JSON.parse(subAttributes);
var lablInfo = findVal(jsonObject, attributekey);
@@ -757,6 +789,14 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
if(lablInfo.includes('required-true')){
isRequired = true;
}
+ if(lablInfo.includes('defaultValue-')){
+ defaultValue = lablInfo.split('defaultValue-')[1];
+ }
+
+ if(lablInfo.includes('description-')){
+ description = lablInfo.split('description-')[1];
+ }
+
}else{
var allkeys = Object.keys(jsonObject);
if(allkeys){
@@ -769,6 +809,15 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
if (tempObject[key].includes('required-true')){
isRequired = true;
}
+
+ if(tempObject[key].includes('defaultValue-')){
+ defaultValue = tempObject[key].split('defaultValue-')[1];
+ }
+
+ if(tempObject[key].includes('description-')){
+ description = tempObject[key].split('description-')[1];
+ }
+
}
}
}
@@ -783,7 +832,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
case string:
if($scope.dataOrderInfo){
elementOrderNum++;
- elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue, "isRequired": isRequired, "type":"text"};
+ elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue, "isRequired": isRequired, "type":"text", "description":description};
$scope.layOutElementList.push(elementObject);
}else{
$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "text");
@@ -793,7 +842,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
case integerValue:
if($scope.dataOrderInfo){
elementOrderNum++;
- elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"number"};
+ elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"number" , "description":description};
$scope.layOutElementList.push(elementObject);
}else{
$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "number");
@@ -802,7 +851,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
case double:
if($scope.dataOrderInfo){
elementOrderNum++;
- elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"double"};
+ elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"double", "description":description};
$scope.layOutElementList.push(elementObject);
}else{
$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "double");
@@ -811,7 +860,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
case boolean:
if($scope.dataOrderInfo){
elementOrderNum++;
- elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": layOutData[key], "list": getBooleanList, "isRequired": isRequired, "type":"dropBox"};
+ elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue, "isRequired": isRequired, "type":"boolean", "description":description};
$scope.layOutElementList.push(elementObject);
}else{
$scope.dropBoxLayout(attirbuteLabel, attributekey, array, layOutData[key], getBooleanList());
@@ -827,7 +876,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
if (list.length===0){ //not dropdown element
if($scope.dataOrderInfo){
elementOrderNum++;
- elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"text"};
+ elementObject = {"id": elementOrderNum,"attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "type":"text", "description":description};
$scope.layOutElementList.push(elementObject);
}else{
@@ -836,7 +885,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}else{
if($scope.dataOrderInfo){
elementOrderNum++;
- elementObject = {"id": elementOrderNum, "attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": layOutData[key],"isRequired": isRequired, "list":list, "type":"dropBox"};
+ elementObject = {"id": elementOrderNum, "attributekey" : attributekey, "array": array, "attirbuteLabel" : attirbuteLabel, "defaultValue": defaultValue,"isRequired": isRequired, "list":list, "type":"dropBox", "description":description};
$scope.layOutElementList.push(elementObject);
}else{
$scope.dropBoxLayout(attirbuteLabel, attributekey, array, layOutData[key], list, isRequired);
@@ -927,15 +976,16 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var attirbuteLabel = layOutElementList[j].attirbuteLabel.toString().trim();
var defaultValue = layOutElementList[j].defaultValue.toString().trim();
+ var description = layOutElementList[j].description;
var isRequired = layOutElementList[j].isRequired;
console.log("layOutElementList[" +j+ "]: id:" + layOutElementList[j].id + ", attributekey:"+ layOutElementList[j].attributekey + ", attirbuteLabel:" + layOutElementList[j].attirbuteLabel);
- console.log("layOutElementList[" +j+ "]: type:" + layOutElementList[j].type);
+ 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);
+ $scope.dropBoxLayout(attirbuteLabel, attributekey, layOutElementList[j].array, defaultValue, layOutElementList[j].list, isRequired, description);
}else{
- $scope.attributeBox(attributekey, layOutElementList[j].array, attirbuteLabel, defaultValue, isRequired, layOutElementList[j].type);
+ $scope.attributeBox(attributekey, layOutElementList[j].array, attirbuteLabel, defaultValue, isRequired, layOutElementList[j].type, description);
}
@@ -949,7 +999,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
- $scope.attributeBox = function(attibuteKey, attributeManyKey, labelValue, defaultValue, isRequired, dataType ){
+ $scope.attributeBox = function(attibuteKey, attributeManyKey, labelValue, defaultValue, isRequired, dataType, description){
$scope.temp.policy.ruleGridData.push(attibuteKey);
var br = document.createElement("BR");
@@ -986,12 +1036,59 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
if(dataType == "double"){
textField.setAttribute("type" , "number");
textField.setAttribute("step" , "any");
- }else{
+
+ }else if(dataType == "boolean"){ //gw1218 testing boolean
+ var booleanDiv = document.createElement("div");
+
+ booleanDiv.setAttribute("class" , "onoffswitch");
+
+ //var checkField = document.createElement("INPUT");
+ textField.setAttribute("type" , "checkbox");
+ textField.setAttribute("name" , "onoffswitch");
+ textField.setAttribute("class" , "onoffswitch-checkbox");
+ textField.setAttribute("id" , ''+labelValue +attibuteKey+'');
+ if(defaultValue && defaultValue == "true") {
+ textField.setAttribute("checked" , "true");
+ }else{
+ textField.setAttribute("checked" , "false");
+ }
+
+ var booleanlabel = document.createElement("Label");
+ booleanlabel.setAttribute("class" , "onoffswitch-label");
+ booleanlabel.setAttribute("for" , ''+labelValue +attibuteKey+'');
+
+ var span1 = document.createElement("span");
+ span1.setAttribute("class" , "onoffswitch-inner");
+
+ var span2 = document.createElement("span");
+ span2.setAttribute("class" , "onoffswitch-switch");
+
+
+ booleanlabel.appendChild(span1);
+ booleanlabel.appendChild(span2);
+ booleanDiv.appendChild(textField);
+ booleanDiv.appendChild(booleanlabel);
+
+ document.getElementById(divID).appendChild(label);
+ document.getElementById(divID).appendChild(booleanDiv);
+
+ //return;
+ } else{
textField.setAttribute("type" , dataType);
}
+
+
+
+ }
+
+ if(dataType != "boolean"){
+ textField.setAttribute("style" , "width:300px;");
+ textField.setAttribute("ng-disabled" , "temp.policy.readOnly");
+ if(description && description != "null"){
+ textField.setAttribute("title", description);
+ }
}
- textField.setAttribute("style" , "width:300px;");
- textField.setAttribute("ng-disabled" , "temp.policy.readOnly");
+
var checkKey;
var id = "";
if(attributeManyKey){
@@ -1022,11 +1119,12 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
textField.className += ' first_child';
if(isRequired){
textField.setAttribute("required", "true");
- }
+ }
+
divTag.appendChild(textField);
document.getElementById(divID).appendChild(divTag);
- }else{
+ }else if (dataType != "boolean"){
checkKey = labelValue + attibuteKey;
textField.setAttribute("id" , ''+labelValue +attibuteKey+'');
if(document.getElementById(divID).hasAttribute('required') || !document.getElementById(divID).hasAttribute('data-conditional')){
@@ -1056,7 +1154,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
- if(divID.includes("@0") && divID.includes("div.")){
+ if(dataType != "boolean" && divID.includes("@0") && divID.includes("div.")){
var firstChild_Id = divID.split("@0")[0];
var firstChild_element = document.getElementById(firstChild_Id);
if(firstChild_element){
@@ -1073,7 +1171,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
console.log('firstChild_Id: ' + firstChild_Id);
console.log('divID: ' + divID);
- if (defaultValue.length > 0){
+ if(dataType != "boolean" && defaultValue.length > 0){
if(defaultValue.includes(":")){
defaultValue = defaultValue.split(":")[0];
if(defaultValue === "NA") {
@@ -1098,7 +1196,12 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
}
}
- plainAttributeKeys.push(labelValue + attibuteKey+'*'+attributeManyKey);
+
+ if (dataType != "boolean"){
+ plainAttributeKeys.push(labelValue + attibuteKey+'*'+attributeManyKey);
+ }else{
+ plainAttributeKeys.push(labelValue + attibuteKey+'*'+"boolean");
+ }
};
$scope.labelManyKeys = [];
@@ -1201,7 +1304,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
};
- $scope.dropBoxLayout = function(labelLevel, attributeName, many , refValue, listemunerateValues, isRequired){
+ $scope.dropBoxLayout = function(labelLevel, attributeName, many , defaultValue, listemunerateValues, isRequired, description){
var br = document.createElement("BR");
if (labelLevel.length < 1){
@@ -1259,6 +1362,10 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
listField.setAttribute("style" , "width:300px;");
listField.setAttribute("ng-disabled" , "temp.policy.readOnly");
+ if(description && description != "null"){
+ listField.setAttribute("title", description);
+ }
+
if(isRequired){
if(document.getElementById(divID).hasAttribute('data-conditional')){
listField.setAttribute("data-conditional", divID);
@@ -1296,6 +1403,14 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}else {
document.getElementById(divID).appendChild(listField).multiple = false;
plainAttributeKeys.push(labelLevel + attributeName+'*'+false);
+
+ if (defaultValue){
+ if(defaultValue.includes(':')){
+ defaultValue = defaultValue.split(':')[0];
+ }
+ var location = listemunerateValues.indexOf(defaultValue);
+ document.getElementById(labelLevel +attributeName).options[location+1].selected = true;
+ }
}
if($scope.temp.policy.ruleData != null){
@@ -1372,12 +1487,30 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
jsonPolicy[key]= multiSlect;
}else{
console.log(" searchElement.value = > " + searchElement.value);
- jsonPolicy[key]= searchElement.value;
+ if(splitPlainAttributeKey[1]!= undefined && splitPlainAttributeKey[1] == "boolean"){
+ jsonPolicy[key]= false;
+ for(var i=0; i<booleanTrueElements.length; i++){
+ if(booleanTrueElements[i] == key){
+ jsonPolicy[key]= true;
+ }
+ }
+
+ }else{
+ jsonPolicy[key]= searchElement.value;
+ }
}
} else {
if(searchElement.value != null){
+ jsonPolicy[key]= searchElement.value;
console.log(" searchElement.value = > " + searchElement.value);
- jsonPolicy[key]= searchElement.value;
+ if(splitPlainAttributeKey[1] == "boolean"){
+ jsonPolicy[key]= false;
+ for(var i=0; i<booleanTrueElements.length; i++){
+ if(booleanTrueElements[i] == key){
+ jsonPolicy[key]= true;
+ }
+ }
+ }
}
}
}
@@ -1418,6 +1551,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
});
};
+ var booleanTrueElements = [];
$scope.validatePolicy = function(policy){
document.getElementById("validate").innerHTML = "";
var splitAt = '*';
@@ -1464,6 +1598,20 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
}
}
+
+
+ var checkedValue = $('.onoffswitch-checkbox:checked').val();
+
+ var x = document.getElementsByClassName("onoffswitch-checkbox");
+
+
+ if(checkedValue){
+ console.log("checkedValue:" + checkedValue);
+ for(var i=0; i<x.length; x++){
+ console.log("checkbox id: " + x[i].id);
+ booleanTrueElements.push(x[i].id)
+ }
+ }
}
var uuu = "policyController/validate_policy.htm";
@@ -1537,4 +1685,40 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
return obj;
}
+
+ // Switch Click
+ $('.Switch').click(function() {
+ // Check If Enabled (Has 'On' Class)
+ if ($(this).hasClass('On')){
+ // Try To Find Checkbox Within Parent Div, And Check It
+ $(this).parent().find('input:checkbox').attr('checked', true);
+ // Change Button Style - Remove On Class, Add Off Class
+ $(this).removeClass('On').addClass('Off');
+ } else { // If Button Is Disabled (Has 'Off' Class)
+ // Try To Find Checkbox Within Parent Div, And Uncheck It
+ $(this).parent().find('input:checkbox').attr('checked', false);
+ // Change Button Style - Remove Off Class, Add On Class
+ $(this).removeClass('Off').addClass('On');
+ }
+ });
+ // Loops Through Each Toggle Switch On Page
+ $('.Switch').each(function() {
+ // Search of a checkbox within the parent
+ if ($(this).parent().find('input:checkbox').length){
+
+ // If checkbox doesnt have the show class then hide it
+ if (!$(this).parent().find('input:checkbox').hasClass("show")){
+ $(this).parent().find('input:checkbox').hide(); }
+
+ // Look at the checkbox's checkked state
+ if ($(this).parent().find('input:checkbox').is(':checked')){
+ // Checkbox is not checked, Remove the On Class and Add the Off Class
+ $(this).removeClass('On').addClass('Off');
+ } else {
+ // Checkbox Is Checked Remove Off Class, and Add the On Class
+ $(this).removeClass('Off').addClass('On');
+ }
+ }
+ });
+
}]); \ No newline at end of file