Changeset 2561

Show
Ignore:
Timestamp:
11/06/08 10:57:13 (2 months ago)
Author:
pataphil
Message:

Changed NSFReaderAlgorithm to not fail silently when converting NSF data.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plugins/converter/edu.iu.nwb.converter.prefusensf/src/edu/iu/nwb/converter/prefusensf/NSFReaderAlgorithm.java

    r2488 r2561  
    185185         
    186186        private Data convertInputData(Data inputData) throws AlgorithmExecutionException { 
    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 
    191192                  
    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); 
    203210                } 
    204211        }