Search in sources :

Example 1 with ResourceItemDto

use of com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto in project midpoint by Evolveum.

the class PageAccounts method initLayout.

private void initLayout() {
    Form form = new Form(ID_MAIN_FORM);
    form.setOutputMarkupId(true);
    add(form);
    Form accForm = new Form(ID_FORM_ACCOUNT);
    accForm.setOutputMarkupId(true);
    add(accForm);
    Form searchForm = new Form(ID_SEARCH_FORM);
    initSearchForm(searchForm);
    searchForm.setOutputMarkupPlaceholderTag(true);
    searchForm.setOutputMarkupId(true);
    searchForm.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return resourceModel.getObject() != null;
        }
    });
    add(searchForm);
    DropDownChoice<ResourceItemDto> resources = new DropDownChoice<>(ID_RESOURCES, resourceModel, resourcesModel, new ChoiceableChoiceRenderer<ResourceItemDto>());
    form.add(resources);
    initLinks(form, accForm);
    initTotals(form);
    final AjaxDownloadBehaviorFromFile ajaxDownloadBehavior = new AjaxDownloadBehaviorFromFile(true) {

        @Override
        protected File initFile() {
            return downloadFile;
        }
    };
    ajaxDownloadBehavior.setRemoveFile(false);
    form.add(ajaxDownloadBehavior);
    WebMarkupContainer filesContainer = new WebMarkupContainer(ID_FILES_CONTAINER);
    filesContainer.setOutputMarkupId(true);
    accForm.add(filesContainer);
    ModalWindow resultPopup = createModalWindow(ID_RESULT_DIALOG, createStringResource("PageAccounts.result.popoup"), 1100, 560);
    resultPopup.setContent(new AceEditorDialog(resultPopup.getContentId()));
    add(resultPopup);
    filesModel = createFilesModel();
    ListView<String> files = new ListView<String>(ID_FILES, filesModel) {

        @Override
        protected void populateItem(final ListItem<String> item) {
            AjaxLink file = new AjaxLink(ID_FILE) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    downloadPerformed(target, item.getModelObject(), ajaxDownloadBehavior);
                }
            };
            file.add(new Label(ID_FILE_NAME, item.getModelObject()));
            item.add(file);
        }
    };
    files.setRenderBodyOnly(true);
    filesContainer.add(files);
    WebMarkupContainer accountsContainer = new WebMarkupContainer(ID_ACCOUNTS_CONTAINER);
    accountsContainer.setOutputMarkupId(true);
    accForm.add(accountsContainer);
    ObjectDataProvider provider = new ObjectDataProvider(this, ShadowType.class);
    provider.setOptions(SelectorOptions.createCollection(GetOperationOptions.createRaw()));
    provider.setQuery(ObjectQuery.createObjectQuery(createResourceQueryFilter()));
    TablePanel accounts = new TablePanel(ID_ACCOUNTS, provider, createAccountsColumns(), UserProfileStorage.TableId.CONF_PAGE_ACCOUNTS, getItemsPerPage(UserProfileStorage.TableId.CONF_PAGE_ACCOUNTS));
    accounts.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return resourceModel.getObject() != null;
        }
    });
    accounts.setItemsPerPage(50);
    accountsContainer.add(accounts);
}
Also used : Form(org.apache.wicket.markup.html.form.Form) AjaxDownloadBehaviorFromFile(com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromFile) Label(org.apache.wicket.markup.html.basic.Label) ObjectDataProvider(com.evolveum.midpoint.web.component.data.ObjectDataProvider) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) ResourceItemDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto) ListView(org.apache.wicket.markup.html.list.ListView) AceEditorDialog(com.evolveum.midpoint.web.page.admin.configuration.component.AceEditorDialog) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) ModalWindow(org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 2 with ResourceItemDto

use of com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto in project midpoint by Evolveum.

the class PageAccounts method createIntentChoices.

private IModel<List<String>> createIntentChoices() {
    return new AbstractReadOnlyModel<List<String>>() {

        @Override
        public List<String> getObject() {
            List<String> intentList = new ArrayList<>();
            ResourceItemDto dto = resourceModel.getObject();
            PrismObject<ResourceType> resourcePrism;
            if (dto == null) {
                return intentList;
            }
            String oid = dto.getOid();
            OperationResult result = new OperationResult(OPERATION_GET_INTENTS);
            try {
                resourcePrism = getModelService().getObject(ResourceType.class, oid, null, createSimpleTask(OPERATION_GET_INTENTS), result);
                ResourceType resource = resourcePrism.asObjectable();
                SchemaHandlingType schemaHandling = resource.getSchemaHandling();
                for (ResourceObjectTypeDefinitionType r : schemaHandling.getObjectType()) {
                    intentList.add(r.getIntent());
                }
            } catch (Exception e) {
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load intents from resource.", e);
                error("Couldn't load intents from resource.");
                return null;
            }
            return intentList;
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) SchemaHandlingType(com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType) ResourceItemDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) ArrayList(java.util.ArrayList) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) IOException(java.io.IOException) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 3 with ResourceItemDto

use of com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto in project midpoint by Evolveum.

the class PageAccounts method loadResourceObjectClass.

private void loadResourceObjectClass() {
    AccountDetailsSearchDto dto = searchModel.getObject();
    PrismObject<ResourceType> resourcePrism;
    OperationResult result = new OperationResult(OPERATION_GET_OBJECT_CLASS);
    List<QName> accountObjectClassList = new ArrayList<>();
    ResourceItemDto resourceDto = resourceModel.getObject();
    String oid = resourceDto.getOid();
    try {
        resourcePrism = getModelService().getObject(ResourceType.class, oid, null, createSimpleTask(OPERATION_GET_INTENTS), result);
        ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resourcePrism, getPrismContext());
        schema.getObjectClassDefinitions();
        for (Definition def : schema.getDefinitions()) {
            accountObjectClassList.add(def.getTypeName());
        }
        dto.setObjectClassList(accountObjectClassList);
    } catch (Exception e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object class list from resource.", e);
        result.recordFatalError("Couldn't load object class list from resource.: " + e.getMessage(), e);
        showResult(result, false);
        resourceModel.setObject(null);
        new RestartResponseException(PageAccounts.this);
    }
}
Also used : AccountDetailsSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Definition(com.evolveum.midpoint.prism.Definition) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) IOException(java.io.IOException) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ResourceItemDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 4 with ResourceItemDto

use of com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto in project midpoint by Evolveum.

the class ReconciliationPopupPanel method createModel.

private IModel<ResourceItemDto> createModel(final List<ResourceItemDto> resources) {
    return new IModel<ResourceItemDto>() {

        @Override
        public ResourceItemDto getObject() {
            ReconciliationReportDto dto = getModel().getObject();
            if (dto.getResourceOid() == null) {
                return null;
            }
            for (ResourceItemDto item : resources) {
                if (StringUtils.equals(item.getOid(), dto.getResourceOid())) {
                    return item;
                }
            }
            return null;
        }

        @Override
        public void setObject(ResourceItemDto object) {
            ReconciliationReportDto dto = getModel().getObject();
            dto.setResourceOid(object != null ? object.getOid() : null);
            dto.setResourceName(object != null ? object.getName() : null);
        }

        @Override
        public void detach() {
        }
    };
}
Also used : IModel(org.apache.wicket.model.IModel) ResourceItemDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto) ReconciliationReportDto(com.evolveum.midpoint.web.page.admin.reports.dto.ReconciliationReportDto)

Example 5 with ResourceItemDto

use of com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto in project midpoint by Evolveum.

the class PageAccounts method loadResources.

private List<ResourceItemDto> loadResources() {
    List<ResourceItemDto> resources = new ArrayList<>();
    OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
    try {
        List<PrismObject<ResourceType>> objects = getModelService().searchObjects(ResourceType.class, null, SelectorOptions.createCollection(GetOperationOptions.createNoFetch()), createSimpleTask(OPERATION_LOAD_RESOURCES), result);
        if (objects != null) {
            for (PrismObject<ResourceType> object : objects) {
                StringBuilder nameBuilder = new StringBuilder(WebComponentUtil.getName(object));
                PrismProperty<OperationResultType> fetchResult = object.findProperty(ResourceType.F_FETCH_RESULT);
                if (fetchResult != null) {
                    nameBuilder.append(" (");
                    nameBuilder.append(fetchResult.getRealValue().getStatus());
                    nameBuilder.append(")");
                }
                resources.add(new ResourceItemDto(object.getOid(), nameBuilder.toString()));
            }
        }
        result.recordSuccess();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load resources", ex);
        result.recordFatalError("Couldn't load resources, reason: " + ex.getMessage(), ex);
    } finally {
        if (result.isUnknown()) {
            result.computeStatus();
        }
    }
    Collections.sort(resources);
    if (!WebComponentUtil.isSuccessOrHandledError(result)) {
        showResult(result, false);
        throw new RestartResponseException(PageDashboard.class);
    }
    return resources;
}
Also used : 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) RestartResponseException(org.apache.wicket.RestartResponseException) IOException(java.io.IOException) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PrismObject(com.evolveum.midpoint.prism.PrismObject) ResourceItemDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto) RestartResponseException(org.apache.wicket.RestartResponseException) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)

Aggregations

ResourceItemDto (com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 CommonException (com.evolveum.midpoint.util.exception.CommonException)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 RestartResponseException (org.apache.wicket.RestartResponseException)3 Definition (com.evolveum.midpoint.prism.Definition)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)1 AjaxDownloadBehaviorFromFile (com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromFile)1 ObjectDataProvider (com.evolveum.midpoint.web.component.data.ObjectDataProvider)1 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 AceEditorDialog (com.evolveum.midpoint.web.page.admin.configuration.component.AceEditorDialog)1 AccountDetailsSearchDto (com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto)1 ReconciliationReportDto (com.evolveum.midpoint.web.page.admin.reports.dto.ReconciliationReportDto)1 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)1