use of org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamComment in project entando-core by entando.
the class SocialActivityStreamDAO method getActionCommentRecords.
@Override
public List<ActivityStreamComment> getActionCommentRecords(int id) {
List<ActivityStreamComment> comments = new ArrayList<>();
Connection conn = null;
PreparedStatement stat = null;
ResultSet result = null;
try {
conn = this.getConnection();
stat = conn.prepareStatement(GET_ACTION_COMMENT_RECORDS);
stat.setInt(1, id);
result = stat.executeQuery();
while (result.next()) {
ActivityStreamComment comment = new ActivityStreamComment();
comment.setId(result.getInt(1));
comment.setUsername(result.getString(2));
comment.setCommentText(result.getString(3));
Timestamp timestamp = result.getTimestamp(4);
comment.setCommentDate(new Date(timestamp.getTime()));
comments.add(comment);
}
} catch (Throwable t) {
logger.error("Error while loading activity stream comment records", t);
throw new RuntimeException("Error while loading activity stream comment records", t);
} finally {
closeDaoResources(result, stat, conn);
}
return comments;
}
use of org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamComment in project entando-core by entando.
the class SocialActivityStreamManager method getActionCommentRecords.
@Override
@CachePut(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'ActivityStreamCommentRecords_id_'.concat(#id)")
@CacheableInfo(groups = "'ActivityStreamCommentRecords_cacheGroup'")
public List<ActivityStreamComment> getActionCommentRecords(int id) throws ApsSystemException {
List<ActivityStreamComment> infos = null;
try {
infos = this.getSocialActivityStreamDAO().getActionCommentRecords(id);
if (null != infos) {
for (int i = 0; i < infos.size(); i++) {
ActivityStreamComment comment = infos.get(i);
String username = comment.getUsername();
IUserProfile profile = this.getUserProfileManager().getProfile(username);
String displayName = (null != profile) ? profile.getDisplayName() : username;
comment.setDisplayName(displayName);
}
}
} catch (Throwable t) {
_logger.error("Error extracting activity stream like records for stream with id {}", id, t);
throw new ApsSystemException("Error extracting activity stream like records", t);
}
return infos;
}
use of org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamComment in project entando-core by entando.
the class TestSocialActivityStreamDAO method testAddDeleteCommentRecord.
public void testAddDeleteCommentRecord() throws Throwable {
ActionLogRecord record1 = this._helper.createActionRecord(1, "username1", "actionName1", "namespace1", DateConverter.parseDate("01/01/2009 00:00", "dd/MM/yyyy HH:mm"), "params1");
ActionLogRecord record2 = this._helper.createActionRecord(2, "username2", "actionName2", "namespace2", DateConverter.parseDate("01/02/2009 00:00", "dd/MM/yyyy HH:mm"), "params2");
this._actionLoggerDAO.addActionRecord(record1);
this._actionLoggerDAO.addActionRecord(record2);
ActionLogRecord addedRecord1 = this._actionLoggerDAO.getActionRecord(record1.getId());
this.compareActionRecords(record1, addedRecord1);
ActionLogRecord addedRecord2 = this._actionLoggerDAO.getActionRecord(record2.getId());
this.compareActionRecords(record2, addedRecord2);
this._socialActivityStreamDAO.addActionCommentRecord(100, addedRecord1.getId(), "admin", "test comment 1");
synchronized (this) {
this.wait(1000);
}
this._socialActivityStreamDAO.addActionCommentRecord(101, addedRecord1.getId(), "admin", "test comment 2");
List<ActivityStreamComment> actionCommentRecords = this._socialActivityStreamDAO.getActionCommentRecords(addedRecord1.getId());
assertEquals(2, actionCommentRecords.size());
assertEquals(100, actionCommentRecords.get(0).getId());
assertEquals(101, actionCommentRecords.get(1).getId());
this._socialActivityStreamDAO.deleteActionCommentRecord(100);
actionCommentRecords = this._socialActivityStreamDAO.getActionCommentRecords(addedRecord1.getId());
assertEquals(1, actionCommentRecords.size());
assertEquals("test comment 2", actionCommentRecords.get(0).getCommentText());
}
Aggregations