Search in sources :

Example 21 with Group

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");
}
Also used : Group(com.eaglegenomics.simlims.core.Group) Transfer(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) Test(org.junit.Test)

Example 22 with Group

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");
}
Also used : Group(com.eaglegenomics.simlims.core.Group) Transfer(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) Test(org.junit.Test)

Example 23 with Group

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;
}
Also used : Group(com.eaglegenomics.simlims.core.Group)

Example 24 with 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();
}
Also used : Group(com.eaglegenomics.simlims.core.Group)

Example 25 with Group

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();
}
Also used : Group(com.eaglegenomics.simlims.core.Group) Criteria(org.hibernate.Criteria)

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