From 8e9c0653dd6c6862123c9609ae34e1206d86456e Mon Sep 17 00:00:00 2001 From: talig Date: Wed, 20 Dec 2017 14:30:43 +0200 Subject: Add collaboration feature Issue-ID: SDC-767 Change-Id: I14fb4c1f54086ed03a56a7ff7fab9ecd40381795 Signed-off-by: talig --- .../dao/impl/ActivityLogDaoCassandraImpl.java | 82 ++++++++-------------- .../dao/impl/ActivityLogDaoFactoryImpl.java | 10 +-- 2 files changed, 34 insertions(+), 58 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java') diff --git a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoCassandraImpl.java index 5772cc16b7..85e0afa90f 100644 --- a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoCassandraImpl.java +++ b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoCassandraImpl.java @@ -26,58 +26,34 @@ import org.openecomp.sdc.activitylog.dao.ActivityLogDao; import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; import java.util.Collection; -import java.util.Date; -public class ActivityLogDaoCassandraImpl extends CassandraBaseDao implements ActivityLogDao{ - private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final Mapper mapper = - noSqlDb.getMappingManager().mapper(ActivityLogEntity.class); - private static final ActivityLogAccessor accessor = - noSqlDb.getMappingManager().createAccessor(ActivityLogAccessor.class); - - @Override - protected Mapper getMapper() { - return mapper; - } - - @Override - protected Object[] getKeys(ActivityLogEntity entity) { - return new Object[0]; - } - - @Override - public Collection list(ActivityLogEntity entity) { - return accessor.list().all(); - } - - @Override - public void create(ActivityLogEntity activityLogEntity) { - accessor.create(activityLogEntity.getItemId(), activityLogEntity.getVersionId(),activityLogEntity.getId(), - activityLogEntity.getType(),activityLogEntity.getUser(), activityLogEntity.getTimestamp(), activityLogEntity.isSuccess(), - activityLogEntity.getMessage(), activityLogEntity.getComment()); - } - - @Override - public Collection getActivityLogListForItem(String itemId, String versionId) { - return accessor.getForItem(itemId, versionId).all(); - } - - - @Accessor - interface ActivityLogAccessor { - @Query("select item_id, version_id, activity_id, type, user, timestamp, success, message, comment" - + " from activity_log") - Result list(); - - @Query("select item_id, version_id, activity_id, type, user, timestamp, success, message, comment" - + " from activity_log where item_id=? and version_id=?") - Result getForItem(String itemId, String versionId); - - @Query("insert into activity_log " + - " (item_id, version_id, activity_id, type, user, timestamp, success, message, comment)" + - " values (?,?,?,?,?,?,?,?,?)") - Result create(String itemId, String versionId, String id, String type, - String user, Date timestamp, boolean success, - String message, String comment); - } +public class ActivityLogDaoCassandraImpl extends CassandraBaseDao + implements ActivityLogDao { + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final Mapper mapper = + noSqlDb.getMappingManager().mapper(ActivityLogEntity.class); + private static final ActivityLogAccessor accessor = + noSqlDb.getMappingManager().createAccessor(ActivityLogAccessor.class); + + @Override + protected Mapper getMapper() { + return mapper; + } + + @Override + protected Object[] getKeys(ActivityLogEntity entity) { + return new Object[]{entity.getItemId(), entity.getVersionId(), entity.getId()}; + } + + @Override + public Collection list(ActivityLogEntity entity) { + return accessor.listByItemVersion(entity.getItemId(), entity.getVersionId()).all(); + } + + @Accessor + interface ActivityLogAccessor { + + @Query("select * from activity_log where item_id=? and version_id=?") + Result listByItemVersion(String itemId, String versionId); + } } diff --git a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoFactoryImpl.java index 98e4cc2ed2..02c8a71b0e 100644 --- a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoFactoryImpl.java @@ -19,10 +19,10 @@ import org.openecomp.sdc.activitylog.dao.ActivityLogDao; import org.openecomp.sdc.activitylog.dao.ActivityLogDaoFactory; public class ActivityLogDaoFactoryImpl extends ActivityLogDaoFactory { - private static final ActivityLogDao INSTANCE = new ActivityLogDaoCassandraImpl(); + private static final ActivityLogDao INSTANCE = new ActivityLogDaoCassandraImpl(); - @Override - public ActivityLogDao createInterface() { - return INSTANCE; - } + @Override + public ActivityLogDao createInterface() { + return INSTANCE; + } } -- cgit 1.2.3-korg