use of uk.ac.bbsrc.tgac.miso.core.data.Subproject in project miso-lims by miso-lims.
the class Dtos method toDetailedSample.
private static DetailedSample toDetailedSample(@Nonnull DetailedSampleDto from) {
DetailedSample to = null;
if (from.getClass() == SampleIdentityDto.class) {
to = toIdentitySample((SampleIdentityDto) from);
} else if (from.getClass() == SampleTissueDto.class) {
to = toTissueSample((SampleTissueDto) from);
} else if (from instanceof SampleTissueProcessingDto) {
to = toTissueProcessingSample((SampleTissueProcessingDto) from);
} else if (from instanceof SampleAliquotDto) {
to = toAliquotSample((SampleAliquotDto) from);
} else if (from instanceof SampleStockDto) {
to = toStockSample((SampleStockDto) from);
} else {
to = new DetailedSampleImpl();
}
if (from.getSubprojectId() != null) {
Subproject subproject = new SubprojectImpl();
subproject.setId(from.getSubprojectId());
to.setSubproject(subproject);
}
if (from.getSampleClassId() != null) {
SampleClass sampleClass = new SampleClassImpl();
sampleClass.setId(from.getSampleClassId());
to.setSampleClass(sampleClass);
}
to.setGroupId(nullifyStringIfBlank(from.getGroupId()));
to.setGroupDescription(nullifyStringIfBlank(from.getGroupDescription()));
to.setSynthetic(from.getSynthetic());
to.setCreationDate(LimsUtils.isStringEmptyOrNull(from.getCreationDate()) ? null : parseDate(from.getCreationDate()));
if (from.getIdentityId() != null) {
to.setIdentityId(from.getIdentityId());
}
to.setNonStandardAlias(from.getNonStandardAlias());
to.setParent(getParent(from));
setBigDecimal(to::setVolumeUsed, from.getVolumeUsed());
setBigDecimal(to::setNgUsed, from.getNgUsed());
return to;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Subproject in project miso-lims by miso-lims.
the class HibernateSubprojectDaoIT method testGetByProjectAndAlias.
@Test
public void testGetByProjectAndAlias() throws Exception {
Project project = (Project) currentSession().get(ProjectImpl.class, 2L);
String existingAlias = "Meh";
Subproject existing = getTestSubject().getByProjectAndAlias(project, existingAlias);
assertNotNull(existing);
assertEquals(existingAlias, existing.getAlias());
assertNull(getTestSubject().getByProjectAndAlias(project, "doesnotexist"));
}
use of uk.ac.bbsrc.tgac.miso.core.data.Subproject in project miso-lims by miso-lims.
the class Dtos method to.
public static Subproject to(@Nonnull SubprojectDto from) {
Subproject to = new SubprojectImpl();
setLong(to::setId, from.getId(), false);
setString(to::setAlias, from.getAlias());
setString(to::setDescription, from.getDescription());
setBoolean(to::setPriority, from.getPriority(), true);
setObject(to::setReferenceGenome, ReferenceGenomeImpl::new, from.getReferenceGenomeId());
setObject(to::setParentProject, ProjectImpl::new, from.getParentProjectId());
return to;
}
use of uk.ac.bbsrc.tgac.miso.core.data.Subproject in project miso-lims by miso-lims.
the class EditProjectController method setupForm.
private ModelAndView setupForm(Project project, ModelMap model) throws IOException {
if (project.isSaved()) {
Collection<Subproject> subprojects = subprojectService.listByProjectId(project.getId());
model.put("subprojects", Dtos.asSubprojectDtos(subprojects));
model.put("title", "Project " + project.getId());
MisoWebUtils.addIssues(issueTrackerManager, () -> issueTrackerManager.getIssuesByTag(project.getShortName()), model);
model.put("projectReportLinks", externalUriBuilder.getUris(project));
}
model.put("project", project);
ObjectMapper mapper = new ObjectMapper();
model.put("projectDto", mapper.writeValueAsString(Dtos.asDto(project)));
ObjectNode formConfig = mapper.createObjectNode();
MisoWebUtils.addJsonArray(mapper, formConfig, "statusOptions", Arrays.asList(StatusType.values()), StatusType::getKey);
ObjectNode namingConfig = formConfig.putObject("naming");
addNamingSchemeConfig(namingConfig, "primary", namingSchemeHolder.getPrimary(), project);
addNamingSchemeConfig(namingConfig, "secondary", namingSchemeHolder.getSecondary(), project);
model.put("formConfig", mapper.writeValueAsString(formConfig));
return new ModelAndView("/WEB-INF/pages/editProject.jsp", model);
}
use of uk.ac.bbsrc.tgac.miso.core.data.Subproject in project miso-lims by miso-lims.
the class HibernateSubprojectDaoIT method getCreateItem.
@Override
public Subproject getCreateItem() {
Subproject subproject = new SubprojectImpl();
subproject.setAlias("Exciting");
subproject.setPriority(true);
Project project = (Project) currentSession().get(ProjectImpl.class, 2L);
subproject.setParentProject(project);
ReferenceGenome reference = (ReferenceGenome) currentSession().get(ReferenceGenomeImpl.class, 1L);
subproject.setReferenceGenome(reference);
User user = (User) currentSession().get(UserImpl.class, 1L);
subproject.setChangeDetails(user);
return subproject;
}
Aggregations