Search in sources :

Example 26 with Group

use of com.eaglegenomics.simlims.core.Group in project miso-lims by miso-lims.

the class HibernateSecurityDao method listAllGroups.

@Override
public List<Group> listAllGroups() throws IOException {
    Criteria criteria = currentSession().createCriteria(Group.class);
    @SuppressWarnings("unchecked") List<Group> results = criteria.list();
    return results;
}
Also used : Group(com.eaglegenomics.simlims.core.Group) Criteria(org.hibernate.Criteria)

Example 27 with Group

use of com.eaglegenomics.simlims.core.Group in project miso-lims by miso-lims.

the class HibernateSecurityDaoIT method testSaveGroupNew.

@Test
public void testSaveGroupNew() throws IOException {
    Group group = new Group();
    String name = "new group";
    group.setName(name);
    group.setDescription("test group");
    Set<User> users = new HashSet<>();
    users.add(dao.getUserById(3L));
    group.setUsers(users);
    long savedId = dao.saveGroup(group);
    clearSession();
    Group saved = (Group) currentSession().get(Group.class, savedId);
    assertNotNull(saved);
    assertEquals(name, saved.getName());
}
Also used : Group(com.eaglegenomics.simlims.core.Group) User(com.eaglegenomics.simlims.core.User) HashSet(java.util.HashSet) Test(org.junit.Test) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest)

Example 28 with Group

use of com.eaglegenomics.simlims.core.Group in project miso-lims by miso-lims.

the class HibernateTransferDaoIT method testListByProperties.

@Test
public void testListByProperties() throws Exception {
    Lab sender = (Lab) currentSession().get(LabImpl.class, 1L);
    Group recipient = (Group) currentSession().get(Group.class, 1L);
    Project project = (Project) currentSession().get(ProjectImpl.class, 1L);
    Date transferTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2016-07-07 12:00:00");
    List<Transfer> list = sut.listByProperties(sender, recipient, project, transferTime);
    assertNotNull(list);
    assertEquals(1, list.size());
    Transfer transfer = list.get(0);
    assertEquals(sender.getId(), transfer.getSenderLab().getId());
    assertEquals(recipient.getId(), transfer.getRecipientGroup().getId());
    assertEquals(project.getId(), transfer.getSampleTransfers().iterator().next().getItem().getProject().getId());
    assertEquals(transferTime, transfer.getTransferTime());
}
Also used : Group(com.eaglegenomics.simlims.core.Group) Project(uk.ac.bbsrc.tgac.miso.core.data.Project) ProjectImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.ProjectImpl) Transfer(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer) LabImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.LabImpl) Lab(uk.ac.bbsrc.tgac.miso.core.data.Lab) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest)

Example 29 with Group

use of com.eaglegenomics.simlims.core.Group in project miso-lims by miso-lims.

the class TransferController method setupForm.

public ModelAndView setupForm(Transfer transfer, PageMode pageMode, boolean editSend, boolean editReceipt, ModelMap model) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode formConfig = mapper.createObjectNode();
    formConfig.put(PageMode.PROPERTY, pageMode.getLabel());
    formConfig.put("editSend", editSend);
    formConfig.put("editReceipt", editReceipt);
    Collection<Group> senderGroups = null;
    User user = authorizationManager.getCurrentUser();
    if (user.isAdmin()) {
        senderGroups = groupService.list();
    } else if (editSend && transfer.getSenderLab() == null) {
        senderGroups = user.getGroups();
    } else if (transfer.getSenderGroup() != null) {
        senderGroups = Collections.singleton(transfer.getSenderGroup());
    } else {
        senderGroups = Collections.emptySet();
    }
    MisoWebUtils.addJsonArray(mapper, formConfig, "senderGroups", senderGroups, Dtos::asDto);
    Collection<Group> recipientGroups = null;
    if (user.isAdmin() || editSend) {
        recipientGroups = groupService.list();
    } else if (transfer.getRecipientGroup() != null) {
        recipientGroups = Collections.singleton(transfer.getRecipientGroup());
    } else {
        recipientGroups = Collections.emptySet();
    }
    MisoWebUtils.addJsonArray(mapper, formConfig, "recipientGroups", recipientGroups, Dtos::asDto);
    ObjectNode itemsListConfig = mapper.createObjectNode();
    itemsListConfig.put("editSend", editSend);
    itemsListConfig.put("editReceipt", editReceipt);
    model.put(PageMode.PROPERTY, pageMode.getLabel());
    model.put("transfer", transfer);
    model.put("transferDto", mapper.writeValueAsString(Dtos.asDto(transfer)));
    model.put("formConfig", mapper.writeValueAsString(formConfig));
    model.put("itemsListConfig", mapper.writeValueAsString(itemsListConfig));
    model.put("notificationsEnabled", notificationsEnabled());
    return new ModelAndView("/WEB-INF/pages/editTransfer.jsp", model);
}
Also used : Group(com.eaglegenomics.simlims.core.Group) User(com.eaglegenomics.simlims.core.User) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) ModelAndView(org.springframework.web.servlet.ModelAndView) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

Group (com.eaglegenomics.simlims.core.Group)29 Test (org.junit.Test)13 Transfer (uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer)10 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)7 User (com.eaglegenomics.simlims.core.User)6 ValidationError (uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError)6 Project (uk.ac.bbsrc.tgac.miso.core.data.Project)4 Date (java.util.Date)3 HashSet (java.util.HashSet)3 Lab (uk.ac.bbsrc.tgac.miso.core.data.Lab)3 LabImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.LabImpl)3 UserImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl)3 IlluminaNotificationDto (ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto)2 NotificationDto (ca.on.oicr.gsi.runscanner.dto.NotificationDto)2 OxfordNanoporeNotificationDto (ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto)2 Criteria (org.hibernate.Criteria)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 Library (uk.ac.bbsrc.tgac.miso.core.data.Library)2 Pool (uk.ac.bbsrc.tgac.miso.core.data.Pool)2 Sample (uk.ac.bbsrc.tgac.miso.core.data.Sample)2