summaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java')
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java34
1 files changed, 12 insertions, 22 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
index f757b58455..6fb20f92e5 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
@@ -13,14 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.be.dao.impl;
import static java.util.stream.Collectors.joining;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
-import org.janusgraph.core.JanusGraphVertex;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -29,11 +27,12 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
+import org.janusgraph.core.JanusGraphVertex;
import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.impl.heal.HealGraphDao;
-import org.openecomp.sdc.be.dao.impl.heal.HealNodeGraphDao;
import org.openecomp.sdc.be.dao.impl.heal.HealJanusGraphDao;
+import org.openecomp.sdc.be.dao.impl.heal.HealNodeGraphDao;
import org.openecomp.sdc.be.dao.impl.heal.HealVertexGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
@@ -48,14 +47,10 @@ import org.springframework.stereotype.Component;
public class HealingPipelineDao {
private static Logger logger = Logger.getLogger(HealingPipelineDao.class.getName());
-
private HealVersion<Integer> currentHealVersion;
-
@Value("${current.heal.version}")
private Integer healVersion;
-
private ImmutableListMultimap<String, Heal> healingPipeline;
-
private HealGraphDao healNodeGraphDao;
private HealGraphDao healVertexGraphDao;
private HealGraphDao healJanusGraphVertexGraphDao;
@@ -77,7 +72,6 @@ public class HealingPipelineDao {
healJanusGraphVertexGraphDao = new HealJanusGraphDao(this);
}
-
private HealGraphDao supplyHealer(Object graphNode) {
if (graphNode instanceof GraphVertex) {
return healVertexGraphDao;
@@ -88,15 +82,18 @@ public class HealingPipelineDao {
if (graphNode instanceof JanusGraphVertex) {
return healJanusGraphVertexGraphDao;
}
-
return null;
}
-
public ImmutableListMultimap<String, Heal> getHealingPipeline() {
return healingPipeline;
}
+ public void setHealingPipeline(ImmutableListMultimap<String, Heal> healingPipeline) {
+ checkValidation(healingPipeline);
+ this.healingPipeline = healingPipeline;
+ }
+
public boolean shouldHeal(HealVersion<Integer> healerVersion, HealVersion<Integer> vertexVersion) {
Objects.requireNonNull(healerVersion);
Objects.requireNonNull(vertexVersion);
@@ -110,7 +107,6 @@ public class HealingPipelineDao {
this.healVersion = healVersion;
}
-
public ImmutableList<Heal> getHealersForVertex(String edgeLabelEnum, HealVersion<Integer> vertexVersion) {
final ImmutableList<Heal> vertexHeals = getHealingPipeline().get(edgeLabelEnum);
List<Heal> list = new ArrayList<>();
@@ -122,13 +118,6 @@ public class HealingPipelineDao {
return ImmutableList.copyOf(list);
}
-
- public void setHealingPipeline(ImmutableListMultimap<String, Heal> healingPipeline) {
- checkValidation(healingPipeline);
- this.healingPipeline = healingPipeline;
- }
-
-
public void setHealingVersion(final GraphVertex graphVertex) {
graphVertex.addMetadataProperty(GraphPropertyEnum.HEALING_VERSION, currentHealVersion.getVersion());
}
@@ -157,16 +146,17 @@ public class HealingPipelineDao {
/**
* prevent duplicated healing version for same edge label.
*/
- private void checkValidation(ImmutableListMultimap<String, Heal> listMultimap) {
+ private void checkValidation(ImmutableListMultimap<String, Heal> listMultimap) {
listMultimap.keySet().forEach(key -> this.validNoDuplicates(key, listMultimap.get(key)));
}
private void validNoDuplicates(String key, List<Heal> heals) {
Set<Integer> duplicatedVersionSet = new HashSet<>();
- Set<Integer> duplicatedNumbersSet = heals.stream().map(heal -> ((HealVersion<Integer>) heal.fromVersion()).getVersion()).filter(n -> !duplicatedVersionSet.add(n)).collect(Collectors.toSet());
+ Set<Integer> duplicatedNumbersSet = heals.stream().map(heal -> ((HealVersion<Integer>) heal.fromVersion()).getVersion())
+ .filter(n -> !duplicatedVersionSet.add(n)).collect(Collectors.toSet());
if (!duplicatedNumbersSet.isEmpty()) {
- throw new IllegalStateException(String.format("Edge label %s , contains multiple healing with same version %s", key, duplicatedNumbersSet.stream().map(Object::toString).collect(joining(" , ", "[ ", " ]"))));
+ throw new IllegalStateException(String.format("Edge label %s , contains multiple healing with same version %s", key,
+ duplicatedNumbersSet.stream().map(Object::toString).collect(joining(" , ", "[ ", " ]"))));
}
}
-
}