use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType in project midpoint by Evolveum.
the class CertWorkItemDtoProvider method internalSize.
// TODO replace searchDecisions with countDecisions (when it will be available)
@Override
protected int internalSize() {
LOGGER.trace("begin::internalSize()");
int count = 0;
OperationResult result = new OperationResult(OPERATION_COUNT_OBJECTS);
try {
Task task = getPage().createSimpleTask(OPERATION_COUNT_OBJECTS);
AccessCertificationService acs = getPage().getCertificationService();
ObjectQuery query = getQuery().clone();
// when counting decisions we need to exclude offset+size (and sorting info is irrelevant)
query.setPaging(null);
List<AccessCertificationWorkItemType> workItems = acs.searchOpenWorkItems(query, notDecidedOnly, null, task, result);
count = workItems.size();
} catch (Exception ex) {
result.recordFatalError("Couldn't count objects.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count objects", ex);
} finally {
result.computeStatusIfUnknown();
}
if (!WebComponentUtil.isSuccessOrHandledError(result)) {
getPage().showResult(result);
throw new RestartResponseException(PageError.class);
}
LOGGER.trace("end::internalSize()");
return count;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType in project midpoint by Evolveum.
the class AbstractCertificationTest method recordDecision.
protected void recordDecision(String campaignOid, AccessCertificationCaseType _case, AccessCertificationResponseType response, String comment, String reviewerOid, Task task, OperationResult result) throws CommunicationException, ObjectNotFoundException, ObjectAlreadyExistsException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
Authentication originalAuthentication = null;
String realReviewerOid;
if (reviewerOid != null) {
originalAuthentication = SecurityContextHolder.getContext().getAuthentication();
login(getUser(reviewerOid));
realReviewerOid = reviewerOid;
} else {
realReviewerOid = securityEnforcer.getPrincipal().getOid();
}
List<AccessCertificationWorkItemType> workItems = _case.getWorkItem().stream().filter(wi -> ObjectTypeUtil.containsOid(wi.getAssigneeRef(), realReviewerOid)).filter(wi -> wi.getStageNumber() == _case.getStageNumber()).collect(Collectors.toList());
assertEquals("Wrong # of current work items for " + realReviewerOid + " in " + _case, 1, workItems.size());
long id = _case.asPrismContainerValue().getId();
certificationManager.recordDecision(campaignOid, id, workItems.get(0).getId(), response, comment, task, result);
if (reviewerOid != null) {
SecurityContextHolder.getContext().setAuthentication(originalAuthentication);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType in project midpoint by Evolveum.
the class AccCertCaseOperationsHelper method getDeltasToAdvanceCases.
List<ItemDelta<?, ?>> getDeltasToAdvanceCases(AccessCertificationCampaignType campaign, AccessCertificationStageType stage, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
LOGGER.trace("Advancing reviewers and timestamps for cases in {}", toShortString(campaign));
List<AccessCertificationCaseType> caseList = queryHelper.searchCases(campaign.getOid(), null, null, result);
List<ItemDelta<?, ?>> rv = new ArrayList<>(caseList.size());
int stageToBe = campaign.getStageNumber() + 1;
List<AccessCertificationResponseType> outcomesToStopOn = computationHelper.getOutcomesToStopOn(campaign);
AccessCertificationReviewerSpecificationType reviewerSpec = reviewersHelper.findReviewersSpecification(campaign, stageToBe, task, result);
for (AccessCertificationCaseType _case : caseList) {
if (!computationHelper.computeEnabled(campaign, _case, outcomesToStopOn)) {
continue;
}
Long caseId = _case.asPrismContainerValue().getId();
assert caseId != null;
List<ObjectReferenceType> reviewers = reviewersHelper.getReviewersForCase(_case, campaign, reviewerSpec, task, result);
List<AccessCertificationWorkItemType> workItems = createWorkItems(reviewers, stageToBe);
_case.getWorkItem().addAll(CloneUtil.cloneCollectionMembers(workItems));
AccessCertificationResponseType currentOutcome = computationHelper.computeOutcomeForStage(_case, campaign, stageToBe);
AccessCertificationResponseType overallOutcome = computationHelper.computeOverallOutcome(_case, campaign, currentOutcome);
rv.addAll(DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, caseId, F_WORK_ITEM).add(PrismContainerValue.toPcvList(workItems)).item(F_CASE, caseId, F_CURRENT_STAGE_CREATE_TIMESTAMP).replace(stage.getStartTimestamp()).item(F_CASE, caseId, F_CURRENT_STAGE_DEADLINE).replace(stage.getDeadline()).item(F_CASE, caseId, F_CURRENT_STAGE_OUTCOME).replace(OutcomeUtils.toUri(currentOutcome)).item(F_CASE, caseId, F_OUTCOME).replace(OutcomeUtils.toUri(overallOutcome)).item(F_CASE, caseId, F_STAGE_NUMBER).replace(stageToBe).asItemDeltas());
}
LOGGER.debug("Created {} deltas to advance {} cases for campaign {}", rv.size(), caseList.size(), toShortString(campaign));
return rv;
}
Aggregations