/** * Method to remove tags in the index that don't exist in the database * * @param indexName the name of the index * @param documentType the document type * @param tagEntityList list of tags in the database */ private void removeAnyIndexDocumentsThatAreNotInTagsList(final String indexName, final String documentType, List<TagEntity> tagEntityList) { // Get a list of tag ids from the list of tag entities in the database List<String> databaseTagIdList = new ArrayList<>(); tagEntityList.forEach(tagEntity -> databaseTagIdList.add(tagEntity.getId().toString())); // Get a list of tag ids in the search index List<String> indexDocumentTagIdList = indexFunctionsDao.getIdsInIndex(indexName, documentType); // Remove the database ids from the index ids indexDocumentTagIdList.removeAll(databaseTagIdList); // If there are any ids left in the index list they need to be removed indexDocumentTagIdList.forEach(id -> indexFunctionsDao.deleteDocumentById(indexName, documentType, id)); }
/** * Method to remove tags in the index that don't exist in the database * * @param indexName the name of the index * @param documentType the document type * @param tagEntityList list of tags in the database */ private void removeAnyIndexDocumentsThatAreNotInTagsList(final String indexName, final String documentType, List<TagEntity> tagEntityList) { // Get a list of tag ids from the list of tag entities in the database List<String> databaseTagIdList = new ArrayList<>(); tagEntityList.forEach(tagEntity -> databaseTagIdList.add(tagEntity.getId().toString())); // Get a list of tag ids in the search index List<String> indexDocumentTagIdList = indexFunctionsDao.getIdsInIndex(indexName, documentType); // Remove the database ids from the index ids indexDocumentTagIdList.removeAll(databaseTagIdList); // If there are any ids left in the index list they need to be removed indexDocumentTagIdList.forEach(id -> indexFunctionsDao.deleteDocumentById(indexName, documentType, id)); }
/** * Method to remove business object definitions in the index that don't exist in the database * * @param indexName the name of the index * @param documentType the document type * @param businessObjectDefinitionEntityList list of business object definitions in the database */ private void removeAnyIndexDocumentsThatAreNotInBusinessObjectsDefinitionsList(final String indexName, final String documentType, List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntityList) { // Get a list of business object definition ids from the list of business object definition entities in the database List<String> databaseBusinessObjectDefinitionIdList = new ArrayList<>(); businessObjectDefinitionEntityList .forEach(businessObjectDefinitionEntity -> databaseBusinessObjectDefinitionIdList.add(businessObjectDefinitionEntity.getId().toString())); // Get a list of business object definition ids in the search index List<String> indexDocumentBusinessObjectDefinitionIdList = indexFunctionsDao.getIdsInIndex(indexName, documentType); // Remove the database ids from the index ids indexDocumentBusinessObjectDefinitionIdList.removeAll(databaseBusinessObjectDefinitionIdList); // If there are any ids left in the index list they need to be removed indexDocumentBusinessObjectDefinitionIdList.forEach(id -> indexFunctionsDao.deleteDocumentById(indexName, documentType, id)); }
/** * Method to remove business object definitions in the index that don't exist in the database * * @param indexName the name of the index * @param documentType the document type * @param businessObjectDefinitionEntityList list of business object definitions in the database */ private void removeAnyIndexDocumentsThatAreNotInBusinessObjectsDefinitionsList(final String indexName, final String documentType, List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntityList) { // Get a list of business object definition ids from the list of business object definition entities in the database List<String> databaseBusinessObjectDefinitionIdList = new ArrayList<>(); businessObjectDefinitionEntityList .forEach(businessObjectDefinitionEntity -> databaseBusinessObjectDefinitionIdList.add(businessObjectDefinitionEntity.getId().toString())); // Get a list of business object definition ids in the search index List<String> indexDocumentBusinessObjectDefinitionIdList = indexFunctionsDao.getIdsInIndex(indexName, documentType); // Remove the database ids from the index ids indexDocumentBusinessObjectDefinitionIdList.removeAll(databaseBusinessObjectDefinitionIdList); // If there are any ids left in the index list they need to be removed indexDocumentBusinessObjectDefinitionIdList.forEach(id -> indexFunctionsDao.deleteDocumentById(indexName, documentType, id)); }
.executeFunctionForBusinessObjectDefinitionEntities(eq(SEARCH_INDEX_NAME), eq(SEARCH_INDEX_DOCUMENT_TYPE), eq(businessObjectDefinitionEntityList), any()); verify(indexFunctionsDao, times(businessObjectDefinitionEntityIdList.size())).deleteDocumentById(any(), any(), any()); verifyNoMoreInteractionsHelper();