Search in sources :

Example 1 with SequencingOrder

use of uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder in project miso-lims by miso-lims.

the class BulkSequencingOrderIT method testCreate.

@Test
public void testCreate() {
    BulkSequencingOrderPage page = BulkSequencingOrderPage.getForCreate(getDriver(), getBaseUrl(), Sets.newHashSet(120001L));
    HandsOnTable table = page.getTable();
    // test initial values
    Map<String, String> attrs = Maps.newLinkedHashMap();
    attrs.put(Columns.NAME, "IPO120001");
    attrs.put(Columns.ALIAS, "1IPO_POOL_1");
    assertColumnValues(table, 0, attrs, "initial");
    // make changes
    Map<String, String> changes = Maps.newLinkedHashMap();
    changes.put(Columns.PURPOSE, "Production");
    changes.put(Columns.INSTRUMENT_MODEL, "Illumina HiSeq 2500");
    changes.put(Columns.CONTAINER_MODEL, "Generic 8-Lane Illumina Flow Cell");
    changes.put(Columns.PARAMETERS, "1x151");
    changes.put(Columns.PARTITIONS, "3");
    changes.put(Columns.DESCRIPTION, "test");
    fillRow(table, 0, changes);
    changes.putAll(attrs);
    assertColumnValues(table, 0, changes, "changes pre-save");
    assertTrue(page.save(false));
    HandsOnTable savedTable = page.getTable();
    // not shown after save as it's not actually saved
    changes.remove(Columns.INSTRUMENT_MODEL);
    assertColumnValues(savedTable, 0, changes, "post-save");
    Pool pool = (Pool) getSession().get(PoolImpl.class, 120001L);
    @SuppressWarnings("unchecked") List<SequencingOrder> orders = getSession().createCriteria(SequencingOrderImpl.class).add(Restrictions.eq("pool", pool)).list();
    assertEquals(1, orders.size());
    assertEquals(changes.get(Columns.PARAMETERS), orders.get(0).getSequencingParameter().getName());
    assertEquals(Integer.valueOf(3), orders.get(0).getPartitions());
    assertEquals("test", orders.get(0).getDescription());
}
Also used : HandsOnTable(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.element.HandsOnTable) SequencingOrder(uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder) BulkSequencingOrderPage(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.BulkSequencingOrderPage) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) PoolImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolImpl) Test(org.junit.Test)

Example 2 with SequencingOrder

use of uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder in project miso-lims by miso-lims.

the class DefaultPoolService method beforeDelete.

@Override
public void beforeDelete(Pool object) throws IOException {
    Set<SequencingOrder> orders = sequencingOrderService.getByPool(object);
    sequencingOrderService.bulkDelete(orders);
    Box box = object.getBox();
    if (box != null) {
        box.getBoxPositions().remove(object.getBoxPosition());
        boxService.save(box);
    }
    fileAttachmentService.beforeDelete(object);
}
Also used : SequencingOrder(uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder) Box(uk.ac.bbsrc.tgac.miso.core.data.Box)

Example 3 with SequencingOrder

use of uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder in project miso-lims by miso-lims.

the class DefaultPoolOrderService method collectValidationErrors.

@Override
protected void collectValidationErrors(PoolOrder object, PoolOrder beforeChange, List<ValidationError> errors) throws IOException {
    if (object.getPool() != null || object.getSequencingOrder() != null) {
        // order should be fulfilled
        if (object.isDraft()) {
            errors.add(new ValidationError("draft", "Fulfilled order cannot be a draft"));
        }
        if (object.getPool() == null) {
            errors.add(new ValidationError("poolId", "Pool must be provided if a sequencing order is linked"));
        } else {
            for (OrderLibraryAliquot orderAli : object.getOrderLibraryAliquots()) {
                if (object.getPool().getPoolContents().stream().map(PoolElement::getAliquot).noneMatch(poolElement -> {
                    if (poolElement.getId() == orderAli.getAliquot().getId()) {
                        return true;
                    }
                    for (ParentAliquot parent = poolElement.getParentAliquot(); parent != null; parent = parent.getParentAliquot()) {
                        if (parent.getId() == orderAli.getAliquot().getId()) {
                            return true;
                        }
                    }
                    return false;
                })) {
                    errors.add(new ValidationError("Pool does not contain all of the required aliquots"));
                    break;
                }
            }
            if (object.getSequencingOrder() != null) {
                SequencingOrder seqOrder = object.getSequencingOrder();
                if (seqOrder.getPurpose().getId() != object.getPurpose().getId() || seqOrder.getSequencingParameter().getId() != object.getParameters().getId() || !seqOrder.getPartitions().equals(object.getPartitions()) || seqOrder.getPool().getId() != object.getPool().getId() || (object.getContainerModel() != null && (seqOrder.getContainerModel() == null || seqOrder.getContainerModel().getId() != object.getContainerModel().getId()))) {
                    errors.add(new ValidationError("Sequencing order does not match the pool order"));
                }
            }
        }
        preventFulfilledChange("partitions", PoolOrder::getPartitions, object, beforeChange, errors);
        preventFulfilledChange("parametersId", PoolOrder::getParameters, object, beforeChange, errors);
        preventFulfilledChange("containerModelId", PoolOrder::getContainerModel, object, beforeChange, errors);
        preventFulfilledChange("description", PoolOrder::getDescription, object, beforeChange, errors);
        preventFulfilledChange("alias", PoolOrder::getAlias, object, beforeChange, errors);
        preventFulfilledChange("purposeId", PoolOrder::getPurpose, object, beforeChange, errors);
        if (!allMatch(object.getOrderLibraryAliquots(), beforeChange.getOrderLibraryAliquots())) {
            errors.add(new ValidationError("Aliquots cannot be changed after the order is fulfilled"));
        }
    }
    // if any sequencing requirements are specified, all are required
    if (object.getContainerModel() != null || object.getParameters() != null || object.getPartitions() != null) {
        // exception: container model not required for legacy orders (from before container model was added to orders)
        if ((beforeChange == null || beforeChange.getContainerModel() != null) && object.getContainerModel() == null) {
            errors.add(ValidationUtils.makeNoNullError("containerModelId"));
        }
        if (object.getParameters() == null) {
            errors.add(ValidationUtils.makeNoNullError("parametersId"));
        }
        if (object.getPartitions() == null) {
            errors.add(ValidationUtils.makeNoNullError("partitions"));
        }
    }
    // Container model and seq params must be linked to same instrument model
    if (object.getContainerModel() != null && object.getParameters().getInstrumentModel().getContainerModels().stream().noneMatch(model -> model.getId() == object.getContainerModel().getId())) {
        errors.add(new ValidationError("containerModelId", "Not compatible with the selected sequencing parameters"));
    }
    PlatformType orderPlatform = object.getParameters() == null ? null : object.getParameters().getInstrumentModel().getPlatformType();
    for (OrderLibraryAliquot orderAli : object.getOrderLibraryAliquots()) {
        PlatformType libPlatform = orderAli.getAliquot().getLibrary().getPlatformType();
        if (orderPlatform == null) {
            orderPlatform = libPlatform;
        } else if (!libPlatform.equals(orderPlatform)) {
            errors.add(new ValidationError("Platform for all aliquots and sequencing parameters (if specified) must match"));
            break;
        }
    }
    if (!object.isDraft() && object.getOrderLibraryAliquots().isEmpty()) {
        errors.add(new ValidationError("Non-draft order must include at least one library aliquot"));
    }
    if (strictPools) {
        validateNoNewDuplicateIndices(object, beforeChange, errors);
    }
}
Also used : PoolOrder(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolOrder) RunPurposeService(uk.ac.bbsrc.tgac.miso.core.service.RunPurposeService) AuthorizationManager(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager) SequencingOrderService(uk.ac.bbsrc.tgac.miso.core.service.SequencingOrderService) PaginationFilter(uk.ac.bbsrc.tgac.miso.core.util.PaginationFilter) SequencingOrder(uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder) Autowired(org.springframework.beans.factory.annotation.Autowired) Function(java.util.function.Function) SequencingContainerModelService(uk.ac.bbsrc.tgac.miso.core.service.SequencingContainerModelService) LibraryAliquotService(uk.ac.bbsrc.tgac.miso.core.service.LibraryAliquotService) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Value(org.springframework.beans.factory.annotation.Value) Service(org.springframework.stereotype.Service) PoolOrder(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolOrder) ParentAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentAliquot) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) ValidationResult(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationResult) OrderLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.OrderLibraryAliquot) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) DeletionStore(uk.ac.bbsrc.tgac.miso.core.store.DeletionStore) PoolOrderDao(uk.ac.bbsrc.tgac.miso.persistence.PoolOrderDao) IOException(java.io.IOException) IndexChecker(uk.ac.bbsrc.tgac.miso.core.util.IndexChecker) Consumer(java.util.function.Consumer) List(java.util.List) SequencingParametersService(uk.ac.bbsrc.tgac.miso.core.service.SequencingParametersService) PoolOrderService(uk.ac.bbsrc.tgac.miso.service.PoolOrderService) PoolService(uk.ac.bbsrc.tgac.miso.core.service.PoolService) ChangeLogService(uk.ac.bbsrc.tgac.miso.core.service.ChangeLogService) PlatformType(uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType) AbstractSaveService(uk.ac.bbsrc.tgac.miso.service.AbstractSaveService) SaveDao(uk.ac.bbsrc.tgac.miso.persistence.SaveDao) Transactional(org.springframework.transaction.annotation.Transactional) OrderLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.OrderLibraryAliquot) SequencingOrder(uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) PlatformType(uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType) ParentAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentAliquot)

Example 4 with SequencingOrder

use of uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder in project miso-lims by miso-lims.

the class DefaultSequencingOrderService method update.

@Override
public long update(SequencingOrder seqOrder) throws IOException {
    SequencingOrder managed = sequencingOrderDao.get(seqOrder.getId());
    managed.setPartitions(seqOrder.getPartitions());
    managed.setChangeDetails(authorizationManager.getCurrentUser());
    validateChange(managed, seqOrder);
    return sequencingOrderDao.update(managed);
}
Also used : SequencingOrder(uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder)

Example 5 with SequencingOrder

use of uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder in project miso-lims by miso-lims.

the class Dtos method to.

public static SequencingOrder to(@Nonnull SequencingOrderDto from) {
    SequencingOrder to = new SequencingOrderImpl();
    if (from.getId() != null)
        to.setId(from.getId());
    to.setPool(to(from.getPool()));
    setObject(to::setContainerModel, SequencingContainerModel::new, from.getContainerModelId());
    to.setSequencingParameters(to(from.getParameters()));
    to.setPartitions(from.getPartitions());
    to.setDescription(from.getDescription());
    setObject(to::setPurpose, RunPurpose::new, from.getPurposeId());
    return to;
}
Also used : RunPurpose(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPurpose) SequencingContainerModel(uk.ac.bbsrc.tgac.miso.core.data.impl.SequencingContainerModel) SequencingOrder(uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder) 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) SequencingOrderImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SequencingOrderImpl)

Aggregations

SequencingOrder (uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder)9 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3 IOException (java.io.IOException)2 List (java.util.List)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 PutMapping (org.springframework.web.bind.annotation.PutMapping)2 SequencingParameters (uk.ac.bbsrc.tgac.miso.core.data.SequencingParameters)2 RunPurpose (uk.ac.bbsrc.tgac.miso.core.data.impl.RunPurpose)2 SequencingContainerModel (uk.ac.bbsrc.tgac.miso.core.data.impl.SequencingContainerModel)2 SequencingOrderImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.SequencingOrderImpl)2 PlatformType (uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType)2 PoolService (uk.ac.bbsrc.tgac.miso.core.service.PoolService)2 RunPurposeService (uk.ac.bbsrc.tgac.miso.core.service.RunPurposeService)2 SequencingContainerModelService (uk.ac.bbsrc.tgac.miso.core.service.SequencingContainerModelService)2 SequencingOrderService (uk.ac.bbsrc.tgac.miso.core.service.SequencingOrderService)2 SequencingParametersService (uk.ac.bbsrc.tgac.miso.core.service.SequencingParametersService)2 IndexChecker (uk.ac.bbsrc.tgac.miso.core.util.IndexChecker)2 PaginationFilter (uk.ac.bbsrc.tgac.miso.core.util.PaginationFilter)2