Search in sources :

Example 1 with ActivityStreamLikeInfo

use of org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamLikeInfo in project entando-core by entando.

the class SocialActivityStreamManager method getActionLikeRecords.

@Override
@CachePut(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'ActivityStreamLikeRecords_id_'.concat(#id)")
@CacheableInfo(groups = "'ActivityStreamLikeRecords_cacheGroup'")
public List<ActivityStreamLikeInfo> getActionLikeRecords(int id) throws ApsSystemException {
    List<ActivityStreamLikeInfo> infos = null;
    try {
        infos = this.getSocialActivityStreamDAO().getActionLikeRecords(id);
        if (null != infos) {
            for (int i = 0; i < infos.size(); i++) {
                ActivityStreamLikeInfo asli = infos.get(i);
                String username = asli.getUsername();
                IUserProfile profile = this.getUserProfileManager().getProfile(username);
                String displayName = (null != profile) ? profile.getDisplayName() : username;
                asli.setDisplayName(displayName);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error extracting activity stream like records", t);
        throw new ApsSystemException("Error extracting activity stream like records", t);
    }
    return infos;
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ActivityStreamLikeInfo(org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamLikeInfo) CacheableInfo(org.entando.entando.aps.system.services.cache.CacheableInfo) CachePut(org.springframework.cache.annotation.CachePut)

Example 2 with ActivityStreamLikeInfo

use of org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamLikeInfo in project entando-core by entando.

the class SocialActivityStreamDAO method getActionLikeRecords.

@Override
public List<ActivityStreamLikeInfo> getActionLikeRecords(int id) {
    List<ActivityStreamLikeInfo> infos = new ActivityStreamLikeInfos();
    Connection conn = null;
    PreparedStatement stat = null;
    ResultSet result = null;
    try {
        conn = this.getConnection();
        stat = conn.prepareStatement(GET_ACTION_LIKE_RECORDS);
        stat.setInt(1, id);
        result = stat.executeQuery();
        while (result.next()) {
            ActivityStreamLikeInfo asli = new ActivityStreamLikeInfo();
            asli.setUsername(result.getString(1));
            infos.add(asli);
        }
    } catch (Throwable t) {
        logger.error("Error while loading activity stream like records", t);
        throw new RuntimeException("Error while loading activity stream like records", t);
    } finally {
        closeDaoResources(result, stat, conn);
    }
    return infos;
}
Also used : Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ActivityStreamLikeInfo(org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamLikeInfo) ActivityStreamLikeInfos(org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamLikeInfos)

Aggregations

ActivityStreamLikeInfo (org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamLikeInfo)2 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 CacheableInfo (org.entando.entando.aps.system.services.cache.CacheableInfo)1 IUserProfile (org.entando.entando.aps.system.services.userprofile.model.IUserProfile)1 ActivityStreamLikeInfos (org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamLikeInfos)1 CachePut (org.springframework.cache.annotation.CachePut)1