Search in sources :

Example 1 with HistoricIdentityLinkEntity

use of org.activiti.engine.impl.persistence.entity.HistoricIdentityLinkEntity in project Activiti by Activiti.

the class GetHistoricIdentityLinksForTaskCmd method getLinksForTask.

@SuppressWarnings({ "unchecked", "rawtypes" })
protected List<HistoricIdentityLink> getLinksForTask(CommandContext commandContext) {
    HistoricTaskInstanceEntity task = commandContext.getHistoricTaskInstanceEntityManager().findHistoricTaskInstanceById(taskId);
    if (task == null) {
        throw new ActivitiObjectNotFoundException("No historic task exists with the given id: " + taskId, HistoricTaskInstance.class);
    }
    List<HistoricIdentityLink> identityLinks = (List) commandContext.getHistoricIdentityLinkEntityManager().findHistoricIdentityLinksByTaskId(taskId);
    // Similar to GetIdentityLinksForTask, return assignee and owner as identity link
    if (task.getAssignee() != null) {
        HistoricIdentityLinkEntity identityLink = new HistoricIdentityLinkEntity();
        identityLink.setUserId(task.getAssignee());
        identityLink.setTaskId(task.getId());
        identityLink.setType(IdentityLinkType.ASSIGNEE);
        identityLinks.add(identityLink);
    }
    if (task.getOwner() != null) {
        HistoricIdentityLinkEntity identityLink = new HistoricIdentityLinkEntity();
        identityLink.setTaskId(task.getId());
        identityLink.setUserId(task.getOwner());
        identityLink.setType(IdentityLinkType.OWNER);
        identityLinks.add(identityLink);
    }
    return identityLinks;
}
Also used : HistoricIdentityLink(org.activiti.engine.history.HistoricIdentityLink) List(java.util.List) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) HistoricTaskInstanceEntity(org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity) HistoricIdentityLinkEntity(org.activiti.engine.impl.persistence.entity.HistoricIdentityLinkEntity)

Example 2 with HistoricIdentityLinkEntity

use of org.activiti.engine.impl.persistence.entity.HistoricIdentityLinkEntity in project Activiti by Activiti.

the class DefaultHistoryManager method recordIdentityLinkCreated.

// Identity link related history
/* (non-Javadoc)
   * @see org.activiti.engine.impl.history.HistoryManagerInterface#recordIdentityLinkCreated(org.activiti.engine.impl.persistence.entity.IdentityLinkEntity)
   */
@Override
public void recordIdentityLinkCreated(IdentityLinkEntity identityLink) {
    // to a process-definition only as this is never kept in history
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT) && (identityLink.getProcessInstanceId() != null || identityLink.getTaskId() != null)) {
        HistoricIdentityLinkEntity historicIdentityLinkEntity = new HistoricIdentityLinkEntity(identityLink);
        getDbSqlSession().insert(historicIdentityLinkEntity);
    }
}
Also used : HistoricIdentityLinkEntity(org.activiti.engine.impl.persistence.entity.HistoricIdentityLinkEntity)

Aggregations

HistoricIdentityLinkEntity (org.activiti.engine.impl.persistence.entity.HistoricIdentityLinkEntity)2 List (java.util.List)1 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 HistoricIdentityLink (org.activiti.engine.history.HistoricIdentityLink)1 HistoricTaskInstanceEntity (org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity)1