diff options
author | 2018-02-19 11:05:17 +0530 | |
---|---|---|
committer | 2018-02-19 16:13:04 +0000 | |
commit | 38b4e81eab76202bcafdec7e0b6374679090ce7e (patch) | |
tree | db6afd3705c212e043cd106e4e44e4934f92d0ea /openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main | |
parent | d299e8af2e9dfa79e53f7cf9e79977bab3474919 (diff) |
Onboarding foundation changes - UniqueValueUtil
Refactored UniqueValueUtil
Change-Id: I7523ad501de9a49c5fbbb59f33c07a40c55eda2f
Issue-ID: SDC-1047
Signed-off-by: sheetalm <sheetal.mudholkar@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main')
2 files changed, 12 insertions, 3 deletions
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<Version> 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<String> 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<String> 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()); |