Search in sources :

Example 1 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class SuggestionFacade method suggestLinkTypes.

private List<LinkType> suggestLinkTypes(String text, int limit) {
    List<Collection> allowedCollections = collectionDao.getCollections(createSimpleSearchQuery());
    if (allowedCollections.isEmpty()) {
        return Collections.emptyList();
    }
    List<String> allowedCollectionIds = allowedCollections.stream().map(Collection::getId).collect(Collectors.toList());
    SuggestionQuery suggestionQuery = createSuggestionQueryWithIds(text, limit, allowedCollectionIds);
    List<LinkType> linkTypes = linkTypeDao.getLinkTypes(suggestionQuery);
    return linkTypes.stream().filter(linkType -> allowedCollectionIds.containsAll(linkType.getCollectionIds())).collect(Collectors.toList());
}
Also used : View(io.lumeer.api.model.View) LinkTypeDao(io.lumeer.storage.api.dao.LinkTypeDao) Set(java.util.Set) SearchQuery(io.lumeer.storage.api.query.SearchQuery) Collectors(java.util.stream.Collectors) LinkType(io.lumeer.api.model.LinkType) SuggestionType(io.lumeer.api.model.SuggestionType) Inject(javax.inject.Inject) List(java.util.List) CollectionDao(io.lumeer.storage.api.dao.CollectionDao) ViewDao(io.lumeer.storage.api.dao.ViewDao) RequestScoped(javax.enterprise.context.RequestScoped) SuggestionQuery(io.lumeer.storage.api.query.SuggestionQuery) Attribute(io.lumeer.api.model.Attribute) JsonSuggestions(io.lumeer.api.dto.JsonSuggestions) Collections(java.util.Collections) Collection(io.lumeer.api.model.Collection) SuggestionQuery(io.lumeer.storage.api.query.SuggestionQuery) Collection(io.lumeer.api.model.Collection) LinkType(io.lumeer.api.model.LinkType)

Example 2 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class SuggestionFacade method keepOnlyMatchingAttributes.

private static List<Collection> keepOnlyMatchingAttributes(List<Collection> collections, String text) {
    for (Collection collection : collections) {
        Set<Attribute> attributes = collection.getAttributes().stream().filter(a -> a.getName().toLowerCase().contains(text)).collect(Collectors.toSet());
        collection.setAttributes(attributes);
    }
    return collections;
}
Also used : View(io.lumeer.api.model.View) LinkTypeDao(io.lumeer.storage.api.dao.LinkTypeDao) Set(java.util.Set) SearchQuery(io.lumeer.storage.api.query.SearchQuery) Collectors(java.util.stream.Collectors) LinkType(io.lumeer.api.model.LinkType) SuggestionType(io.lumeer.api.model.SuggestionType) Inject(javax.inject.Inject) List(java.util.List) CollectionDao(io.lumeer.storage.api.dao.CollectionDao) ViewDao(io.lumeer.storage.api.dao.ViewDao) RequestScoped(javax.enterprise.context.RequestScoped) SuggestionQuery(io.lumeer.storage.api.query.SuggestionQuery) Attribute(io.lumeer.api.model.Attribute) JsonSuggestions(io.lumeer.api.dto.JsonSuggestions) Collections(java.util.Collections) Collection(io.lumeer.api.model.Collection) Attribute(io.lumeer.api.model.Attribute) Collection(io.lumeer.api.model.Collection)

Example 3 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class CollectionFacade method createCollection.

public Collection createCollection(Collection collection) {
    checkProjectWriteRole();
    Collection storedCollection = createCollectionMetadata(collection);
    dataDao.createDataRepository(storedCollection.getId());
    return keepOnlyActualUserRoles(storedCollection);
}
Also used : Collection(io.lumeer.api.model.Collection)

Example 4 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class CollectionFacade method getCollectionPermissions.

public Permissions getCollectionPermissions(final String collectionId) {
    Collection collection = collectionDao.getCollectionById(collectionId);
    permissionsChecker.checkRole(collection, Role.MANAGE);
    return collection.getPermissions();
}
Also used : Collection(io.lumeer.api.model.Collection)

Example 5 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class CollectionFacade method updateCollection.

public Collection updateCollection(String collectionId, Collection collection) {
    Collection storedCollection = collectionDao.getCollectionById(collectionId);
    permissionsChecker.checkRole(storedCollection, Role.MANAGE);
    keepUnmodifiableFields(collection, storedCollection);
    Collection updatedCollection = collectionDao.updateCollection(storedCollection.getId(), collection);
    return keepOnlyActualUserRoles(updatedCollection);
}
Also used : Collection(io.lumeer.api.model.Collection)

Aggregations

Collection (io.lumeer.api.model.Collection)77 Test (org.junit.Test)47 JsonCollection (io.lumeer.api.dto.JsonCollection)34 DataDocument (io.lumeer.engine.api.data.DataDocument)17 MorphiaCollection (io.lumeer.storage.mongodb.model.MorphiaCollection)17 SearchQuery (io.lumeer.storage.api.query.SearchQuery)14 SoftAssertions (org.assertj.core.api.SoftAssertions)12 Document (io.lumeer.api.model.Document)8 ImportedCollection (io.lumeer.api.model.ImportedCollection)8 SuggestionQuery (io.lumeer.storage.api.query.SuggestionQuery)8 Response (javax.ws.rs.core.Response)8 JsonAttribute (io.lumeer.api.dto.JsonAttribute)7 Attribute (io.lumeer.api.model.Attribute)7 HashSet (java.util.HashSet)6 JsonQuery (io.lumeer.api.dto.JsonQuery)5 LocalDateTime (java.time.LocalDateTime)4 List (java.util.List)4 JsonDocument (io.lumeer.api.dto.JsonDocument)3 LinkType (io.lumeer.api.model.LinkType)3 CollectionDao (io.lumeer.storage.api.dao.CollectionDao)3