use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class ValueChoosePanel method replaceIfEmpty.
protected void replaceIfEmpty(ObjectType object) {
ObjectReferenceType ort = ObjectTypeUtil.createObjectRef(object, getPageBase().getPrismContext());
getModel().setObject((R) ort);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class CertDecisionHelper method createReviewerNameColumn.
public <T extends CertCaseOrWorkItemDto> IColumn<T, String> createReviewerNameColumn(final PageBase page, final String headerKey) {
IColumn column;
column = new AbstractColumn<T, String>(page.createStringResource(headerKey)) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<T>> cellItem, String componentId, final IModel<T> rowModel) {
CertCaseOrWorkItemDto dto = rowModel.getObject();
RepeatingView reviewersPanel = new RepeatingView(componentId);
if (dto instanceof CertWorkItemDto) {
List<ObjectReferenceType> reviewersList = ((CertWorkItemDto) dto).getReviewerRefList();
if (CollectionUtils.isNotEmpty(reviewersList)) {
for (ObjectReferenceType reviewer : reviewersList) {
reviewersPanel.add(new AjaxLinkPanel(reviewersPanel.newChildId(), Model.of(WebComponentUtil.getDisplayNameOrName(reviewer))) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
dispatchToObjectDetailsPage(reviewer, page, false);
}
});
}
}
}
cellItem.add(reviewersPanel);
}
};
return column;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class PageRegistrationFinish method assignDefaultRoles.
private void assignDefaultRoles(String userOid, PrismObject<UserType> administrator, OperationResult parentResult) throws CommonException {
List<ObjectReferenceType> rolesToAssign = getSelfRegistrationConfiguration().getDefaultRoles();
if (CollectionUtils.isEmpty(rolesToAssign)) {
return;
}
OperationResult result = parentResult.createSubresult(OPERATION_ASSIGN_DEFAULT_ROLES);
try {
PrismContext prismContext = getPrismContext();
List<AssignmentType> assignmentsToCreate = rolesToAssign.stream().map(ref -> ObjectTypeUtil.createAssignmentTo(ref, prismContext)).collect(Collectors.toList());
ObjectDelta<Objectable> delta = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).addRealValues(assignmentsToCreate).asObjectDelta(userOid);
runAsChecked(() -> {
Task task = createSimpleTask(OPERATION_ASSIGN_DEFAULT_ROLES);
WebModelServiceUtils.save(delta, result, task, PageRegistrationFinish.this);
return null;
}, administrator);
} catch (CommonException | RuntimeException e) {
result.recordFatalError(getString("PageRegistrationConfirmation.message.assignDefaultRoles.fatalError"), e);
throw e;
} finally {
result.computeStatusIfUnknown();
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class ExecutionHelper method checkDependentCases.
/**
* We need to check
* 1) if there are any executable cases that depend on this one
* 2) if we can close the parent (root)
*/
public void checkDependentCases(String rootOid, OperationResult result) throws SchemaException, ObjectNotFoundException, ObjectAlreadyExistsException {
CaseType rootCase = repositoryService.getObject(CaseType.class, rootOid, null, result).asObjectable();
if (CaseTypeUtil.isClosed(rootCase)) {
return;
}
List<CaseType> subcases = miscHelper.getSubcases(rootOid, result);
LOGGER.debug("Subcases:");
for (CaseType subcase : subcases) {
LOGGER.debug(" - {}: state={}, closeTS={}", subcase, subcase.getState(), subcase.getCloseTimestamp());
}
List<String> openOids = subcases.stream().filter(c -> !CaseTypeUtil.isClosed(c)).map(ObjectType::getOid).collect(Collectors.toList());
LOGGER.debug("open cases OIDs: {}", openOids);
if (openOids.isEmpty()) {
closeCaseInRepository(rootCase, result);
} else {
ObjectQuery query = prismContext.queryFor(TaskType.class).item(TaskType.F_OBJECT_REF).ref(openOids.toArray(new String[0])).and().item(TaskType.F_EXECUTION_STATE).eq(TaskExecutionStateType.WAITING).build();
SearchResultList<PrismObject<TaskType>> waitingTasks = repositoryService.searchObjects(TaskType.class, query, null, result);
LOGGER.debug("Waiting tasks: {}", waitingTasks);
for (PrismObject<TaskType> waitingTask : waitingTasks) {
String waitingCaseOid = waitingTask.asObjectable().getObjectRef().getOid();
assert waitingCaseOid != null;
List<CaseType> waitingCaseList = subcases.stream().filter(c -> waitingCaseOid.equals(c.getOid())).collect(Collectors.toList());
assert waitingCaseList.size() == 1;
Set<String> prerequisiteOids = waitingCaseList.get(0).getPrerequisiteRef().stream().map(ObjectReferenceType::getOid).collect(Collectors.toSet());
Collection<String> openPrerequisites = CollectionUtils.intersection(prerequisiteOids, openOids);
LOGGER.trace("prerequisite OIDs = {}; intersection with open OIDs = {}", prerequisiteOids, openPrerequisites);
if (openPrerequisites.isEmpty()) {
LOGGER.trace("All prerequisites are fulfilled, going to release the task {}", waitingTask);
try {
taskManager.unpauseTask(taskManager.createTaskInstance(waitingTask, result), result);
} catch (PreconditionViolationException e) {
LoggingUtils.logException(LOGGER, "Race condition when unpausing the task. " + "It may or may not be unpaused now. Continuing.", e);
}
} else {
LOGGER.trace("...task is not released and continues waiting for those cases");
}
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class ObjectMerger method getProjections.
private <O extends ObjectType> List<ShadowType> getProjections(PrismObject<O> objectRight, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
if (!objectRight.canRepresent(FocusType.class)) {
return new ArrayList<>(0);
}
List<ObjectReferenceType> linkRefs = ((FocusType) objectRight.asObjectable()).getLinkRef();
List<ShadowType> projections = new ArrayList<>(linkRefs.size());
for (ObjectReferenceType linkRef : linkRefs) {
projections.add(getProjection(linkRef, task, result));
}
return projections;
}
Aggregations