@Test public void should_find_collection_by_processid_tenant_status() { populateDatabase(auditReportEntryKO, auditReportEntryOK, auditReportEntryWARNING); MongoCursor<Document> iterator = repository.findCollectionByProcessIdTenantAndStatus(processId, TENANT_ID, "WARNING", "KO"); List<Document> documents = new ArrayList<>(); while (iterator.hasNext()) { Document reportModel = iterator.next(); documents.add(reportModel); } assertThat(documents.size()).isEqualTo(2); }
public MongoCursor<Document> findCollectionByProcessIdTenantAndStatus(String processId, int tenantId, String... status) { Bson eqProcessId = eq(AuditObjectGroupModel.PROCESS_ID, processId); Bson eqTenant = eq(AuditObjectGroupModel.TENANT, tenantId); Bson inStatus = or(in(AuditObjectGroupModel.METADATA + ".status", status), in(AuditObjectGroupModel.METADATA + ".objectVersions.status", status)); return objectGroupReportCollection .aggregate(Arrays.asList(Aggregates.match(and(eqProcessId, eqTenant, inStatus)), Aggregates.project(reportProjection()))) .allowDiskUse(true).iterator(); }
AuditReportRepository extends ReportCommonRepository { public MongoCursor<Document> findCollectionByProcessIdTenantAndStatus(String processId, int tenantId, String... status) { Bson eqProcessId = eq(AuditObjectGroupModel.PROCESS_ID, processId); Bson eqTenant = eq(AuditObjectGroupModel.TENANT, tenantId); Bson inStatus = or(in(AuditObjectGroupModel.METADATA + ".status", status), in(AuditObjectGroupModel.METADATA + ".objectVersions.status", status)); return objectGroupReportCollection .aggregate(Arrays.asList(Aggregates.match(and(eqProcessId, eqTenant, inStatus)), Aggregates.project(reportProjection()))) .allowDiskUse(true).iterator(); } }
AuditReportRepository extends ReportCommonRepository { public MongoCursor<Document> findCollectionByProcessIdTenantAndStatus(String processId, int tenantId, String... status) { Bson eqProcessId = eq(AuditObjectGroupModel.PROCESS_ID, processId); Bson eqTenant = eq(AuditObjectGroupModel.TENANT, tenantId); Bson inStatus = or(in(AuditObjectGroupModel.METADATA + ".status", status), in(AuditObjectGroupModel.METADATA + ".objectVersions.status", status)); return objectGroupReportCollection .aggregate(Arrays.asList(Aggregates.match(and(eqProcessId, eqTenant, inStatus)), Aggregates.project(reportProjection()))) .allowDiskUse(true).iterator(); } @VisibleForTesting  AuditReportRepository(MongoDbAccess mongoDbAccess, String collectionName);  AuditReportRepository(MongoDbAccess mongoDbAccess); }
AuditReportRepository extends ReportCommonRepository { public MongoCursor<Document> findCollectionByProcessIdTenantAndStatus(String processId, int tenantId, String... status) { Bson eqProcessId = eq(AuditObjectGroupModel.PROCESS_ID, processId); Bson eqTenant = eq(AuditObjectGroupModel.TENANT, tenantId); Bson inStatus = or(in(AuditObjectGroupModel.METADATA + ".status", status), in(AuditObjectGroupModel.METADATA + ".objectVersions.status", status)); return objectGroupReportCollection .aggregate(Arrays.asList(Aggregates.match(and(eqProcessId, eqTenant, inStatus)), Aggregates.project(reportProjection()))) .allowDiskUse(true).iterator(); } @VisibleForTesting  AuditReportRepository(MongoDbAccess mongoDbAccess, String collectionName);  AuditReportRepository(MongoDbAccess mongoDbAccess); void bulkAppendReport(List<AuditObjectGroupModel> reports); void deleteReportByIdAndTenant(String processId, int tenantId); ReportResults computeVitamResults(String processId, Integer tenantId); MongoCursor<Document> findCollectionByProcessIdTenantAndStatus(String processId, int tenantId,
            String... status); MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId); AuditStatsModel stats(String processId, int tenantId); }
AuditReportRepository extends ReportCommonRepository { public MongoCursor<Document> findCollectionByProcessIdTenantAndStatus(String processId, int tenantId, String... status) { Bson eqProcessId = eq(AuditObjectGroupModel.PROCESS_ID, processId); Bson eqTenant = eq(AuditObjectGroupModel.TENANT, tenantId); Bson inStatus = or(in(AuditObjectGroupModel.METADATA + ".status", status), in(AuditObjectGroupModel.METADATA + ".objectVersions.status", status)); return objectGroupReportCollection .aggregate(Arrays.asList(Aggregates.match(and(eqProcessId, eqTenant, inStatus)), Aggregates.project(reportProjection()))) .allowDiskUse(true).iterator(); } @VisibleForTesting  AuditReportRepository(MongoDbAccess mongoDbAccess, String collectionName);  AuditReportRepository(MongoDbAccess mongoDbAccess); void bulkAppendReport(List<AuditObjectGroupModel> reports); void deleteReportByIdAndTenant(String processId, int tenantId); ReportResults computeVitamResults(String processId, Integer tenantId); MongoCursor<Document> findCollectionByProcessIdTenantAndStatus(String processId, int tenantId,
            String... status); MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId); AuditStatsModel stats(String processId, int tenantId); static final String AUDIT_OBJECT_GROUP; }