Source:
public void setValuesToMissing(final Integer datasetId) { final List<Phenotype> phenotypes = this.daoFactory.getPhenotypeDAO().getDraftDataOfDataset(datasetId); if (phenotypes.size() > 0) { final List<Phenotype> allPhenotypes = this.daoFactory.getPhenotypeDAO().getPhenotypes(datasetId); final List<MeasurementVariable> measurementVariableList = this.daoFactory.getDmsProjectDAO().getObservationSetVariables(datasetId, DatasetServiceImpl.MEASUREMENT_VARIABLE_TYPES); for (final MeasurementVariable measurementVariable : measurementVariableList) { final Collection<Phenotype> selectedPhenotypes = CollectionUtils.select(phenotypes, new Predicate() { @Override public boolean evaluate(final Object o) { final Phenotype phenotype = (Phenotype) o; return phenotype.getObservableId().equals(measurementVariable.getTermId()); } }); Collection<Phenotype> possibleValues = null; if (measurementVariable.getPossibleValues() != null && !measurementVariable.getPossibleValues().isEmpty()) { possibleValues = CollectionUtils.collect(measurementVariable.getPossibleValues(), new Transformer() { @Override public String transform(final Object input) { final ValueReference variable = (ValueReference) input; return variable.getName(); } }); } for (final Phenotype phenotype : selectedPhenotypes) { if (!ExportImportUtils.isValidValue(measurementVariable, phenotype.getDraftValue(), possibleValues)) { this.updatePhenotype(phenotype.getPhenotypeId(), null, Phenotype.MISSING, false); } else { this.acceptDraftData(phenotype); } } if (!selectedPhenotypes.isEmpty()) { this.reorganizeStatusOfPehnotypes(datasetId, phenotypes, allPhenotypes); } } } }

Target:
public void setValuesToMissing(final Integer datasetId) { final List<Phenotype> draftPhenotypes = this.daoFactory.getPhenotypeDAO().getDatasetDraftData(datasetId); if (!draftPhenotypes.isEmpty()) { final List<Phenotype> allPhenotypes = this.daoFactory.getPhenotypeDAO().getPhenotypes(datasetId); final List<MeasurementVariable> measurementVariableList = this.daoFactory.getDmsProjectDAO().getObservationSetVariables(datasetId, DatasetServiceImpl.MEASUREMENT_VARIABLE_TYPES); for (final MeasurementVariable measurementVariable : measurementVariableList) { final Collection<Phenotype> selectedPhenotypes = CollectionUtils.select(draftPhenotypes, new Predicate() { @Override public boolean evaluate(final Object o) { final Phenotype phenotype = (Phenotype) o; return phenotype.getObservableId().equals(measurementVariable.getTermId()); } }); Collection<Phenotype> possibleValues = null; if (measurementVariable.getPossibleValues() != null && !measurementVariable.getPossibleValues().isEmpty()) { possibleValues = CollectionUtils.collect(measurementVariable.getPossibleValues(), new Transformer() { @Override public String transform(final Object input) { final ValueReference variable = (ValueReference) input; return variable.getName(); } }); } for (final Phenotype phenotype : selectedPhenotypes) { if (!ExportImportUtils.isValidValue(measurementVariable, phenotype.getDraftValue(), possibleValues)) { this.updatePhenotype(phenotype.getPhenotypeId(), null, Phenotype.MISSING, false); } else { this.acceptDraftData(phenotype); } } if (!selectedPhenotypes.isEmpty()) { this.reorganizePhenotypesStatus(datasetId, draftPhenotypes, allPhenotypes); } } } }