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;
}
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();
}
}
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;
}
Aggregations