Search in sources :

Example 6 with PolyStringNormalizer

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

the class ObjectQueryUtil method createNormNameQuery.

public static ObjectQuery createNormNameQuery(PolyString name, PrismContext prismContext) throws SchemaException {
    PolyStringNormalizer normalizer = new PrismDefaultPolyStringNormalizer();
    name.recompute(normalizer);
    return QueryBuilder.queryFor(ObjectType.class, prismContext).item(ObjectType.F_NAME).eq(name).matchingNorm().build();
}
Also used : PrismDefaultPolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PrismDefaultPolyStringNormalizer) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer) PrismDefaultPolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PrismDefaultPolyStringNormalizer)

Example 7 with PolyStringNormalizer

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

the class AbstractTreeTablePanel method createOrgChildQuery.

protected ObjectQuery createOrgChildQuery() {
    SelectableBean<OrgType> dto = selected.getObject();
    String oid = dto != null && dto.getValue() != null ? dto.getValue().getOid() : getModel().getObject();
    BasicSearchPanel<String> basicSearch = (BasicSearchPanel) get(createComponentPath(ID_SEARCH_FORM, ID_BASIC_SEARCH));
    String object = basicSearch.getModelObject();
    DropDownChoice<String> searchScopeChoice = (DropDownChoice) get(createComponentPath(ID_SEARCH_FORM, ID_SEARCH_SCOPE));
    String scope = searchScopeChoice.getModelObject();
    if (StringUtils.isBlank(object)) {
        object = null;
    }
    PageBase page = getPageBase();
    PrismContext context = page.getPrismContext();
    S_AtomicFilterExit q;
    if (object == null || SEARCH_SCOPE_ONE.equals(scope)) {
        q = QueryBuilder.queryFor(OrgType.class, context).isDirectChildOf(oid);
    } else {
        q = QueryBuilder.queryFor(OrgType.class, context).isChildOf(oid);
    }
    if (object == null) {
        return q.build();
    }
    PolyStringNormalizer normalizer = context.getDefaultPolyStringNormalizer();
    String normalizedString = normalizer.normalize(object);
    if (StringUtils.isEmpty(normalizedString)) {
        return q.build();
    }
    ObjectQuery query = q.and().block().item(OrgType.F_NAME).containsPoly(normalizedString).matchingNorm().or().item(OrgType.F_DISPLAY_NAME).containsPoly(normalizedString).matchingNorm().build();
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Searching child orgs of org {} with query:\n{}", oid, query.debugDump());
    }
    return query;
}
Also used : DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) BasicSearchPanel(com.evolveum.midpoint.web.component.BasicSearchPanel) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) PrismContext(com.evolveum.midpoint.prism.PrismContext) S_AtomicFilterExit(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Example 8 with PolyStringNormalizer

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

the class PageReports method createQuery.

private ObjectQuery createQuery() {
    ReportSearchDto dto = searchModel.getObject();
    String text = dto.getText();
    Boolean parent = !dto.isParent();
    S_AtomicFilterEntry q = QueryBuilder.queryFor(ReportType.class, getPrismContext());
    if (StringUtils.isNotEmpty(text)) {
        PolyStringNormalizer normalizer = getPrismContext().getDefaultPolyStringNormalizer();
        String normalizedText = normalizer.normalize(text);
        q = q.item(ReportType.F_NAME).eqPoly(normalizedText).matchingNorm().and();
    }
    if (parent) {
        q = q.item(ReportType.F_PARENT).eq(true).and();
    }
    return q.all().build();
}
Also used : ReportSearchDto(com.evolveum.midpoint.web.page.admin.reports.dto.ReportSearchDto) S_AtomicFilterEntry(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterEntry) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Example 9 with PolyStringNormalizer

use of com.evolveum.midpoint.prism.polystring.PolyStringNormalizer 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)

Example 10 with PolyStringNormalizer

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

the class PrismPropertyValue method checkConsistenceInternal.

@Override
public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope) {
    if (!scope.isThorough()) {
        return;
    }
    ItemPath myPath = getPath();
    if (prohibitRaw && rawElement != null) {
        throw new IllegalStateException("Raw element in property value " + this + " (" + myPath + " in " + rootItem + ")");
    }
    if (value == null && rawElement == null && expression == null) {
        throw new IllegalStateException("Neither value, expression nor raw element specified in property value " + this + " (" + myPath + " in " + rootItem + ")");
    }
    if (value != null && rawElement != null) {
        throw new IllegalStateException("Both value and raw element specified in property value " + this + " (" + myPath + " in " + rootItem + ")");
    }
    if (value != null) {
        if (value instanceof Recomputable) {
            try {
                ((Recomputable) value).checkConsistence();
            } catch (IllegalStateException e) {
                throw new IllegalStateException(e.getMessage() + " in property value " + this + " (" + myPath + " in " + rootItem + ")", e);
            }
        }
        if (value instanceof PolyStringType) {
            throw new IllegalStateException("PolyStringType found in property value " + this + " (" + myPath + " in " + rootItem + ")");
        }
        if (value instanceof ProtectedStringType) {
            if (((ProtectedStringType) value).isEmpty()) {
                throw new IllegalStateException("Empty ProtectedStringType found in property value " + this + " (" + myPath + " in " + rootItem + ")");
            }
        }
        PrismContext prismContext = getPrismContext();
        if (value instanceof PolyString && prismContext != null) {
            PolyString poly = (PolyString) value;
            String orig = poly.getOrig();
            String norm = poly.getNorm();
            PolyStringNormalizer polyStringNormalizer = prismContext.getDefaultPolyStringNormalizer();
            String expectedNorm = polyStringNormalizer.normalize(orig);
            if (!norm.equals(expectedNorm)) {
                throw new IllegalStateException("PolyString has inconsistent orig (" + orig + ") and norm (" + norm + ") in property value " + this + " (" + myPath + " in " + rootItem + ")");
            }
        }
    }
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)

Aggregations

PolyStringNormalizer (com.evolveum.midpoint.prism.polystring.PolyStringNormalizer)10 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 PrismDefaultPolyStringNormalizer (com.evolveum.midpoint.prism.polystring.PrismDefaultPolyStringNormalizer)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 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 FailedOperationTypeType (com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType)1 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)1 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)1