Ignore:
Timestamp:
Feb 14, 2007, 2:51:39 PM (16 years ago)
Author:
mbayer
Message:

error handling improved

Location:
trunk/uk/ac/scri/batchimporter/src/sbrn/base
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/uk/ac/scri/batchimporter/src/sbrn/base/BatchDataImport.java

    r231 r234  
    200200    System.out.println("dir = " + dir.getName());
    201201
    202     //get the raw data type
     202    //get the raw data type from the experiment
    203203    RawDataType rawDataType = experiment.getRawDataType();
    204204    System.out.println("rawDataType = " + rawDataType.getName());
     
    247247            }
    248248            //if it's a cel file, add it to the dataFiles array
    249             if(extension.equalsIgnoreCase("cel"))
     249            else if(extension.equalsIgnoreCase("cel"))
    250250            {
    251251                System.out.println("setting dataFiles["+dataFileCount+"] to file " + file.getName());
    252252                dataFiles[dataFileCount] = file;
    253253                dataFileCount++;
     254            }
     255            //if it is neither a cel file nor a cdf file then the user must have defined the Experiment as
     256            //being Affy but the data they are importing is not Affy
     257            //in that case we need to throw an Exception and abort the whole import
     258            else
     259            {
     260              throw new Exception("data file is not Affymetrix cel file but Experiment was defined as Affymetrix data type");
    254261            }
    255262          }
     
    277284      File exampleFile = fileList.get(0);
    278285      System.out.println("exampleFile = " + exampleFile.getName());
    279 
    280       //only do this for non-Affy data types
     286     
     287      //check we don't have a discrepancy between the raw data type and the data files here
     288      //if users have specified a non-affy data type and the data is affy we need to abort the import with an appropriate error
     289      //get the current file and check its extension
     290      String exampleFileName = exampleFile.getName();
     291      String exampleFileExtension = exampleFileName.substring(exampleFileName.lastIndexOf(".")+1);
     292      if(exampleFileExtension.equalsIgnoreCase("cdf") || exampleFileExtension.equalsIgnoreCase("cel"))
     293      {
     294        throw new Exception("Affymetrix data found but Experiment data type was specified as non-Affy");
     295      }
     296
     297      //for non-Affy data types, find a suitable plugin configuration
    281298      PluginConfiguration importConfig = null;
    282299      if (!rawDataType.getName().equalsIgnoreCase("affymetrix"))
     
    286303        importConfig = detector.detectPluginConfig(exampleFile);     
    287304        System.out.println("PluginConfiguration importConfig = " + importConfig);
     305       
     306        //now need to figure out the raw data type to make sure it matches that of the Experiment we are importing into
     307        //this can be done by looking at the plugin config which should have it stored in it
     308        List rdtVal = importConfig.getParameterValues("rawDataType");
     309        String rawDataTypeStr = (String)rdtVal.get(0);
     310        System.out.println("rawDataType detected from files = " + rawDataTypeStr); 
     311        //compare this to the raw data type of the experiment
     312        if(!rawDataType.getName().equalsIgnoreCase(rawDataTypeStr))
     313        {
     314          throw new Exception("raw data types of experiment and data files do not match");
     315        }
     316       
    288317      }
    289318
     
    374403      }
    375404     
     405      //make sure we have a working dbcontrol object
     406      if(dc.isClosed())
     407        dc = sc.newDbControl();     
    376408      //commit the changes to the database
    377409      dc.commit();
  • trunk/uk/ac/scri/batchimporter/src/sbrn/base/PluginConfigDetector.java

    r229 r234  
    7979      pc = configList.get(0);
    8080    }
    81     catch (Exception x)
     81    catch (IndexOutOfBoundsException x)
    8282    {
    8383      x.printStackTrace();
    84       throw new Exception(x);
     84      throw new Exception("no suitable plugin configuration found for this data type");
    8585    }
    8686    finally
Note: See TracChangeset for help on using the changeset viewer.