use of org.finos.waltz.schema.tables.LogicalDataElement.LOGICAL_DATA_ELEMENT in project waltz by khartec.
the class LogicalDataElementSearchDao method search.
@Override
public List<LogicalDataElement> search(EntitySearchOptions options) {
List<String> terms = SearchUtilities.mkTerms(options.searchQuery());
if (terms.isEmpty()) {
return Collections.emptyList();
}
Set<String> validStatusNames = EnumUtilities.names(options.entityLifecycleStatuses());
Condition statusCondition = LOGICAL_DATA_ELEMENT.ENTITY_LIFECYCLE_STATUS.in(validStatusNames);
Condition likeName = JooqUtilities.mkBasicTermSearch(LOGICAL_DATA_ELEMENT.NAME, terms);
Condition likeDesc = JooqUtilities.mkBasicTermSearch(LOGICAL_DATA_ELEMENT.DESCRIPTION, terms);
List<LogicalDataElement> results = dsl.select(LOGICAL_DATA_ELEMENT.fields()).from(LOGICAL_DATA_ELEMENT).where(likeName.and(statusCondition)).union(dsl.select(LOGICAL_DATA_ELEMENT.fields()).from(LOGICAL_DATA_ELEMENT).where(likeDesc.and(statusCondition))).orderBy(LOGICAL_DATA_ELEMENT.NAME).limit(options.limit()).fetch(LogicalDataElementDao.TO_DOMAIN_MAPPER);
List<LogicalDataElement> sortedResults = sort(results, SearchUtilities.mkRelevancyComparator(a -> a.name(), terms.get(0)));
return sortedResults;
}
Aggregations