blob: 2fc5c8fc5d03f4852764ba68859b7b727f54095b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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;
}
}
|