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();
}
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;
}
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();
}
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);
}
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 + ")");
}
}
}
}
Aggregations