@Override public void archive(final long archiveDate, final SComment sComment) throws SObjectModificationException { final SAComment saComment = BuilderFactory.get(SACommentBuilderFactory.class).createNewInstance(sComment).done(); if (saComment != null) { final ArchiveInsertRecord insertRecord = new ArchiveInsertRecord(saComment); try { archiveService.recordInsert(archiveDate, insertRecord); } catch (final SRecorderException e) { throw new SObjectModificationException("Unable to archive the comment with id = <" + sComment.getId() + ">", e); } } }
SearchArchivedCommentsDescriptor() { SACommentBuilderFactory saCommentBuilderFact = BuilderFactory.get(SACommentBuilderFactory.class); searchEntityKeys = new HashMap<>(7); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.PROCESS_INSTANCE_ID, new FieldDescriptor(SAComment.class, saCommentBuilderFact.getProcessInstanceIdKey())); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.POSTED_BY_ID, new FieldDescriptor(SAComment.class, saCommentBuilderFact.getUserIdKey())); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.ID, new FieldDescriptor(SAComment.class, saCommentBuilderFact.getIdKey())); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.POSTDATE, new FieldDescriptor(SAComment.class, saCommentBuilderFact.getPostDateKey())); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.SOURCE_OBJECT_ID, new FieldDescriptor(SAComment.class, saCommentBuilderFact.getSourceObjectId())); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.CONTENT, new FieldDescriptor(SAComment.class, saCommentBuilderFact.getContentKey())); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.USER_NAME, new FieldDescriptor(SUser.class, BuilderFactory.get(SUserBuilderFactory.class).getUserNameKey())); archivedCommentsAllFields = new HashMap<>(1); final Set<String> archivedCommentFields = new HashSet<>(1); archivedCommentFields.add(saCommentBuilderFact.getContentKey()); archivedCommentsAllFields.put(SAComment.class, archivedCommentFields); }
private void deleteArchivedComments(final long processInstanceId) throws SBonitaException { final List<FilterOption> filters = Collections.singletonList(new FilterOption(SAComment.class, BuilderFactory.get(SACommentBuilderFactory.class) .getProcessInstanceIdKey(), processInstanceId)); final List<OrderByOption> orderByOptions = Collections.singletonList(new OrderByOption(SAComment.class, BuilderFactory.get( SACommentBuilderFactory.class).getIdKey(), OrderByType.ASC)); List<SAComment> searchArchivedComments; // fromIndex always will be zero because the elements will be deleted final QueryOptions queryOptions = new QueryOptions(0, 100, orderByOptions, filters, null); do { searchArchivedComments = commentService.searchArchivedComments(queryOptions); for (final SAComment saComment : searchArchivedComments) { archiveService.recordDelete(new DeleteRecord(saComment)); } } while (!searchArchivedComments.isEmpty()); }
@Override public List<Long> getSourceProcessInstanceIdsOfArchProcessInstancesFromDefinition(final long processDefinitionId, final int fromIndex, final int maxResults, final OrderByType sortingOrder) throws SProcessInstanceReadException { final ReadPersistenceService persistenceService = archiveService.getDefinitiveArchiveReadPersistenceService(); final String saCommentSourceObjectId = BuilderFactory.get(SACommentBuilderFactory.class).getSourceObjectId(); final QueryOptions queryOptions = new QueryOptions(fromIndex, maxResults, SAProcessInstance.class, saCommentSourceObjectId, sortingOrder); try { return persistenceService.selectList(SelectDescriptorBuilder.getSourceProcesInstanceIdsOfArchProcessInstancesFromDefinition(processDefinitionId, queryOptions)); } catch (final SBonitaReadException e) { throw new SProcessInstanceReadException(e); } }
SearchArchivedCommentsDescriptor() { SACommentBuilderFactory saCommentBuilderFact = BuilderFactory.get(SACommentBuilderFactory.class); searchEntityKeys = new HashMap<>(7); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.PROCESS_INSTANCE_ID, new FieldDescriptor(SAComment.class, saCommentBuilderFact.getProcessInstanceIdKey())); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.POSTED_BY_ID, new FieldDescriptor(SAComment.class, saCommentBuilderFact.getUserIdKey())); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.ID, new FieldDescriptor(SAComment.class, saCommentBuilderFact.getIdKey())); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.POSTDATE, new FieldDescriptor(SAComment.class, saCommentBuilderFact.getPostDateKey())); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.SOURCE_OBJECT_ID, new FieldDescriptor(SAComment.class, saCommentBuilderFact.getSourceObjectId())); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.CONTENT, new FieldDescriptor(SAComment.class, saCommentBuilderFact.getContentKey())); searchEntityKeys.put(ArchivedCommentsSearchDescriptor.USER_NAME, new FieldDescriptor(SUser.class, BuilderFactory.get(SUserBuilderFactory.class).getUserNameKey())); archivedCommentsAllFields = new HashMap<>(1); final Set<String> archivedCommentFields = new HashSet<>(1); archivedCommentFields.add(saCommentBuilderFact.getContentKey()); archivedCommentsAllFields.put(SAComment.class, archivedCommentFields); }
private void deleteArchivedComments(final long processInstanceId) throws SBonitaException { final List<FilterOption> filters = Collections.singletonList(new FilterOption(SAComment.class, BuilderFactory.get(SACommentBuilderFactory.class) .getProcessInstanceIdKey(), processInstanceId)); final List<OrderByOption> orderByOptions = Collections.singletonList(new OrderByOption(SAComment.class, BuilderFactory.get( SACommentBuilderFactory.class).getIdKey(), OrderByType.ASC)); List<SAComment> searchArchivedComments; // fromIndex always will be zero because the elements will be deleted final QueryOptions queryOptions = new QueryOptions(0, 100, orderByOptions, filters, null); do { searchArchivedComments = commentService.searchArchivedComments(queryOptions); for (final SAComment saComment : searchArchivedComments) { archiveService.recordDelete(new DeleteRecord(saComment)); } } while (!searchArchivedComments.isEmpty()); }
@Override public void archive(final long archiveDate, final SComment sComment) throws SObjectModificationException { final SAComment saComment = BuilderFactory.get(SACommentBuilderFactory.class).createNewInstance(sComment).done(); if (saComment != null) { final ArchiveInsertRecord insertRecord = new ArchiveInsertRecord(saComment); try { archiveService.recordInsert(archiveDate, insertRecord); } catch (final SRecorderException e) { throw new SObjectModificationException("Unable to archive the comment with id = <" + sComment.getId() + ">", e); } } }
@Override public List<Long> getSourceProcessInstanceIdsOfArchProcessInstancesFromDefinition(final long processDefinitionId, final int fromIndex, final int maxResults, final OrderByType sortingOrder) throws SProcessInstanceReadException { final ReadPersistenceService persistenceService = archiveService.getDefinitiveArchiveReadPersistenceService(); final String saCommentSourceObjectId = BuilderFactory.get(SACommentBuilderFactory.class).getSourceObjectId(); final QueryOptions queryOptions = new QueryOptions(fromIndex, maxResults, SAProcessInstance.class, saCommentSourceObjectId, sortingOrder); try { return persistenceService.selectList(SelectDescriptorBuilder.getSourceProcesInstanceIdsOfArchProcessInstancesFromDefinition(processDefinitionId, queryOptions)); } catch (final SBonitaReadException e) { throw new SProcessInstanceReadException(e); } }