| 187 | | DataConversionService converter = (DataConversionService) |
|---|
| 188 | | context.getService(DataConversionService.class.getName()); |
|---|
| 189 | | //this is a bit like a cast. We know the nsf format is also a csv, so we change the format to csv so |
|---|
| 190 | | //the Conversion service knows it is a csv when it tries to convert it to a prefuse.data.Table |
|---|
| | 187 | try { |
|---|
| | 188 | DataConversionService converter = (DataConversionService) |
|---|
| | 189 | context.getService(DataConversionService.class.getName()); |
|---|
| | 190 | // This is a bit like a cast. We know the nsf format is also a csv, so we change the format to csv so |
|---|
| | 191 | // the Conversion service knows it is a csv when it tries to convert it to a prefuse.data.Table |
|---|
| 192 | | //printTable((Table) inputData.getData()); |
|---|
| 193 | | Dictionary metadata = inputData.getMetadata(); |
|---|
| 194 | | Data formatChangedData = new BasicData(metadata, cleanNSFCSVFormat((File) inputData.getData()), "file:text/csv"); |
|---|
| 195 | | try { |
|---|
| 196 | | Data convertedData = converter.convert(formatChangedData, "prefuse.data.Table"); |
|---|
| 197 | | if (! (convertedData.getData() instanceof Table)) { |
|---|
| 198 | | throw new ConversionException("Output of conversion was not a prefuse.data.Table"); |
|---|
| 199 | | } |
|---|
| 200 | | return convertedData; |
|---|
| 201 | | } catch (ConversionException e1) { |
|---|
| 202 | | throw new AlgorithmExecutionException("Could not convert format to prefuse.data.Table", e1); |
|---|
| | 193 | // PrintTable((Table) inputData.getData()); |
|---|
| | 194 | Dictionary metadata = inputData.getMetadata(); |
|---|
| | 195 | Data formatChangedData = new BasicData(metadata, cleanNSFCSVFormat((File) inputData.getData()), "file:text/csv"); |
|---|
| | 196 | |
|---|
| | 197 | try { |
|---|
| | 198 | Data convertedData = converter.convert(formatChangedData, "prefuse.data.Table"); |
|---|
| | 199 | |
|---|
| | 200 | if (!(convertedData.getData() instanceof Table)) { |
|---|
| | 201 | throw new ConversionException("Output of conversion was not a prefuse.data.Table"); |
|---|
| | 202 | } |
|---|
| | 203 | |
|---|
| | 204 | return convertedData; |
|---|
| | 205 | } catch (ConversionException e1) { |
|---|
| | 206 | throw new AlgorithmExecutionException("Could not convert format to prefuse.data.Table", e1); |
|---|
| | 207 | } |
|---|
| | 208 | } catch (Throwable e) { |
|---|
| | 209 | throw new AlgorithmExecutionException("An error occurred while converting NSF data.", e); |
|---|