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