use of io.lumeer.api.model.LinkAttributeFilter in project engine by Lumeer.
the class LinkAttributeFilterCodec method convertFromDocument.
public static LinkAttributeFilter convertFromDocument(final Document document) {
String linkTypeId = document.getString(LINK_TYPE_ID);
AttributeFilter filter = AttributeFilterCodec.convertFromDocument(document);
return new LinkAttributeFilter(linkTypeId, filter.getAttributeId(), filter.getCondition(), filter.getConditionValues());
}
use of io.lumeer.api.model.LinkAttributeFilter in project engine by Lumeer.
the class ViewCreator method translateQuery.
private Query translateQuery(final Query query) {
var newStems = new ArrayList<QueryStem>();
query.getStems().forEach(stem -> {
var collectionId = stem.getCollectionId() != null ? templateParser.getDict().getCollectionId(stem.getCollectionId()) : null;
List<String> linkTypeIds = new ArrayList<>();
var linkTypeIdsUsed = false;
if (stem.getLinkTypeIds() != null) {
linkTypeIdsUsed = true;
stem.getLinkTypeIds().forEach(linkTypeId -> linkTypeIds.add(templateParser.getDict().getLinkTypeId(linkTypeId)));
}
Set<String> documentIds = new HashSet<>();
var documentIdsUsed = false;
if (stem.getDocumentIds() != null) {
documentIdsUsed = true;
stem.getDocumentIds().forEach(documentId -> documentIds.add(templateParser.getDict().getDocumentId(documentId)));
}
List<CollectionAttributeFilter> collectionAttributeFilters = new ArrayList<>();
var filtersUsed = false;
if (stem.getFilters() != null) {
filtersUsed = true;
stem.getFilters().forEach(filter -> collectionAttributeFilters.add(new CollectionAttributeFilter(templateParser.getDict().getCollectionId(filter.getCollectionId()), filter.getAttributeId(), filter.getCondition(), filter.getConditionValues())));
}
List<LinkAttributeFilter> linkAttributeFilters = new ArrayList<>();
var linkFiltersUsed = false;
if (stem.getCollectionId() != null) {
linkFiltersUsed = true;
stem.getLinkFilters().forEach(filter -> linkAttributeFilters.add(new LinkAttributeFilter(templateParser.getDict().getLinkTypeId(filter.getLinkTypeId()), filter.getAttributeId(), filter.getCondition(), filter.getConditionValues())));
}
newStems.add(new QueryStem(null, collectionId, linkTypeIdsUsed ? linkTypeIds : null, documentIdsUsed ? documentIds : null, filtersUsed ? collectionAttributeFilters : null, linkFiltersUsed ? linkAttributeFilters : null));
});
return new Query(newStems, query.getFulltexts(), query.getPage(), query.getPageSize());
}
Aggregations