summaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java6
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java95
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java67
-rw-r--r--openecomp-be/tools/install/database/schemaTemplates/questionnaire/component.ftl3
-rw-r--r--openecomp-be/tools/zusammen-tools/pom.xml4
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java116
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/CassandraElementRepository.java267
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java29
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java109
9 files changed, 515 insertions, 181 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index 0a3428579d..1891cddfd5 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -329,7 +329,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(), vspDetails
.getOnboardingMethod()));
- if (vspDetails.getOnboardingMethod().equals("Manual")) {
+ if ("Manual".equals(vspDetails.getOnboardingMethod())) {
Collection<ErrorCode> deploymentFlavourValidationErrList =
deploymentFlavorValidation(vspDetails.getId(), vspDetails.getVersion());
if (validationResponse.getVspErrors() != null) {
@@ -527,7 +527,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
if (vspDetails.getSubCategory() == null) {
errors.add(createMissingMandatoryFieldError("sub category"));
}
- if (vspDetails.getOnboardingMethod().equals("Manual")) {
+ if ("Manual".equals(vspDetails.getOnboardingMethod())) {
//Manual Onboarding specific validations
Collection<DeploymentFlavorEntity> deploymentFlavorEntities = vendorSoftwareProductDao
.listDeploymentFlavors(vspDetails.getId(), vspDetails.getVersion());
@@ -729,7 +729,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
mdcDataDebugMessage.debugEntryMessage("VSP id", vspDetails.getId());
VspDetails retrieved = vspInfoDao.get(vspDetails);
- if (!retrieved.getOnboardingMethod().equals(vspDetails.getOnboardingMethod())) {
+ if (!Objects.equals(retrieved.getOnboardingMethod(), vspDetails.getOnboardingMethod())) {
final ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder
.getOnboardingUpdateError();
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
index e3701743ec..6fc8cfef61 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
@@ -21,6 +21,8 @@
package org.openecomp.sdc.healing.healers;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.dao.ServiceModelDaoFactory;
import org.openecomp.core.model.types.ServiceElement;
@@ -114,72 +116,36 @@ public class CompositionDataHealer implements Healer {
Collection<NetworkEntity> networkEntities =
networkDao.list(new NetworkEntity(vspId, version, null));
- Optional<ToscaServiceModel> serviceModelForHealing = getServiceModelForHealing(vspId, version);
+ Optional<Pair<ToscaServiceModel, ToscaServiceModel>> serviceModels =
+ getServiceModelForHealing(vspId, version);
CompositionData compositionData = null;
- if (!doesVspNeedCompositionDataHealing(vspId, version, componentEntities, networkEntities,
- nicEntities)) {
+ if (!doesVspNeedCompositionDataHealing(componentEntities, networkEntities, nicEntities)) {
updateComponentsDisplayNames(componentEntities);
mdcDataDebugMessage.debugExitMessage(null, null);
- //return Optional.empty();
} else {
- if (!serviceModelForHealing.isPresent()) {
+ if (!serviceModels.isPresent()) {
mdcDataDebugMessage.debugExitMessage(null, null);
return Optional.empty();
}
- compositionData = healCompositionData(vspId, version, serviceModelForHealing);
+ compositionData = serviceModels.isPresent() ? healCompositionData(vspId, version,
+ serviceModels.get()) : null;
}
- compositionData =
- getCompositionDataForHealing(vspId, version, serviceModelForHealing.get());
- HealNfodData(vspId, version, compositionData);
- mdcDataDebugMessage.debugExitMessage(null, null);
- return Optional.of(compositionData);
- }
-
- private boolean doesVspNeedCompositionDataHealing(String vspId, Version version,
- Collection<ComponentEntity> componentEntities,
- Collection<NetworkEntity> networkEntities,
- Collection<NicEntity> nicEntities) {
-
- return (CollectionUtils.isEmpty(componentEntities) && CollectionUtils.isEmpty(nicEntities) &&
- CollectionUtils.isEmpty(networkEntities) );
-
-// mdcDataDebugMessage.debugEntryMessage(null, null);
-//
-//// ToscaServiceModel toscaServiceModel;
-//
-// ByteBuffer contentData = uploadData.getContentData();
-// FileContentHandler fileContentHandler = CommonUtil.validateAndUploadFileContent(uploadData
-// .getContentData().array());
-//
-//
-//
-// TranslatorOutput translatorOutput =
-// HeatToToscaUtil.loadAndTranslateTemplateData(fileContentHandler);
-// ToscaServiceModel toscaServiceModel = translatorOutput.getToscaServiceModel();
-//
-//// toscaServiceModel = enrichedServiceModelDao.getServiceModel(vspId, version);
-//
-// mdcDataDebugMessage.debugExitMessage(null, null);
-// return toscaServiceModel;
+ if(serviceModels.isPresent()) {
+ compositionData =
+ getCompositionDataForHealing(vspId, version, serviceModels.get());
+ HealNfodData(vspId, version, compositionData);
+ }
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return Optional.ofNullable(compositionData);
}
private void HealNfodData(String vspId, Version version, CompositionData compositionData) {
Collection<ComponentEntity> componentEntities;
- /*componentEntities =
- vendorSoftwareProductDao.listComponents(vspId, version);*/
componentEntities = componentDao.list(new ComponentEntity(vspId, version, null));
- /*Collection<ComputeEntity> computeEntities=vendorSoftwareProductDao.listComputesByVsp(vspId,
- version);
- Collection<ImageEntity> imageEntities =vendorSoftwareProductDao.listImagesByVsp(vspId, version);
- Collection<DeploymentFlavorEntity> deploymentFlavorEntities =vendorSoftwareProductDao
- .listDeploymentFlavors(vspId, version);*/
-
Collection<ComputeEntity> computeEntities = computeDao.listByVsp(vspId, version);
Collection<ImageEntity> imageEntities = imageDao.listByVsp(vspId, version);
- //Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deloymentFlavorDao.list(new
- //DeploymentFlavorEntity(vspId, version, null));
if (CollectionUtils.isEmpty(computeEntities) && CollectionUtils.isEmpty(imageEntities)) {
for (Component component : compositionData.getComponents()) {
@@ -198,17 +164,12 @@ public class CompositionDataHealer implements Healer {
}
}
-
- /*if (CollectionUtils.isEmpty(deploymentFlavorEntities)) {
- compositionEntityDataManager.saveDeploymentFlavors(vspId,version,compositionData);
- }*/
}
private CompositionData healCompositionData(String vspId, Version version,
- Optional<ToscaServiceModel> serviceModelForHealing) {
- ToscaServiceModel toscaServiceModel = serviceModelForHealing.get();
+ Pair<ToscaServiceModel, ToscaServiceModel> toscaServiceModels) {
CompositionData compositionData =
- getCompositionDataForHealing(vspId, version, toscaServiceModel);
+ getCompositionDataForHealing(vspId, version, toscaServiceModels);
compositionEntityDataManager.saveCompositionData(vspId, version, compositionData);
return compositionData;
}
@@ -222,19 +183,16 @@ public class CompositionDataHealer implements Healer {
}
private CompositionData getCompositionDataForHealing(String vspId, Version version,
- ToscaServiceModel toscaServiceModel) {
+ Pair<ToscaServiceModel, ToscaServiceModel> toscaServiceModels) {
mdcDataDebugMessage.debugEntryMessage(null);
- if (Objects.isNull(toscaServiceModel)) {
+ if (Objects.isNull(toscaServiceModels)) {
return null;
}
- CompositionData compositionData = new CompositionData();
- if (Objects.nonNull(toscaServiceModel)) {
- compositionData = compositionDataExtractor
- .extractServiceCompositionData(toscaServiceModel);
- serviceModelDao.storeServiceModel(vspId, version, toscaServiceModel);
- }
+ CompositionData compositionData = compositionDataExtractor
+ .extractServiceCompositionData(toscaServiceModels.getRight());
+ serviceModelDao.storeServiceModel(vspId, version, toscaServiceModels.getLeft());
mdcDataDebugMessage.debugExitMessage(null);
return compositionData;
@@ -269,12 +227,12 @@ public class CompositionDataHealer implements Healer {
}
- private Optional<ToscaServiceModel> getServiceModelForHealing(String vspId, Version version)
+ private Optional<Pair<ToscaServiceModel, ToscaServiceModel>> getServiceModelForHealing(String
+ vspId, Version
+ version)
throws IOException {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- /*UploadDataEntity uploadData =
- vendorSoftwareProductDao.getUploadData(new UploadDataEntity(vspId, version));*/
UploadDataEntity uploadData =
orchestrationTemplateDataDao.getOrchestrationTemplate(vspId, version);
@@ -297,7 +255,8 @@ public class CompositionDataHealer implements Healer {
}
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return Optional.of(translatorOutput.getToscaServiceModel());
+ return Optional.of(new ImmutablePair<>(translatorOutput.getToscaServiceModel(), translatorOutput
+ .getNonUnifiedToscaServiceModel()));
}
private TranslatorOutput getTranslatorOutputForHealing(UploadDataEntity uploadData) {
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
index 69fa33aae7..348739e780 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
@@ -36,7 +36,7 @@ public class ToscaConverterImpl implements ToscaConverter {
@Override
public ToscaServiceModel convert(FileContentHandler fileContentHandler)
- throws IOException {
+ throws IOException {
Map<String, byte[]> csarFiles = new HashMap<>(fileContentHandler.getFiles());
ToscaServiceModel toscaServiceModel = new ToscaServiceModel();
Map<String, ServiceTemplate> serviceTemplates = new HashMap<>();
@@ -88,9 +88,9 @@ public class ToscaConverterImpl implements ToscaConverter {
}
} catch (YAMLException ye) {
throw new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withMessage("Invalid YAML content in file " + key + ". reason - "
- + ye.getMessage())
- .withCategory(ErrorCategory.APPLICATION).build());
+ .withMessage("Invalid YAML content in file " + key + ". reason - "
+ + ye.getMessage())
+ .withCategory(ErrorCategory.APPLICATION).build());
}
}
@@ -100,7 +100,7 @@ public class ToscaConverterImpl implements ToscaConverter {
GlobalSubstitutionServiceTemplate globalSubstitutionServiceTemplate,
Map<String, byte[]> csarFiles) {
Collection<ServiceTemplate> globalServiceTemplates =
- GlobalTypesGenerator.getGlobalTypesServiceTemplate().values();
+ GlobalTypesGenerator.getGlobalTypesServiceTemplate().values();
addGlobalServiceTemplates(globalServiceTemplates, serviceTemplates);
toscaServiceModel.setEntryDefinitionServiceTemplate(mainStName);
toscaServiceModel.setServiceTemplates(serviceTemplates);
@@ -125,10 +125,10 @@ public class ToscaConverterImpl implements ToscaConverter {
String fileName, Map<String, byte[]> csarFiles,
Map<String, ServiceTemplate> serviceTemplates) {
Optional<ServiceTemplate> serviceTemplate =
- getServiceTemplateFromCsar(fileName, csarFiles);
+ getServiceTemplateFromCsar(fileName, csarFiles);
serviceTemplate.ifPresent(
- serviceTemplate1 -> addServiceTemplate(serviceTemplateName, serviceTemplate1,
- serviceTemplates));
+ serviceTemplate1 -> addServiceTemplate(serviceTemplateName, serviceTemplate1,
+ serviceTemplates));
}
private void addServiceTemplate(String serviceTemplateName,
@@ -160,7 +160,7 @@ public class ToscaConverterImpl implements ToscaConverter {
ServiceTemplate serviceTemplate = new ServiceTemplate();
try {
ServiceTemplateReaderService readerService =
- new ServiceTemplateReaderServiceImpl(fileContent);
+ new ServiceTemplateReaderServiceImpl(fileContent);
convertMetadata(serviceTemplateName, serviceTemplate, readerService);
convertToscaVersion(serviceTemplate, readerService);
convertImports(serviceTemplate);
@@ -169,9 +169,9 @@ public class ToscaConverterImpl implements ToscaConverter {
} catch (YAMLException ye) {
throw new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withMessage("Invalid YAML content in file" + serviceTemplateName + ". reason - "
- + ye.getMessage())
- .withCategory(ErrorCategory.APPLICATION).build());
+ .withMessage("Invalid YAML content in file" + serviceTemplateName + ". reason - "
+ + ye.getMessage())
+ .withCategory(ErrorCategory.APPLICATION).build());
}
@@ -187,7 +187,7 @@ public class ToscaConverterImpl implements ToscaConverter {
private void convertImports(ServiceTemplate serviceTemplate) {
serviceTemplate.setImports(new ArrayList<>());
serviceTemplate.getImports()
- .add(createImportMap(openecompHeatIndex, "openecomp-heat/_index.yml"));
+ .add(createImportMap(openecompHeatIndex, "openecomp-heat/_index.yml"));
serviceTemplate.getImports().add(createImportMap(globalSubstitution, globalStName));
}
@@ -210,7 +210,7 @@ public class ToscaConverterImpl implements ToscaConverter {
if (MapUtils.isNotEmpty(metadataToConvert)) {
for (Map.Entry<String, Object> metadataEntry : metadataToConvert.entrySet()) {
if (Objects.isNull(metadataEntry.getValue()) ||
- !(metadataEntry.getValue() instanceof String)) {
+ !(metadataEntry.getValue() instanceof String)) {
continue;
}
finalMetadata.put(metadataEntry.getKey(), (String) metadataEntry.getValue());
@@ -229,9 +229,9 @@ public class ToscaConverterImpl implements ToscaConverter {
for (Map.Entry<String, Object> nodeTypeEntry : nodeTypes.entrySet()) {
DataModelUtil
- .addNodeType(serviceTemplate, nodeTypeEntry.getKey(),
- (NodeType) createObjectFromClass(nodeTypeEntry.getKey(), nodeTypeEntry.getValue(),
- NodeType.class));
+ .addNodeType(serviceTemplate, nodeTypeEntry.getKey(),
+ (NodeType) createObjectFromClass(nodeTypeEntry.getKey(), nodeTypeEntry.getValue(),
+ NodeType.class));
}
}
@@ -265,10 +265,10 @@ public class ToscaConverterImpl implements ToscaConverter {
for (Map.Entry<String, Object> entry : mapToConvert.entrySet()) {
ParameterDefinition parameterDefinition =
- (ParameterDefinition) createObjectFromClass(
- entry.getKey(), entry.getValue(), ParameterDefinition.class);
+ (ParameterDefinition) createObjectFromClass(
+ entry.getKey(), entry.getValue(), ParameterDefinition.class);
addToServiceTemplateAccordingToSection(
- serviceTemplate, inputsOrOutputs, entry.getKey(), parameterDefinition);
+ serviceTemplate, inputsOrOutputs, entry.getKey(), parameterDefinition);
}
}
@@ -279,11 +279,11 @@ public class ToscaConverterImpl implements ToscaConverter {
switch (inputsOrOutputs) {
case inputs:
DataModelUtil
- .addInputParameterToTopologyTemplate(serviceTemplate, parameterId, parameterDefinition);
+ .addInputParameterToTopologyTemplate(serviceTemplate, parameterId, parameterDefinition);
break;
case outputs:
DataModelUtil
- .addOutputParameterToTopologyTemplate(serviceTemplate, parameterId, parameterDefinition);
+ .addOutputParameterToTopologyTemplate(serviceTemplate, parameterId, parameterDefinition);
}
}
@@ -315,15 +315,15 @@ public class ToscaConverterImpl implements ToscaConverter {
substitutionMapping.setNode_type((String) substitutionMappings.get(nodeType));
substitutionMapping.setCapabilities(
- convertSubstitutionMappingsSections((Map<String, Object>) substitutionMappings.get(capabilities)));
+ convertSubstitutionMappingsSections((Map<String, Object>) substitutionMappings.get(capabilities)));
substitutionMapping.setRequirements(
- convertSubstitutionMappingsSections((Map<String, Object>) substitutionMappings.get(requirements)));
+ convertSubstitutionMappingsSections((Map<String, Object>) substitutionMappings.get(requirements)));
return substitutionMapping;
}
private Map<String, List<String>> convertSubstitutionMappingsSections(
- Map<String, Object> sectionToConvert) {
+ Map<String, Object> sectionToConvert) {
Map<String, List<String>> convertedSection = new HashMap<>();
if (MapUtils.isEmpty(sectionToConvert)) {
return null;
@@ -345,7 +345,7 @@ public class ToscaConverterImpl implements ToscaConverter {
return CsarFileTypes.globalServiceTemplate;
} else if (isDefinitions(fileName)) {
return CsarFileTypes.definitionsFile;
- } else if (isMetadataFile(metadataFile)) {
+ } else if (isMetadataFile(fileName)) {
return CsarFileTypes.toscaMetadata;
}
return CsarFileTypes.externalFile;
@@ -373,14 +373,14 @@ public class ToscaConverterImpl implements ToscaConverter {
nodeTemplate.setDescription((String) nodeTemplateAsMap.get("description"));
nodeTemplate.setDirectives((List<String>) nodeTemplateAsMap.get("directives"));
nodeTemplate.setInterfaces(
- (Map<String, InterfaceDefinition>) nodeTemplateAsMap.get("interfaces"));
+ (Map<String, InterfaceDefinition>) nodeTemplateAsMap.get("interfaces"));
nodeTemplate.setNode_filter((NodeFilter) nodeTemplateAsMap.get("node_filter"));
nodeTemplate.setProperties((Map<String, Object>) nodeTemplateAsMap.get("properties"));
nodeTemplate.setRequirements(
- (List<Map<String, RequirementAssignment>>) nodeTemplateAsMap.get("requirements"));
+ (List<Map<String, RequirementAssignment>>) nodeTemplateAsMap.get("requirements"));
nodeTemplate.setType((String) nodeTemplateAsMap.get("type"));
nodeTemplate.setCapabilities(
- convertCapabilities((Map<String, Object>) nodeTemplateAsMap.get("capabilities")));
+ convertCapabilities((Map<String, Object>) nodeTemplateAsMap.get("capabilities")));
return nodeTemplate;
}
@@ -393,8 +393,8 @@ public class ToscaConverterImpl implements ToscaConverter {
for (Map.Entry<String, Object> capabilityAssignmentEntry : capabilities.entrySet()) {
Map<String, CapabilityAssignment> tempMap = new HashMap<>();
tempMap.put(capabilityAssignmentEntry.getKey(),
- (CapabilityAssignment) createObjectFromClass
- (capabilityAssignmentEntry.getKey(), capabilityAssignmentEntry.getValue(), CapabilityAssignment.class));
+ (CapabilityAssignment) createObjectFromClass
+ (capabilityAssignmentEntry.getKey(), capabilityAssignmentEntry.getValue(), CapabilityAssignment.class));
convertedCapabilities.add(tempMap);
}
return convertedCapabilities;
@@ -408,8 +408,9 @@ public class ToscaConverterImpl implements ToscaConverter {
} catch (Exception e) {
//todo - return error to user?
throw new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withCategory(ErrorCategory.APPLICATION)
- .withMessage("Can't create Node Type from " + nodeTypeId).build());
+ .withCategory(ErrorCategory.APPLICATION)
+ .withMessage("Can't create " + classToCreate.getSimpleName() + " from " +
+ nodeTypeId).build());
}
}
diff --git a/openecomp-be/tools/install/database/schemaTemplates/questionnaire/component.ftl b/openecomp-be/tools/install/database/schemaTemplates/questionnaire/component.ftl
index 062bf55928..c023f1c88c 100644
--- a/openecomp-be/tools/install/database/schemaTemplates/questionnaire/component.ftl
+++ b/openecomp-be/tools/install/database/schemaTemplates/questionnaire/component.ftl
@@ -35,9 +35,10 @@
"providedBy": {
"type": "string",
"enum": [
+ "AIC",
"Vendor"
],
- "default": "Vendor"
+ "default": "AIC"
}
},
"additionalProperties": false
diff --git a/openecomp-be/tools/zusammen-tools/pom.xml b/openecomp-be/tools/zusammen-tools/pom.xml
index 0c84fbf9ba..ecb185e15e 100644
--- a/openecomp-be/tools/zusammen-tools/pom.xml
+++ b/openecomp-be/tools/zusammen-tools/pom.xml
@@ -212,6 +212,10 @@
<fixcrlf srcdir="./" eol="unix"
includes="zusammenMainTool.sh"/>
</tasks>
+ <tasks>
+ <replace file="src/main/resources/zusammenMainTool.sh" token="1.0-SNAPSHOT" value="${project.version}"/>
+ </tasks>
+
</configuration>
<goals>
<goal>run</goal>
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 031d1328b5..1725df7e93 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
@@ -3,24 +3,36 @@ package org.openecomp.core.tools.Commands;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.plugin.statestore.cassandra.dao.impl.VersionCassandraDao;
+import com.google.common.collect.Sets;
+import org.openecomp.core.tools.store.ElementHandler;
import org.openecomp.core.tools.store.VersionInfoCassandraLoader;
import org.openecomp.core.tools.store.VspGeneralLoader;
-import org.openecomp.core.tools.store.ElementHandler;
import org.openecomp.core.zusammen.impl.CassandraConnectionInitializer;
import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
+import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.openecomp.core.tools.store.VspGeneralLoader.buildKey;
public class ResetOldVersion {
+ public static final String OLD_VERSION = "oldVersion";
+
private static Map<String, List<String>> itemVersionMap = new HashMap<>();
+ private static Map<String, List<String>> itemChangeRefMap = new HashMap<>();
- private static int count =0;
- public static void reset(SessionContext context, String oldVersion,String emptyOldVersion) {
+ private static int count = 0;
+ public static void reset(SessionContext context, String oldVersion, String emptyOldVersion) {
CassandraConnectionInitializer.setCassandraConnectionPropertiesToSystem();
@@ -28,64 +40,102 @@ public class ResetOldVersion {
loadItemVersionInfo(context);
Map<String, ElementEntity> generalElementMap =
- VspGeneralLoader.load(context,
- itemVersionMap);
+ VspGeneralLoader.load(context,
+ itemVersionMap, itemChangeRefMap);
generalElementMap.values().forEach(elementEntity -> updateOldVersionFlag(elementEntity,
- oldVersion,"true".equals(emptyOldVersion)));
+ oldVersion, Boolean.TRUE.toString().equals(emptyOldVersion)));
+
+
+ itemVersionMap.entrySet().forEach(entry -> updateElements(context, generalElementMap, entry));
+
+ itemChangeRefMap.entrySet().forEach(entry -> updateElements(context, generalElementMap, entry));
+ System.out.println("number of element updated:" + count);
- itemVersionMap.entrySet().forEach(entry->entry.getValue().stream().filter
- (version->generalElementMap.containsKey(context.getUser().getUserName()+"_"+entry.getKey()
- +"_"+version)).forEach(version->ElementHandler.update(context,
- entry.getKey(),version,generalElementMap.get(context.getUser().getUserName()+"_"+entry.getKey()
- +"_"+version))));
+ }
+
+ private static void updateElements(SessionContext context, Map<String,
+ ElementEntity> generalElementMap, Map.Entry<String, List<String>> entry) {
- System.out.println("nymber of element updated:"+count);
+ entry.getValue().stream().filter
+ (changeRef -> generalElementMap
+ .containsKey(buildKey(context, entry, changeRef))).
+ forEach(changeref -> ElementHandler.update(context, entry.getKey(), changeref, changeref,
+ generalElementMap.get(buildKey(context, entry, changeref))));
}
private static void updateOldVersionFlag(ElementEntity elementEntity, String oldVersion,
boolean emptyOldVersion) {
- if(!emptyOldVersion){
- elementEntity.getInfo().addProperty("oldVersion",oldVersion);
+ if (!emptyOldVersion) {
+ elementEntity.getInfo().addProperty(OLD_VERSION, oldVersion);
count++;
- }else if(elementEntity.getInfo().getProperty("oldVersion")== null || ""
- .equals(elementEntity.getInfo().getProperty("oldVersion"))){
- elementEntity.getInfo().addProperty("oldVersion",oldVersion);
+ } else if (elementEntity.getInfo().getProperty(OLD_VERSION) == null
+ || "".equals(elementEntity.getInfo().getProperty(OLD_VERSION))) {
+ elementEntity.getInfo().addProperty(OLD_VERSION, oldVersion);
count++;
}
-
-
}
-
private static void loadItemVersionInfo(SessionContext context) {
List<String> items = new ArrayList<>();
System.setProperty("cassandra.dox.keystore", "dox");
VersionInfoCassandraLoader versionInfoCassandraLoader = new VersionInfoCassandraLoader();
- Collection<VersionInfoEntity> versions =
- versionInfoCassandraLoader.list();
+ Collection<VersionInfoEntity> versions = versionInfoCassandraLoader.list();
+
+ versions.stream().filter(versionInfoEntity -> versionInfoEntity.getEntityType()
+ .equals(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE)).forEach
+ (versionInfoEntity -> {
+ handleVersionInfoEntity(items, versionInfoEntity);
+ });
- versions.stream().filter(versionInfoEntity -> versionInfoEntity.getEntityType().equals
- (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE)).forEach
- (versionInfoEntity
- -> items.add(versionInfoEntity.getEntityId()));
System.setProperty("cassandra.dox.keystore", "zusammen_dox");
VersionCassandraDao versionCassandraDao = new VersionCassandraDao();
- items
- .forEach(itemId -> versionCassandraDao.list(context, context.getUser().getUserName(), new Id
- (itemId)).forEach(itemVersion -> addItemVersion(itemId, itemVersion.getId())));
+ items.forEach(itemId -> versionCassandraDao.list(context, context.getUser().getUserName(),
+ new Id(itemId)).forEach(itemVersion -> addItemVersion(itemId, itemVersion.getId())));
}
+ private static void handleVersionInfoEntity(List<String> items, VersionInfoEntity versionInfoEntity) {
+ items.add(versionInfoEntity.getEntityId());
+ Set<Version> viewableVersions;
+ if (versionInfoEntity.getViewableVersions() != null
+ && !versionInfoEntity.getViewableVersions().isEmpty()) {
+ viewableVersions = versionInfoEntity.getViewableVersions();
+ } else {
+ viewableVersions = Sets.newHashSet(versionInfoEntity.getActiveVersion());
+ }
+ addItemChangeRef(versionInfoEntity.getEntityId(), maxChangeRef(viewableVersions));
+ }
+
+ private static Id maxChangeRef(Set<Version> viewableVersions) {
+
+ return new Id(viewableVersions.stream().max((o1, o2) -> o1.getMajor() > o2.getMajor()
+ ?1:o1.getMajor
+ () == o2.getMajor() ? (o1.getMinor() > o2.getMinor() ? 1: o1.getMinor() == o2.getMinor()
+ ? 0 : -1) : -1).get().toString());
+
+ }
+
+ private static void addItemChangeRef(String itemId, Id changeRef) {
+ addItemVersion(itemChangeRefMap, itemId, changeRef);
+ }
+
private static void addItemVersion(String itemId, Id versionId) {
- if (!itemVersionMap.containsKey(itemId)) {
- itemVersionMap.put(itemId, new ArrayList<>());
+ addItemVersion(itemVersionMap, itemId, versionId);
+ }
+
+ private static void addItemVersion(Map<String, List<String>> itemVersions, String itemId, Id id) {
+
+ if (!itemVersions.containsKey(itemId)) {
+ itemVersions.put(itemId, new ArrayList<>());
}
- itemVersionMap.get(itemId).add(versionId.getValue());
+
+ itemVersions.get(itemId).add(id.getValue());
}
}
+
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/CassandraElementRepository.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/CassandraElementRepository.java
new file mode 100644
index 0000000000..c41b46ea14
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/CassandraElementRepository.java
@@ -0,0 +1,267 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.core.tools.store;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.Namespace;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Relation;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import com.amdocs.zusammen.utils.fileutils.json.JsonUtil;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Param;
+import com.datastax.driver.mapping.annotations.Query;
+import com.google.gson.reflect.TypeToken;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+
+import java.lang.reflect.Type;
+import java.nio.ByteBuffer;
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class CassandraElementRepository {
+
+
+ public Collection<ElementEntity> list(SessionContext context,
+ ElementEntityContext elementContext) {
+ Set<String> elementIds = getVersionElementIds(context, elementContext);
+
+ return elementIds.stream()
+ .map(elementId -> get(context, elementContext, new ElementEntity(new Id(elementId))).get())
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+ }
+
+
+ public void update(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ updateElement(context, elementContext, element);
+ }
+
+
+ public Optional<ElementEntity> get(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ Row row = getElementAccessor(context).get(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ getVersionId(elementContext),
+ element.getId().toString()).one();
+
+ return row == null ? Optional.empty() : Optional.of(getElementEntity(element, row));
+ }
+
+
+ private String getVersionId(ElementEntityContext elementContext) {
+ return elementContext.getChangeRef() == null
+ ? elementContext.getVersionId().toString()
+ : elementContext.getChangeRef();
+ }
+
+
+ private ElementAccessor getElementAccessor(SessionContext context) {
+ return NoSqlDbFactory.getInstance().createInterface().getMappingManager().createAccessor
+ (ElementAccessor.class);
+
+ }
+
+ private VersionElementsAccessor getVersionElementsAccessor() {
+ return NoSqlDbFactory.getInstance().createInterface().getMappingManager().createAccessor
+ (VersionElementsAccessor.class);
+
+ }
+
+
+ private void updateElement(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+
+ if (elementContext.getChangeRef() == null) {
+
+ getElementAccessor(context).update(
+ JsonUtil.object2Json(element.getInfo()),
+ JsonUtil.object2Json(element.getRelations()),
+ element.getData(),
+ element.getSearchableData(),
+ element.getVisualization(),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ element.getId().toString());
+ } else {
+ getElementAccessor(context).update(
+ JsonUtil.object2Json(element.getInfo()),
+ JsonUtil.object2Json(element.getRelations()),
+ element.getData(),
+ element.getSearchableData(),
+ element.getVisualization(),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getChangeRef(),
+ element.getId().toString());
+ }
+ }
+
+
+ private ElementEntity getElementEntity(ElementEntity element, Row row) {
+ element.setNamespace(getNamespace(row.getString(ElementField.NAMESPACE)));
+ element.setParentId(new Id(row.getString(ElementField.PARENT_ID)));
+ element.setInfo(json2Object(row.getString(ElementField.INFO), Info.class));
+ element.setRelations(
+ json2Object(row.getString(ElementField.RELATIONS), new TypeToken<ArrayList<Relation>>() {
+ }.getType()));
+ element.setData(row.getBytes(ElementField.DATA));
+ element.setSearchableData(row.getBytes(ElementField.SEARCHABLE_DATA));
+ element.setVisualization(row.getBytes(ElementField.VISUALIZATION));
+ element.setSubElementIds(row.getSet(ElementField.SUB_ELEMENT_IDS, String.class)
+ .stream().map(Id::new).collect(Collectors.toSet()));
+ return element;
+ }
+
+ private Namespace getNamespace(String namespaceStr) {
+ Namespace namespace = new Namespace();
+ if (namespaceStr != null) {
+ namespace.setValue(namespaceStr);
+ }
+ return namespace;
+ }
+
+ private static <T> T json2Object(String json, Type typeOfT) {
+ return json == null ? null : JsonUtil.json2Object(json, typeOfT);
+ }
+
+ private Set<String> getVersionElementIds(SessionContext context,
+ ElementEntityContext elementContext) {
+ Row row = getVersionElementsAccessor().get(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ getVersionId(elementContext)).one();
+ return row == null
+ ? new HashSet<>()
+ : row.getSet(CassandraElementRepository.VersionElementsField.ELEMENT_IDS, String.class);
+ }
+
+ /*
+CREATE TABLE IF NOT EXISTS element_namespace (
+ space text,
+ item_id text,
+ element_id text,
+ namespace text,
+ PRIMARY KEY (( space, item_id, element_id ))
+);
+ */
+ @Accessor
+ interface ElementNamespaceAccessor {
+ @Query(
+ "UPDATE element_namespace SET namespace=:ns " +
+ "WHERE space=:space AND item_id=:item AND element_id=:id ")
+ void create(@Param("space") String space,
+ @Param("item") String itemId,
+ @Param("id") String elementId,
+ @Param("ns") String namespace);
+ }
+
+ /*
+CREATE TABLE IF NOT EXISTS element (
+ space text,
+ item_id text,
+ version_id text,
+ element_id text,
+ parent_id text,
+ namespace text,
+ info text,
+ relations text,
+ data blob,
+ searchable_data blob,
+ visualization blob,
+ sub_element_ids set<text>,
+ PRIMARY KEY (( space, item_id, version_id, element_id ))
+);
+ */
+ @Accessor
+ interface ElementAccessor {
+ @Query(
+ "UPDATE zusammen_dox.element SET parent_id=:parentId, namespace=:ns, info=:info, " +
+ "relations=:rels, " +
+ "data=:data, searchable_data=:searchableData, visualization=:visualization, " +
+ "sub_element_ids=sub_element_ids+:subs " +
+ "WHERE space=:space AND item_id=:item AND version_id=:ver AND element_id=:id ")
+ void create(@Param("space") String space,
+ @Param("item") String itemId,
+ @Param("ver") String versionId,
+ @Param("id") String elementId,
+ @Param("parentId") String parentElementId,
+ @Param("ns") String namespace,
+ @Param("info") String info,
+ @Param("rels") String relations,
+ @Param("data") ByteBuffer data,
+ @Param("searchableData") ByteBuffer searchableData,
+ @Param("visualization") ByteBuffer visualization,
+ @Param("subs") Set<String> subElementIds);
+
+ @Query("UPDATE zusammen_dox.element SET info=?, relations=?, data=?, searchable_data=?, " +
+ "visualization=?" +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
+ void update(String info, String relations, ByteBuffer data, ByteBuffer searchableData,
+ ByteBuffer visualization, String space, String itemId, String versionId,
+ String elementId);
+
+
+ @Query("SELECT parent_id, namespace, info, relations, data, searchable_data, visualization, " +
+ "sub_element_ids FROM zusammen_dox.element " +
+ "WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
+ ResultSet get(String space, String itemId, String versionId, String elementId);
+
+
+ }
+
+ private static final class ElementField {
+ private static final String NAMESPACE = "namespace";
+ private static final String PARENT_ID = "parent_id";
+ private static final String INFO = "info";
+ private static final String RELATIONS = "relations";
+ private static final String DATA = "data";
+ private static final String SEARCHABLE_DATA = "searchable_data";
+ private static final String VISUALIZATION = "visualization";
+ private static final String SUB_ELEMENT_IDS = "sub_element_ids";
+ }
+
+ /*
+ CREATE TABLE IF NOT EXISTS version_elements (
+ space text,
+ item_id text,
+ version_id text,
+ element_ids set<text>,
+ PRIMARY KEY (( space, item_id, version_id ))
+ );
+ */
+ @Accessor
+ interface VersionElementsAccessor {
+
+
+ @Query("SELECT element_ids FROM zusammen_dox.version_elements WHERE space=? AND item_id=? AND version_id=?")
+ ResultSet get(String space, String itemId, String versionId);
+
+
+ }
+
+ private static final class VersionElementsField {
+ private static final String ELEMENT_IDS = "element_ids";
+ }
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java
index 2690130974..5c72c95f49 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java
@@ -2,25 +2,32 @@ package org.openecomp.core.tools.store;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
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;
public class ElementHandler {
- private static final String GLOBAL_USER = "GLOBAL_USER";
+ private static final String GLOBAL_USER = "GLOBAL_USER";
- public static void update(SessionContext context,
+ public static void update(SessionContext context,
+ String itemId, String versionId, String changeRef,
+ ElementEntity elementEntity) {
- String itemId, String versionId,
- ElementEntity elementEntity) {
+ ElementEntityContext elementContext;
+ CassandraElementRepository cassandraElementRepository = new CassandraElementRepository();
+ if (changeRef == null) {
- ElementEntityContext elementContext;
- elementContext = new ElementEntityContext(GLOBAL_USER, new Id(itemId),
- new Id(versionId));
- CassandraElementRepository cassandraElementRepository = new CassandraElementRepository();
- cassandraElementRepository.update(context, elementContext, elementEntity);
+ elementContext = new ElementEntityContext(GLOBAL_USER, new Id(itemId),
+ new Id(versionId));
- }
+ } else {
+ elementContext = new ElementEntityContext(GLOBAL_USER, new ElementContext(new Id(itemId),
+ new Id(versionId),
+ changeRef));
+ }
+ cassandraElementRepository.update(context, elementContext, elementEntity);
+
+ }
}
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 b5d09daf3f..fbfde7431e 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
@@ -12,67 +12,114 @@ import java.util.Map;
import java.util.Optional;
public class VspGeneralLoader {
+
+ public static final String NAME = "name";
+ public static final String GENERAL = "General";
+
private static CassandraElementRepository cassandraElementRepository =
- new CassandraElementRepository();
+ new CassandraElementRepository();
public static Map<String, ElementEntity> load(SessionContext context,
- Map<String, List<String>> vspItemVersionsMap) {
+ Map<String, List<String>> vspItemVersionsMap,
+ Map<String, List<String>> vspItemChangeRefssMap) {
Map<String, ElementEntity> elementEntityMap = new HashMap<>();
System.setProperty("cassandra.dox.keystore", "zusammen_dox");
Id entityId;
Id itemId;
- Id versionId;
+ Id changeRefId;
for (Map.Entry<String, List<String>> entry : vspItemVersionsMap.entrySet()) {
for (String version : entry.getValue()) {
itemId = new Id(entry.getKey());
- versionId = new Id(version);
- entityId = getEntityIdByInfoNameValue(context, itemId, versionId, null, "name",
- "General");
+ changeRefId = new Id(version);
+ entityId = getEntityIdByInfoNameValue(context, itemId, changeRefId, null, null, NAME,
+ GENERAL);
+ if (entityId != null) {
+ Optional<ElementEntity> result =
+ cassandraElementRepository.get(context, new ElementEntityContext(
+ context.getUser().getUserName(),
+ itemId,
+ changeRefId),
+ new ElementEntity(entityId));
+ if (result.isPresent()) {
+ elementEntityMap.put(buildKey(context, entry, version), result.get());
+ }
+ }
+ }
+ }
+
+
+ for (Map.Entry<String, List<String>> entry : vspItemChangeRefssMap.entrySet()) {
+
+ for (String changeRef : entry.getValue()) {
+
+
+ itemId = new Id(entry.getKey());
+
+ entityId = getEntityIdByInfoNameValue(context, itemId, null, changeRef,null, NAME,
+ GENERAL);
if (entityId != null) {
+ ElementEntityContext elementContext = new ElementEntityContext(
+ context.getUser().getUserName(),
+ itemId,
+ null);
+ elementContext.setChangeRef(changeRef);
Optional<ElementEntity> result =
- cassandraElementRepository.get(context, new ElementEntityContext(
- context.getUser().getUserName(),
- itemId,
- versionId),
- new ElementEntity(entityId));
+ cassandraElementRepository.get(context, elementContext,
+ new ElementEntity(entityId));
if (result.isPresent()) {
- elementEntityMap.put(context.getUser().getUserName() + "_" + entry.getKey()
- + "_" + version, result.get());
+ elementEntityMap.put(buildKey(context, entry, changeRef), result.get());
}
}
}
}
+
return elementEntityMap;
}
- private static Id getEntityIdByInfoNameValue(SessionContext context, Id itemId, Id versionId,
- Id elementId, String
- name, String value) {
+ public static String buildKey(SessionContext context, Map.Entry<String, List<String>> entry, String version) {
+ return String.format("%s_%s_%s", context.getUser().getUserName(), entry.getKey(), version);
+ }
- Id id;
+ private static Id getEntityIdByInfoNameValue(SessionContext context,
+ Id itemId,
+ Id versionId,
+ String changeRef,
+ Id elementId,
+ String name,
+ String value) {
+
+
+ ElementEntityContext elementContext = new ElementEntityContext(
+ context.getUser().getUserName(),
+ itemId,
+ versionId);
+ if (changeRef != null) {
+ elementContext.setChangeRef(changeRef);
+ }
Optional<ElementEntity> result =
- cassandraElementRepository.get(context, new ElementEntityContext(
- context.getUser().getUserName(),
- itemId,
- versionId),
- new ElementEntity(Id.ZERO));
+ cassandraElementRepository.get(context, elementContext,
+ new ElementEntity(Id.ZERO));
if (result.isPresent()) {
ElementEntity elementEntity = result.get();
return elementEntity.getSubElementIds().stream().filter(subelementId -> {
+ ElementEntityContext subElementContext = new ElementEntityContext(
+ context.getUser().getUserName(),
+ itemId,
+ versionId);
+ if(changeRef!= null){
+ subElementContext.setChangeRef(changeRef);
+ }
Optional<ElementEntity> subElementEntity =
- cassandraElementRepository.get(context, new ElementEntityContext(
- context.getUser().getUserName(),
- itemId,
- versionId),
- new ElementEntity(subelementId));
+ cassandraElementRepository.get(context, subElementContext,
+ new ElementEntity(subelementId));
if (subElementEntity.isPresent()) {
- if("name".equals(name)){
- if(value.equals(subElementEntity.get().getInfo().getName())){
+ if (NAME.equals(name)) {
+ if (value.equals(subElementEntity.get().getInfo().getName())) {
return true;
}
}
@@ -87,9 +134,7 @@ public class VspGeneralLoader {
return null;
+ }
-
-
- }
}