aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/tools/zusammen-tools/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/tools/zusammen-tools/src/main')
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java24
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java2
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java77
3 files changed, 87 insertions, 16 deletions
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java
index 527efa5fc6..7058c57e85 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java
@@ -18,7 +18,8 @@ public class ResetOldVersion {
public static Map<String, List<String>> itemVersionMap = new HashMap<>();
- public static void reset(SessionContext context, String oldVersion) {
+ public static int count =0;
+ public static void reset(SessionContext context, String oldVersion,String emptyOldVersion) {
@@ -30,7 +31,8 @@ public class ResetOldVersion {
VspGeneralLoader.load(context,
itemVersionMap);
- generalElementMap.values().forEach(elementEntity -> updateOldVersionFlag(elementEntity,oldVersion));
+ generalElementMap.values().forEach(elementEntity -> updateOldVersionFlag(elementEntity,
+ oldVersion,"true".equals(emptyOldVersion)));
itemVersionMap.entrySet().forEach(entry->entry.getValue().stream().filter
@@ -38,10 +40,24 @@ public class ResetOldVersion {
+"_"+version)).forEach(version->ElementHandler.update(context,
entry.getKey(),version,generalElementMap.get(context.getUser().getUserName()+"_"+entry.getKey()
+"_"+version))));
+
+ System.out.println("nymber of element updated:"+count);
+
}
- private static void updateOldVersionFlag(ElementEntity elementEntity, String oldVersion) {
- elementEntity.getInfo().addProperty("oldVersion",oldVersion);
+ private static void updateOldVersionFlag(ElementEntity elementEntity, String oldVersion,
+ boolean emptyOldVersion) {
+
+ if(!emptyOldVersion){
+ elementEntity.getInfo().addProperty("oldVersion",oldVersion);
+ count++;
+ }else if(elementEntity.getInfo().getProperty("oldVersion")== null || ""
+ .equals(elementEntity.getInfo().getProperty("oldVersion"))){
+ elementEntity.getInfo().addProperty("oldVersion",oldVersion);
+ count++;
+ }
+
+
}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java
index 926566864f..6f092d2f56 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java
@@ -38,7 +38,7 @@ public class ZusammenMainTool {
switch (COMMANDS.valueOf(command)){
case RESET_OLD_VERSION:
- ResetOldVersion.reset(context,ToolsUtil.getParam("v",args));
+ ResetOldVersion.reset(context,ToolsUtil.getParam("v",args),ToolsUtil.getParam("n",args));
break;
case EXPORT:
ExportDataCommand.exportData(context,ToolsUtil.getParam("i",args));
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java
index 54a3dd9ada..b5d09daf3f 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java
@@ -5,7 +5,6 @@ import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
import org.openecomp.core.zusammen.plugin.dao.impl.CassandraElementRepository;
import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
import java.util.HashMap;
import java.util.List;
@@ -13,28 +12,84 @@ import java.util.Map;
import java.util.Optional;
public class VspGeneralLoader {
+ private static CassandraElementRepository cassandraElementRepository =
+ new CassandraElementRepository();
+
public static Map<String, ElementEntity> load(SessionContext context,
Map<String, List<String>> vspItemVersionsMap) {
Map<String, ElementEntity> elementEntityMap = new HashMap<>();
System.setProperty("cassandra.dox.keystore", "zusammen_dox");
- CassandraElementRepository cassandraElementRepository = new CassandraElementRepository();
+
+ Id entityId;
+ Id itemId;
+ Id versionId;
for (Map.Entry<String, List<String>> entry : vspItemVersionsMap.entrySet()) {
for (String version : entry.getValue()) {
- Optional<ElementEntity> result =
- cassandraElementRepository.get(context, new ElementEntityContext(
- context.getUser().getUserName(),
- new Id(entry.getKey()),
- new Id(version)),
- new ElementEntity(new Id(StructureElement.General.name())));
- if (result.isPresent()) {
- elementEntityMap.put(context.getUser().getUserName() + "_" + entry.getKey()
- + "_" + version, result.get());
+
+ itemId = new Id(entry.getKey());
+ versionId = new Id(version);
+ entityId = getEntityIdByInfoNameValue(context, itemId, versionId, null, "name",
+ "General");
+ if (entityId != null) {
+ Optional<ElementEntity> result =
+ cassandraElementRepository.get(context, new ElementEntityContext(
+ context.getUser().getUserName(),
+ itemId,
+ versionId),
+ new ElementEntity(entityId));
+ if (result.isPresent()) {
+ elementEntityMap.put(context.getUser().getUserName() + "_" + entry.getKey()
+ + "_" + version, result.get());
+ }
}
}
}
return elementEntityMap;
}
+
+ private static Id getEntityIdByInfoNameValue(SessionContext context, Id itemId, Id versionId,
+ Id elementId, String
+ name, String value) {
+
+ Id id;
+ Optional<ElementEntity> result =
+ cassandraElementRepository.get(context, new ElementEntityContext(
+ context.getUser().getUserName(),
+ itemId,
+ versionId),
+ new ElementEntity(Id.ZERO));
+ if (result.isPresent()) {
+ ElementEntity elementEntity = result.get();
+ return elementEntity.getSubElementIds().stream().filter(subelementId -> {
+ Optional<ElementEntity> subElementEntity =
+ cassandraElementRepository.get(context, new ElementEntityContext(
+ context.getUser().getUserName(),
+ itemId,
+ versionId),
+ new ElementEntity(subelementId));
+ if (subElementEntity.isPresent()) {
+ if("name".equals(name)){
+ if(value.equals(subElementEntity.get().getInfo().getName())){
+ return true;
+ }
+ }
+ if (value.equals(subElementEntity.get().getInfo().getProperty(name))) {
+ return true;
+ }
+ }
+ return false;
+
+ }).findFirst().orElse(null);
+ }
+ return null;
+
+
+
+
+
+
+ }
}