Search in sources :

Example 1 with AccountDetailsSearchDto

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

the class PageAccounts method createObjectClassValidator.

private IValidator<String> createObjectClassValidator() {
    return new IValidator<String>() {

        @Override
        public void validate(IValidatable<String> validatable) {
            String value = validatable.getValue();
            AccountDetailsSearchDto dto = searchModel.getObject();
            List<QName> accountObjectClassList = dto.getObjectClassList();
            List<String> accountObjectClassListString = new ArrayList<>();
            for (QName objectClass : accountObjectClassList) {
                accountObjectClassListString.add(objectClass.getLocalPart());
            }
            if (!accountObjectClassListString.contains(value)) {
                error(createStringResource("PageAccounts.message.validationError", value).getString());
            }
        }
    };
}
Also used : AccountDetailsSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto) IValidator(org.apache.wicket.validation.IValidator) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) IValidatable(org.apache.wicket.validation.IValidatable)

Example 2 with AccountDetailsSearchDto

use of com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto 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 3 with AccountDetailsSearchDto

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

the class PageAccounts method clearSearchPerformed.

private void clearSearchPerformed(AjaxRequestTarget target) {
    refreshSyncTotalsModels();
    searchModel.setObject(new AccountDetailsSearchDto());
    TablePanel panel = getAccountsTable();
    DataTable table = panel.getDataTable();
    ObjectDataProvider provider = (ObjectDataProvider) table.getDataProvider();
    provider.setQuery(ObjectQuery.createObjectQuery(createResourceQueryFilter()));
    ConfigurationStorage storage = getSessionStorage().getConfiguration();
    storage.setAccountSearchDto(searchModel.getObject());
    storage.setAccountDetailsPaging(null);
    panel.setCurrentPage(storage.getAccountDetailsPaging());
    target.add(getTotalsPanel());
    target.add(getSearchPanel());
    target.add(getAccountsContainer());
}
Also used : AccountDetailsSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto) DataTable(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable) ConfigurationStorage(com.evolveum.midpoint.web.session.ConfigurationStorage) ObjectDataProvider(com.evolveum.midpoint.web.component.data.ObjectDataProvider) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 4 with AccountDetailsSearchDto

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

the class PageAccounts method initSearchForm.

private void initSearchForm(Form searchForm) {
    BasicSearchPanel<AccountDetailsSearchDto> basicSearch = new BasicSearchPanel<AccountDetailsSearchDto>(ID_SEARCH_BASIC) {

        @Override
        protected IModel<String> createSearchTextModel() {
            return new PropertyModel<>(searchModel, AccountDetailsSearchDto.F_SEARCH_TEXT);
        }

        @Override
        protected void searchPerformed(AjaxRequestTarget target) {
            PageAccounts.this.searchPerformed(target);
        }

        @Override
        protected void clearSearchPerformed(AjaxRequestTarget target) {
            PageAccounts.this.clearSearchPerformed(target);
        }
    };
    basicSearch.setOutputMarkupId(true);
    searchForm.add(basicSearch);
    DropDownChoice failedOperationType = new DropDownChoice<>(ID_SEARCH_FAILED_OPERATION_TYPE, new PropertyModel<FailedOperationTypeType>(searchModel, AccountDetailsSearchDto.F_FAILED_OPERATION_TYPE), WebComponentUtil.createReadonlyModelFromEnum(FailedOperationTypeType.class), new EnumChoiceRenderer<FailedOperationTypeType>(this));
    failedOperationType.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            searchPerformed(target);
        }
    });
    failedOperationType.setOutputMarkupId(true);
    failedOperationType.setNullValid(true);
    searchForm.add(failedOperationType);
    DropDownChoice kind = new DropDownChoice<>(ID_SEARCH_KIND, new PropertyModel<ShadowKindType>(searchModel, AccountDetailsSearchDto.F_KIND), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>(this));
    kind.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            searchPerformed(target);
        }
    });
    kind.setOutputMarkupId(true);
    kind.setNullValid(true);
    searchForm.add(kind);
    DropDownChoice intent = new DropDownChoice<>(ID_SEARCH_INTENT, new PropertyModel<String>(searchModel, AccountDetailsSearchDto.F_INTENT), createIntentChoices(), new StringChoiceRenderer(null));
    intent.setNullValid(true);
    intent.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            searchPerformed(target);
        }
    });
    intent.setOutputMarkupId(true);
    searchForm.add(intent);
    AutoCompleteTextField<String> objectClass = new AutoCompleteTextField<String>(ID_SEARCH_OBJECT_CLASS, new PropertyModel<String>(searchModel, AccountDetailsSearchDto.F_OBJECT_CLASS)) {

        @Override
        protected Iterator<String> getChoices(String input) {
            if (Strings.isEmpty(input)) {
                List<String> emptyList = Collections.emptyList();
                return emptyList.iterator();
            }
            AccountDetailsSearchDto dto = searchModel.getObject();
            List<QName> accountObjectClassList = dto.getObjectClassList();
            List<String> choices = new ArrayList<>(AUTO_COMPLETE_LIST_SIZE);
            for (QName s : accountObjectClassList) {
                if (s.getLocalPart().toLowerCase().startsWith(input.toLowerCase())) {
                    choices.add(s.getLocalPart());
                    if (choices.size() == AUTO_COMPLETE_LIST_SIZE) {
                        break;
                    }
                }
            }
            return choices.iterator();
        }
    };
    objectClass.add(AttributeModifier.replace("placeholder", createStringResource("PageAccounts.accounts.objectClass")));
    objectClass.setOutputMarkupId(true);
    objectClass.add(createObjectClassValidator());
    objectClass.add(new SearchFormEnterBehavior(basicSearch.getSearchButton()));
    searchForm.add(objectClass);
}
Also used : AccountDetailsSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto) SearchFormEnterBehavior(com.evolveum.midpoint.web.util.SearchFormEnterBehavior) QName(javax.xml.namespace.QName) PropertyModel(org.apache.wicket.model.PropertyModel) ArrayList(java.util.ArrayList) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) BasicSearchPanel(com.evolveum.midpoint.web.component.BasicSearchPanel) StringChoiceRenderer(com.evolveum.midpoint.web.component.input.StringChoiceRenderer) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) FailedOperationTypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType)

Example 5 with AccountDetailsSearchDto

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

the class PageAccounts method createObjectQuery.

private ObjectQuery createObjectQuery() {
    AccountDetailsSearchDto dto = searchModel.getObject();
    String searchText = dto.getText();
    ShadowKindType kind = dto.getKind();
    String intent = dto.getIntent();
    String objectClass = dto.getObjectClass();
    FailedOperationTypeType failedOperatonType = dto.getFailedOperationType();
    S_AtomicFilterEntry q = QueryBuilder.queryFor(ShadowType.class, getPrismContext());
    if (StringUtils.isNotEmpty(searchText)) {
        PolyStringNormalizer normalizer = getPrismContext().getDefaultPolyStringNormalizer();
        String normalized = normalizer.normalize(searchText);
        q = q.item(ShadowType.F_NAME).contains(normalized).matchingNorm().and();
    }
    if (kind != null) {
        q = q.item(ShadowType.F_KIND).eq(kind).and();
    }
    if (StringUtils.isNotEmpty(intent)) {
        q = q.item(ShadowType.F_INTENT).eq(intent).and();
    }
    if (failedOperatonType != null) {
        q = q.item(ShadowType.F_FAILED_OPERATION_TYPE).eq(failedOperatonType).and();
    }
    if (StringUtils.isNotEmpty(objectClass)) {
        QName objClass = new QName(objectClass);
        for (QName qn : dto.getObjectClassList()) {
            if (objectClass.equals(qn.getLocalPart())) {
                objClass = qn;
            }
        }
        q = q.item(ShadowType.F_OBJECT_CLASS).eq(objClass).and();
    }
    return appendResourceQueryFilter(q);
}
Also used : AccountDetailsSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto) QName(javax.xml.namespace.QName) S_AtomicFilterEntry(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) FailedOperationTypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Aggregations

AccountDetailsSearchDto (com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto)5 QName (javax.xml.namespace.QName)4 ArrayList (java.util.ArrayList)3 FailedOperationTypeType (com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType)2 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)2 Definition (com.evolveum.midpoint.prism.Definition)1 PolyStringNormalizer (com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)1 S_AtomicFilterEntry (com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry)1 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 BasicSearchPanel (com.evolveum.midpoint.web.component.BasicSearchPanel)1 ObjectDataProvider (com.evolveum.midpoint.web.component.data.ObjectDataProvider)1 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)1 StringChoiceRenderer (com.evolveum.midpoint.web.component.input.StringChoiceRenderer)1 ResourceItemDto (com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto)1 ConfigurationStorage (com.evolveum.midpoint.web.session.ConfigurationStorage)1 SearchFormEnterBehavior (com.evolveum.midpoint.web.util.SearchFormEnterBehavior)1