Source:
File generate( final int studyId, final int datasetId, final Set<Integer> instanceIds, final int collectionOrderId, final DatasetFileGenerator generator, final boolean singleFile, final String fileExtension) throws IOException { final Study study = this.studyDataManager.getStudy(studyId); final DatasetDTO dataSet = this.datasetService.getDataset(datasetId); final List<MeasurementVariable> columns = this.getColumns(study.getId(), dataSet.getDatasetId()); if (dataSet.getDatasetTypeId().equals(DatasetTypeEnum.PLOT_DATA.getId())) { final LotsSearchDto lotsSearchDto = new LotsSearchDto(); lotsSearchDto.setPlantingStudyIds(Arrays.asList(studyId)); if (this.lotService.countSearchLots(lotsSearchDto) > 0) { this.addStockIdColumn(columns); } } final Map<Integer, StudyInstance> selectedDatasetInstancesMap = this.getSelectedDatasetInstancesMap( dataSet.getInstances(), instanceIds); final Map<Integer, List<ObservationUnitRow>> observationUnitRowMap = this.getObservationUnitRowMap(study, dataSet, selectedDatasetInstancesMap); final DatasetCollectionOrderServiceImpl.CollectionOrder collectionOrder = DatasetCollectionOrderServiceImpl.CollectionOrder.findById(collectionOrderId); final int trialDatasetId = this.studyDataManager.getDataSetsByType(study.getId(), DatasetTypeEnum.SUMMARY_DATA.getId()).get(0).getId(); this.datasetCollectionOrderService.reorder(collectionOrder, trialDatasetId, selectedDatasetInstancesMap, observationUnitRowMap); if (singleFile) { return this.generateInSingleFile(study, dataSet, observationUnitRowMap, columns, generator, fileExtension); } else { return this .generateFiles(study, dataSet, selectedDatasetInstancesMap, observationUnitRowMap, columns, generator, fileExtension); } }

Target:
File generate( final int studyId, final int datasetId, final Set<Integer> instanceIds, final int collectionOrderId, final DatasetFileGenerator generator, final boolean singleFile, final String fileExtension) throws IOException { final Study study = this.studyDataManager.getStudy(studyId); final DatasetDTO dataSet = this.datasetService.getDataset(datasetId); final List<MeasurementVariable> columns = this.getColumns(study.getId(), dataSet.getDatasetId()); if (dataSet.getDatasetTypeId().equals(DatasetTypeEnum.PLOT_DATA.getId())) { final TransactionsSearchDto transactionsSearchDto = new TransactionsSearchDto(); transactionsSearchDto.setTransactionStatus(Arrays.asList(0,1)); transactionsSearchDto.setPlantingStudyIds(Arrays.asList(studyId)); if (this.transactionService.countSearchTransactions(transactionsSearchDto) > 0) { this.addStockIdColumn(columns); } } final Map<Integer, StudyInstance> selectedDatasetInstancesMap = this.getSelectedDatasetInstancesMap( dataSet.getInstances(), instanceIds); final Map<Integer, List<ObservationUnitRow>> observationUnitRowMap = this.getObservationUnitRowMap(study, dataSet, selectedDatasetInstancesMap); final DatasetCollectionOrderServiceImpl.CollectionOrder collectionOrder = DatasetCollectionOrderServiceImpl.CollectionOrder.findById(collectionOrderId); final int trialDatasetId = this.studyDataManager.getDataSetsByType(study.getId(), DatasetTypeEnum.SUMMARY_DATA.getId()).get(0).getId(); this.datasetCollectionOrderService.reorder(collectionOrder, trialDatasetId, selectedDatasetInstancesMap, observationUnitRowMap); if (singleFile) { return this.generateInSingleFile(study, dataSet, observationUnitRowMap, columns, generator, fileExtension); } else { return this .generateFiles(study, dataSet, selectedDatasetInstancesMap, observationUnitRowMap, columns, generator, fileExtension); } }