From 4c14395a640b3f0f1d0422b5ff7f840ebee8e92d Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Fri, 8 Sep 2017 12:14:08 +0200 Subject: Add Holmes to the Backend Add support for Holmes boxes defined in GUI, Holmes model has been added and also policy calls. Change-Id: I2bbef0030b5174075792b459b7ced74aa2e8aad2 Issue-Id: CLAMP-27 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/client/HolmesPolicyDelegate.java | 72 ++++++++ .../clds/client/HolmesPolicyDeleteDelegate.java | 62 +++++++ .../org/onap/clamp/clds/model/prop/Holmes.java | 71 ++++++++ .../org/onap/clamp/clds/model/prop/ModelBpmn.java | 28 +-- .../onap/clamp/clds/model/prop/ModelElement.java | 28 ++- .../clamp/clds/model/prop/ModelProperties.java | 50 ++---- .../org/onap/clamp/clds/model/prop/Policy.java | 22 +-- .../onap/clamp/clds/model/prop/ResourceGroup.java | 14 +- .../onap/clamp/clds/model/prop/StringMatch.java | 18 +- .../java/org/onap/clamp/clds/model/prop/Tca.java | 20 +-- .../onap/clamp/clds/transform/XslTransformer.java | 6 +- src/main/resources/bpmn/clds-process-action.bpmn | 199 +++++++++++---------- src/main/resources/xsl/clds-bpmn-transformer.xsl | 14 +- .../clamp/clds/transform/XslTransformerTest.java | 34 ++++ src/test/resources/example/modelBpmn.xml | 110 ------------ .../resources/example/xsl-validation/modelBpmn.xml | 156 ++++++++++++++++ .../example/xsl-validation/modelBpmnForVerif.json | 38 ++++ 17 files changed, 639 insertions(+), 303 deletions(-) create mode 100644 src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/Holmes.java create mode 100644 src/test/java/org/onap/clamp/clds/transform/XslTransformerTest.java delete mode 100644 src/test/resources/example/modelBpmn.xml create mode 100644 src/test/resources/example/xsl-validation/modelBpmn.xml create mode 100644 src/test/resources/example/xsl-validation/modelBpmnForVerif.json (limited to 'src') diff --git a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java new file mode 100644 index 000000000..db7b5241b --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java @@ -0,0 +1,72 @@ +/*- + * ============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============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.client; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.clamp.clds.model.prop.Holmes; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * Send Holmes info to policy api. + */ +public class HolmesPolicyDelegate implements JavaDelegate { + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(HolmesPolicyDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + @Autowired + private PolicyClient policyClient; + + @Autowired + private RefProp refProp; + + /** + * Perform activity. Send Holmes info to policy api. + * + * @param execution + */ + @Override + public void execute(DelegateExecution execution) throws Exception { + String holmesPolicyRequestUuid = UUID.randomUUID().toString(); + execution.setVariable("holmesPolicyRequestUuid", holmesPolicyRequestUuid); + + ModelProperties prop = ModelProperties.create(execution); + Holmes holmes = prop.getType(Holmes.class); + if (holmes.isFound()) { + String responseMessage = policyClient.sendMicroServiceInJson(holmes.getCorrelationLogic(), prop, + holmesPolicyRequestUuid); + if (responseMessage != null) { + execution.setVariable("holmesPolicyResponseMessage", responseMessage.getBytes()); + } + } + } + +} diff --git a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java new file mode 100644 index 000000000..46b33ffea --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java @@ -0,0 +1,62 @@ +/*- + * ============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============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.client; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.clamp.clds.model.prop.Holmes; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * Delete Holmes Policy via policy api. + */ +public class HolmesPolicyDeleteDelegate implements JavaDelegate { + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(HolmesPolicyDeleteDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + @Autowired + private PolicyClient policyClient; + + /** + * Perform activity. Delete Holmes Policy via policy api. + * + * @param execution + */ + @Override + public void execute(DelegateExecution execution) throws Exception { + ModelProperties prop = ModelProperties.create(execution); + Holmes holmes = prop.getType(Holmes.class); + if (holmes.isFound()) { + prop.setCurrentModelElementId(holmes.getId()); + + policyClient.deleteMicrosService(prop); + } + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Holmes.java b/src/main/java/org/onap/clamp/clds/model/prop/Holmes.java new file mode 100644 index 000000000..233f656e1 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/Holmes.java @@ -0,0 +1,71 @@ +/*- + * ============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============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.prop; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Parse Holmes bpmn parameters json properties. + *

+ * Example json: + * [{"name":"correlationalLogic","value":"vcwx"},{"name":"operationalPolicy","value":"cccc"}] + * + */ +public class Holmes extends ModelElement { + + private static final String TYPE_HOLMES = "holmes"; + + private String correlationLogic; + + private String operationalPolicy; + + /** + * Default constructor for Holmes Element + * + * @param modelProp + * The ModelProperties containing the all the info, like bpmn, + * bpmn params, etc ... + * @param modelBpmn + * @param modelJson + */ + public Holmes(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + super(TYPE_HOLMES, modelProp, modelBpmn, modelJson); + + correlationLogic = this.getValueByName("correlationalLogic"); + operationalPolicy = this.getValueByName("operationalPolicy"); + } + + public static final String getType() { + return TYPE_HOLMES; + } + + public String getCorrelationLogic() { + return correlationLogic; + } + + public String getOperationalPolicy() { + return operationalPolicy; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java index 63a03058d..ae7028dcd 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java @@ -23,6 +23,15 @@ package org.onap.clamp.clds.model.prop; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -33,15 +42,6 @@ import java.util.Map.Entry; import org.onap.clamp.clds.service.CldsService; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - /** * Parse Model BPMN properties. *

@@ -50,9 +50,9 @@ import com.fasterxml.jackson.databind.node.ObjectNode; * :[{"id":"Policy_0oxeocn", "from":"StringMatch_0h6cbdv"}]} */ public class ModelBpmn { - protected static final EELFLogger logger = EELFManager.getInstance() + protected static final EELFLogger logger = EELFManager.getInstance() .getLogger(CldsService.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); // for each type, an array of entries private final Map> entriesByType = new HashMap<>(); @@ -123,12 +123,14 @@ public class ModelBpmn { } /** - * + * This method verifies if the ModelElement Type (collector, holmes, tca, + * ...) is in the list. * * @param type + * A model Element type (tca, collector, ...) * @return true if the element is found or false otherwise */ - public boolean getModelElementFound(String type) { + public boolean isModelElementTypeInList(String type) { return entriesByType.get(type) != null; } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java index 42d11f4b5..edf114261 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java @@ -32,20 +32,19 @@ import java.util.Iterator; import java.util.List; /** - * Provide base ModelElement functionality. + * Provide base ModelElement functionality. Perform base parsing of properties + * for a ModelElement (such as, Collector, StringMatch, Policy, Tca, Holmes, + * ...) */ public abstract class ModelElement { protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelElement.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - public static final String TYPE_POLICY = "policy"; - public static final String TYPE_TCA = "tca"; - private final String type; private final ModelBpmn modelBpmn; private final String id; protected String topicPublishes; - protected final JsonNode meNode; + protected final JsonNode modelElementJsonNode; private boolean isFound; private final ModelProperties modelProp; @@ -64,12 +63,13 @@ public abstract class ModelElement { this.modelProp = modelProp; this.modelBpmn = modelBpmn; this.id = modelBpmn.getId(type); - this.meNode = modelJson.get(id); - this.isFound = modelBpmn.getModelElementFound(type); + this.modelElementJsonNode = modelJson.get(id); + this.isFound = modelBpmn.isModelElementTypeInList(type); } /** - * topicSubscribes is the topicPublishes of the from Model Element + * topicSubscribes is the topicPublishes of the from Model Element (the + * previous one in the chain). * * @return the topicSubscribes */ @@ -159,16 +159,14 @@ public abstract class ModelElement { while (i.hasNext()) { JsonNode node = i.next(); if (node.path("name").asText().equals(name)) { - String value; JsonNode vnode = node.path("value"); if (vnode.isArray()) { // if array, assume value is in first element - value = vnode.path(0).asText(); + values.add(vnode.path(0).asText()); } else { // otherwise, just return text - value = vnode.asText(); + values.add(vnode.asText()); } - values.add(value); } } } @@ -241,7 +239,7 @@ public abstract class ModelElement { * @return */ public String getValueByName(String name) { - return getValueByName(meNode, name); + return getValueByName(modelElementJsonNode, name); } /** @@ -252,7 +250,7 @@ public abstract class ModelElement { * @return */ public Integer getIntValueByName(String name) { - return getIntValueByName(meNode, name); + return getIntValueByName(modelElementJsonNode, name); } /** @@ -263,7 +261,7 @@ public abstract class ModelElement { * @return */ public List getValuesByName(String name) { - return getValuesByName(meNode, name); + return getValuesByName(modelElementJsonNode, name); } /** diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java index 1cfd46165..9684eea86 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java @@ -23,6 +23,12 @@ package org.onap.clamp.clds.model.prop; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.HashSet; @@ -36,19 +42,13 @@ import org.onap.clamp.clds.model.CldsEvent; import org.onap.clamp.clds.model.CldsModel; import org.onap.clamp.clds.service.CldsService; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - /** * Parse model properties. */ public class ModelProperties { - protected static final EELFLogger logger = EELFManager.getInstance() + protected static final EELFLogger logger = EELFManager.getInstance() .getLogger(CldsService.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance() + protected static final EELFLogger auditLogger = EELFManager.getInstance() .getAuditLogger(); private ModelBpmn modelBpmn; @@ -58,10 +58,9 @@ public class ModelProperties { private final String controlName; private final String actionCd; // Flag indicate whether it is triggered by Validation Test button from UI - private final boolean isTest; + private final boolean isTest; private Global global; - private Tca tca; private final Map modelElements = new ConcurrentHashMap<>(); @@ -93,8 +92,8 @@ public class ModelProperties { * @throws JsonProcessingException * @throws IOException */ - public ModelProperties(String modelName, String controlName, String actionCd, boolean isTest, String modelBpmnPropText, - String modelPropText) throws IOException { + public ModelProperties(String modelName, String controlName, String actionCd, boolean isTest, + String modelBpmnPropText, String modelPropText) throws IOException { this.modelName = modelName; this.controlName = controlName; this.actionCd = actionCd; @@ -150,7 +149,7 @@ public class ModelProperties { Global global = new Global(modelJson); vfs = global.getResourceVf(); } catch (IOException e) { - // VF is null + logger.warn("no VF found", e); } String vf = null; if (vfs != null && !vfs.isEmpty()) { @@ -168,13 +167,12 @@ public class ModelProperties { * @throws IOException */ public static ModelProperties create(DelegateExecution execution) throws IOException { - // String modelProp = (String) execution.getVariable("modelProp"); String modelProp = new String((byte[]) execution.getVariable("modelProp")); String modelBpmnProp = (String) execution.getVariable("modelBpmnProp"); String modelName = (String) execution.getVariable("modelName"); String controlName = (String) execution.getVariable("controlName"); String actionCd = (String) execution.getVariable("actionCd"); - boolean isTest = (boolean)execution.getVariable("isTest"); + boolean isTest = (boolean) execution.getVariable("isTest"); return new ModelProperties(modelName, controlName, actionCd, isTest, modelBpmnProp, modelProp); } @@ -303,12 +301,12 @@ public class ModelProperties { return actionCd; } - /** - * @return the isTest - */ - public boolean isTest() { - return isTest; - } + /** + * @return the isTest + */ + public boolean isTest() { + return isTest; + } /** * @return the isCreateRequest @@ -352,14 +350,4 @@ public class ModelProperties { String type = modelElementClasses.get(clazz); return (type != null ? (T) modelElements.get(type) : null); } - - /** - * @return the tca - */ - public Tca getTca() { - if (tca == null) { - tca = new Tca(this, modelBpmn, modelJson); - } - return tca; - } } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Policy.java b/src/main/java/org/onap/clamp/clds/model/prop/Policy.java index 6673af213..452af20cd 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Policy.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Policy.java @@ -23,14 +23,14 @@ package org.onap.clamp.clds.model.prop; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** * Parse Policy json properties. *

@@ -49,12 +49,12 @@ import com.fasterxml.jackson.databind.JsonNode; * "vf3RtPi"]}]]}] */ public class Policy extends ModelElement { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private List policyChains; + private List policyChains; - private static final String TYPE_POLICY = "policy"; + private static final String TYPE_POLICY = "policy"; /** * Parse Policy given json node. @@ -64,12 +64,12 @@ public class Policy extends ModelElement { * @param modelJson */ public Policy(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { - super(ModelElement.TYPE_POLICY, modelProp, modelBpmn, modelJson); + super(TYPE_POLICY, modelProp, modelBpmn, modelJson); // process policies - if (meNode != null) { - Iterator itr = meNode.elements(); - policyChains = new ArrayList(); + if (modelElementJsonNode != null) { + Iterator itr = modelElementJsonNode.elements(); + policyChains = new ArrayList<>(); while (itr.hasNext()) { policyChains.add(new PolicyChain(itr.next())); } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java b/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java index de98333a1..6e986bb0e 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java @@ -23,14 +23,14 @@ package org.onap.clamp.clds.model.prop; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** * Parse Resource Group json properties. * @@ -63,8 +63,8 @@ import com.fasterxml.jackson.databind.JsonNode; */ public class ResourceGroup { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ResourceGroup.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ResourceGroup.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); private String groupNumber; private String policyId; @@ -84,7 +84,7 @@ public class ResourceGroup { // process Server_Configurations JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations"); Iterator itr = serviceConfigurationsNode.elements(); - serviceConfigurations = new ArrayList(); + serviceConfigurations = new ArrayList<>(); while (itr.hasNext()) { serviceConfigurations.add(new ServiceConfiguration(itr.next())); } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java b/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java index b20db0aff..7fcc1b1b9 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java @@ -23,14 +23,12 @@ package org.onap.clamp.clds.model.prop; +import com.fasterxml.jackson.databind.JsonNode; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - /** * Parse StringMatch json properties. *

@@ -62,12 +60,10 @@ import com.fasterxml.jackson.databind.JsonNode; * */ public class StringMatch extends ModelElement { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(StringMatch.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private List resourceGroups; + private List resourceGroups; - private static final String TYPE_STRING_MATCH = "stringMatch"; + private static final String TYPE_STRING_MATCH = "stringMatch"; /** * Parse StringMatch given json node. @@ -79,9 +75,9 @@ public class StringMatch extends ModelElement { super(TYPE_STRING_MATCH, modelProp, modelBpmn, modelJson); // process Server_Configurations - if (meNode != null) { - Iterator itr = meNode.elements(); - resourceGroups = new ArrayList(); + if (modelElementJsonNode != null) { + Iterator itr = modelElementJsonNode.elements(); + resourceGroups = new ArrayList<>(); while (itr.hasNext()) { resourceGroups.add(new ResourceGroup(itr.next())); } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Tca.java b/src/main/java/org/onap/clamp/clds/model/prop/Tca.java index b94f52304..6bc68e23d 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Tca.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Tca.java @@ -23,14 +23,14 @@ package org.onap.clamp.clds.model.prop; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** * Parse Tca json properties. * @@ -50,12 +50,12 @@ import com.fasterxml.jackson.databind.JsonNode; */ public class Tca extends ModelElement { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Tca.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Tca.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private List tcaItems; + private List tcaItems; - private static final String TYPE_TCA = "tca"; + private static final String TYPE_TCA = "tca"; /** * Parse Tca given json node @@ -68,9 +68,9 @@ public class Tca extends ModelElement { super(TYPE_TCA, modelProp, modelBpmn, modelJson); // process Server_Configurations - if (meNode != null) { - Iterator itr = meNode.elements(); - tcaItems = new ArrayList(); + if (modelElementJsonNode != null) { + Iterator itr = modelElementJsonNode.elements(); + tcaItems = new ArrayList<>(); while (itr.hasNext()) { tcaItems.add(new TcaItem(itr.next())); } diff --git a/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java b/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java index d15f67c77..684bae3f6 100644 --- a/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java +++ b/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java @@ -34,6 +34,8 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import org.onap.clamp.clds.util.ResourceFileUtil; + /** * XSL Transformer. */ @@ -43,7 +45,7 @@ public class XslTransformer { public void setXslResourceName(String xslResourceName) throws TransformerConfigurationException { TransformerFactory tfactory = TransformerFactory.newInstance(); - templates = tfactory.newTemplates(new StreamSource(TransformUtil.getResourceAsStream(xslResourceName))); + templates = tfactory.newTemplates(new StreamSource(ResourceFileUtil.getResourceAsStream(xslResourceName))); } /** @@ -53,7 +55,7 @@ public class XslTransformer { * @throws TransformerException */ public String doXslTransformToString(String xml) throws TransformerException { - StringWriter output = new StringWriter(4000); + StringWriter output = new StringWriter(4096); Transformer transformer = templates.newTransformer(); transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult(output)); diff --git a/src/main/resources/bpmn/clds-process-action.bpmn b/src/main/resources/bpmn/clds-process-action.bpmn index d9f8619cc..780162403 100644 --- a/src/main/resources/bpmn/clds-process-action.bpmn +++ b/src/main/resources/bpmn/clds-process-action.bpmn @@ -1,5 +1,5 @@ - + @@ -13,26 +13,27 @@ sendOpPolicyReqDistribute StartEvent_1 ServiceTask_0x8ypxf - sendStringMatchingReqDistribute sendTcaReqDistribute + sendStringMatchingReqDistribute + sendHolmesReqDistribute sendStringMatchingReqDelete - sendOpPolicyReqDelete sendTcaReqDelete + sendOpPolicyReqDelete + sendHolmesReqDelete sendOpPolicyReqUpdate sendStringMatchingReqUpdate sendTcaReqUpdate + sendHolmesReqUpdate sendOpPolicyReqStop - ServiceTask_0d5zgbw sendOpPolicyReqRestart - ServiceTask_04d5jlr @@ -69,34 +70,32 @@ SequenceFlow_7 - - SequenceFlow_1rga27p + SequenceFlow_1tu9g11 SequenceFlow_10 - SequenceFlow_1kegg6u + SequenceFlow_0ejpmee SequenceFlow_28 - - SequenceFlow_17snsdc + SequenceFlow_29 SequenceFlow_30 - + - SequenceFlow_188n2z7 + SequenceFlow_31 SequenceFlow_32 - + @@ -122,43 +121,50 @@ SequenceFlow_1xlfq66 SequenceFlow_0w39hon - - - SequenceFlow_31 - SequenceFlow_188n2z7 + + + + SequenceFlow_23 + SequenceFlow_0tpegxf - - - SequenceFlow_29 - SequenceFlow_17snsdc + + + SequenceFlow_14 + SequenceFlow_1rga27p SequenceFlow_0w39hon SequenceFlow_14 - - - SequenceFlow_14 - SequenceFlow_1rga27p + + + + SequenceFlow_1rga27p + SequenceFlow_1tu9g11 - SequenceFlow_0tpegxf + SequenceFlow_1mtizad SequenceFlow_6 - - - SequenceFlow_23 - SequenceFlow_0tpegxf + + SequenceFlow_0tpegxf + SequenceFlow_1mtizad + SequenceFlow_27 SequenceFlow_26 - SequenceFlow_26 SequenceFlow_1kegg6u + + + SequenceFlow_1kegg6u + SequenceFlow_0ejpmee + + @@ -175,16 +181,16 @@ - + - - - + + + - + @@ -235,19 +241,19 @@ - - - - + + + + - + - + @@ -260,22 +266,22 @@ - + - - - + + + - + - + @@ -283,10 +289,10 @@ - - + + - + @@ -297,11 +303,10 @@ - - - + + - + @@ -310,7 +315,7 @@ - + @@ -322,18 +327,18 @@ - + - + - - + + - + @@ -349,9 +354,9 @@ - + - + @@ -362,56 +367,66 @@ - - - + + + - + - - + + - - - + + + - + - - + + - - + + + + + + + + + + + + + + + - + - - + + - - - + + + - + - - + + - - + + - + - - - diff --git a/src/main/resources/xsl/clds-bpmn-transformer.xsl b/src/main/resources/xsl/clds-bpmn-transformer.xsl index 94af952fc..8a39be55a 100644 --- a/src/main/resources/xsl/clds-bpmn-transformer.xsl +++ b/src/main/resources/xsl/clds-bpmn-transformer.xsl @@ -1,4 +1,4 @@ - + - - - - - SequenceFlow_0ex3w2w - - - SequenceFlow_0ex3w2w - SequenceFlow_185iyma - - - SequenceFlow_185iyma - SequenceFlow_092429t - - - SequenceFlow_092429t - SequenceFlow_0hghw7g - - - SequenceFlow_08j3fsl - SequenceFlow_0hghw7g - - - SequenceFlow_0hghw7g - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/test/resources/example/xsl-validation/modelBpmn.xml b/src/test/resources/example/xsl-validation/modelBpmn.xml new file mode 100644 index 000000000..3021902c7 --- /dev/null +++ b/src/test/resources/example/xsl-validation/modelBpmn.xml @@ -0,0 +1,156 @@ + + + + + SequenceFlow_1nvvr00 + + + SequenceFlow_0qf2552 + SequenceFlow_1a2oxpd + + + SequenceFlow_0jeu0gv + SequenceFlow_15gkgs5 + + + SequenceFlow_1nvvr00 + SequenceFlow_0qf2552 + + + SequenceFlow_15gkgs5 + SequenceFlow_0ev75ss + + + SequenceFlow_0ev75ss + SequenceFlow_103hvmr + + + SequenceFlow_103hvmr + + + SequenceFlow_1a2oxpd + SequenceFlow_0jeu0gv + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/example/xsl-validation/modelBpmnForVerif.json b/src/test/resources/example/xsl-validation/modelBpmnForVerif.json new file mode 100644 index 000000000..1bef49a1a --- /dev/null +++ b/src/test/resources/example/xsl-validation/modelBpmnForVerif.json @@ -0,0 +1,38 @@ +{ + "collector": [ + { + "id": "Collector_", + "from": "StartEvent_1" + } + ], + "stringMatch": [ + { + "id": "StringMatch_0tw2y4f", + "from": "Collector_" + } + ], + "policy": [ + { + "id": "Policy_", + "from": "TCA_09hcdsx" + } + ], + "tca": [ + { + "id": "TCA_09hcdsx", + "from": "VesCollector_1kxjxy6" + } + ], + "vesCollector": [ + { + "id": "VesCollector_1kxjxy6", + "from": "Holmes_1fzdqp9" + } + ], + "holmes": [ + { + "id": "Holmes_1fzdqp9", + "from": "StringMatch_0tw2y4f" + } + ] +} \ No newline at end of file -- cgit 1.2.3-korg