Search in sources :

Example 1 with CertDefinitionDto

use of com.evolveum.midpoint.web.page.admin.certification.dto.CertDefinitionDto in project midpoint by Evolveum.

the class PageCertDefinition method createDefinition.

private CertDefinitionDto createDefinition() throws SchemaException {
    AccessCertificationDefinitionType definition = getPrismContext().createObjectable(AccessCertificationDefinitionType.class);
    definition.setHandlerUri(AccessCertificationApiConstants.DIRECT_ASSIGNMENT_HANDLER_URI);
    AccessCertificationStageDefinitionType stage = new AccessCertificationStageDefinitionType(getPrismContext());
    stage.setName("Stage 1");
    stage.setNumber(1);
    stage.setReviewerSpecification(new AccessCertificationReviewerSpecificationType(getPrismContext()));
    definition.getStageDefinition().add(stage);
    CertDefinitionDto definitionDto = new CertDefinitionDto(definition, PageCertDefinition.this, getPrismContext());
    return definitionDto;
}
Also used : CertDefinitionDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertDefinitionDto)

Example 2 with CertDefinitionDto

use of com.evolveum.midpoint.web.page.admin.certification.dto.CertDefinitionDto in project midpoint by Evolveum.

the class PageCertDefinition method savePerformed.

//endregion
//region Actions
public void savePerformed(AjaxRequestTarget target) {
    CertDefinitionDto dto = definitionModel.getObject();
    if (StringUtils.isEmpty(dto.getName())) {
        error(getString("CertDefinitionPage.message.cantSaveEmptyName"));
        target.add(getFeedbackPanel());
        return;
    }
    Task task = createSimpleTask(OPERATION_SAVE_DEFINITION);
    OperationResult result = task.getResult();
    try {
        AccessCertificationDefinitionType oldObject = dto.getOldDefinition();
        oldObject.asPrismObject().revive(getPrismContext());
        AccessCertificationDefinitionType newObject = dto.getUpdatedDefinition(getPrismContext());
        newObject.asPrismObject().revive(getPrismContext());
        ObjectDelta<AccessCertificationDefinitionType> delta;
        if (oldObject.getOid() != null) {
            delta = DiffUtil.diff(oldObject, newObject);
        } else {
            delta = ObjectDelta.createAddDelta(newObject.asPrismObject());
        }
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Access definition delta:\n{}", delta.debugDump());
        }
        delta.normalize();
        if (delta != null && !delta.isEmpty()) {
            getPrismContext().adopt(delta);
            ModelExecuteOptions options = new ModelExecuteOptions();
            options.setRaw(true);
            getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), options, task, result);
        }
        result.computeStatus();
    } catch (Exception ex) {
        result.recordFatalError("Couldn't save object: " + ex.getMessage(), ex);
    }
    showResult(result);
    if (result.isError()) {
        target.add(getFeedbackPanel());
    } else {
        redirectBack();
    }
}
Also used : CertDefinitionDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertDefinitionDto) Task(com.evolveum.midpoint.task.api.Task) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Example 3 with CertDefinitionDto

use of com.evolveum.midpoint.web.page.admin.certification.dto.CertDefinitionDto in project midpoint by Evolveum.

the class PageCertDefinition method loadDefinition.

private CertDefinitionDto loadDefinition(String definitionOid) {
    Task task = createSimpleTask(OPERATION_LOAD_DEFINITION);
    OperationResult result = task.getResult();
    AccessCertificationDefinitionType definition = null;
    CertDefinitionDto definitionDto = null;
    try {
        Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createResolveNames());
        PrismObject<AccessCertificationDefinitionType> definitionObject = WebModelServiceUtils.loadObject(AccessCertificationDefinitionType.class, definitionOid, options, PageCertDefinition.this, task, result);
        if (definitionObject != null) {
            definition = definitionObject.asObjectable();
        }
        definitionDto = new CertDefinitionDto(definition, this, getPrismContext());
        result.recordSuccessIfUnknown();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get definition", ex);
        result.recordFatalError("Couldn't get definition.", ex);
    }
    result.recomputeStatus();
    if (!WebComponentUtil.isSuccessOrHandledError(result)) {
        showResult(result);
    }
    return definitionDto;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CertDefinitionDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertDefinitionDto) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Aggregations

CertDefinitionDto (com.evolveum.midpoint.web.page.admin.certification.dto.CertDefinitionDto)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)1 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)1