Search in sources :

Example 1 with AssayMetric

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

the class DefaultAssayService method loadChildEntities.

@Override
protected void loadChildEntities(Assay object) throws IOException {
    for (AssayMetric metric : object.getAssayMetrics()) {
        loadChildEntity(metric.getMetric(), metric::setMetric, metricService);
        metric.setAssay(object);
    }
}
Also used : AssayMetric(uk.ac.bbsrc.tgac.miso.core.data.impl.AssayMetric)

Example 2 with AssayMetric

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

the class AssayMetricDto method to.

public AssayMetric to() {
    AssayMetric to = new AssayMetric();
    setObject(to::setMetric, Metric::new, getId());
    setBigDecimal(to::setMinimumThreshold, getMinimumThreshold());
    setBigDecimal(to::setMaximumThreshold, getMaximumThreshold());
    return to;
}
Also used : AssayMetric(uk.ac.bbsrc.tgac.miso.core.data.impl.AssayMetric) AssayMetric(uk.ac.bbsrc.tgac.miso.core.data.impl.AssayMetric) Metric(uk.ac.bbsrc.tgac.miso.core.data.impl.Metric)

Example 3 with AssayMetric

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

the class DefaultAssayService method applyMetricChanges.

private void applyMetricChanges(Set<AssayMetric> to, Set<AssayMetric> from) throws IOException {
    for (Iterator<AssayMetric> iterator = to.iterator(); iterator.hasNext(); ) {
        AssayMetric toItem = iterator.next();
        if (from.stream().noneMatch(fromItem -> fromItem.getMetric().getId() == toItem.getMetric().getId())) {
            iterator.remove();
            assayDao.deleteAssayMetric(toItem);
        }
    }
    for (AssayMetric fromItem : from) {
        AssayMetric toItem = to.stream().filter(x -> x.getMetric().getId() == fromItem.getMetric().getId()).findFirst().orElse(null);
        if (toItem == null) {
            to.add(fromItem);
        } else {
            toItem.setMaximumThreshold(fromItem.getMaximumThreshold());
            toItem.setMinimumThreshold(fromItem.getMinimumThreshold());
        }
    }
}
Also used : AssayMetric(uk.ac.bbsrc.tgac.miso.core.data.impl.AssayMetric)

Example 4 with AssayMetric

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

the class HibernateAssayDaoIT method testDeleteAssayMetric.

@Test
public void testDeleteAssayMetric() throws Exception {
    final long assayId = 2L;
    final long metricId = 2L;
    Assay before = (Assay) currentSession().get(Assay.class, assayId);
    assertEquals(2, before.getAssayMetrics().size());
    AssayMetric beforeMetric = before.getAssayMetrics().stream().filter(x -> x.getMetric().getId() == metricId).findAny().orElse(null);
    before.getAssayMetrics().remove(beforeMetric);
    assertNotNull(beforeMetric);
    getTestSubject().deleteAssayMetric(beforeMetric);
    clearSession();
    Assay after = (Assay) currentSession().get(Assay.class, assayId);
    assertEquals(1, after.getAssayMetrics().size());
    assertTrue(after.getAssayMetrics().stream().noneMatch(x -> x.getMetric().getId() == metricId));
}
Also used : Assay(uk.ac.bbsrc.tgac.miso.core.data.impl.Assay) Assay(uk.ac.bbsrc.tgac.miso.core.data.impl.Assay) AbstractHibernateSaveDaoTest(uk.ac.bbsrc.tgac.miso.AbstractHibernateSaveDaoTest) Arrays(java.util.Arrays) AssayMetric(uk.ac.bbsrc.tgac.miso.core.data.impl.AssayMetric) Test(org.junit.Test) Assert(org.junit.Assert) AssayMetric(uk.ac.bbsrc.tgac.miso.core.data.impl.AssayMetric) AbstractHibernateSaveDaoTest(uk.ac.bbsrc.tgac.miso.AbstractHibernateSaveDaoTest) Test(org.junit.Test)

Aggregations

AssayMetric (uk.ac.bbsrc.tgac.miso.core.data.impl.AssayMetric)4 Arrays (java.util.Arrays)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1 AbstractHibernateSaveDaoTest (uk.ac.bbsrc.tgac.miso.AbstractHibernateSaveDaoTest)1 Assay (uk.ac.bbsrc.tgac.miso.core.data.impl.Assay)1 Metric (uk.ac.bbsrc.tgac.miso.core.data.impl.Metric)1