private void addSystemComment(final SFlowNodeInstance flowNodeInstance, final FlowNodeState state) throws SCommentAddException { if (commentService.isCommentEnabled(SystemCommentType.STATE_CHANGE) && state.mustAddSystemComment(flowNodeInstance)) { commentService.addSystemComment(flowNodeInstance.getRootContainerId(), state.getSystemComment(flowNodeInstance)); } }
@Override public List<SAComment> executeSearch(final QueryOptions searchOptions) throws SBonitaReadException { return sCommentService.searchArchivedComments(searchOptions); }
@Override public long executeCount(final QueryOptions searchOptions) throws SBonitaReadException { return sCommentService.getNumberOfArchivedComments(searchOptions); }
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); } } } }
private void archiveComments(final SProcessDefinition processDefinition, final SProcessInstance processInstance, final SCommentService commentService, final long archiveDate) throws SArchivingException { try { List<SComment> sComments; int startIndex = 0; do { sComments = commentService .getComments(processInstance.getId(), new QueryOptions(startIndex, BATCH_SIZE, SComment.class, "id", OrderByType.ASC)); for (final SComment sComment : sComments) { commentService.archive(archiveDate, sComment); } startIndex += BATCH_SIZE; } while (!sComments.isEmpty()); } catch (final SBonitaException e) { setExceptionContext(processDefinition, processInstance, e); throw new SArchivingException("Unable to archive the process instance comments.", e); } }
@Override public long executeCount(QueryOptions searchOptions) throws SBonitaReadException { return commentService.getNumberOfComments(searchOptions); }
@Deprecated @Override public List<Comment> getComments(final long processInstanceId) { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final SCommentService commentService = tenantAccessor.getCommentService(); try { final List<SComment> sComments = commentService.getComments(processInstanceId); return ModelConvertor.toComments(sComments); } catch (final SBonitaReadException sbe) { throw new RetrieveException(sbe); } }
@Override public ArchivedComment getArchivedComment(final long archivedCommentId) throws RetrieveException, NotFoundException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final SCommentService sCommentService = tenantAccessor.getCommentService(); try { final SAComment archivedComment = sCommentService.getArchivedComment(archivedCommentId); return ModelConvertor.toArchivedComment(archivedComment); } catch (final SCommentNotFoundException e) { throw new NotFoundException(e); } catch (final SBonitaException e) { throw new RetrieveException(e); } }
private void deleteElementsOfArchivedProcessInstances(List<Long> sourceProcessInstanceIds) throws SBonitaException { documentService.deleteArchivedDocuments(sourceProcessInstanceIds); connectorInstanceService.deleteArchivedConnectorInstances(sourceProcessInstanceIds, SConnectorInstance.PROCESS_TYPE); dataInstanceService.deleteLocalArchivedDataInstances(sourceProcessInstanceIds, DataInstanceContainer.PROCESS_INSTANCE.toString()); commentService.deleteArchivedComments(sourceProcessInstanceIds); refBusinessDataService.deleteArchivedRefBusinessDataInstance(sourceProcessInstanceIds); contractDataService.deleteArchivedProcessData(sourceProcessInstanceIds); }
protected void deleteProcessInstanceElements(final SProcessInstance processInstance) throws SBonitaException { SProcessDefinition processDefinition = null; try { processDefinition = processDefinitionService.getProcessDefinition(processInstance.getProcessDefinitionId()); } catch (final SProcessDefinitionNotFoundException e) { // delete anyway } deleteFlowNodeInstances(processInstance.getId(), processDefinition); deleteDataInstancesIfNecessary(processInstance, processDefinition); documentService.deleteDocumentsFromProcessInstance(processInstance.getId()); deleteConnectorInstancesIfNecessary(processInstance, processDefinition); commentService.deleteComments(processInstance.getId()); }
@Override public Comment addProcessCommentOnBehalfOfUser(final long processInstanceId, final String comment, long userId) throws CreationException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); try { tenantAccessor.getProcessInstanceService().getProcessInstance(processInstanceId); } catch (final SProcessInstanceReadException | SProcessInstanceNotFoundException e) { throw new RetrieveException(buildCantAddCommentOnProcessInstance(), e); // FIXME: should be another exception } final SCommentService commentService = tenantAccessor.getCommentService(); try { SComment sComment = commentService.addComment(processInstanceId, comment, userId); return ModelConvertor.toComment(sComment); } catch (final SBonitaException e) { throw new CreationException(buildCantAddCommentOnProcessInstance(), e.getCause()); } }
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); } } } }
private void archiveComments(final SProcessDefinition processDefinition, final SProcessInstance processInstance, final SCommentService commentService, final long archiveDate) throws SArchivingException { try { List<SComment> sComments; int startIndex = 0; do { sComments = commentService .getComments(processInstance.getId(), new QueryOptions(startIndex, BATCH_SIZE, SComment.class, "id", OrderByType.ASC)); for (final SComment sComment : sComments) { commentService.archive(archiveDate, sComment); } startIndex += BATCH_SIZE; } while (!sComments.isEmpty()); } catch (final SBonitaException e) { setExceptionContext(processDefinition, processInstance, e); throw new SArchivingException("Unable to archive the process instance comments.", e); } }
@Override public long executeCount(QueryOptions searchOptions) throws SBonitaReadException { return commentService.getNumberOfComments(searchOptions); }
@Deprecated @Override public List<Comment> getComments(final long processInstanceId) { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final SCommentService commentService = tenantAccessor.getCommentService(); try { final List<SComment> sComments = commentService.getComments(processInstanceId); return ModelConvertor.toComments(sComments); } catch (final SBonitaReadException sbe) { throw new RetrieveException(sbe); } }
@Override public ArchivedComment getArchivedComment(final long archivedCommentId) throws RetrieveException, NotFoundException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final SCommentService sCommentService = tenantAccessor.getCommentService(); try { final SAComment archivedComment = sCommentService.getArchivedComment(archivedCommentId); return ModelConvertor.toArchivedComment(archivedComment); } catch (final SCommentNotFoundException e) { throw new NotFoundException(e); } catch (final SBonitaException e) { throw new RetrieveException(e); } }
private void deleteElementsOfArchivedProcessInstances(List<Long> sourceProcessInstanceIds) throws SBonitaException { documentService.deleteArchivedDocuments(sourceProcessInstanceIds); connectorInstanceService.deleteArchivedConnectorInstances(sourceProcessInstanceIds, SConnectorInstance.PROCESS_TYPE); dataInstanceService.deleteLocalArchivedDataInstances(sourceProcessInstanceIds, DataInstanceContainer.PROCESS_INSTANCE.toString()); commentService.deleteArchivedComments(sourceProcessInstanceIds); refBusinessDataService.deleteArchivedRefBusinessDataInstance(sourceProcessInstanceIds); contractDataService.deleteArchivedProcessData(sourceProcessInstanceIds); }
protected void deleteProcessInstanceElements(final SProcessInstance processInstance) throws SBonitaException { SProcessDefinition processDefinition = null; try { processDefinition = processDefinitionService.getProcessDefinition(processInstance.getProcessDefinitionId()); } catch (final SProcessDefinitionNotFoundException e) { // delete anyway } deleteFlowNodeInstances(processInstance.getId(), processDefinition); deleteDataInstancesIfNecessary(processInstance, processDefinition); documentService.deleteDocumentsFromProcessInstance(processInstance.getId()); deleteConnectorInstancesIfNecessary(processInstance, processDefinition); commentService.deleteComments(processInstance.getId()); }
@Override public Comment addProcessCommentOnBehalfOfUser(final long processInstanceId, final String comment, long userId) throws CreationException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); try { tenantAccessor.getProcessInstanceService().getProcessInstance(processInstanceId); } catch (final SProcessInstanceReadException | SProcessInstanceNotFoundException e) { throw new RetrieveException(buildCantAddCommentOnProcessInstance(), e); // FIXME: should be another exception } final SCommentService commentService = tenantAccessor.getCommentService(); try { SComment sComment = commentService.addComment(processInstanceId, comment, userId); return ModelConvertor.toComment(sComment); } catch (final SBonitaException e) { throw new CreationException(buildCantAddCommentOnProcessInstance(), e.getCause()); } }
private void addSystemComment(final SFlowNodeInstance flowNodeInstance, final FlowNodeState state) throws SCommentAddException { if (commentService.isCommentEnabled(SystemCommentType.STATE_CHANGE) && state.mustAddSystemComment(flowNodeInstance)) { commentService.addSystemComment(flowNodeInstance.getRootContainerId(), state.getSystemComment(flowNodeInstance)); } }