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 fj.data.Either;
23 import java.util.ArrayList;
24 import java.util.Collections;
25 import java.util.HashMap;
26 import java.util.Iterator;
27 import java.util.List;
29 import java.util.UUID;
30 import java.util.stream.Collectors;
31 import org.apache.commons.collections.CollectionUtils;
32 import org.apache.commons.collections.MapUtils;
33 import org.apache.commons.lang3.StringUtils;
34 import org.apache.commons.lang3.tuple.ImmutablePair;
35 import org.apache.commons.lang3.tuple.Pair;
36 import org.apache.tinkerpop.gremlin.structure.Direction;
37 import org.apache.tinkerpop.gremlin.structure.Edge;
38 import org.apache.tinkerpop.gremlin.structure.Vertex;
39 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
40 import org.janusgraph.core.JanusGraphVertex;
41 import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
42 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
43 import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
44 import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
45 import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
46 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
47 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
48 import org.openecomp.sdc.be.dao.jsongraph.utils.IdBuilderUtils;
49 import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
50 import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
51 import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
52 import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
53 import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
54 import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
55 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
56 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
57 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
58 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
59 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
60 import org.openecomp.sdc.be.model.User;
61 import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElementTypeEnum;
62 import org.openecomp.sdc.be.model.operations.StorageException;
63 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
64 import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
65 import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
66 import org.openecomp.sdc.common.jsongraph.util.CommonUtility;
67 import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum;
68 import org.openecomp.sdc.common.log.wrappers.Logger;
69 import org.openecomp.sdc.common.util.ValidationUtils;
70 import org.springframework.beans.factory.annotation.Autowired;
73 * public abstract class BaseOperation provides base operation functionality and common fields
75 public abstract class BaseOperation {
77 public static final String VF_MODULE = "org.openecomp.groups.VfModule";
78 private static final String FAILED_REMOVE_TOSCA_DATA_VERTEX_OF_THE_TOSCA_ELEMENT_BY_LABEL_STATUS_IS = "Failed remove tosca data vertex of the tosca element {} by label {}. Status is {}. ";
79 private static final String FAILED_TO_GET_CHILD_VERTEX_OF_THE_TOSCA_ELEMENT_BY_LABEL_STATUS_IS = "Failed to get child vertex of the tosca element {} by label {}. Status is {}. ";
80 private static final String FAILED_TO_GET_TOSCA_ELEMENT_UPON_ADDING_THE_PROPERTIES_STATUS_IS = "Failed to get tosca element {} upon adding the properties. Status is {}. ";
81 private static final Logger log = Logger.getLogger(BaseOperation.class.getName());
83 protected JanusGraphDao janusGraphDao;
85 protected NodeTypeOperation nodeTypeOperation;
87 protected TopologyTemplateOperation topologyTemplateOperation;
89 protected HealingPipelineDao healingPipelineDao;
91 public void setJanusGraphDao(JanusGraphDao janusGraphDao) {
92 this.janusGraphDao = janusGraphDao;
96 * Returns reference to appropriate toscaTemplateOperation
98 * @param componentType
101 public ToscaElementOperation getToscaElementOperation(ComponentTypeEnum componentType) {
102 ToscaElementOperation operation;
103 switch (componentType) {
106 operation = topologyTemplateOperation;
109 operation = nodeTypeOperation;
116 * Returns reference to appropriate toscaTemplateOperation
118 * @param toscaElementType
121 public ToscaElementOperation getToscaElementOperation(ToscaElementTypeEnum toscaElementType) {
122 ToscaElementOperation operation;
123 switch (toscaElementType) {
124 case TOPOLOGY_TEMPLATE:
125 operation = topologyTemplateOperation;
128 operation = nodeTypeOperation;
138 * Returns reference to appropriate toscaTemplateOperation
140 * @param toscaElementType
143 public ToscaElementOperation getToscaElementOperation(VertexTypeEnum toscaElementType) {
144 ToscaElementOperation operation;
145 switch (toscaElementType) {
146 case TOPOLOGY_TEMPLATE:
147 operation = topologyTemplateOperation;
150 operation = nodeTypeOperation;
160 * Converts received vertex to User object
165 public User convertToUser(Vertex ownerV) {
166 User owner = new User();
167 owner.setUserId((String) ownerV.property(GraphPropertyEnum.USERID.getProperty()).value());
168 VertexProperty<Object> property = ownerV.property(GraphPropertyEnum.ROLE.getProperty());
169 if (property != null && property.isPresent()) {
170 owner.setRole((String) property.value());
172 property = ownerV.property(GraphPropertyEnum.FIRST_NAME.getProperty());
173 if (property != null && property.isPresent()) {
174 owner.setFirstName((String) ownerV.property(GraphPropertyEnum.FIRST_NAME.getProperty()).value());
176 property = ownerV.property(GraphPropertyEnum.LAST_NAME.getProperty());
177 if (property != null && property.isPresent()) {
178 owner.setLastName((String) ownerV.property(GraphPropertyEnum.LAST_NAME.getProperty()).value());
180 property = ownerV.property(GraphPropertyEnum.EMAIL.getProperty());
181 if (property != null && property.isPresent()) {
182 owner.setEmail((String) ownerV.property(GraphPropertyEnum.EMAIL.getProperty()).value());
184 property = ownerV.property(GraphPropertyEnum.LAST_LOGIN_TIME.getProperty());
185 if (property != null && property.isPresent()) {
186 owner.setLastLoginTime((Long) ownerV.property(GraphPropertyEnum.LAST_LOGIN_TIME.getProperty()).value());
191 protected <T extends ToscaDataDefinition> Either<Map<String, T>, JanusGraphOperationStatus> getDataFromGraph(GraphVertex componentV,
192 EdgeLabelEnum edgelabel) {
193 Either<Pair<GraphVertex, Map<String, T>>, JanusGraphOperationStatus> dataVertex = getDataAndVertexFromGraph(componentV, edgelabel);
194 if (dataVertex.isRight()) {
195 return Either.right(dataVertex.right().value());
197 Map<String, T> properties = dataVertex.left().value().getRight();
198 return Either.left(properties);
201 @SuppressWarnings("unchecked")
202 protected <T extends ToscaDataDefinition> Either<Pair<GraphVertex, Map<String, T>>, JanusGraphOperationStatus> getDataAndVertexFromGraph(
203 GraphVertex componentV, EdgeLabelEnum edgelabel) {
204 Either<GraphVertex, JanusGraphOperationStatus> dataVertex = getDataVertex(componentV, edgelabel);
205 if (dataVertex.isRight()) {
206 return Either.right(dataVertex.right().value());
208 GraphVertex propV = dataVertex.left().value();
209 Map<String, T> properties = (Map<String, T>) propV.getJson();
210 Pair<GraphVertex, Map<String, T>> pair = new ImmutablePair<>(propV, properties);
211 return Either.left(pair);
214 protected <T extends ToscaDataDefinition> Either<GraphVertex, JanusGraphOperationStatus> getDataVertex(GraphVertex componentV,
215 EdgeLabelEnum edgelabel) {
216 Either<GraphVertex, JanusGraphOperationStatus> childVertex = janusGraphDao.getChildVertex(componentV, edgelabel, JsonParseFlagEnum.ParseJson);
217 if (childVertex.isRight()) {
218 if (childVertex.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
219 log.debug("failed to fetch {} for tosca element with id {}, error {}", edgelabel, componentV.getUniqueId(),
220 childVertex.right().value());
222 return Either.right(childVertex.right().value());
224 GraphVertex propV = childVertex.left().value();
225 return Either.left(propV);
229 * Returns tosca data belonging to tosca element specified by uid according received label
231 * @param toscaElementUid
235 public <T extends ToscaDataDefinition> Either<Map<String, T>, JanusGraphOperationStatus> getDataFromGraph(String toscaElementUid,
236 EdgeLabelEnum edgelabel) {
237 Either<Map<String, T>, JanusGraphOperationStatus> result = null;
238 Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
239 getToscaElementRes = janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse);
240 if (getToscaElementRes.isRight()) {
241 JanusGraphOperationStatus status = getToscaElementRes.right().value();
242 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to get tosca element {} upon getting tosca data from graph. Status is {}. ",
243 toscaElementUid, status);
244 result = Either.right(status);
246 if (result == null) {
247 result = getDataFromGraph(getToscaElementRes.left().value(), edgelabel);
252 public Either<GraphVertex, JanusGraphOperationStatus> findUserVertex(String userId) {
253 return janusGraphDao.getVertexByPropertyAndLabel(GraphPropertyEnum.USERID, userId, VertexTypeEnum.USER, JsonParseFlagEnum.NoParse);
261 public Either<Boolean, StorageOperationStatus> isCloneNeeded(String elemementId, EdgeLabelEnum label) {
262 Either<GraphVertex, JanusGraphOperationStatus> vertexById = janusGraphDao.getVertexById(elemementId);
263 if (vertexById.isRight()) {
264 log.debug("Failed to fetch element by id {} error {}", elemementId, vertexById.right().value());
265 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(vertexById.right().value()));
267 GraphVertex toscaElementVertex = vertexById.left().value();
268 Either<GraphVertex, JanusGraphOperationStatus> childVertex = janusGraphDao
269 .getChildVertex(toscaElementVertex, label, JsonParseFlagEnum.NoParse);
270 if (childVertex.isRight()) {
271 if (childVertex.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
272 log.debug("failed to fetch {} for tosca element with id {}, error {}", label, toscaElementVertex.getUniqueId(),
273 childVertex.right().value());
274 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(childVertex.right().value()));
276 return Either.left(Boolean.FALSE);
278 GraphVertex dataVertex = childVertex.left().value();
279 Iterator<Edge> edges = dataVertex.getVertex().edges(Direction.IN, label.name());
281 while (edges.hasNext()) {
286 return Either.left(Boolean.TRUE);
288 return Either.left(Boolean.FALSE);
292 protected Either<GraphVertex, JanusGraphOperationStatus> updateOrCopyOnUpdate(GraphVertex dataVertex, GraphVertex toscaElementVertex,
293 EdgeLabelEnum label) {
294 Iterator<Edge> edges = dataVertex.getVertex().edges(Direction.IN, label.name());
296 Edge edgeToRemove = null;
297 while (edges.hasNext()) {
298 Edge edge = edges.next();
300 Vertex outVertex = edge.outVertex();
301 String outId = (String) janusGraphDao.getProperty((JanusGraphVertex) outVertex, GraphPropertyEnum.UNIQUE_ID.getProperty());
302 if (toscaElementVertex.getUniqueId().equals(outId)) {
306 if (edgeToRemove == null) {
307 log.debug("No edges {} from vertex {} to vertex {}", label, toscaElementVertex.getUniqueId(), dataVertex.getUniqueId());
308 return Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
313 log.debug("No edges {} to vertex {}", label, dataVertex.getUniqueId());
314 return Either.right(JanusGraphOperationStatus.GENERAL_ERROR);
317 log.trace("Only one edge {} to vertex {}. Update vertex", label, dataVertex.getUniqueId());
318 return janusGraphDao.updateVertex(dataVertex);
321 log.trace("More than one edge {} to vertex {}. Need to clone vertex", label, dataVertex.getUniqueId());
322 return cloneDataVertex(dataVertex, toscaElementVertex, label, edgeToRemove);
326 private Either<GraphVertex, JanusGraphOperationStatus> cloneDataVertex(GraphVertex dataVertex, GraphVertex toscaElementVertex,
327 EdgeLabelEnum label, Edge edgeToRemove) {
328 GraphVertex newDataVertex = new GraphVertex(dataVertex.getLabel());
329 String id = IdBuilderUtils.generateChildId(toscaElementVertex.getUniqueId(), dataVertex.getLabel());
330 newDataVertex.cloneData(dataVertex);
331 newDataVertex.setUniqueId(id);
332 Either<GraphVertex, JanusGraphOperationStatus> createVertex = janusGraphDao.createVertex(newDataVertex);
333 if (createVertex.isRight()) {
334 log.debug("Failed to clone data vertex for {} error {}", dataVertex.getUniqueId(), createVertex.right().value());
337 newDataVertex = createVertex.left().value();
338 JanusGraphOperationStatus createEdge = janusGraphDao
339 .createEdge(toscaElementVertex, newDataVertex, label, janusGraphDao.getEdgeProperties(edgeToRemove));
340 if (createEdge != JanusGraphOperationStatus.OK) {
341 log.debug("Failed to associate vertex {} to vertex {}, error {}", toscaElementVertex.getUniqueId(), newDataVertex.getUniqueId(),
343 return Either.right(createEdge);
345 edgeToRemove.remove();
346 return Either.left(newDataVertex);
349 public Either<GraphVertex, StorageOperationStatus> associateElementToData(GraphVertex element, VertexTypeEnum vertexLabel,
350 EdgeLabelEnum edgeLabel,
351 Map<String, ? extends ToscaDataDefinition> data) {
352 GraphVertex dataV = new GraphVertex(vertexLabel);
353 String id = IdBuilderUtils.generateChildId(element.getUniqueId(), vertexLabel);
354 dataV.setUniqueId(id);
356 Either<GraphVertex, JanusGraphOperationStatus> createVertex = janusGraphDao.createVertex(dataV);
357 if (createVertex.isRight()) {
358 log.trace("Failed to create {} vertex for type node {}", vertexLabel, element.getUniqueId());
359 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(createVertex.right().value()));
361 dataV = createVertex.left().value();
362 JanusGraphOperationStatus createEdgeStatus = janusGraphDao.createEdge(element.getVertex(), dataV.getVertex(), edgeLabel, new HashMap<>());
363 if (createEdgeStatus != JanusGraphOperationStatus.OK) {
364 log.trace("Failed to create {} vertex for type node {}", vertexLabel, element.getUniqueId());
365 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(createEdgeStatus));
367 return Either.left(dataV);
371 * Adds tosca data element to tosca element according received labels
373 * @param toscaElement
380 public <T extends ToscaDataDefinition> StorageOperationStatus addToscaDataToToscaElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel,
381 VertexTypeEnum vertexLabel, T toscaData,
382 JsonPresentationFields mapKeyField) {
383 List<T> toscaDataList = new ArrayList<>();
384 toscaDataList.add(toscaData);
385 return addToscaDataToToscaElement(toscaElement, edgeLabel, vertexLabel, toscaDataList, mapKeyField);
389 * Adds list of tosca data deep elements to tosca element according received labels
391 * @param toscaElement
394 * @param toscaDataList
399 public <T extends ToscaDataDefinition> StorageOperationStatus addToscaDataDeepElementsToToscaElement(GraphVertex toscaElement,
400 EdgeLabelEnum edgeLabel,
401 VertexTypeEnum vertexLabel,
402 List<T> toscaDataList, List<String> pathKeys,
403 JsonPresentationFields mapKeyField) {
404 return updateOrAddToscaDataDeepElement(toscaElement, edgeLabel, vertexLabel, toscaDataList, pathKeys, mapKeyField, false);
408 * Updates list of tosca data elements of tosca element according received labels
410 * @param toscaElement
417 public <T extends ToscaDataDefinition> StorageOperationStatus updateToscaDataOfToscaElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel,
418 VertexTypeEnum vertexLabel, T toscaData,
419 JsonPresentationFields mapKeyField) {
420 List<T> toscaDataList = new ArrayList<>();
421 toscaDataList.add(toscaData);
422 return updateToscaDataOfToscaElement(toscaElement, edgeLabel, vertexLabel, toscaDataList, mapKeyField);
426 * Updates tosca data deep element of tosca element according received labels
428 * @param toscaElement
436 public <T extends ToscaDataDefinition> StorageOperationStatus updateToscaDataDeepElementOfToscaElement(GraphVertex toscaElement,
437 EdgeLabelEnum edgeLabel,
438 VertexTypeEnum vertexLabel, T toscaData,
439 List<String> pathKeys,
440 JsonPresentationFields mapKeyField) {
441 List<T> toscaDataList = new ArrayList<>();
442 toscaDataList.add(toscaData);
443 return updateToscaDataDeepElementsOfToscaElement(toscaElement, edgeLabel, vertexLabel, toscaDataList, pathKeys, mapKeyField);
447 * Updates tosca data deep elements of tosca element according received labels
449 * @param toscaElement
452 * @param toscaDataList
457 public <T extends ToscaDataDefinition> StorageOperationStatus updateToscaDataDeepElementsOfToscaElement(GraphVertex toscaElement,
458 EdgeLabelEnum edgeLabel,
459 VertexTypeEnum vertexLabel,
460 List<T> toscaDataList,
461 List<String> pathKeys,
462 JsonPresentationFields mapKeyField) {
463 return updateOrAddToscaDataDeepElement(toscaElement, edgeLabel, vertexLabel, toscaDataList, pathKeys, mapKeyField, true);
467 * Adds tosca data element to tosca element with specified uid according received labels
469 * @param toscaElementUid
476 public <T extends ToscaDataDefinition> StorageOperationStatus addToscaDataToToscaElement(String toscaElementUid, EdgeLabelEnum edgeLabel,
477 VertexTypeEnum vertexLabel, T toscaData,
478 JsonPresentationFields mapKeyField) {
479 List<T> toscaDataList = new ArrayList<>();
480 toscaDataList.add(toscaData);
481 return addToscaDataToToscaElement(toscaElementUid, edgeLabel, vertexLabel, toscaDataList, mapKeyField);
485 * Adds tosca data deep element to tosca element with specified uid according received labels
487 * @param toscaElementUid
495 public <T extends ToscaDataDefinition> StorageOperationStatus addToscaDataDeepElementToToscaElement(String toscaElementUid,
496 EdgeLabelEnum edgeLabel,
497 VertexTypeEnum vertexLabel, T toscaData,
498 List<String> pathKeys,
499 JsonPresentationFields mapKeyField) {
500 List<T> toscaDataList = new ArrayList<>();
501 toscaDataList.add(toscaData);
502 return addToscaDataDeepElementsToToscaElement(toscaElementUid, edgeLabel, vertexLabel, toscaDataList, pathKeys, mapKeyField);
505 public <T extends ToscaDataDefinition> StorageOperationStatus updateToscaDataDeepElementOfToscaElement(String toscaElementUid,
506 EdgeLabelEnum edgeLabel,
507 VertexTypeEnum vertexLabel, T toscaData,
508 List<String> pathKeys,
509 JsonPresentationFields mapKeyField) {
510 List<T> toscaDataList = new ArrayList<>();
511 toscaDataList.add(toscaData);
512 return updateToscaDataDeepElementsOfToscaElement(toscaElementUid, edgeLabel, vertexLabel, toscaDataList, pathKeys, mapKeyField);
515 public <T extends ToscaDataDefinition> StorageOperationStatus updateToscaDataDeepElementsOfToscaElement(String toscaElementUid,
516 EdgeLabelEnum edgeLabel,
517 VertexTypeEnum vertexLabel,
518 List<T> toscaDataList,
519 List<String> pathKeys,
520 JsonPresentationFields mapKeyField) {
521 StorageOperationStatus statusRes = null;
522 Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
523 getToscaElementRes = janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse);
524 if (getToscaElementRes.isRight()) {
525 JanusGraphOperationStatus status = getToscaElementRes.right().value();
527 .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_TOSCA_ELEMENT_UPON_ADDING_THE_PROPERTIES_STATUS_IS, toscaElementUid, status);
528 statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
530 if (statusRes == null && CollectionUtils.isNotEmpty(toscaDataList)) {
531 statusRes = updateToscaDataDeepElementsOfToscaElement(getToscaElementRes.left().value(), edgeLabel, vertexLabel, toscaDataList, pathKeys,
534 if (statusRes == null) {
535 statusRes = StorageOperationStatus.OK;
540 StorageOperationStatus overrideToscaDataOfToscaElement(String toscaElementUid, EdgeLabelEnum edgeLabel,
541 Map<String, ? extends ToscaDataDefinition> toscaData) {
542 return janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse).left()
543 .bind(graphVertex -> overrideToscaElementData(graphVertex, toscaData, edgeLabel))
544 .either(graphVertex -> StorageOperationStatus.OK, DaoStatusConverter::convertJanusGraphStatusToStorageStatus);
547 private Either<GraphVertex, JanusGraphOperationStatus> overrideToscaElementData(GraphVertex toscaElement,
548 Map<String, ? extends ToscaDataDefinition> toscaData,
549 EdgeLabelEnum edgeLabelEnum) {
550 return janusGraphDao.getChildVertex(toscaElement, edgeLabelEnum, JsonParseFlagEnum.ParseJson).left()
551 .bind(dataVertex -> overrideToscaElementData(dataVertex, toscaElement, toscaData, edgeLabelEnum)).right().map(
552 err -> logAndReturn(err, "failed to override tosca data for element {} of type {}. status: {}", toscaElement.getUniqueId(),
553 edgeLabelEnum, err));
556 private Either<GraphVertex, JanusGraphOperationStatus> overrideToscaElementData(GraphVertex dataElement, GraphVertex toscaElement,
557 Map<String, ? extends ToscaDataDefinition> toscaData,
558 EdgeLabelEnum edgeLabelEnum) {
559 dataElement.setJson(toscaData);
560 return updateOrCopyOnUpdate(dataElement, toscaElement, edgeLabelEnum);
564 * Adds list of tosca data deep elements to tosca element with specified uid according received labels
566 * @param toscaElementUid
569 * @param toscaDataList
574 public <T extends ToscaDataDefinition> StorageOperationStatus addToscaDataDeepElementsToToscaElement(String toscaElementUid,
575 EdgeLabelEnum edgeLabel,
576 VertexTypeEnum vertexLabel,
577 List<T> toscaDataList, List<String> pathKeys,
578 JsonPresentationFields mapKeyField) {
579 StorageOperationStatus statusRes = null;
580 Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
581 getToscaElementRes = janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse);
582 if (getToscaElementRes.isRight()) {
583 JanusGraphOperationStatus status = getToscaElementRes.right().value();
585 .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_TOSCA_ELEMENT_UPON_ADDING_THE_PROPERTIES_STATUS_IS, toscaElementUid, status);
586 statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
588 if (statusRes == null && CollectionUtils.isNotEmpty(toscaDataList)) {
589 statusRes = addToscaDataDeepElementsToToscaElement(getToscaElementRes.left().value(), edgeLabel, vertexLabel, toscaDataList, pathKeys,
592 if (statusRes == null) {
593 statusRes = StorageOperationStatus.OK;
598 public <T extends ToscaDataDefinition> StorageOperationStatus deleteToscaDataDeepElementsBlockOfToscaElement(String toscaElementUid,
599 EdgeLabelEnum edgeLabel,
600 VertexTypeEnum vertexLabel,
602 StorageOperationStatus statusRes = null;
603 Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
604 getToscaElementRes = janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse);
605 if (getToscaElementRes.isRight()) {
606 JanusGraphOperationStatus status = getToscaElementRes.right().value();
608 .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_TOSCA_ELEMENT_UPON_ADDING_THE_PROPERTIES_STATUS_IS, toscaElementUid, status);
609 statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
611 if (statusRes == null) {
612 statusRes = deleteToscaDataDeepElementsBlockToToscaElement(getToscaElementRes.left().value(), edgeLabel, vertexLabel, key);
614 if (statusRes == null) {
615 statusRes = StorageOperationStatus.OK;
620 public <T extends ToscaDataDefinition> StorageOperationStatus deleteToscaDataDeepElementsBlockToToscaElement(GraphVertex toscaElement,
621 EdgeLabelEnum edgeLabel,
622 VertexTypeEnum vertexLabel,
624 StorageOperationStatus result = null;
625 GraphVertex toscaDataVertex = null;
626 Either<GraphVertex, JanusGraphOperationStatus> toscaDataVertexRes = janusGraphDao
627 .getChildVertex(toscaElement, edgeLabel, JsonParseFlagEnum.ParseJson);
628 if (toscaDataVertexRes.isRight()) {
629 JanusGraphOperationStatus status = toscaDataVertexRes.right().value();
630 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_CHILD_VERTEX_OF_THE_TOSCA_ELEMENT_BY_LABEL_STATUS_IS,
631 toscaElement.getUniqueId(), edgeLabel, status);
632 result = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(toscaDataVertexRes.right().value());
634 if (result == null) {
635 toscaDataVertex = toscaDataVertexRes.left().value();
636 result = deleteDeepElementsBlock(toscaDataVertex, key);
638 if (result == null) {
639 Either<GraphVertex, JanusGraphOperationStatus> updateOrCopyRes = updateOrCopyOnUpdate(toscaDataVertex, toscaElement, edgeLabel);
640 if (updateOrCopyRes.isRight()) {
641 JanusGraphOperationStatus status = updateOrCopyRes.right().value();
643 .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to delete tosca data block {} from the tosca element {}. Status is {}. ",
644 edgeLabel, toscaElement.getUniqueId(), status);
645 result = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
648 if (result == null) {
649 result = StorageOperationStatus.OK;
654 @SuppressWarnings("rawtypes")
655 public <T extends ToscaDataDefinition> StorageOperationStatus addToscaDataDeepElementsBlockToToscaElement(String toscaElementUid,
656 EdgeLabelEnum edgeLabel,
657 VertexTypeEnum vertexLabel,
658 MapDataDefinition toscaDataMap,
660 StorageOperationStatus statusRes = null;
661 Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
662 getToscaElementRes = janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse);
663 if (getToscaElementRes.isRight()) {
664 JanusGraphOperationStatus status = getToscaElementRes.right().value();
666 .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_TOSCA_ELEMENT_UPON_ADDING_THE_PROPERTIES_STATUS_IS, toscaElementUid, status);
667 statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
669 if (statusRes == null && toscaDataMap != null) {
670 statusRes = addToscaDataDeepElementsBlockToToscaElement(getToscaElementRes.left().value(), edgeLabel, vertexLabel, toscaDataMap, key);
672 if (statusRes == null) {
673 statusRes = StorageOperationStatus.OK;
678 @SuppressWarnings("rawtypes")
679 public <T extends ToscaDataDefinition> StorageOperationStatus addToscaDataDeepElementsBlockToToscaElement(GraphVertex toscaElement,
680 EdgeLabelEnum edgeLabel,
681 VertexTypeEnum vertexLabel,
682 MapDataDefinition toscaDataMap,
684 StorageOperationStatus result = null;
685 GraphVertex toscaDataVertex = null;
686 Either<GraphVertex, JanusGraphOperationStatus> toscaDataVertexRes = janusGraphDao
687 .getChildVertex(toscaElement, edgeLabel, JsonParseFlagEnum.ParseJson);
688 if (toscaDataVertexRes.isRight() && toscaDataVertexRes.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
689 JanusGraphOperationStatus status = toscaDataVertexRes.right().value();
690 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_CHILD_VERTEX_OF_THE_TOSCA_ELEMENT_BY_LABEL_STATUS_IS,
691 toscaElement.getUniqueId(), edgeLabel, status);
692 result = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(toscaDataVertexRes.right().value());
694 if (result == null && toscaDataVertexRes.isLeft()) {
695 toscaDataVertex = toscaDataVertexRes.left().value();
696 result = addDeepElementsBlock(toscaDataVertex, toscaDataMap, key);
698 if (result == null) {
699 if (toscaDataVertex != null) {
700 Either<GraphVertex, JanusGraphOperationStatus> updateOrCopyRes = updateOrCopyOnUpdate(toscaDataVertex, toscaElement, edgeLabel);
701 if (updateOrCopyRes.isRight()) {
702 JanusGraphOperationStatus status = updateOrCopyRes.right().value();
704 .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add tosca data {} to the tosca element {}. Status is {}. ", edgeLabel,
705 toscaElement.getUniqueId(), status);
706 result = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
709 Map<String, MapDataDefinition> data = new HashMap<>();
710 data.put(key, toscaDataMap);
711 Either<GraphVertex, StorageOperationStatus> createRes = associateElementToData(toscaElement, vertexLabel, edgeLabel, data);
712 if (createRes.isRight()) {
713 StorageOperationStatus status = createRes.right().value();
714 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to assosiate tosca data {} of the tosca element {}. Status is {}. ",
715 edgeLabel, toscaElement.getUniqueId(), status);
720 if (result == null) {
721 result = StorageOperationStatus.OK;
727 * @param toscaElementId the id of the tosca element data container
728 * @param edgeLabel the edge label of the data type to update
729 * @param toscaDataMap the data to update
730 * @param key the key in the json object where the map object block resides
731 * @return the status of the update operation
733 public <T extends ToscaDataDefinition> StorageOperationStatus updateToscaDataDeepElementsBlockToToscaElement(String toscaElementId,
734 EdgeLabelEnum edgeLabel,
735 MapDataDefinition<T> toscaDataMap,
737 return janusGraphDao.getVertexById(toscaElementId, JsonParseFlagEnum.NoParse)
738 .either(toscaElement -> updateToscaDataDeepElementsBlockToToscaElement(toscaElement, edgeLabel, toscaDataMap, key),
739 DaoStatusConverter::convertJanusGraphStatusToStorageStatus);
742 private <T extends ToscaDataDefinition> StorageOperationStatus updateToscaDataDeepElementsBlockToToscaElement(GraphVertex toscaElement,
743 EdgeLabelEnum edgeLabel,
744 MapDataDefinition<T> toscaDataMap,
746 return janusGraphDao.getChildVertex(toscaElement, edgeLabel, JsonParseFlagEnum.ParseJson).left()
747 .bind(dataVertex -> updateToscaDataDeepElementsBlockToToscaElement(toscaElement, dataVertex, edgeLabel, toscaDataMap, key))
748 .either(updatedVertex -> StorageOperationStatus.OK, DaoStatusConverter::convertJanusGraphStatusToStorageStatus);
751 private <T extends ToscaDataDefinition> Either<GraphVertex, JanusGraphOperationStatus> updateToscaDataDeepElementsBlockToToscaElement(
752 GraphVertex toscaElement, GraphVertex dataElement, EdgeLabelEnum edgeLabel, MapDataDefinition<T> toscaDataMap, String key) {
753 Map<String, T> mapToscaDataDefinition = toscaDataMap.getMapToscaDataDefinition();
754 updateDeepElements(dataElement, mapToscaDataDefinition, Collections.singletonList(key));
755 return updateOrCopyOnUpdate(dataElement, toscaElement, edgeLabel).right().map(
756 err -> logAndReturn(err, "failed while trying to update data vertex from tosca element {}, of type {} . status {}",
757 toscaElement.getUniqueId(), edgeLabel, err));
761 * Updates tosca data element of tosca element by specified uid according received labels
763 * @param toscaElementUid
770 public <T extends ToscaDataDefinition> StorageOperationStatus updateToscaDataOfToscaElement(String toscaElementUid, EdgeLabelEnum edgeLabel,
771 VertexTypeEnum vertexLabel, T toscaData,
772 JsonPresentationFields mapKeyField) {
773 List<T> toscaDataList = new ArrayList<>();
774 toscaDataList.add(toscaData);
775 return updateToscaDataOfToscaElement(toscaElementUid, edgeLabel, vertexLabel, toscaDataList, mapKeyField);
779 * Updates list of tosca data elements belonging to tosca element with specified uid according received labels
781 * @param toscaElementUid
784 * @param toscaDataList
788 public <T extends ToscaDataDefinition> StorageOperationStatus updateToscaDataOfToscaElement(String toscaElementUid, EdgeLabelEnum edgeLabel,
789 VertexTypeEnum vertexLabel, List<T> toscaDataList,
790 JsonPresentationFields mapKeyField) {
791 StorageOperationStatus statusRes = null;
792 Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
793 getToscaElementRes = janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse);
794 if (getToscaElementRes.isRight()) {
795 JanusGraphOperationStatus status = getToscaElementRes.right().value();
797 .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_TOSCA_ELEMENT_UPON_ADDING_THE_PROPERTIES_STATUS_IS, toscaElementUid, status);
798 statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
800 if (statusRes == null && CollectionUtils.isNotEmpty(toscaDataList)) {
801 statusRes = updateToscaDataOfToscaElement(getToscaElementRes.left().value(), edgeLabel, vertexLabel, toscaDataList, mapKeyField);
803 if (statusRes == null) {
804 statusRes = StorageOperationStatus.OK;
810 * Adds list of tosca data elements to tosca element with specified uid according received labels
812 * @param toscaElementUid
815 * @param toscaDataList
819 public <T extends ToscaDataDefinition> StorageOperationStatus addToscaDataToToscaElement(String toscaElementUid, EdgeLabelEnum edgeLabel,
820 VertexTypeEnum vertexLabel, List<T> toscaDataList,
821 JsonPresentationFields mapKeyField) {
822 StorageOperationStatus statusRes = null;
823 Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
824 getToscaElementRes = janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse);
825 if (getToscaElementRes.isRight()) {
826 JanusGraphOperationStatus status = getToscaElementRes.right().value();
828 .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_TOSCA_ELEMENT_UPON_ADDING_THE_PROPERTIES_STATUS_IS, toscaElementUid, status);
829 statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
831 if (statusRes == null && CollectionUtils.isNotEmpty(toscaDataList)) {
832 statusRes = addToscaDataToToscaElement(getToscaElementRes.left().value(), edgeLabel, vertexLabel, toscaDataList, mapKeyField);
834 if (statusRes == null) {
835 statusRes = StorageOperationStatus.OK;
841 * Converts recieved map of tosca data elements to list and adds it to tosca element according received labels
843 * @param toscaElement
846 * @param toscaDataMap
850 public <T extends ToscaDataDefinition> StorageOperationStatus addToscaDataToToscaElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel,
851 VertexTypeEnum vertexLabel, Map<String, T> toscaDataMap,
852 JsonPresentationFields mapKeyField) {
853 return addToscaDataToToscaElement(toscaElement, edgeLabel, vertexLabel, toscaDataMap.values().stream().collect(Collectors.toList()),
858 * Adds list of tosca data elements to tosca element according received labels
860 * @param toscaElement
863 * @param toscaDataList
867 public <T extends ToscaDataDefinition> StorageOperationStatus addToscaDataToToscaElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel,
868 VertexTypeEnum vertexLabel, List<T> toscaDataList,
869 JsonPresentationFields mapKeyField) {
870 return updateOrAddToscaData(toscaElement, edgeLabel, vertexLabel, toscaDataList, mapKeyField, false);
874 * Updates list of tosca data elements belonging to tosca element according received labels
876 * @param toscaElement
879 * @param toscaDataList
883 public <T extends ToscaDataDefinition> StorageOperationStatus updateToscaDataOfToscaElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel,
884 VertexTypeEnum vertexLabel, List<T> toscaDataList,
885 JsonPresentationFields mapKeyField) {
886 return updateOrAddToscaData(toscaElement, edgeLabel, vertexLabel, toscaDataList, mapKeyField, true);
889 public boolean hasEdgeOfType(GraphVertex toscaElement, EdgeLabelEnum edgeLabel) {
890 Either<GraphVertex, JanusGraphOperationStatus> vertex = janusGraphDao.getChildVertex(toscaElement, edgeLabel, JsonParseFlagEnum.ParseJson);
891 return vertex.isLeft();
894 @SuppressWarnings("unchecked")
895 private <T extends ToscaDataDefinition> StorageOperationStatus updateOrAddToscaData(GraphVertex toscaElement, EdgeLabelEnum edgeLabel,
896 VertexTypeEnum vertexLabel, List<T> toscaDataList,
897 JsonPresentationFields mapKeyField, boolean isUpdate) {
898 StorageOperationStatus result = null;
899 GraphVertex toscaDataVertex = null;
900 Map<String, T> existingToscaDataMap = null;
901 Either<Map<String, T>, StorageOperationStatus> validateRes = null;
902 Map<String, T> mergedToscaDataMap;
903 Either<GraphVertex, JanusGraphOperationStatus> toscaDataVertexRes = janusGraphDao
904 .getChildVertex(toscaElement, edgeLabel, JsonParseFlagEnum.ParseJson);
905 if (toscaDataVertexRes.isRight() && toscaDataVertexRes.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
906 JanusGraphOperationStatus status = toscaDataVertexRes.right().value();
907 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_CHILD_VERTEX_OF_THE_TOSCA_ELEMENT_BY_LABEL_STATUS_IS,
908 toscaElement.getUniqueId(), edgeLabel, status);
909 result = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(toscaDataVertexRes.right().value());
911 if (result == null) {
912 if (toscaDataVertexRes.isLeft()) {
913 toscaDataVertex = toscaDataVertexRes.left().value();
914 existingToscaDataMap = (Map<String, T>) toscaDataVertex.getJson();
916 validateRes = validateMergeToscaData(toscaElement, toscaDataList, mapKeyField, existingToscaDataMap, isUpdate);
917 if (validateRes.isRight()) {
918 result = validateRes.right().value();
919 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed validate tosca data upon adding to tosca element {}. Status is {}. ",
920 toscaElement.getUniqueId(), edgeLabel, result);
923 if (result == null) {
924 mergedToscaDataMap = validateRes.left().value();
925 result = handleToscaData(toscaElement, vertexLabel, edgeLabel, toscaDataVertex, mergedToscaDataMap);
927 if (result == null) {
928 result = StorageOperationStatus.OK;
933 <T extends ToscaDataDefinition> StorageOperationStatus updateFullToscaData(GraphVertex toscaElement, EdgeLabelEnum edgeLabel,
934 VertexTypeEnum vertexLabel, Map<String, T> toscaData) {
935 Either<GraphVertex, JanusGraphOperationStatus> toscaDataVertexRes = janusGraphDao
936 .getChildVertex(toscaElement, edgeLabel, JsonParseFlagEnum.ParseJson);
937 if (toscaDataVertexRes.isRight() && toscaDataVertexRes.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
938 JanusGraphOperationStatus status = toscaDataVertexRes.right().value();
939 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_CHILD_VERTEX_OF_THE_TOSCA_ELEMENT_BY_LABEL_STATUS_IS,
940 toscaElement.getUniqueId(), edgeLabel, status);
941 return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(toscaDataVertexRes.right().value());
943 GraphVertex toscaDataVertex = null;
944 if (toscaDataVertexRes.isLeft()) {
945 toscaDataVertex = toscaDataVertexRes.left().value();
947 StorageOperationStatus result = handleToscaData(toscaElement, vertexLabel, edgeLabel, toscaDataVertex, toscaData);
948 return result == null ? StorageOperationStatus.OK : result;
951 @SuppressWarnings({"rawtypes", "unchecked"})
952 private <T, K extends ToscaDataDefinition> StorageOperationStatus updateOrAddToscaDataDeepElement(GraphVertex toscaElement,
953 EdgeLabelEnum edgeLabel,
954 VertexTypeEnum vertexLabel,
955 List<K> toscaDataList, List<String> pathKeys,
956 JsonPresentationFields mapKeyField,
958 StorageOperationStatus result = null;
959 GraphVertex toscaDataVertex = null;
960 Map<String, K> existingDeepElementsMap = null;
961 Either<Map<String, K>, StorageOperationStatus> validateRes = null;
962 Either<GraphVertex, JanusGraphOperationStatus> toscaDataVertexRes = janusGraphDao
963 .getChildVertex(toscaElement, edgeLabel, JsonParseFlagEnum.ParseJson);
964 if (toscaDataVertexRes.isRight() && toscaDataVertexRes.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
965 JanusGraphOperationStatus status = toscaDataVertexRes.right().value();
966 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_CHILD_VERTEX_OF_THE_TOSCA_ELEMENT_BY_LABEL_STATUS_IS,
967 toscaElement.getUniqueId(), edgeLabel, status);
968 result = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(toscaDataVertexRes.right().value());
970 if (result == null) {
971 if (toscaDataVertexRes.isLeft()) {
972 toscaDataVertex = toscaDataVertexRes.left().value();
973 existingDeepElementsMap = getDeepElements(toscaDataVertex, pathKeys);
975 validateRes = validateMergeToscaData(toscaElement, toscaDataList, mapKeyField, existingDeepElementsMap, isUpdate);
976 if (validateRes.isRight()) {
977 result = validateRes.right().value();
978 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed validate tosca data upon adding to tosca element {}. Status is {}. ",
979 toscaElement.getUniqueId(), edgeLabel, result);
982 if (result == null) {
983 updateDeepElements(toscaDataVertex, validateRes.left().value(), pathKeys);
984 Map<String, K> toscaDataToHandle;
985 if (toscaDataVertex == null) {
986 toscaDataToHandle = new HashMap<>();
987 Map<String, K> currMap = toscaDataToHandle;
988 for (int i = 1; i < pathKeys.size() - 1; ++i) {
989 currMap.put(pathKeys.get(i), (K) new MapDataDefinition());
990 currMap = (Map<String, K>) ((MapDataDefinition) currMap).getMapToscaDataDefinition().get(pathKeys.get(i));
992 toscaDataToHandle.put(pathKeys.get(pathKeys.size() - 1), (K) new MapDataDefinition(validateRes.left().value()));
994 toscaDataToHandle = (Map<String, K>) toscaDataVertex.getJson();
996 result = handleToscaData(toscaElement, vertexLabel, edgeLabel, toscaDataVertex, toscaDataToHandle);
998 if (result == null) {
999 result = StorageOperationStatus.OK;
1004 @SuppressWarnings({"rawtypes", "unchecked"})
1005 private <T, K extends ToscaDataDefinition> void updateDeepElements(GraphVertex toscaDataVertex, Map<String, K> mergedDeepElementMap,
1006 List<String> pathKeys) {
1007 if (toscaDataVertex != null && MapUtils.isNotEmpty(mergedDeepElementMap)) {
1008 Map<String, MapDataDefinition> currMap = (Map<String, MapDataDefinition>) toscaDataVertex.getJson();
1009 if (!currMap.containsKey(pathKeys.get(0))) {
1010 currMap.put(pathKeys.get(0), new MapDataDefinition<>());
1012 MapDataDefinition currDeepElement = currMap.get(pathKeys.get(0));
1013 for (int i = 1; i < pathKeys.size(); ++i) {
1014 if (currDeepElement.findByKey(pathKeys.get(i)) == null) {
1015 currDeepElement.put(pathKeys.get(i), new MapDataDefinition<>());
1017 currDeepElement = (MapDataDefinition) currDeepElement.findByKey(pathKeys.get(i));
1019 if (currDeepElement != null) {
1020 for (Map.Entry<String, K> elementEntry : mergedDeepElementMap.entrySet()) {
1021 currDeepElement.put(elementEntry.getKey(), elementEntry.getValue());
1027 @SuppressWarnings({"unchecked", "rawtypes"})
1028 private <T, K extends ToscaDataDefinition> Map<String, K> getDeepElements(GraphVertex toscaDataVertex, List<String> pathKeys) {
1029 Map<String, K> result = null;
1030 Map<String, T> currMap = (Map<String, T>) toscaDataVertex.getJson();
1031 MapDataDefinition currDeepElement = (MapDataDefinition) currMap.get(pathKeys.get(0));
1032 for (int i = 1; i < pathKeys.size(); ++i) {
1033 currDeepElement = (MapDataDefinition) currDeepElement.findByKey(pathKeys.get(i));
1035 if (currDeepElement != null) {
1036 result = (Map<String, K>) currDeepElement.getMapToscaDataDefinition();
1041 @SuppressWarnings("unchecked")
1042 private <T extends ToscaDataDefinition> StorageOperationStatus addDeepElementsBlock(GraphVertex toscaDataVertex, T toscaDataBlock, String key) {
1043 StorageOperationStatus result = null;
1044 Map<String, T> currMap = (Map<String, T>) toscaDataVertex.getJson();
1045 if (currMap.containsKey(key)) {
1046 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
1047 "Failed to add block of deep tosca data elements by label {}." + " The block element with the same key {} already exists. ",
1048 toscaDataVertex.getLabel(), key);
1049 result = StorageOperationStatus.ENTITY_ALREADY_EXISTS;
1051 if (result == null) {
1052 currMap.put(key, toscaDataBlock);
1057 @SuppressWarnings("unchecked")
1058 private <T extends ToscaDataDefinition> StorageOperationStatus deleteDeepElementsBlock(GraphVertex toscaDataVertex, String key) {
1059 StorageOperationStatus result = null;
1060 Map<String, T> currMap = (Map<String, T>) toscaDataVertex.getJson();
1061 if (!currMap.containsKey(key)) {
1062 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
1063 "Failed to delete block of deep tosca data elements by label {}." + " The block element with the same key {} doesn't exist. ",
1064 toscaDataVertex.getLabel(), key);
1065 result = StorageOperationStatus.NOT_FOUND;
1067 if (result == null) {
1068 currMap.remove(key);
1074 * Removes tosca data vertex belonging to tosca element specified by uid according label
1076 * @param toscaElementUid
1078 * @param vertexLabel
1081 public StorageOperationStatus removeToscaData(String toscaElementUid, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel) {
1082 StorageOperationStatus statusRes = StorageOperationStatus.OK;
1083 Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
1084 getToscaElementRes = janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse);
1085 if (getToscaElementRes.isRight()) {
1086 JanusGraphOperationStatus status = getToscaElementRes.right().value();
1088 .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_TOSCA_ELEMENT_UPON_ADDING_THE_PROPERTIES_STATUS_IS, toscaElementUid, status);
1089 statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
1091 if (statusRes == StorageOperationStatus.OK) {
1092 statusRes = removeToscaDataVertex(getToscaElementRes.left().value(), edgeLabel, vertexLabel);
1098 * Removes tosca data vertex belonging to tosca element according label
1100 * @param toscaElement
1102 * @param vertexLabel
1105 public StorageOperationStatus removeToscaDataVertex(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel) {
1106 StorageOperationStatus result = null;
1107 GraphVertex toscaDataVertex = null;
1108 Iterator<Edge> edges = null;
1109 int edgeCounter = 0;
1111 Edge edgeToDelete = null;
1112 Either<GraphVertex, JanusGraphOperationStatus> toscaDataVertexRes = janusGraphDao
1113 .getChildVertex(toscaElement, edgeLabel, JsonParseFlagEnum.ParseJson);
1114 if (toscaDataVertexRes.isRight()) {
1115 JanusGraphOperationStatus status = toscaDataVertexRes.right().value();
1116 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_REMOVE_TOSCA_DATA_VERTEX_OF_THE_TOSCA_ELEMENT_BY_LABEL_STATUS_IS,
1117 toscaElement.getUniqueId(), edgeLabel, status);
1118 result = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(toscaDataVertexRes.right().value());
1120 if (result == null) {
1121 toscaDataVertex = toscaDataVertexRes.left().value();
1122 edges = toscaDataVertex.getVertex().edges(Direction.IN);
1123 if (edges == null || !edges.hasNext()) {
1124 result = StorageOperationStatus.NOT_FOUND;
1125 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_REMOVE_TOSCA_DATA_VERTEX_OF_THE_TOSCA_ELEMENT_BY_LABEL_STATUS_IS,
1126 toscaElement.getUniqueId(), edgeLabel, result);
1129 if (result == null) {
1130 if (edges != null) {
1131 while (edges.hasNext()) {
1133 edge = edges.next();
1134 if (edge.outVertex().id().equals(toscaElement.getVertex().id())) {
1135 edgeToDelete = edge;
1140 if (edgeToDelete == null) {
1141 result = StorageOperationStatus.NOT_FOUND;
1142 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_REMOVE_TOSCA_DATA_VERTEX_OF_THE_TOSCA_ELEMENT_BY_LABEL_STATUS_IS,
1143 toscaElement.getUniqueId(), edgeLabel, result);
1146 if (result == null) {
1147 if (edgeCounter > 1 && edgeToDelete != null) {
1148 edgeToDelete.remove();
1150 toscaDataVertex.getVertex().remove();
1153 if (result == null) {
1154 result = StorageOperationStatus.OK;
1160 * Deletes tosca data elements belonging to tosca element specified by uid according label
1162 * @param toscaElementUid
1167 public StorageOperationStatus deleteToscaDataElements(String toscaElementUid, EdgeLabelEnum edgeLabel, List<String> uniqueKeys) {
1168 StorageOperationStatus statusRes = StorageOperationStatus.OK;
1169 Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
1170 getToscaElementRes = janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse);
1171 if (getToscaElementRes.isRight()) {
1172 JanusGraphOperationStatus status = getToscaElementRes.right().value();
1174 .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_TOSCA_ELEMENT_UPON_ADDING_THE_PROPERTIES_STATUS_IS, toscaElementUid, status);
1175 statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
1177 if (statusRes == StorageOperationStatus.OK) {
1178 statusRes = deleteToscaDataElements(getToscaElementRes.left().value(), edgeLabel, uniqueKeys);
1184 * Deletes tosca data element belonging to tosca element specified by uid according label
1186 * @param toscaElementUid
1188 * @param vertexLabel
1190 * @param mapKeyField
1193 public StorageOperationStatus deleteToscaDataElement(String toscaElementUid, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel,
1194 String uniqueKey, JsonPresentationFields mapKeyField) {
1195 StorageOperationStatus statusRes = StorageOperationStatus.OK;
1196 Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
1197 getToscaElementRes = janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse);
1198 if (getToscaElementRes.isRight()) {
1199 JanusGraphOperationStatus status = getToscaElementRes.right().value();
1201 .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_TOSCA_ELEMENT_UPON_ADDING_THE_PROPERTIES_STATUS_IS, toscaElementUid, status);
1202 statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
1204 if (statusRes == StorageOperationStatus.OK) {
1205 statusRes = deleteToscaDataElement(getToscaElementRes.left().value(), edgeLabel, vertexLabel, uniqueKey, mapKeyField);
1211 * Deletes tosca data deep element belonging to tosca element specified by uid according label
1213 * @param toscaElementUid
1215 * @param vertexLabel
1218 * @param mapKeyField
1221 public StorageOperationStatus deleteToscaDataDeepElement(String toscaElementUid, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel,
1222 String uniqueKey, List<String> pathKeys, JsonPresentationFields mapKeyField) {
1223 StorageOperationStatus statusRes = StorageOperationStatus.OK;
1224 Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
1225 getToscaElementRes = janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse);
1226 if (getToscaElementRes.isRight()) {
1227 JanusGraphOperationStatus status = getToscaElementRes.right().value();
1229 .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_TOSCA_ELEMENT_UPON_ADDING_THE_PROPERTIES_STATUS_IS, toscaElementUid, status);
1230 statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
1232 if (statusRes == StorageOperationStatus.OK) {
1233 statusRes = deleteToscaDataDeepElement(getToscaElementRes.left().value(), edgeLabel, vertexLabel, uniqueKey, pathKeys, mapKeyField);
1239 * Deletes tosca data deep element belonging to tosca element according label
1241 * @param toscaElement
1243 * @param vertexLabel
1246 * @param mapKeyField
1249 public StorageOperationStatus deleteToscaDataDeepElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel,
1250 String uniqueKey, List<String> pathKeys, JsonPresentationFields mapKeyField) {
1251 List<String> uniqueKeys = new ArrayList<>();
1252 uniqueKeys.add(uniqueKey);
1253 return deleteToscaDataDeepElements(toscaElement, edgeLabel, vertexLabel, uniqueKeys, pathKeys, mapKeyField);
1256 public StorageOperationStatus deleteToscaDataDeepElements(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel,
1257 List<String> uniqueKeys, List<String> pathKeys, JsonPresentationFields mapKeyField) {
1258 StorageOperationStatus result = null;
1259 GraphVertex toscaDataVertex;
1260 Map<String, ToscaDataDefinition> existingToscaDataMap = null;
1261 Either<GraphVertex, JanusGraphOperationStatus> toscaDataVertexRes = janusGraphDao
1262 .getChildVertex(toscaElement, edgeLabel, JsonParseFlagEnum.ParseJson);
1263 if (toscaDataVertexRes.isRight()) {
1264 JanusGraphOperationStatus status = toscaDataVertexRes.right().value();
1265 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_CHILD_VERTEX_OF_THE_TOSCA_ELEMENT_BY_LABEL_STATUS_IS,
1266 toscaElement.getUniqueId(), edgeLabel, status);
1267 result = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(toscaDataVertexRes.right().value());
1269 if (result == null) {
1270 toscaDataVertex = toscaDataVertexRes.left().value();
1271 existingToscaDataMap = getDeepElements(toscaDataVertexRes.left().value(), pathKeys);
1272 result = deleteElementsFromDataVertex(toscaElement, edgeLabel, uniqueKeys, toscaDataVertex, existingToscaDataMap);
1274 if (result == null) {
1275 result = StorageOperationStatus.OK;
1280 private StorageOperationStatus deleteElementsFromDataVertex(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, List<String> uniqueKeys,
1281 GraphVertex toscaDataVertex, Map<String, ToscaDataDefinition> existingToscaDataMap) {
1282 StorageOperationStatus result;
1283 for (String uniqueKey : uniqueKeys) {
1284 result = removeKeyFromDataVertex(uniqueKey, existingToscaDataMap);
1285 if (result != StorageOperationStatus.OK) {
1286 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
1287 "Failed to delete tosca data element of the tosca element {} by label {}. Status is {}. ", toscaElement.getUniqueId(), edgeLabel,
1292 result = updateToscaDataElement(toscaElement, edgeLabel, toscaDataVertex);
1297 * Deletes tosca data element belonging to tosca element according label
1299 * @param toscaElement
1301 * @param vertexLabel
1303 * @param mapKeyField
1306 public StorageOperationStatus deleteToscaDataElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel,
1307 String uniqueKey, JsonPresentationFields mapKeyField) {
1308 List<String> uniqueKeys = new ArrayList<>();
1309 uniqueKeys.add(uniqueKey);
1310 return deleteToscaDataElements(toscaElement, edgeLabel, uniqueKeys);
1313 @SuppressWarnings("unchecked")
1315 * Deletes tosca data elements belonging to tosca element according label
1316 * @param toscaElement
1321 public StorageOperationStatus deleteToscaDataElements(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, List<String> uniqueKeys) {
1322 StorageOperationStatus result = null;
1323 GraphVertex toscaDataVertex;
1324 Map<String, ToscaDataDefinition> existingToscaDataMap;
1325 Either<GraphVertex, JanusGraphOperationStatus> toscaDataVertexRes = janusGraphDao
1326 .getChildVertex(toscaElement, edgeLabel, JsonParseFlagEnum.ParseJson);
1327 if (toscaDataVertexRes.isRight()) {
1328 JanusGraphOperationStatus status = toscaDataVertexRes.right().value();
1329 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_CHILD_VERTEX_OF_THE_TOSCA_ELEMENT_BY_LABEL_STATUS_IS,
1330 toscaElement.getUniqueId(), edgeLabel, status);
1331 result = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(toscaDataVertexRes.right().value());
1333 if (result == null) {
1334 toscaDataVertex = toscaDataVertexRes.left().value();
1335 existingToscaDataMap = (Map<String, ToscaDataDefinition>) toscaDataVertex.getJson();
1336 result = deleteElementsFromDataVertex(toscaElement, edgeLabel, uniqueKeys, toscaDataVertex, existingToscaDataMap);
1338 if (result == null) {
1339 result = StorageOperationStatus.OK;
1345 * Adds the map data entry to the graph vertex of the specified type, related with the specified edge to the component specified by ID
1347 * @param componentId The uniqueId of the component
1348 * @param vertexTypeEnum The type of the vertex
1349 * @param edgeLabelEnum The type of the edge
1350 * @param mapDataEntry The map data entry
1351 * @param <T extends MapDataDefinition>
1352 * @return The status of the operation result
1354 public <T extends MapDataDefinition> StorageOperationStatus addElementToComponent(String componentId, VertexTypeEnum vertexTypeEnum,
1355 EdgeLabelEnum edgeLabelEnum,
1356 Map.Entry<String, T> mapDataEntry) {
1357 if (MapUtils.isNotEmpty(mapDataEntry.getValue().getMapToscaDataDefinition())) {
1358 return addToscaDataDeepElementsBlockToToscaElement(componentId, edgeLabelEnum, vertexTypeEnum, mapDataEntry.getValue(),
1359 mapDataEntry.getKey());
1361 return StorageOperationStatus.OK;
1364 private <T extends ToscaDataDefinition> StorageOperationStatus updateToscaDataElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel,
1365 GraphVertex toscaDataVertex) {
1366 StorageOperationStatus result = StorageOperationStatus.OK;
1367 Either<GraphVertex, JanusGraphOperationStatus> updateOrCopyRes = updateOrCopyOnUpdate(toscaDataVertex, toscaElement, edgeLabel);
1368 if (updateOrCopyRes.isRight()) {
1369 result = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(updateOrCopyRes.right().value());
1370 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to update tosca data {} of the tosca element {}. Status is {}. ", edgeLabel,
1371 toscaElement.getUniqueId(), result);
1376 private <T extends ToscaDataDefinition> StorageOperationStatus removeKeyFromDataVertex(String uniqueKey, Map<String, T> existingToscaDataMap) {
1377 if (!existingToscaDataMap.containsKey(uniqueKey)) {
1378 return StorageOperationStatus.NOT_FOUND;
1380 existingToscaDataMap.remove(uniqueKey);
1381 return StorageOperationStatus.OK;
1384 <K extends ToscaDataDefinition> StorageOperationStatus handleToscaData(GraphVertex toscaElement, VertexTypeEnum vertexLabel,
1385 EdgeLabelEnum edgeLabel, GraphVertex toscaDataVertex,
1386 Map<String, K> mergedToscaDataMap) {
1387 StorageOperationStatus result = StorageOperationStatus.OK;
1388 if (toscaDataVertex == null) {
1389 if (MapUtils.isEmpty(mergedToscaDataMap)) {
1390 //If no new data and this vertex type does not exist, return
1393 Either<GraphVertex, StorageOperationStatus> createRes = associateElementToData(toscaElement, vertexLabel, edgeLabel, mergedToscaDataMap);
1394 if (createRes.isRight()) {
1395 StorageOperationStatus status = createRes.right().value();
1397 .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to associate tosca data {} of the tosca element {}. Status is {}. ", edgeLabel,
1398 toscaElement.getUniqueId(), status);
1402 if (MapUtils.isEmpty(mergedToscaDataMap)) {
1403 JanusGraphOperationStatus janusGraphOperationStatus = janusGraphDao.disassociateAndDeleteLast(toscaElement, Direction.OUT, edgeLabel);
1404 return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(janusGraphOperationStatus);
1406 toscaDataVertex.setJson(mergedToscaDataMap);
1407 Either<GraphVertex, JanusGraphOperationStatus> updateOrCopyRes = updateOrCopyOnUpdate(toscaDataVertex, toscaElement, edgeLabel);
1408 if (updateOrCopyRes.isRight()) {
1409 JanusGraphOperationStatus status = updateOrCopyRes.right().value();
1411 .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add tosca data {} to the tosca element {}. Status is {}. ", edgeLabel,
1412 toscaElement.getUniqueId(), status);
1413 result = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
1419 private <T extends ToscaDataDefinition> Either<Map<String, T>, StorageOperationStatus> validateMergeToscaData(GraphVertex toscaElement,
1420 List<T> toscaDataList,
1421 JsonPresentationFields mapKeyField,
1422 Map<String, T> existingToscaDataMap,
1424 Map<String, T> mergedToscaDataMap = new HashMap<>();
1425 StorageOperationStatus status;
1426 Either<Map<String, T>, StorageOperationStatus> result = Either.left(mergedToscaDataMap);
1427 if (MapUtils.isNotEmpty(existingToscaDataMap)) {
1428 mergedToscaDataMap.putAll(existingToscaDataMap);
1430 for (T toscaDataElement : toscaDataList) {
1431 status = handleToscaDataElement(toscaElement, mapKeyField, mergedToscaDataMap, toscaDataElement, isUpdate);
1432 if (status != StorageOperationStatus.OK) {
1433 result = Either.right(status);
1440 private <T extends ToscaDataDefinition> StorageOperationStatus handleToscaDataElement(GraphVertex toscaElement,
1441 JsonPresentationFields mapKeyField,
1442 Map<String, T> mergedToscaDataMap, T toscaDataElement,
1444 StorageOperationStatus status = StorageOperationStatus.OK;
1445 String currKey = (String) toscaDataElement.getToscaPresentationValue(mapKeyField);
1446 if (StringUtils.isEmpty(currKey) && toscaDataElement instanceof ListDataDefinition) {
1447 ToscaDataDefinition toscaDataDefinition = ((ListDataDefinition<? extends ToscaDataDefinition>) toscaDataElement)
1448 .getListToscaDataDefinition().get(0);
1449 if (toscaDataDefinition != null) {
1450 currKey = (String) toscaDataDefinition.getToscaPresentationValue(mapKeyField);
1453 if (StringUtils.isEmpty(currKey)) {
1454 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add tosca data to tosca element {}. The key is empty. ");
1455 status = StorageOperationStatus.BAD_REQUEST;
1456 } else if (!isUpdate && mergedToscaDataMap.containsKey(currKey)) {
1457 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
1458 "Failed to add tosca data to tosca element {}. The element with the same key {} already exists. ", toscaElement.getUniqueId(),
1460 status = StorageOperationStatus.BAD_REQUEST;
1462 mergedToscaDataMap.put(currKey, toscaDataElement);
1466 protected GroupInstanceDataDefinition buildGroupInstanceDataDefinition(GroupDataDefinition group,
1467 ComponentInstanceDataDefinition componentInstance,
1468 Map<String, ArtifactDataDefinition> instDeplArtifMap) {
1469 String componentInstanceName = componentInstance.getName();
1470 Long creationDate = System.currentTimeMillis();
1471 GroupInstanceDataDefinition groupInstance = new GroupInstanceDataDefinition();
1472 String groupUid = group.getUniqueId();
1473 groupInstance.setGroupUid(groupUid);
1474 groupInstance.setType(group.getType());
1475 groupInstance.setCustomizationUUID(generateCustomizationUUID());
1476 groupInstance.setCreationTime(creationDate);
1477 groupInstance.setModificationTime(creationDate);
1478 groupInstance.setName(buildGroupInstanceName(componentInstanceName, group.getName()));
1479 groupInstance.setGroupName(group.getName());
1480 groupInstance.setNormalizedName(ValidationUtils.normalizeComponentInstanceName(groupInstance.getName()));
1482 .setUniqueId(UniqueIdBuilder.buildResourceInstanceUniuqeId(componentInstance.getUniqueId(), groupUid, groupInstance.getNormalizedName()));
1483 groupInstance.setArtifacts(group.getArtifacts());
1484 groupInstance.setArtifactsUuid(group.getArtifactsUuid());
1485 groupInstance.setProperties(group.getProperties());
1486 convertPropertiesToInstanceProperties(groupInstance.getProperties());
1487 groupInstance.setInvariantUUID(group.getInvariantUUID());
1488 groupInstance.setGroupUUID(group.getGroupUUID());
1489 groupInstance.setVersion(group.getVersion());
1490 return groupInstance;
1493 protected String buildGroupInstanceName(String instanceName, String groupName) {
1494 return ValidationUtils.normalizeComponentInstanceName(instanceName) + ".." + groupName;
1497 protected String generateCustomizationUUID() {
1498 return UUID.randomUUID().toString();
1501 protected void convertPropertiesToInstanceProperties(List<PropertyDataDefinition> properties) {
1502 properties.forEach(PropertyDataDefinition::convertPropertyDataToInstancePropertyData);
1505 private JanusGraphOperationStatus logAndReturn(JanusGraphOperationStatus janusGraphOperationStatus, String logMsg, Object... logParams) {
1506 log.debug(logMsg, logParams);
1507 return janusGraphOperationStatus;
1510 protected GraphVertex throwStorageException(JanusGraphOperationStatus status) {
1511 throw new StorageException(status);
1514 public void setHealingPipelineDao(HealingPipelineDao healingPipelineDao) {
1515 this.healingPipelineDao = healingPipelineDao;