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());
}
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);
}
}
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;
}
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;
}
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);
}
Aggregations