Search in sources :

Example 1 with LinkAttributeFilter

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());
}
Also used : LinkAttributeFilter(io.lumeer.api.model.LinkAttributeFilter) AttributeFilter(io.lumeer.api.model.AttributeFilter) LinkAttributeFilter(io.lumeer.api.model.LinkAttributeFilter)

Example 2 with LinkAttributeFilter

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());
}
Also used : CollectionAttributeFilter(io.lumeer.api.model.CollectionAttributeFilter) Query(io.lumeer.api.model.Query) LinkAttributeFilter(io.lumeer.api.model.LinkAttributeFilter) ArrayList(java.util.ArrayList) QueryStem(io.lumeer.api.model.QueryStem) HashSet(java.util.HashSet)

Aggregations

LinkAttributeFilter (io.lumeer.api.model.LinkAttributeFilter)2 AttributeFilter (io.lumeer.api.model.AttributeFilter)1 CollectionAttributeFilter (io.lumeer.api.model.CollectionAttributeFilter)1 Query (io.lumeer.api.model.Query)1 QueryStem (io.lumeer.api.model.QueryStem)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1