@Override protected void populate(Element xml, Study s) { xml.setAttribute("alias", s.getAlias()); Element studyDescriptor = xml.getOwnerDocument().createElementNS(null, "DESCRIPTOR"); xml.appendChild(studyDescriptor); Element studyTitle = xml.getOwnerDocument().createElementNS(null, "STUDY_TITLE"); studyTitle.setTextContent(s.getAlias()); studyDescriptor.appendChild(studyTitle); Element studyType = xml.getOwnerDocument().createElementNS(null, "STUDY_TYPE"); studyType.setAttribute("existing_study_type", s.getStudyType().getName()); studyDescriptor.appendChild(studyType); Element centerProjectName = xml.getOwnerDocument().createElementNS(null, "CENTER_PROJECT_NAME"); centerProjectName.setTextContent(s.getProject().getAlias()); studyDescriptor.appendChild(centerProjectName); Element studyAbstract = xml.getOwnerDocument().createElementNS(null, "STUDY_ABSTRACT"); studyDescriptor.appendChild(studyAbstract); Element studyDescription = xml.getOwnerDocument().createElementNS(null, "STUDY_DESCRIPTION"); studyDescription.setTextContent(s.getDescription()); studyDescriptor.appendChild(studyDescription); }
public static StudyDto asDto(@Nonnull Study from) { StudyDto dto = new StudyDto(); dto.setId(from.getId()); dto.setAccession(from.getAccession()); dto.setAlias(from.getAlias()); dto.setDescription(from.getDescription()); dto.setName(from.getName()); dto.setProjectId(from.getProject().getId()); dto.setStudyTypeId(from.getStudyType().getId()); return dto; }
@Override public long save(Study study) throws IOException { if (study.getId() == StudyImpl.UNSAVED_ID) { study.setChangeDetails(authorizationManager.getCurrentUser()); study.setStudyType(studyStore.getType(study.getStudyType().getId())); study.setProject(projectStore.get(study.getProject().getId())); study.setName(LimsUtils.generateTemporaryName()); study.setSecurityProfile(study.getProject().getSecurityProfile()); long id = studyStore.save(study); try { study.setName(namingScheme.generateNameFor(study)); LimsUtils.validateNameOrThrow(study, namingScheme); studyStore.save(study); } catch (MisoNamingException e) { throw new IOException(e); } return id; } else { Study original = studyStore.get(study.getId()); authorizationManager.throwIfNotWritable(original); original.setAccession(study.getAccession()); original.setAlias(study.getAlias()); original.setDescription(study.getDescription()); original.setChangeDetails(authorizationManager.getCurrentUser()); // project is immutable original.setStudyType(studyStore.getType(study.getStudyType().getId())); return studyStore.save(original); } }