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