2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
22 import com.google.gson.reflect.TypeToken;
23 import fj.data.Either;
24 import java.lang.reflect.Type;
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.Iterator;
28 import java.util.List;
30 import java.util.Map.Entry;
31 import java.util.Optional;
32 import java.util.stream.Collectors;
33 import org.apache.commons.collections.MapUtils;
34 import org.apache.tinkerpop.gremlin.structure.Direction;
35 import org.apache.tinkerpop.gremlin.structure.Edge;
36 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
37 import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
38 import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
39 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
40 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
41 import org.openecomp.sdc.be.datatypes.category.MetadataKeyDataDefinition;
42 import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition;
43 import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
44 import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
45 import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
46 import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
47 import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
48 import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition;
49 import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
50 import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
51 import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
52 import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
53 import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
54 import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
55 import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
56 import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty;
57 import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
58 import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
59 import org.openecomp.sdc.be.datatypes.elements.MapInterfaceDataDefinition;
60 import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition;
61 import org.openecomp.sdc.be.datatypes.elements.MapListRequirementDataDefinition;
62 import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
63 import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition;
64 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
65 import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterDataDefinition;
66 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
67 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
68 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
69 import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
70 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
71 import org.openecomp.sdc.be.model.Component;
72 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
73 import org.openecomp.sdc.be.model.ComponentParametersView;
74 import org.openecomp.sdc.be.model.DistributionStatusEnum;
75 import org.openecomp.sdc.be.model.GroupDefinition;
76 import org.openecomp.sdc.be.model.PolicyDefinition;
77 import org.openecomp.sdc.be.model.User;
78 import org.openecomp.sdc.be.model.category.CategoryDefinition;
79 import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
80 import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
81 import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElementTypeEnum;
82 import org.openecomp.sdc.be.model.jsonjanusgraph.utils.CapabilityRequirementNameResolver;
83 import org.openecomp.sdc.be.model.jsonjanusgraph.utils.ModelConverter;
84 import org.openecomp.sdc.be.model.operations.StorageException;
85 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
86 import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
87 import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
88 import org.openecomp.sdc.common.api.Constants;
89 import org.openecomp.sdc.common.jsongraph.util.CommonUtility;
90 import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum;
91 import org.openecomp.sdc.common.log.elements.ErrorLogOptionalData;
92 import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
93 import org.openecomp.sdc.common.log.wrappers.Logger;
94 import org.openecomp.sdc.common.util.ValidationUtils;
95 import org.springframework.beans.factory.annotation.Autowired;
97 @org.springframework.stereotype.Component("topology-template-operation")
98 public class TopologyTemplateOperation extends ToscaElementOperation {
100 private static final Logger log = Logger.getLogger(TopologyTemplateOperation.class);
102 private ArchiveOperation archiveOperation;
104 public static String buildSubComponentName(String componentName, String subComponentTypeName, int counter) {
105 String normalizedComponentName = ValidationUtils.normalizeComponentInstanceName(componentName);
106 String typeSuffix = subComponentTypeName.substring(subComponentTypeName.lastIndexOf('.') + 1, subComponentTypeName.length());
107 return normalizedComponentName + Constants.GROUP_POLICY_NAME_DELIMETER + typeSuffix + Constants.GROUP_POLICY_NAME_DELIMETER + counter;
110 public Either<TopologyTemplate, StorageOperationStatus> createTopologyTemplate(TopologyTemplate topologyTemplate) {
111 topologyTemplate.generateUUID();
112 topologyTemplate = getResourceMetaDataFromResource(topologyTemplate);
113 String resourceUniqueId = topologyTemplate.getUniqueId();
114 if (resourceUniqueId == null) {
115 resourceUniqueId = UniqueIdBuilder.buildResourceUniqueId();
116 topologyTemplate.setUniqueId(resourceUniqueId);
118 GraphVertex topologyTemplateVertex = new GraphVertex();
119 topologyTemplateVertex = fillMetadata(topologyTemplateVertex, topologyTemplate, JsonParseFlagEnum.ParseAll);
120 Either<GraphVertex, JanusGraphOperationStatus> createdVertex = janusGraphDao.createVertex(topologyTemplateVertex);
121 if (createdVertex.isRight()) {
122 JanusGraphOperationStatus status = createdVertex.right().value();
123 log.debug("Error returned after creating topology template data node {}. status returned is ", topologyTemplateVertex, status);
124 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
126 StorageOperationStatus assosiateCommon = assosiateCommonForToscaElement(topologyTemplateVertex, topologyTemplate);
127 if (assosiateCommon != StorageOperationStatus.OK) {
128 return Either.right(assosiateCommon);
130 StorageOperationStatus associateCategory = assosiateMetadataToCategory(topologyTemplateVertex, topologyTemplate);
131 if (associateCategory != StorageOperationStatus.OK) {
132 return Either.right(associateCategory);
134 StorageOperationStatus associateInputs = associateInputsToComponent(topologyTemplateVertex, topologyTemplate);
135 if (associateInputs != StorageOperationStatus.OK) {
136 return Either.right(associateInputs);
138 StorageOperationStatus associateGroups = associateGroupsToComponent(topologyTemplateVertex, topologyTemplate);
139 if (associateGroups != StorageOperationStatus.OK) {
140 return Either.right(associateGroups);
142 StorageOperationStatus associatePolicies = associatePoliciesToComponent(topologyTemplateVertex, topologyTemplate);
143 if (associatePolicies != StorageOperationStatus.OK) {
144 return Either.right(associatePolicies);
146 StorageOperationStatus associateInstAttr = associateInstAttributesToComponent(topologyTemplateVertex, topologyTemplate);
147 if (associateInstAttr != StorageOperationStatus.OK) {
148 return Either.right(associateInstAttr);
150 StorageOperationStatus associateInstProperties = associateInstPropertiesToComponent(topologyTemplateVertex, topologyTemplate);
151 if (associateInstProperties != StorageOperationStatus.OK) {
152 return Either.right(associateInstProperties);
154 StorageOperationStatus associateInstInputs = associateInstInputsToComponent(topologyTemplateVertex, topologyTemplate);
155 if (associateInstProperties != StorageOperationStatus.OK) {
156 return Either.right(associateInstInputs);
158 StorageOperationStatus associateInstGroups = associateInstGroupsToComponent(topologyTemplateVertex, topologyTemplate);
159 if (associateInstGroups != StorageOperationStatus.OK) {
160 return Either.right(associateInstInputs);
162 StorageOperationStatus associateRequirements = associateRequirementsToResource(topologyTemplateVertex, topologyTemplate);
163 if (associateRequirements != StorageOperationStatus.OK) {
164 return Either.right(associateRequirements);
166 StorageOperationStatus associateCapabilities = associateCapabilitiesToResource(topologyTemplateVertex, topologyTemplate);
167 if (associateCapabilities != StorageOperationStatus.OK) {
168 return Either.right(associateCapabilities);
170 StorageOperationStatus associateArtifacts = associateTopologyTemplateArtifactsToComponent(topologyTemplateVertex, topologyTemplate);
171 if (associateArtifacts != StorageOperationStatus.OK) {
172 return Either.right(associateArtifacts);
174 StorageOperationStatus addAdditionalInformation = addAdditionalInformationToResource(topologyTemplateVertex, topologyTemplate);
175 if (addAdditionalInformation != StorageOperationStatus.OK) {
176 return Either.right(addAdditionalInformation);
178 StorageOperationStatus associateCapProperties = associateCapPropertiesToResource(topologyTemplateVertex, topologyTemplate);
179 if (associateCapProperties != StorageOperationStatus.OK) {
180 return Either.right(associateCapProperties);
182 StorageOperationStatus associateInterfaces = associateInterfacesToComponent(topologyTemplateVertex, topologyTemplate);
183 if (associateInterfaces != StorageOperationStatus.OK) {
184 return Either.right(associateInterfaces);
186 StorageOperationStatus associatePathProperties = associateForwardingPathToResource(topologyTemplateVertex, topologyTemplate);
187 if (associateCapProperties != StorageOperationStatus.OK) {
188 return Either.right(associatePathProperties);
190 final StorageOperationStatus associateServiceToModel = associateComponentToModel(topologyTemplateVertex, topologyTemplate,
191 EdgeLabelEnum.MODEL);
192 if (associateServiceToModel != StorageOperationStatus.OK) {
193 return Either.right(associateServiceToModel);
195 return Either.left(topologyTemplate);
198 private StorageOperationStatus associatePoliciesToComponent(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
199 return associatePoliciesToComponent(nodeTypeVertex, topologyTemplate.getPolicies());
202 private StorageOperationStatus associatePoliciesToComponent(GraphVertex nodeTypeVertex, Map<String, PolicyDataDefinition> policies) {
203 if (policies != null && !policies.isEmpty()) {
204 policies.values().stream().filter(p -> p.getUniqueId() == null).forEach(p -> {
205 String uid = UniqueIdBuilder.buildGroupingUid(nodeTypeVertex.getUniqueId(), p.getName());
208 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex, VertexTypeEnum.POLICIES,
209 EdgeLabelEnum.POLICIES, policies);
210 if (assosiateElementToData.isRight()) {
211 return assosiateElementToData.right().value();
214 return StorageOperationStatus.OK;
217 private StorageOperationStatus associateForwardingPathToResource(GraphVertex topologyTemplateVertex, TopologyTemplate topologyTemplate) {
218 Map<String, ForwardingPathDataDefinition> forwardingPaths = topologyTemplate.getForwardingPaths();
219 return associateForwardingPathToComponent(topologyTemplateVertex, forwardingPaths);
222 private StorageOperationStatus associateCapPropertiesToResource(GraphVertex topologyTemplateVertex, TopologyTemplate topologyTemplate) {
223 Map<String, MapCapabilityProperty> calculatedCapProperties = topologyTemplate.getCalculatedCapabilitiesProperties();
224 if (MapUtils.isNotEmpty(calculatedCapProperties)) {
225 Either<GraphVertex, StorageOperationStatus> associateElementToData = associateElementToData(topologyTemplateVertex,
226 VertexTypeEnum.CALCULATED_CAP_PROPERTIES, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, calculatedCapProperties);
227 if (associateElementToData.isRight()) {
228 return associateElementToData.right().value();
231 Map<String, MapPropertiesDataDefinition> capabilitiesProperties = topologyTemplate.getCapabilitiesProperties();
232 if (MapUtils.isNotEmpty(capabilitiesProperties)) {
233 Either<GraphVertex, StorageOperationStatus> associateElementToData = associateElementToData(topologyTemplateVertex,
234 VertexTypeEnum.CAPABILITIES_PROPERTIES, EdgeLabelEnum.CAPABILITIES_PROPERTIES, capabilitiesProperties);
235 if (associateElementToData.isRight()) {
236 return associateElementToData.right().value();
239 return StorageOperationStatus.OK;
242 private StorageOperationStatus associateCapabilitiesToResource(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
243 Map<String, MapListCapabilityDataDefinition> calculatedCapabilities = topologyTemplate.getCalculatedCapabilities();
244 if (calculatedCapabilities != null && !calculatedCapabilities.isEmpty()) {
245 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex,
246 VertexTypeEnum.CALCULATED_CAPABILITIES, EdgeLabelEnum.CALCULATED_CAPABILITIES, calculatedCapabilities);
247 if (assosiateElementToData.isRight()) {
248 return assosiateElementToData.right().value();
251 Map<String, MapListCapabilityDataDefinition> fullfilledCapabilities = topologyTemplate.getFullfilledCapabilities();
252 if (fullfilledCapabilities != null && !fullfilledCapabilities.isEmpty()) {
253 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex,
254 VertexTypeEnum.FULLFILLED_CAPABILITIES, EdgeLabelEnum.FULLFILLED_CAPABILITIES, fullfilledCapabilities);
255 if (assosiateElementToData.isRight()) {
256 return assosiateElementToData.right().value();
259 Map<String, ListCapabilityDataDefinition> capabilities = topologyTemplate.getCapabilities();
260 if (MapUtils.isNotEmpty(capabilities)) {
261 Either<GraphVertex, StorageOperationStatus> associateElementToData = associateElementToData(nodeTypeVertex, VertexTypeEnum.CAPABILITIES,
262 EdgeLabelEnum.CAPABILITIES, capabilities);
263 if (associateElementToData.isRight()) {
264 return associateElementToData.right().value();
267 return StorageOperationStatus.OK;
270 private StorageOperationStatus associateRequirementsToResource(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
271 Map<String, MapListRequirementDataDefinition> calculatedRequirements = topologyTemplate.getCalculatedRequirements();
272 if (calculatedRequirements != null && !calculatedRequirements.isEmpty()) {
273 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex,
274 VertexTypeEnum.CALCULATED_REQUIREMENTS, EdgeLabelEnum.CALCULATED_REQUIREMENTS, calculatedRequirements);
275 if (assosiateElementToData.isRight()) {
276 return assosiateElementToData.right().value();
279 Map<String, MapListRequirementDataDefinition> fullfilledRequirements = topologyTemplate.getFullfilledRequirements();
280 if (fullfilledRequirements != null && !fullfilledRequirements.isEmpty()) {
281 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex,
282 VertexTypeEnum.FULLFILLED_REQUIREMENTS, EdgeLabelEnum.FULLFILLED_REQUIREMENTS, fullfilledRequirements);
283 if (assosiateElementToData.isRight()) {
284 return assosiateElementToData.right().value();
287 Map<String, ListRequirementDataDefinition> requirements = topologyTemplate.getRequirements();
288 if (MapUtils.isNotEmpty(requirements)) {
289 Either<GraphVertex, StorageOperationStatus> associateElementToData = associateElementToData(nodeTypeVertex, VertexTypeEnum.REQUIREMENTS,
290 EdgeLabelEnum.REQUIREMENTS, requirements);
291 if (associateElementToData.isRight()) {
292 return associateElementToData.right().value();
295 return StorageOperationStatus.OK;
298 private StorageOperationStatus associateTopologyTemplateArtifactsToComponent(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
299 Map<String, ArtifactDataDefinition> addInformation = topologyTemplate.getServiceApiArtifacts();
300 if (addInformation != null && !addInformation.isEmpty()) {
301 addInformation.values().stream().filter(a -> a.getUniqueId() == null).forEach(a -> {
302 String uniqueId = UniqueIdBuilder
303 .buildPropertyUniqueId(nodeTypeVertex.getUniqueId().toLowerCase(), a.getArtifactLabel().toLowerCase());
304 a.setUniqueId(uniqueId);
306 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex,
307 VertexTypeEnum.SERVICE_API_ARTIFACTS, EdgeLabelEnum.SERVICE_API_ARTIFACTS, addInformation);
308 if (assosiateElementToData.isRight()) {
309 return assosiateElementToData.right().value();
312 Map<String, MapArtifactDataDefinition> instArtifacts = topologyTemplate.getInstDeploymentArtifacts();
313 if (instArtifacts != null && !instArtifacts.isEmpty()) {
314 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex,
315 VertexTypeEnum.INST_DEPLOYMENT_ARTIFACTS, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS, instArtifacts);
316 if (assosiateElementToData.isRight()) {
317 return assosiateElementToData.right().value();
320 Map<String, MapArtifactDataDefinition> instInfoArtifacts = topologyTemplate.getInstanceArtifacts();
321 if (instInfoArtifacts != null && !instInfoArtifacts.isEmpty()) {
322 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex,
323 VertexTypeEnum.INSTANCE_ARTIFACTS, EdgeLabelEnum.INSTANCE_ARTIFACTS, instInfoArtifacts);
324 if (assosiateElementToData.isRight()) {
325 return assosiateElementToData.right().value();
328 Map<String, ListRequirementDataDefinition> requirements = topologyTemplate.getRequirements();
329 if (MapUtils.isNotEmpty(requirements)) {
330 Either<GraphVertex, StorageOperationStatus> associateElementToData = associateElementToData(nodeTypeVertex, VertexTypeEnum.REQUIREMENTS,
331 EdgeLabelEnum.REQUIREMENTS, requirements);
332 if (associateElementToData.isRight()) {
333 return associateElementToData.right().value();
336 return StorageOperationStatus.OK;
339 private StorageOperationStatus addAdditionalInformationToResource(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
340 Map<String, AdditionalInfoParameterDataDefinition> addInformation = topologyTemplate.getAdditionalInformation();
341 if (addInformation != null && !addInformation.isEmpty()) {
342 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex,
343 VertexTypeEnum.ADDITIONAL_INFORMATION, EdgeLabelEnum.ADDITIONAL_INFORMATION, addInformation);
344 if (assosiateElementToData.isRight()) {
345 return assosiateElementToData.right().value();
348 return StorageOperationStatus.OK;
351 public StorageOperationStatus associateInstPropertiesToComponent(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
352 Map<String, MapPropertiesDataDefinition> instProps = topologyTemplate.getInstProperties();
353 return associateInstPropertiesToComponent(nodeTypeVertex, instProps);
356 public StorageOperationStatus associateInstInputsToComponent(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
357 Map<String, MapPropertiesDataDefinition> instProps = topologyTemplate.getInstInputs();
358 return associateInstInputsToComponent(nodeTypeVertex, instProps);
361 public StorageOperationStatus associateInstGroupsToComponent(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
362 Map<String, MapGroupsDataDefinition> instGroups = topologyTemplate.getInstGroups();
363 return associateInstGroupsToComponent(nodeTypeVertex, instGroups);
366 public StorageOperationStatus associateInstPropertiesToComponent(GraphVertex nodeTypeVertex, Map<String, MapPropertiesDataDefinition> instProps) {
367 if (instProps != null && !instProps.isEmpty()) {
368 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex,
369 VertexTypeEnum.INST_PROPERTIES, EdgeLabelEnum.INST_PROPERTIES, instProps);
370 if (assosiateElementToData.isRight()) {
371 return assosiateElementToData.right().value();
374 return StorageOperationStatus.OK;
377 public StorageOperationStatus associateInstInputsToComponent(GraphVertex nodeTypeVertex, Map<String, MapPropertiesDataDefinition> instInputs) {
378 if (instInputs != null && !instInputs.isEmpty()) {
379 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex, VertexTypeEnum.INST_INPUTS,
380 EdgeLabelEnum.INST_INPUTS, instInputs);
381 if (assosiateElementToData.isRight()) {
382 return assosiateElementToData.right().value();
385 return StorageOperationStatus.OK;
388 public StorageOperationStatus associateInstGroupsToComponent(GraphVertex nodeTypeVertex, Map<String, MapGroupsDataDefinition> instGroups) {
389 if (instGroups != null && !instGroups.isEmpty()) {
390 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex, VertexTypeEnum.INST_GROUPS,
391 EdgeLabelEnum.INST_GROUPS, instGroups);
392 if (assosiateElementToData.isRight()) {
393 return assosiateElementToData.right().value();
396 return StorageOperationStatus.OK;
399 public StorageOperationStatus deleteInstInputsToComponent(GraphVertex nodeTypeVertex, Map<String, MapPropertiesDataDefinition> instInputs) {
400 if (instInputs != null && !instInputs.isEmpty()) {
401 instInputs.entrySet().forEach(i -> {
402 List<String> uniqueKeys = new ArrayList<>(i.getValue().getMapToscaDataDefinition().keySet());
403 List<String> pathKeys = new ArrayList<>();
404 pathKeys.add(i.getKey());
405 StorageOperationStatus status = deleteToscaDataDeepElements(nodeTypeVertex, EdgeLabelEnum.INST_INPUTS, VertexTypeEnum.INST_INPUTS,
406 uniqueKeys, pathKeys, JsonPresentationFields.NAME);
407 if (status != StorageOperationStatus.OK) {
412 return StorageOperationStatus.OK;
415 public StorageOperationStatus addInstPropertiesToComponent(GraphVertex nodeTypeVertex, Map<String, MapPropertiesDataDefinition> instInputs) {
416 if (instInputs != null && !instInputs.isEmpty()) {
417 instInputs.entrySet().forEach(i -> {
418 StorageOperationStatus status = addToscaDataDeepElementsBlockToToscaElement(nodeTypeVertex, EdgeLabelEnum.INST_PROPERTIES,
419 VertexTypeEnum.INST_PROPERTIES, i.getValue(), i.getKey());
420 if (status != StorageOperationStatus.OK) {
425 return StorageOperationStatus.OK;
428 public StorageOperationStatus associateInstDeploymentArtifactsToComponent(GraphVertex nodeTypeVertex,
429 Map<String, MapArtifactDataDefinition> instArtifacts) {
430 return associateInstanceArtifactsToComponent(nodeTypeVertex, instArtifacts, VertexTypeEnum.INST_DEPLOYMENT_ARTIFACTS,
431 EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS);
434 public StorageOperationStatus associateInstArtifactsToComponent(GraphVertex nodeTypeVertex,
435 Map<String, MapArtifactDataDefinition> instArtifacts) {
436 return associateInstanceArtifactsToComponent(nodeTypeVertex, instArtifacts, VertexTypeEnum.INSTANCE_ARTIFACTS,
437 EdgeLabelEnum.INSTANCE_ARTIFACTS);
440 private StorageOperationStatus associateInstanceArtifactsToComponent(GraphVertex nodeTypeVertex, Map<String, MapArtifactDataDefinition> instProps,
441 VertexTypeEnum vertexType, EdgeLabelEnum edgeLabel) {
442 if (instProps != null && !instProps.isEmpty()) {
443 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex, vertexType, edgeLabel,
445 if (assosiateElementToData.isRight()) {
446 return assosiateElementToData.right().value();
449 return StorageOperationStatus.OK;
452 public StorageOperationStatus associateOrAddCalcCapReqToComponent(GraphVertex nodeTypeVertex,
453 Map<String, MapListRequirementDataDefinition> calcRequirements,
454 Map<String, MapListCapabilityDataDefinition> calcCapabilty,
455 Map<String, MapCapabilityProperty> calculatedCapabilitiesProperties) {
456 if (!MapUtils.isEmpty(calcRequirements)) {
457 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateOrAddElementToData(nodeTypeVertex,
458 VertexTypeEnum.CALCULATED_REQUIREMENTS, EdgeLabelEnum.CALCULATED_REQUIREMENTS, calcRequirements);
459 if (assosiateElementToData.isRight()) {
460 return assosiateElementToData.right().value();
462 Map<String, MapListRequirementDataDefinition> fullFilled = new HashMap<>();
463 assosiateElementToData = associateOrAddElementToData(nodeTypeVertex, VertexTypeEnum.FULLFILLED_REQUIREMENTS,
464 EdgeLabelEnum.FULLFILLED_REQUIREMENTS, fullFilled);
465 if (assosiateElementToData.isRight()) {
466 return assosiateElementToData.right().value();
469 if (!MapUtils.isEmpty(calcCapabilty)) {
470 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateOrAddElementToData(nodeTypeVertex,
471 VertexTypeEnum.CALCULATED_CAPABILITIES, EdgeLabelEnum.CALCULATED_CAPABILITIES, calcCapabilty);
472 if (assosiateElementToData.isRight()) {
473 return assosiateElementToData.right().value();
475 Map<String, MapListCapabilityDataDefinition> fullFilled = new HashMap<>();
476 assosiateElementToData = associateOrAddElementToData(nodeTypeVertex, VertexTypeEnum.FULLFILLED_CAPABILITIES,
477 EdgeLabelEnum.FULLFILLED_CAPABILITIES, fullFilled);
478 if (assosiateElementToData.isRight()) {
479 return assosiateElementToData.right().value();
482 if (!MapUtils.isEmpty(calculatedCapabilitiesProperties)) {
483 return associateOrAddElementToData(nodeTypeVertex, VertexTypeEnum.CALCULATED_CAP_PROPERTIES, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES,
484 calculatedCapabilitiesProperties).right().on(v -> StorageOperationStatus.OK);
486 return StorageOperationStatus.OK;
489 private <T extends MapDataDefinition> Either<GraphVertex, StorageOperationStatus> associateOrAddElementToData(GraphVertex nodeTypeVertex,
490 VertexTypeEnum vertexTypeEnum,
491 EdgeLabelEnum edgeLabelEnum,
492 Map<String, T> dataMap) {
493 return janusGraphDao.getChildVertex(nodeTypeVertex, edgeLabelEnum, JsonParseFlagEnum.ParseJson)
494 .either(dataVertex -> addElementsToComponent(nodeTypeVertex, dataVertex, vertexTypeEnum, edgeLabelEnum, dataMap),
495 status -> associateElementToDataIfNotFound(status, nodeTypeVertex, vertexTypeEnum, edgeLabelEnum, dataMap));
498 private Either<GraphVertex, StorageOperationStatus> associateElementToDataIfNotFound(JanusGraphOperationStatus status, GraphVertex nodeTypeVertex,
499 VertexTypeEnum vertexTypeEnum, EdgeLabelEnum edgeLabelEnum,
500 Map<String, ? extends ToscaDataDefinition> dataMap) {
501 if (status == JanusGraphOperationStatus.NOT_FOUND) {
502 return associateElementToData(nodeTypeVertex, vertexTypeEnum, edgeLabelEnum, dataMap);
504 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
507 private <T extends MapDataDefinition> Either<GraphVertex, StorageOperationStatus> addElementsToComponent(GraphVertex nodeTypeVertex,
508 GraphVertex dataVertex,
509 VertexTypeEnum vertexTypeEnum,
510 EdgeLabelEnum edgeLabelEnum,
511 Map<String, T> dataMap) {
512 Optional<StorageOperationStatus> error = dataMap.entrySet().stream()
513 .map(e -> addElementToComponent(nodeTypeVertex.getUniqueId(), vertexTypeEnum, edgeLabelEnum, e))
514 .filter(s -> s != StorageOperationStatus.OK).findFirst();
515 if (error.isPresent()) {
516 return Either.right(error.get());
518 return Either.left(dataVertex);
521 private StorageOperationStatus associateInstAttributesToComponent(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
522 Map<String, MapAttributesDataDefinition> instAttr = topologyTemplate.getInstAttributes();
523 return associateInstAttributeToComponent(nodeTypeVertex, instAttr);
526 public StorageOperationStatus associateForwardingPathToComponent(GraphVertex nodeTypeVertex,
527 Map<String, ForwardingPathDataDefinition> forwardingPathMap) {
528 if (forwardingPathMap != null && !forwardingPathMap.isEmpty()) {
529 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex,
530 VertexTypeEnum.FORWARDING_PATH, EdgeLabelEnum.FORWARDING_PATH, forwardingPathMap);
531 if (assosiateElementToData.isRight()) {
532 return assosiateElementToData.right().value();
535 return StorageOperationStatus.OK;
538 public StorageOperationStatus associateInstAttributeToComponent(GraphVertex nodeTypeVertex, Map<String, MapAttributesDataDefinition> instAttr) {
539 if (instAttr != null && !instAttr.isEmpty()) {
540 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex,
541 VertexTypeEnum.INST_ATTRIBUTES, EdgeLabelEnum.INST_ATTRIBUTES, instAttr);
542 if (assosiateElementToData.isRight()) {
543 return assosiateElementToData.right().value();
546 return StorageOperationStatus.OK;
549 public StorageOperationStatus associateGroupsToComponent(GraphVertex nodeTypeVertex, Map<String, GroupDataDefinition> groups) {
550 if (groups != null && !groups.isEmpty()) {
551 groups.values().stream().filter(p -> p.getUniqueId() == null).forEach(p -> {
552 String uid = UniqueIdBuilder.buildGroupingUid(nodeTypeVertex.getUniqueId(), p.getName());
555 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex, VertexTypeEnum.GROUPS,
556 EdgeLabelEnum.GROUPS, groups);
557 if (assosiateElementToData.isRight()) {
558 return assosiateElementToData.right().value();
561 return StorageOperationStatus.OK;
564 private StorageOperationStatus associateGroupsToComponent(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
565 return associateGroupsToComponent(nodeTypeVertex, topologyTemplate.getGroups());
568 public StorageOperationStatus associateInputsToComponent(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
569 Map<String, PropertyDataDefinition> inputs = topologyTemplate.getInputs();
570 return associateInputsToComponent(nodeTypeVertex, inputs, topologyTemplate.getUniqueId());
573 public StorageOperationStatus associateInputsToComponent(GraphVertex nodeTypeVertex, Map<String, PropertyDataDefinition> inputs, String id) {
574 if (inputs != null && !inputs.isEmpty()) {
575 inputs.values().stream().filter(e -> e.getUniqueId() == null)
576 .forEach(e -> e.setUniqueId(UniqueIdBuilder.buildPropertyUniqueId(id, e.getName())));
577 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex, VertexTypeEnum.INPUTS,
578 EdgeLabelEnum.INPUTS, inputs);
579 if (assosiateElementToData.isRight()) {
580 return assosiateElementToData.right().value();
583 return StorageOperationStatus.OK;
586 private GraphVertex fillMetadata(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate, JsonParseFlagEnum flag) {
587 nodeTypeVertex.setLabel(VertexTypeEnum.TOPOLOGY_TEMPLATE);
588 fillCommonMetadata(nodeTypeVertex, topologyTemplate);
589 if (flag == JsonParseFlagEnum.ParseAll || flag == JsonParseFlagEnum.ParseJson) {
590 nodeTypeVertex.setJson(topologyTemplate.getCompositions());
592 nodeTypeVertex.addMetadataProperty(GraphPropertyEnum.CSAR_UUID, topologyTemplate.getMetadataValue(JsonPresentationFields.CSAR_UUID));
593 nodeTypeVertex.addMetadataProperty(GraphPropertyEnum.CSAR_VERSION_UUID,
594 topologyTemplate.getMetadataValue(JsonPresentationFields.CSAR_VERSION_ID));
595 nodeTypeVertex.addMetadataProperty(GraphPropertyEnum.DISTRIBUTION_STATUS,
596 topologyTemplate.getMetadataValue(JsonPresentationFields.DISTRIBUTION_STATUS));
597 return nodeTypeVertex;
600 private StorageOperationStatus assosiateMetadataToCategory(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
601 if (topologyTemplate.getResourceType() == null) {
603 return associateServiceMetadataToCategory(nodeTypeVertex, topologyTemplate);
606 return assosiateResourceMetadataToCategory(nodeTypeVertex, topologyTemplate);
610 private StorageOperationStatus associateServiceMetadataToCategory(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
611 String categoryName = topologyTemplate.getCategories().get(0).getName();
612 Either<GraphVertex, StorageOperationStatus> category = categoryOperation.getCategory(categoryName,
613 VertexTypeEnum.SERVICE_CATEGORY);
614 if (category.isRight()) {
615 log.trace("NO category {} for service {}", categoryName, topologyTemplate.getUniqueId());
616 return StorageOperationStatus.CATEGORY_NOT_FOUND;
618 GraphVertex categoryV = category.left().value();
619 JanusGraphOperationStatus createEdge = janusGraphDao.createEdge(nodeTypeVertex, categoryV, EdgeLabelEnum.CATEGORY, new HashMap<>());
620 if (createEdge != JanusGraphOperationStatus.OK) {
621 log.trace("Failed to associate resource {} to category {} with id {}", topologyTemplate.getUniqueId(), categoryName,
622 categoryV.getUniqueId());
623 return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(createEdge);
625 return StorageOperationStatus.OK;
629 public Either<ToscaElement, StorageOperationStatus> getToscaElement(String uniqueId, ComponentParametersView componentParametersView) {
630 JsonParseFlagEnum parseFlag = componentParametersView.detectParseFlag();
631 Either<GraphVertex, StorageOperationStatus> componentByLabelAndId = getComponentByLabelAndId(uniqueId, ToscaElementTypeEnum.TOPOLOGY_TEMPLATE,
633 if (componentByLabelAndId.isRight()) {
634 return Either.right(componentByLabelAndId.right().value());
636 GraphVertex componentV = componentByLabelAndId.left().value();
637 return getToscaElement(componentV, componentParametersView);
640 // -------------------------------------------------------------
641 public Either<ToscaElement, StorageOperationStatus> getToscaElement(GraphVertex componentV, ComponentParametersView componentParametersView) {
642 TopologyTemplate toscaElement;
643 toscaElement = convertToTopologyTemplate(componentV);
644 JanusGraphOperationStatus status;
645 if (!componentParametersView.isIgnoreUsers()) {
646 status = setCreatorFromGraph(componentV, toscaElement);
647 if (status != JanusGraphOperationStatus.OK) {
648 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
650 status = setLastModifierFromGraph(componentV, toscaElement);
651 if (status != JanusGraphOperationStatus.OK) {
652 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
655 if (!componentParametersView.isIgnoreCategories()) {
656 status = setTopologyTempalteCategoriesFromGraph(componentV, toscaElement);
657 if (status != JanusGraphOperationStatus.OK) {
658 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
661 if (!componentParametersView.isIgnoreArtifacts()) {
662 JanusGraphOperationStatus storageStatus = setAllArtifactsFromGraph(componentV, toscaElement);
663 if (storageStatus != JanusGraphOperationStatus.OK) {
664 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(storageStatus));
667 if (!componentParametersView.isIgnoreComponentInstancesProperties()) {
668 status = setComponentInstancesPropertiesFromGraph(componentV, toscaElement);
669 if (status != JanusGraphOperationStatus.OK) {
670 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
673 if (!componentParametersView.isIgnoreComponentInstancesAttributes()) {
674 status = setComponentInstancesAttributesFromGraph(componentV, toscaElement);
675 if (status != JanusGraphOperationStatus.OK) {
676 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
679 if (!componentParametersView.isIgnoreCapabilities()) {
680 status = setCapabilitiesFromGraph(componentV, toscaElement);
681 if (status != JanusGraphOperationStatus.OK) {
682 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
685 if (!componentParametersView.isIgnoreRequirements()) {
686 status = setRequirementsFromGraph(componentV, toscaElement);
687 if (status != JanusGraphOperationStatus.OK) {
688 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
691 if (!componentParametersView.isIgnoreAllVersions()) {
692 status = setAllVersions(componentV, toscaElement);
693 if (status != JanusGraphOperationStatus.OK) {
694 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
697 if (!componentParametersView.isIgnoreAdditionalInformation()) {
698 status = setAdditionalInformationFromGraph(componentV, toscaElement);
699 if (status != JanusGraphOperationStatus.OK) {
700 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
703 if (!componentParametersView.isIgnoreGroups()) {
704 status = setGroupsFromGraph(componentV, toscaElement);
705 if (status != JanusGraphOperationStatus.OK) {
706 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
709 if (!componentParametersView.isIgnorePolicies()) {
710 status = setPoliciesFromGraph(componentV, toscaElement);
711 if (status != JanusGraphOperationStatus.OK) {
712 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
715 if (!componentParametersView.isIgnoreComponentInstances()) {
716 status = setInstGroupsFromGraph(componentV, toscaElement);
717 //Mark all CIs that has archived origins
718 archiveOperation.setArchivedOriginsFlagInComponentInstances(componentV);
719 if (status != JanusGraphOperationStatus.OK) {
720 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
723 if (!componentParametersView.isIgnoreInputs()) {
724 status = setInputsFromGraph(componentV, toscaElement);
725 if (status != JanusGraphOperationStatus.OK) {
726 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
729 if (!componentParametersView.isIgnoreOutputs()) {
730 final JanusGraphOperationStatus storageStatus = setOutputsFromGraph(componentV, toscaElement);
731 if (storageStatus != JanusGraphOperationStatus.OK) {
732 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(storageStatus));
735 if (!componentParametersView.isIgnoreProperties()) {
736 status = setPropertiesFromGraph(componentV, toscaElement);
737 if (status != JanusGraphOperationStatus.OK) {
738 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
741 if (!componentParametersView.isIgnoreComponentInstancesInputs()) {
742 status = setComponentInstancesInputsFromGraph(componentV, toscaElement);
743 if (status != JanusGraphOperationStatus.OK) {
744 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
747 if (!componentParametersView.isIgnoreCapabiltyProperties()) {
748 status = setComponentInstancesCapPropertiesFromGraph(componentV, toscaElement);
749 if (status != JanusGraphOperationStatus.OK) {
750 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
753 if (!componentParametersView.isIgnoreServicePath()) {
754 status = setForwardingGraphPropertiesFromGraph(componentV, toscaElement);
755 if (status != JanusGraphOperationStatus.OK) {
756 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
759 if (!componentParametersView.isIgnoreNodeFilter()) {
760 status = setNodeFilterComponentFromGraph(componentV, toscaElement);
761 if (status != JanusGraphOperationStatus.OK) {
762 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
765 if (!componentParametersView.isIgnoreSubstitutionFilter()) {
766 status = setSubstitutionFilterComponentFromGraph(componentV, toscaElement);
767 if (status != JanusGraphOperationStatus.OK) {
768 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
771 if (!componentParametersView.isIgnoreInterfaces()) {
772 JanusGraphOperationStatus storageStatus = setInterfacesFromGraph(componentV, toscaElement);
773 if (storageStatus != JanusGraphOperationStatus.OK) {
774 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(storageStatus));
777 if (!componentParametersView.isIgnoreInterfaces()) {
778 JanusGraphOperationStatus storageStatus = setInterfcesFromGraph(componentV, toscaElement);
779 if (storageStatus != JanusGraphOperationStatus.OK) {
780 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(storageStatus));
783 if (!componentParametersView.isIgnoreComponentInstancesInterfaces()) {
784 JanusGraphOperationStatus storageStatus = setComponentInstancesInterfacesFromGraph(componentV, toscaElement);
785 if (storageStatus != JanusGraphOperationStatus.OK) {
786 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(storageStatus));
789 if (!componentParametersView.isIgnoreDataType()) {
790 JanusGraphOperationStatus storageStatus = setDataTypesFromGraph(componentV, toscaElement);
791 if (storageStatus != JanusGraphOperationStatus.OK) {
792 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(storageStatus));
795 return Either.left(toscaElement);
798 private JanusGraphOperationStatus setDataTypesFromGraph(GraphVertex componentV, TopologyTemplate toscaElement) {
799 Either<Map<String, DataTypeDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.DATA_TYPES);
800 if (result.isLeft()) {
801 toscaElement.setDataTypes(result.left().value());
803 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
804 return result.right().value();
807 return JanusGraphOperationStatus.OK;
810 private JanusGraphOperationStatus setInterfcesFromGraph(GraphVertex componentV, TopologyTemplate topologyTemplate) {
811 Either<Map<String, InterfaceDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.INTERFACE);
812 if (result.isLeft()) {
813 topologyTemplate.setInterfaces(result.left().value());
815 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
816 return result.right().value();
819 return JanusGraphOperationStatus.OK;
822 private JanusGraphOperationStatus setPoliciesFromGraph(GraphVertex componentV, TopologyTemplate toscaElement) {
823 Either<Map<String, PolicyDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.POLICIES);
824 if (result.isLeft()) {
825 toscaElement.setPolicies(result.left().value());
827 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
828 return result.right().value();
831 return JanusGraphOperationStatus.OK;
834 private JanusGraphOperationStatus setInterfacesFromGraph(GraphVertex componentV, TopologyTemplate topologyTemplate) {
835 Either<Map<String, InterfaceDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.INTERFACE);
836 if (result.isLeft()) {
837 topologyTemplate.setInterfaces(result.left().value());
839 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
840 return result.right().value();
843 return JanusGraphOperationStatus.OK;
846 private JanusGraphOperationStatus setComponentInstancesInterfacesFromGraph(GraphVertex componentV, TopologyTemplate topologyTemplate) {
847 Either<Map<String, MapInterfaceDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV,
848 EdgeLabelEnum.INST_INTERFACES);
849 if (result.isLeft()) {
850 result.left().value().entrySet().forEach(entry -> topologyTemplate.addComponentInstanceInterfaceMap(entry.getKey(), entry.getValue()));
852 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
853 return result.right().value();
856 return JanusGraphOperationStatus.OK;
859 private StorageOperationStatus associateInterfacesToComponent(GraphVertex topologyTemplateVertex, TopologyTemplate topologyTemplate) {
860 Map<String, InterfaceDataDefinition> interfaceMap = topologyTemplate.getInterfaces();
861 if (interfaceMap != null && !interfaceMap.isEmpty()) {
862 Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(topologyTemplateVertex,
863 VertexTypeEnum.INTERFACE, EdgeLabelEnum.INTERFACE, interfaceMap);
864 if (assosiateElementToData.isRight()) {
865 return assosiateElementToData.right().value();
868 return StorageOperationStatus.OK;
871 private JanusGraphOperationStatus setForwardingGraphPropertiesFromGraph(GraphVertex componentV, TopologyTemplate topologyTemplate) {
872 Either<Map<String, ForwardingPathDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV,
873 EdgeLabelEnum.FORWARDING_PATH);
874 if (result.isLeft()) {
875 topologyTemplate.setForwardingPaths(result.left().value());
877 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
878 return result.right().value();
881 return JanusGraphOperationStatus.OK;
884 private JanusGraphOperationStatus setComponentInstancesCapPropertiesFromGraph(GraphVertex componentV, TopologyTemplate topologyTemplate) {
885 Either<Map<String, MapCapabilityProperty>, JanusGraphOperationStatus> result = getDataFromGraph(componentV,
886 EdgeLabelEnum.CALCULATED_CAP_PROPERTIES);
887 if (result.isLeft()) {
888 topologyTemplate.setCalculatedCapabilitiesProperties(result.left().value());
890 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
891 return result.right().value();
894 Either<Map<String, MapPropertiesDataDefinition>, JanusGraphOperationStatus> capPropResult = getDataFromGraph(componentV,
895 EdgeLabelEnum.CAPABILITIES_PROPERTIES);
896 if (capPropResult.isLeft()) {
897 topologyTemplate.setCapabilitiesProperties(capPropResult.left().value());
899 if (capPropResult.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
900 return capPropResult.right().value();
903 return JanusGraphOperationStatus.OK;
906 private JanusGraphOperationStatus setPropertiesFromGraph(GraphVertex componentV, TopologyTemplate toscaElement) {
907 Either<Map<String, PropertyDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.PROPERTIES);
908 if (result.isLeft()) {
909 toscaElement.setProperties(result.left().value());
911 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
912 return result.right().value();
915 return JanusGraphOperationStatus.OK;
918 private JanusGraphOperationStatus setInstGroupsFromGraph(GraphVertex componentV, TopologyTemplate topologyTemplate) {
919 Either<Map<String, MapGroupsDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.INST_GROUPS);
920 if (result.isLeft()) {
921 topologyTemplate.setInstGroups(result.left().value());
923 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
924 return result.right().value();
927 return JanusGraphOperationStatus.OK;
930 private JanusGraphOperationStatus setComponentInstancesPropertiesFromGraph(GraphVertex componentV, TopologyTemplate topologyTemplate) {
931 Either<Map<String, MapPropertiesDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV,
932 EdgeLabelEnum.INST_PROPERTIES);
933 if (result.isLeft()) {
934 topologyTemplate.setInstProperties(result.left().value());
936 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
937 return result.right().value();
940 return JanusGraphOperationStatus.OK;
943 private JanusGraphOperationStatus setComponentInstancesAttributesFromGraph(final GraphVertex componentV,
944 final TopologyTemplate topologyTemplate) {
945 final Either<Map<String, MapAttributesDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV,
946 EdgeLabelEnum.INST_ATTRIBUTES);
947 if (result.isLeft()) {
948 topologyTemplate.setInstAttributes(result.left().value());
949 } else if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
950 return result.right().value();
952 return JanusGraphOperationStatus.OK;
955 private JanusGraphOperationStatus setComponentInstancesInputsFromGraph(GraphVertex componentV, TopologyTemplate topologyTemplate) {
956 Either<Map<String, MapPropertiesDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.INST_INPUTS);
957 if (result.isLeft()) {
958 topologyTemplate.setInstInputs(result.left().value());
960 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
961 return result.right().value();
964 return JanusGraphOperationStatus.OK;
967 private JanusGraphOperationStatus setNodeFilterComponentFromGraph(final GraphVertex componentV, final TopologyTemplate topologyTemplate) {
968 final Either<Map<String, CINodeFilterDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV,
969 EdgeLabelEnum.NODE_FILTER_TEMPLATE);
970 if (result.isLeft()) {
971 topologyTemplate.setNodeFilterComponents(result.left().value());
973 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
974 return result.right().value();
977 return JanusGraphOperationStatus.OK;
980 private JanusGraphOperationStatus setSubstitutionFilterComponentFromGraph(final GraphVertex componentV, final TopologyTemplate topologyTemplate) {
981 final Either<Map<String, SubstitutionFilterDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV,
982 EdgeLabelEnum.SUBSTITUTION_FILTER_TEMPLATE);
983 if (result.isLeft()) {
984 final Map<String, SubstitutionFilterDataDefinition> filters = result.left().value();
985 if (MapUtils.isEmpty(filters)) {
986 return JanusGraphOperationStatus.OK;
988 if(filters.values().size() > 1) {
989 log.error(EcompLoggerErrorCode.DATA_ERROR, TopologyTemplateOperation.class.getName(),
990 (ErrorLogOptionalData) null, "Only a single substitution filter is expected, but got '{}'", filters.values().size());
991 return JanusGraphOperationStatus.GENERAL_ERROR;
993 topologyTemplate.setSubstitutionFilters(new SubstitutionFilterDataDefinition(filters.values().iterator().next()));
995 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
996 return result.right().value();
999 return JanusGraphOperationStatus.OK;
1003 protected <T extends ToscaElement> JanusGraphOperationStatus setRequirementsFromGraph(GraphVertex componentV, T toscaElement) {
1004 Either<Map<String, MapListRequirementDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV,
1005 EdgeLabelEnum.CALCULATED_REQUIREMENTS);
1006 if (result.isLeft()) {
1007 ((TopologyTemplate) toscaElement).setCalculatedRequirements(result.left().value());
1009 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
1010 return result.right().value();
1013 result = getDataFromGraph(componentV, EdgeLabelEnum.FULLFILLED_REQUIREMENTS);
1014 if (result.isLeft()) {
1015 ((TopologyTemplate) toscaElement).setFullfilledRequirements(result.left().value());
1017 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
1018 return result.right().value();
1021 Either<Map<String, ListRequirementDataDefinition>, JanusGraphOperationStatus> requirementResult = getDataFromGraph(componentV,
1022 EdgeLabelEnum.REQUIREMENTS);
1023 if (requirementResult.isLeft()) {
1024 toscaElement.setRequirements(requirementResult.left().value());
1026 if (requirementResult.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
1027 return requirementResult.right().value();
1030 return JanusGraphOperationStatus.OK;
1033 protected <T extends ToscaElement> JanusGraphOperationStatus setCapabilitiesFromGraph(GraphVertex componentV, T toscaElement) {
1034 Either<Map<String, MapListCapabilityDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV,
1035 EdgeLabelEnum.CALCULATED_CAPABILITIES);
1036 if (result.isLeft()) {
1037 ((TopologyTemplate) toscaElement).setCalculatedCapabilities(result.left().value());
1039 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
1040 return result.right().value();
1043 result = getDataFromGraph(componentV, EdgeLabelEnum.FULLFILLED_CAPABILITIES);
1044 if (result.isLeft()) {
1045 ((TopologyTemplate) toscaElement).setFullfilledCapabilities(result.left().value());
1047 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
1048 return result.right().value();
1051 Either<Map<String, ListCapabilityDataDefinition>, JanusGraphOperationStatus> capabilitiesResult = getDataFromGraph(componentV,
1052 EdgeLabelEnum.CAPABILITIES);
1053 if (capabilitiesResult.isLeft()) {
1054 toscaElement.setCapabilities(capabilitiesResult.left().value());
1056 if (capabilitiesResult.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
1057 return capabilitiesResult.right().value();
1060 return JanusGraphOperationStatus.OK;
1063 private JanusGraphOperationStatus setAllArtifactsFromGraph(GraphVertex componentV, TopologyTemplate toscaElement) {
1064 JanusGraphOperationStatus storageStatus = setArtifactsFromGraph(componentV, toscaElement);
1065 if (storageStatus != JanusGraphOperationStatus.OK) {
1066 return storageStatus;
1068 Either<Map<String, ArtifactDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV,
1069 EdgeLabelEnum.SERVICE_API_ARTIFACTS);
1070 if (result.isLeft()) {
1071 toscaElement.setServiceApiArtifacts(result.left().value());
1073 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
1074 return result.right().value();
1077 Either<Map<String, MapArtifactDataDefinition>, JanusGraphOperationStatus> resultInstArt = getDataFromGraph(componentV,
1078 EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS);
1079 if (resultInstArt.isLeft()) {
1080 toscaElement.setInstDeploymentArtifacts(resultInstArt.left().value());
1082 if (resultInstArt.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
1083 return resultInstArt.right().value();
1086 Either<Map<String, MapArtifactDataDefinition>, JanusGraphOperationStatus> instanceArt = getDataFromGraph(componentV,
1087 EdgeLabelEnum.INSTANCE_ARTIFACTS);
1088 if (instanceArt.isLeft()) {
1089 toscaElement.setInstanceArtifacts(instanceArt.left().value());
1091 if (instanceArt.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
1092 return instanceArt.right().value();
1095 return JanusGraphOperationStatus.OK;
1098 private JanusGraphOperationStatus setInputsFromGraph(GraphVertex componentV, TopologyTemplate toscaElement) {
1099 Either<Map<String, PropertyDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.INPUTS);
1100 if (result.isLeft()) {
1101 toscaElement.setInputs(result.left().value());
1103 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
1104 return result.right().value();
1107 Either<Map<String, ListCapabilityDataDefinition>, JanusGraphOperationStatus> capabilitiesResult = getDataFromGraph(componentV,
1108 EdgeLabelEnum.CAPABILITIES);
1109 if (capabilitiesResult.isLeft()) {
1110 toscaElement.setCapabilities(capabilitiesResult.left().value());
1112 if (capabilitiesResult.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
1113 return capabilitiesResult.right().value();
1116 return JanusGraphOperationStatus.OK;
1119 private JanusGraphOperationStatus setOutputsFromGraph(final GraphVertex componentV, final TopologyTemplate toscaElement) {
1120 final Either<Map<String, AttributeDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.OUTPUTS);
1121 if (result.isLeft()) {
1122 toscaElement.setOutputs(result.left().value());
1124 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
1125 return result.right().value();
1128 return JanusGraphOperationStatus.OK;
1131 private JanusGraphOperationStatus setGroupsFromGraph(GraphVertex componentV, TopologyTemplate toscaElement) {
1132 Either<Map<String, GroupDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.GROUPS);
1133 if (result.isLeft()) {
1134 toscaElement.setGroups(result.left().value());
1136 if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
1137 return result.right().value();
1140 return JanusGraphOperationStatus.OK;
1143 private JanusGraphOperationStatus setTopologyTempalteCategoriesFromGraph(GraphVertex componentV, ToscaElement toscaElement) {
1144 List<CategoryDefinition> categories = new ArrayList<>();
1145 switch (componentV.getType()) {
1147 return setResourceCategoryFromGraph(componentV, toscaElement);
1149 return setServiceCategoryFromGraph(componentV, toscaElement, categories);
1151 log.debug("Not supported component type {} ", componentV.getType());
1154 return JanusGraphOperationStatus.OK;
1157 private JanusGraphOperationStatus setServiceCategoryFromGraph(GraphVertex componentV, ToscaElement toscaElement,
1158 List<CategoryDefinition> categories) {
1159 Either<GraphVertex, JanusGraphOperationStatus> childVertex = janusGraphDao
1160 .getChildVertex(componentV, EdgeLabelEnum.CATEGORY, JsonParseFlagEnum.NoParse);
1161 if (childVertex.isRight()) {
1162 log.debug("failed to fetch {} for tosca element with id {}, error {}", EdgeLabelEnum.CATEGORY, componentV.getUniqueId(),
1163 childVertex.right().value());
1164 return childVertex.right().value();
1166 GraphVertex categoryV = childVertex.left().value();
1167 Map<GraphPropertyEnum, Object> metadataProperties = categoryV.getMetadataProperties();
1168 CategoryDefinition category = new CategoryDefinition();
1169 category.setUniqueId(categoryV.getUniqueId());
1170 category.setNormalizedName((String) metadataProperties.get(GraphPropertyEnum.NORMALIZED_NAME));
1171 category.setName((String) metadataProperties.get(GraphPropertyEnum.NAME));
1172 final Boolean useServiceSubstitutionForNestedServices = (Boolean) metadataProperties
1173 .get(GraphPropertyEnum.USE_SUBSTITUTION_FOR_NESTED_SERVICES);
1174 category.setUseServiceSubstitutionForNestedServices(
1175 useServiceSubstitutionForNestedServices == null ? false : useServiceSubstitutionForNestedServices);
1176 Type listTypeCat = new TypeToken<List<String>>() {
1178 List<String> iconsfromJsonCat = getGson().fromJson((String) metadataProperties.get(GraphPropertyEnum.ICONS.getProperty()), listTypeCat);
1179 category.setIcons(iconsfromJsonCat);
1180 category.setModels((getGson().fromJson((String) metadataProperties.get(GraphPropertyEnum.MODEL.getProperty()), listTypeCat)));
1181 final Type metadataKeysTypeCat = new TypeToken<List<MetadataKeyDataDefinition>>() {
1183 final List<MetadataKeyDataDefinition> metadataKeysfromJsonCat = getGson()
1184 .fromJson((String) metadataProperties.get(GraphPropertyEnum.METADATA_KEYS), metadataKeysTypeCat);
1185 category.setMetadataKeys(metadataKeysfromJsonCat);
1186 categories.add(category);
1187 toscaElement.setCategories(categories);
1188 return JanusGraphOperationStatus.OK;
1191 @SuppressWarnings("unchecked")
1192 private TopologyTemplate convertToTopologyTemplate(GraphVertex componentV) {
1193 TopologyTemplate topologyTemplate = super.convertToComponent(componentV);
1194 Map<String, CompositionDataDefinition> json = (Map<String, CompositionDataDefinition>) componentV.getJson();
1195 topologyTemplate.setCompositions(json);
1196 return topologyTemplate;
1200 public Either<ToscaElement, StorageOperationStatus> deleteToscaElement(GraphVertex toscaElementVertex) {
1201 Either<ToscaElement, StorageOperationStatus> nodeType = getToscaElement(toscaElementVertex, new ComponentParametersView());
1202 if (nodeType.isRight()) {
1203 log.debug("Failed to fetch tosca element {} error {}", toscaElementVertex.getUniqueId(), nodeType.right().value());
1206 JanusGraphOperationStatus status = disassociateAndDeleteCommonElements(toscaElementVertex);
1207 if (status != JanusGraphOperationStatus.OK) {
1208 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1210 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INST_ATTRIBUTES);
1211 if (status != JanusGraphOperationStatus.OK) {
1212 log.debug("Failed to disassociate instances attributes for {} error {}", toscaElementVertex.getUniqueId(), status);
1213 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1215 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INST_PROPERTIES);
1216 if (status != JanusGraphOperationStatus.OK) {
1217 log.debug("Failed to disassociate instances properties for {} error {}", toscaElementVertex.getUniqueId(), status);
1218 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1220 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INST_INPUTS);
1221 if (status != JanusGraphOperationStatus.OK) {
1222 log.debug("Failed to disassociate instances inputs for {} error {}", toscaElementVertex.getUniqueId(), status);
1223 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1225 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.GROUPS);
1226 if (status != JanusGraphOperationStatus.OK) {
1227 log.debug("Failed to disassociate groups for {} error {}", toscaElementVertex.getUniqueId(), status);
1228 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1230 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.POLICIES);
1231 if (status != JanusGraphOperationStatus.OK) {
1232 log.debug("Failed to disassociate policies for {} error {}", toscaElementVertex.getUniqueId(), status);
1233 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1235 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INST_GROUPS);
1236 if (status != JanusGraphOperationStatus.OK) {
1237 log.debug("Failed to disassociate instance groups for {} error {}", toscaElementVertex.getUniqueId(), status);
1238 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1240 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INPUTS);
1241 if (status != JanusGraphOperationStatus.OK) {
1242 log.debug("Failed to disassociate inputs for {} error {}", toscaElementVertex.getUniqueId(), status);
1243 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1245 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INST_INPUTS);
1246 if (status != JanusGraphOperationStatus.OK) {
1247 log.debug("Failed to disassociate instance inputs for {} error {}", toscaElementVertex.getUniqueId(), status);
1248 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1250 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.CAPABILITIES_PROPERTIES);
1251 if (status != JanusGraphOperationStatus.OK) {
1252 log.debug("Failed to disassociate capabilities properties for {} error {}", toscaElementVertex.getUniqueId(), status);
1253 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1255 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.CALCULATED_CAPABILITIES);
1256 if (status != JanusGraphOperationStatus.OK) {
1257 log.debug("Failed to disassociate calculated capabiliites for {} error {}", toscaElementVertex.getUniqueId(), status);
1258 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1260 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.FULLFILLED_CAPABILITIES);
1261 if (status != JanusGraphOperationStatus.OK) {
1262 log.debug("Failed to disassociate fullfilled capabilities for {} error {}", toscaElementVertex.getUniqueId(), status);
1263 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1265 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES);
1266 if (status != JanusGraphOperationStatus.OK) {
1267 log.debug("Failed to disassociate calculated capabiliites properties for {} error {}", toscaElementVertex.getUniqueId(), status);
1268 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1270 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.CALCULATED_REQUIREMENTS);
1271 if (status != JanusGraphOperationStatus.OK) {
1272 log.debug("Failed to disassociate calculated requirements for {} error {}", toscaElementVertex.getUniqueId(), status);
1273 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1275 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.FULLFILLED_REQUIREMENTS);
1276 if (status != JanusGraphOperationStatus.OK) {
1277 log.debug("Failed to disassociate full filled requirements for {} error {}", toscaElementVertex.getUniqueId(), status);
1278 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1280 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS);
1281 if (status != JanusGraphOperationStatus.OK) {
1282 log.debug("Failed to disassociate instance artifacts for {} error {}", toscaElementVertex.getUniqueId(), status);
1283 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1285 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.SERVICE_API_ARTIFACTS);
1286 if (status != JanusGraphOperationStatus.OK) {
1287 log.debug("Failed to disassociate service api artifacts for {} error {}", toscaElementVertex.getUniqueId(), status);
1288 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1290 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.FORWARDING_PATH);
1291 if (status != JanusGraphOperationStatus.OK) {
1292 log.debug("Failed to disassociate service api artifacts for {} error {}", toscaElementVertex.getUniqueId(), status);
1293 Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1295 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INTERFACE);
1296 if (status != JanusGraphOperationStatus.OK) {
1297 log.debug("Failed to disassociate interfaces for {} error {}", toscaElementVertex.getUniqueId(), status);
1298 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1300 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INSTANCE_ARTIFACTS);
1301 if (status != JanusGraphOperationStatus.OK) {
1302 log.debug("Failed to disassociate instance artifact for {} error {}", toscaElementVertex.getUniqueId(), status);
1303 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1305 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.REQUIREMENTS);
1306 if (status != JanusGraphOperationStatus.OK) {
1307 log.debug("Failed to disassociate requirements for {} error {}", toscaElementVertex.getUniqueId(), status);
1308 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1310 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.CAPABILITIES);
1311 if (status != JanusGraphOperationStatus.OK) {
1312 log.debug("Failed to disassociate capabilities for {} error {}", toscaElementVertex.getUniqueId(), status);
1313 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1315 status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INST_INTERFACES);
1316 if (status != JanusGraphOperationStatus.OK) {
1317 log.debug("Failed to disassociate instances interfaces for {} error {}", toscaElementVertex.getUniqueId(), status);
1318 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1320 toscaElementVertex.getVertex().remove();
1321 log.trace("Tosca element vertex for {} was removed", toscaElementVertex.getUniqueId());
1325 @SuppressWarnings("unchecked")
1327 public Either<TopologyTemplate, StorageOperationStatus> createToscaElement(ToscaElement toscaElement) {
1328 return createTopologyTemplate((TopologyTemplate) toscaElement);
1332 protected <T extends ToscaElement> JanusGraphOperationStatus setCategoriesFromGraph(GraphVertex vertexComponent, T toscaElement) {
1333 return setTopologyTempalteCategoriesFromGraph(vertexComponent, toscaElement);
1337 protected <T extends ToscaElement> StorageOperationStatus validateCategories(T toscaElementToUpdate, GraphVertex elementV) {
1338 // Product isn't supported now!!
1340 // TODO add for Product
1341 if (toscaElementToUpdate.getComponentType() == ComponentTypeEnum.SERVICE) {
1342 return validateServiceCategory(toscaElementToUpdate, elementV);
1345 return validateResourceCategory(toscaElementToUpdate, elementV);
1350 protected <T extends ToscaElement> StorageOperationStatus updateDerived(T toscaElementToUpdate, GraphVertex updateElementV) {
1351 // not relevant now for topology template
1352 return StorageOperationStatus.OK;
1356 public <T extends ToscaElement> void fillToscaElementVertexData(GraphVertex elementV, T toscaElementToUpdate, JsonParseFlagEnum flag) {
1357 fillMetadata(elementV, (TopologyTemplate) toscaElementToUpdate, flag);
1360 private <T extends ToscaElement> StorageOperationStatus validateServiceCategory(T toscaElementToUpdate, GraphVertex elementV) {
1361 StorageOperationStatus status = StorageOperationStatus.OK;
1362 List<CategoryDefinition> newCategoryList = toscaElementToUpdate.getCategories();
1363 CategoryDefinition newCategory = newCategoryList.get(0);
1364 Either<GraphVertex, JanusGraphOperationStatus> childVertex = janusGraphDao
1365 .getChildVertex(elementV, EdgeLabelEnum.CATEGORY, JsonParseFlagEnum.NoParse);
1366 if (childVertex.isRight()) {
1367 log.debug("failed to fetch {} for tosca element with id {}, error {}", EdgeLabelEnum.CATEGORY, elementV.getUniqueId(),
1368 childVertex.right().value());
1369 return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(childVertex.right().value());
1371 GraphVertex categoryV = childVertex.left().value();
1372 Map<GraphPropertyEnum, Object> metadataProperties = categoryV.getMetadataProperties();
1373 String categoryNameCurrent = (String) metadataProperties.get(GraphPropertyEnum.NAME);
1374 String newCategoryName = newCategory.getName();
1375 if (newCategoryName != null && !newCategoryName.equals(categoryNameCurrent)) {
1376 // the category was changed
1377 Either<GraphVertex, StorageOperationStatus> getCategoryVertex = categoryOperation
1378 .getCategory(newCategoryName, VertexTypeEnum.SERVICE_CATEGORY);
1379 if (getCategoryVertex.isRight()) {
1380 return getCategoryVertex.right().value();
1382 GraphVertex newCategoryV = getCategoryVertex.left().value();
1383 status = moveCategoryEdge(elementV, newCategoryV);
1384 log.debug("Going to update the category of the resource from {} to {}. status is {}", categoryNameCurrent, newCategory, status);
1389 public Either<GraphVertex, StorageOperationStatus> updateDistributionStatus(String uniqueId, User user,
1390 DistributionStatusEnum distributionStatus) {
1391 Either<GraphVertex, StorageOperationStatus> result = null;
1392 String userId = user.getUserId();
1393 Either<GraphVertex, JanusGraphOperationStatus> getRes = findUserVertex(userId);
1394 GraphVertex userVertex = null;
1395 GraphVertex serviceVertex = null;
1396 if (getRes.isRight()) {
1397 JanusGraphOperationStatus status = getRes.right().value();
1398 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Cannot find user {} in the graph. status is {}", userId, status);
1399 result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1401 if (result == null) {
1402 userVertex = getRes.left().value();
1403 getRes = janusGraphDao.getVertexById(uniqueId, JsonParseFlagEnum.ParseMetadata);
1404 if (getRes.isRight()) {
1405 JanusGraphOperationStatus status = getRes.right().value();
1406 log.debug("Cannot find service {} in the graph. status is {}", uniqueId, status);
1407 result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1410 if (result == null) {
1411 serviceVertex = getRes.left().value();
1412 Iterator<Edge> edgeIterator = serviceVertex.getVertex().edges(Direction.IN, EdgeLabelEnum.LAST_DISTRIBUTION_STATE_MODIFIER.name());
1413 if (edgeIterator.hasNext()) {
1414 log.debug("Remove existing edge from user to component {}. Edge type is {}", userId, uniqueId,
1415 EdgeLabelEnum.LAST_DISTRIBUTION_STATE_MODIFIER);
1416 edgeIterator.next().remove();
1419 if (result == null) {
1420 JanusGraphOperationStatus status = janusGraphDao
1421 .createEdge(userVertex, serviceVertex, EdgeLabelEnum.LAST_DISTRIBUTION_STATE_MODIFIER, null);
1422 if (status != JanusGraphOperationStatus.OK) {
1423 log.debug("Failed to associate user {} to component {}. Edge type is {}", userId, uniqueId,
1424 EdgeLabelEnum.LAST_DISTRIBUTION_STATE_MODIFIER);
1425 result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
1428 if (result == null) {
1429 serviceVertex.addMetadataProperty(GraphPropertyEnum.DISTRIBUTION_STATUS, distributionStatus.name());
1430 long lastUpdateDate = System.currentTimeMillis();
1431 serviceVertex.setJsonMetadataField(JsonPresentationFields.LAST_UPDATE_DATE, lastUpdateDate);
1432 Either<GraphVertex, JanusGraphOperationStatus> updateRes = janusGraphDao.updateVertex(serviceVertex);
1433 if (updateRes.isRight()) {
1434 result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(updateRes.right().value()));
1437 if (result == null) {
1438 result = Either.left(serviceVertex);
1444 * Returns list of ComponentInstanceProperty belonging to component instance capability specified by name, type and ownerId
1446 * @param componentId
1448 * @param capabilityName
1449 * @param capabilityType
1453 public Either<List<ComponentInstanceProperty>, StorageOperationStatus> getComponentInstanceCapabilityProperties(String componentId,
1455 String capabilityName,
1456 String capabilityType,
1458 Either<List<ComponentInstanceProperty>, StorageOperationStatus> result = null;
1459 Map<String, MapCapabilityProperty> mapPropertiesDataDefinition = null;
1460 Either<GraphVertex, StorageOperationStatus> componentByLabelAndId = getComponentByLabelAndId(componentId,
1461 ToscaElementTypeEnum.TOPOLOGY_TEMPLATE, JsonParseFlagEnum.NoParse);
1462 if (componentByLabelAndId.isRight()) {
1463 result = Either.right(componentByLabelAndId.right().value());
1465 if (componentByLabelAndId.isLeft()) {
1466 Either<Map<String, MapCapabilityProperty>, JanusGraphOperationStatus> getDataRes = getDataFromGraph(componentByLabelAndId.left().value(),
1467 EdgeLabelEnum.CALCULATED_CAP_PROPERTIES);
1468 if (getDataRes.isRight()) {
1469 result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getDataRes.right().value()));
1471 mapPropertiesDataDefinition = getDataRes.left().value();
1474 if (isNotEmptyMapOfProperties(instanceId, mapPropertiesDataDefinition)) {
1475 result = Either.left(findComponentInstanceCapabilityProperties(instanceId, capabilityName, capabilityType, ownerId,
1476 mapPropertiesDataDefinition.get(instanceId).getMapToscaDataDefinition()));
1481 public StorageOperationStatus updateComponentInstanceCapabilityProperties(Component containerComponent, String componentInstanceId,
1482 MapCapabilityProperty instanceProperties) {
1483 return updateToscaDataDeepElementsBlockToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.CALCULATED_CAP_PROPERTIES,
1484 instanceProperties, componentInstanceId);
1487 public StorageOperationStatus updateComponentInstanceInterfaces(Component containerComponent, String componentInstanceId,
1488 MapInterfaceDataDefinition instanceInterfaces) {
1489 if (MapUtils.isNotEmpty(instanceInterfaces.getMapToscaDataDefinition())) {
1490 return updateToscaDataDeepElementsBlockToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_INTERFACES, instanceInterfaces,
1491 componentInstanceId);
1493 return StorageOperationStatus.OK;
1496 private boolean isNotEmptyMapOfProperties(String instanceId, Map<String, MapCapabilityProperty> mapPropertiesDataDefinition) {
1497 return MapUtils.isNotEmpty(mapPropertiesDataDefinition) && instanceId != null && mapPropertiesDataDefinition.get(instanceId) != null
1498 && MapUtils.isNotEmpty(mapPropertiesDataDefinition.get(instanceId).getMapToscaDataDefinition());
1501 private List<ComponentInstanceProperty> findComponentInstanceCapabilityProperties(String instanceId, String capabilityName, String capabilityType,
1503 Map<String, MapPropertiesDataDefinition> propertiesMap) {
1504 List<ComponentInstanceProperty> capPropsList = null;
1505 for (Entry<String, MapPropertiesDataDefinition> capProp : propertiesMap.entrySet()) {
1506 if (isBelongingPropertyMap(instanceId, capabilityName, capabilityType, ownerId, capProp)) {
1507 Map<String, PropertyDataDefinition> capMap = capProp.getValue().getMapToscaDataDefinition();
1508 if (capMap != null && !capMap.isEmpty()) {
1509 capPropsList = capMap.values().stream().map(ComponentInstanceProperty::new).collect(Collectors.toList());
1514 if (capPropsList == null) {
1515 capPropsList = new ArrayList<>();
1517 return capPropsList;
1520 private boolean isBelongingPropertyMap(String instanceId, String capabilityName, String capabilityType, String ownerId,
1521 Entry<String, MapPropertiesDataDefinition> capProp) {
1522 if (capProp != null) {
1523 String[] path = capProp.getKey().split(ModelConverter.CAP_PROP_DELIM);
1524 if (path.length < 4) {
1525 log.debug("wrong key format for capabilty, key {}", capProp);
1528 return path[path.length - 2].equals(capabilityType) && path[path.length - 1].equals(capabilityName) && path[1].equals(ownerId) && path[0]
1529 .equals(instanceId);
1534 public StorageOperationStatus addPolicyToToscaElement(GraphVertex componentV, PolicyDefinition policyDefinition, int counter) {
1535 fillPolicyDefinition(componentV, policyDefinition, counter);
1536 return addToscaDataToToscaElement(componentV, EdgeLabelEnum.POLICIES, VertexTypeEnum.POLICIES, policyDefinition,
1537 JsonPresentationFields.UNIQUE_ID);
1540 public StorageOperationStatus addPoliciesToToscaElement(GraphVertex componentV, List<PolicyDefinition> policies) {
1541 return addToscaDataToToscaElement(componentV, EdgeLabelEnum.POLICIES, VertexTypeEnum.POLICIES, policies, JsonPresentationFields.UNIQUE_ID);
1544 public StorageOperationStatus updatePolicyOfToscaElement(GraphVertex componentV, PolicyDefinition policyDefinition) {
1545 return updateToscaDataOfToscaElement(componentV, EdgeLabelEnum.POLICIES, VertexTypeEnum.POLICIES, policyDefinition,
1546 JsonPresentationFields.UNIQUE_ID);
1549 public StorageOperationStatus updatePoliciesOfToscaElement(GraphVertex componentV, List<PolicyDefinition> policiesDefinitions) {
1550 return updateToscaDataOfToscaElement(componentV, EdgeLabelEnum.POLICIES, VertexTypeEnum.POLICIES, policiesDefinitions,
1551 JsonPresentationFields.UNIQUE_ID);
1554 public StorageOperationStatus removePolicyFromToscaElement(GraphVertex componentV, String policyId) {
1555 return deleteToscaDataElement(componentV, EdgeLabelEnum.POLICIES, VertexTypeEnum.POLICIES, policyId, JsonPresentationFields.UNIQUE_ID);
1558 public StorageOperationStatus updateGroupOfToscaElement(GraphVertex componentV, GroupDefinition groupDefinition) {
1559 return updateToscaDataOfToscaElement(componentV, EdgeLabelEnum.GROUPS, VertexTypeEnum.GROUPS, groupDefinition,
1560 JsonPresentationFields.CI_INVARIANT_NAME);
1563 private void fillPolicyDefinition(GraphVertex componentV, PolicyDefinition policyDefinition, int counter) {
1564 String policyName = buildSubComponentName((String) componentV.getJsonMetadataField(JsonPresentationFields.NAME),
1565 policyDefinition.getPolicyTypeName(), counter);
1566 policyDefinition.setName(policyName);
1567 policyDefinition.setInvariantName(policyName);
1568 policyDefinition.setComponentName((String) componentV.getJsonMetadataField(JsonPresentationFields.NAME));
1569 policyDefinition.setUniqueId(UniqueIdBuilder.buildPolicyUniqueId(componentV.getUniqueId(), policyName));
1570 policyDefinition.setInvariantUUID(UniqueIdBuilder.buildInvariantUUID());
1571 policyDefinition.setPolicyUUID(UniqueIdBuilder.generateUUID());
1574 void revertNamesOfCalculatedCapabilitiesRequirements(String componentId, TopologyTemplate toscaElement) {
1575 if (MapUtils.isNotEmpty(toscaElement.getComponentInstances()) || MapUtils.isNotEmpty(toscaElement.getGroups())) {
1576 GraphVertex toscaElementV = janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse).left().on(this::throwStorageException);
1577 if (MapUtils.isNotEmpty(toscaElement.getComponentInstances())) {
1578 toscaElement.getComponentInstances().values().forEach(i -> CapabilityRequirementNameResolver
1579 .revertNamesOfCalculatedCapabilitiesRequirements(toscaElement, i.getUniqueId(), this::getOriginToscaElement));
1581 if (MapUtils.isNotEmpty(toscaElement.getGroups())) {
1582 toscaElement.getGroups().values().forEach(g -> CapabilityRequirementNameResolver
1583 .revertNamesOfCalculatedCapabilitiesRequirements(toscaElement, g.getUniqueId(), this::getOriginToscaElement));
1585 topologyTemplateOperation
1586 .updateFullToscaData(toscaElementV, EdgeLabelEnum.CALCULATED_CAPABILITIES, VertexTypeEnum.CALCULATED_CAPABILITIES,
1587 toscaElement.getCalculatedCapabilities());
1588 topologyTemplateOperation
1589 .updateFullToscaData(toscaElementV, EdgeLabelEnum.CALCULATED_REQUIREMENTS, VertexTypeEnum.CALCULATED_REQUIREMENTS,
1590 toscaElement.getCalculatedRequirements());
1591 topologyTemplateOperation
1592 .updateFullToscaData(toscaElementV, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, VertexTypeEnum.CALCULATED_CAP_PROPERTIES,
1593 toscaElement.getCalculatedCapabilitiesProperties());
1597 public void updateNamesOfCalculatedCapabilitiesRequirements(String componentId, TopologyTemplate toscaElement) {
1598 if (MapUtils.isNotEmpty(toscaElement.getComponentInstances()) || MapUtils.isNotEmpty(toscaElement.getGroups())) {
1599 GraphVertex toscaElementV = janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse).left().on(this::throwStorageException);
1600 if (MapUtils.isNotEmpty(toscaElement.getComponentInstances())) {
1601 toscaElement.getComponentInstances().values().forEach(i -> CapabilityRequirementNameResolver
1602 .updateNamesOfCalculatedCapabilitiesRequirements(toscaElement, i.getUniqueId(), i.getNormalizedName(),
1603 this::getOriginToscaElement));
1605 if (MapUtils.isNotEmpty(toscaElement.getGroups())) {
1606 toscaElement.getGroups().values().forEach(g -> CapabilityRequirementNameResolver
1607 .updateNamesOfCalculatedCapabilitiesRequirements(toscaElement, g.getUniqueId(), g.getName(), this::getOriginToscaElement));
1609 topologyTemplateOperation
1610 .updateFullToscaData(toscaElementV, EdgeLabelEnum.CALCULATED_CAPABILITIES, VertexTypeEnum.CALCULATED_CAPABILITIES,
1611 toscaElement.getCalculatedCapabilities());
1612 topologyTemplateOperation
1613 .updateFullToscaData(toscaElementV, EdgeLabelEnum.CALCULATED_REQUIREMENTS, VertexTypeEnum.CALCULATED_REQUIREMENTS,
1614 toscaElement.getCalculatedRequirements());
1615 topologyTemplateOperation
1616 .updateFullToscaData(toscaElementV, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, VertexTypeEnum.CALCULATED_CAP_PROPERTIES,
1617 toscaElement.getCalculatedCapabilitiesProperties());
1621 private ToscaElement getOriginToscaElement(ComponentInstanceDataDefinition instance) {
1622 log.debug("#getOriginToscaElement - origin name: {}", instance.getComponentName());
1623 ToscaElementTypeEnum elementType = detectToscaType(instance.getOriginType());
1624 Either<ToscaElement, StorageOperationStatus> getOriginRes;
1625 if (elementType == ToscaElementTypeEnum.TOPOLOGY_TEMPLATE) {
1626 getOriginRes = this.getToscaElement(CapabilityRequirementNameResolver.getActualComponentUid(instance), getFilter());
1628 getOriginRes = nodeTypeOperation.getToscaElement(CapabilityRequirementNameResolver.getActualComponentUid(instance), getFilter());
1630 if (getOriginRes.isRight()) {
1631 log.debug("Failed to get an origin component with uniqueId {}", CapabilityRequirementNameResolver.getActualComponentUid(instance));
1632 throw new StorageException(getOriginRes.right().value());
1634 return getOriginRes.left().value();
1637 private ToscaElementTypeEnum detectToscaType(OriginTypeEnum originType) {
1638 log.debug("#detectToscaType - type: {}", originType);
1639 if (originType == OriginTypeEnum.VFC || originType == OriginTypeEnum.CP || originType == OriginTypeEnum.VL
1640 || originType == OriginTypeEnum.Configuration || originType == OriginTypeEnum.VFCMT) {
1641 return ToscaElementTypeEnum.NODE_TYPE;
1643 return ToscaElementTypeEnum.TOPOLOGY_TEMPLATE;
1647 private ComponentParametersView getFilter() {
1648 ComponentParametersView filter = new ComponentParametersView();
1649 filter.setIgnoreCapabilities(false);
1650 filter.setIgnoreCapabiltyProperties(false);
1651 filter.setIgnoreRequirements(false);
1655 public void updateCapReqPropertiesOwnerId(String componentId, TopologyTemplate toscaElement) {
1656 GraphVertex toscaElementV = janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse).left().on(this::throwStorageException);
1657 updateCapOwnerId(toscaElement, componentId);
1658 updateReqOwnerId(toscaElement, componentId);
1659 updatePropertiesOwnerId(toscaElement, componentId);
1660 topologyTemplateOperation
1661 .updateFullToscaData(toscaElementV, EdgeLabelEnum.CAPABILITIES, VertexTypeEnum.CAPABILITIES, toscaElement.getCapabilities());
1662 topologyTemplateOperation
1663 .updateFullToscaData(toscaElementV, EdgeLabelEnum.REQUIREMENTS, VertexTypeEnum.REQUIREMENTS, toscaElement.getRequirements());
1664 topologyTemplateOperation
1665 .updateFullToscaData(toscaElementV, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, toscaElement.getProperties());
1668 private void updateCapOwnerId(ToscaElement toscaElement, String ownerId) {
1669 if (MapUtils.isNotEmpty(toscaElement.getCapabilities())) {
1670 toscaElement.getCapabilities().values().stream().flatMap(listCapDef -> listCapDef.getListToscaDataDefinition().stream())
1671 .forEach(capabilityDefinition -> capabilityDefinition.setOwnerId(ownerId));
1675 private void updateReqOwnerId(ToscaElement toscaElement, String ownerId) {
1676 if (MapUtils.isNotEmpty(toscaElement.getRequirements())) {
1677 toscaElement.getRequirements().values().stream().flatMap(listReqDef -> listReqDef.getListToscaDataDefinition().stream())
1678 .forEach(requirementDefinition -> requirementDefinition.setOwnerId(ownerId));
1682 private void updatePropertiesOwnerId(ToscaElement toscaElement, String ownerId) {
1683 Map<String, PropertyDataDefinition> properties = toscaElement.getProperties();
1684 if (MapUtils.isNotEmpty(properties)) {
1685 properties.values().forEach(propertyDataDefinition -> propertyDataDefinition.setParentUniqueId(ownerId));