From 38b4e81eab76202bcafdec7e0b6374679090ce7e Mon Sep 17 00:00:00 2001 From: sheetalm Date: Mon, 19 Feb 2018 11:05:17 +0530 Subject: Onboarding foundation changes - UniqueValueUtil Refactored UniqueValueUtil Change-Id: I7523ad501de9a49c5fbbb59f33c07a40c55eda2f Issue-ID: SDC-1047 Signed-off-by: sheetalm --- .../dao/impl/VersionableEntityDaoCassandraImpl.java | 11 +++++++++-- .../versioning/dao/impl/VersionableEntityDaoFactoryImpl.java | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-versioning-lib') diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionableEntityDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionableEntityDaoCassandraImpl.java index 0845beaa2f..0a14c7ae19 100644 --- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionableEntityDaoCassandraImpl.java +++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionableEntityDaoCassandraImpl.java @@ -24,6 +24,7 @@ import com.datastax.driver.core.ColumnDefinitions; import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Row; import com.datastax.driver.mapping.UDTMapper; +import org.openecomp.core.dao.UniqueValueDao; import org.openecomp.core.nosqldb.api.NoSqlDb; import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; import org.openecomp.core.util.UniqueValueUtil; @@ -44,12 +45,18 @@ import java.util.stream.Collectors; class VersionableEntityDaoCassandraImpl implements VersionableEntityDao { + private final UniqueValueUtil uniqueValueUtil; private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); private static Logger Logger = (Logger) LoggerFactory.getLogger(VersionableEntityDaoCassandraImpl.class); private static UDTMapper versionMapper = noSqlDb.getMappingManager().udtMapper(Version.class); + public VersionableEntityDaoCassandraImpl( + UniqueValueDao uniqueValueDao) { + this.uniqueValueUtil = new UniqueValueUtil(uniqueValueDao); + } + private static String commaSeparatedQuestionMarks(int size) { StringBuilder sb = new StringBuilder(size * 2 - 1); for (int i = 0; i < size; i++) { @@ -128,7 +135,7 @@ class VersionableEntityDaoCassandraImpl implements VersionableEntityDao { for (UniqueValueMetadata uniqueMetadata : metadata) { List uniqueValueCombination = uniqueMetadata.getUniqueConstraintIdentifiers().stream() .map(colName -> (String) columnNameToValue.get(colName)).collect(Collectors.toList()); - UniqueValueUtil.createUniqueValue(uniqueMetadata.getType(), + uniqueValueUtil.createUniqueValue(uniqueMetadata.getType(), uniqueValueCombination.toArray(new String[uniqueValueCombination.size()])); } } @@ -138,7 +145,7 @@ class VersionableEntityDaoCassandraImpl implements VersionableEntityDao { for (UniqueValueMetadata uniqueMetadata : metadata) { List uniqueValueCombination = uniqueMetadata.getUniqueConstraintIdentifiers().stream() .map(colName -> (String) columnNameToValue.get(colName)).collect(Collectors.toList()); - UniqueValueUtil.deleteUniqueValue(uniqueMetadata.getType(), + uniqueValueUtil.deleteUniqueValue(uniqueMetadata.getType(), uniqueValueCombination.toArray(new String[uniqueValueCombination.size()])); } } diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionableEntityDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionableEntityDaoFactoryImpl.java index 3ab6560c71..d9300a007b 100644 --- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionableEntityDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionableEntityDaoFactoryImpl.java @@ -20,13 +20,15 @@ package org.openecomp.sdc.versioning.dao.impl; +import org.openecomp.core.dao.UniqueValueDaoFactory; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; import org.openecomp.sdc.versioning.dao.VersionableEntityDao; import org.openecomp.sdc.versioning.dao.VersionableEntityDaoFactory; import org.openecomp.sdc.versioning.types.VersionableEntityStoreType; public class VersionableEntityDaoFactoryImpl extends VersionableEntityDaoFactory { - private static VersionableEntityDao CASSANDRA_INSTANCE = new VersionableEntityDaoCassandraImpl(); + private static VersionableEntityDao CASSANDRA_INSTANCE = new VersionableEntityDaoCassandraImpl( + UniqueValueDaoFactory.getInstance().createInterface()); private static VersionableEntityDao ZUSAMMEN_INSTANCE = new VersionableEntityDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface()); -- cgit 1.2.3-korg