Search in sources :

Example 1 with AttachmentCategory

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;
}
Also used : AttachmentCategory(uk.ac.bbsrc.tgac.miso.core.data.impl.AttachmentCategory) IonTorrentRunDto(uk.ac.bbsrc.tgac.miso.dto.run.IonTorrentRunDto) QcHierarchyNodeDto(uk.ac.bbsrc.tgac.miso.dto.dashi.QcHierarchyNodeDto) RunPositionDto(uk.ac.bbsrc.tgac.miso.dto.run.RunPositionDto) PacBioRunDto(uk.ac.bbsrc.tgac.miso.dto.run.PacBioRunDto) Ls454RunDto(uk.ac.bbsrc.tgac.miso.dto.run.Ls454RunDto) IlluminaNotificationDto(ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto) OxfordNanoporeRunDto(uk.ac.bbsrc.tgac.miso.dto.run.OxfordNanoporeRunDto) IlluminaRunDto(uk.ac.bbsrc.tgac.miso.dto.run.IlluminaRunDto) NotificationDto(ca.on.oicr.gsi.runscanner.dto.NotificationDto) OxfordNanoporeNotificationDto(ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto) RunDto(uk.ac.bbsrc.tgac.miso.dto.run.RunDto) SolidRunDto(uk.ac.bbsrc.tgac.miso.dto.run.SolidRunDto) OrderAliquotDto(uk.ac.bbsrc.tgac.miso.dto.PoolOrderDto.OrderAliquotDto)

Example 2 with AttachmentCategory

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);
}
Also used : AttachmentCategory(uk.ac.bbsrc.tgac.miso.core.data.impl.AttachmentCategory)

Example 3 with AttachmentCategory

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);
    }
}
Also used : MultipartFile(org.springframework.web.multipart.MultipartFile) ArrayList(java.util.ArrayList) ClientErrorException(uk.ac.bbsrc.tgac.miso.webapp.controller.component.ClientErrorException) 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)

Example 4 with AttachmentCategory

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());
}
Also used : AttachmentCategory(uk.ac.bbsrc.tgac.miso.core.data.impl.AttachmentCategory) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Example 5 with AttachmentCategory

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);
}
Also used : AttachmentCategory(uk.ac.bbsrc.tgac.miso.core.data.impl.AttachmentCategory) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Aggregations

AttachmentCategory (uk.ac.bbsrc.tgac.miso.core.data.impl.AttachmentCategory)10 Test (org.junit.Test)5 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)5 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)2 MultipartFile (org.springframework.web.multipart.MultipartFile)2 Attachable (uk.ac.bbsrc.tgac.miso.core.data.Attachable)2 IlluminaNotificationDto (ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto)1 NotificationDto (ca.on.oicr.gsi.runscanner.dto.NotificationDto)1 OxfordNanoporeNotificationDto (ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto)1 ArrayList (java.util.ArrayList)1 NotFoundException (org.springframework.security.acls.model.NotFoundException)1 OrderAliquotDto (uk.ac.bbsrc.tgac.miso.dto.PoolOrderDto.OrderAliquotDto)1 QcHierarchyNodeDto (uk.ac.bbsrc.tgac.miso.dto.dashi.QcHierarchyNodeDto)1 IlluminaRunDto (uk.ac.bbsrc.tgac.miso.dto.run.IlluminaRunDto)1 IonTorrentRunDto (uk.ac.bbsrc.tgac.miso.dto.run.IonTorrentRunDto)1 Ls454RunDto (uk.ac.bbsrc.tgac.miso.dto.run.Ls454RunDto)1 OxfordNanoporeRunDto (uk.ac.bbsrc.tgac.miso.dto.run.OxfordNanoporeRunDto)1 PacBioRunDto (uk.ac.bbsrc.tgac.miso.dto.run.PacBioRunDto)1 RunDto (uk.ac.bbsrc.tgac.miso.dto.run.RunDto)1