use of uk.ac.bbsrc.tgac.miso.core.data.impl.AttachmentCategory in project miso-lims by miso-lims.
the class Dtos method to.
public static AttachmentCategory to(@Nonnull AttachmentCategoryDto from) {
AttachmentCategory to = new AttachmentCategory();
setLong(to::setId, from.getId(), false);
setString(to::setAlias, from.getAlias());
return to;
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.AttachmentCategory in project miso-lims by miso-lims.
the class AttachmentCategoryRestController method doSave.
private AttachmentCategoryDto doSave(AttachmentCategoryDto dto) throws IOException {
AttachmentCategory category = Dtos.to(dto);
long id = attachmentCategoryService.save(category);
constantsController.refreshConstants();
AttachmentCategory saved = attachmentCategoryService.get(id);
return Dtos.asDto(saved);
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.AttachmentCategory in project miso-lims by miso-lims.
the class AttachmentController method acceptSharedUpload.
@PostMapping(value = "/{entityType}/shared")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void acceptSharedUpload(@PathVariable String entityType, @RequestParam String entityIds, @RequestParam(required = false) Long categoryId, @RequestParam("files") MultipartFile[] files) throws IOException {
List<Attachable> items = new ArrayList<>();
for (Long id : LimsUtils.parseIds(entityIds)) {
Attachable item = fileAttachmentService.get(entityType, id);
if (item == null) {
throw new ClientErrorException(String.format("%s %d not found", entityType, id));
} else {
items.add(item);
}
}
AttachmentCategory category = getCategory(categoryId);
for (MultipartFile fileItem : files) {
fileAttachmentService.addShared(items, fileItem, category);
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.AttachmentCategory in project miso-lims by miso-lims.
the class HibernateAttachmentCategoryDaoIT method testUpdate.
@Test
public void testUpdate() throws IOException {
String alias = "changed";
AttachmentCategory cat = (AttachmentCategory) sessionFactory.getCurrentSession().get(AttachmentCategory.class, 1L);
assertNotEquals(alias, cat.getAlias());
cat.setAlias(alias);
assertTrue(cat.isSaved());
sut.save(cat);
sessionFactory.getCurrentSession().flush();
sessionFactory.getCurrentSession().clear();
AttachmentCategory saved = (AttachmentCategory) sessionFactory.getCurrentSession().get(AttachmentCategory.class, cat.getId());
assertEquals(alias, saved.getAlias());
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.AttachmentCategory in project miso-lims by miso-lims.
the class HibernateAttachmentCategoryDaoIT method testGetUsage.
@Test
public void testGetUsage() {
AttachmentCategory cat = (AttachmentCategory) sessionFactory.getCurrentSession().get(AttachmentCategory.class, 1L);
assertNotNull(cat);
long usage = sut.getUsage(cat);
assertEquals(3L, usage);
}
Aggregations