1 package org.openecomp.sdc.be.dao.impl.heal;
3 import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
4 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
5 import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
6 import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
7 import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersion;
8 import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
10 public class HealNodeGraphDao implements HealGraphDao<GraphNode, GraphEdge> {
12 private HealingPipelineDao healingPipelineDao;
15 public HealNodeGraphDao(HealingPipelineDao healingPipelineDao) {
16 this.healingPipelineDao = healingPipelineDao;
20 public GraphNode performGraphReadHealing(GraphNode childVertex, GraphEdge graphEdge) {
21 Integer healingVersionInt = childVertex.getHealingVersion();
22 HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt);
23 healingPipelineDao.getHealersForVertex(graphEdge.getEdgeType().getProperty(), healingVersion).forEach(heal -> healJanusGraphVertex(childVertex, heal));
24 childVertex.setHealingVersion(healingPipelineDao.getCurrentHealVersion().getVersion());
28 private GraphNode healJanusGraphVertex(GraphNode childVertex, Heal<GraphNode> heal) {
29 heal.healData(childVertex);
30 final HealVersion<Integer> healVersion = heal.fromVersion();
31 HealVersion<Integer> newerVersion = HealVersionBuilder.build(healVersion.getVersion() + 1);
32 childVertex.setHealingVersion(newerVersion.getVersion());