summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop/src
diff options
context:
space:
mode:
authorbrunomilitzer <bruno.militzer@est.tech>2021-09-21 10:08:50 +0100
committerbrunomilitzer <bruno.militzer@est.tech>2021-09-21 11:10:52 +0100
commita3654d33f3b3bdb06f9e3c87abd71903439d0f84 (patch)
tree683fb93bd1c9a8ac2cdd761cc81513dad83b52e1 /runtime-controlloop/src
parent7b7fbdf6af90cf695709c734d9d22a5b0c918462 (diff)
Removed Instance From Participant Type.
Added Null Checker on Participant Type and ID Issue-ID: POLICY-3647 Change-Id: I5bed8ec7f302990745d9c8583c65bdf49dec3ab3 Signed-off-by: brunomilitzer <bruno.militzer@est.tech>
Diffstat (limited to 'runtime-controlloop/src')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
index 28558cc02..d2e8be24d 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
@@ -74,6 +74,7 @@ public class ControlLoopInstantiationProvider {
private static final String CONTROL_LOOP_NODE_TYPE = "org.onap.policy.clamp.controlloop.ControlLoop";
private static final String CONTROL_LOOP_NODE_ELEMENT_TYPE = "ControlLoopElement";
private static final String PARTICIPANT_ID_PROPERTY_KEY = "participant_id";
+ private static final String PARTICIPANT_TYPE_PROPERTY_KEY = "participantType";
private static final String CL_ELEMENT_NAME = "name";
private static final String CL_ELEMENT_VERSION = "version";
private static final String INSTANCE_TEXT = "_Instance";
@@ -475,7 +476,7 @@ public class ControlLoopInstantiationProvider {
}
if (template.getType().contains(CONTROL_LOOP_NODE_ELEMENT_TYPE)) {
- ControlLoopElement controlLoopElement = getControlLoopElement(instanceName, newNodeTemplate);
+ ControlLoopElement controlLoopElement = getControlLoopElement(newNodeTemplate);
controlLoopElements.put(controlLoopElement.getId(), controlLoopElement);
}
@@ -548,12 +549,11 @@ public class ControlLoopInstantiationProvider {
/**
* Retrieves Control Loop Element.
*
- * @param instanceName instance name to be appended to participant name
* @param template tosca node template
* @return a control loop element
*/
@SuppressWarnings("unchecked")
- private ControlLoopElement getControlLoopElement(String instanceName, ToscaNodeTemplate template) {
+ private ControlLoopElement getControlLoopElement(ToscaNodeTemplate template) {
ControlLoopElement controlLoopElement = new ControlLoopElement();
ToscaConceptIdentifier definition = new ToscaConceptIdentifier();
definition.setName(template.getName());
@@ -563,12 +563,22 @@ public class ControlLoopInstantiationProvider {
LinkedTreeMap<String, Object> participantId = (LinkedTreeMap<String, Object>) template.getProperties()
.get(PARTICIPANT_ID_PROPERTY_KEY);
- ToscaConceptIdentifier participantIdAndType = new ToscaConceptIdentifier();
- participantIdAndType.setName(participantId.get(CL_ELEMENT_NAME) + instanceName);
- participantIdAndType.setVersion(String.valueOf(participantId.get(CL_ELEMENT_VERSION)));
+ if (participantId != null) {
+ ToscaConceptIdentifier participantIdProperty = new ToscaConceptIdentifier();
+ participantIdProperty.setName(String.valueOf(participantId.get(CL_ELEMENT_NAME)));
+ participantIdProperty.setVersion(String.valueOf(participantId.get(CL_ELEMENT_VERSION)));
+ controlLoopElement.setParticipantId(participantIdProperty);
+ }
+
+ LinkedTreeMap<String, Object> participantType = (LinkedTreeMap<String, Object>) template.getProperties()
+ .get(PARTICIPANT_TYPE_PROPERTY_KEY);
- controlLoopElement.setParticipantType(participantIdAndType);
- controlLoopElement.setParticipantId(participantIdAndType);
+ if (participantType != null) {
+ ToscaConceptIdentifier participantTypeProperty = new ToscaConceptIdentifier();
+ participantTypeProperty.setName(String.valueOf(participantType.get(CL_ELEMENT_NAME)));
+ participantTypeProperty.setVersion(participantType.get(CL_ELEMENT_VERSION).toString());
+ controlLoopElement.setParticipantType(participantTypeProperty);
+ }
return controlLoopElement;
}