diff options
author | Michael Lando <ml636r@att.com> | 2017-07-18 20:46:42 +0300 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2017-07-18 20:46:42 +0300 |
commit | 39a4e0cb1b805470ad85ed4cf4fdeb69610ae98c (patch) | |
tree | 9faa499670544cce1ec5510c242ad984871ca32d /catalog-dao/src/main/java/org | |
parent | b8e2faf476202b6ffe61bc3a9a37df1304881d40 (diff) |
[SDC] rebase 1710
Change-Id: I07fced02f40a57700d9d35ed3ba498bca351fb13
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-dao/src/main/java/org')
-rw-r--r-- | catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactAccessor.java | 19 | ||||
-rw-r--r-- | catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java | 11 |
2 files changed, 30 insertions, 0 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactAccessor.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactAccessor.java new file mode 100644 index 0000000000..61e23b8de2 --- /dev/null +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactAccessor.java @@ -0,0 +1,19 @@ +package org.openecomp.sdc.be.dao.cassandra; + +import com.datastax.driver.core.ResultSet; +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Param; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.sdc.be.resources.data.auditing.DistributionStatusEvent; + + +/** + * Created by chaya on 7/5/2017. + */ +@Accessor +public interface ArtifactAccessor { + // ***** get the number of artifacts with a specific id + @Query("SELECT COUNT(*) FROM sdcartifact.resources WHERE ID = :uniqueId") + ResultSet getNumOfArtifactsById(@Param("uniqueId") String uniqueId); +} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java index a9a4a99de1..5b37d3df2c 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java @@ -22,6 +22,7 @@ package org.openecomp.sdc.be.dao.cassandra; import javax.annotation.PostConstruct; +import com.datastax.driver.core.ResultSet; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.resources.data.ESArtifactData; import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants; @@ -38,6 +39,7 @@ import fj.data.Either; public class ArtifactCassandraDao extends CassandraDao { private static Logger logger = LoggerFactory.getLogger(ArtifactCassandraDao.class.getName()); + private ArtifactAccessor artifactAccessor; public ArtifactCassandraDao() { super(); @@ -52,6 +54,7 @@ public class ArtifactCassandraDao extends CassandraDao { if (result.isLeft()) { session = result.left().value().left; manager = result.left().value().right; + artifactAccessor = manager.createAccessor(ArtifactAccessor.class); logger.info("** ArtifactCassandraDao created"); } else { logger.info("** ArtifactCassandraDao failed"); @@ -107,4 +110,12 @@ public class ArtifactCassandraDao extends CassandraDao { return super.isTableEmpty(tableName); } + public Either<Long, CassandraOperationStatus> getCountOfArtifactById(String uniqeId) { + ResultSet artifactCount = artifactAccessor.getNumOfArtifactsById(uniqeId); + if (artifactCount == null) { + return Either.right(CassandraOperationStatus.NOT_FOUND); + } + return Either.left(artifactCount.one().getLong(0)); + } + } |