From 558d8d0d2d958ff3b18fb2f6e04cab14d8ff2da3 Mon Sep 17 00:00:00 2001 From: mojahidi Date: Thu, 29 Mar 2018 10:37:45 +0530 Subject: Added new files requied for operation Added new files requied for workflow operation Change-Id: I561185415a7e82aa75772c6c0b4b1a206b547699 Issue-ID: SDC-1060 Signed-off-by: mojahidi --- .../datamodel/utils/InterfaceUIDataConverter.java | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java (limited to 'catalog-be/src/main') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java new file mode 100644 index 0000000000..7885ab1bd2 --- /dev/null +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + +package org.openecomp.sdc.be.datamodel.utils; + +import org.openecomp.sdc.be.datatypes.elements.InterfaceOperationDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.InterfaceOperationParamDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition; +import org.openecomp.sdc.be.model.Operation; + +import java.util.List; +import java.util.stream.Collectors; + +public class InterfaceUIDataConverter { + + private InterfaceUIDataConverter () { + + } + public static Operation convertInterfaceDataToOperationData(InterfaceOperationDataDefinition interfaceOperation){ + + ListDataDefinition inputParams = interfaceOperation.getInputParams(); + ListDataDefinition inputs = new ListDataDefinition<>(); + if (inputParams != null) { + List inputList = inputParams.getListToscaDataDefinition().stream() + .map(a -> new OperationInputDefinition(a.getParamName(), a.getParamId())).collect(Collectors.toList()); + inputList.forEach(inputs::add); + } + Operation operationData = new Operation(); + operationData.setDescription(interfaceOperation.getDescription()); + operationData.setName(interfaceOperation.getOperationType()); + operationData.setUniqueId(interfaceOperation.getUniqueId()); + operationData.setInputs(inputs); + + return operationData; + } + + public static InterfaceOperationDataDefinition convertOperationDataToInterfaceData(Operation operationData){ + + ListDataDefinition inputs = operationData.getInputs(); + List inputParamList = inputs.getListToscaDataDefinition().stream().map(a -> new InterfaceOperationParamDataDefinition(a.getName(), a.getInputId())).collect( + Collectors.toList()); + ListDataDefinition inputParams = new ListDataDefinition<>(); + inputParamList.forEach(inputParams::add); + + InterfaceOperationDataDefinition interfaceOperationDataDefinition = new InterfaceOperationDataDefinition(); + interfaceOperationDataDefinition.setUniqueId(operationData.getUniqueId()); + interfaceOperationDataDefinition.setOperationType(operationData.getName()); + interfaceOperationDataDefinition.setDescription(operationData.getDescription()); + interfaceOperationDataDefinition.setInputParams(inputParams); + interfaceOperationDataDefinition.setWorkflowId(operationData.getImplementation().getArtifactUUID()); + + return interfaceOperationDataDefinition; + } + +} -- cgit 1.2.3-korg