use of uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryTemplate in project miso-lims by miso-lims.
the class DefaultProjectService method beforeDelete.
@Override
public void beforeDelete(Project object) throws IOException {
fileAttachmentService.beforeDelete(object);
List<LibraryTemplate> templates = libraryTemplateService.listByProject(object.getId());
for (LibraryTemplate template : templates) {
template.getProjects().removeIf(templateProject -> templateProject.getId() == object.getId());
libraryTemplateService.update(template);
}
SampleNumberPerProject sampleNumberPerProject = sampleNumberPerProjectService.getByProject(object);
if (sampleNumberPerProject != null) {
sampleNumberPerProjectService.delete(sampleNumberPerProject);
}
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryTemplate in project miso-lims by miso-lims.
the class LibraryTemplateRestController method makeTemplateDtosForIndexUpdate.
private List<LibraryTemplateDto> makeTemplateDtosForIndexUpdate(long templateId, List<LibraryTemplateIndexDto> dtos) throws IOException {
LibraryTemplate template = RestUtils.retrieve(TYPE_LABEL, templateId, libraryTemplateService);
LibraryTemplateDto templateDto = Dtos.asDto(template);
for (LibraryTemplateIndexDto index : dtos) {
setIndex(index.getBoxPosition(), index.getIndex1Id(), templateDto.getIndexOneIds());
setIndex(index.getBoxPosition(), index.getIndex2Id(), templateDto.getIndexTwoIds());
}
return Collections.singletonList(templateDto);
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryTemplate in project miso-lims by miso-lims.
the class EditLibraryTemplateController method edit.
@GetMapping("/{templateId}")
public ModelAndView edit(@PathVariable long templateId, ModelMap model) throws IOException {
LibraryTemplate template = getTemplate(templateId);
model.put(PageMode.PROPERTY, PageMode.EDIT.getLabel());
model.put("title", "Library Template " + templateId);
return libraryTemplatePage(template, model);
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryTemplate in project miso-lims by miso-lims.
the class EditLibraryTemplateController method create.
@GetMapping("/new")
public ModelAndView create(@RequestParam(name = "projectId", required = false) Long projectId, ModelMap model) throws IOException {
LibraryTemplate template = isDetailedSampleEnabled() ? new DetailedLibraryTemplate() : new LibraryTemplate();
if (projectId != null) {
Project project = projectService.get(projectId);
if (project == null) {
throw new ClientErrorException("No project found with ID: " + projectId);
}
template.getProjects().add(project);
}
model.put(PageMode.PROPERTY, PageMode.CREATE.getLabel());
model.put("title", "New Library Template");
return libraryTemplatePage(template, model);
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryTemplate in project miso-lims by miso-lims.
the class HibernateLibraryTemplateDaoIT method testUpdate.
@Test
public void testUpdate() throws Exception {
long id = 2L;
String newAlias = "asdf";
LibraryTemplate before = (LibraryTemplate) currentSession().get(LibraryTemplate.class, id);
assertNotEquals(newAlias, before.getAlias());
before.setAlias(newAlias);
sut.update(before);
clearSession();
LibraryTemplate after = (LibraryTemplate) currentSession().get(LibraryTemplate.class, id);
assertEquals(newAlias, after.getAlias());
}
Aggregations