Search in sources :

Example 6 with XMLGregorianCalendar

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;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar)

Example 7 with XMLGregorianCalendar

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;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta)

Example 8 with XMLGregorianCalendar

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;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar)

Example 9 with XMLGregorianCalendar

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);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 10 with XMLGregorianCalendar

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);
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ObjectTypeUtil.toShortString(com.evolveum.midpoint.schema.util.ObjectTypeUtil.toShortString) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)336 Test (org.testng.annotations.Test)159 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)130 Task (com.evolveum.midpoint.task.api.Task)104 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)72 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)52 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)44 Date (java.util.Date)36 TestValidityRecomputeTask (com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask)32 ArrayList (java.util.ArrayList)32 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)31 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)31 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)30 AbstractSynchronizationStoryTest (com.evolveum.midpoint.model.intest.sync.AbstractSynchronizationStoryTest)23 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)21 GregorianCalendar (java.util.GregorianCalendar)18 QName (javax.xml.namespace.QName)18 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)15 Duration (javax.xml.datatype.Duration)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)14