Search in sources :

Example 1 with ActivityStreamSeachBean

use of org.entando.entando.aps.system.services.actionlog.model.ActivityStreamSeachBean in project entando-core by entando.

the class ActionLogManager method lastUpdateDate.

@Override
public Date lastUpdateDate(UserDetails loggedUser) throws ApsSystemException {
    List<Integer> actionRecordIds = null;
    Date lastUpdate = new Date();
    try {
        ActivityStreamSeachBean searchBean = new ActivityStreamSeachBean();
        searchBean.setUserGroupCodes(this.extractUserGroupCodes(loggedUser));
        searchBean.setEndUpdate(lastUpdate);
        actionRecordIds = this.getActionRecords(searchBean);
        if (null != actionRecordIds && actionRecordIds.size() > 0) {
            ActionLogRecord actionRecord = this.getActionRecord(actionRecordIds.get(0));
            lastUpdate = actionRecord.getUpdateDate();
        }
    } catch (Throwable t) {
        _logger.error("Error on loading updated activities", t);
        throw new ApsSystemException("Error on loading updated activities", t);
    }
    return lastUpdate;
}
Also used : ActionLogRecord(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord) ActivityStreamSeachBean(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamSeachBean) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Date(java.util.Date)

Example 2 with ActivityStreamSeachBean

use of org.entando.entando.aps.system.services.actionlog.model.ActivityStreamSeachBean in project entando-core by entando.

the class TestActivityStream method testActivityStreamSearchBean.

public void testActivityStreamSearchBean() throws Throwable {
    // "coach" group
    Content content = this._contentManager.loadContent("EVN41", false);
    String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(content, ApsAdminSystemConstants.ADD);
    content.setId(null);
    String contentId = null;
    Date dateBeforeSave = new Date();
    Thread.sleep(1000);
    try {
        this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, content);
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        contentId = content.getId();
        assertNotNull(this._contentManager.loadContent(contentId, false));
        super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
        Date firstDate = new Date();
        ActionLogRecordSearchBean searchBean = this._helper.createSearchBean("admin", null, null, null, null, null);
        List<Integer> ids = this._actionLoggerManager.getActionRecords(searchBean);
        assertEquals(1, ids.size());
        ActivityStreamSeachBean activityStreamSeachBean = new ActivityStreamSeachBean();
        activityStreamSeachBean.setEndCreation(firstDate);
        List<Integer> activityStreamEndDate = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
        assertEquals(1, activityStreamEndDate.size());
        activityStreamSeachBean = new ActivityStreamSeachBean();
        activityStreamSeachBean.setEndUpdate(dateBeforeSave);
        List<Integer> activityStreamDateBeforeSave = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
        assertEquals(0, activityStreamDateBeforeSave.size());
        Thread.sleep(1000);
        this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, content);
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        contentId = content.getId();
        assertNotNull(this._contentManager.loadContent(contentId, false));
        super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
        activityStreamSeachBean = new ActivityStreamSeachBean();
        activityStreamSeachBean.setStartUpdate(dateBeforeSave);
        activityStreamSeachBean.setEndUpdate(firstDate);
        List<Integer> activityStreamBetweenSave = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
        assertEquals(1, activityStreamBetweenSave.size());
        activityStreamSeachBean = new ActivityStreamSeachBean();
        activityStreamSeachBean.setStartUpdate(dateBeforeSave);
        activityStreamSeachBean.setEndUpdate(new Date());
        List<Integer> activityStreamBetweenSave2 = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
        assertEquals(2, activityStreamBetweenSave2.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this._contentManager.deleteContent(content);
        assertNull(this._contentManager.loadContent(contentId, false));
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActivityStreamSeachBean(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamSeachBean) ActionLogRecordSearchBean(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean) Date(java.util.Date)

Example 3 with ActivityStreamSeachBean

use of org.entando.entando.aps.system.services.actionlog.model.ActivityStreamSeachBean in project entando-core by entando.

the class TestActivityStreamAction method testActivityStreamSearchBean.

public void testActivityStreamSearchBean() throws Throwable {
    // "coach" group
    Content content = this._contentManager.loadContent("EVN41", false);
    String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(content, ApsAdminSystemConstants.ADD);
    content.setId(null);
    String contentId = null;
    Date dateBeforeSave = new Date();
    Thread.sleep(1000);
    try {
        this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, content);
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        contentId = content.getId();
        assertNotNull(this._contentManager.loadContent(contentId, false));
        super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
        Date firstDate = new Date();
        ActionLogRecordSearchBean searchBean = this._helper.createSearchBean("admin", null, null, null, null, null);
        List<Integer> ids = this._actionLoggerManager.getActionRecords(searchBean);
        assertEquals(1, ids.size());
        ActionLogRecord firstRecord = this._actionLoggerManager.getActionRecord(ids.get(0));
        ActivityStreamSeachBean activityStreamSeachBean = new ActivityStreamSeachBean();
        activityStreamSeachBean.setEndUpdate(firstDate);
        List<Integer> activityStreamEndDate = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
        assertEquals(1, activityStreamEndDate.size());
        Thread.sleep(1000);
        this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, content);
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        contentId = content.getId();
        assertNotNull(this._contentManager.loadContent(contentId, false));
        super.waitThreads(IActionLogManager.LOG_APPENDER_THREAD_NAME_PREFIX);
        activityStreamSeachBean = new ActivityStreamSeachBean();
        activityStreamSeachBean.setEndUpdate(new Date());
        List<Integer> activityStreamBetweenSave2 = this._actionLoggerManager.getActivityStream(activityStreamSeachBean);
        assertEquals(2, activityStreamBetweenSave2.size());
        String firstDateString = DateConverter.getFormattedDate(firstDate, ApsAdminSystemConstants.CALENDAR_TIMESTAMP_PATTERN);
        this.initActivityStreamAction("/do/ActivityStream", "update", firstDateString);
        this.setUserOnSession("admin");
        result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        ActivityStreamAction activityStreamAction = (ActivityStreamAction) this.getAction();
        List<Integer> update = activityStreamAction.getActionRecordIds();
        assertEquals(1, update.size());
        ActionLogRecord updateRecord = this._actionLoggerManager.getActionRecord(update.get(0));
        String actionRecordDate = DateConverter.getFormattedDate(updateRecord.getActionDate(), ApsAdminSystemConstants.CALENDAR_TIMESTAMP_PATTERN);
        this.initActivityStreamAction("/do/ActivityStream", "viewMore", actionRecordDate);
        this.setUserOnSession("admin");
        result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        activityStreamAction = (ActivityStreamAction) this.getAction();
        List<Integer> viewMore = activityStreamAction.getActionRecordIds();
        assertEquals(1, viewMore.size());
        assertEquals(firstRecord.getId(), viewMore.get(0).intValue());
    } catch (Throwable t) {
        throw t;
    } finally {
        this._contentManager.deleteContent(content);
        assertNull(this._contentManager.loadContent(contentId, false));
    }
}
Also used : ActionLogRecord(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActivityStreamSeachBean(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamSeachBean) ActionLogRecordSearchBean(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean) Date(java.util.Date)

Example 4 with ActivityStreamSeachBean

use of org.entando.entando.aps.system.services.actionlog.model.ActivityStreamSeachBean in project entando-core by entando.

the class ActivityStreamAction method update.

public String update() {
    List<Integer> actionRecordIds = new ArrayList<Integer>();
    try {
        Date timestamp = this.getTimestamp();
        if (timestamp != null) {
            timestamp.setTime(timestamp.getTime() + 100);
        }
        ActivityStreamSeachBean searchBean = new ActivityStreamSeachBean();
        List<Group> userGroups = this.getAuthorizationManager().getUserGroups(this.getCurrentUser());
        searchBean.setUserGroupCodes(groupsToStringCode(userGroups));
        searchBean.setStartUpdate(timestamp);
        searchBean.setEndUpdate(new Date());
        actionRecordIds = this.getActionLogManager().getActionRecords(searchBean);
    } catch (Throwable t) {
        _logger.error("Error on loading updated activities", t);
    }
    this.setActionRecordIds(actionRecordIds);
    return SUCCESS;
}
Also used : Group(com.agiletec.aps.system.services.group.Group) ActivityStreamSeachBean(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamSeachBean) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 5 with ActivityStreamSeachBean

use of org.entando.entando.aps.system.services.actionlog.model.ActivityStreamSeachBean in project entando-core by entando.

the class ActivityStreamAction method viewMore.

public String viewMore() {
    List<Integer> actionRecordIds = new ArrayList<Integer>();
    try {
        Date timestamp = this.getTimestamp();
        ActivityStreamSeachBean searchBean = new ActivityStreamSeachBean();
        List<Group> userGroups = this.getAuthorizationManager().getUserGroups(this.getCurrentUser());
        searchBean.setUserGroupCodes(groupsToStringCode(userGroups));
        if (timestamp != null) {
            timestamp.setTime(timestamp.getTime() - 100);
        }
        searchBean.setEndCreation(timestamp);
        actionRecordIds = this.getActionLogManager().getActionRecords(searchBean);
    } catch (Throwable t) {
        _logger.error("Error on loading more activities", t);
    }
    this.setActionRecordIds(actionRecordIds);
    return SUCCESS;
}
Also used : Group(com.agiletec.aps.system.services.group.Group) ActivityStreamSeachBean(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamSeachBean) ArrayList(java.util.ArrayList) Date(java.util.Date)

Aggregations

Date (java.util.Date)5 ActivityStreamSeachBean (org.entando.entando.aps.system.services.actionlog.model.ActivityStreamSeachBean)5 Group (com.agiletec.aps.system.services.group.Group)2 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)2 ArrayList (java.util.ArrayList)2 ActionLogRecord (org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord)2 ActionLogRecordSearchBean (org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordSearchBean)2 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1