@Override public Long getId() { return study.getId(); }
@Override public void setId(Long id) { study.setId(id); }
public void addStudy(Study s) { // do study validation s.setProject(this); // propagate security profiles down the hierarchy s.setSecurityProfile(this.securityProfile); // add this.studies.add(s); }
@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); } }
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 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); }
/** * Equivalency is based on getProjectId() if set, otherwise on name, description and creation date. */ @Override public boolean equals(Object obj) { if (obj == null) return false; if (obj == this) return true; if (!(obj instanceof Study)) return false; Study them = (Study) obj; // If not saved, then compare resolved actual objects. Otherwise // just compare IDs. if (getId() == StudyImpl.UNSAVED_ID || them.getId() == StudyImpl.UNSAVED_ID) { if (getName() != null && them.getName() != null) { return getName().equals(them.getName()); } else { return getAlias().equals(them.getAlias()); } } else { return this.getId() == them.getId(); } }
xmlStudyRef.setAttribute("refname", experiment.getStudy().getAlias()); xmlStudyRef.setAttribute("refcenter", centreName); if (!isStringEmptyOrNull(experiment.getStudy().getAccession())) { xmlStudyRef.setAttribute("accession", experiment.getStudy().getAccession());
public static Study to(@Nonnull StudyDto dto) { Study to = new StudyImpl(); to.setId(dto.getId()); return to; }
experiment.setInstrumentModel(platformService.get(experiment.getInstrumentModel().getId())); experiment.setLibrary(libraryService.get(experiment.getLibrary().getId())); experiment.setStudy(studyService.get(experiment.getStudy().getId())); experiment.setChangeDetails(authorizationManager.getCurrentUser()); if (experiment.getSecurityProfile().getProfileId() == SecurityProfile.UNSAVED_ID) { original.setInstrumentModel(platformService.get(experiment.getInstrumentModel().getId())); original.setLibrary(libraryService.get(experiment.getLibrary().getId())); original.setStudy(studyService.get(experiment.getStudy().getId())); original.setSecurityProfile(securityStore.getSecurityProfileById(experiment.getSecurityProfile().getProfileId())); original.setTitle(experiment.getTitle());