use of com.eaglegenomics.simlims.core.Group in project miso-lims by miso-lims.
the class DefaultTransferServiceTest method testSenderLabChangeAllowed.
@Test
public void testSenderLabChangeAllowed() throws Exception {
Group group1 = makeGroup(1L);
setUser(false, group1);
Transfer before = makeTransfer(makeLab(1L), group1);
Transfer updated = copyTransfer(before);
updated.setSenderLab(makeLab(2L));
List<ValidationError> errors = validate(updated, before);
assertNoError(errors, "Only administrators and members of the recipient group can change sender lab");
}
use of com.eaglegenomics.simlims.core.Group in project miso-lims by miso-lims.
the class DefaultTransferServiceTest method testValidateItemChangeAllowed.
@Test
public void testValidateItemChangeAllowed() throws Exception {
Group group1 = makeGroup(1L);
setUser(false, group1);
Transfer before = makeTransfer(group1, "Recipient");
addTransferSample(before, makeSample(1L), true);
addTransferSample(before, makeSample(2L), true);
Transfer updated = copyTransfer(before);
updated.getSampleTransfers().removeIf(item -> item.getItem().getId() == 2L);
List<ValidationError> errors = validate(updated, before);
assertNoError(errors, "Only administrators and members of the sender group can modify items");
}
use of com.eaglegenomics.simlims.core.Group in project miso-lims by miso-lims.
the class DefaultTransferServiceTest method makeGroup.
private Group makeGroup(long groupId) {
Group group = new Group();
group.setId(groupId);
return group;
}
use of com.eaglegenomics.simlims.core.Group in project miso-lims by miso-lims.
the class DefaultAuthorizationManager method makeGroupList.
private String makeGroupList(Collection<Group> groups) {
StringBuilder sb = new StringBuilder();
int i = 0;
for (Iterator<Group> groupIterator = groups.iterator(); groupIterator.hasNext(); ) {
Group group = groupIterator.next();
if (i != 0) {
sb.append(",' ");
}
if (i > 0 && i == groups.size()) {
sb.append("or ");
}
sb.append("'").append(group.getName());
if (i == groups.size()) {
sb.append("'");
}
i++;
}
return sb.toString();
}
use of com.eaglegenomics.simlims.core.Group in project miso-lims by miso-lims.
the class HibernateSecurityDao method getGroupByName.
@Override
public Group getGroupByName(String groupName) throws IOException {
if (groupName == null)
throw new NullPointerException("Can not get by null group name");
Criteria criteria = currentSession().createCriteria(Group.class);
criteria.add(Restrictions.eq("name", groupName));
return (Group) criteria.uniqueResult();
}
Aggregations