Source:
public SampleDetailsDTO getSampleObservation(final String sampleId) { final SampleDetailsDTO samplesDetailsDto; final Sample sample = this.sampleDao.getBySampleBk(sampleId); if (sample == null) { return new SampleDetailsDTO(); } final Integer studyId = sample.getPlant().getExperiment().getExperimentStocks().get(0).getExperiment().getProject().getRelatedTos().get(0) .getObjectProject().getProjectId(); final String takenBy = sample.getTakenBy() != null ? sample.getTakenBy().getPerson().getDisplayName() : null; final String plotId = sample.getPlant().getExperiment().getPlotId(); final String studyName = sample.getPlant().getExperiment().getExperimentStocks().get(0).getExperiment().getProject().getRelatedTos().get(0) .getObjectProject().getName(); final String entryNo = sample.getPlant().getExperiment().getExperimentStocks().get(0).getStock().getUniqueName(); final Integer gid = sample.getPlant().getExperiment().getExperimentStocks().get(0).getStock().getDbxrefId(); samplesDetailsDto = new SampleDetailsDTO(studyId, plotId, sample.getPlant().getPlantBusinessKey(), sample.getSampleBusinessKey()); samplesDetailsDto.setTakenBy(takenBy); samplesDetailsDto.setSampleDate(sample.getSamplingDate()); samplesDetailsDto.setStudyName(studyName); samplesDetailsDto.setEntryNo(Integer.valueOf(entryNo)); samplesDetailsDto.setGid(gid); getPlotNoByExperimentProperty(sample.getPlant().getExperiment().getProperties(), samplesDetailsDto); getProjectProperties( sample.getPlant().getExperiment().getProject().getRelatedTos().get(0).getObjectProject().getProperties(), samplesDetailsDto); getLocationByGeoLocationProperties(sample.getPlant().getExperiment().getGeoLocation().getProperties(), samplesDetailsDto); return samplesDetailsDto; }

Target:
public SampleDetailsDTO getSampleObservation(final String sampleId) { final SampleDetailsDTO samplesDetailsDto; final Sample sample = this.sampleDao.getBySampleBk(sampleId); if (sample == null) { return new SampleDetailsDTO(); } final ExperimentModel experiment = sample.getPlant().getExperiment(); final DmsProject objectProject = experiment.getExperimentStocks().get(0).getExperiment().getProject().getRelatedTos().get(0).getObjectProject(); final Integer studyId = objectProject.getProjectId(); final String takenBy = sample.getTakenBy() != null ? sample.getTakenBy().getPerson().getDisplayName() : null; final String plotId = experiment.getPlotId(); final String studyName = objectProject.getName(); final StockModel stock = experiment.getExperimentStocks().get(0).getStock(); final String entryNo = stock.getUniqueName(); final Integer gid = stock.getDbxrefId(); samplesDetailsDto = new SampleDetailsDTO(studyId, plotId, sample.getPlant().getPlantBusinessKey(), sample.getSampleBusinessKey()); samplesDetailsDto.setTakenBy(takenBy); samplesDetailsDto.setSampleDate(sample.getSamplingDate()); samplesDetailsDto.setStudyName(studyName); samplesDetailsDto.setEntryNo(Integer.valueOf(entryNo)); samplesDetailsDto.setGid(gid); fillPlotNoByExperimentProperty(sample.getPlant().getExperiment().getProperties(), samplesDetailsDto); fillProjectProperties(sample.getPlant().getExperiment().getProject().getRelatedTos().get(0).getObjectProject().getProperties(), samplesDetailsDto); fillLocationByGeoLocationProperties(sample.getPlant().getExperiment().getGeoLocation().getProperties(), samplesDetailsDto); return samplesDetailsDto; }