Source:
public DatasetDTO generateSubObservationDataset( final String cropName, final Integer studyId, final Integer parentId, final DatasetGeneratorInput datasetGeneratorInput) { this.studyValidator.validate(studyId, true); final BindingResult bindingResult = new MapBindingResult(new HashMap<String, String>(), DatasetGeneratorInput.class.getName()); this.datasetValidator.validateDatasetBelongsToStudy(studyId, parentId); this.instanceValidator.validate(null, Sets.newHashSet(datasetGeneratorInput.getInstanceIds())); this.datasetGeneratorInputValidator.validateBasicData(cropName, studyId, parentId, datasetGeneratorInput, bindingResult); if (bindingResult.hasErrors()) { throw new ApiRequestValidationException(bindingResult.getAllErrors()); } this.datasetGeneratorInputValidator.validateDatasetTypeIsImplemented(datasetGeneratorInput.getDatasetTypeId(), bindingResult); if (bindingResult.hasErrors()) { throw new NotSupportedException(bindingResult.getAllErrors().get(0)); } this.datasetGeneratorInputValidator.validateDatasetName(datasetGeneratorInput, bindingResult); if (bindingResult.hasErrors()) { throw new ConflictException(bindingResult.getAllErrors()); } this.datasetGeneratorInputValidator.validateDataConflicts(studyId, datasetGeneratorInput, bindingResult); if (bindingResult.hasErrors()) { throw new ConflictException(bindingResult.getAllErrors()); } final org.generationcp.middleware.domain.dms.DatasetDTO datasetDTO = this.middlewareDatasetService .generateSubObservationDataset(studyId, datasetGeneratorInput.getDatasetName(), datasetGeneratorInput.getDatasetTypeId(), Arrays.asList(datasetGeneratorInput.getInstanceIds()), datasetGeneratorInput.getSequenceVariableId(), datasetGeneratorInput.getNumberOfSubObservationUnits(), parentId); final ModelMapper mapper = new ModelMapper(); mapper.getConfiguration().setPropertyCondition(Conditions.isNotNull()); return mapper.map(datasetDTO, DatasetDTO.class); }

Target:
public DatasetDTO generateSubObservationDataset( final String cropName, final Integer studyId, final Integer parentId, final DatasetGeneratorInput datasetGeneratorInput) { this.studyValidator.validate(studyId, true); final BindingResult bindingResult = new MapBindingResult(new HashMap<String, String>(), DatasetGeneratorInput.class.getName()); this.datasetValidator.validateDatasetBelongsToStudy(studyId, parentId); this.instanceValidator.validate(null, Sets.newHashSet(datasetGeneratorInput.getInstanceIds())); this.datasetGeneratorInputValidator.validateBasicData(cropName, studyId, parentId, datasetGeneratorInput, bindingResult); if (bindingResult.hasErrors()) { throw new ApiRequestValidationException(bindingResult.getAllErrors()); } this.datasetGeneratorInputValidator.validateDatasetTypeIsImplemented(datasetGeneratorInput.getDatasetTypeId(), bindingResult); if (bindingResult.hasErrors()) { throw new NotSupportedException(bindingResult.getAllErrors().get(0)); } this.datasetGeneratorInputValidator.validateDataConflicts(studyId, datasetGeneratorInput, bindingResult); if (bindingResult.hasErrors()) { throw new ConflictException(bindingResult.getAllErrors()); } final org.generationcp.middleware.domain.dms.DatasetDTO datasetDTO = this.middlewareDatasetService .generateSubObservationDataset(studyId, datasetGeneratorInput.getDatasetName(), datasetGeneratorInput.getDatasetTypeId(), Arrays.asList(datasetGeneratorInput.getInstanceIds()), datasetGeneratorInput.getSequenceVariableId(), datasetGeneratorInput.getNumberOfSubObservationUnits(), parentId); final ModelMapper mapper = new ModelMapper(); mapper.getConfiguration().setPropertyCondition(Conditions.isNotNull()); return mapper.map(datasetDTO, DatasetDTO.class); }