use of uk.ac.bbsrc.tgac.miso.core.data.Sample in project miso-lims by miso-lims.
the class HibernateSampleDao method listByIdList.
@Override
public List<Sample> listByIdList(Collection<Long> idList) throws IOException {
if (idList.isEmpty()) {
return Collections.emptyList();
}
Criteria criteria = currentSession().createCriteria(SampleImpl.class);
criteria.add(Restrictions.in("sampleId", idList));
@SuppressWarnings("unchecked") List<Sample> records = criteria.list();
return records;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Sample in project miso-lims by miso-lims.
the class HibernateSampleNumberPerProjectDao method nextNumber.
@SuppressWarnings("unchecked")
@Override
public synchronized String nextNumber(Project project, User user, String partialAlias) {
SampleNumberPerProject sampleNumberPerProject = getByProject(project);
if (sampleNumberPerProject == null) {
sampleNumberPerProject = createSampleNumberPerProject(project, user);
}
Integer highestSampleNumber = sampleNumberPerProject.getHighestSampleNumber();
String num = null;
List<Sample> existing = null;
do {
highestSampleNumber++;
num = padInteger(sampleNumberPerProject.getPadding(), highestSampleNumber);
Criteria criteria = currentSession().createCriteria(SampleImpl.class);
criteria.add(Restrictions.eq("alias", partialAlias + num));
existing = criteria.list();
} while (existing != null && !existing.isEmpty());
sampleNumberPerProject.setHighestSampleNumber(highestSampleNumber);
sampleNumberPerProject.setUpdatedBy(user);
update(sampleNumberPerProject);
return num;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Sample in project miso-lims by miso-lims.
the class HibernateAttachableDaoIT method testGetManagedAttachable.
@Test
public void testGetManagedAttachable() throws Exception {
Sample sample = (Sample) currentSession().get(SampleImpl.class, 1L);
Attachable attachable = sut.getManaged(sample);
assertTrue(attachable instanceof Sample);
assertEquals(sample.getId(), attachable.getId());
}
use of uk.ac.bbsrc.tgac.miso.core.data.Sample in project miso-lims by miso-lims.
the class HibernateProgressDaoIT method makeSampleProgressStep.
private SampleProgressStep makeSampleProgressStep(long sampleId, int stepNumber) {
SampleProgressStep step = new SampleProgressStep();
Sample sample = new SampleImpl();
sample.setId(sampleId);
step.setInput(sample);
step.setStepNumber(stepNumber);
return step;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Sample in project miso-lims by miso-lims.
the class RequisitionController method edit.
@GetMapping("/{id}")
public ModelAndView edit(@PathVariable long id, ModelMap model) throws IOException {
Requisition requisition = requisitionService.get(id);
if (requisition == null) {
throw new NotFoundException("No requisition found for ID: " + id);
}
model.put("title", "Requisition " + id);
List<Sample> samples = sampleService.list(0, 0, false, "id", PaginationFilter.requisitionId(id));
List<Sample> extractions = sampleService.getChildren(samples.stream().map(Sample::getId).collect(Collectors.toSet()), SampleStock.CATEGORY_NAME);
List<SampleDto> extractionDtos = extractions.stream().map(sam -> Dtos.asDto(sam, false)).collect(Collectors.toList());
model.put("extractions", extractionDtos);
List<Long> libraryIds = libraryService.listIdsByRequisitionId(id);
List<Run> runs = runService.listByLibraryIdList(libraryIds);
List<RunDto> runDtos = runs.stream().map(Dtos::asDto).collect(Collectors.toList());
model.put("runs", runDtos);
return setupForm(requisition, PageMode.EDIT, model);
}
Aggregations