diff options
author | JvD_Ericsson <jeff.van.dam@est.tech> | 2023-10-23 16:50:37 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-10-24 19:34:58 +0000 |
commit | 133d8bbc63891a9c169b002c03be9ec27f8bc486 (patch) | |
tree | 42523ec19f9824c736fc42786a8c1c72e3239a1e /catalog-be/src | |
parent | a762f63e5dc464dd160808615fce1cfa6c922c90 (diff) |
Milestone updates
Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Change-Id: I43c91fbeb476acea8a8c05c249dcfb01618ddb7b
Issue-ID: SDC-4666
Diffstat (limited to 'catalog-be/src')
9 files changed, 125 insertions, 108 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java index a5927a5b45..0314f97781 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java @@ -45,7 +45,6 @@ import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.INPUTS; import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.INTERFACES; import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.IS_PASSWORD; import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.MEMBERS; -import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.MILESTONES; import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.NODE; import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.NODE_TEMPLATES; import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.NODE_TYPE; @@ -98,13 +97,10 @@ import org.openecomp.sdc.be.components.utils.PropertiesUtils; import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; -import org.openecomp.sdc.be.datatypes.elements.ActivityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.FilterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.MilestoneDataDefinition; import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition; import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition; import org.openecomp.sdc.be.datatypes.elements.PolicyTargetType; @@ -114,9 +110,9 @@ import org.openecomp.sdc.be.datatypes.elements.SubPropertyToscaFunction; import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterPropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ToscaFunction; import org.openecomp.sdc.be.datatypes.elements.ToscaFunctionType; -import org.openecomp.sdc.be.datatypes.enums.ActivityTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ConstraintType; import org.openecomp.sdc.be.datatypes.enums.FilterValueType; +import org.openecomp.sdc.be.datatypes.enums.MilestoneTypeEnum; import org.openecomp.sdc.be.datatypes.enums.PropertyFilterTargetType; import org.openecomp.sdc.be.model.CapabilityDefinition; import org.openecomp.sdc.be.model.Component; @@ -969,7 +965,7 @@ public class YamlTemplateParsingHandler { if (nodeTemplateJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.INSTANCE_COUNT.getElementName())) { Object instanceCount = nodeTemplateJsonMap.get(TypeUtils.ToscaTagNamesEnum.INSTANCE_COUNT.getElementName()); if (instanceCount instanceof Map) { - String instanceCountAsString = "{get_input:" + (String)((Map)instanceCount).get("get_input") + "}"; + String instanceCountAsString = "{get_input:" + (String) ((Map) instanceCount).get("get_input") + "}"; nodeTemplateInfo.setInstanceCount(instanceCountAsString); } else { nodeTemplateInfo.setInstanceCount(instanceCount.toString()); @@ -1303,9 +1299,19 @@ public class YamlTemplateParsingHandler { final Map<String, Object> interfaceInputs = (Map<String, Object>) operationValue.get(INPUTS.getElementName()); operationDef.setInputs(handleInterfaceOperationInputs(interfaceInputs)); } - if (operationValue.containsKey(MILESTONES.getElementName())) { - final Map<String, Object> interfaceMilestones = (Map<String, Object>) operationValue.get(MILESTONES.getElementName()); - operationDef.setMilestones(interfaceDefinitionHandler.handleInterfaceOperationMilestones(interfaceMilestones)); + for (MilestoneTypeEnum milestone : MilestoneTypeEnum.values()) { + String milestoneType = milestone.getValue(); + if (operationValue.containsKey(milestoneType)) { + final Map<String, Object> interfaceMilestones = (Map<String, Object>) operationValue.get(milestoneType); + if (operationDef.getMilestones() == null || operationDef.getMilestones().isEmpty()) { + operationDef.setMilestones(new HashMap<>()); + operationDef.getMilestones().put(milestoneType, + interfaceDefinitionHandler.handleInterfaceOperationMilestones(interfaceMilestones, milestoneType)); + continue; + } + operationDef.getMilestones() + .put(milestoneType, interfaceDefinitionHandler.handleInterfaceOperationMilestones(interfaceMilestones, milestoneType)); + } } operations.put(operationEntry.getKey(), operationDef); } @@ -1415,7 +1421,7 @@ public class YamlTemplateParsingHandler { if (operationDefinitionMap.get(IMPLEMENTATION.getElementName()) instanceof Map && ((Map) operationDefinitionMap.get(IMPLEMENTATION.getElementName())).containsKey("timeout")) { final Object timeOut = ((Map) operationDefinitionMap.get(IMPLEMENTATION.getElementName())).get("timeout"); - artifactDataDefinition.setTimeout((Integer)timeOut); + artifactDataDefinition.setTimeout((Integer) timeOut); } if (operationDefinitionMap.get(IMPLEMENTATION.getElementName()) instanceof String) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java index 8d713c48b0..b850dfd567 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java @@ -27,7 +27,6 @@ import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DESCRIPTION import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.FILTERS; import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.IMPLEMENTATION; import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.INPUTS; -import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.MILESTONES; import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.NOTIFICATIONS; import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.OPERATIONS; import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.REQUIRED; @@ -47,7 +46,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.UUID; @@ -70,6 +68,7 @@ import org.openecomp.sdc.be.datatypes.elements.ToscaFunction; import org.openecomp.sdc.be.datatypes.elements.ToscaFunctionType; import org.openecomp.sdc.be.datatypes.enums.ActivityTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ConstraintType; +import org.openecomp.sdc.be.datatypes.enums.MilestoneTypeEnum; import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; @@ -192,29 +191,38 @@ public class InterfaceDefinitionHandler { final Map<String, Object> interfaceInputs = (Map<String, Object>) operationDefinitionMap.get(INPUTS.getElementName()); operation.setInputs(handleInterfaceOperationInputs(interfaceInputs)); } - if (operationDefinitionMap.containsKey(MILESTONES.getElementName())) { - final Map<String, Object> interfaceMilestones = (Map<String, Object>) operationDefinitionMap.get(MILESTONES.getElementName()); - operation.setMilestones(handleInterfaceOperationMilestones(interfaceMilestones)); + for (MilestoneTypeEnum milestone : MilestoneTypeEnum.values()) { + String milestoneType = milestone.getValue(); + if (operationDefinitionMap.containsKey(milestone.getValue())) { + final Map<String, Object> interfaceMilestones = (Map<String, Object>) operationDefinitionMap.get(milestoneType); + if (operation.getMilestones() == null || operation.getMilestones().isEmpty()) { + operation.setMilestones(new HashMap<>()); + operation.getMilestones().put(milestoneType, handleInterfaceOperationMilestones(interfaceMilestones, milestoneType)); + continue; + } + operation.getMilestones().put(milestoneType, handleInterfaceOperationMilestones(interfaceMilestones, milestoneType)); + } } return operation; } - public Map<String, MilestoneDataDefinition> handleInterfaceOperationMilestones(final Map<String, Object> interfaceMilestones) { - final Map<String, MilestoneDataDefinition> milestones = new HashMap<>(); - for (final Entry<String, Object> interfaceInput : interfaceMilestones.entrySet()) { - final MilestoneDataDefinition operationMilestone = new MilestoneDataDefinition(); - ListDataDefinition<ActivityDataDefinition> activities = handleMilestoneActivities(interfaceInput.getValue()); - if (activities.isEmpty()) { - throw new ByActionStatusComponentException(ActionStatus.INVALID_OPERATION_MILESTONE, interfaceInput.getKey()); - } - ListDataDefinition<FilterDataDefinition> filters = handleMilestoneFilters(interfaceInput.getValue()); + public MilestoneDataDefinition handleInterfaceOperationMilestones(final Map<String, Object> interfaceMilestones, String key) { + final MilestoneDataDefinition operationMilestone = new MilestoneDataDefinition(); + if (interfaceMilestones != null && !interfaceMilestones.containsKey(ACTIVITIES.getElementName())) { + throw new ByActionStatusComponentException(ActionStatus.INVALID_OPERATION_MILESTONE, key); + } + ListDataDefinition<ActivityDataDefinition> activities = handleMilestoneActivities(interfaceMilestones); + if (activities.isEmpty()) { + throw new ByActionStatusComponentException(ActionStatus.INVALID_OPERATION_MILESTONE, key); + } + if (interfaceMilestones.containsKey(FILTERS.getElementName())) { + ListDataDefinition<FilterDataDefinition> filters = handleMilestoneFilters(interfaceMilestones); if (!filters.isEmpty()) { operationMilestone.setFilters(filters); } - operationMilestone.setActivities(activities); - milestones.put(interfaceInput.getKey(), operationMilestone); } - return milestones; + operationMilestone.setActivities(activities); + return operationMilestone; } private ListDataDefinition<FilterDataDefinition> handleMilestoneFilters(Object milestone) { @@ -325,7 +333,7 @@ public class InterfaceDefinitionHandler { } return inputs; } - + private boolean isMilestoneJeopardyData(Object value) { if (value instanceof Map) { Set<String> allowedKeys = new HashSet<>(); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java index 97657f06bf..57c48f53de 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java @@ -67,7 +67,6 @@ import org.openecomp.sdc.be.model.tosca.constraints.LessOrEqualConstraint; import org.openecomp.sdc.be.model.tosca.constraints.LessThanConstraint; import org.openecomp.sdc.be.model.tosca.constraints.MaxLengthConstraint; import org.openecomp.sdc.be.model.tosca.constraints.MinLengthConstraint; -import org.openecomp.sdc.be.model.tosca.constraints.PatternConstraint; import org.openecomp.sdc.be.model.tosca.constraints.ValidValuesConstraint; import org.openecomp.sdc.be.tosca.PropertyConvertor.PropertyType; import org.openecomp.sdc.be.tosca.model.ToscaActivity; @@ -92,7 +91,6 @@ import org.openecomp.sdc.be.tosca.model.ToscaPropertyConstraintLessOrEqual; import org.openecomp.sdc.be.tosca.model.ToscaPropertyConstraintLessThan; import org.openecomp.sdc.be.tosca.model.ToscaPropertyConstraintMaxLength; import org.openecomp.sdc.be.tosca.model.ToscaPropertyConstraintMinLength; -import org.openecomp.sdc.be.tosca.model.ToscaPropertyConstraintPattern; import org.openecomp.sdc.be.tosca.model.ToscaPropertyConstraintValidValues; import org.openecomp.sdc.be.tosca.utils.OperationArtifactUtil; import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum; @@ -489,7 +487,8 @@ public class InterfacesOperationsConverter { } else { if (toscaInterfaceOperationImplementation.getTimeout() != null) { final ToscaArtifactDefinition toscaArtifactDefinition = new ToscaArtifactDefinition(); - toscaArtifactDefinition.setFile(StringUtils.isBlank(operationArtifactPath) || "null".equals(operationArtifactPath) ? null : operationArtifactPath); + toscaArtifactDefinition.setFile( + StringUtils.isBlank(operationArtifactPath) || "null".equals(operationArtifactPath) ? null : operationArtifactPath); toscaInterfaceOperationImplementation.setPrimary(toscaArtifactDefinition); toscaOperation.setImplementation(toscaInterfaceOperationImplementation); } else { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinition.java index 53aca457a1..e4b55fce3e 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinition.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaLifecycleOperationDefinition.java @@ -13,8 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.openecomp.sdc.be.tosca.model; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import java.util.Map; import lombok.Data; @@ -28,6 +31,12 @@ public class ToscaLifecycleOperationDefinition { private String description; private Object implementation; private Map<String, ToscaProperty> inputs; + @JsonIgnore private Map<String, ToscaMilestone> milestones; + @JsonAnyGetter + public Map<String, ToscaMilestone> getMilestonesMap() { + return milestones; + } + } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandlerTest.java index 800fbc2082..b57ae5a00c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandlerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandlerTest.java @@ -129,7 +129,7 @@ class InterfaceDefinitionHandlerTest { assertThrows(ByActionStatusComponentException.class, () -> interfaceDefinitionHandler.create(load, StringUtils.EMPTY)); assertEquals(ActionStatus.INVALID_OPERATION_MILESTONE, actualException.getActionStatus()); assertEquals(1, actualException.getParams().length); - assertEquals("on_failure", actualException.getParams()[0]); + assertEquals("on_success", actualException.getParams()[0]); } private void assertInterfaceDefinition(final InterfaceDefinition actualInterfaceDefinition) { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java index 7e4b4c28e2..5afd520811 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java @@ -661,10 +661,8 @@ class InterfacesOperationsConverterTest { Map<String, Object> resource = (Map<String, Object>) resourceName; assertTrue(resource.containsKey("name_for_op_0")); Map<String, Object> operation0 = (Map<String, Object>) resource.get("name_for_op_0"); - assertTrue(operation0.containsKey("milestones")); - Map<String, Object> operation0Milestones = (Map<String, Object>) operation0.get("milestones"); - assertTrue(operation0Milestones.containsKey(MilestoneTypeEnum.ON_ENTRY.getValue())); - Map<String, Object> milestone = (Map<String, Object>) operation0Milestones.get(MilestoneTypeEnum.ON_ENTRY.getValue()); + assertTrue(operation0.containsKey(MilestoneTypeEnum.ON_ENTRY.getValue())); + Map<String, Object> milestone = (Map<String, Object>) operation0.get(MilestoneTypeEnum.ON_ENTRY.getValue()); assertTrue(milestone.containsKey("activities")); List<Map<String, Object>> activities = (List<Map<String, Object>>) milestone.get("activities"); assertEquals(1, activities.size()); @@ -676,7 +674,7 @@ class InterfacesOperationsConverterTest { assertEquals("workflow1", activityVariables.get("workflow")); assertTrue(activityVariables.containsKey("inputs")); assertTrue(activityVariables.get("inputs") instanceof Map); - Map<String, Object> inputs = (Map<String, Object>) activityVariables.get("inputs"); + Map<String, Object> inputs = (Map<String, Object>) activityVariables.get("inputs"); assertNotNull(inputs); assertTrue(inputs.containsKey("stringName")); assertTrue(inputs.get("stringName") instanceof String); diff --git a/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-legacy.yaml b/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-legacy.yaml index 108c43f547..2d13fb8f5e 100644 --- a/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-legacy.yaml +++ b/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-legacy.yaml @@ -46,54 +46,53 @@ start: service_restoration_sla: service_restoration_sla_value battery_backup: true partner_priorty_assist: false - milestones: - on_failure: - activities: - - delegate: - workflow: workflow1 - - delegate: - workflow: workflow2 - on_success: - activities: - - delegate: - workflow: workflow1 - - delegate: - workflow: workflow2 - inputs: - string: - testString - complex: - jeopardyType: test - name: name - eventType: type - message: message - filters: - - my_attribute: - equal: - get_attribute: - - SELF - - role - - my_attribute1: - greaterThan: my_other_value - - my_attribute2: - inRange: - - test1 - - test99 - - my_attribute3: - validValues: - - test1 - - test2 - - test3 - - my_attribute4: - length: 12 - - my_attribute5: - minLength: 4 - on_timeout: - activities: - - delegate: - workflow: workflow1 - - delegate: - workflow: workflow2 + on_failure: + activities: + - delegate: + workflow: workflow1 + - delegate: + workflow: workflow2 + on_success: + activities: + - delegate: + workflow: workflow1 + - delegate: + workflow: workflow2 + inputs: + string: + testString + complex: + jeopardyType: test + name: name + eventType: type + message: message + filters: + - my_attribute: + equal: + get_attribute: + - SELF + - role + - my_attribute1: + greaterThan: my_other_value + - my_attribute2: + inRange: + - test1 + - test99 + - my_attribute3: + validValues: + - test1 + - test2 + - test3 + - my_attribute4: + length: 12 + - my_attribute5: + minLength: 4 + on_timeout: + activities: + - delegate: + workflow: workflow1 + - delegate: + workflow: workflow2 stop: implementation: "camunda/executeAction" inputs: diff --git a/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-tosca1.3.yaml b/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-tosca1.3.yaml index 0eb1db33a9..2b3e28c721 100644 --- a/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-tosca1.3.yaml +++ b/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-tosca1.3.yaml @@ -41,25 +41,24 @@ operations: service_restoration_sla: service_restoration_sla_value battery_backup: true partner_priorty_assist: false - milestones: - on_failure: - activities: - - delegate: - workflow: workflow1 - - delegate: - workflow: workflow2 - on_success: - activities: - - delegate: - workflow: workflow1 - - delegate: - workflow: workflow2 - on_timeout: - activities: - - delegate: - workflow: workflow1 - - delegate: - workflow: workflow2 + on_failure: + activities: + - delegate: + workflow: workflow1 + - delegate: + workflow: workflow2 + on_success: + activities: + - delegate: + workflow: workflow1 + - delegate: + workflow: workflow2 + on_timeout: + activities: + - delegate: + workflow: workflow1 + - delegate: + workflow: workflow2 stop: implementation: "camunda/executeAction" inputs: diff --git a/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinitionInvalidMilestone-tosca1.3.yaml b/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinitionInvalidMilestone-tosca1.3.yaml index 4e3c556cb8..c6a297b4ae 100644 --- a/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinitionInvalidMilestone-tosca1.3.yaml +++ b/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinitionInvalidMilestone-tosca1.3.yaml @@ -11,7 +11,6 @@ type: tosca.interfaces.node.lifecycle.Standard operations: start: implementation: "camunda/executeAction" - milestones: - on_failure: - on_success: - on_timeout:
\ No newline at end of file + on_failure: + on_success: + on_timeout:
\ No newline at end of file |