1 package org.openecomp.sdc.be.dao.impl.heal;
3 import org.janusgraph.core.JanusGraphVertex;
4 import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
5 import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
6 import org.openecomp.sdc.be.dao.jsongraph.heal.HealConstants;
7 import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersion;
8 import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
9 import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
10 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
12 public class HealJanusGraphDao implements HealGraphDao<JanusGraphVertex, GraphEdgeLabels> {
14 private HealingPipelineDao healingPipelineDao;
16 public HealJanusGraphDao(HealingPipelineDao healingPipelineDao) {
17 this.healingPipelineDao = healingPipelineDao;
21 public JanusGraphVertex performGraphReadHealing(JanusGraphVertex childVertex, GraphEdgeLabels graphEdgeLabels) {
22 final Integer healingVersionInt = (Integer) childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty()).orElse(HealConstants.DEFAULT_HEAL_VERSION);
23 HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt);
24 healingPipelineDao.getHealersForVertex(graphEdgeLabels.name(), healingVersion).forEach(heal -> healGraphVertex(childVertex, heal));
25 childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty(), healingPipelineDao.getCurrentHealVersion().getVersion());
30 private JanusGraphVertex healGraphVertex(JanusGraphVertex childVertex, Heal<JanusGraphVertex> heal) {
31 heal.healData(childVertex);
32 final HealVersion<Integer> healVersion = heal.fromVersion();
33 HealVersion newerVersion = HealVersionBuilder.build(healVersion.getVersion() + 1);
34 childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty(), newerVersion);
35 heal.healData(childVertex);