Search in sources :

Example 11 with Attachable

use of uk.ac.bbsrc.tgac.miso.core.data.Attachable in project miso-lims by miso-lims.

the class DefaultFileAttachmentService method addLink.

@Override
public void addLink(Attachable object, FileAttachment attachment) throws IOException {
    Attachable managedObject = attachableStore.getManaged(object);
    FileAttachment managedAttachment = getManaged(attachment);
    addLinkIfNecessary(managedObject, managedAttachment);
}
Also used : FileAttachment(uk.ac.bbsrc.tgac.miso.core.data.impl.FileAttachment) Attachable(uk.ac.bbsrc.tgac.miso.core.data.Attachable)

Example 12 with Attachable

use of uk.ac.bbsrc.tgac.miso.core.data.Attachable in project miso-lims by miso-lims.

the class HibernateAttachableDaoIT method testGetManagedAttachable.

@Test
public void testGetManagedAttachable() throws Exception {
    Sample sample = (Sample) currentSession().get(SampleImpl.class, 1L);
    Attachable attachable = sut.getManaged(sample);
    assertTrue(attachable instanceof Sample);
    assertEquals(sample.getId(), attachable.getId());
}
Also used : Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) Attachable(uk.ac.bbsrc.tgac.miso.core.data.Attachable) SampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl) Test(org.junit.Test) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest)

Example 13 with Attachable

use of uk.ac.bbsrc.tgac.miso.core.data.Attachable in project miso-lims by miso-lims.

the class AttachmentController method acceptUpload.

@PostMapping(value = "/{entityType}/{entityId}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void acceptUpload(@PathVariable String entityType, @PathVariable long entityId, @RequestParam(required = false) Long categoryId, @RequestParam("files") MultipartFile[] files) throws IOException {
    Attachable item = fileAttachmentService.get(entityType, entityId);
    if (item == null) {
        throw new NotFoundException(entityType + " not found");
    }
    AttachmentCategory category = getCategory(categoryId);
    for (MultipartFile fileItem : files) {
        fileAttachmentService.add(item, fileItem, category);
    }
}
Also used : MultipartFile(org.springframework.web.multipart.MultipartFile) NotFoundException(org.springframework.security.acls.model.NotFoundException) AttachmentCategory(uk.ac.bbsrc.tgac.miso.core.data.impl.AttachmentCategory) Attachable(uk.ac.bbsrc.tgac.miso.core.data.Attachable) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Aggregations

Attachable (uk.ac.bbsrc.tgac.miso.core.data.Attachable)13 FileAttachment (uk.ac.bbsrc.tgac.miso.core.data.impl.FileAttachment)9 MultipartFile (org.springframework.web.multipart.MultipartFile)6 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)5 File (java.io.File)4 IOException (java.io.IOException)4 PostMapping (org.springframework.web.bind.annotation.PostMapping)4 ArrayList (java.util.ArrayList)2 NotFoundException (org.springframework.security.acls.model.NotFoundException)2 AttachmentCategory (uk.ac.bbsrc.tgac.miso.core.data.impl.AttachmentCategory)2 ClientErrorException (uk.ac.bbsrc.tgac.miso.webapp.controller.component.ClientErrorException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 FileInputStream (java.io.FileInputStream)1 OutputStream (java.io.OutputStream)1 Test (org.junit.Test)1 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)1 Sample (uk.ac.bbsrc.tgac.miso.core.data.Sample)1 SampleImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl)1