@Test public void should_bulk_append_objectgroup_report() throws Exception { List<PurgeObjectGroupModel> purgeObjectGroupModels = getDocuments("/purgeObjectGroupModel.json"); repository.bulkAppendReport(purgeObjectGroupModels); Document first = purgeObjectGroupCollection.find(and(eq(PurgeObjectGroupModel.METADATA + "." + "id", "id2"), eq(PurgeObjectGroupModel.TENANT, 0))).first(); assertThat(first).isNotNull() .containsEntry("processId", "123456789") .containsEntry("_tenant", 0) .containsKeys("_metadata"); Object metadata = first.get("_metadata"); JsonNode metadataNode = JsonHandler.toJsonNode(metadata); JsonNode expected = JsonHandler.getFromString( "{\"id\":\"id2\",\"opi\":\"opi0\",\"originatingAgency\":\"sp1\",\"status\":\"DELETED\",\"objectIds\":[\"parent\",\"parent2\"],\"objectVersions\":[{\"opi\":\"opi0\",\"size\":3},{\"opi\":\"opi0add\",\"size\":6}]}"); assertThat(metadataNode).isNotNull().isEqualTo(expected); }
public void bulkAppendReport(List<PurgeObjectGroupModel> reports) { Set<PurgeObjectGroupModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> purgeObjectGroupDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(purgeObjectGroupDocument, objectGroupReportCollection); }
PurgeObjectGroupRepository extends ReportCommonRepository { public void bulkAppendReport(List<PurgeObjectGroupModel> reports) { Set<PurgeObjectGroupModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> purgeObjectGroupDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(purgeObjectGroupDocument, objectGroupReportCollection); } }
PurgeObjectGroupRepository extends ReportCommonRepository { public void bulkAppendReport(List<PurgeObjectGroupModel> reports) { Set<PurgeObjectGroupModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> purgeObjectGroupDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(purgeObjectGroupDocument, objectGroupReportCollection); } @VisibleForTesting  PurgeObjectGroupRepository(MongoDbAccess mongoDbAccess, String collectionName);  PurgeObjectGroupRepository(MongoDbAccess mongoDbAccess); }
PurgeObjectGroupRepository extends ReportCommonRepository { public void bulkAppendReport(List<PurgeObjectGroupModel> reports) { Set<PurgeObjectGroupModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> purgeObjectGroupDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(purgeObjectGroupDocument, objectGroupReportCollection); } @VisibleForTesting  PurgeObjectGroupRepository(MongoDbAccess mongoDbAccess, String collectionName);  PurgeObjectGroupRepository(MongoDbAccess mongoDbAccess); void bulkAppendReport(List<PurgeObjectGroupModel> reports); MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId); void deleteReportByIdAndTenant(String processId, int tenantId); MongoCursor<Document> computeOwnAccessionRegisterDetails(String processId, int tenantId); }
PurgeObjectGroupRepository extends ReportCommonRepository { public void bulkAppendReport(List<PurgeObjectGroupModel> reports) { Set<PurgeObjectGroupModel> reportsWithoutDuplicate = new HashSet<>(reports); List<Document> purgeObjectGroupDocument = reportsWithoutDuplicate.stream() .map(ReportCommonRepository::pojoToDocument) .collect(Collectors.toList()); super.bulkAppendReport(purgeObjectGroupDocument, objectGroupReportCollection); } @VisibleForTesting  PurgeObjectGroupRepository(MongoDbAccess mongoDbAccess, String collectionName);  PurgeObjectGroupRepository(MongoDbAccess mongoDbAccess); void bulkAppendReport(List<PurgeObjectGroupModel> reports); MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId); void deleteReportByIdAndTenant(String processId, int tenantId); MongoCursor<Document> computeOwnAccessionRegisterDetails(String processId, int tenantId); static final String PURGE_OBJECT_GROUP; static final String OPI_GOT; }