Search in sources :

Example 1 with Group

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

the class DefaultTransferServiceTest method validateRecipientChangeAllowed.

@Test
public void validateRecipientChangeAllowed() throws Exception {
    Group group1 = makeGroup(1L);
    setUser(false, group1);
    Transfer before = makeTransfer(group1, "Recipient");
    Transfer updated = copyTransfer(before);
    updated.setRecipient("Changed");
    List<ValidationError> errors = validate(updated, before);
    assertNoError(errors, "Only administrators and members of the sender group can change recipient");
}
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 2 with Group

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

the class DefaultTransferServiceTest method validateRecipientGroupChangeAllowed.

@Test
public void validateRecipientGroupChangeAllowed() throws Exception {
    Group group1 = makeGroup(1L);
    setUser(false, group1);
    Transfer before = makeTransfer(group1, makeGroup(2L));
    Transfer updated = copyTransfer(before);
    updated.setRecipientGroup(makeGroup(3L));
    List<ValidationError> errors = validate(updated, before);
    assertNoError(errors, "Only administrators and members of the sender group can change recipient group");
}
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 3 with Group

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

the class DefaultTransferServiceTest method setUser.

private void setUser(boolean isAdmin, Group... groups) throws IOException {
    User user = new UserImpl();
    user.setId(1L);
    Mockito.when(authorizationManager.getCurrentUser()).thenReturn(user);
    Mockito.when(authorizationManager.isAdminUser()).thenReturn(isAdmin);
    Mockito.when(authorizationManager.isGroupMember(Mockito.any())).thenReturn(false);
    if (groups.length > 0) {
        for (Group group : groups) {
            Mockito.when(authorizationManager.isGroupMember(group)).thenReturn(true);
        }
    }
}
Also used : Group(com.eaglegenomics.simlims.core.Group) User(com.eaglegenomics.simlims.core.User) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl)

Example 4 with Group

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

the class Dtos method to.

public static Transfer to(@Nonnull TransferDto from) {
    Transfer to = new Transfer();
    setLong(to::setId, from.getId(), false);
    setString(to::setTransferRequestName, from.getTransferRequestName());
    setDateTime(to::setTransferTime, from.getTransferTime());
    setObject(to::setSenderLab, LabImpl::new, from.getSenderLabId());
    setObject(to::setSenderGroup, Group::new, from.getSenderGroupId());
    setString(to::setRecipient, from.getRecipient());
    setObject(to::setRecipientGroup, Group::new, from.getRecipientGroupId());
    addTransferItems(to::getSampleTransfers, from.getItems(), EntityType.SAMPLE, TransferSample::new, SampleImpl::new, SampleBoxPosition::new, Sample::setBoxPosition);
    addTransferItems(to::getLibraryTransfers, from.getItems(), EntityType.LIBRARY, TransferLibrary::new, LibraryImpl::new, LibraryBoxPosition::new, Library::setBoxPosition);
    addTransferItems(to::getLibraryAliquotTransfers, from.getItems(), EntityType.LIBRARY_ALIQUOT, TransferLibraryAliquot::new, LibraryAliquot::new, LibraryAliquotBoxPosition::new, LibraryAliquot::setBoxPosition);
    addTransferItems(to::getPoolTransfers, from.getItems(), EntityType.POOL, TransferPool::new, PoolImpl::new, PoolBoxPosition::new, Pool::setBoxPosition);
    return to;
}
Also used : Group(com.eaglegenomics.simlims.core.Group) TransferPool(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferPool) ParentSample(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentSample) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) WorksetSample(uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetSample) GrandparentSample(uk.ac.bbsrc.tgac.miso.core.data.impl.view.GrandparentSample) TransferSample(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferSample) LibraryAliquotBoxPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.boxposition.LibraryAliquotBoxPosition) LibraryBoxPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.boxposition.LibraryBoxPosition) LabImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.LabImpl) TransferSample(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferSample) TransferLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibraryAliquot) WorksetLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetLibraryAliquot) OrderLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.OrderLibraryAliquot) DetailedLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.DetailedLibraryAliquot) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) PoolImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolImpl) TransferLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibraryAliquot) SampleBoxPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.boxposition.SampleBoxPosition) TransferLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibrary) PoolBoxPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.boxposition.PoolBoxPosition) LibraryImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryImpl) DetailedLibraryImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.DetailedLibraryImpl) Transfer(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer) TransferPool(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferPool) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) InstrumentStatusPositionRunPool(uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPositionRunPool) 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) TransferLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibrary) ParentLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentLibrary) DetailedLibrary(uk.ac.bbsrc.tgac.miso.core.data.DetailedLibrary) WorksetLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetLibrary) Library(uk.ac.bbsrc.tgac.miso.core.data.Library) SampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl) DetailedSampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.DetailedSampleImpl)

Example 5 with Group

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

the class Dtos method toReceiptTransfer.

private static <T extends Boxable, R extends TransferItem<T>> R toReceiptTransfer(@Nonnull ReceivableDto<T, R> from, @Nonnull T item) {
    if (isStringEmptyOrNull(from.getReceivedTime())) {
        return null;
    }
    R transferItem = from.makeTransferItem();
    transferItem.setItem(item);
    setBoolean(transferItem::setReceived, from.isReceived(), true);
    setBoolean(transferItem::setQcPassed, from.isReceiptQcPassed(), true);
    setString(transferItem::setQcNote, from.getReceiptQcNote());
    Transfer transfer = new Transfer();
    transferItem.setTransfer(transfer);
    from.getTransferItemsFunction().apply(transfer).add(transferItem);
    setDateTime(transfer::setTransferTime, from.getReceivedTime());
    setObject(transfer::setSenderLab, LabImpl::new, from.getSenderLabId());
    setObject(transfer::setRecipientGroup, Group::new, from.getRecipientGroupId());
    return transferItem;
}
Also used : Group(com.eaglegenomics.simlims.core.Group) Transfer(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer) LabImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.LabImpl)

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