protected Long getExecuteByUserId(final Map<String, Serializable> parameters) { Serializable executeByUserId = parameters.get(USER_ID_KEY); // executeByUserId is not defined when the use is doing the task by himself if (executeByUserId == null) { return SessionInfos.getSessionInfos().getUserId(); } return (Long) executeByUserId; }
protected Long getExecuteByUserId(final Map<String, Serializable> parameters) { Serializable executeByUserId = parameters.get(USER_ID_KEY); // executeByUserId is not defined when the use is doing the task by himself if (executeByUserId == null) { return SessionInfos.getSessionInfos().getUserId(); } return (Long) executeByUserId; }
protected void addSystemCommentOnProcessInstanceWhenExecutingTaskFor(final SFlowNodeInstance flowNodeInstance, final long executerUserId, final long executerSubstituteUserId) { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final TechnicalLoggerService logger = tenantAccessor.getTechnicalLoggerService(); final SCommentService commentService = tenantAccessor.getCommentService(); final SessionInfos session = SessionInfos.getSessionInfos(); if (executerUserId != executerSubstituteUserId) { final IdentityService identityService = tenantAccessor.getIdentityService(); try { final SUser executerUser = identityService.getUser(executerUserId); final StringBuilder stb = new StringBuilder(); stb.append("The user " + session.getUsername() + " "); stb.append("acting as delegate of the user " + executerUser.getUserName() + " "); stb.append("has done the task \"" + flowNodeInstance.getDisplayName() + "\"."); commentService.addSystemComment(flowNodeInstance.getParentProcessInstanceId(), stb.toString()); } catch (final SBonitaException e) { logger.log(this.getClass(), TechnicalLogSeverity.ERROR, "Error when adding a comment on the process instance.", e); } } } }
protected void addSystemCommentOnProcessInstanceWhenExecutingTaskFor(final SFlowNodeInstance flowNodeInstance, final long executerUserId, final long executerSubstituteUserId) { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final TechnicalLoggerService logger = tenantAccessor.getTechnicalLoggerService(); final SCommentService commentService = tenantAccessor.getCommentService(); final SessionInfos session = SessionInfos.getSessionInfos(); if (executerUserId != executerSubstituteUserId) { final IdentityService identityService = tenantAccessor.getIdentityService(); try { final SUser executerUser = identityService.getUser(executerUserId); final StringBuilder stb = new StringBuilder(); stb.append("The user " + session.getUsername() + " "); stb.append("acting as delegate of the user " + executerUser.getUserName() + " "); stb.append("has done the task \"" + flowNodeInstance.getDisplayName() + "\"."); commentService.addSystemComment(flowNodeInstance.getParentProcessInstanceId(), stb.toString()); } catch (final SBonitaException e) { logger.log(this.getClass(), TechnicalLogSeverity.ERROR, "Error when adding a comment on the process instance.", e); } } } }
protected void executeActivity(final SFlowNodeInstance flowNodeInstance, long executerUserId) throws SFlowNodeReadException, SFlowNodeExecutionException { final TenantServiceAccessor tenantAccessor = TenantServiceSingleton.getInstance(getTenantId()); final ProcessExecutor processExecutor = tenantAccessor.getProcessExecutor(); final TechnicalLoggerService logger = tenantAccessor.getTechnicalLoggerService(); final SessionInfos sessionInfos = SessionInfos.getSessionInfos(); final long executerSubstituteId = sessionInfos.getUserId(); // no need to handle failed state, all is in the same tx, if the node fail we just have an exception on client side + rollback processExecutor.executeFlowNode(flowNodeInstance.getId(), executerUserId, executerSubstituteId); if (logger.isLoggable(getClass(), TechnicalLogSeverity.INFO) && flowNodeInstance.getStateId() != 0 /* don't log when create subtask */) { final String message = LogMessageBuilder.buildExecuteTaskContextMessage(flowNodeInstance, sessionInfos.getUsername(), executerUserId, executerSubstituteId, null); // no inputs taken in this LEGACY command for old-version web form execution logger.log(getClass(), TechnicalLogSeverity.INFO, message); } addSystemCommentOnProcessInstanceWhenExecutingTaskFor(flowNodeInstance, executerUserId, executerSubstituteId); }
protected void executeActivity(final SFlowNodeInstance flowNodeInstance, long executerUserId) throws SFlowNodeReadException, SFlowNodeExecutionException { final TenantServiceAccessor tenantAccessor = TenantServiceSingleton.getInstance(getTenantId()); final ProcessExecutor processExecutor = tenantAccessor.getProcessExecutor(); final TechnicalLoggerService logger = tenantAccessor.getTechnicalLoggerService(); final SessionInfos sessionInfos = SessionInfos.getSessionInfos(); final long executerSubstituteId = sessionInfos.getUserId(); // no need to handle failed state, all is in the same tx, if the node fail we just have an exception on client side + rollback processExecutor.executeFlowNode(flowNodeInstance.getId(), executerUserId, executerSubstituteId); if (logger.isLoggable(getClass(), TechnicalLogSeverity.INFO) && flowNodeInstance.getStateId() != 0 /* don't log when create subtask */) { final String message = LogMessageBuilder.buildExecuteTaskContextMessage(flowNodeInstance, sessionInfos.getUsername(), executerUserId, executerSubstituteId, null); // no inputs taken in this LEGACY command for old-version web form execution logger.log(getClass(), TechnicalLogSeverity.INFO, message); } addSystemCommentOnProcessInstanceWhenExecutingTaskFor(flowNodeInstance, executerUserId, executerSubstituteId); }