use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class CertHelper method appendStatistics.
public void appendStatistics(StringBuilder sb, AccessCertificationCampaignType campaign, Task task, OperationResult result) {
AccessCertificationCasesStatisticsType stat;
try {
stat = certificationManager.getCampaignStatistics(campaign.getOid(), false, task, result);
} catch (ObjectNotFoundException | SchemaException | SecurityViolationException | ObjectAlreadyExistsException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get campaign statistics", e);
sb.append("Couldn't get campaign statistics because of ").append(e);
return;
}
int all = stat.getMarkedAsAccept() + stat.getMarkedAsRevoke() + stat.getMarkedAsReduce() + stat.getMarkedAsNotDecide() + stat.getWithoutResponse();
sb.append("Number of cases:\t").append(all);
sb.append("\nMarked as ACCEPT:\t").append(stat.getMarkedAsAccept());
sb.append("\nMarked as REVOKE:\t").append(stat.getMarkedAsRevoke()).append(" (remedied: ").append(stat.getMarkedAsRevokeAndRemedied()).append(")");
sb.append("\nMarked as REDUCE:\t").append(stat.getMarkedAsReduce()).append(" (remedied: ").append(stat.getMarkedAsReduceAndRemedied()).append(")");
sb.append("\nMarked as NOT DECIDED:\t").append(stat.getMarkedAsNotDecide());
sb.append("\nNo response:\t\t").append(stat.getWithoutResponse());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class ReportFunctions method searchCertificationDefinitions.
// TODO implement if needed
// <O extends Containerable> RefFilter createReferenceEqualFilter(QName propertyName, Class<O> type, String... oids) {
// return RefFilter.createReferenceEqual(propertyName, type, prismContext, oids);
// }
// <O extends Containerable> RefFilter createReferenceEqualFilter(ItemPath propertyPath, Class<O> type, String... oids) throws SchemaException {
// return RefFilter.createReferenceEqual(propertyPath, type, prismContext, oids);
// }
// Object parseObjectFromXML (String xml) throws SchemaException {
// return prismContext.parserFor(xml).xml().parseAnyData();
// }
/**
* Retrieves all definitions.
* Augments them by count of campaigns (all + open ones).
*
* TODO query parameters, customizable sorting
* definitions and campaigns counts are expected to be low, so we can afford to go through all of them here
*/
public Collection<PrismObject<AccessCertificationDefinitionForReportType>> searchCertificationDefinitions() throws ConfigurationException, SchemaException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException {
Task task = taskManager.createTaskInstance();
OperationResult result = task.getResult();
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createResolveNames());
List<PrismObject<AccessCertificationDefinitionType>> definitions = model.searchObjects(AccessCertificationDefinitionType.class, null, options, task, result);
final Map<String, PrismObject<AccessCertificationDefinitionForReportType>> definitionsForReportMap = new HashMap<>();
for (PrismObject<AccessCertificationDefinitionType> definition : definitions) {
// create subclass with the values copied from the superclass
PrismObject<AccessCertificationDefinitionForReportType> definitionForReport = prismContext.createObjectable(AccessCertificationDefinitionForReportType.class).asPrismObject();
for (Item<?, ?> item : definition.getValue().getItems()) {
definitionForReport.getValue().add(item.clone());
}
definitionsForReportMap.put(definition.getOid(), definitionForReport);
}
ResultHandler<AccessCertificationCampaignType> handler = (campaignObject, parentResult) -> {
AccessCertificationCampaignType campaign = campaignObject.asObjectable();
if (campaign.getDefinitionRef() != null) {
String definitionOid = campaign.getDefinitionRef().getOid();
PrismObject<AccessCertificationDefinitionForReportType> definitionObject = definitionsForReportMap.get(definitionOid);
if (definitionObject != null) {
AccessCertificationDefinitionForReportType definition = definitionObject.asObjectable();
int campaigns = definition.getCampaigns() != null ? definition.getCampaigns() : 0;
definition.setCampaigns(campaigns + 1);
AccessCertificationCampaignStateType state = campaign.getState();
if (state != AccessCertificationCampaignStateType.CREATED && state != CLOSED) {
int openCampaigns = definition.getOpenCampaigns() != null ? definition.getOpenCampaigns() : 0;
definition.setOpenCampaigns(openCampaigns + 1);
}
}
}
return true;
};
model.searchObjectsIterative(AccessCertificationCampaignType.class, null, handler, null, task, result);
List<PrismObject<AccessCertificationDefinitionForReportType>> rv = new ArrayList<>(definitionsForReportMap.values());
Collections.sort(rv, (o1, o2) -> {
String n1 = o1.asObjectable().getName().getOrig();
String n2 = o2.asObjectable().getName().getOrig();
if (n1 == null) {
n1 = "";
}
return n1.compareTo(n2);
});
for (PrismObject<AccessCertificationDefinitionForReportType> defObject : rv) {
AccessCertificationDefinitionForReportType def = defObject.asObjectable();
if (def.getCampaigns() == null) {
def.setCampaigns(0);
}
if (def.getOpenCampaigns() == null) {
def.setOpenCampaigns(0);
}
}
return rv;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class SimpleCampaignNotifier method getBody.
@Override
protected String getBody(Event event, GeneralNotifierType generalNotifierType, String transport, Task task, OperationResult result) {
StringBuilder body = new StringBuilder();
CertCampaignEvent campaignEvent = (CertCampaignEvent) event;
AccessCertificationCampaignType campaign = campaignEvent.getCampaign();
body.append("Campaign ");
body.append(certHelper.getCampaignNameAndOid(campaignEvent));
body.append(" was ");
if (campaignEvent.isAdd()) {
body.append("STARTED");
} else if (campaignEvent.isDelete()) {
body.append("CLOSED");
} else {
throw new IllegalStateException("Unexpected campaign event type: neither ADD nor DELETE");
}
body.append(".\n\n");
// the event is generated in the real time
body.append("Time: ").append(new Date());
body.append("\nRequester: ").append(formatRequester(event, result));
body.append("\nOperation status: ").append(certHelper.formatStatus(campaignEvent));
body.append("\n\nCurrent state: ").append(certHelper.formatState(campaignEvent));
body.append("\n\n");
certHelper.appendStatistics(body, campaign, task, result);
body.append("\n\n");
functions.addRequesterAndChannelInformation(body, event, result);
return body.toString();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class CertificationCaseHelper method updateLoadedCertificationCase.
// TODO find a better name
public AccessCertificationCaseType updateLoadedCertificationCase(GetContainerableResult result, Map<String, PrismObject<AccessCertificationCampaignType>> ownersMap, Collection<SelectorOptions<GetOperationOptions>> options, Session session, OperationResult operationResult) throws SchemaException {
AccessCertificationCaseType aCase = RAccessCertificationCase.createJaxb(result.getFullObject(), prismContext, false);
generalHelper.validateContainerable(aCase, AccessCertificationCaseType.class);
String ownerOid = result.getOwnerOid();
PrismObject<AccessCertificationCampaignType> campaign = resolveCampaign(ownerOid, ownersMap, session, operationResult);
if (campaign != null && !campaign.asObjectable().getCase().contains(aCase)) {
campaign.asObjectable().getCase().add(aCase);
}
return aCase;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class CertificationTest method test730CurrentUnansweredCases.
@Test
public void test730CurrentUnansweredCases() throws Exception {
OperationResult result = new OperationResult("test730CurrentUnansweredCases");
ObjectQuery query = QueryBuilder.queryFor(AccessCertificationCaseType.class, prismContext).item(AccessCertificationCaseType.F_STAGE_NUMBER).eq().item(T_PARENT, AccessCertificationCampaignType.F_STAGE_NUMBER).and().item(T_PARENT, F_STATE).eq(IN_REVIEW_STAGE).and().exists(F_WORK_ITEM).block().item(F_CLOSE_TIMESTAMP).isNull().and().block().item(F_OUTPUT, F_OUTCOME).isNull().endBlock().endBlock().build();
List<AccessCertificationCaseType> cases = repositoryService.searchContainers(AccessCertificationCaseType.class, query, createCollection(createDistinct()), result);
AccessCertificationCampaignType campaign1 = getFullCampaign(campaign1Oid, result).asObjectable();
AccessCertificationCampaignType campaign2 = getFullCampaign(campaign2Oid, result).asObjectable();
List<AccessCertificationCaseType> expectedCases = new ArrayList<>();
addUnansweredActiveCases(expectedCases, campaign1.getCase(), campaign1);
addUnansweredActiveCases(expectedCases, campaign2.getCase(), campaign2);
PrismAsserts.assertEqualsCollectionUnordered("list of cases is different", cases, expectedCases.toArray(new AccessCertificationCaseType[0]));
}
Aggregations