use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class AccCertUpdateHelper method createStage.
protected AccessCertificationStageType createStage(AccessCertificationCampaignType campaign, int requestedStageNumber) {
AccessCertificationStageType stage = new AccessCertificationStageType(prismContext);
stage.setNumber(requestedStageNumber);
stage.setStartTimestamp(XmlTypeConverter.createXMLGregorianCalendar(new Date()));
AccessCertificationStageDefinitionType stageDef = CertCampaignTypeUtil.findStageDefinition(campaign, stage.getNumber());
XMLGregorianCalendar deadline = computeDeadline(stage.getStartTimestamp(), stageDef.getDuration(), stageDef.getDeadlineRounding());
stage.setDeadline(deadline);
stage.setName(stageDef.getName());
stage.setDescription(stageDef.getDescription());
return stage;
}
use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class AccCertUpdateHelper method getDeltasForStageClose.
List<ItemDelta<?, ?>> getDeltasForStageClose(AccessCertificationCampaignType campaign, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
XMLGregorianCalendar now = XmlTypeConverter.createXMLGregorianCalendar(new Date());
List<ItemDelta<?, ?>> rv = caseHelper.createOutcomeDeltas(campaign, result);
rv.add(createStateDelta(REVIEW_STAGE_DONE));
rv.add(createStageEndTimeDelta(campaign, now));
rv.add(createTriggerDeleteDelta());
rv.addAll(createWorkItemsCloseDeltas(campaign, now, result));
return rv;
}
use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class AccCertUpdateHelper method computeDeadline.
private XMLGregorianCalendar computeDeadline(XMLGregorianCalendar start, Duration duration, DeadlineRoundingType deadlineRounding) {
XMLGregorianCalendar deadline = (XMLGregorianCalendar) start.clone();
if (duration != null) {
deadline.add(duration);
}
DeadlineRoundingType rounding = deadlineRounding != null ? deadlineRounding : DeadlineRoundingType.DAY;
switch(rounding) {
case DAY:
deadline.setHour(23);
case HOUR:
deadline.setMinute(59);
deadline.setSecond(59);
deadline.setMillisecond(999);
case NONE:
}
return deadline;
}
use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class AccCertCaseOperationsHelper method markCaseAsRemedied.
// TODO temporary implementation - should be done somehow in batches in order to improve performance
void markCaseAsRemedied(@NotNull String campaignOid, long caseId, Task task, OperationResult parentResult) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, SecurityViolationException {
PropertyDelta<XMLGregorianCalendar> reviewRemediedDelta = PropertyDelta.createModificationReplaceProperty(new ItemPath(new NameItemPathSegment(F_CASE), new IdItemPathSegment(caseId), new NameItemPathSegment(AccessCertificationCaseType.F_REMEDIED_TIMESTAMP)), generalHelper.getCampaignObjectDefinition(), XmlTypeConverter.createXMLGregorianCalendar(new Date()));
updateHelper.modifyObjectViaModel(AccessCertificationCampaignType.class, campaignOid, Collections.singletonList(reviewRemediedDelta), task, parentResult);
}
use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.
the class AccCertCaseOperationsHelper method recordDecision.
void recordDecision(String campaignOid, long caseId, long workItemId, AccessCertificationResponseType response, String comment, Task task, OperationResult result) throws SecurityViolationException, ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
AccessCertificationCaseType _case = queryHelper.getCase(campaignOid, caseId, task, result);
if (_case == null) {
throw new ObjectNotFoundException("Case " + caseId + " was not found in campaign " + campaignOid);
}
AccessCertificationCampaignType campaign = CertCampaignTypeUtil.getCampaign(_case);
if (campaign == null) {
throw new IllegalStateException("No owning campaign present in case " + _case);
}
AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(_case, workItemId);
if (workItem == null) {
throw new ObjectNotFoundException("Work item " + workItemId + " was not found in campaign " + toShortString(campaign) + ", case " + caseId);
}
if (response == AccessCertificationResponseType.NO_RESPONSE) {
response = null;
}
ObjectReferenceType responderRef = ObjectTypeUtil.createObjectRef(securityEnforcer.getPrincipal().getUser());
XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar();
ItemPath workItemPath = new ItemPath(F_CASE, caseId, F_WORK_ITEM, workItemId);
Collection<ItemDelta<?, ?>> deltaList = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(workItemPath.subPath(AccessCertificationWorkItemType.F_OUTPUT)).replace(new AbstractWorkItemOutputType().outcome(OutcomeUtils.toUri(response)).comment(comment)).item(workItemPath.subPath(AccessCertificationWorkItemType.F_OUTPUT_CHANGE_TIMESTAMP)).replace(now).item(workItemPath.subPath(AccessCertificationWorkItemType.F_PERFORMER_REF)).replace(responderRef).asItemDeltas();
ItemDelta.applyTo(deltaList, campaign.asPrismContainerValue());
String newCurrentOutcome = OutcomeUtils.toUri(computationHelper.computeOutcomeForStage(_case, campaign, campaign.getStageNumber()));
if (!ObjectUtils.equals(newCurrentOutcome, _case.getCurrentStageOutcome())) {
deltaList.add(DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, _case.asPrismContainerValue().getId(), F_CURRENT_STAGE_OUTCOME).replace(newCurrentOutcome).asItemDelta());
}
String newOverallOutcome = OutcomeUtils.toUri(computationHelper.computeOverallOutcome(_case, campaign, newCurrentOutcome));
if (!ObjectUtils.equals(newOverallOutcome, _case.getOutcome())) {
deltaList.add(DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, _case.asPrismContainerValue().getId(), F_OUTCOME).replace(newOverallOutcome).asItemDelta());
}
updateHelper.modifyObjectViaModel(AccessCertificationCampaignType.class, campaignOid, deltaList, task, result);
}
Aggregations