use of uk.ac.bbsrc.tgac.miso.core.data.ArrayRun in project miso-lims by miso-lims.
the class HibernateArrayRunDao method listByArrayId.
@Override
public List<ArrayRun> listByArrayId(long arrayId) throws IOException {
Criteria criteria = currentSession().createCriteria(ArrayRun.class);
criteria.add(Restrictions.eq("array.id", arrayId));
@SuppressWarnings("unchecked") List<ArrayRun> list = criteria.list();
return list;
}
use of uk.ac.bbsrc.tgac.miso.core.data.ArrayRun in project miso-lims by miso-lims.
the class DefaultArrayRunService method validateChange.
/**
* Checks submitted data for validity, throwing a ValidationException containing all of the errors if invalid
*
* @param arrayRun submitted Array Run to validate
* @param beforeChange the already-persisted Array Run before changes
* @throws IOException
*/
private void validateChange(ArrayRun arrayRun, ArrayRun beforeChange) throws IOException {
List<ValidationError> errors = new ArrayList<>();
if (arrayRun.isSaved() && beforeChange == null) {
errors.add(new ValidationError("Array Run not found"));
}
if (isStringEmptyOrNull(arrayRun.getAlias())) {
errors.add(new ValidationError("alias", "Alias cannot be blank"));
}
if (arrayRun.getInstrument() == null) {
errors.add(new ValidationError("instrument", "An instrument must be selected"));
} else if (arrayRun.getInstrument().getInstrumentModel().getInstrumentType() != InstrumentType.ARRAY_SCANNER) {
errors.add(new ValidationError("instrument", "Instrument must be an array scanner"));
}
if (beforeChange == null || !arrayRun.getAlias().equals(beforeChange.getAlias())) {
ArrayRun duplicateAlias = arrayRunStore.getByAlias(arrayRun.getAlias());
if (duplicateAlias != null) {
errors.add(new ValidationError("alias", "There is already an array run with this alias"));
}
}
if (arrayRun.getArray() != null && arrayRun.getArray().getAlias() == null) {
errors.add(new ValidationError("array", "Array not found"));
}
validateStartDate(arrayRun, beforeChange, errors);
validateStatusAndCompletion(arrayRun, beforeChange, errors);
if (!errors.isEmpty()) {
throw new ValidationException(errors);
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.ArrayRun in project miso-lims by miso-lims.
the class HibernateArrayRunDaoIT method testSaveExisting.
@Test
public void testSaveExisting() throws Exception {
long runId = 1L;
String alias = "NewAlias";
String desc = "NewDesc";
ArrayRun run = sut.get(runId);
assertNotNull(run.getArray());
assertNotEquals(alias, run.getAlias());
assertNotEquals(desc, run.getDescription());
run.setArray(null);
run.setAlias(alias);
run.setDescription(desc);
long savedId = sut.save(run);
assertEquals(runId, savedId);
ArrayRun saved = sut.get(savedId);
assertNotNull(saved);
assertNull(saved.getArray());
assertEquals(alias, run.getAlias());
assertEquals(desc, run.getDescription());
}
use of uk.ac.bbsrc.tgac.miso.core.data.ArrayRun in project miso-lims by miso-lims.
the class HibernateArrayRunDaoIT method testSaveNew.
@Test
public void testSaveNew() throws Exception {
ArrayRun run = new ArrayRun();
run.setAlias("TestArrayRun");
Instrument inst = (Instrument) sessionFactory.getCurrentSession().get(InstrumentImpl.class, 3L);
run.setInstrument(inst);
run.setHealth(HealthType.Running);
Date now = new Date();
run.setStartDate(now);
User user = (User) sessionFactory.getCurrentSession().get(UserImpl.class, 1L);
run.setCreator(user);
run.setCreationTime(now);
run.setLastModifier(user);
run.setLastModified(now);
long savedId = sut.save(run);
ArrayRun saved = sut.get(savedId);
assertNotNull(saved);
assertEquals(run.getAlias(), saved.getAlias());
assertEquals(run.getInstrument().getId(), saved.getInstrument().getId());
assertEquals(run.getHealth(), saved.getHealth());
assertEquals(LimsUtils.formatDate(run.getStartDate()), LimsUtils.formatDate(saved.getStartDate()));
}
use of uk.ac.bbsrc.tgac.miso.core.data.ArrayRun in project miso-lims by miso-lims.
the class HibernateArrayRunDaoIT method testGetByAlias.
@Test
public void testGetByAlias() throws Exception {
String alias = "ArrayRun_1";
ArrayRun run = sut.getByAlias(alias);
assertNotNull(run);
assertEquals(alias, run.getAlias());
}
Aggregations