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