use of uk.ac.bbsrc.tgac.miso.core.data.Experiment in project miso-lims by miso-lims.
the class HibernateExperimentDao method listByStudyId.
@Override
public List<Experiment> listByStudyId(long studyId) {
Criteria criteria = currentSession().createCriteria(Experiment.class);
criteria.createAlias("study", "study");
criteria.add(Restrictions.eq("study.id", studyId));
@SuppressWarnings("unchecked") List<Experiment> results = criteria.list();
return results;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Experiment in project miso-lims by miso-lims.
the class EditExperimentController method setupForm.
@GetMapping(value = "/{experimentId}")
public ModelAndView setupForm(@PathVariable Long experimentId, ModelMap model) throws IOException {
Experiment experiment = experimentService.get(experimentId);
if (experiment == null)
throw new NotFoundException("No experiment found for ID " + experimentId.toString());
ObjectMapper mapper = new ObjectMapper();
ObjectNode consumableConfig = mapper.createObjectNode();
consumableConfig.put("experimentId", experiment.getId());
Stream.<//
KitDescriptor>concat(//
Stream.of(experiment.getLibrary().getKitDescriptor()), //
experiment.getRunPartitions().stream().map(//
RunPartition::getPartition).flatMap(partition -> Stream.of(partition.getSequencerPartitionContainer().getClusteringKit(), //
partition.getSequencerPartitionContainer().getMultiplexingKit()))).filter(//
Objects::nonNull).distinct().map(//
Dtos::asDto).forEach(consumableConfig.putArray("allowedDescriptors")::addPOJO);
model.put("experiment", experiment);
model.put("experimentDto", mapper.writeValueAsString(Dtos.asDto(experiment)));
model.put("consumables", experiment.getKits().stream().map(Dtos::asDto).collect(Collectors.toList()));
model.put("consumableConfig", mapper.writeValueAsString(consumableConfig));
model.put("runPartitions", experiment.getRunPartitions().stream().map(entry -> new ExperimentDto.RunPartitionDto(Dtos.asDto(entry.getRun()), Dtos.asDto(entry.getPartition(), indexChecker))).collect(Collectors.toList()));
model.put("title", "Edit Experiment");
return new ModelAndView("/WEB-INF/pages/editExperiment.jsp", model);
}
use of uk.ac.bbsrc.tgac.miso.core.data.Experiment in project miso-lims by miso-lims.
the class HibernateExperimentDaoIT method testGet.
/**
* Test method for {@link uk.ac.bbsrc.tgac.miso.persistence.impl.HibernateExperimentDao#get(long)}.
*
* @throws IOException
*/
@Test
public void testGet() throws IOException {
Experiment experiment = dao.get(1L);
assertNotNull(experiment);
assertEquals("EXP1", experiment.getName());
assertEquals("TEST", experiment.getDescription());
assertEquals("PRO1 Illumina Other experiment (Auto-gen)", experiment.getTitle());
}
use of uk.ac.bbsrc.tgac.miso.core.data.Experiment in project miso-lims by miso-lims.
the class ExperimentRestController method addPartition.
@PostMapping(value = "/{experimentId}/add", produces = "application/json")
@ResponseBody
public ExperimentDto addPartition(@PathVariable Long experimentId, @RequestParam("runId") Long runId, @RequestParam("partitionId") Long partitionId) throws IOException {
Experiment experiment = experimentService.get(experimentId);
if (experiment == null) {
throw new RestException("No such experiment.", Status.NOT_FOUND);
}
Run run = runService.get(runId);
if (run == null) {
throw new RestException("No such run.", Status.NOT_FOUND);
}
Partition partition = containerService.getPartition(partitionId);
if (partition == null) {
throw new RestException("No such partition.", Status.NOT_FOUND);
}
if (run.getSequencerPartitionContainers().stream().flatMap(container -> container.getPartitions().stream()).noneMatch(p -> p.getId() == partitionId)) {
throw new RestException("Partition not in run.", Status.BAD_REQUEST);
}
if (experiment.getRunPartitions().stream().noneMatch(rp -> rp.getPartition().getId() == partition.getId() && rp.getRun().getId() == run.getId())) {
RunPartition rp = new RunPartition();
rp.setExperiment(experiment);
rp.setPartition(partition);
rp.setRun(run);
experiment.getRunPartitions().add(rp);
experimentService.update(experiment);
}
return get(experimentId);
}
use of uk.ac.bbsrc.tgac.miso.core.data.Experiment in project miso-lims by miso-lims.
the class DefaultExperimentService method update.
@Override
public long update(Experiment experiment) throws IOException {
loadRunPartitions(experiment);
ValidationResult nameValidation = namingSchemeHolder.getPrimary().validateName(experiment.getName());
if (!nameValidation.isValid()) {
throw new IOException("Cannot save Experiment - invalid name:" + nameValidation.getMessage());
}
Experiment original = experimentStore.get(experiment.getId());
original.setAccession(experiment.getAccession());
original.setAlias(experiment.getAlias());
original.setDescription(experiment.getDescription());
original.setName(experiment.getName());
original.setInstrumentModel(instrumentModelService.get(experiment.getInstrumentModel().getId()));
original.setLibrary(libraryService.get(experiment.getLibrary().getId()));
original.setStudy(studyService.get(experiment.getStudy().getId()));
original.setTitle(experiment.getTitle());
// These have been already reloaded.
original.setRunPartitions(experiment.getRunPartitions());
original.getRunPartitions().forEach(rp -> rp.setExperiment(original));
Set<Kit> kits = new HashSet<>();
for (Kit k : experiment.getKits()) {
kits.add(kitService.get(k.getId()));
}
original.setKits(kits);
original.setChangeDetails(authorizationManager.getCurrentUser());
return experimentStore.save(original);
}
Aggregations