use of io.lumeer.api.model.common.Resource in project engine by Lumeer.
the class UserNotificationFacade method createResourceSharedNotifications.
private List<UserNotification> createResourceSharedNotifications(final Resource resource, final java.util.Collection<String> newUsers) {
if (workspaceKeeper.getOrganization().isEmpty() && resource.getType() != ResourceType.ORGANIZATION) {
return Collections.emptyList();
}
final DataDocument data = getResourceDescription(resource);
final List<UserNotification> notifications = newUsers.stream().map(userId -> createNotification(userId, getNotificationTypeByResource(resource), data)).collect(Collectors.toList());
return dao.createNotificationsBatch(notifications);
}
use of io.lumeer.api.model.common.Resource in project engine by Lumeer.
the class FunctionFacade method convertQueueToTask.
public FunctionTask convertQueueToTask(final Deque<FunctionParameterDocuments> queue) {
Set<String> collectionIds = queue.stream().filter(q -> q.getType() == FunctionResourceType.COLLECTION && q.getCollection() == null).map(FunctionParameter::getResourceId).collect(Collectors.toSet());
Set<String> linkTypeIds = queue.stream().filter(q -> q.getType() == FunctionResourceType.LINK && q.getLinkType() == null).map(FunctionParameter::getResourceId).collect(Collectors.toSet());
Map<String, Collection> collectionMap = collectionIds.size() > 0 ? collectionDao.getCollectionsByIds(collectionIds).stream().collect(Collectors.toMap(Resource::getId, c -> c)) : new HashMap<>();
List<LinkType> linkTypes = linkTypeIds.size() > 0 ? linkTypeAdapter.mapLinkTypesComputedProperties(linkTypeDao.getLinkTypesByIds(linkTypeIds)) : new ArrayList<>();
Map<String, LinkType> linkTypeMap = linkTypes.stream().collect(Collectors.toMap(LinkType::getId, c -> c));
FunctionTask task = null;
final Iterator<FunctionParameterDocuments> iterator = queue.descendingIterator();
while (iterator.hasNext()) {
final FunctionParameterDocuments parameter = iterator.next();
if (parameter.getType() == FunctionResourceType.COLLECTION) {
Collection collection = parameter.getCollection() != null ? parameter.getCollection() : collectionMap.get(parameter.getResourceId());
Attribute attribute = parameter.getAttribute() != null ? parameter.getAttribute() : findAttributeInCollection(collection, parameter.getAttributeId());
if (collection != null && attribute != null) {
FunctionTask functionTask = contextualTaskFactory.getInstance(FunctionTask.class);
functionTask.setFunctionTask(attribute, collection, parameter.getDocuments(), task);
task = functionTask;
}
} else if (parameter.getType() == FunctionResourceType.LINK) {
LinkType linkType = parameter.getLinkType() != null ? parameter.getLinkType() : linkTypeMap.get(parameter.getResourceId());
Attribute attribute = parameter.getAttribute() != null ? parameter.getAttribute() : findAttributeInLinkType(linkType, parameter.getAttributeId());
if (linkType != null && attribute != null) {
FunctionTask functionTask = contextualTaskFactory.getInstance(FunctionTask.class);
functionTask.setFunctionTask(attribute, linkType, parameter.getLinkInstances(), task);
task = functionTask;
}
}
}
return task;
}
use of io.lumeer.api.model.common.Resource in project engine by Lumeer.
the class ViewCodec method generateIdIfAbsentFromDocument.
@Override
public View generateIdIfAbsentFromDocument(final View jsonView) {
Resource resource = generateIdIfAbsentFromDocument((Resource) jsonView);
jsonView.setId(resource.getId());
return jsonView;
}
use of io.lumeer.api.model.common.Resource in project engine by Lumeer.
the class CollectionCodec method generateIdIfAbsentFromDocument.
@Override
public Collection generateIdIfAbsentFromDocument(final Collection jsonCollection) {
Resource resource = generateIdIfAbsentFromDocument((Resource) jsonCollection);
jsonCollection.setId(resource.getId());
return jsonCollection;
}
use of io.lumeer.api.model.common.Resource in project engine by Lumeer.
the class PermissionsCheckerTest method testGetActualRolesEmpty.
@Test
public void testGetActualRolesEmpty() {
Resource resource = prepareResource(Collections.emptySet(), Collections.emptySet());
Set<RoleType> roles = permissionsChecker.getActualRoles(resource);
assertThat(roles).isEmpty();
}
Aggregations