private void cleanupCampaignsByNumber(int maxRecords, Task task, OperationResult parentResult) { OperationResult result = parentResult.createSubresult(OPERATION_CLEANUP_CAMPAIGNS_BY_NUMBER); LOGGER.info("Starting cleanup for closed certification campaigns, keeping {} ones.", maxRecords); int deleted = 0; Set<String> poisonedCampaigns = new HashSet<>(); try { for (;;) { ObjectQuery query = prismContext.queryFor(AccessCertificationCampaignType.class) .item(AccessCertificationCampaignType.F_STATE).eq(AccessCertificationCampaignStateType.CLOSED) .and().not().id(poisonedCampaigns.toArray(new String[0])) // hoping there are not many of these .desc(AccessCertificationCampaignType.F_END_TIMESTAMP) .offset(maxRecords) .maxSize(DELETE_BLOCK_SIZE) .build(); int delta = searchAndDeleteCampaigns(query, poisonedCampaigns, result, task); if (delta == 0) { LOGGER.info("Deleted {} campaigns.", deleted); return; } } } finally { result.computeStatusIfUnknown(); } }
.item(F_WORKFLOW_CONTEXT, F_REQUESTER_REF).ref("123456") .and().not().item(F_WORKFLOW_CONTEXT, F_PROCESS_INSTANCE_ID).isNull() .desc(F_WORKFLOW_CONTEXT, F_START_TIMESTAMP) .build(); String real = getInterpretedQuery2(session, TaskType.class, query);
.item(AccessCertificationCampaignType.F_STATE).eq(AccessCertificationCampaignStateType.CLOSED) .and().not().id("10-10-10-10-10") // hoping there are not many of these .desc(AccessCertificationCampaignType.F_END_TIMESTAMP) .offset(100) .maxSize(20)
ObjectQuery query = prismContext.queryFor(AccessCertificationCaseType.class) .item(AccessCertificationCaseType.F_OBJECT_REF).ref(userAdministrator.getOid()) .desc(AccessCertificationCaseType.F_TARGET_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME) .offset(2).maxSize(2) .build();