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