Search in sources :

Example 1 with PolyStringNormalizer

use of com.evolveum.midpoint.prism.polystring.PolyStringNormalizer in project midpoint by Evolveum.

the class TestPolyString method testNormalization.

private void testNormalization(final String TEST_NAME, String orig, String expectedNorm) {
    System.out.println("===[ " + TEST_NAME + " ]===");
    PolyString polyString = new PolyString(orig);
    PolyStringNormalizer normalizer = new PrismDefaultPolyStringNormalizer();
    // WHEN
    polyString.recompute(normalizer);
    // THEN
    assertEquals("orig have changed", orig, polyString.getOrig());
    assertEquals("wrong norm", expectedNorm, polyString.getNorm());
    assertEquals("wrong toString", orig, polyString.toString());
}
Also used : PrismDefaultPolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PrismDefaultPolyStringNormalizer) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer) PrismDefaultPolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PrismDefaultPolyStringNormalizer)

Example 2 with PolyStringNormalizer

use of com.evolveum.midpoint.prism.polystring.PolyStringNormalizer in project midpoint by Evolveum.

the class PageCreatedReports method createQuery.

private ObjectQuery createQuery() {
    ReportOutputSearchDto dto = searchModel.getObject();
    S_AtomicFilterEntry q = QueryBuilder.queryFor(ReportOutputType.class, getPrismContext());
    if (StringUtils.isNotEmpty(dto.getText())) {
        PolyStringNormalizer normalizer = getPrismContext().getDefaultPolyStringNormalizer();
        String normalizedString = normalizer.normalize(dto.getText());
        q = q.item(ReportOutputType.F_NAME).containsPoly(normalizedString).matchingNorm().and();
    }
    String oid = dto.getReportTypeMap().get(dto.getReportType());
    if (StringUtils.isNotEmpty(oid)) {
        q = q.item(ReportOutputType.F_REPORT_REF).ref(oid).and();
    }
    return q.all().build();
}
Also used : ReportOutputSearchDto(com.evolveum.midpoint.web.page.admin.reports.dto.ReportOutputSearchDto) S_AtomicFilterEntry(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Example 3 with PolyStringNormalizer

use of com.evolveum.midpoint.prism.polystring.PolyStringNormalizer in project midpoint by Evolveum.

the class Search method createFilterForSearchValue.

private ObjectFilter createFilterForSearchValue(SearchItem item, DisplayableValue searchValue, PrismContext ctx) {
    ItemDefinition definition = item.getDefinition();
    ItemPath path = item.getPath();
    if (definition instanceof PrismReferenceDefinition) {
        return QueryBuilder.queryFor(ObjectType.class, ctx).item(path, definition).ref((PrismReferenceValue) searchValue.getValue()).buildFilter();
    }
    PrismPropertyDefinition propDef = (PrismPropertyDefinition) definition;
    if ((propDef.getAllowedValues() != null && !propDef.getAllowedValues().isEmpty()) || DOMUtil.XSD_BOOLEAN.equals(propDef.getTypeName())) {
        //we're looking for enum value, therefore equals filter is ok
        //or if it's boolean value
        DisplayableValue displayableValue = (DisplayableValue) searchValue.getValue();
        Object value = displayableValue.getValue();
        return QueryBuilder.queryFor(ObjectType.class, ctx).item(path, propDef).eq(value).buildFilter();
    } else if (DOMUtil.XSD_INT.equals(propDef.getTypeName()) || DOMUtil.XSD_INTEGER.equals(propDef.getTypeName()) || DOMUtil.XSD_LONG.equals(propDef.getTypeName()) || DOMUtil.XSD_SHORT.equals(propDef.getTypeName())) {
        String text = (String) searchValue.getValue();
        if (!StringUtils.isNumeric(text) && (searchValue instanceof SearchValue)) {
            ((SearchValue) searchValue).clear();
            return null;
        }
        Object value = Long.parseLong((String) searchValue.getValue());
        return QueryBuilder.queryFor(ObjectType.class, ctx).item(path, propDef).eq(value).buildFilter();
    } else if (DOMUtil.XSD_STRING.equals(propDef.getTypeName())) {
        String text = (String) searchValue.getValue();
        return QueryBuilder.queryFor(ObjectType.class, ctx).item(path, propDef).contains(text).matchingCaseIgnore().buildFilter();
    } else if (SchemaConstants.T_POLY_STRING_TYPE.equals(propDef.getTypeName())) {
        //we're looking for string value, therefore substring filter should be used
        String text = (String) searchValue.getValue();
        PolyStringNormalizer normalizer = ctx.getDefaultPolyStringNormalizer();
        String value = normalizer.normalize(text);
        return QueryBuilder.queryFor(ObjectType.class, ctx).item(path, propDef).contains(text).matchingNorm().buildFilter();
    }
    if (searchValue instanceof SearchValue) {
        ((SearchValue) searchValue).clear();
    }
    return null;
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) DisplayableValue(com.evolveum.midpoint.util.DisplayableValue) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Example 4 with PolyStringNormalizer

use of com.evolveum.midpoint.prism.polystring.PolyStringNormalizer in project midpoint by Evolveum.

the class PageTasks method createTaskQuery.

private ObjectQuery createTaskQuery() {
    TasksSearchDto dto = searchModel.getObject();
    TaskDtoExecutionStatusFilter status = dto.getStatus();
    String category = dto.getCategory();
    boolean showSubtasks = dto.isShowSubtasks();
    S_AtomicFilterEntry q = QueryBuilder.queryFor(TaskType.class, getPrismContext());
    if (status != null) {
        q = status.appendFilter(q);
    }
    if (category != null && !ALL_CATEGORIES.equals(category)) {
        q = q.item(TaskType.F_CATEGORY).eq(category).and();
    }
    if (StringUtils.isNotBlank(searchText)) {
        PolyStringNormalizer normalizer = getPrismContext().getDefaultPolyStringNormalizer();
        String normalizedString = normalizer.normalize(searchText);
        q = q.item(TaskType.F_NAME).containsPoly(normalizedString, normalizedString).matchingNorm().and();
        // ???
        searchText = "";
    }
    if (!Boolean.TRUE.equals(showSubtasks)) {
        q = q.item(TaskType.F_PARENT).isNull().and();
    }
    return q.all().build();
}
Also used : S_AtomicFilterEntry(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Example 5 with PolyStringNormalizer

use of com.evolveum.midpoint.prism.polystring.PolyStringNormalizer in project midpoint by Evolveum.

the class ObjectSelectionPanel method createObjectQuery.

private ObjectQuery createObjectQuery() {
    ObjectSearchDto dto = searchModel.getObject();
    ObjectQuery query = null;
    if (StringUtils.isEmpty(dto.getText())) {
        if (context.getDataProviderQuery() != null) {
            return context.getDataProviderQuery();
        } else {
            return query;
        }
    }
    try {
        PageBase pageBase = WebComponentUtil.getPageBase(this);
        PrismContext prismContext = pageBase.getPrismContext();
        PolyStringNormalizer normalizer = prismContext.getDefaultPolyStringNormalizer();
        String normalized = normalizer.normalize(dto.getText());
        ObjectFilter filter = QueryBuilder.queryFor(objectType, prismContext).item(context.getSearchProperty()).contains(normalized).matchingNorm().buildFilter();
        if (context.getDataProviderQuery() != null) {
            AndFilter and = AndFilter.createAnd(context.getDataProviderQuery().getFilter(), filter);
            query = ObjectQuery.createObjectQuery(and);
        } else {
            query = ObjectQuery.createObjectQuery(filter);
        }
    } catch (Exception e) {
        error(getString("chooseTypeDialog.message.queryError") + " " + e.getMessage());
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create query filter.", e);
    }
    return query;
}
Also used : AndFilter(com.evolveum.midpoint.prism.query.AndFilter) ObjectSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectSearchDto) PrismContext(com.evolveum.midpoint.prism.PrismContext) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Aggregations

PolyStringNormalizer (com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)11 S_AtomicFilterEntry (com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry)4 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)2 PrismContext (com.evolveum.midpoint.prism.PrismContext)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)1 AlphanumericPolyStringNormalizer (com.evolveum.midpoint.prism.impl.polystring.AlphanumericPolyStringNormalizer)1 Ascii7PolyStringNormalizer (com.evolveum.midpoint.prism.impl.polystring.Ascii7PolyStringNormalizer)1 PrismDefaultPolyStringNormalizer (com.evolveum.midpoint.prism.polystring.PrismDefaultPolyStringNormalizer)1 AndFilter (com.evolveum.midpoint.prism.query.AndFilter)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 S_AtomicFilterExit (com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit)1 DisplayableValue (com.evolveum.midpoint.util.DisplayableValue)1 BasicSearchPanel (com.evolveum.midpoint.web.component.BasicSearchPanel)1 AccountDetailsSearchDto (com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto)1 ObjectSearchDto (com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectSearchDto)1 ReportOutputSearchDto (com.evolveum.midpoint.web.page.admin.reports.dto.ReportOutputSearchDto)1 ReportSearchDto (com.evolveum.midpoint.web.page.admin.reports.dto.ReportSearchDto)1