use of uk.ac.bbsrc.tgac.miso.core.data.Array in project miso-lims by miso-lims.
the class Dtos method to.
public static final ArrayRun to(@Nonnull ArrayRunDto from) {
ArrayRun run = new ArrayRun();
if (from.getId() != null) {
run.setId(from.getId());
}
run.setAlias(from.getAlias());
run.setDescription(nullifyStringIfBlank(from.getDescription()));
run.setFilePath(nullifyStringIfBlank(from.getFilePath()));
setObject(run::setInstrument, InstrumentImpl::new, from.getInstrumentId());
setObject(run::setArray, Array::new, from.getArrayId());
run.setHealth(HealthType.get(from.getStatus()));
setDate(run::setStartDate, from.getStartDate());
setDate(run::setCompletionDate, from.getCompletionDate());
setDate(run::setLastModified, from.getLastModified());
return run;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Array in project miso-lims by miso-lims.
the class DefaultArrayService method applyChanges.
private void applyChanges(Array from, Array to) throws IOException {
to.setAlias(from.getAlias());
to.setSerialNumber(from.getSerialNumber());
to.setDescription(from.getDescription());
// have to add/remove samples individually to avoid unnecessary "sample removed; sample added" changelogs for non-changes
Map<String, Sample> toSamples = to.getSamples();
Set<String> removePositions = toSamples.keySet().stream().filter(key -> !from.getSamples().containsKey(key)).collect(Collectors.toSet());
for (String key : removePositions) {
recordRemoval(to, toSamples.get(key).getName(), key);
toSamples.remove(key);
}
from.getSamples().forEach((key, val) -> {
Sample current = toSamples.get(key);
if (toSamples.get(key) == null || current.getId() != val.getId()) {
toSamples.put(key, val);
}
});
}
use of uk.ac.bbsrc.tgac.miso.core.data.Array in project miso-lims by miso-lims.
the class ArrayRestController method removeSample.
@DeleteMapping(value = "/{arrayId}/positions/{position}")
@ResponseBody
public ArrayDto removeSample(@PathVariable(name = "arrayId", required = true) long arrayId, @PathVariable(name = "position", required = true) String position) throws IOException {
Array array = arrayService.get(arrayId);
if (array == null) {
throw new RestException(ERROR_NOTFOUND, Status.NOT_FOUND);
} else if (!array.isPositionValid(position)) {
throw new RestException("Invalid array position", Status.BAD_REQUEST);
}
if (array.getSample(position) == null) {
// already empty - do nothing
return Dtos.asDto(array);
}
array.setSample(position, null);
arrayService.update(array);
Array saved = arrayService.get(arrayId);
return Dtos.asDto(saved);
}
use of uk.ac.bbsrc.tgac.miso.core.data.Array in project miso-lims by miso-lims.
the class EditArrayController method setupForm.
@RequestMapping("/{arrayId}")
public ModelAndView setupForm(@PathVariable(name = "arrayId", required = true) long arrayId, ModelMap model) throws IOException {
model.addAttribute(PageMode.PROPERTY, PageMode.EDIT.getLabel());
Array array = arrayService.get(arrayId);
if (array == null) {
throw new NotFoundException("Array not found");
}
model.addAttribute(MODEL_ATTR_ARRAYRUNS, arrayRunService.listByArrayId(arrayId).stream().map(Dtos::asDto).collect(Collectors.toList()));
ObjectMapper mapper = new ObjectMapper();
model.addAttribute(MODEL_ATTR_JSON, mapper.writer().writeValueAsString(Dtos.asDto(array)));
return new ModelAndView(JSP, model);
}
use of uk.ac.bbsrc.tgac.miso.core.data.Array in project miso-lims by miso-lims.
the class HibernateArrayDaoIT method testSaveNew.
@Test
public void testSaveNew() throws Exception {
Session session = sessionFactory.getCurrentSession();
ArrayModel model = (ArrayModel) session.get(ArrayModel.class, 1L);
User user = (User) session.get(UserImpl.class, 1L);
Date now = new Date();
Array a = new Array();
a.setAlias("Test Array");
a.setArrayModel(model);
a.setDescription("Array for test");
a.setSerialNumber("12345");
a.setCreator(user);
a.setCreationTime(now);
a.setLastModifier(user);
a.setLastModified(now);
long savedId = sut.save(a);
Array saved = sut.get(savedId);
assertNotNull(saved);
assertEquals(a.getAlias(), saved.getAlias());
}
Aggregations