use of uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot.RunPartitionAliquotId in project miso-lims by miso-lims.
the class HibernateRunPartitionAliquotDaoIT method testCreate.
@Test
public void testCreate() throws Exception {
Run run = (Run) currentSession().get(Run.class, 1L);
Partition partition = (Partition) currentSession().get(PartitionImpl.class, 2L);
LibraryAliquot aliquot = (LibraryAliquot) currentSession().get(LibraryAliquot.class, 3L);
RunPartitionAliquotId id = new RunPartitionAliquotId(run, partition, aliquot);
assertNull(currentSession().get(RunPartitionAliquot.class, id));
RunPartitionAliquot rpa = new RunPartitionAliquot(run, partition, aliquot);
User user = (User) currentSession().get(UserImpl.class, 1L);
rpa.setLastModifier(user);
RunLibraryQcStatus qc = (RunLibraryQcStatus) currentSession().get(RunLibraryQcStatus.class, 1L);
rpa.setQcStatus(qc);
rpa.setQcUser(user);
rpa.setQcDate(new Date());
sut.create(rpa);
clearSession();
RunPartitionAliquot saved = (RunPartitionAliquot) currentSession().get(RunPartitionAliquot.class, id);
assertNotNull(saved);
assertEquals(1L, saved.getRun().getId());
assertEquals(2L, saved.getPartition().getId());
assertEquals(3L, saved.getAliquot().getId());
}
use of uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot.RunPartitionAliquotId in project miso-lims by miso-lims.
the class HibernateRunPartitionAliquotDaoIT method testSaveCreate.
@Test
public void testSaveCreate() throws Exception {
Run run = (Run) currentSession().get(Run.class, 1L);
Partition partition = (Partition) currentSession().get(PartitionImpl.class, 2L);
LibraryAliquot aliquot = (LibraryAliquot) currentSession().get(LibraryAliquot.class, 3L);
RunPartitionAliquotId id = new RunPartitionAliquotId(run, partition, aliquot);
assertNull(currentSession().get(RunPartitionAliquot.class, id));
RunPartitionAliquot rpa = new RunPartitionAliquot(run, partition, aliquot);
User user = (User) currentSession().get(UserImpl.class, 1L);
rpa.setLastModifier(user);
RunLibraryQcStatus qc = (RunLibraryQcStatus) currentSession().get(RunLibraryQcStatus.class, 1L);
rpa.setQcStatus(qc);
rpa.setQcUser(user);
rpa.setQcDate(new Date());
sut.save(rpa);
clearSession();
RunPartitionAliquot saved = (RunPartitionAliquot) currentSession().get(RunPartitionAliquot.class, id);
assertNotNull(saved);
assertEquals(1L, saved.getRun().getId());
assertEquals(2L, saved.getPartition().getId());
assertEquals(3L, saved.getAliquot().getId());
}
use of uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot.RunPartitionAliquotId in project miso-lims by miso-lims.
the class HibernateRunPartitionAliquotDaoIT method get.
private RunPartitionAliquot get(long runId, long partitionId, long aliquotId, boolean expectExisting) throws IOException {
Run run = (Run) currentSession().get(Run.class, runId);
Partition partition = (Partition) currentSession().get(PartitionImpl.class, partitionId);
LibraryAliquot aliquot = (LibraryAliquot) currentSession().get(LibraryAliquot.class, aliquotId);
RunPartitionAliquotId id = new RunPartitionAliquotId(run, partition, aliquot);
RunPartitionAliquot existing = (RunPartitionAliquot) currentSession().get(RunPartitionAliquot.class, id);
if (expectExisting) {
assertNotNull(existing);
} else {
assertNull(existing);
}
return sut.get(run, partition, aliquot);
}
use of uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot.RunPartitionAliquotId in project miso-lims by miso-lims.
the class HibernateRunPartitionAliquotDaoIT method testSaveUpdate.
@Test
public void testSaveUpdate() throws Exception {
Run run = (Run) currentSession().get(Run.class, 1L);
Partition partition = (Partition) currentSession().get(PartitionImpl.class, 1L);
LibraryAliquot aliquot = (LibraryAliquot) currentSession().get(LibraryAliquot.class, 1L);
RunPartitionAliquotId id = new RunPartitionAliquotId(run, partition, aliquot);
RunPartitionAliquot existing = (RunPartitionAliquot) currentSession().get(RunPartitionAliquot.class, id);
assertNotNull(existing);
assertNull(existing.getPurpose());
RunPurpose purpose = (RunPurpose) currentSession().get(RunPurpose.class, 1L);
assertNull(existing.getPurpose());
existing.setPurpose(purpose);
sut.save(existing);
clearSession();
RunPartitionAliquot saved = (RunPartitionAliquot) currentSession().get(RunPartitionAliquot.class, id);
assertNotNull(saved.getPurpose());
assertEquals(purpose.getId(), saved.getPurpose().getId());
}
use of uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot.RunPartitionAliquotId in project miso-lims by miso-lims.
the class HibernateRunPartitionAliquotDao method get.
@Override
public RunPartitionAliquot get(Run run, Partition partition, LibraryAliquot aliquot) throws IOException {
RunPartitionAliquotId id = new RunPartitionAliquotId();
id.setRun(run);
id.setPartition(partition);
id.setAliquot(aliquot);
RunPartitionAliquot result = (RunPartitionAliquot) currentSession().get(RunPartitionAliquot.class, id);
if (result == null) {
// ensure the relationship exists before constructing the entity
List<Object[]> ids = queryIds("WHERE r.runId = ? AND part.partitionId = ? AND pla.aliquotId = ?", new long[] { run.getId(), partition.getId(), aliquot.getId() });
if (ids.isEmpty()) {
return null;
}
result = new RunPartitionAliquot(run, partition, aliquot);
}
return result;
}
Aggregations