aboutsummaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController
diff options
context:
space:
mode:
Diffstat (limited to 'POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController')
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js74
-rw-r--r--POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js60
2 files changed, 116 insertions, 18 deletions
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 fb966430c..94c1bc998 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
@@ -163,10 +163,14 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var addElement = parentElement.childElementCount + 1;
clone.id = ''+value+'@'+addElement;
clone.value = '';
+ clone.className += ' child_single'; //here cloned is single element
document.getElementById("div."+value).appendChild(clone);
plainAttributeKeys.push(''+value+'@'+addElement);
}else{
div = document.getElementById("div."+value+"@0");
+
+ div.className += ' children_group'; //here is div with a group of children.
+
var childElement = parentElement.firstElementChild;
var countParent = parentElement.childElementCount;
var childElementString = childElement.innerHTML;
@@ -295,9 +299,12 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var plainAttributeKeys = [];
$scope.dcaeModelData = data[0].dcaeModelData;
$scope.dcaeJsonDate = data[0].jsonValue;
+ console.log("$scope.dcaeJsonDate: " + $scope.dcaeJsonDate);
var attributes = $scope.dcaeModelData.attributes;
var refAttributes = $scope.dcaeModelData.ref_attributes;
- var subAttributes = $scope.dcaeModelData.sub_attributes;
+ var subAttributes = $scope.dcaeModelData.sub_attributes;
+ console.log("subAttributes: " + subAttributes);
+
var enumAttributes = $scope.dcaeModelData.enumValues;
var annotation = $scope.dcaeModelData.annotation;
var dictionary = $scope.microServiceAttributeDictionaryDatas;
@@ -442,11 +449,11 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
return Object.prototype.toString.call(arrayTest) === '[object Array]';
}
var lableList = [];
-
function deconstructJSON(dataTest, level , name) {
var array = false;
var label = level;
var stringValue = "java.lang.String";
+ var string = "string";
var intValue = "int";
var double = "double";
var boolean = "boolean";
@@ -459,6 +466,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
for (key in dataTest) {
array = isArray(dataTest[key]);
console.log(key , dataTest[key]);
+
if (!!dataTest[key] && typeof(dataTest[key])=="object") {
if (array==false && key!=="0"){
$scope.labelLayout(label, key, array );
@@ -500,11 +508,35 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
if (dataTest[key].includes('required-true')){
isRequired = true;
}
- console.log("attirbuteLabel = " + attirbuteLabel);
+
+ var subAttributes = $scope.dcaeModelData.sub_attributes;
+
+ if(subAttributes){
+ var jsonObject = JSON.parse(subAttributes);
+ var allkeys = Object.keys(jsonObject);
+ if(allkeys){
+ for (var k = 0; k < allkeys.length; k++) {
+ var keyValue = allkeys[k];
+ console.log(" keyValue:jsonObject["+keyValue+ "]: " + jsonObject[keyValue]);
+ if(jsonObject[keyValue]){
+ var tempObject = jsonObject[keyValue];
+ if(tempObject && tempObject[key]){
+ if (tempObject[key].includes('required-true')){
+ isRequired = true;
+ }
+ }
+ }
+ }
+ }
+ }
+
switch (dataTest[key].split(splitcolon)[0]){
case stringValue:
$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired);
break;
+ case string:
+ $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired);
+ break;
case intValue:
$scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired);
break;
@@ -582,13 +614,13 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var buttonaddLabel = document.createTextNode("+");
addButton.appendChild(buttonaddLabel);
addButton.setAttribute("id", labelValue + attibuteKey);
- addButton.setAttribute("class", "btn btn-default");
+ addButton.setAttribute("class", "btn btn-add-remove");
addButton.setAttribute("ng-click" , 'addNewChoice("'+labelValue + attibuteKey+'");');
addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
var removeButton = document.createElement("BUTTON");
var buttonremoveLabel = document.createTextNode("-");
removeButton.appendChild(buttonremoveLabel);
- removeButton.setAttribute("class", "btn btn-default");
+ removeButton.setAttribute("class", "btn btn-add-remove");
removeButton.setAttribute("ng-click" , 'removeChoice("'+labelValue + attibuteKey+'");');
removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
document.getElementById(divID).appendChild(addButton);
@@ -597,6 +629,7 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
document.getElementById(divID).appendChild(textField);
document.getElementById(divID).appendChild(br);
document.getElementById(divID).appendChild(divTag);
+
}else{
checkKey = labelValue + attibuteKey;
textField.setAttribute("id" , ''+labelValue +attibuteKey+'');
@@ -609,6 +642,16 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
+ if(divID.includes("@0") && divID.includes("div.")){
+ var firstChild_Id = divID.split("@0")[0];
+ var firstChild_element = document.getElementById(firstChild_Id);
+ if(firstChild_element){
+ firstChild_element.className += ' children_group'; //here is a div with a group of children.
+ }
+ }
+ console.log('firstChild_Id: ' + firstChild_Id);
+ console.log('divID: ' + divID);
+
if (defaultValue.length > 0){
if(defaultValue.includes(":")){
defaultValue = defaultValue.split(":")[0];
@@ -661,18 +704,20 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var labeltext = document.createTextNode(lableName);
label.appendChild(labeltext);
+
+ var subAttributes = $scope.dcaeModelData.sub_attributes;
if(labelManyKey){
var addButton = document.createElement("BUTTON");
var buttonLabel = document.createTextNode("+");
addButton.appendChild(buttonLabel);
- addButton.setAttribute("class", "btn btn-default");
+ addButton.setAttribute("class", "btn btn-add-remove");
addButton.setAttribute("ng-click" , 'addNewChoice("'+labelValue + lableName+'");');
addButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
var removeButton = document.createElement("BUTTON");
var buttonremoveLabel = document.createTextNode("-");
removeButton.appendChild(buttonremoveLabel);
- removeButton.setAttribute("class", "btn btn-default");
+ removeButton.setAttribute("class", "btn btn-add-remove");
removeButton.setAttribute("ng-click" , 'removeChoice("'+labelValue +lableName+'");');
removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly");
document.getElementById(divID).appendChild(addButton);
@@ -685,12 +730,16 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
var divTag = document.createElement("div");
divTag.setAttribute("id", id +'@0');
+
+ divTag.className += ' children_group'; //here is div with a group of children.
+
document.getElementById(id).appendChild(divTag);
}else{
var divTag = document.createElement("div");
divTag.setAttribute("id", "div."+labelValue+lableName);
+ divTag.className += ' children_group'; //here is div with a group of children.
document.getElementById(divID).appendChild(label);
- document.getElementById(divID).appendChild(divTag);
+ document.getElementById(divID).appendChild(divTag);
}
};
@@ -801,7 +850,6 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
if (elumentLocation > 1){
enumKey = keySplit[keySplit.length - 1];
}
- var aWhiteSpace = " ";
if (enumKeyList.indexOf(enumKey) != -1){
if (splitPlainAttributeKey[1].indexOf("true") !== -1){
var multiSlect = [];
@@ -810,19 +858,11 @@ angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$wind
}
jsonPolicy[key]= multiSlect;
}else{
- //set a space due to empty value caused JSON format error in PolicyRestAdapter and remove it in back-end.
- if(searchElement.value == ""){
- searchElement.value = aWhiteSpace;
- }
console.log(" searchElement.value = > " + searchElement.value);
jsonPolicy[key]= searchElement.value;
}
} else {
if(searchElement.value != null){
- //set a default value due to empty value caused JSON format error in PolicyRestAdapter
- if(searchElement.value == ""){
- searchElement.value = aWhiteSpace;
- }
console.log(" searchElement.value = > " + searchElement.value);
jsonPolicy[key]= searchElement.value;
}
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 4b5a990ef..72b6f06ca 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
@@ -80,6 +80,26 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
console.log("failed");
});
+ 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_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");
+ });
+
function extend(obj, src) {
for (var key in src) {
if (src.hasOwnProperty(key)) obj[key] = src[key];
@@ -166,6 +186,9 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
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 = [];
}
@@ -178,7 +201,7 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
}else if($scope.temp.policy.ruleProvider=="Custom"){
if($scope.temp.policy.attributes.length == 0){
- $scope.temp.policy.attributes = [];
+ $scope.temp.policy.attributes = [];
}
if($scope.temp.policy.settings.length == 0){
$scope.temp.policy.settings = [];
@@ -190,6 +213,10 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
if($scope.temp.policy.yamlparams.blackList.length==0){
$scope.temp.policy.yamlparams.blackList = [];
}
+ }else if($scope.temp.policy.ruleProvider=="GUARD_YAML"){
+ 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 = [];
@@ -215,6 +242,14 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
$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.addNewBL = function() {
$scope.temp.policy.yamlparams.blackList.push('');
};
@@ -232,6 +267,29 @@ angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyA
$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.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 }];