Search in sources :

Example 1 with PoolOrder

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

the class PoolOrderPageIT method testCreateMinimal.

@Test
public void testCreateMinimal() {
    PoolOrderPage page = PoolOrderPage.getForCreate(getDriver(), getBaseUrl());
    Map<Field, String> fields = new LinkedHashMap<>();
    fields.put(Field.ALIAS, "Test Create Order");
    fields.put(Field.PURPOSE, "Production");
    page.setFields(fields);
    String aliquotName1 = "LDI902";
    String aliquotName2 = "LDI1001";
    page.addAliquots(Lists.newArrayList(aliquotName1, aliquotName2));
    assertEquals("", page.getField(Field.ID));
    assertFieldValues("changes pre-save", fields, page);
    PoolOrderPage savedPage = page.clickSave();
    assertNotNull("Pool order should save successfully", savedPage);
    assertFieldValues("changes post-save", fields, savedPage);
    PoolOrder order = (PoolOrder) getSession().get(PoolOrder.class, Long.valueOf(savedPage.getField(Field.ID)));
    assertEquals(fields.get(Field.ALIAS), order.getAlias());
    assertEquals(fields.get(Field.PURPOSE), order.getPurpose().getAlias());
    assertEquals(2, order.getOrderLibraryAliquots().size());
    assertEquals(1, order.getOrderLibraryAliquots().stream().filter(a -> a.getAliquot().getName().equals(aliquotName1)).count());
}
Also used : PoolOrder(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolOrder) Field(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.PoolOrderPage.Field) PoolOrderPage(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.PoolOrderPage) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 2 with PoolOrder

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

the class DefaultPoolService method validateChange.

private void validateChange(Pool pool, Pool beforeChange) throws IOException {
    List<ValidationError> errors = new ArrayList<>();
    if (ValidationUtils.isSetAndChanged(Pool::getAlias, pool, beforeChange) && poolStore.getByAlias(pool.getAlias()) != null) {
        errors.add(new ValidationError("alias", "There is already a pool with this alias"));
    }
    validateConcentrationUnits(pool.getConcentration(), pool.getConcentrationUnits(), errors);
    validateVolumeUnits(pool.getVolume(), pool.getVolumeUnits(), errors);
    validateBarcodeUniqueness(pool, beforeChange, barcodableReferenceService, errors);
    validateUnboxableFields(pool, errors);
    if (strictPools && !pool.isMergeChild()) {
        validateIndices(pool, beforeChange, errors);
    }
    // If this is a new pool, we don't have to worry about syncing to pool orders: either it's irrelevant, or a guarantee
    List<PoolOrder> potentialPoolOrders = beforeChange == null ? null : poolOrderService.getAllByPoolId(beforeChange.getId());
    if (potentialPoolOrders != null && potentialPoolOrders.size() != 0) {
        errors.addAll(getMismatchesWithOrders(pool, potentialPoolOrders));
    }
    if (!errors.isEmpty()) {
        throw new ValidationException(errors);
    }
}
Also used : PoolOrder(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolOrder) ValidationException(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationException) ArrayList(java.util.ArrayList) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError)

Example 3 with PoolOrder

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

the class DefaultPoolService method getMismatchesWithOrders.

private List<ValidationError> getMismatchesWithOrders(Pool pool, List<PoolOrder> poolOrders) throws IOException {
    Set<Long> poolAliquotIds = new HashSet<>();
    List<ValidationError> errors = new LinkedList<>();
    for (PoolElement pe : pool.getPoolContents()) {
        poolAliquotIds.add(pe.getAliquot().getId());
        for (ParentAliquot parent = pe.getAliquot().getParentAliquot(); parent != null; parent = parent.getParentAliquot()) {
            poolAliquotIds.add(parent.getId());
        }
    }
    for (PoolOrder order : poolOrders) {
        for (OrderLibraryAliquot orderAliquot : order.getOrderLibraryAliquots()) {
            if (!poolAliquotIds.contains(orderAliquot.getAliquot().getId())) {
                String errorMessage = String.format("Pool must contain library aliquot '%s', as specified by pool order '%s'", orderAliquot.getAliquot().getAlias(), order.getAlias());
                errors.add(new ValidationError("poolElements", errorMessage));
            }
        }
    }
    return errors;
}
Also used : PoolOrder(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolOrder) OrderLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.OrderLibraryAliquot) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) ParentAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentAliquot) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 4 with PoolOrder

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

the class HibernatePoolOrderDao method getAllByPoolId.

@Override
public List<PoolOrder> getAllByPoolId(long poolId) {
    Criteria criteria = currentSession().createCriteria(PoolOrder.class);
    criteria.add(Restrictions.eq(FIELD_POOL, poolId));
    @SuppressWarnings("unchecked") List<PoolOrder> list = criteria.list();
    return list;
}
Also used : PoolOrder(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolOrder) Criteria(org.hibernate.Criteria)

Example 5 with PoolOrder

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

the class EditPoolOrderController method create.

@GetMapping("/new")
public ModelAndView create(@RequestParam(name = "aliquotIds", required = false) String aliquotIds, ModelMap model) throws IOException {
    model.put("title", "New Pool Order");
    model.put(PageMode.PROPERTY, PageMode.CREATE.getLabel());
    PoolOrder order = new PoolOrder();
    if (aliquotIds != null) {
        for (Long aliquotId : LimsUtils.parseIds(aliquotIds)) {
            LibraryAliquot ali = libraryAliquotService.get(aliquotId);
            if (ali == null) {
                throw new ClientErrorException("Library aliquot " + aliquotId + " not found");
            }
            OrderLibraryAliquot orderLib = new OrderLibraryAliquot();
            orderLib.setAliquot(ali);
            order.getOrderLibraryAliquots().add(orderLib);
        }
    }
    return orderPage(order, model);
}
Also used : PoolOrder(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolOrder) OrderLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.OrderLibraryAliquot) ClientErrorException(uk.ac.bbsrc.tgac.miso.webapp.controller.component.ClientErrorException) OrderLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.OrderLibraryAliquot) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

PoolOrder (uk.ac.bbsrc.tgac.miso.core.data.impl.PoolOrder)11 Test (org.junit.Test)4 OrderLibraryAliquot (uk.ac.bbsrc.tgac.miso.core.data.impl.OrderLibraryAliquot)4 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)3 ValidationError (uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 RunPurpose (uk.ac.bbsrc.tgac.miso.core.data.impl.RunPurpose)2 ParentAliquot (uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentAliquot)2 PoolElement (uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement)2 IlluminaNotificationDto (ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto)1 NotificationDto (ca.on.oicr.gsi.runscanner.dto.NotificationDto)1 OxfordNanoporeNotificationDto (ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto)1 User (com.eaglegenomics.simlims.core.User)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1