diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src')
2 files changed, 33 insertions, 36 deletions
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 e6dd5a6d3b..0eae247869 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 @@ -21,48 +21,44 @@ import com.datastax.driver.mapping.MappingManager; import com.datastax.driver.mapping.Result; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; +import java.util.Collection; import org.openecomp.core.dao.impl.CassandraBaseDao; import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; import org.openecomp.sdc.activitylog.dao.ActivityLogDao; import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; import org.openecomp.sdc.activitylog.dao.type.ActivityType; -import java.util.Collection; - -public class ActivityLogDaoCassandraImpl extends CassandraBaseDao<ActivityLogEntity> - implements ActivityLogDao { - - private static final Mapper<ActivityLogEntity> mapper; - private static final ActivityLogAccessor accessor; +public class ActivityLogDaoCassandraImpl extends CassandraBaseDao<ActivityLogEntity> implements ActivityLogDao { - static { - MappingManager mappingManager = NoSqlDbFactory.getInstance().createInterface().getMappingManager(); - mappingManager.getSession().getCluster().getConfiguration().getCodecRegistry() - .register(new EnumNameCodec<>(ActivityType.class)); + private static final Mapper<ActivityLogEntity> mapper; + private static final ActivityLogAccessor accessor; - mapper = mappingManager.mapper(ActivityLogEntity.class); - accessor = mappingManager.createAccessor(ActivityLogAccessor.class); - } + static { + MappingManager mappingManager = NoSqlDbFactory.getInstance().createInterface().getMappingManager(); + mappingManager.getSession().getCluster().getConfiguration().getCodecRegistry().register(new EnumNameCodec<>(ActivityType.class)); + mapper = mappingManager.mapper(ActivityLogEntity.class); + accessor = mappingManager.createAccessor(ActivityLogAccessor.class); + } - @Override - protected Mapper<ActivityLogEntity> getMapper() { - return mapper; - } + @Override + protected Mapper<ActivityLogEntity> getMapper() { + return mapper; + } - @Override - protected Object[] getKeys(ActivityLogEntity entity) { - return new Object[]{entity.getItemId(), entity.getVersionId(), entity.getId()}; - } + @Override + protected Object[] getKeys(ActivityLogEntity entity) { + return new Object[]{entity.getItemId(), entity.getVersionId(), entity.getId()}; + } - @Override - public Collection<ActivityLogEntity> list(ActivityLogEntity entity) { - return accessor.listByItemVersion(entity.getItemId(), entity.getVersionId()).all(); - } + @Override + public Collection<ActivityLogEntity> list(ActivityLogEntity entity) { + return accessor.listByItemVersion(entity.getItemId(), entity.getVersionId()).all(); + } - @Accessor - interface ActivityLogAccessor { + @Accessor + interface ActivityLogAccessor { - @Query("select * from activity_log where item_id=? and version_id=?") - Result<ActivityLogEntity> listByItemVersion(String itemId, String versionId); - } + @Query("select * from activity_log where item_id=? and version_id=?") + Result<ActivityLogEntity> 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 02c8a71b0e..0da29828e2 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,11 @@ 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(); - @Override - public ActivityLogDao createInterface() { - return INSTANCE; - } + private static final ActivityLogDao INSTANCE = new ActivityLogDaoCassandraImpl(); + + @Override + public ActivityLogDao createInterface() { + return INSTANCE; + } } |