Search in sources :

Example 71 with ObjectReferenceType

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);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Example 72 with ObjectReferenceType

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;
}
Also used : AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) CertCaseOrWorkItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCaseOrWorkItemDto) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) List(java.util.List) CertWorkItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertWorkItemDto)

Example 73 with ObjectReferenceType

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();
    }
}
Also used : com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) PageDescriptor(com.evolveum.midpoint.authentication.api.authorization.PageDescriptor) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AuthorizationConstants(com.evolveum.midpoint.security.api.AuthorizationConstants) Trace(com.evolveum.midpoint.util.logging.Trace) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) ArrayList(java.util.ArrayList) WebModelServiceUtils(com.evolveum.midpoint.gui.api.util.WebModelServiceUtils) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) PrismContext(com.evolveum.midpoint.prism.PrismContext) RestartResponseException(org.apache.wicket.RestartResponseException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AuthenticationException(org.springframework.security.core.AuthenticationException) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) Label(org.apache.wicket.markup.html.basic.Label) Url(com.evolveum.midpoint.authentication.api.authorization.Url) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Objectable(com.evolveum.midpoint.prism.Objectable) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) Collectors(java.util.stream.Collectors) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) LoggingUtils(com.evolveum.midpoint.util.logging.LoggingUtils) CommonException(com.evolveum.midpoint.util.exception.CommonException) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal) List(java.util.List) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) AuthorizationAction(com.evolveum.midpoint.authentication.api.authorization.AuthorizationAction) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Authentication(org.springframework.security.core.Authentication) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) Task(com.evolveum.midpoint.task.api.Task) PrismContext(com.evolveum.midpoint.prism.PrismContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Objectable(com.evolveum.midpoint.prism.Objectable) CommonException(com.evolveum.midpoint.util.exception.CommonException)

Example 74 with ObjectReferenceType

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");
            }
        }
    }
}
Also used : CaseTypeUtil(com.evolveum.midpoint.schema.util.cases.CaseTypeUtil) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Autowired(org.springframework.beans.factory.annotation.Autowired) Trace(com.evolveum.midpoint.util.logging.Trace) TaskManager(com.evolveum.midpoint.task.api.TaskManager) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) WorkItemHelper(com.evolveum.midpoint.cases.impl.engine.helpers.WorkItemHelper) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) Duration(javax.xml.datatype.Duration) LensContext(com.evolveum.midpoint.model.impl.lens.LensContext) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) PrismContext(com.evolveum.midpoint.prism.PrismContext) Qualifier(org.springframework.beans.factory.annotation.Qualifier) AuthorizationHelper(com.evolveum.midpoint.cases.impl.helpers.AuthorizationHelper) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) TriggerHelper(com.evolveum.midpoint.cases.impl.engine.helpers.TriggerHelper) XmlTypeConverter(com.evolveum.midpoint.prism.xml.XmlTypeConverter) CaseMiscHelper(com.evolveum.midpoint.cases.impl.helpers.CaseMiscHelper) Collection(java.util.Collection) Set(java.util.Set) ExpressionEvaluationHelper(com.evolveum.midpoint.wf.impl.processes.common.ExpressionEvaluationHelper) PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) Collectors(java.util.stream.Collectors) LoggingUtils(com.evolveum.midpoint.util.logging.LoggingUtils) PreconditionViolationException(com.evolveum.midpoint.repo.api.PreconditionViolationException) List(java.util.List) Component(org.springframework.stereotype.Component) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) PrimaryChangeProcessor(com.evolveum.midpoint.wf.impl.processors.primary.PrimaryChangeProcessor) SystemObjectCache(com.evolveum.midpoint.model.common.SystemObjectCache) StageComputeHelper(com.evolveum.midpoint.wf.impl.processes.common.StageComputeHelper) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Clock(com.evolveum.midpoint.common.Clock) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PrismObject(com.evolveum.midpoint.prism.PrismObject) PreconditionViolationException(com.evolveum.midpoint.repo.api.PreconditionViolationException)

Example 75 with ObjectReferenceType

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;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) ArrayList(java.util.ArrayList)

Aggregations

ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)278 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)104 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)61 Test (org.testng.annotations.Test)61 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)56 Task (com.evolveum.midpoint.task.api.Task)53 QName (javax.xml.namespace.QName)46 ArrayList (java.util.ArrayList)44 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)42 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)37 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)33 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)32 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)32 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)31 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)30 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)30 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)26 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)26 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)23 List (java.util.List)23