use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class PageCertCampaigns method actOnCampaignsPerformed.
private void actOnCampaignsPerformed(AjaxRequestTarget target, String operationName, List<CertCampaignListItemDto> items) {
int processed = 0;
AccessCertificationService acs = getCertificationService();
OperationResult result = new OperationResult(operationName);
for (CertCampaignListItemDto item : items) {
try {
AccessCertificationCampaignType campaign = item.getCampaign();
Task task = createSimpleTask(operationName);
switch(operationName) {
case OPERATION_START_CAMPAIGN:
if (campaign.getState() == AccessCertificationCampaignStateType.CREATED) {
acs.openNextStage(campaign.getOid(), 1, task, result);
processed++;
}
break;
case OPERATION_CLOSE_CAMPAIGN:
if (campaign.getState() != AccessCertificationCampaignStateType.CLOSED) {
acs.closeCampaign(campaign.getOid(), task, result);
processed++;
}
break;
default:
throw new IllegalStateException("Unknown action: " + operationName);
}
} catch (Exception ex) {
result.recordPartialError("Couldn't process campaign.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't process campaign", ex);
}
}
if (processed == 0) {
warn(getString("PageCertCampaigns.message.noCampaignsSelected"));
target.add(getFeedbackPanel());
return;
}
result.recomputeStatus();
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS, processed + " campaign(s) have been successfully processed.");
}
showResult(result);
target.add(getFeedbackPanel(), (Component) getCampaignsTable());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class CertificationCaseHelper method updateLoadedCampaign.
// adds cases to campaign if requested by options
public <T extends ObjectType> void updateLoadedCampaign(PrismObject<T> object, Collection<SelectorOptions<GetOperationOptions>> options, Session session) throws SchemaException {
if (!SelectorOptions.hasToLoadPath(AccessCertificationCampaignType.F_CASE, options)) {
return;
}
LOGGER.debug("Loading certification campaign cases.");
Criteria criteria = session.createCriteria(RAccessCertificationCase.class);
criteria.add(Restrictions.eq("ownerOid", object.getOid()));
// TODO fetch only XML representation
List<RAccessCertificationCase> cases = criteria.list();
if (cases == null || cases.isEmpty()) {
return;
}
AccessCertificationCampaignType campaign = (AccessCertificationCampaignType) object.asObjectable();
List<AccessCertificationCaseType> jaxbCases = campaign.getCase();
for (RAccessCertificationCase rCase : cases) {
AccessCertificationCaseType jaxbCase = rCase.toJAXB(prismContext);
jaxbCases.add(jaxbCase);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class CertificationCaseHelper method updateLoadedCertificationWorkItem.
public AccessCertificationWorkItemType updateLoadedCertificationWorkItem(GetCertificationWorkItemResult result, // key=OID:ID
Map<String, PrismContainerValue<AccessCertificationCaseType>> casesCache, // key=OID
Map<String, PrismObject<AccessCertificationCampaignType>> campaignsCache, Collection<SelectorOptions<GetOperationOptions>> options, QueryEngine2 engine, Session session, OperationResult operationResult) throws SchemaException, QueryException {
String campaignOid = result.getCampaignOid();
Integer caseId = result.getCaseId();
Integer workItemId = result.getId();
String caseKey = campaignOid + ":" + caseId;
PrismContainerValue<AccessCertificationCaseType> casePcv = casesCache.get(caseKey);
if (casePcv == null) {
ObjectQuery query = QueryBuilder.queryFor(AccessCertificationCaseType.class, prismContext).ownerId(campaignOid).and().id(caseId).build();
RQuery caseQuery = engine.interpret(query, AccessCertificationCaseType.class, null, false, session);
List<GetContainerableResult> cases = caseQuery.list();
if (cases.size() > 1) {
throw new IllegalStateException("More than one certification case found for campaign " + campaignOid + ", ID " + caseId);
} else if (cases.isEmpty()) {
// we need it, because otherwise we have only identifiers for the work item, no data
throw new IllegalStateException("No certification case found for campaign " + campaignOid + ", ID " + caseId);
}
AccessCertificationCaseType _case = updateLoadedCertificationCase(cases.get(0), campaignsCache, null, session, operationResult);
casePcv = _case.asPrismContainerValue();
casesCache.put(caseKey, casePcv);
}
@SuppressWarnings({ "raw", "unchecked" }) PrismContainerValue<AccessCertificationWorkItemType> workItemPcv = (PrismContainerValue<AccessCertificationWorkItemType>) casePcv.find(new ItemPath(AccessCertificationCaseType.F_WORK_ITEM, workItemId));
if (workItemPcv == null) {
throw new IllegalStateException("No work item " + workItemId + " in " + casePcv);
} else {
return workItemPcv.asContainerable();
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class CertificationTest method test270ModifyWorkItem.
@Test
public void test270ModifyWorkItem() throws Exception {
OperationResult result = new OperationResult("test270ModifyWorkItem");
PrismObject<AccessCertificationCampaignType> campaign = getFullCampaign(campaign1Oid, result);
AccessCertificationCaseType case100 = campaign.asObjectable().getCase().stream().filter(c -> c.getId() == NEW_CASE_ID).findFirst().orElseThrow(() -> new AssertionError("No case 100"));
assertEquals("Wrong # of work items in case 100", 2, case100.getWorkItem().size());
AccessCertificationWorkItemType workItem = case100.getWorkItem().stream().filter(wi -> wi.getOriginalAssigneeRef() != null).findFirst().orElse(null);
assertNotNull("No new work item", workItem);
XMLGregorianCalendar closedTimestamp = XmlTypeConverter.createXMLGregorianCalendar(new Date());
List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, NEW_CASE_ID, F_WORK_ITEM, workItem.getId(), AccessCertificationWorkItemType.F_CLOSE_TIMESTAMP).replace(closedTimestamp).asItemDeltas();
// WHEN
executeAndCheckModification(modifications, result, 0);
// THEN
checkCasesForCampaign(campaign1Oid, 8, result);
checkCasesTotal(8, result);
checkWorkItemsForCampaign(campaign1Oid, 10, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, 1, 2, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, 2, 1, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, NEW_CASE_ID, 2, result);
checkWorkItemsTotal(10, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class CertHelper method formatStage.
private String formatStage(AccessCertificationCampaignType campaign) {
String rv = campaign.getStageNumber() + "/" + CertCampaignTypeUtil.getNumberOfStages(campaign);
AccessCertificationStageType stage = CertCampaignTypeUtil.findCurrentStage(campaign);
if (StringUtils.isNotEmpty(stage.getName())) {
rv += " (" + stage.getName() + ")";
}
return rv;
}
Aggregations