Search in sources :

Example 1 with LinkDataDao

use of io.lumeer.storage.api.dao.LinkDataDao in project engine by Lumeer.

the class FileAttachmentFacade method filterLinkAttachments.

private List<FileAttachment> filterLinkAttachments(final List<FileAttachment> attachments, final String linkTypeId) {
    LinkType linkType = linkTypeDao.getLinkType(linkTypeId);
    Set<String> linkIds = attachments.stream().map(FileAttachment::getDocumentId).collect(Collectors.toSet());
    List<LinkInstance> linkInstances = linkInstanceDao.getLinkInstances(linkIds);
    Map<String, LinkInstance> linkInstanceMap = LinkInstanceUtils.loadLinkInstancesData(linkDataDao, linkType, linkInstances).stream().collect(Collectors.toMap(LinkInstance::getId, doc -> doc));
    return attachments.stream().filter(fileAttachment -> permissionsChecker.canReadLinkInstance(linkType, linkInstanceMap.get(fileAttachment.getDocumentId()))).collect(Collectors.toList());
}
Also used : ZonedDateTime(java.time.ZonedDateTime) LinkTypeDao(io.lumeer.storage.api.dao.LinkTypeDao) LinkInstanceUtils(io.lumeer.core.util.LinkInstanceUtils) HashSet(java.util.HashSet) Inject(javax.inject.Inject) LumeerS3Client(io.lumeer.core.util.LumeerS3Client) CollectionDao(io.lumeer.storage.api.dao.CollectionDao) DataDao(io.lumeer.storage.api.dao.DataDao) Map(java.util.Map) URI(java.net.URI) InvalidValueException(io.lumeer.engine.api.exception.InvalidValueException) DocumentDao(io.lumeer.storage.api.dao.DocumentDao) Document(io.lumeer.api.model.Document) Set(java.util.Set) Collectors(java.util.stream.Collectors) LinkInstance(io.lumeer.api.model.LinkInstance) FileAttachmentAdapter(io.lumeer.core.adapter.FileAttachmentAdapter) LinkType(io.lumeer.api.model.LinkType) DocumentUtils(io.lumeer.core.util.DocumentUtils) FileAttachment(io.lumeer.api.model.FileAttachment) LinkInstanceDao(io.lumeer.storage.api.dao.LinkInstanceDao) DefaultConfigurationProducer(io.lumeer.core.facade.configuration.DefaultConfigurationProducer) StorageException(io.lumeer.storage.api.exception.StorageException) List(java.util.List) FileAttachmentDao(io.lumeer.storage.api.dao.FileAttachmentDao) RequestScoped(javax.enterprise.context.RequestScoped) PostConstruct(javax.annotation.PostConstruct) LinkDataDao(io.lumeer.storage.api.dao.LinkDataDao) Collections(java.util.Collections) Collection(io.lumeer.api.model.Collection) LinkInstance(io.lumeer.api.model.LinkInstance) LinkType(io.lumeer.api.model.LinkType)

Example 2 with LinkDataDao

use of io.lumeer.storage.api.dao.LinkDataDao in project engine by Lumeer.

the class AuditFacade method getAuditRecordsForLink.

public List<AuditRecord> getAuditRecordsForLink(final String linkTypeId, final String linkInstanceId) {
    final LinkType linkType = linkTypeDao.getLinkType(linkTypeId);
    final LinkInstance linkInstance = LinkInstanceUtils.loadLinkInstanceWithData(linkInstanceDao, linkDataDao, linkInstanceId);
    permissionsChecker.checkEditLinkInstance(linkType, linkInstance);
    return auditAdapter.getAuditRecords(linkTypeId, ResourceType.LINK, linkInstanceId, getServiceLevel()).stream().peek(link -> decode(linkType, link)).collect(toList());
}
Also used : CollectionUtil(io.lumeer.api.util.CollectionUtil) ZonedDateTime(java.time.ZonedDateTime) User(io.lumeer.api.model.User) LinkTypeDao(io.lumeer.storage.api.dao.LinkTypeDao) UpdateDefaultWorkspace(io.lumeer.engine.api.event.UpdateDefaultWorkspace) UnsupportedOperationException(io.lumeer.core.exception.UnsupportedOperationException) CreateLinkInstance(io.lumeer.engine.api.event.CreateLinkInstance) CollectionDao(io.lumeer.storage.api.dao.CollectionDao) ResourceType(io.lumeer.api.model.ResourceType) Resource(io.lumeer.api.model.common.Resource) Map(java.util.Map) Observes(javax.enterprise.event.Observes) ResourceCommentDao(io.lumeer.storage.api.dao.ResourceCommentDao) RequestDataKeeper(io.lumeer.core.auth.RequestDataKeeper) CollectionAdapter(io.lumeer.core.adapter.CollectionAdapter) ServiceLimits(io.lumeer.api.model.ServiceLimits) ConstraintManager(io.lumeer.core.constraint.ConstraintManager) RoleType(io.lumeer.api.model.RoleType) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document) RemoveDocument(io.lumeer.engine.api.event.RemoveDocument) CreateDocument(io.lumeer.engine.api.event.CreateDocument) Set(java.util.Set) Collectors(java.util.stream.Collectors) Constraint(io.lumeer.api.model.Constraint) LinkInstance(io.lumeer.api.model.LinkInstance) LinkType(io.lumeer.api.model.LinkType) DefaultConfigurationProducer(io.lumeer.core.facade.configuration.DefaultConfigurationProducer) List(java.util.List) AuditRecord(io.lumeer.api.model.AuditRecord) PusherClient(io.lumeer.core.util.PusherClient) PostConstruct(javax.annotation.PostConstruct) FavoriteItemDao(io.lumeer.storage.api.dao.FavoriteItemDao) Attribute(io.lumeer.api.model.Attribute) Utils(io.lumeer.core.util.Utils) LinkInstanceAdapter(io.lumeer.core.adapter.LinkInstanceAdapter) UserDao(io.lumeer.storage.api.dao.UserDao) AuditType(io.lumeer.api.model.AuditType) HashMap(java.util.HashMap) DocumentAdapter(io.lumeer.core.adapter.DocumentAdapter) Event(org.marvec.pusher.data.Event) LinkInstanceUtils(io.lumeer.core.util.LinkInstanceUtils) GroupDao(io.lumeer.storage.api.dao.GroupDao) HashSet(java.util.HashSet) Inject(javax.inject.Inject) DataDao(io.lumeer.storage.api.dao.DataDao) ViewDao(io.lumeer.storage.api.dao.ViewDao) Organization(io.lumeer.api.model.Organization) DocumentDao(io.lumeer.storage.api.dao.DocumentDao) ResourceAdapter(io.lumeer.core.adapter.ResourceAdapter) AuditAdapter(io.lumeer.core.adapter.AuditAdapter) LinkTypeAdapter(io.lumeer.core.adapter.LinkTypeAdapter) Payment(io.lumeer.api.model.Payment) DocumentUtils(io.lumeer.core.util.DocumentUtils) RemoveLinkInstance(io.lumeer.engine.api.event.RemoveLinkInstance) Project(io.lumeer.api.model.Project) UpdateLinkInstance(io.lumeer.engine.api.event.UpdateLinkInstance) LinkInstanceDao(io.lumeer.storage.api.dao.LinkInstanceDao) AuditDao(io.lumeer.storage.api.dao.AuditDao) PermissionAdapter(io.lumeer.core.adapter.PermissionAdapter) PusherAdapter(io.lumeer.core.adapter.PusherAdapter) RequestScoped(javax.enterprise.context.RequestScoped) LinkDataDao(io.lumeer.storage.api.dao.LinkDataDao) UpdateDocument(io.lumeer.engine.api.event.UpdateDocument) Collections(java.util.Collections) Collection(io.lumeer.api.model.Collection) CreateLinkInstance(io.lumeer.engine.api.event.CreateLinkInstance) LinkInstance(io.lumeer.api.model.LinkInstance) RemoveLinkInstance(io.lumeer.engine.api.event.RemoveLinkInstance) UpdateLinkInstance(io.lumeer.engine.api.event.UpdateLinkInstance) LinkType(io.lumeer.api.model.LinkType)

Aggregations

Collection (io.lumeer.api.model.Collection)2 Document (io.lumeer.api.model.Document)2 LinkInstance (io.lumeer.api.model.LinkInstance)2 LinkType (io.lumeer.api.model.LinkType)2 DefaultConfigurationProducer (io.lumeer.core.facade.configuration.DefaultConfigurationProducer)2 DocumentUtils (io.lumeer.core.util.DocumentUtils)2 LinkInstanceUtils (io.lumeer.core.util.LinkInstanceUtils)2 CollectionDao (io.lumeer.storage.api.dao.CollectionDao)2 DataDao (io.lumeer.storage.api.dao.DataDao)2 DocumentDao (io.lumeer.storage.api.dao.DocumentDao)2 LinkDataDao (io.lumeer.storage.api.dao.LinkDataDao)2 LinkInstanceDao (io.lumeer.storage.api.dao.LinkInstanceDao)2 LinkTypeDao (io.lumeer.storage.api.dao.LinkTypeDao)2 ZonedDateTime (java.time.ZonedDateTime)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2