Changeset 555


Ignore:
Timestamp:
Jan 28, 2008, 11:48:07 AM (13 years ago)
Author:
Martin Svensson
Message:

References #89 Added more property checks when an item already exists and changed some exception messages. Now await some comments on names, ids etc. according to our meeting 25/1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/net/sf/basedb/illumina/src/net/sf/basedb/illumina/install/Install.java

    r554 r555  
    2929import net.sf.basedb.core.DataFileType;
    3030import net.sf.basedb.core.DbControl;
     31import net.sf.basedb.core.FileType;
    3132import net.sf.basedb.core.InvalidDataException;
    3233import net.sf.basedb.core.Item;
     
    4344import net.sf.basedb.core.RequestInformation;
    4445import net.sf.basedb.core.StringParameterType;
     46import net.sf.basedb.core.SystemItems;
    4547import net.sf.basedb.core.plugin.About;
    4648import net.sf.basedb.core.plugin.AboutImpl;
     
    111113    (
    112114      "installSnp",
    113       "Install SNP variant",
    114       "The SNP variant of Illumina should be installed?",
     115      "SNP variant",
     116      "TRUE if he SNP variant of Illumina should be installed, FALSE otherwise.",
    115117      new BooleanParameterType(true, true)
    116118    );   
     
    118120  (
    119121    "installExp1",
    120     "Install Expression1 variant",
    121     "The Expression1 variant of Illumina should be installed?",
     122    "Expression 1",
     123    "TRUE if the Expression 1 variant of Illumina should be installed, FALSE otherwise.",
    122124    new BooleanParameterType(true, true)
    123125  ); 
     
    125127  (
    126128    "installExp2",
    127     "Install Expression2 variant",
    128     "The Expression2 variant of Illumina should be installed?",
     129    "Expression2",
     130    "TRUE if the Expression 2 variant of Illumina should be installed, FALSE otherwise",
    129131    new BooleanParameterType(true, true)
    130132  );
     
    134136 
    135137  private static final String BGX_FILEYTPE_EXTENSION = "bgx";
    136   private static final String SCANDATA_FILETYPE_EXTENSION = "";
    137   private static final String SNP_FILETYPE_EXTENSION = "";
     138  private static final String SCANDATA_FILETYPE_EXTENSION = ""; //TODO
     139  private static final String SNP_FILETYPE_EXTENSION = ""; //TODO
    138140 
    139141  private static final PluginParameter<String> alreadyInstalledErrorParameter = new PluginParameter<String>(
    140142    "alreadyInstalledError",
    141     "Platform or any of the selected variants is already installed",
    142     "How to situations where the platform or any of the selected variants " +
    143     "already exists in the database." +
    144     "If not specified, default value will be used.\n\n" +
     143    "Item already exists.",
     144    "How to act when an external id is taken for either the platform or any of the selected variants." +
     145    "If not specified, default value(skip) will be used.\n\n" +
    145146    "abort = Abort the installation, nothing will be created.\n" +
    146     "skip = Installation of the already existing item will be skipped " +
    147     "and the installation tries to proceed with rest of the items.",
     147    "skip = The installation will skip the existing item " +
     148    "and try to proceed.",
    148149    new StringParameterType(255, SKIP_OPTION, true, 1, 0, 0,
    149150      Arrays.asList( new String[] { ABORT_OPTION, SKIP_OPTION}))
     
    198199        boolean installExp2 = (Boolean)job.getValue("installExp2");
    199200        String alreadyExistingItem = (String)job.getValue("alreadyInstalledError");
    200        
     201
    201202        HashSet<Integer> expressionTypes = new HashSet<Integer>();
    202203        if (installExp1) expressionTypes.add(1);
     
    299300  public void installIlluminaItems(boolean installSNP, HashSet<Integer> expressionTypes, boolean ignoreExistingItems, ProgressReporter progress)
    300301    throws ItemAlreadyExistsException
    301   {
     302  {   
     303    RawDataType illuminaRawDataType = RawDataTypes.getRawDataType("illumina_scandata");
     304    if (illuminaRawDataType == null)
     305    {
     306      throw new InvalidDataException("Raw data type[illumina.scandata] is missing. " +
     307          "This must exist before the items can be installed, see the Illumina plug-in manual.");
     308    }
    302309    DbControl dc = null;
    303310    int largestNumOfStrips = 0;
     
    309316    String bgxFileTypeId = "illumina.bgx";
    310317   
     318    FileType reporterMapType = null;
     319    FileType rawDataType = null;
     320   
    311321    Iterator<Integer> expressionTypeIterator = expressionTypes.iterator();
    312322    while(expressionTypeIterator.hasNext())
     
    320330      dc = sc.newDbControl();
    321331 
     332      reporterMapType = FileType.getById(dc, SystemItems.getId("net.sf.basedb.core.FileType.REPORTER_MAP"));
     333      rawDataType = FileType.getById(dc, SystemItems.getId("net.sf.basedb.core.FileType.RAW_DATA"));
     334     
    322335      List<DataFileType> expressionDataFileTypes = new ArrayList<DataFileType>();
    323336      DataFileType dft = createDataFileType(dc, bgxFileTypeId, "BGX file", Item.ARRAYDESIGN, BGX_FILEYTPE_EXTENSION, ignoreExistingItems);
    324       dft.setDescription("Illumina BGX file");
     337      if (dft.getDescription() == null || dft.getDescription().equals(""))dft.setDescription("Illumina BGX file");
     338      if (dft.getGenericType() == null) dft.setGenericType(reporterMapType);
    325339      expressionDataFileTypes.add(dft);
    326340
    327341      for (int i = 1; i <= largestNumOfStrips; i++ )
    328342      {
    329         String name = "Scandata filetype" + i; 
     343        String name = "Scandata " + i; 
    330344        dft = createDataFileType(dc, scandataFileTypePrefix + i, name, Item.RAWBIOASSAY, SCANDATA_FILETYPE_EXTENSION, ignoreExistingItems);
    331         dft.setDescription("Illumina scandata file");
     345        if (dft.getGenericType() == null) dft.setGenericType(rawDataType);
     346        if (dft.getDescription() == null || dft.getDescription().equals("")) dft.setDescription("Illumina scandata file for strip #" + i + " in the array.");
    332347        expressionDataFileTypes.add(dft);
    333348      }
     
    338353      dc = sc.newDbControl();
    339354      Platform illuminaPlatform = createPlatform(dc, illuminaPlatformExternalId, "Illumina", ignoreExistingItems);
     355      if (illuminaPlatform.getDescription() == null || illuminaPlatform.getDescription().equals("")) illuminaPlatform.setDescription("Illumina platform.");
    340356           
    341357      List<PlatformVariant> platformVariants = new ArrayList<PlatformVariant>();     
    342       String namePrefix = "Illumina expression";
     358      String namePrefix = "Expression ";
    343359      for (int type : expressionTypes)
    344360      {
    345361        PlatformVariant pfv = createPlatformVariant(dc, expExternalIdPrefix + type, namePrefix + type,
    346             illuminaPlatform, RawDataTypes.getRawDataType("illumina.scandata"), ignoreExistingItems);
    347         pfv.setDescription("Platform variant to use with Illumina expression containing " + type + " strip(s)/array");
     362            illuminaPlatform, illuminaRawDataType, ignoreExistingItems);
     363        if (pfv.getDescription() == null || pfv.getDescription().equals("")) pfv.setDescription("Platform variant to use with Illumina expression containing " + type + " strip(s)/array");
    348364        pfv.addFileType(DataFileType.getByExternalId(dc, bgxFileTypeId), true);
    349365        for (int i = 1; i <= type; i++)
     
    356372      {
    357373        PlatformVariant pfv = createPlatformVariant(dc, snpVariantExternalId, "Illumina SNP", illuminaPlatform, 2, ignoreExistingItems);
    358         pfv.setDescription("Platform variant to be used with Illumina SNP data.");
     374        if (pfv.getDescription() == null || pfv.getDescription().equals("")) pfv.setDescription("Platform variant to be used with Illumina SNP data.");
    359375        //TODO Add data file types to the SNP variant.
    360376        platformVariants.add(pfv);       
     
    409425      dft = DataFileType.getByExternalId(dc, externalId);
    410426      if (!dft.getExtension().equals(extension)) message = dft.getName() + " has invalid extension";
    411       if (dft.getItemType().equals(itemType)) message = dft.getName() + " has invalid item type";
     427      if (!dft.getItemType().equals(itemType)) message = dft.getName() + " has invalid item type";
    412428      if (message != null) throw new ItemAlreadyExistsException(message);
    413429     
     
    433449        throw new ItemAlreadyExistsException(platform.getExternalId());
    434450      }
     451      String message = null;
     452      if (platform.getRawDataType() != null) message = "The already existing platform has a raw data type that can't be used with " + name + "[" + externalId + "]";
     453      if (message != null) throw new ItemAlreadyExistsException(message);
    435454      //TODO Check that existing platform can be used with the rest of the items.
    436455    }
     
    460479      String message = null;
    461480      if (variant.isFileOnly()) message = "Platform variant " + variant.getExternalId() + " already exists but is file-only";
    462       if (!variant.getRawDataType().equals(rawDataType)) message = "Platform variant " + variant.getExternalId() + " already exists but has not " + rawDataType.getName() + " as raw data type";
    463       if (!variant.getPlatform().equals(illuminaPlatform)) message = "Platform variant " + variant.getExternalId() + " already exists for another platform.";
     481      else if (variant.getRawDataType() != null && !variant.getRawDataType().equals(rawDataType))
     482      {
     483        message = "Platform variant " + variant.getExternalId() + " already exists but has not the right raw data type";
     484      }
     485      else if (!variant.getPlatform().equals(illuminaPlatform)) message = "Platform variant " + variant.getExternalId() + " already exists for another platform.";
    464486      if (message != null) throw new ItemAlreadyExistsException(message);
    465487     
     
    490512      String message = null;
    491513      if (!variant.isFileOnly()) message = "Platform variant " + variant.getName() + " exists but is not file-only";
    492       if (!variant.getPlatform().equals(platform)) message = "Platform variant " + variant.getName() + " exists but has not platform: " + platform;
    493       if (variant.getRawDataType().getChannels() != channels) message = "Platform variant " + variant.getName() + " exists but not for " + channels + " data"; 
     514      else if (!variant.getPlatform().equals(platform)) message = "Platform variant " + variant.getName() + " exists but has not platform: " + platform;
     515      else if (variant.getRawDataType().getChannels() != channels) message = "Platform variant " + variant.getName() + " exists but not for " + channels + " data"; 
    494516      if (message != null) throw new InvalidDataException (message);
    495517    }
Note: See TracChangeset for help on using the changeset viewer.