summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/clamp/clds/exception/policy/PolicyModelException.java31
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java24
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java7
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java15
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstaller.java4
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java15
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsService.java5
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsToscaService.java14
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html265
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/holmes_properties.html106
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/tca_properties.html505
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/vesCollector_properties.html38
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js26
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js4
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js11
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js23
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js4
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/app.js64
-rw-r--r--src/main/resources/clds/camel/rest/clds-services.xml1
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java6
-rw-r--r--src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java7
-rw-r--r--src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java25
-rw-r--r--src/test/resources/example/sdc/service-without-policy.csarbin0 -> 56126 bytes
23 files changed, 196 insertions, 1004 deletions
diff --git a/src/main/java/org/onap/clamp/clds/exception/policy/PolicyModelException.java b/src/main/java/org/onap/clamp/clds/exception/policy/PolicyModelException.java
new file mode 100644
index 000000000..0b64b78ea
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/exception/policy/PolicyModelException.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia 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.
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.exception.policy;
+
+public class PolicyModelException extends Exception {
+
+ public PolicyModelException(String msg, Throwable throwable) {
+ super(msg, throwable);
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java b/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java
index 25b8d4016..6184b3946 100644
--- a/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java
+++ b/src/main/java/org/onap/clamp/clds/model/CldsToscaModel.java
@@ -36,7 +36,12 @@ public class CldsToscaModel extends CldsToscaModelRevision {
private String id;
private String policyType;
private String toscaModelName;
- private String toscaModelYaml;
+
+ /**
+ * Construct
+ */
+ public CldsToscaModel () {
+ }
/**
* Creates or updates Tosca Model to DB
@@ -123,21 +128,4 @@ public class CldsToscaModel extends CldsToscaModelRevision {
this.toscaModelName = toscaModelName;
}
- /**
- * @return the toscaModelYaml
- */
- @Override
- public String getToscaModelYaml() {
- return toscaModelYaml;
- }
-
- /**
- * @param toscaModelYaml
- * the toscaModelYaml to set
- */
- @Override
- public void setToscaModelYaml(String toscaModelYaml) {
- this.toscaModelYaml = toscaModelYaml;
- }
-
}
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java
index 5959c0fb5..c9405d202 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java
@@ -33,6 +33,7 @@ import java.util.concurrent.ThreadLocalRandom;
import org.onap.clamp.clds.config.ClampProperties;
import org.onap.clamp.clds.config.sdc.SdcSingleControllerConfiguration;
+import org.onap.clamp.clds.exception.policy.PolicyModelException;
import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException;
import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException;
import org.onap.clamp.clds.exception.sdc.controller.SdcControllerException;
@@ -257,6 +258,10 @@ public class SdcSingleController {
logger.error("SdcDownloadException exception caught during the notification processing", e);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DOWNLOAD,
DistributionStatusEnum.DOWNLOAD_ERROR, e.getMessage());
+ } catch (PolicyModelException e) {
+ logger.error("PolicyModelException exception caught during the notification processing", e);
+ sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
+ DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
} catch (InterruptedException e) {
logger.error("Interrupt exception caught during the notification processing", e);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
@@ -266,7 +271,7 @@ public class SdcSingleController {
logger.error("Unexpected exception caught during the notification processing", e);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
- } finally {
+ } finally {
this.changeControllerStatus(SdcSingleControllerStatus.IDLE);
}
}
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java
index 1a99919ee..f2c75ef28 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java
@@ -36,6 +36,7 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -68,6 +69,7 @@ public class CsarHandler {
private INotificationData sdcNotification;
public static final String RESOURCE_INSTANCE_NAME_PREFIX = "/Artifacts/Resources/";
public static final String RESOURCE_INSTANCE_NAME_SUFFIX = "/Deployment/";
+ public static final String POLICY_DEFINITION_NAME_SUFFIX = "Definitions/policies.yml";
public CsarHandler(INotificationData iNotif, String controller, String clampCsarPath) throws CsarHandlerException {
this.sdcNotification = iNotif;
@@ -167,4 +169,17 @@ public class CsarHandler {
public Map<String, BlueprintArtifact> getMapOfBlueprints() {
return mapOfBlueprints;
}
+
+ Optional<String> getPolicyModelYaml() throws IOException {
+ String result = null;
+ try (ZipFile zipFile = new ZipFile(csarFilePath)) {
+ ZipEntry entry = zipFile.getEntry(POLICY_DEFINITION_NAME_SUFFIX);
+ if (entry != null) {
+ result = IOUtils.toString(zipFile.getInputStream(entry));
+ } else{
+ logger.info("Policy model not found inside the CSAR file: " + csarFilePath);
+ }
+ return Optional.ofNullable(result);
+ }
+ }
}
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstaller.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstaller.java
index b5c025ecb..12a761dbf 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstaller.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstaller.java
@@ -23,11 +23,13 @@
package org.onap.clamp.clds.sdc.controller.installer;
+import org.onap.clamp.clds.exception.policy.PolicyModelException;
import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException;
public interface CsarInstaller {
boolean isCsarAlreadyDeployed(CsarHandler csar) throws SdcArtifactInstallerException;
- public void installTheCsar(CsarHandler csar) throws SdcArtifactInstallerException, InterruptedException;
+ public void installTheCsar(CsarHandler csar)
+ throws SdcArtifactInstallerException, InterruptedException, PolicyModelException;
}
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
index bfda6924d..6841b87b0 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
@@ -34,6 +34,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
import javax.annotation.PostConstruct;
import javax.xml.transform.TransformerException;
@@ -43,6 +44,7 @@ import org.onap.clamp.clds.client.DcaeInventoryServices;
import org.onap.clamp.clds.config.sdc.BlueprintParserFilesConfiguration;
import org.onap.clamp.clds.config.sdc.BlueprintParserMappingConfiguration;
import org.onap.clamp.clds.dao.CldsDao;
+import org.onap.clamp.clds.exception.policy.PolicyModelException;
import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException;
import org.onap.clamp.clds.model.CldsModel;
import org.onap.clamp.clds.model.CldsTemplate;
@@ -125,7 +127,8 @@ public class CsarInstallerImpl implements CsarInstaller {
@Override
@Transactional
- public void installTheCsar(CsarHandler csar) throws SdcArtifactInstallerException, InterruptedException {
+ public void installTheCsar(CsarHandler csar)
+ throws SdcArtifactInstallerException, InterruptedException, PolicyModelException {
try {
logger.info("Installing the CSAR " + csar.getFilePath());
for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {
@@ -135,6 +138,7 @@ public class CsarInstallerImpl implements CsarInstaller {
this.searchForRightMapping(blueprint.getValue())),
queryDcaeToGetServiceTypeId(blueprint.getValue()));
}
+ createPolicyModel(csar);
logger.info("Successfully installed the CSAR " + csar.getFilePath());
} catch (IOException e) {
throw new SdcArtifactInstallerException("Exception caught during the Csar installation in database", e);
@@ -143,6 +147,15 @@ public class CsarInstallerImpl implements CsarInstaller {
}
}
+ private void createPolicyModel(CsarHandler csar) throws PolicyModelException {
+ try{
+ Optional<String> policyModelYaml = csar.getPolicyModelYaml();
+ // save policy model into the database
+ } catch (IOException e) {
+ throw new PolicyModelException("TransformerException when decoding the YamlText", e);
+ }
+ }
+
private BlueprintParserFilesConfiguration searchForRightMapping(BlueprintArtifact blueprintArtifact)
throws SdcArtifactInstallerException {
List<BlueprintParserFilesConfiguration> listConfig = new ArrayList<>();
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsService.java b/src/main/java/org/onap/clamp/clds/service/CldsService.java
index 42e9cf713..e3a379b36 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java
@@ -394,11 +394,14 @@ public class CldsService extends SecureServiceBase {
errorMessage = e.getMessage();
}
- if (!errorMessage.isEmpty()) {
+ if (null == errorMessage || (null != errorMessage && !errorMessage.isEmpty())) {
CldsEvent.insEvent(cldsDao, model.getControlName(), getUserId(), actionCd, CldsEvent.ACTION_STATE_ERROR,
null);
// Need a refresh as new events have been inserted
model = CldsModel.retrieve(cldsDao, modelName, false);
+ if (null == errorMessage) {
+ errorMessage = "No response from Policy";
+ }
model.setErrorMessageForUi(errorMessage);
util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "putModelAndProcessAction failed", Level.INFO,
ONAPLogConstants.ResponseStatus.ERROR);
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java b/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java
index 04205b704..adebd7853 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsToscaService.java
@@ -101,7 +101,7 @@ public class CldsToscaService extends SecureServiceBase {
*
* @return clds tosca models - list of CLDS tosca models
*/
- public ResponseEntity<List<CldsToscaModel>> getAllToscaModels() {
+ public List<CldsToscaModel> getAllToscaModels() {
Date startTime = new Date();
LoggingUtils.setRequestContext("CldsToscaService: Get All tosca models", getPrincipalName());
@@ -111,7 +111,7 @@ public class CldsToscaService extends SecureServiceBase {
LoggingUtils.setTimeContext(startTime, new Date());
LoggingUtils.setResponseContext("0", "Get All tosca models success", this.getClass().getName());
auditLogger.info("Get All tosca models");
- return new ResponseEntity<>(cldsToscaModels, HttpStatus.OK);
+ return cldsToscaModels;
}
/**
@@ -123,7 +123,7 @@ public class CldsToscaService extends SecureServiceBase {
*
* @return clds tosca model - CLDS tosca model for a given tosca model name
*/
- public ResponseEntity<CldsToscaModel> getToscaModel(String toscaModelName) {
+ public CldsToscaModel getToscaModel(String toscaModelName) {
Date startTime = new Date();
LoggingUtils.setRequestContext("CldsToscaService: Get tosca models by model name", getPrincipalName());
// TODO revisit based on new permissions
@@ -132,8 +132,7 @@ public class CldsToscaService extends SecureServiceBase {
LoggingUtils.setTimeContext(startTime, new Date());
LoggingUtils.setResponseContext("0", "Get tosca models by model name success", this.getClass().getName());
auditLogger.info("GET tosca models by model name completed");
- return new ResponseEntity<>(Optional.ofNullable(cldsToscaModels).get().stream().findFirst().get(),
- HttpStatus.OK);
+ return cldsToscaModels.get(0);
}
/**
@@ -143,7 +142,7 @@ public class CldsToscaService extends SecureServiceBase {
* @param policyType
* @return clds tosca model - CLDS tosca model for a given policy type
*/
- public ResponseEntity<CldsToscaModel> getToscaModelsByPolicyType(String policyType) {
+ public CldsToscaModel getToscaModelsByPolicyType(String policyType) {
Date startTime = new Date();
LoggingUtils.setRequestContext("CldsToscaService: Get tosca models by policyType", getPrincipalName());
// TODO revisit based on new permissions
@@ -152,8 +151,7 @@ public class CldsToscaService extends SecureServiceBase {
LoggingUtils.setTimeContext(startTime, new Date());
LoggingUtils.setResponseContext("0", "Get tosca models by policyType success", this.getClass().getName());
auditLogger.info("GET tosca models by policyType completed");
- return new ResponseEntity<>(Optional.ofNullable(cldsToscaModels).get().stream().findFirst().get(),
- HttpStatus.OK);
+ return cldsToscaModels.get(0);
}
public ResponseEntity<?> deleteToscaModelById(String toscaModeId) {
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html
index 331ab5cd1..182dab8d5 100644
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html
+++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html
@@ -23,20 +23,10 @@
<style>
-#deletePolicy {
- height: 34px;
- background-color: #dddd;
-}
-
.disabled {
background-color: #dddd;
}
-.modelSearchBox {
- position: absolute;
- padding: 25px 12px;
-}
-
label {
text-align: right;
vertical-align: middle;
@@ -46,12 +36,6 @@ label {
padding: 0 10px 0 0;
}
-#createNewPolicy {
- height: 34px;
- width: 120px; /*84*/
- background-color: #f2bfab;
-}
-
.idError {
color: red;
padding: 50px 0px;
@@ -74,14 +58,6 @@ label {
margin-bottom: 0px;
}
-#policySearch {
- height: 33px;
- font-size: 12px;
- padding: 2px 2px 2px 30px;
- margin-bottom: 5px;
- width: 100%;
-}
-
#policyTable {
cursor: pointer;
width: 100%;
@@ -124,36 +100,17 @@ label {
<div class="modal-body">
<div attribute-test="policywindowpropertiesb" class="modal-body row">
-
- <div class="leftPolicyPanel">
+ <div class="leftPolicyPanel" style="display: none;">
<div class="panel panel-default">
- <i class="glyphicon glyphicon-search modelSearchBox"></i> <input
- type="text" id="policySearch" onkeyup="searchPolicyList()"
- placeholder="Search ...">
<div id="policyTableHolder">
<table id="policyTable"></table>
</div>
</div>
- <div style="float: left">
- <button type="button" id="createNewPolicy" class="btn btn-sm">New
- Policy</button>
- </span>
- </div>
- <div style="float: right">
- <button type="button" id="deletePolicy"
- class="btn btn-sm glyphicon glyphicon-trash" disabled></button>
- </span>
- </div>
- <div id="repeatIdError" class="idError">Error: This Policy
- name is already taken.</div>
- <div id="newIdError" class="idError">Error: Please rename your
- new Policy.</div>
+
<div id="spaceError" class="idError">Error: Spaces are not
allowed in the ID.</div>
</div>
-
- <div class="panel panel-default col-sm-9 policyPanel"
- style="display: none;">
+ <div class="panel panel-default col-sm-9 policyPanel">
<form id="Timeoutform" class="form-horizontal">
<div>
<div class="form-group clearfix row">
@@ -379,11 +336,12 @@ label {
}
function initTargetResourceId() {
+ if (vf_Services !== null && vf_Services !== undefined) {
// Set all the Resource Invariant UUID in the target resource ID list (+Empty and other)
Object.keys(vf_Services["shared"]["byVf"]).forEach(function(key) {
$("#targetResourceId").append($('<option></option>').val(key).html(key));
});
-
+ }
}
function changeTargetResourceIdOther() {
@@ -409,6 +367,7 @@ label {
//Basically this method will add a new form. All forms share the same class. When you want one form to show(active form) the other forms get the
// css attribute display:none
$("#add_one_more").click(function(event) {
+ console.log("add one more");
event.preventDefault();
var num = add_one_more();
setMultiSelect();
@@ -425,7 +384,8 @@ label {
//Grab saved values for dropdowns
var obj = elementMap[lastElementSelected];
-
+ var loadPolicy;
+ console.log("lastElementSelected :"+ lastElementSelected);
if (!($.isEmptyObject(obj))){
allPolicies = jQuery.extend({}, obj);
for (var x in allPolicies){
@@ -433,12 +393,23 @@ label {
if (allPolicies[x][1]['value']){
allPolIds.push(parseInt(allPolicies[x][1]['value']));
}
+ console.log("policies found :"+ x);
+ loadPolicy = x;
}
}
- $("#pname").val('');
+
+ if (loadPolicy !== undefined && loadPolicy !== null) {
+ // load properties
+ console.log("load properties");
+ disperseConfig(allPolicies,loadPolicy);
+ } else {
+ console.log("create new policy");
+ add_new_policy();
+ }
//load recipes for a chosen policy
function disperseConfig(policyObj, id){
+ console.log("disperseConfig with id:" + id);
parent_policy={};
//remove old gui forms
for (var i=1; i<($(".formId").length + 1); i++){
@@ -446,18 +417,21 @@ label {
}
$(".formId").remove();
- if (policyObj !== undefined) {
+ if (policyObj !== undefined && policyObj[id] !== undefined) {
var el = policyObj[id][3]['policyConfigurations']
for (var i = 0; i < el.length; i++) {
loadingId=true;
var num = add_one_more();
+ console.log("number is=:" + num);
loadingId=false;
for (var j = 0; j < el[i].length; j++) {
if(el[i][j].hasOwnProperty("name")){
$("#formId" + num + " #" + el[i][j].name).val(
el[i][j].value);
- if(el[i][j].name==="_id")
+ if(el[i][j].name==="_id") {
+ console.log("formId num:" + num + "; value is:" + el[i][j].value);
policy_ids["#formId" + num]=el[i][j].value
+ }
if(el[i][j].name==='parentPolicy')
parent_policy[num]=el[i][j].value
if(el[i][j].name==='recipe' && el[i][j].value.toString()!==''){
@@ -563,25 +537,14 @@ label {
}
$("#savePropsBtn").click(function(event) {
+ console.log("save properties triggered");
if($("#targetResourceIdOther").is(":visible")) {
$('#targetResourceId').append($('<option></option>').val($("#targetResourceIdOther").val()).html($("#targetResourceIdOther").val()))
$("#targetResourceId").val($("#targetResourceIdOther").val());
}
$(".idError").hide();
- if ($("#policyTable .highlight td").html() !== $("#pname").val()){
- //repeated name
- if ($.inArray($("#pname").val(), Object.keys(allPolicies)) > -1){
- $("#repeatIdError").show();
- return;
- } else { //not repeated
- delete allPolicies[$("#policyTable .highlight td").html()];
- }
- }
- if ($("#pname").val().trim() == "New_Policy"){
- $("#newIdError").show();
- return;
- }
-
+
+ console.log("save properties triggered2");
//Saves edits
/* if ($("#policyTable .highlight").length > 0){
saveLastPolicyLocally($("#policyTable .highlight").attr("id"));
@@ -589,12 +552,15 @@ label {
startNextItem();
//Removes outdated (deleted) policies by checking against left menu
+ console.log("get all policies");
var finalSaveList = {};
$("#policyTable td").each(function(){
+ console.log("enter policy table each loop");
var tableVal = $(this).text();
if (tableVal in allPolicies){
finalSaveList[tableVal] = allPolicies[tableVal];
}
+ console.log("save properties; add tableVal to policies: "+ tableVal);
});
saveProperties(finalSaveList);
@@ -669,21 +635,8 @@ label {
return count;
}
-
- function add_new_policy(issueNewNames) {
- //remove old gui forms
- for (var i=1; i<($(".formId").length + 1); i++){
- $("#go_properties_tab"+i).parent().remove();
- }
- $(".formId").remove();
-
- //Reset headers
- //$("#pname").val("0");
- $("#pname").val("New_Policy");
- $("#timeout").val(defaults_props.policy.timeout);
-
- $("#add_one_more").click();
- }
+
+
function addCustListen(count) {
$('#go_properties_tab' + count).click(function(event) {
@@ -751,21 +704,8 @@ label {
this.name = name
}
- //Policy table search filter
- function searchPolicyList() {
- var search = document.getElementById("policySearch");
- var row = document.getElementsByTagName("td");
- for (var i = 0; i < row.length; i++) {
- if (row[i].innerHTML.toUpperCase().indexOf(
- search.value.toUpperCase()) > -1) {
- row[i].style.display = "";
- } else {
- row[i].style.display = "none";
- }
- }
- }
-
function saveLastPolicyLocally(lastPolicyId) {
+ console.log("last policy id is:" + lastPolicyId);
var polForm = []
var properties = $(".saveProps").not("#formSpan .saveProps");
@@ -783,100 +723,29 @@ label {
d["policyConfigurations"].push(s);
}
polForm.push(d);
- allPolicies[lastPolicyId] = polForm;
- }
- function getNextId(){
- var newPolId;
- allPolIds.sort();
- if ((Math.min.apply(Math, allPolIds) == 0)
- && (allPolIds.length > 0)) {
- loop1:
- for (var i = 1; i < allPolIds.length; i++) {
- if ((allPolIds[i] - allPolIds[i - 1]) != 1) {
- newPolId = (allPolIds[i - 1] + 1);
- break loop1;
- };
- };
- if (!newPolId) {
- newPolId = (Math.max.apply(Math, allPolIds)) + 1;
+ for (var x in allPolicies){
+ if (x !== lastPolicyId) {
+ delete allPolicies[x];
+ console.log("remove old policy"+ x);
}
- } else {
- newPolId = 0;
}
- allPolIds.push(newPolId);
- $("#pid").val(newPolId);
- }
-
- $("#deletePolicy").on('click', function() {
- $(".idError").hide();
- //delete policy id
- allPolIds.splice((allPolIds.indexOf(parseInt($("#pid").val()))),1);
- //delete policy name
- var deleteId = $("#policyTable .highlight td").html();
- delete allPolicies[deleteId];
- $("#policyTable .highlight").remove();
- $("#pname").val('');
- expandTable();
- });
+ allPolicies[lastPolicyId] = polForm;
+ }
$('#policyTable').on('click', 'tr', function(event) {
+
+ console.log("click on policyTable");
$(".idError").hide();
- //edited name
- if ($("#policyTable .highlight td").html() !== $("#pname").val()){
- //repeated name
- if ($.inArray($("#pname").val(), Object.keys(allPolicies)) > -1){
- $("#repeatIdError").show();
- return;
- } else { //not repeated
- $("#repeatIdError").hide();
- delete allPolicies[$("#policyTable .highlight td").html()];
- }
- }
- //if (parseInt($("#pname").val()) == 0){
- if ($("#pname").val().trim() == "New_Policy"){
- $("#newIdError").show();
- return;
- }
+
if (!(readMOnly)){
startNextItem();
- } else {
- if ($("#policyTable .highlight").length == 0){
- collapseTable();
- }
}
$(this).addClass('highlight').siblings().removeClass('highlight');
disperseConfig(allPolicies, $(this).find("td").html());
});
- $('#createNewPolicy').on('click', function(){
- $(".idError").hide();
- //edited name
- if ($("#policyTable .highlight td").html() !== $("#pname").val()){
- //repeated name
- if ($.inArray($("#pname").val(), Object.keys(allPolicies)) > -1){
- $("#repeatIdError").show();
- return;
- } else { //not repeated
- $("#repeatIdError").hide();
- delete allPolicies[$("#policyTable .highlight td").html()];
- }
- }
- //if (parseInt($("#pname").val()) == 0){
- if ($("#pname").val().trim() == "New_Policy"){
- $("#newIdError").show();
- return;
- }
- startNextItem();
- add_new_policy();
- if (("#policyTable .highlight").length > 0){
- $('#policyTable tr.highlight').removeClass('highlight');
- }
- $("#policyTable").prepend("<tr class='highlight'><td>New_Policy</td></tr>");
-
- getNextId();
- });
$('#pname').on('keypress', function(e){
/* var newVal = $(this).val() + String.fromCharCode(e.which);
@@ -898,22 +767,41 @@ label {
}
function startNextItem() {
+ console.log("start next Item");
//save last item before transitioning
var lastItem = $("#policyTable .highlight");
if (lastItem.length > 0) {
+ console.log("start next Item length > 0");
saveLastPolicyLocally($("#pname").val());
//lastItem.attr("id", $("#pname").val());
lastItem.find("td").html($("#pname").val());
- } else {
- collapseTable();
}
-
- //allow deleting
- if ($("#deletePolicy").prop("disabled")) {
- $("#deletePolicy").prop("disabled", false);
+ }
+
+ function add_new_policy(issueNewNames) {
+ //remove old gui forms
+ for (var i=1; i<($(".formId").length + 1); i++){
+ $("#go_properties_tab"+i).parent().remove();
}
+ $(".formId").remove();
+
+ //Reset headers
+ //$("#pname").val("0");
+ $("#pname").val("New_Policy");
+ $("#timeout").val(defaults_props.policy.timeout);
+
+ $("#add_one_more").click();
}
+ startNextItem();
+
+ if (("#policyTable .highlight").length > 0){
+ $('#policyTable tr.highlight').removeClass('highlight');
+ }
+ $("#policyTable").prepend("<tr class='highlight'><td>New_Policy</td></tr>");
+
+ $("#pid").val(0);
+
setASDCFields();
initTargetResourceId();
@@ -922,7 +810,7 @@ label {
for (var i = 0; i < (elementMap["global"].length); i++){
if ((elementMap["global"][i]["name"]) == "actionSet"){
var asSel = elementMap["global"][i]["value"];
- if (asSel == "vnfRecipe"){
+ if (asSel == "vnfRecipe" && vf_Services !== null && vf_Services !== undefined){
if (vf_Services["policy"][asSel]){
$.each((vf_Services["policy"][asSel]), function(val, text) {
$('#recipe').append(
@@ -935,21 +823,6 @@ label {
};
};
};
- //Show table panel only
- function expandTable() {
- $(".policyPanel").css("display", "none");
- $(".leftPolicyPanel").removeClass("col-sm-3");
- $(".modelSearchBox").css("padding", "25px 12px");
- if (!($("#deletePolicy").prop("disabled"))) {
- $("#deletePolicy").prop("disabled", true);
- }
- }
- //Show both menus
- function collapseTable() {
- $(".leftPolicyPanel").addClass("col-sm-3");
- $(".modelSearchBox").css("padding", "10px 12px");
- $(".policyPanel").css("display", "unset");
- }
</script>
</div>
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/holmes_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/holmes_properties.html
deleted file mode 100644
index 1a9f9bad8..000000000
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/holmes_properties.html
+++ /dev/null
@@ -1,106 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- ONAP CLAMP
- ================================================================================
- Copyright (C) 2017 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.
- 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.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END============================================
- ===================================================================
- -->
-<style>
-</style>
-
-
-<div id="holmes-configuration">
- <!-- form header -->
- <div class="modal-header">
- <button type="button" class="close" ng-click="close(false)" aria-hidden="true" style="margin-top: -3px">&times;</button>
- <h4>Holmes Microservice Configuration</h4>
- </div>
-
- <!-- Form center-->
- <div class="modal-body" style="height: 280px">
-
- <form id="saveProps" class="form-horizontal">
- <div class="form-group">
- <div>
- <label for="correlationalLogic" class="col-sm-4 control-label">Correlational logic</label>
- </div>
- <div class="col-sm-8">
- <textarea class="form-control" focus="true" name="correlationalLogic" id="correlationalLogic" />
- </div>
- <div>
- <label for="configPolicyName" class="col-sm-4 control-label">Configuration Policy Name</label>
- </div>
- <div class="col-sm-8">
- <textarea class="form-control" focus="true" name="configPolicyName" id="configPolicyName" />
- </div>
- </div>
- </form>
-
- </div>
-
- <!-- footer -->
- <div class="modal-footer">
- <button id="savePropsBtn" class="btn btn-primary">Save</button>
- <button id="close_button" class="btn btn-primary" ng-click="close(true)">Cancel</button>
- </div>
-</div>
-
-<script language="javascript">
-
-// load window
-loadPropertyWindow('holmes')
-
-// fill policy combo box (allPolicies from ImporSchemaCtrl.js
-if (typeof allPolicies !== "undefined"){
- $.each(Object.keys(allPolicies), function(val, text) {
- $('#operationalPolicy').append($('<option></option>').val(text).html(text));
- });
-} else if (typeof elementMap !== "undefined"){
- for (key in elementMap){
- if (key.indexOf("Policy")>-1){
- $.each(Object.keys(elementMap[key]), function(val, text){
- $('#operationalPolicy').append(
- $('<option></option>').val(text).html(text)
- );
- });
- }
- }
-}
-
-// load property values
-var el=elementMap[lastElementSelected];
-if(el!==undefined){
- for(var i=0;i<el.length;i++){
- $("#"+el[i].name).val(el[i].value);
- }
-}
-
-$("#saveProps").on('submit', function (event) {
- saveProperties($(this).serializeArray())
- event.preventDefault();
- $("#close_button").click();
-});
-
-$("#savePropsBtn").click(function (event) {
- $("#saveProps").submit();
-});
-
-
-
-
-
-</script>
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/tca_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/tca_properties.html
deleted file mode 100644
index 89b13fa11..000000000
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/tca_properties.html
+++ /dev/null
@@ -1,505 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- ONAP CLAMP
- ================================================================================
- Copyright (C) 2017-2018 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.
- 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.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END============================================
- ===================================================================
-
- -->
-
-<style>
-#createNewThresh{
- height:34px;
- width:120px; /*84*/
- background-color:#f2bfab;
-}
-
-#deleteThresh{
- height:34px;
- background-color:#dddd;
-}
-
-.form-group {
- margin-bottom:15px;
- display:-webkit-flex;
- display: flex;
- align-items: center;
-}
-
-#tcaEditHolder{
- background-color: #f5f5f5;
- padding:10px 10px;
- margin: 15px 15px 0 0;
- float: right;
-}
-
-
-#tcaEditHolder #properties_tab>div+div {
- margin-top: 10px;
-}
-
-.tcaErr{
- display:none;
- text-align:center;
- margin-bottom:20px;
- color:red;
-}
-
-.tcaParentItems {
- padding-left: 20px;
-}
-
-.tcaParentItems label{
- margin-bottom: 0px;
-}
-
-#tcaTable{
- cursor: pointer;
- width:100%;
-}
-
-#tcaTable tr{
- border-bottom: 1px solid #ddd;
- border-collapse: collapse;
- text-align: center;
- font-size: 12px;
- font-weight: normal;
-}
-
-#tcaTable td{
- padding: 8px 10px;
-}
-
-#tcaTable tr.highlight{
- background-color: #f5f5f5;
- font-weight: bold;
- font-size: 13px;
-}
-
-#tcaTableHolder{
- height:160px;
- width: 100%;
- overflow:auto;
-}
-
-</style>
-
-<div id="configure-widgets" class="disabled-block-container">
- <div class="modal-header">
- <button type="button" class="close" ng-click="close(false)"
- aria-hidden="true" style="margin-top: -3px">&times;</button>
- <h4>TCA Micro Services</h4>
- </div>
- <div class="modal-body">
- <div style="height: 10px"></div>
- <div class="panel panel-default" id="panelHolder">
-
- <span id="formSpan" style="display:none;">
- <div class="panel-body">
-
- <form class="tcaParentItems">
- <div class="row">
- <div class="col-sm-8 form-group">
- <label class="col-sm-3"> Name </label>
- <div class="col-sm-9" style="padding:0px;">
- <input class="form-control" type="text" maxlength="48" id="tname" name="tname"></input>
- </div>
- </div>
-
- <div class="col-sm-8 form-group" style="display:none;">
- <label class="col-sm-3"> UUID </label>
- <div class="col-sm-9" style="padding:0px;">
- <input class="form-control" onkeydown="return false;" type="text" id="tuuid" name="tuuid"></input>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-8 form-group">
- <label class="col-sm-3"> Policy </label>
- <div class="col-sm-9" style="padding:0px;">
- <select name="tcaPol" id="tcaPol" enableFilter="true"></select>
- </div>
- </div>
- <div class="col-sm-8 form-group">
- <label class="col-sm-3">EventName</label>
- <div class="col-sm-9" style="padding:0px;">
- <select name="eventName" id="eventName" enableFilter="true"></select>
- </div>
- </div>
- <div class="col-sm-8 form-group">
- <label class="col-sm-3">Control Loop Schema Type</label>
- <div class="col-sm-9" style="padding:0px;">
- <select name="controlLoopSchemaType" id="controlLoopSchemaType" enableFilter="true"></select>
- </div>
- </div>
- <div class="col-sm-8 form-group" style="display:none;">
- <label class="col-sm-3"> Policy ID </label>
- <div class="col-sm-9" style="padding:0px;">
- <input class="form-control" onkeydown="return false;" type="text" id="tcaPolId" name="tcaPolId"></input>
- </div>
- </div>
-
- </div>
- </form>
-
- <div class="tcaBody row">
- <div class="col-sm-5" style="padding:0px 5px; margin: 15px;">
- <div class="panel panel-default" id="tcaTableHolder">
- <table id="tcaTable">
- </table>
- </div>
- <div id="tcaError" class="tcaErr">Error: Please define/delete this new threshold</div>
- <div id="tcaUnique" class="tcaErr">Error: Duplicate Set Name Found</div>
- <div style="float:left">
- <button type="button" id="createNewThresh" class="btn btn-sm">New Threshold</button>
- </div>
- <div style="float:right">
- <button type="button" id="deleteThresh" class="btn btn-sm glyphicon glyphicon-trash" disabled></button>
- </div>
-
- </div>
-
- <div id="tcaEditHolder" class="panel panel-default col-sm-6">
- <div class="tab-content">
- <div id="properties_tab" class="form-vertical">
- <div>
- <label class="control-label">Metric</label>
- <div>
- <select id="fieldPathM" name="fieldPathM"></select>
- </div>
- </div>
- <div>
- <label class="control-label">Operator</label>
- <div>
- <select id="operator" name="operator"></select>
- </div>
- </div>
- <div>
- <label class="control-label">Threshold</label>
- <div>
- <input type="text" maxlength="10" class="form-control" name="threshold"
- onkeypress="return isNumberKey(event)" id="threshold"></input>
- </div>
- </div>
- <div>
- <label class="control-label">Closed Loop Event Status</label>
- <div>
- <select id="closedLoopEventStatus" name="closedLoopEventStatus"></select>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- </div>
- </span>
-
- </div>
- </div>
-</div>
-
- <div class="modal-footer">
- <!--<button ng-click="reset()" class="btn btn-primary" style="float:left">Reset</button>-->
- <button id="savePropsBtn" class="btn btn-primary">Close</button>
- <button ng-click="close(true)" id="close_button"
- class="btn btn-primary">Cancel</button>
- </div>
-
- <script language="javascript">
- // helper that make jquery objects visibles or invisible
- // to use instead of show to keep placeholder size correct
- jQuery.fn.visible = function() {
- return this.css('visibility', 'visible');
- };
- jQuery.fn.invisible = function() {
- return this.css('visibility', 'hidden');
- };
-
- var generateTUUID = function(count){
- var d = new Date().getTime();
- var tuuid = 'xxxxxxxx-xxxx-txxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function(c){
- var r = (d + Math.random()*16)%16 | 0;
- d = Math.floor(d/16);
- return (c == 'x' ? r : (r*0x3|0*8)).toString(16);
- });
- $("#formId" + count + " #tuuid").val(tuuid);
- };
-
-
- var propertiesToString = function(formIdNum) {
- return $('#formId'+formIdNum+' #fieldPathM').find(':selected').text() + ' ' +
- $('#formId'+formIdNum+' #operator').val() + ' ' +
- $('#formId'+formIdNum+' #threshold').val() + ' ' +
- $('#formId'+formIdNum+' #closedLoopEventStatus').val();
- };
-
- loadPropertyWindow("tca");
-
- //load dropdown with policy options
- if (typeof allPolicies !== "undefined"){
- $.each(Object.keys(allPolicies), function(val, text) {
- $('#tcaPol').append($('<option></option>').val(text).html(text));
- });
- } else if (typeof elementMap !== "undefined"){
- for (key in elementMap){
- if (key.indexOf("Policy")>-1){
- $.each(Object.keys(elementMap[key]), function(val, text){
- $('#tcaPol').append(
- $('<option></option>').val(text).html(text)
- );
- });
- }
- }
- }
-
- var fieldPathMLabel2Value = function(label) {
- return Object.keys(defaults_props['tca']['fieldPathM']).find(key => defaults_props['tca']['fieldPathM'][key] == label)
- }
- var fieldPathMValue2Label = function(value) {
- return defaults_props['tca']['fieldPathM'][value];
- }
-
- setASDCFields();
-
- var arr = elementMap[lastElementSelected];
-
- if (arr !== undefined) {
- for (var x in arr){
- var num = add_one_more();
- for (var i=0; i< arr[x].length; i++){
-
- if (arr[x][i].hasOwnProperty('serviceConfigurations')){
- for (var j=0; j<arr[x][i]["serviceConfigurations"].length; j++){
- $("#formId" + num + " #tcaTable").prepend("<tr><td>"
- +fieldPathMValue2Label(arr[x][i]["serviceConfigurations"][j][0])+ " "
- +(Object.keys(defaults_props['tca']['operator']).find(key => defaults_props['tca']['operator'][key] == (arr[x][i]["serviceConfigurations"][j][1])))+ " "
- +arr[x][i]["serviceConfigurations"][j][2]+" "
- +arr[x][i]["serviceConfigurations"][j][3]+" "
- +arr[x][i]["serviceConfigurations"][j][4]+"</td></tr>");
- }
- } else {
- $("#formId" + num + " #"+arr[x][i].name).val(arr[x][i].value);
- }
- }
- $('#go_properties_tab'+num).text($('#formId' +num+ ' #tname').val());
- $("#formId"+num + " #properties_tab").invisible();
- }
- } else {
- var count = add_one_more();
- generateTUUID(count);
- }
-
- $("#savePropsBtn").click(function(event) {
- var num = 1
- if (($('#formId'+num+' #tcaTable .highlight').length > 0 ) &&
- (!($('#formId'+num+' #threshold').val()) || !($('#formId'+num+' #fieldPathM').val())) ) {
- $('#formId'+num+' #tcaError').show();
- return;
- } else {
- $('#formId'+num+' .tcaErr').hide();
- if ($('#formId'+num+' #tcaTable .highlight').length > 0){
- $('#formId'+num+' #tcaTable .highlight td').text(propertiesToString(num));
- }
- var saveP = {};
- $('.formId').each(function(){
- var count = $(this).attr('id').slice(-1);
- var header = $(this).find('.tcaParentItems').serializeArray();
- var sconf = {};
- var sconfa = [];
- $('#formId' +count+' #tcaTable tr').each(function(){
- $('td', this).each(function(){
- var splitTd = $(this).text().split(' ');
- splitTd[0]=fieldPathMLabel2Value(splitTd[0]);
- splitTd[1]=defaults_props['tca']['operator'][splitTd[1]];
- sconfa.push(splitTd);
- });
-
- });
- var polSel = $(this).find('.tcaParentItems #tcaPol').val();
- $.grep(header, function(e,i){
- if (e.name == "tcaPolId"){
- if (polSel){
- if (typeof allPolicies !== "undefined"){
- header[i]["value"] = allPolicies[polSel][1]["value"];
- } else if (typeof elementMap !== "undefined"){
- for (key in elementMap){
- if (key.indexOf("Policy")>-1){
- header[i]["value"] = elementMap[key][polSel][1]["value"];
- }
- }
- }
- } else {
- header[i]["value"]="";
- }
- }
- });
-
- sconf["serviceConfigurations"]=sconfa;
- header.push(sconf);
- saveP[$(this).find('.tcaParentItems #tname').val()] = header;
- });
-
- saveProperties(saveP);
- $("#close_button").click();
- }
- })
-
- function uniquet(arr) {
- var a = [];
- for (var i=0, l=arr.length; i<l; i++){
- if (a.indexOf(arr[i]) === -1 && arr[i] !== ''){
- a.push(arr[i]);
- }
- }
- if (a.length==arr.length){
- return false;
- } else {
- return true;
- }
- }
-
- function add_one_more(){
- $("#nav_Tabs li").removeClass("active");
- var form=$($("#formSpan").children()[0]).clone();
- var count=0;
- if($(".formId").length>0){
- var greatest=0;
- var s=$(".formId");
- for(var i=0;i<s.length; i++){
- if(parseInt($(s[i]).attr("id").substring(6))>greatest){
- greatest=parseInt($(s[i]).attr("id").substring(6))
- }
- }
- count=greatest+1;
- $("#panelHolder").append(('<span class="formId" id="formId'+count+'"></span>'));
- }else{
- count++;
- $("#panelHolder").append('<span class="formId" id="formId1"></span>');
- }
-
- $("#add_one_more").parent().before(' <li class="active"><a id="go_properties_tab'+count+'">New_Set</a><button id="tab_close'+count+'" type="button" class="close tab-close-popup" aria-hidden="true" style="margin-top: -30px;margin-right: 5px">&times;</button></li>');
- $("#formId"+count).append(form);
- $('#formId'+count+ ' #properties_tab').invisible();
- $(".formId").not($("#formId"+count)).css("display","none");
- addCustListen(count);
- setMultiSelect();
- return count;
- }
-
- function isNumberKey(event){
- var charCode = (event.which) ? event.which : event.keyCode
- if (charCode > 31 && (charCode < 48 || charCode > 57)){
- return false;
- }
- return true;
- };
-
- function addCustListen(count) {
- $('#go_properties_tab' + count).click(function(event) {
- if ($("#nav_Tabs li.active").length>0){
- var oldCount = $("#nav_Tabs li.active").find("a").attr("id").slice(-1);
- if (($('#formId'+oldCount+' #tcaTable .highlight').length > 0 ) &&
- (!($('#formId'+oldCount+' #threshold').val()) || !($('#formId'+oldCount+' #fieldPathM').val())) ) {
- $('#formId'+oldCount+' #tcaError').show();
- return;
- } else {
- $('#formId'+oldCount+' .tcaErr').hide();
- if ($('#formId'+oldCount+' #tcaTable .highlight').length > 0){
- $('#formId'+oldCount+' #tcaTable .highlight td').text(propertiesToString(oldCount));
- }
- $("#formId"+oldCount+" #tcaTable .highlight").removeClass("highlight")
- }
- }
-
- $("#nav_Tabs li").removeClass("active");
- $(this).parent().addClass("active");
- $("#formId"+count).css("display","");
- $(".formId").not($("#formId"+count)).css("display","none");
- });
-
- $('#tab_close'+count).click(function(event){
- $(this).parent().remove();
- $("#formId"+count).remove();
- });
-
- $('#formId'+count+' #tcaTable').on('click', 'tr', function(event){
- if (($('#formId'+count+' #tcaTable .highlight').length > 0 ) &&
- (!($('#formId'+count+' #threshold').val()) || !($('#formId'+count+' #fieldPathM').val())) ) {
- $('#formId'+count+' #tcaError').show();
- return;
- } else {
- $('#formId'+count+' .tcaErr').hide();
- if ($('#formId'+count+' #tcaTable .highlight').length > 0){
- $('#formId'+count+' #tcaTable .highlight td').text(propertiesToString(num));
- }
- //$('#formId'+count+' #tcaTable .highlight').text();
- $(this).addClass('highlight').siblings().removeClass('highlight');
- var str = $(this).text().split(' ');
- $('#formId'+count + ' #properties_tab').visible();
- if (str.length == 5){
- $('#formId'+count+' #fieldPathM').val(fieldPathMLabel2Value(str[0])).multiselect('refresh');
- $('#formId'+count+' #operator').val(str[1]).multiselect('refresh');
- $('#formId'+count+' #threshold').val(str[2]);
- $('#formId'+count+' #closedLoopEventStatus').val(str[3]).multiselect('refresh');
- }
-
- if ((!(readMOnly)) && ($('#formId'+count + ' #deleteThresh').prop('disabled'))) {
- $('#formId'+count + ' #deleteThresh').prop('disabled', false);
- }
- }
- });
-
- $('#formId'+count+' #deleteThresh').on('click', function(){
- $('#formId'+num+' .tcaErr').hide();
- $('#formId'+count+ ' #properties_tab').invisible();
- $('#formId'+count+ ' #tcaTable .highlight').remove();
- $('#formId'+count+ ' #deleteThresh').prop('disabled', true);
- });
-
- $('#formId'+count+' #createNewThresh').on('click', function(){
- if (($('#formId'+count+' #tcaTable .highlight').length > 0 ) &&
- (!($('#formId'+count+' #threshold').val()) || !($('#formId'+count+' #fieldPathM').val())) ){
- $('#formId'+count+' #tcaError').show();
- return;
- } else {
- $('#formId'+count+' .tcaErr').hide();
- if ($('#formId'+count+' #tcaTable .highlight').length > 0){
- $('#formId'+count+' #tcaTable .highlight td').text(propertiesToString(count));
- }
- $('#formId'+count+ ' #properties_tab').visible();
- if (('#formId'+count+' #tcaTable .highlight').length > 0 ){
- $('#formId'+count+' #tcaTable tr.highlight').removeClass('highlight');
- }
- $('#formId'+count+' #tcaTable').prepend('<tr class="highlight"><td>New Threshold</td></tr>');
- $('#formId'+count+' #fieldPathM').prop("selectedIndex", 0).multiselect('refresh');
- $('#formId'+count+' #operator').prop("selectedIndex", 0).multiselect('refresh');
- $('#formId'+count+' #threshold').val("");
- $('#formId'+count+' #closedLoopEventStatus').prop("selectedIndex", 0).multiselect('refresh');
-
- if ($('#formId'+count + ' #deleteThresh').prop('disabled')) {
- $('#formId'+count + ' #deleteThresh').prop('disabled', false);
- }
- }
- });
-
- $('#formId'+count+' #tname').on('change',function(){
- $('#go_properties_tab'+count).text($('#formId'+count+' #tname').val())
- });
- }
- </script>
-</div>
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/vesCollector_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/vesCollector_properties.html
deleted file mode 100644
index 97263d832..000000000
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/vesCollector_properties.html
+++ /dev/null
@@ -1,38 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- ONAP CLAMP
- ================================================================================
- Copyright (C) 2017 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.
- 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.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END============================================
- ===================================================================
- -->
-<style>
-</style>
-
-<div attribute-test="vescollectorproperties" id="configure-widgets" >
- <div attribute-test="cldsopentemplateh" class="modal-header">
- <button type="button" class="close" ng-click="close(false)" aria-hidden="true" style="margin-top: -3px">&times;</button>
- <h4>VES Collector</h4>
- </div>
-
- <div attribute-test="cldsopentemplateb" class="modal-body" style="height: 280px">
- No parameter can be configured.
- </div>
-
- <div class="modal-footer">
- <button ng-click="close(true)" id="close_button" class="btn btn-primary">Close</button>
- </div>
-</div>
diff --git a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
index 0e44aec16..62ab5ab2f 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
@@ -30,10 +30,9 @@ app
'$rootScope',
function(alertService, $http, $q, $rootScope) {
- function checkIfElementType(name, isSimple) {
+ function checkIfElementType(name) {
//This will open the methods located in the app.js
- if (isSimple){
if (undefined == name) {
return;
}else if (name.toLowerCase().indexOf("policy") >= 0){
@@ -42,21 +41,6 @@ app
$rootScope.selectedBoxName = name.toLowerCase();
ToscaModelWindow();
}
- } else {
- if (undefined == name) {
- return;
- }
- mapping = {
- 'tca' : TCAWindow,
- 'policy' : PolicyWindow,
- 'vescollector' : VesCollectorWindow,
- 'holmes' : HolmesWindow,
- };
- key = name.split('_')[0].toLowerCase()
- if (key in mapping) {
- mapping[key]();
- }
- };
}
function handleQueryToBackend(def, svcAction, svcUrl, svcPayload) {
@@ -226,7 +210,7 @@ app
document.getElementById(menuText).classList.add('ThisLink');
}
};
- this.processActionResponse = function(modelName, pars, simple) {
+ this.processActionResponse = function(modelName, pars) {
// populate control name (prefix and uuid here)
var controlNamePrefix = pars.controlNamePrefix;
@@ -244,7 +228,7 @@ app
document.getElementById("modeler_name").textContent = headerText;
document.getElementById("templa_name").textContent = ("Template Used - " + selected_template);
setStatus(pars)
- disableBPMNAddSVG(pars, simple);
+ disableBPMNAddSVG(pars);
this.enableDisableMenuOptions(pars);
};
this.processRefresh = function(pars) {
@@ -293,7 +277,7 @@ app
'<span id="status_clds" style="position: absolute; left: 61%;top: 151px; font-size:20px;">Status: '
+ statusMsg + '</span>');
}
- function disableBPMNAddSVG(pars, simple) {
+ function disableBPMNAddSVG(pars) {
var svg = pars.imageText.substring(pars.imageText.indexOf("<svg"))
if ($("#svgContainer").length > 0)
@@ -314,7 +298,7 @@ app
var name = $($(event.target).parent()).attr("data-element-id")
lastElementSelected = $($(event.target).parent()).attr(
"data-element-id")
- checkIfElementType(name, simple)
+ checkIfElementType(name)
});
}
this.enableDisableMenuOptions = function(pars) {
diff --git a/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js
index 2b7c62589..111bb2463 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js
@@ -163,10 +163,8 @@ function($scope, $rootScope, $modalInstance, $window, $uibModalInstance, cldsMod
} else {
elementMap = JSON.parse(propText);
}
- var simple = elementMap.simpleModel;
- $rootScope.isSimpleModel = simple;
selected_model = modelName;
- cldsModelService.processActionResponse(modelName, pars, simple);
+ cldsModelService.processActionResponse(modelName, pars);
// set model bpmn and open diagram
$rootScope.isPalette = true;
}, function(data) {
diff --git a/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js
index 21572a5f2..2916f3969 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js
@@ -104,17 +104,6 @@ function($scope, $rootScope, $uibModalInstance, cldsModelService, $location,
$scope.submitForm = function() {
saveGlobalProperties(noRepeats($("#saveProps").serializeArray()))
- //module reset, based on property updates
- if (elementMap["global"]) {
- $.each(Object.keys(elementMap), function(i, v) {
- if ((v.match(/^Policy/)) && asDiff) {
- elementMap[v] = {};
- }
- if ((v.match(/^TCA/)) && (vfDiff || serDiff)) {
- elementMap[v] = {};
- }
- });
- }
$uibModalInstance.close();
}
diff --git a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
index f43161ec0..f78ad1e6b 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
@@ -28,9 +28,8 @@ app.controller('ToscaModelCtrl',
if (selectedPolicy && selectedPolicy != '') {
toscaModelService.getHpModelJsonByPolicyType(selectedPolicy).then(function(response) {
$('#editor').empty();
- // get the list of available policies
- $scope.getPolicyList();
- var toscaModel = JSON.parse(response.body.toscaModelJson);
+
+ var toscaModel = JSON.parse(response.toscaModelJson);
if($scope.policyList && toscaModel.schema.properties && toscaModel.schema.properties.policyList){
toscaModel.schema.properties.policyList.enum = $scope.policyList;
}
@@ -59,24 +58,6 @@ app.controller('ToscaModelCtrl',
}
}
- $scope.getPolicyList = function(){
- var policyNameList = [];
- if (typeof elementMap !== 'undefined'){
- for (key in elementMap){
- if (key.indexOf('Policy')>-1){
- angular.forEach(Object.keys(elementMap[key]), function(text, val){
- for (policyKey in elementMap[key][text]){
- if(elementMap[key][text][policyKey].name == 'pname'){
- policyNameList.push(elementMap[key][text][policyKey].value);
- }
- }
- });
- }
- }
- };
- $scope.policyList = policyNameList;
- }
-
if($rootScope.selectedBoxName) {
var policyType = $rootScope.selectedBoxName.split('_')[0].toLowerCase();
$scope.toscaModelName = policyType.toUpperCase() + " Microservice";
diff --git a/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js b/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js
index 11ad5fa95..2da505cf6 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js
@@ -151,7 +151,7 @@ function loadSharedPropertyByServiceProperties(callBack) {
dataType: "json",
url: '/restservices/clds/v1/clds/properties/',
success: function(data) {
- vf_Services = JSON.parse(data);
+
setASDCFields();
if (callBack && _.isFunction(callBack)) {
callBack(true);
@@ -206,7 +206,7 @@ function setASDCFields() {
//Typically used when opening a new model/template
function reloadDefaultVariables(isTemp) {
isTemplate = isTemp;
- vf_Services = null;
+
}
$(window).on('load',function() {
diff --git a/src/main/resources/META-INF/resources/designer/scripts/app.js b/src/main/resources/META-INF/resources/designer/scripts/app.js
index 544756888..100dda361 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/app.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/app.js
@@ -709,56 +709,6 @@ function($scope, $rootScope, $timeout, dialogs) {
});
}
- $scope.VesCollectorWindow = function(vesCollector) {
-
- var dlg = dialogs.create(
- 'partials/portfolios/vesCollector_properties.html',
- 'ImportSchemaCtrl', {
- closable : true,
- draggable : true
- }, {
- size : 'lg',
- keyboard : true,
- backdrop : 'static',
- windowClass : 'my-class'
- });
- dlg.result.then(function(name) {
-
- }, function() {
-
- });
- };
- $scope.HolmesWindow = function(holmes) {
-
- var partial = 'partials/portfolios/holmes_properties.html'
- var dlg = dialogs.create(partial, 'ImportSchemaCtrl', holmes, {
- closable : true,
- draggable : true
- }, {
- size : 'lg',
- keyboard : true,
- backdrop : 'static',
- windowClass : 'my-class'
- });
- };
- $scope.TCAWindow = function(tca) {
-
- var dlg = dialogs.create('partials/portfolios/tca_properties.html',
- 'ImportSchemaCtrl', {
- closable : true,
- draggable : true
- }, {
- size : 'lg',
- keyboard : true,
- backdrop : 'static',
- windowClass : 'my-class'
- });
- dlg.result.then(function(name) {
-
- }, function() {
-
- });
- };
$scope.ToscaModelWindow = function (tosca_model) {
var dlg = dialogs.create('partials/portfolios/tosca_model_properties.html','ToscaModelCtrl',{closable:true,draggable:true},{size:'lg',keyboard: true,backdrop: 'static',windowClass: 'my-class'});
@@ -872,24 +822,10 @@ function importshema() {
angular.element(document.getElementById('navbar')).scope().importSchema();
}
-function VesCollectorWindow(vesCollectorWin) {
-
- angular.element(document.getElementById('navbar')).scope()
- .VesCollectorWindow(vesCollectorWin);
-}
-function HolmesWindow(holmesWin) {
-
- angular.element(document.getElementById('navbar')).scope().HolmesWindow(
- holmesWin);
-}
function F5Window() {
angular.element(document.getElementById('navbar')).scope().F5Window();
}
-function TCAWindow(tca) {
-
- angular.element(document.getElementById('navbar')).scope().TCAWindow(tca);
-}
function GOCWindow() {
angular.element(document.getElementById('navbar')).scope().GOCWindow();
diff --git a/src/main/resources/clds/camel/rest/clds-services.xml b/src/main/resources/clds/camel/rest/clds-services.xml
index e4c4f4cbc..7abffd35d 100644
--- a/src/main/resources/clds/camel/rest/clds-services.xml
+++ b/src/main/resources/clds/camel/rest/clds-services.xml
@@ -115,6 +115,7 @@
uri="bean:org.onap.clamp.clds.service.CldsToscaService?method=parseToscaModelAndSave(${header.toscaModelName},${body})" />
</put>
<get uri="/tosca/models/policyType/{policyType}"
+ outType="org.onap.clamp.clds.model.CldsToscaModel"
produces="application/json">
<to
uri="bean:org.onap.clamp.clds.service.CldsToscaService?method=getToscaModelsByPolicyType(${header.policyType})" />
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java
index d4c7e5c2a..7d48086cb 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java
@@ -120,16 +120,14 @@ public class CldsToscaServiceItCase {
@Test
public void testGetToscaModel() throws Exception {
- ResponseEntity<CldsToscaModel> responseEntity = cldsToscaService.getToscaModel("tca-policy-test");
- CldsToscaModel savedModel = responseEntity.getBody();
+ CldsToscaModel savedModel = cldsToscaService.getToscaModel("tca-policy-test");
assertNotNull(savedModel);
assertEquals("tca-policy-test", savedModel.getToscaModelName());
}
@Test
public void testGetToscaModelsByPolicyType() throws Exception {
- ResponseEntity<CldsToscaModel> responseEntity = cldsToscaService.getToscaModelsByPolicyType("tca");
- CldsToscaModel savedModel = responseEntity.getBody();
+ CldsToscaModel savedModel = cldsToscaService.getToscaModelsByPolicyType("tca");
assertNotNull(savedModel);
assertEquals("tca-policy-test", savedModel.getToscaModelName());
assertEquals("tca", savedModel.getPolicyType());
diff --git a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
index 2c24dcb5c..0df252388 100644
--- a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
@@ -42,6 +42,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.onap.clamp.clds.dao.CldsDao;
+import org.onap.clamp.clds.exception.policy.PolicyModelException;
import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException;
import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException;
import org.onap.clamp.clds.model.CldsModel;
@@ -78,7 +79,7 @@ public class CsarInstallerItCase {
@Test(expected = SdcArtifactInstallerException.class)
public void testInstallTheCsarFail() throws SdcArtifactInstallerException, SdcToscaParserException,
- CsarHandlerException, IOException, InterruptedException {
+ CsarHandlerException, IOException, InterruptedException, PolicyModelException {
CsarHandler csarHandler = Mockito.mock(CsarHandler.class);
BlueprintArtifact blueprintArtifact = Mockito.mock(BlueprintArtifact.class);
Mockito.when(blueprintArtifact.getResourceAttached()).thenReturn(Mockito.mock(IResourceInstance.class));
@@ -145,7 +146,7 @@ public class CsarInstallerItCase {
@Test
public void testIsCsarAlreadyDeployedTca() throws SdcArtifactInstallerException, SdcToscaParserException,
- CsarHandlerException, IOException, InterruptedException {
+ CsarHandlerException, IOException, InterruptedException, PolicyModelException {
String generatedName = RandomStringUtils.randomAlphanumeric(5);
CsarHandler csarHandler = buildFakeCsarHandler(generatedName);
assertFalse(csarInstaller.isCsarAlreadyDeployed(csarHandler));
@@ -155,7 +156,7 @@ public class CsarInstallerItCase {
@Test
public void testInstallTheCsarTca() throws SdcArtifactInstallerException, SdcToscaParserException,
- CsarHandlerException, IOException, JSONException, InterruptedException {
+ CsarHandlerException, IOException, JSONException, InterruptedException, PolicyModelException {
String generatedName = RandomStringUtils.randomAlphanumeric(5);
CsarHandler csar = buildFakeCsarHandler(generatedName);
csarInstaller.installTheCsar(csar);
diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
index bb4fd01f2..544c8ca1d 100644
--- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
+++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
@@ -24,6 +24,7 @@
package org.onap.clamp.clds.sdc.controller.installer;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -115,6 +116,13 @@ public class CsarHandlerTest {
return resultArtifact;
}
+ private IDistributionClientDownloadResult buildFakeSdcResultWithoutPolicyModel() throws IOException {
+ IDistributionClientDownloadResult resultArtifact = Mockito.mock(IDistributionClientDownloadResult.class);
+ Mockito.when(resultArtifact.getArtifactPayload()).thenReturn(
+ IOUtils.toByteArray(ResourceFileUtil.getResourceAsStream("example/sdc/service-without-policy.csar")));
+ return resultArtifact;
+ }
+
@Test
public void testSave()
throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException {
@@ -148,6 +156,23 @@ public class CsarHandlerTest {
}
@Test
+ public void testLoadingOfPolicyModelFromCsar()
+ throws CsarHandlerException, IOException, SdcArtifactInstallerException, SdcToscaParserException {
+ CsarHandler csar = new CsarHandler(buildFakeSdcNotification(), "test-controller", "/tmp/csar-handler-tests");
+ csar.save(buildFakeSdcResut());
+ String policyModelYaml = csar.getPolicyModelYaml().get();
+ assertTrue(policyModelYaml.contains("tosca_simple_yaml_1_1"));
+ }
+
+ @Test
+ public void testLoadingOfNonexistentPolicyModelFromCsar()
+ throws CsarHandlerException, IOException, SdcArtifactInstallerException, SdcToscaParserException {
+ CsarHandler csar = new CsarHandler(buildFakeSdcNotification(), "test-controller", "/tmp/csar-handler-tests");
+ csar.save(buildFakeSdcResultWithoutPolicyModel());
+ assertFalse(csar.getPolicyModelYaml().isPresent());
+ }
+
+ @Test
public void testDoubleSave()
throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException {
CsarHandler csar = new CsarHandler(buildFakeSdcNotification(), "test-controller", "/tmp/csar-handler-tests");
diff --git a/src/test/resources/example/sdc/service-without-policy.csar b/src/test/resources/example/sdc/service-without-policy.csar
new file mode 100644
index 000000000..20c4eef65
--- /dev/null
+++ b/src/test/resources/example/sdc/service-without-policy.csar
Binary files differ