Search in sources :

Example 96 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class SampleFormFocusTabPanel method initLayout.

private void initLayout(final LoadableModel<ObjectWrapper<F>> focusModel, LoadableModel<List<AssignmentEditorDto>> assignmentsModel, PageBase pageBase) {
    add(new Label(ID_HEADER, "Object details"));
    WebMarkupContainer body = new WebMarkupContainer("body");
    add(body);
    addPrismPropertyPanel(body, ID_PROP_NAME, FocusType.F_NAME);
    addPrismPropertyPanel(body, ID_PROP_FULL_NAME, UserType.F_FULL_NAME);
    // TODO: create proxy for these operations
    Task task = pageBase.createSimpleTask(OPERATION_SEARCH_ROLES);
    List<PrismObject<RoleType>> availableRoles;
    try {
        availableRoles = pageBase.getModelService().searchObjects(RoleType.class, null, null, task, task.getResult());
    } catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
        task.getResult().recordFatalError(e);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load roles", e);
        availableRoles = new ArrayList<>();
    // TODO: better errror reporting
    }
    add(new SimpleRoleSelector<F, RoleType>(ID_ROLES, assignmentsModel, availableRoles));
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) Label(org.apache.wicket.markup.html.basic.Label) ArrayList(java.util.ArrayList) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismObject(com.evolveum.midpoint.prism.PrismObject) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 97 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class ResourceRelatedHandlerDto method updateObjectClassList.

private void updateObjectClassList(PageBase pageBase) {
    Task task = pageBase.createSimpleTask(OPERATION_LOAD_RESOURCE);
    OperationResult result = task.getResult();
    List<QName> objectClassList = new ArrayList<>();
    if (resourceRef != null) {
        PrismObject<ResourceType> resource = WebModelServiceUtils.loadObject(ResourceType.class, resourceRef.getOid(), pageBase, task, result);
        try {
            ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resource, pageBase.getPrismContext());
            schema.getObjectClassDefinitions();
            for (Definition def : schema.getDefinitions()) {
                objectClassList.add(def.getTypeName());
            }
            setObjectClassList(objectClassList);
        } catch (Exception e) {
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object class list from resource.", e);
        }
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException)

Example 98 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class DefaultGuiProgressListener method getResourceName.

private String getResourceName(@NotNull String oid) {
    String name = nameCache.get(oid);
    if (name != null) {
        return name;
    }
    Task task = parentPage.createSimpleTask("getResourceName");
    OperationResult result = new OperationResult("getResourceName");
    // todo what about security?
    Collection<SelectorOptions<GetOperationOptions>> raw = SelectorOptions.createCollection(GetOperationOptions.createRaw());
    try {
        PrismObject<ResourceType> object = parentPage.getModelService().getObject(ResourceType.class, oid, raw, task, result);
        name = PolyString.getOrig(object.asObjectable().getName());
    } catch (ObjectNotFoundException | SchemaException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't determine the name of resource {}", e, oid);
        name = "(" + oid + ")";
    }
    nameCache.put(oid, name);
    return name;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceOperationResult(com.evolveum.midpoint.web.component.progress.ProgressReportActivityDto.ResourceOperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 99 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class ReportCreateHandlerPanel method initLayout.

private void initLayout(final PageTaskEdit parentPage) {
    final AjaxDownloadBehaviorFromStream ajaxDownloadBehavior = new AjaxDownloadBehaviorFromStream() {

        @Override
        protected InputStream initStream() {
            String outputOid = getModelObject().getReportOutputOid();
            if (outputOid == null) {
                return null;
            }
            Task task = parentPage.createSimpleTask(OPERATION_LOAD_REPORT_OUTPUT);
            PrismObject<ReportOutputType> reportObject = WebModelServiceUtils.loadObject(ReportOutputType.class, outputOid, parentPage, task, task.getResult());
            if (reportObject != null) {
                return PageCreatedReports.createReport(reportObject.asObjectable(), this, parentPage);
            } else {
                return null;
            }
        }
    };
    parentPage.getForm().add(ajaxDownloadBehavior);
    WebMarkupContainer reportParametersContainer = new WebMarkupContainer(ID_REPORT_PARAMETERS_CONTAINER);
    TextArea reportParameters = new TextArea<>(ID_REPORT_PARAMETERS, new PropertyModel<>(getModel(), ReportCreateHandlerDto.F_REPORT_PARAMS));
    reportParameters.setEnabled(false);
    reportParametersContainer.add(reportParameters);
    add(reportParametersContainer);
    WebMarkupContainer downloadContainer = new WebMarkupContainer(ID_DOWNLOAD_CONTAINER);
    AjaxButton download = new AjaxButton(ID_DOWNLOAD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            ajaxDownloadBehavior.initiate(target);
        }
    };
    downloadContainer.add(download);
    downloadContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().getReportOutputOid() != null;
        }
    });
    add(downloadContainer);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Task(com.evolveum.midpoint.task.api.Task) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) AjaxDownloadBehaviorFromStream(com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromStream) TextArea(org.apache.wicket.markup.html.form.TextArea) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ReportOutputType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportOutputType) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 100 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class ResourceRelatedHandlerPanel method initLayout.

private void initLayout() {
    final VisibleEnableBehaviour visibleIfEdit = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return parentPage.isEdit();
        }
    };
    final VisibleEnableBehaviour visibleIfView = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !parentPage.isEdit();
        }
    };
    enabledIfEdit = new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit();
        }
    };
    final VisibleEnableBehaviour visibleForResourceCoordinates = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getTaskDto().configuresResourceCoordinates();
        }
    };
    final WebMarkupContainer resourceRefContainer = new WebMarkupContainer(ID_RESOURCE_REF_CONTAINER);
    resourceRefContainer.add(visibleForResourceCoordinates);
    resourceRefContainer.setOutputMarkupId(true);
    add(resourceRefContainer);
    final DropDownChoice<TaskAddResourcesDto> resourceRef = new DropDownChoice<>(ID_RESOURCE_REF, new PropertyModel<TaskAddResourcesDto>(getModel(), ResourceRelatedHandlerDto.F_RESOURCE_REFERENCE), new AbstractReadOnlyModel<List<TaskAddResourcesDto>>() {

        @Override
        public List<TaskAddResourcesDto> getObject() {
            return createResourceList();
        }
    }, new ChoiceableChoiceRenderer<TaskAddResourcesDto>());
    resourceRef.setOutputMarkupId(true);
    resourceRef.add(enabledIfEdit);
    resourceRef.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            Task task = parentPage.createSimpleTask(OPERATION_LOAD_RESOURCE);
            OperationResult result = task.getResult();
            List<QName> objectClassList = new ArrayList<>();
            TaskAddResourcesDto resourcesDto = getModelObject().getResourceRef();
            if (resourcesDto != null) {
                PrismObject<ResourceType> resource = WebModelServiceUtils.loadObject(ResourceType.class, resourcesDto.getOid(), parentPage, task, result);
                try {
                    ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resource, parentPage.getPrismContext());
                    schema.getObjectClassDefinitions();
                    for (Definition def : schema.getDefinitions()) {
                        objectClassList.add(def.getTypeName());
                    }
                    getModelObject().setObjectClassList(objectClassList);
                } catch (Exception e) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object class list from resource.", e);
                    error("Couldn't load object class list from resource.");
                }
            }
            target.add(resourceRefContainer);
        }
    });
    resourceRefContainer.add(resourceRef);
    WebMarkupContainer kindContainer = new WebMarkupContainer(ID_KIND_CONTAINER);
    kindContainer.add(visibleForResourceCoordinates);
    add(kindContainer);
    final DropDownChoice kind = new DropDownChoice<>(ID_KIND, new PropertyModel<ShadowKindType>(getModel(), ResourceRelatedHandlerDto.F_KIND), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>());
    kind.setOutputMarkupId(true);
    kind.setNullValid(true);
    kindContainer.add(kind);
    WebMarkupContainer intentContainer = new WebMarkupContainer(ID_INTENT_CONTAINER);
    intentContainer.add(visibleForResourceCoordinates);
    add(intentContainer);
    final TextField<String> intent = new TextField<>(ID_INTENT, new PropertyModel<String>(getModel(), ResourceRelatedHandlerDto.F_INTENT));
    intentContainer.add(intent);
    intent.setOutputMarkupId(true);
    intent.add(enabledIfEdit);
    WebMarkupContainer objectClassContainer = new WebMarkupContainer(ID_OBJECT_CLASS_CONTAINER);
    objectClassContainer.add(visibleForResourceCoordinates);
    add(objectClassContainer);
    AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
    autoCompleteSettings.setShowListOnEmptyInput(true);
    final AutoCompleteTextField<String> objectClass = new AutoCompleteTextField<String>(ID_OBJECT_CLASS, new PropertyModel<String>(getModel(), ResourceRelatedHandlerDto.F_OBJECT_CLASS), autoCompleteSettings) {

        @Override
        protected Iterator<String> getChoices(String input) {
            return prepareObjectClassChoiceList(input);
        }
    };
    objectClass.add(enabledIfEdit);
    objectClassContainer.add(objectClass);
    WebMarkupContainer optionsContainer = new WebMarkupContainer(ID_OPTIONS_CONTAINER);
    optionsContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getTaskDto().configuresDryRun();
        }
    });
    add(optionsContainer);
    WebMarkupContainer dryRunContainer = new WebMarkupContainer(ID_DRY_RUN_CONTAINER);
    dryRunContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getTaskDto().configuresDryRun();
        }
    });
    optionsContainer.add(dryRunContainer);
    CheckBox dryRun = new CheckBox(ID_DRY_RUN, new PropertyModel<Boolean>(getModel(), ResourceRelatedHandlerDto.F_DRY_RUN));
    dryRun.add(enabledIfEdit);
    dryRunContainer.add(dryRun);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismObject(com.evolveum.midpoint.prism.PrismObject) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) TextField(org.apache.wicket.markup.html.form.TextField) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) Definition(com.evolveum.midpoint.prism.Definition) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AutoCompleteSettings(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox) TaskAddResourcesDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddResourcesDto) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)

Aggregations

Task (com.evolveum.midpoint.task.api.Task)4943 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4698 Test (org.testng.annotations.Test)3991 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)599 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)542 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)464 PrismObject (com.evolveum.midpoint.prism.PrismObject)327 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)323 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)290 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)282 ArrayList (java.util.ArrayList)249 QName (javax.xml.namespace.QName)208 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)199 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)193 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)175 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)159 AbstractConfiguredModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)140 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)123 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)108 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)108