diff options
Diffstat (limited to 'catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java')
-rw-r--r-- | catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java new file mode 100644 index 0000000000..2fc5c8fc5d --- /dev/null +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java @@ -0,0 +1,35 @@ +package org.openecomp.sdc.be.dao.impl.heal; + +import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge; +import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; +import org.openecomp.sdc.be.dao.impl.HealingPipelineDao; +import org.openecomp.sdc.be.dao.jsongraph.heal.Heal; +import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersion; +import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder; + +public class HealNodeGraphDao implements HealGraphDao<GraphNode, GraphEdge> { + + private HealingPipelineDao healingPipelineDao; + + + public HealNodeGraphDao(HealingPipelineDao healingPipelineDao) { + this.healingPipelineDao = healingPipelineDao; + } + + @Override + public GraphNode performGraphReadHealing(GraphNode childVertex, GraphEdge graphEdge) { + Integer healingVersionInt = childVertex.getHealingVersion(); + HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt); + healingPipelineDao.getHealersForVertex(graphEdge.getEdgeType().getProperty(), healingVersion).forEach(heal -> healTitanVertex(childVertex, heal)); + childVertex.setHealingVersion(healingPipelineDao.getCurrentHealVersion().getVersion()); + return childVertex; + } + + private GraphNode healTitanVertex(GraphNode childVertex, Heal<GraphNode> heal) { + heal.healData(childVertex); + final HealVersion<Integer> healVersion = heal.fromVersion(); + HealVersion<Integer> newerVersion = HealVersionBuilder.build(healVersion.getVersion() + 1); + childVertex.setHealingVersion(newerVersion.getVersion()); + return childVertex; + } +} |