Changeset 3820


Ignore:
Timestamp:
Oct 12, 2007, 12:03:18 PM (16 years ago)
Author:
Nicklas Nordborg
Message:

Merged branches/filedb into trunk.

Location:
trunk
Files:
73 edited
51 copied

Legend:

Unmodified
Added
Removed
  • trunk/config/dist/raw-data-types.xml

    r3675 r3820  
    649649    </intensity-formula>
    650650  </raw-data-type>
    651  
    652   <raw-data-type
    653     id="affymetrix"
    654     channels="1"
    655     name="Affymetrix"
    656     storage="file"
    657     >
    658   </raw-data-type>
    659  
     651
    660652  <raw-data-type
    661653    id="agilent"
  • trunk/src/clients/migrate/net/sf/basedb/clients/migrate/ArrayTypeTransfer.java

    r3683 r3820  
    3131import net.sf.basedb.core.CommonItem;
    3232import net.sf.basedb.core.DbControl;
     33import net.sf.basedb.core.Platform;
     34
    3335import java.sql.PreparedStatement;
    3436import java.sql.ResultSet;
     
    6163   */
    6264  private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("net.sf.basedb.clients.migrate.ArrayTypeTransfer");
     65 
     66  private Platform generic = null;
    6367 
    6468  /**
     
    99103  {
    100104    DbControl dc = newDbControl();
    101     boolean isAffyChip = false;
    102     ArrayDesign arrayDesign = ArrayDesign.getNew(dc, isAffyChip);
     105    if (generic == null) generic = Platform.getByExternalId(dc, Platform.GENERIC);
     106    ArrayDesign arrayDesign = ArrayDesign.getNew(dc, generic);
    103107    setCommonItemData(dc, (CommonItem) arrayDesign, rs);
    104108    dc.saveItem(arrayDesign);
  • trunk/src/clients/migrate/net/sf/basedb/clients/migrate/RawBioAssayDataTransfer.java

    r3725 r3820  
    136136      {
    137137        log.info("Skipping since it already has data");
    138         progress.increase(rawBioAssay.getSpots());
     138        progress.increase(rawBioAssay.getNumDbSpots());
    139139      }
    140140      progress.decrease(); // We do not want to count the RawBioAssays
  • trunk/src/clients/migrate/net/sf/basedb/clients/migrate/RawBioAssayTransfer.java

    r3725 r3820  
    3030import net.sf.basedb.core.BaseException;
    3131import net.sf.basedb.core.DbControl;
     32import net.sf.basedb.core.Platform;
    3233import net.sf.basedb.core.RawBioAssay;
    3334import net.sf.basedb.core.RawDataTypes;
     
    6263  private SoftwareTransfer softwareT = null;
    6364  private SampleTransfer sampleT = null;
     65  private Platform generic = null;
    6466
    6567  RawBioAssayTransfer()
     
    122124  {
    123125    if (log.isDebugEnabled()) log.debug("transfer RawBioAssay with id:" + rs.getInt(1) + " from  BASE1");
     126    if (generic == null) generic = Platform.getByExternalId(dc, Platform.GENERIC);
    124127    RawBioAssay rawBioAssay = RawBioAssay.getNew(
    125         dc, RawDataTypes.getRawDataType("genepix"));
     128        dc, generic, RawDataTypes.getRawDataType("genepix"));
    126129    setCommonItemData(dc, rawBioAssay, rs);
    127130    // File file = uploadFT.getRawBioAssayFileById(dc, rs.getInt(1));
  • trunk/src/clients/web/net/sf/basedb/clients/web/Base.java

    r3775 r3820  
    2727
    2828import net.sf.basedb.core.Coloring;
     29import net.sf.basedb.core.DataFileType;
    2930import net.sf.basedb.core.DateUtil;
    3031import net.sf.basedb.core.File;
     32import net.sf.basedb.core.FileSet;
     33import net.sf.basedb.core.FileStoreEnabled;
    3134import net.sf.basedb.core.Location;
     35import net.sf.basedb.core.Path;
     36import net.sf.basedb.core.Platform;
     37import net.sf.basedb.core.PlatformVariant;
    3238import net.sf.basedb.core.Protocol;
    3339import net.sf.basedb.core.SessionControl;
     
    826832  }
    827833 
     834  /**
     835    Get a query that returns all data file types for a specific
     836    platform/variant that can be used on a given item type.
     837    @param itemType The item type
     838    @param platform The platform to get file types for, or null
     839    @param variant The platform variant to get file types for, or null
     840    @return An <code>ItemQuery</code> object
     841    @since 2.5
     842  */
     843  public static ItemQuery<DataFileType> getDataFileTypes(Item itemType, Platform platform, PlatformVariant variant)
     844  {
     845    ItemQuery<DataFileType> q = DataFileType.getQuery();
     846    q.restrict(
     847      Restrictions.eq(
     848        Hql.property("itemType"),
     849        Expressions.integer(itemType.getValue())
     850      )
     851    );
     852    if (platform != null)
     853    {
     854      q.join(Hql.innerJoin("platforms", "pft"));
     855      q.restrict(Restrictions.eq(Hql.property("pft", "platform"), Hql.entity(platform)));
     856      if (variant != null)
     857      {
     858        q.restrict(Restrictions.or(
     859            Restrictions.eq(Hql.property("pft", "variant"), null),
     860            Restrictions.eq(Hql.property("pft", "variant"), Hql.entity(variant))
     861        ));
     862      }
     863      else
     864      {
     865        q.restrict(Restrictions.eq(Hql.property("pft", "variant"), null));
     866      }
     867    }
     868    q.order(Orders.asc(Hql.property("name")));
     869    q.setCacheResult(true);
     870    return q;
     871  }
     872 
    828873  private static final Float defaultScale = 1.0f;
    829874  /**
     
    10661111 
    10671112  /**
     1113    Update files that are associated with a {@link FileStoreEnabled}
     1114    item. The <code>request</code> parameter is checked for parameters
     1115    with a name like <code>datafile.id</code> where <code>id</code> is
     1116    the numeric id of a {@link DataFileType}. The parameter value is the
     1117    path of the file to associated with the data file type, or null
     1118    to remove an existing association.
     1119   
     1120    @param dc A DbControl to access the database
     1121    @param item The item the files should be associated with
     1122    @param request The request object containing the selected files
     1123    @param validate If {@link FileSet#validate(DbControl, boolean)}
     1124      should be called or not
     1125    @param extractMetadata If meta data should be extracted or not
     1126      (requires that validate is true)
     1127    @since 2.5
     1128  */
     1129  @SuppressWarnings("unchecked")
     1130  public static void updateFiles(DbControl dc, FileStoreEnabled item,
     1131    HttpServletRequest request, boolean validate, boolean extractMetadata,
     1132    ItemContext cc, int maxRecent)
     1133  {
     1134    Enumeration<String> names = (Enumeration<String>)request.getParameterNames();
     1135    FileSet fileSet = null;
     1136    while (names.hasMoreElements())
     1137    {
     1138      String param = names.nextElement();
     1139      if (param.startsWith("datafile."))
     1140      {
     1141        int dataFileTypeId = Values.getInt(param.substring(9));
     1142        DataFileType dft = DataFileType.getById(dc, dataFileTypeId);
     1143        String filePath = Values.getStringOrNull(request.getParameter(param));
     1144        if (fileSet == null) fileSet = item.getFileSet();
     1145        if (filePath == null)
     1146        {
     1147          fileSet.removeMember(dft);
     1148        }
     1149        else
     1150        {
     1151          File file = File.getByPath(dc, new Path(filePath, Path.Type.FILE), false);
     1152          fileSet.setMember(file, dft);
     1153          if (cc != null)
     1154          {
     1155            cc.setRecent(file, dft.getExternalId(), maxRecent);
     1156          }
     1157        }
     1158      }
     1159    }
     1160    if (validate)
     1161    {
     1162      fileSet.validate(dc, extractMetadata);
     1163    }
     1164  }
     1165 
     1166  /**
    10681167    @see #getEncodedName(Nameable, boolean, String)
    10691168  */
  • trunk/src/clients/web/net/sf/basedb/clients/web/PermissionUtil.java

    r3679 r3820  
    145145    Item.BIOASSAYSET, Item.BIOASSAY, Item.TRANSFORMATION, Item.EXTRAVALUE,
    146146    Item.VIRTUALDB, Item.DATACUBE, Item.DATACUBELAYER, Item.DATACUBECOLUMN, Item.DATACUBEFILTER,
    147     Item.DATACUBEEXTRAVALUE
     147    Item.DATACUBEEXTRAVALUE,
     148    Item.FILESET, Item.FILESETMEMBER,
     149    Item.PLATFORMVARIANT, Item.PLATFORMFILETYPE
    148150  );
    149151 
     
    169171            Item.PROTOCOL, Item.PROTOCOLTYPE, Item.HARDWARE, Item.HARDWARETYPE, Item.SOFTWARE, Item.SOFTWARETYPE,
    170172            Item.ANNOTATIONTYPE, Item.ANNOTATIONTYPECATEGORY, Item.FILETYPE, Item.MIMETYPE, Item.REPORTER,
    171             Item.REPORTERLIST, Item.REPORTERTYPE, Item.EXTRAVALUETYPE
     173            Item.REPORTERLIST, Item.REPORTERTYPE, Item.EXTRAVALUETYPE,
     174            Item.PLATFORM, Item.DATAFILETYPE
    172175          })
    173176        );
  • trunk/src/core/common-queries.xml

    r3741 r3820  
    27152715  </query>
    27162716 
     2717  <query id="UPDATE_PROPERTY_FILTER_VALUE" type="SQL">
     2718    <sql>
     2719      UPDATE [PropertyFilters]
     2720      SET [value] = :newValue
     2721      WHERE [property] = :property AND [value] = :oldValue
     2722    </sql>
     2723    <description>
     2724      An SQL query that changes the property for all PropertyFilters
     2725      with a given value.
     2726    </description>
     2727  </query>
     2728 
    27172729  <query id="SET_AUTOCOMPRESS_ON_MIMETYPES" type="HQL">
    27182730    <sql>
     
    27562768    <sql>
    27572769      UPDATE ArrayDesignData ad
    2758       SET ad.numFeatures = 0
    2759       WHERE ad.numFeatures IS NULL
    2760     </sql>
    2761     <description>
    2762       A HQL query that sets the number of features to 0
     2770      SET ad.numDbFeatures = 0, ad.numFileFeatures = 0
     2771      WHERE ad.numDbFeatures IS NULL OR ad.numFileFeatures IS NULL
     2772    </sql>
     2773    <description>
     2774      A HQL query that sets the number of file and db features to 0
    27632775      on all array designs with a null value.
    27642776    </description>
    27652777  </query>
     2778 
     2779  <query id="SET_NUMFILESPOTS_ON_RAWBIOASSAY" type="HQL">
     2780    <sql>
     2781      UPDATE RawBioAssayData rbd
     2782      SET rbd.numFileSpots = 0
     2783      WHERE rbd.numFileSpots IS NULL
     2784    </sql>
     2785    <description>
     2786      A HQL query that sets the number of file aspots to 0
     2787      on all raw bioassays with a null value.
     2788    </description>
     2789  </query>
     2790
     2791  <query id="GET_RAWBIOASSAYS_FOR_PLATFORM" type="HQL">
     2792    <sql>
     2793      SELECT {1}
     2794      FROM RawBioAssayData rba
     2795      WHERE rba.platform = :platform
     2796    </sql>
     2797    <description>
     2798      A Hibernate query that gets raw bioassays
     2799      with a given platform.
     2800    </description>
     2801  </query>
     2802
     2803  <query id="GET_ARRAYDESIGNS_FOR_PLATFORM" type="HQL">
     2804    <sql>
     2805      SELECT {1}
     2806      FROM ArrayDesignData ad
     2807      WHERE ad.platform = :platform
     2808    </sql>
     2809    <description>
     2810      A Hibernate query that gets array designs
     2811      with a given platform.
     2812    </description>
     2813  </query>
     2814 
     2815  <query id="GET_RAWBIOASSAYS_FOR_VARIANT" type="HQL">
     2816    <sql>
     2817      SELECT {1}
     2818      FROM RawBioAssayData rba
     2819      WHERE rba.variant = :variant
     2820    </sql>
     2821    <description>
     2822      A Hibernate query that gets raw bioassays
     2823      with a given platform variant.
     2824    </description>
     2825  </query>
     2826
     2827  <query id="GET_ARRAYDESIGNS_FOR_VARIANT" type="HQL">
     2828    <sql>
     2829      SELECT {1}
     2830      FROM ArrayDesignData ad
     2831      WHERE ad.variant = :variant
     2832    </sql>
     2833    <description>
     2834      A Hibernate query that gets array designs
     2835      with a given platform variant.
     2836    </description>
     2837  </query>
     2838 
     2839  <query id="GET_PLATFORM_FOR_EXTERNAL_ID" type="HQL">
     2840    <sql>
     2841      SELECT plf
     2842      FROM PlatformData plf
     2843      WHERE plf.externalId = :externalId
     2844    </sql>
     2845    <description>
     2846      A Hibernate query that loads a platform by external ID.
     2847    </description>
     2848  </query>
     2849 
     2850  <query id="GET_PLATFORMVARIANT_FOR_EXTERNAL_ID" type="HQL">
     2851    <sql>
     2852      SELECT plv
     2853      FROM PlatformVariantData plv
     2854      WHERE plv.externalId = :externalId
     2855    </sql>
     2856    <description>
     2857      A Hibernate query that loads a platform variant by external ID.
     2858    </description>
     2859  </query>
     2860 
     2861  <query id="GET_DATAFILETYPE_FOR_EXTERNAL_ID" type="HQL">
     2862    <sql>
     2863      SELECT dft
     2864      FROM DataFileTypeData dft
     2865      WHERE dft.externalId = :externalId
     2866    </sql>
     2867    <description>
     2868      A Hibernate query that loads a data file type by external ID.
     2869    </description>
     2870  </query>
     2871
     2872  <query id="GET_FILESETMEMBERS_FOR_DATAFILETYPE" type="HQL">
     2873    <sql>
     2874      SELECT {1}
     2875      FROM FileSetMemberData mbr
     2876      WHERE mbr.dataFileType = :dataFileType
     2877    </sql>
     2878    <description>
     2879      A Hibernate query that gets file set members of a specific
     2880      data file type.
     2881    </description>
     2882  </query>
     2883
     2884  <query id="GET_PLATFORMFILETYPE_FOR_DATAFILETYPE" type="HQL">
     2885    <sql>
     2886      SELECT {1}
     2887      FROM PlatformFileTypeData pft
     2888      WHERE pft.dataFileType = :dataFileType
     2889    </sql>
     2890    <description>
     2891      A Hibernate query that gets platform file types of a specific
     2892      data file type.
     2893    </description>
     2894  </query>
     2895 
     2896  <query id="GET_FILESETMEMBER_FOR_DATAFILETYPE" type="HQL">
     2897    <sql>
     2898      SELECT mbr
     2899      FROM FileSetMemberData mbr
     2900      WHERE mbr.dataFileType.externalId = :externalId
     2901      AND mbr.fileSet = :fileSet
     2902    </sql>
     2903    <description>
     2904      A Hibernate query that loads a member in a given file set
     2905      if we know the external ID of the data file type.
     2906    </description>
     2907  </query>
     2908
     2909 
     2910  <query id="DELETE_PROPERTY_FILTER" type="SQL">
     2911    <sql>
     2912      DELETE FROM [PropertyFilters]
     2913      WHERE [property] = :property
     2914    </sql>
     2915    <description>
     2916      An SQL query that delete all PropertyFilters
     2917      which filter on a given property.
     2918    </description>
     2919  </query>
     2920 
     2921  <query id="GET_PLUGINS_WITH_KEYS" type="HQL">
     2922    <sql>
     2923      SELECT DISTINCT pk.pluginDefinitionId
     2924      FROM PluginKeys pk WHERE pk.keyId IN (:keys)
     2925    </sql>
     2926    <description>
     2927      A HQL query that has been granted a specific permission. Used by
     2928      update scripts when new item types are added to make sure existing
     2929      plug-ins can continue to work.
     2930    </description>
     2931  </query>
     2932
     2933  <query id="CHANGE_EXPERIMENT_RAWDATATYPE" type="HQL">
     2934    <sql>
     2935      UPDATE ExperimentData
     2936      SET rawDataType = :newRawDataType
     2937      WHERE rawDataType = :oldRawDataType
     2938    </sql>
     2939    <description>
     2940      A HQL query that changes all raw data type for experiments from
     2941      an old value to a new value.
     2942    </description>
     2943  </query>
     2944
    27662945
    27672946</predefined-queries>
  • trunk/src/core/net/sf/basedb/core/Affymetrix.java

    r3741 r3820  
    2626
    2727import net.sf.basedb.core.data.ReporterData;
     28import net.sf.basedb.core.filehandler.CdfFileHandler;
     29import net.sf.basedb.core.filehandler.CelFileHandler;
    2830import affymetrix.fusion.cdf.FusionCDFData;
    2931import affymetrix.fusion.cel.FusionCELData;
     
    4446    The name of the {@link AnyToAny} link between an array design
    4547    and a file that contains the CDF information.
     48    @deprecated See {@link DataFileType#AFFYMETRIX_CDF}
    4649  */
    4750  public static final String CDF_LINK_NAME = "cdf-file";
     
    5053    The name of the {@link AnyToAny} link between a raw bioassay
    5154    and a file that contains the CEL information.
     55    @deprecated See {@link DataFileType#AFFYMETRIX_CEL}
    5256  */
    5357  public static final String CEL_LINK_NAME = "cel-file";
     
    5660    The name of the {@link AnyToAny} link between a raw bioassay
    5761    and a file that contains the CHP information.
     62    @deprecated See {@link DataFileType}
    5863  */
    5964  public static final String CHP_LINK_NAME = "chp-file";
     
    7580      Affymetrix chip or if the file is not a CDF file
    7681    @throws BaseException If there is another error
     82    @deprecated Use {@link FileStoreUtil#setDataFile(DbControl, FileStoreEnabled, String, File)}
     83      instead with {@link DataFileType#AFFYMETRIX_CDF} as the file
     84      type
    7785  */
    7886  public static void setCdfFile(ArrayDesign design, File file)
     
    8088  {
    8189    if (design == null) throw new InvalidUseOfNullException("design");
    82     if (!design.isAffyChip())
     90    if (!design.isPlatform(Platform.AFFYMETRIX))
    8391    {
    8492      throw new InvalidDataException("Array design isn't an Affymetrix chip: " + design);
    8593    }
    86     design.checkPermission(Permission.WRITE);
    8794    DbControl dc = design.getDbControl();
    88     if (file != null)
    89     {
    90       file.checkPermission(Permission.USE);
    91      
    92       // Verify that the file is a CDF file
    93       FusionCDFData cdf = loadCdfFile(file);
    94    
    95       AnyToAny ata = AnyToAny.getNewOrExisting(dc, design, CDF_LINK_NAME, file, true);
    96       if (!ata.isInDatabase()) dc.saveItem(ata);
    97       design.getData().setHasFeatures(true);
    98       design.getData().setNumFeatures(cdf.getHeader().getNumProbeSets());
    99     }
    100     else
    101     {
    102       AnyToAny.unlinkFrom(dc, design, CDF_LINK_NAME);
    103       design.getData().setHasFeatures(false);
    104     }
     95    FileStoreUtil.setDataFile(dc, design, DataFileType.AFFYMETRIX_CDF, file);
     96    if (file != null) design.getFileSet().validate(dc, true);
    10597  }
    10698 
    10799  /**
    108100    Get the file that has been specified as the CDF file for an
    109     array design.
     101    array design. This method has been deprecated with the
     102    implementation of the {@link Platform} and {@link DataFileType}
     103    which solves the problem in a more generic way.
     104    <p>
     105    This method is equivalent to:
     106    <pre class="code">
     107DataFileType cdfType =
     108   DataFileType.getByExternalId(dc, DataFileType.AFFYMETRIX_CDF);
     109File cdfFile = design.getFileSet().getMember(cdfType.getFile());
     110</pre>
    110111   
    111112    @param design The design to get the CDF file from, it must
     
    117118      Affymetrix chip
    118119    @throws BaseException If there is another error
     120    @deprecated Use {@link FileStoreUtil#getDataFile(DbControl, FileStoreEnabled, String)}
     121      with a data file type of {@link DataFileType#AFFYMETRIX_CDF}
     122      instead
    119123  */
    120124  public static File getCdfFile(ArrayDesign design)
     
    122126  {
    123127    if (design == null) throw new InvalidUseOfNullException("design");
    124     if (!design.isAffyChip())
    125     {
    126       throw new InvalidDataException("Array design isn't an Affymetrix chip: " + design);
     128    if (!design.isPlatform(Platform.AFFYMETRIX))
     129    {
     130      throw new InvalidDataException("Array design isn't an Affymetrix chip: " + design.getName());
    127131    }
    128132    DbControl dc = design.getDbControl();
    129     File cdfFile = null;
    130     try
    131     {
    132       AnyToAny ata = AnyToAny.getByName(dc, design, CDF_LINK_NAME);
    133       if (ata.getToType() == Item.FILE)
    134       {
    135         cdfFile = (File)ata.getTo();
    136       }
    137     }
    138     catch (ItemNotFoundException ex)
    139     {}
    140     return cdfFile;
     133    return FileStoreUtil.getDataFile(dc, design, DataFileType.AFFYMETRIX_CDF);
    141134  }
    142135
     
    170163      raw data type
    171164    @throws BaseException If there is another error
     165    @deprecated Use {@link FileStoreUtil#setDataFile(DbControl, FileStoreEnabled, String, File)}
     166      instead with {@link DataFileType#AFFYMETRIX_CEL} as the file
     167      type
    172168  */
    173169  public static void setCelFile(RawBioAssay rawBioAssay, File file)
    174170    throws PermissionDeniedException, InvalidDataException, BaseException
    175171  {
    176     // Validate raw bioassay
    177172    if (rawBioAssay == null) throw new InvalidUseOfNullException("rawBioAssay");
    178     if (!rawBioAssay.getRawDataType().isAffymetrix())
    179     {
    180       throw new InvalidDataException("Raw data type for " + rawBioAssay.getName() +
    181         " is not an Affymetrix raw data type");
    182     }
    183173    rawBioAssay.checkPermission(Permission.WRITE);
    184  
     174
     175    if (!rawBioAssay.isPlatform(Platform.AFFYMETRIX))
     176    {
     177      throw new InvalidDataException("Raw bioassay isn't an Affymetrix chip: " + rawBioAssay.getName());
     178    }
    185179    DbControl dc = rawBioAssay.getDbControl();
    186     if (file != null)
    187     {
    188       // Validate array design
    189       ArrayDesign design = rawBioAssay.getArrayDesign();
    190       if (design == null)
    191       {
    192         throw new InvalidDataException("Raw bioassay " + rawBioAssay.getName() +
    193           " must have an array design to set CEL file");
    194       }
    195       if (!design.isAffyChip())
    196       {
    197         throw new InvalidDataException("The array design " + design.getName() +
    198           " is not an Affymterix design");
    199       }
    200  
    201       // Verify that CEL chip type match CDF type
    202       FusionCELData cel = loadCelFile(file);
    203       File cdfFile = getCdfFile(design);
    204       FusionCDFData cdf = loadCdfFile(cdfFile);
    205       validateCelAndCdf(cel, cdf, cdfFile.getName());
    206      
    207       file.checkPermission(Permission.USE);
    208       AnyToAny ata = AnyToAny.getNewOrExisting(dc, rawBioAssay, CEL_LINK_NAME, file, true);
    209       if (!ata.isInDatabase()) dc.saveItem(ata);
    210      
    211       // Set headers
    212       setHeader(rawBioAssay, "Algorithm", cel.getAlg());
    213       for (int i = 0; i < cel.getNumberAlgorithmParameters(); ++i)
    214       {
    215         String name = cel.getAlgorithmParameterTag(i);
    216         setHeader(rawBioAssay, "Algorithm parameter: " + name, cel.getAlgorithmParameter(name));
    217       }
    218       setHeader(rawBioAssay, "Dat header", cel.getDatHeader());
    219       setHeader(rawBioAssay, "Chip type", cel.getChipType());
    220      
    221       // Set number of spots
    222       rawBioAssay.getData().setHasData(true);
    223       rawBioAssay.getData().setSpots(cel.getCells());
    224      
    225     }
    226     else
    227     {
    228       AnyToAny.unlinkFrom(dc, rawBioAssay, CEL_LINK_NAME);
    229       rawBioAssay.getData().setHasData(false);
    230       rawBioAssay.getData().setSpots(0);
    231     }
    232   }
    233  
    234   private static void setHeader(RawBioAssay rba, String name, String value)
    235   {
    236     if (name == null || value == null) return;
    237     rba.setHeader(name, value);
     180    FileStoreUtil.setDataFile(dc, rawBioAssay, DataFileType.AFFYMETRIX_CEL, file);
     181    if (file != null) rawBioAssay.getFileSet().validate(dc, true);
    238182  }
    239183 
     
    250194      Affymetrix raw data type
    251195    @throws BaseException If there is another error
     196    @deprecated
    252197  */
    253198  public static File getCelFile(RawBioAssay rawBioAssay)
     
    255200  {
    256201    if (rawBioAssay == null) throw new InvalidUseOfNullException("rawBioAssay");
    257     if (!rawBioAssay.getRawDataType().isAffymetrix())
     202    if (!rawBioAssay.isPlatform(Platform.AFFYMETRIX))
    258203    {
    259204      throw new InvalidDataException("Raw data type for " + rawBioAssay.getName() +
    260       " is not an Affymetrix raw data type");
     205        " is not an Affymetrix raw data type");
    261206    }
    262207    DbControl dc = rawBioAssay.getDbControl();
    263     File celFile = null;
    264     try
    265     {
    266       AnyToAny ata = AnyToAny.getByName(dc, rawBioAssay, CEL_LINK_NAME);
    267       if (ata.getToType() == Item.FILE)
    268       {
    269         celFile = (File)ata.getTo();
    270       }
    271     }
    272     catch (ItemNotFoundException ex)
    273     {}
    274     return celFile;
     208    return FileStoreUtil.getDataFile(dc, rawBioAssay, DataFileType.AFFYMETRIX_CEL);
    275209  }
    276210 
     
    289223  public static void validateCelAndCdf(RawBioAssay rawBioAssay, ArrayDesign design, boolean required)
    290224  {
    291     File celFile = getCelFile(rawBioAssay);
    292     File cdfFile = getCdfFile(design);
     225    DbControl dc = rawBioAssay.getDbControl();
     226    File celFile = FileStoreUtil.getDataFile(dc, rawBioAssay, DataFileType.AFFYMETRIX_CEL);;
     227    File cdfFile = FileStoreUtil.getDataFile(dc, design, DataFileType.AFFYMETRIX_CDF);
    293228    if (celFile != null && cdfFile != null)
    294229    {
    295230      String cdfChipType = cdfFile.getName();
    296       FusionCELData cel = loadCelFile(celFile);
    297       FusionCDFData cdf = loadCdfFile(cdfFile);
     231      FusionCELData cel = new CelFileHandler().loadCelFile(celFile);
     232      FusionCDFData cdf = new CdfFileHandler().loadCdfFile(cdfFile);
    298233      validateCelAndCdf(cel, cdf, cdfChipType);
    299234    }
     
    338273    @throws InvalidDataException If the file is not a CDF file
    339274    @since 2.4
     275    @deprecated Use {@link CdfFileHandler#loadCdfFile(File)} instead
    340276  */
    341277  public static FusionCDFData loadCdfFile(File cdfFile)
    342278    throws ItemNotFoundException, InvalidDataException
    343279  {
    344     if (cdfFile == null) throw new InvalidUseOfNullException("cdfFile");
    345     if (cdfFile.getLocation() != Location.PRIMARY)
    346     {
    347       throw new ItemNotFoundException("File data is not online for file '" +
    348         cdfFile.getName() + "'; location=" + cdfFile.getLocation());
    349     }
    350     FusionCDFData cdf = new FusionCDFData();
    351     cdf.setFileName(cdfFile.getName());
    352     cdf.setInputStream(cdfFile.getDownloadStream(0));
    353     if (!cdf.readHeader())
    354     {
    355       throw new InvalidDataException("Could not read CDF file '" +
    356           cdfFile.getPath()+"': " + cdf.getError());
    357     }
    358     return cdf;
     280    return new CdfFileHandler().loadCdfFile(cdfFile);
    359281  }
    360282 
     
    368290    @throws InvalidDataException If the file is not a CEL file
    369291    @since 2.4
     292    @deprecated Use {@link CdfFileHandler#loadCdfFile(File)} instead
    370293  */
    371294  public static FusionCELData loadCelFile(File celFile)
    372295    throws InvalidDataException
    373296  {
    374     if (celFile == null) throw new InvalidUseOfNullException("celFile");
    375     if (celFile.getLocation() != Location.PRIMARY)
    376     {
    377       throw new ItemNotFoundException("File data is not online for file '" +
    378           celFile.getName() + "'; location=" + celFile.getLocation());
    379     }
    380     FusionCELData cel = new FusionCELData();
    381     cel.setFileName(celFile.getName());
    382     cel.setInputStream(celFile.getDownloadStream(0));
    383     if (!cel.readHeader())
    384     {
    385       throw new InvalidDataException("Could not read CEL file '" +
    386           celFile.getPath()+"': " + cel.getError());
    387     }
    388     return cel;
     297    return new CelFileHandler().loadCelFile(celFile);
    389298  }
    390299 
  • trunk/src/core/net/sf/basedb/core/Application.java

    r3765 r3820  
    468468        Keyring.init();
    469469        HibernateUtil.testTransactions();
     470        RawDataTypes.initPlatforms();
    470471 
    471472        // Adding a task that cleans the session control cache at regular intervale
  • trunk/src/core/net/sf/basedb/core/ArrayDesign.java

    r3741 r3820  
    3232import net.sf.basedb.core.query.Restrictions;
    3333
     34import java.util.Collection;
    3435import java.util.HashMap;
    3536import java.util.HashSet;
     
    5960public class ArrayDesign
    6061  extends AnnotatedItem<ArrayDesignData>
     62  implements FileStoreEnabled
    6163{
    6264 
     
    7880    @return The new <code>ArrayDesign</code> item
    7981    @throws BaseException If there is an error
     82    @deprecated Use {@link #getNew(DbControl, Platform)} instead
    8083  */
    8184  public static ArrayDesign getNew(DbControl dc, boolean affyChip)
    8285    throws BaseException
    8386  {
     87    Platform platform = Platform.getByExternalId(dc,
     88        affyChip ? Platform.AFFYMETRIX : Platform.GENERIC);
     89    return getNew(dc, platform);
     90  }
     91
     92  /**
     93    Create a new <code>ArrayDesign</code> item for a given platform.
     94 
     95    @param dc The <code>DbControl</code> which will be used for
     96      permission checking and database access
     97    @param platform The platform of the array design
     98    @return The new <code>ArrayDesign</code> item
     99    @throws BaseException If there is an error
     100    @since 2.5
     101  */
     102  public static ArrayDesign getNew(DbControl dc, Platform platform)
     103  {
    84104    ArrayDesign ad = dc.newItem(ArrayDesign.class);
    85105    ad.setName("New array design");
    86     ad.getData().setAffyChip(affyChip);
     106    ad.setPlatform(platform);
    87107    return ad;
    88108  }
    89109
     110  /**
     111    Create a new <code>ArrayDesign</code> item for a given platform
     112    variant.
     113 
     114    @param dc The <code>DbControl</code> which will be used for
     115      permission checking and database access
     116    @param variant The platform variant of the array design
     117    @return The new <code>ArrayDesign</code> item
     118    @throws BaseException If there is an error
     119    @since 2.5
     120  */
     121  public static ArrayDesign getNew(DbControl dc, PlatformVariant variant)
     122  {
     123    ArrayDesign ad = dc.newItem(ArrayDesign.class);
     124    ad.setName("New array design");
     125    ad.setVariant(variant);
     126    return ad;
     127  }
     128 
    90129  /**
    91130    Get an <code>ArrayDesign</code> item when you know the ID.
     
    154193  }
    155194  // -------------------------------------------
    156 
     195  /*
     196    From the FileStoreEnabled interface
     197    -------------------------------------------
     198  */
     199  /**
     200    @since 2.5
     201  */
     202  public FileSet getFileSet()
     203  {
     204    DbControl dc = getDbControl();
     205    FileSet fs = dc.getItem(FileSet.class, getData().getFileSet(), this);
     206    if (fs == null)
     207    {
     208      fs = FileSet.getNew(dc, this);
     209      getData().setFileSet(fs.getData());
     210      dc.saveItemIf(this, fs, false);
     211    }
     212    return fs;
     213  }
     214  /**
     215    @since 2.5
     216  */
     217  public boolean hasFileSet()
     218  {
     219    return getData().getFileSet() != null;
     220  }
     221  /**
     222    @since 2.5
     223  */
     224  public Platform getPlatform()
     225  {
     226    return getDbControl().getItem(Platform.class, getData().getPlatform());
     227  }
     228  /**
     229    @since 2.5
     230  */
     231  public PlatformVariant getVariant()
     232  {
     233    return getDbControl().getItem(PlatformVariant.class, getData().getVariant());
     234  }
     235  /**
     236    There are no parent file sets.
     237    @return Always null
     238    @since 2.5
     239  */
     240  public Collection<FileSet> getParentFileSets()
     241  {
     242    return null;
     243  }
     244  // -------------------------------------------
    157245  /*
    158246    From the BasicItem class
     
    228316 
    229317  /**
    230       @return TRUE if this is an AffyChip, FALSE otherwise.     
     318    Set the platform of the array design. This method will set the variant
     319    to null. Use {@link #setVariant(PlatformVariant)} if you want to
     320    set a specific variant.
     321    @param platform The new platform
     322    @throws PermissionDeniedException If the logged in user doesn't have
     323      write permission
     324    @throws InvalidDataException If platform is null
     325    @since 2.5
     326  */
     327  @SuppressWarnings("deprecation")
     328  public void setPlatform(Platform platform)
     329  {
     330    checkPermission(Permission.WRITE);
     331    if (platform == null) throw new InvalidUseOfNullException("platform");
     332    getData().setPlatform(platform.getData());
     333    getData().setVariant(null);
     334    getData().setAffyChip(isPlatform(Platform.AFFYMETRIX));
     335  }
     336 
     337  /**
     338    Set the platform and variant of the array design. This method will
     339    automatically set the platform to {@link PlatformVariant#getPlatform()}.
     340
     341    @param variant The new platform variant, or null to remove
     342      the variant and keep the platform as it is
     343    @throws PermissionDeniedException If the logged in user doesn't have
     344      write permission
     345    @since 2.5
     346  */
     347  @SuppressWarnings("deprecation")
     348  public void setVariant(PlatformVariant variant)
     349  {
     350    checkPermission(Permission.WRITE);
     351    if (variant != null)
     352    {
     353      getData().setVariant(variant.getData());
     354      getData().setPlatform(variant.getData().getPlatform());
     355    }
     356    else
     357    {
     358      getData().setVariant(null);
     359    }
     360    getData().setAffyChip(isPlatform(Platform.AFFYMETRIX));
     361  }
     362 
     363  /**
     364    Check if the platform/variant of this array design has the
     365    given external ID.
     366    @param externalId The external ID to match
     367    @return TRUE if either the variant of platform matches the
     368      external ID
     369    @since 2.5
     370  */
     371  public boolean isPlatform(String externalId)
     372  {
     373    if (externalId == null) return false;
     374    if (externalId.equals(getData().getPlatform().getExternalId())) return true;
     375    if (getData().getVariant() != null)
     376    {
     377      if (externalId.equals(getData().getVariant().getExternalId())) return true;
     378    }
     379    return false;
     380  }
     381 
     382  /**
     383    Check if this array design uses a file-only platform or variant.
     384    If the array design has a platform variant, the setting from the
     385    variant is returned, otherwise the setting from the platform.
     386    @return TRUE if this array design use a file-only variant / platform
     387    @since 2.5
     388  */
     389  public boolean isFileOnlyPlatform()
     390  {
     391    if (getData().getVariant() != null)
     392    {
     393      return getData().getVariant().isFileOnly();
     394    }
     395    else
     396    {
     397      return getData().getPlatform().isFileOnly();
     398    }
     399  }
     400 
     401  /**
     402      @return TRUE if this is an Affymetrix chip, FALSE otherwise.
     403      @deprecated Use {@link #isPlatform(String)} instead with
     404        {@link Platform#AFFYMETRIX} as the parameter
    231405  */
    232406  public boolean isAffyChip()
    233407  {
    234     return getData().isAffyChip();
    235   }
    236 
    237   /**
     408    return isPlatform(Platform.AFFYMETRIX);
     409  }
     410
     411  /**
     412    Check if this array design has information about features, either
     413    in the database or in files.
    238414      @return TRUE if this object has features, FALSE otherwise
    239415  */
     
    421597    that can add features to the new block.
    422598    <p>
    423     It is not possible to add blocks to an Affymetrix chip. It stores
    424     it's feature in a CDF file instead. See {@link Affymetrix#setCdfFile(ArrayDesign, File)}.
     599    It is not possible to add blocks to an array design which uses a
     600    file-only platform. The must store feature information in files
     601    instead. See {@link Platform} and {@link DataFileType}.
    425602
    426603    @param bi The information for the new block
     
    433610    throws PermissionDeniedException, BaseException
    434611  {
     612    if (getData().getPlatform().isFileOnly())
     613    {
     614      throw new PermissionDeniedException("Can't add blocks to a file-only array design: " + this.getName());
     615    }
    435616    if (hasFeatures())
    436617    {
    437       throw new PermissionDeniedException("Can't add blocks to a design that already has features: " + this);
    438     }
    439     if (isAffyChip())
    440     {
    441       throw new PermissionDeniedException("Can't add blocks to an Affymetrix chip: " + this);
     618      throw new PermissionDeniedException("Can't add blocks to a design that already has features: " + this.getName());
    442619    }
    443620    checkPermission(Permission.WRITE);
     
    461638    array design.   
    462639    <p>
    463     It is not possible to add features to an Affymetrix chip. It stores
    464     it's feature in a CDF file instead. See {@link Affymetrix#setCdfFile(ArrayDesign, File)}.
     640    It is not possible to add blocks to an array design which uses a
     641    file-only platform. The must store feature information in files
     642    instead. See {@link Platform} and {@link DataFileType}.
    465643
    466644    @throws PermissionDeniedException If raw data has already been added
     
    472650  {
    473651    checkPermission(Permission.WRITE);
     652    if (isFileOnlyPlatform())
     653    {
     654      throw new PermissionDeniedException("Can't add features to a file-only array design: " + this.getName());
     655    }
    474656    if (hasFeatures())
    475657    {
    476       throw new PermissionDeniedException("Features has already been added to "+this);
    477     }
    478     if (isAffyChip())
    479     {
    480       throw new PermissionDeniedException("Can't add features to an Affymetrix chip: " + this);
     658      throw new PermissionDeniedException("Features has already been added to "+this.getName());
    481659    }
    482660    if (featureBatcher == null)
     
    528706  /**
    529707    Get the number of features added to this array design. If the
    530     array design is an Affymetrix design information in the CDF file is
    531     used, otherwise the database is queried.
     708    array design has features in the database the value from {@link #getNumDbFeatures()}
     709    is returned, otherwise the value from {@link #getNumFileFeatures()}
    532710    @return The number of features or probesets
    533711    @since 2.4
    534     @deprecated Use {@link #getNumFeatures()} instead
     712    @deprecated Use {@link #getNumDbFeatures()} and/or {@link #getNumFileFeatures()}
     713      instead
    535714  */
    536715  public long getNumFeatures(DbControl dc)
    537716  {
    538     return getNumFeatures();
    539   }
    540  
    541   /**
    542     Get the number of features on this array design. Depending on the
    543     type of array design, this may or may not correspond to the number
    544     of features in the database.
     717    int dbFeatures = getNumDbFeatures();
     718    return dbFeatures > 0 ? dbFeatures : getNumFileFeatures();
     719  }
     720 
     721  /**
     722    Get the number of features on this array design that are
     723    stored in the database.
    545724    @return The number of features or probesets
    546725    @since 2.5
    547726  */
    548   public int getNumFeatures()
    549   {
    550     return getData().getNumFeatures();
     727  public int getNumDbFeatures()
     728  {
     729    return getData().getNumDbFeatures();
     730  }
     731
     732  /**
     733    Get the number of features on this array design that are
     734    stored inside files.
     735    @return The number of features or probesets
     736    @since 2.5
     737  */
     738  public int getNumFileFeatures()
     739  {
     740    return getData().getNumFileFeatures();
     741  }
     742 
     743  /**
     744    Set the number of features that are stored in files.
     745    @param numFeatures The number of features
     746    @since 2.5
     747  */
     748  public void setNumFileFeatures(int numFeatures)
     749  {
     750    checkPermission(Permission.WRITE);
     751    getData().setNumFileFeatures(numFeatures);
     752    getData().setHasFeatures(numFeatures > 0 || getNumDbFeatures() > 0);
    551753  }
    552754 
  • trunk/src/core/net/sf/basedb/core/Experiment.java

    r3679 r3820  
    545545      for the raw bioassay
    546546    @throws InvalidDataException If the rawBioAssay is null,
    547       doesn't have and data, or has a different raw data type
     547      or has a different raw data type
    548548  */
    549549  public void addRawBioAssay(RawBioAssay rawBioAssay)
     
    553553    if (rawBioAssay == null) throw new InvalidUseOfNullException("rawBioAssay");
    554554    rawBioAssay.checkPermission(Permission.USE);
    555     if (!rawBioAssay.hasData())
    556     {
    557       throw new InvalidDataException("No raw data has been added to the raw bioassay: "+rawBioAssay);
    558     }
    559555    String experimentDataType = getData().getRawDataType();
    560556    String bioAssayDataType = rawBioAssay.getData().getRawDataType();
  • trunk/src/core/net/sf/basedb/core/FeatureBatcher.java

    r3775 r3820  
    7777 
    7878  /**
    79     If the array design is an affy chip which needs AffyFeatureData
    80     objects instead of FeatureData.
    81   */
    82   private final boolean isAffy;
    83 
    84  
    85   /**
    8679    Keeps track of the position number.
    8780  */
     
    9487    this.arrayDesign = arrayDesign;
    9588    this.arrayDesignData = arrayDesign.getData();
    96     this.isAffy = arrayDesign.isAffyChip();
    9789    setDbControl(dc);
    9890  }
     
    209201    throws BaseException
    210202  {
    211     if (getTotalInsertCount() > 0)
     203    int insertCount = getTotalInsertCount();
     204    if (insertCount > 0)
    212205    {
    213206      arrayDesignData.setHasFeatures(true);
     207      arrayDesignData.setNumDbFeatures(insertCount);
    214208    }
    215209  }
  • trunk/src/core/net/sf/basedb/core/Install.java

    r3784 r3820  
    2828import net.sf.basedb.core.data.ColoringData;
    2929import net.sf.basedb.core.data.DirectoryData;
     30import net.sf.basedb.core.data.DataFileTypeData;
    3031import net.sf.basedb.core.data.FileTypeData;
    3132import net.sf.basedb.core.data.FormulaData;
     
    3334import net.sf.basedb.core.data.HardwareTypeData;
    3435import net.sf.basedb.core.data.MimeTypeData;
     36import net.sf.basedb.core.data.PlatformData;
     37import net.sf.basedb.core.data.PlatformFileTypeData;
    3538import net.sf.basedb.core.data.PluginConfigurationData;
    3639import net.sf.basedb.core.data.ProtocolTypeData;
     
    104107    method.
    105108  */
    106   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(43).intValue();
     109  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(44).intValue();
    107110 
    108111  public static synchronized void createTables(boolean update, final ProgressReporter progress)
     
    162165    throws BaseException
    163166  {
    164     final int total_progress_steps = 24;
     167    final int total_progress_steps = 26;
    165168    final float progress_factor = 100 / total_progress_steps;
    166169    if (progress != null) progress.display(0, "Initialising database...");
     
    323326      createRoleKey(Item.SOFTWARETYPE, "Software types", "Gives access to software types", all_use_administrators_write);
    324327      createRoleKey(Item.SOFTWARE, "Software", "Gives access to software", power_users_create);
    325  
     328     
     329      // Platforms, platform variants, platform file types
     330      createRoleKey(Item.PLATFORM, "Platforms", "Gives access to platforms", guests_use_administrators_all);
     331      createRoleKey(Item.DATAFILETYPE, "Data file types", "Gives access to data file types", guests_use_administrators_all);
     332
    326333      // Annotations
    327334      createRoleKey(Item.ANNOTATIONTYPE, "Annotation types", "Gives access to annotation types", power_users_create);
     
    667674      if (progress != null) progress.display((int)(24*progress_factor), "--Creating job agents...");
    668675      // TODO
     676     
     677      // File set member types
     678      if (progress != null) progress.display((int)(25*progress_factor), "--Creating data file types...");
     679      DataFileTypeData celFile = createDataFileType(
     680        DataFileType.AFFYMETRIX_CEL, "CEL file", "Affymetrix CEL file",
     681        Item.RAWBIOASSAY, "cel", rawDataType, 
     682        "net.sf.basedb.core.filehandler.CelFileHandler",
     683        "net.sf.basedb.core.filehandler.CelFileHandler");
     684      DataFileTypeData cdfFile = createDataFileType(
     685        DataFileType.AFFYMETRIX_CDF, "CDF file", "Affymetrix CDF file",
     686        Item.ARRAYDESIGN, "cdf", reporterMapType, 
     687        "net.sf.basedb.core.filehandler.CdfFileHandler",
     688        "net.sf.basedb.core.filehandler.CdfFileHandler");
     689      DataFileTypeData reporterMapFile = createDataFileType(
     690        DataFileType.GENERIC_REPORTER_MAP, "Reporter map",
     691        "Generic file that contains information about the reporters present on an array design",
     692        Item.ARRAYDESIGN, null, reporterMapType, null, null);
     693      DataFileTypeData printMapFile = createDataFileType(
     694        DataFileType.GENERIC_PRINT_MAP, "Print map",
     695        "Generic file that contains information about how the plates was printed on the array design",
     696        Item.ARRAYDESIGN, null, printMapType, null, null);
     697      DataFileTypeData rawDataFile = createDataFileType(
     698        DataFileType.GENERIC_RAW_DATA, "Generic raw data",
     699        "Generic file that contains the raw data of this raw bioassay",
     700        Item.RAWBIOASSAY, null, rawDataType, null, null);
     701     
     702      // Platforms and variants
     703      if (progress != null) progress.display((int)(26*progress_factor), "--Creating platforms...");
     704      createPlatform("generic", "Generic", "Generic platform which expects data to be imported into the database",
     705        false, null, 0,
     706        new PlatformFT(reporterMapFile, false),
     707        new PlatformFT(printMapFile, false),
     708        new PlatformFT(rawDataFile, false)
     709      );
     710      createPlatform("affymetrix", "Affymetrix", "Affymetrix platform", true, null, 1,
     711        new PlatformFT(celFile, true),
     712        new PlatformFT(cdfFile, true)
     713      );
    669714     
    670715      if (progress != null) progress.display(100, "Database initialised successfully.");
     
    21562201    }
    21572202    return formula;
     2203  }
     2204 
     2205  /**
     2206    Create a {@link Platform}.
     2207  */
     2208  private static PlatformData createPlatform(String externalId, String name, String description,
     2209    boolean fileOnly, String rawDataType, int channels, PlatformFT... fileTypes)
     2210    throws BaseException
     2211  {
     2212    org.hibernate.Transaction tx = null;
     2213    PlatformData platform = null;
     2214    try
     2215    {
     2216      tx = HibernateUtil.newTransaction(session);
     2217   
     2218      if (platform == null)
     2219      {
     2220        org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     2221          "GET_PLATFORM_FOR_EXTERNAL_ID");
     2222        query.setString("externalId", externalId);
     2223        platform = HibernateUtil.loadData(PlatformData.class, query);
     2224      }
     2225     
     2226      if (platform != null)
     2227      {
     2228        log.info("createPlatform: EXISTS [externalId="+externalId+"]");
     2229        HibernateUtil.commit(tx);
     2230      }
     2231      else
     2232      {
     2233        platform = new PlatformData();
     2234        platform.setExternalId(externalId);
     2235        platform.setName(name);
     2236        platform.setDescription(description);
     2237        platform.setFileOnly(fileOnly);
     2238        if (fileOnly)
     2239        {
     2240          platform.setChannels(channels);
     2241          platform.setRawDataType("platform." + externalId);
     2242        }
     2243        else
     2244        {
     2245          platform.setRawDataType(rawDataType);
     2246        }
     2247        HibernateUtil.saveData(session, platform);
     2248 
     2249        if (fileTypes != null)
     2250        {
     2251          for (PlatformFT pft : fileTypes)
     2252          {
     2253            PlatformFileTypeData platformFile = new PlatformFileTypeData();
     2254            platformFile.setPlatform(platform);
     2255            platformFile.setDataFileType(pft.fileType);
     2256            platformFile.setRequired(pft.required);
     2257            HibernateUtil.saveData(session, platformFile);
     2258          }
     2259        }
     2260       
     2261        HibernateUtil.commit(tx);
     2262        log.info("createPlatform: OK [externalId="+externalId+"]");
     2263      }
     2264    }
     2265    catch (BaseException ex)
     2266    {
     2267      if(tx != null) HibernateUtil.rollback(tx);
     2268      log.error("createPlatform: FAILED [externalId="+externalId+"]", ex);
     2269      throw ex;
     2270    }
     2271    return platform;
     2272  }
     2273
     2274  /**
     2275    Create a {@link DataFileType}.
     2276  */
     2277  private static DataFileTypeData createDataFileType(
     2278    String externalId, String name, String description,
     2279    Item itemType, String extension, FileTypeData genericType,
     2280    String validatorClass, String metadataReaderClass)
     2281    throws BaseException
     2282  {
     2283    org.hibernate.Transaction tx = null;
     2284    DataFileTypeData fileType = null;
     2285    try
     2286    {
     2287      tx = HibernateUtil.newTransaction(session);
     2288   
     2289      if (fileType == null)
     2290      {
     2291        org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     2292          "GET_DATAFILETYPE_FOR_EXTERNAL_ID");
     2293        query.setString("externalId", externalId);
     2294        fileType = HibernateUtil.loadData(DataFileTypeData.class, query);
     2295      }
     2296     
     2297      if (fileType != null)
     2298      {
     2299        log.info("createDataFileType: EXISTS [externalId="+externalId+"]");
     2300        HibernateUtil.commit(tx);
     2301      }
     2302      else
     2303      {
     2304        fileType = new DataFileTypeData();
     2305        fileType.setExternalId(externalId);
     2306        fileType.setName(name);
     2307        fileType.setDescription(description);
     2308        fileType.setItemType(itemType.getValue());
     2309        fileType.setExtension(extension);
     2310        fileType.setGenericType(genericType);
     2311        fileType.setValidatorClass(validatorClass);
     2312        fileType.setMetadataReaderClass(metadataReaderClass);
     2313 
     2314        HibernateUtil.saveData(session, fileType);
     2315        HibernateUtil.commit(tx);
     2316        log.info("createDataFileType: OK [externalId="+externalId+"]");
     2317      }
     2318    }
     2319    catch (BaseException ex)
     2320    {
     2321      if(tx != null) HibernateUtil.rollback(tx);
     2322      log.error("createDataFileType: FAILED [externalId="+externalId+"]", ex);
     2323      throw ex;
     2324    }
     2325    return fileType;
    21582326  }
     2327 
     2328  private static class PlatformFT
     2329  {
     2330    private final DataFileTypeData fileType;
     2331    private final boolean required;
     2332   
     2333    private PlatformFT(DataFileTypeData fileType, boolean required)
     2334    {
     2335      this.fileType = fileType;
     2336      this.required = required;
     2337    }
     2338  }
     2339 
    21592340}
  • trunk/src/core/net/sf/basedb/core/Item.java

    r3679 r3820  
    496496  */
    497497  DATACUBEEXTRAVALUE(326, "Data cube extra value", "dev", DataCubeExtraValue.class, DataCubeExtraValueData.class, null,
    498     250);
     498    250),
     499   
     500  /**
     501    The item is a {@link Platform}
     502  */
     503  PLATFORM(350, "Platform", "plf", Platform.class, PlatformData.class, DefinedPermissions.basic,
     504    970),
     505   
     506  /**
     507    The item is a {@link PlatformVariant}
     508  */
     509  PLATFORMVARIANT(351, "Platform variant", "plv", PlatformVariant.class, PlatformVariantData.class, null,
     510    965),
     511   
     512  /**
     513    The item is a {@link PlatformFileType}
     514  */
     515  PLATFORMFILETYPE(352, "Platform file type", "pft", PlatformFileType.class, PlatformFileTypeData.class, null,
     516    960),
     517   
     518  /**
     519    The item is a {@link FileSet}
     520  */
     521  FILESET(353, "File set", "fs", FileSet.class, FileSetData.class, null,
     522    950),
     523
     524  /**
     525    The item is a {@link FileSetMember}
     526  */
     527  FILESETMEMBER(354, "File set member", "fsm", FileSetMember.class, FileSetMemberData.class, null,
     528    955),
     529   
     530  /**
     531    The item is a {@link DataFileType}
     532  */
     533  DATAFILETYPE(355, "Data file type", "dft", DataFileType.class, DataFileTypeData.class, DefinedPermissions.basic,
     534    980)
     535   
     536    ;
    499537
    500538  static int MAX_VALUE = 0;
  • trunk/src/core/net/sf/basedb/core/ItemContext.java

    r3789 r3820  
    614614 
    615615  /**
     616    Add an item to the "recently used items" list. Each type of item
     617    has their own list and sublists which may contain at
     618    most <code>maxInList</code> items.
     619    <p>
     620    Note! The lists are stored as string of colon-separated ID:s in
     621    the setting given by the item type and sublist name. For example the
     622    recently used protocols are found in the setting:
     623    <code>getSetting("PROTOCOL.subList.recent")</code>. Client code is advised to
     624    not change these settings.
     625
     626    @param item The item to add
     627    @param subList The sublist
     628    @param maxInList The maximum number of items in the list
     629    @since 2.5
     630  */
     631  public void setRecent(BasicItem item, String subList, int maxInList)
     632  {
     633    setRecent(item.getType().name() + "." + subList, Integer.toString(item.getId()), maxInList);
     634  }
     635 
     636  /**
    616637    Add a value to the list of recently used values for the specified key.
    617638    Each key has it's own list of values which may contain at most
     
    649670 
    650671  /**
     672    Get the number of recently used items in a list with a sublist.
     673    @param itemType The type of items
     674    @param subList The name of the sublist
     675    @since 2.5
     676  */
     677  public int getNumRecent(Item itemType, String subList)
     678  {
     679    return getRecent(itemType.name() + "." + subList).size();
     680  }
     681 
     682  /**
    651683    Get the number of recently used value in the list.
    652684    @param key The key to the list
     
    670702  public List<? extends BasicItem> getRecent(DbControl dc, Item itemType)
    671703  {
    672     List<String> recentIds = getRecent(itemType.name());
     704    return loadRecent(dc, itemType, itemType.name());
     705  }
     706 
     707  /**
     708    Get all recently used items of the specified type in a given sublist.
     709    The list only contains items that the logged in user has read permission
     710    to and that hasn't been deleted. Thus, the {@link #getNumRecent(Item)}
     711    may return a larger number than what is actually returned in this
     712    list.
     713   
     714    @param dc The DbControl used to access the database
     715    @param itemType The type of items
     716    @param subList The name of the sublist
     717    @return A list with the items
     718    @since 2.5
     719  */
     720  public List<? extends BasicItem> getRecent(DbControl dc, Item itemType, String subList)
     721  {
     722    return loadRecent(dc, itemType, itemType.name() + "." + subList);
     723  }
     724 
     725  private List<? extends BasicItem> loadRecent(DbControl dc, Item itemType, String key)
     726  {
     727    List<String> recentIds = getRecent(key);
    673728    List<BasicItem> recent = new ArrayList<BasicItem>(recentIds.size());
    674729    for (String id : recentIds)
     
    687742  }
    688743 
     744 
    689745  public BasicItem getRecent(DbControl dc, Item itemType, int index)
    690746  {
    691     List<String> recentIds = getRecent(itemType.name());
     747    return loadRecent(dc, itemType, itemType.name(), index);
     748  }
     749 
     750  public BasicItem getRecent(DbControl dc, Item itemType, String subList, int index)
     751  {
     752    return loadRecent(dc, itemType, itemType.name() + "." + subList, index);
     753  }
     754 
     755  private BasicItem loadRecent(DbControl dc, Item itemType, String key, int index)
     756  {
     757    List<String> recentIds = getRecent(key);
    692758    BasicItem item = null;
    693759    if (index >= 0 && index < recentIds.size())
     
    707773    return item;
    708774  }
     775
    709776 
    710777  /**
     
    742809  {
    743810    setRecent(itemType.name(), null);
     811  }
     812 
     813  /**
     814    Clear the recently used items sublist from items of the specified type.
     815    @param itemType The type of items
     816    @param subList The name of the sublist
     817  */
     818  public void clearRecent(Item itemType, String subList)
     819  {
     820    setRecent(itemType.name() + "." + subList, null);
    744821  }
    745822 
  • trunk/src/core/net/sf/basedb/core/Metadata.java

    r3679 r3820  
    5454  private static Set<Item> ownableItems;
    5555  private static Set<Item> diskConsumableItems;
     56  private static Set<Item> fileStoreEnabledItems;
    5657
    5758  private static boolean isInitialised = false;
     
    6566    ownableItems = Collections.unmodifiableSet(getImplementingItems(Ownable.class));
    6667    diskConsumableItems = Collections.unmodifiableSet(getImplementingItems(DiskConsumable.class));
     68    fileStoreEnabledItems = Collections.unmodifiableSet(getImplementingItems(FileStoreEnabled.class));
    6769    isInitialised = true;
    6870  }
     
    7981    ownableItems = null;
    8082    diskConsumableItems = null;
     83    fileStoreEnabledItems = null;
    8184  }
    8285
     
    171174  }
    172175
     176  /**
     177    Get a set containing all {@link FileStoreEnabled} item types.
     178    The set cannot be modified.
     179  */
     180  public static Set<Item> getFileStoreEnabledItems()
     181  {
     182    return fileStoreEnabledItems;
     183  }
     184 
     185 
    173186  /**
    174187    Cache of Metadata instances. Only one instance for each type
  • trunk/src/core/net/sf/basedb/core/PluginDefinition.java

    r3679 r3820  
    976976        if (unloadBefore) JarClassLoader.unload(jarPath);
    977977        ClassLoader cl = JarClassLoader.getInstance(jarPath, Application.autoUnloadPlugins());
    978         c = cl.loadClass(className);
    979       }
    980       if (!Plugin.class.isAssignableFrom(c))
    981       {
    982         throw new InvalidDataException("Class does not implement net.sf.basedb.core.plugin.Plugin: "+className);
     978        c = ClassUtil.checkAndLoadClass(cl, className, true, Plugin.class);
    983979      }
    984980      return (Plugin)c.newInstance();
  • trunk/src/core/net/sf/basedb/core/RawBioAssay.java

    r3775 r3820  
    2727
    2828import net.sf.basedb.core.data.FeatureData;
     29import net.sf.basedb.core.data.PlatformData;
     30import net.sf.basedb.core.data.PlatformVariantData;
    2931import net.sf.basedb.core.data.RawBioAssayData;
    3032import net.sf.basedb.core.data.RawData;
     
    3739import net.sf.basedb.core.query.Expressions;
    3840
     41import java.util.Collection;
    3942import java.util.HashMap;
    4043import java.util.Map;
     
    6265public class RawBioAssay
    6366  extends AnnotatedItem<RawBioAssayData>
    64   implements DiskConsumable
     67  implements DiskConsumable, FileStoreEnabled
    6568{
    6669  /**
     
    8891
    8992  /**
    90     Create a new <code>RawBioAssay</code> item.
     93    Create a new <code>RawBioAssay</code> item. The platform/variant will
     94    automatically be set to the values returned by {@link RawDataType#getPlatform(DbControl)}
     95    and {@link RawDataType#getVariant(DbControl)}. If both return null
     96    the {@link Platform#GENERIC} is used.
    9197
    9298    @param dc The <code>DbControl</code> which will be used for
     
    95101    @return The new <code>RawBioAssay</code> item
    96102    @throws BaseException If there is an error
     103    @deprecated Use {@link #getNew(DbControl, Platform, RawDataType)} or
     104      {@link #getNew(DbControl, PlatformVariant, RawDataType)} instead.
     105      This method will set the platform to {@link Platform#GENERIC}.
    97106  */
    98107  public static RawBioAssay getNew(DbControl dc, RawDataType rawDataType)
    99108    throws BaseException
    100109  {
     110    Platform platform = rawDataType.getPlatform(dc);
     111    PlatformVariant variant = rawDataType.getVariant(dc);
     112    RawBioAssay rba = null;
     113    if (variant != null)
     114    {
     115      rba = getNew(dc, variant, rawDataType);
     116    }
     117    else
     118    {
     119      if (platform == null) platform = Platform.getByExternalId(dc, Platform.GENERIC);
     120      rba = getNew(dc, platform, rawDataType);
     121    }
     122    return rba;
     123  }
     124 
     125  /**
     126    Create a new raw bioassay for a specific platform and/or raw data type.
     127    If the platform is locked to a specific raw data type, the <code>rawDataType</code>
     128    parameter is ignored. If the platform isn't locked the raw data type
     129    is required and must be a database-based raw data type. Ie.
     130    {@link RawDataType#isStoredInDb()} must return true.
     131   
     132    @param dc The <code>DbControl</code> which will be used for
     133      permission checking and database access
     134    @param platform The platform of the new raw bioassay, null is not allowed
     135    @param rawDataType The raw data type of the raw bioassay (required if
     136      the platform isn't locked to a specific raw data type)
     137    @return The new <code>RawBioAssay</code> item
     138    @since 2.5
     139  */
     140  public static RawBioAssay getNew(DbControl dc, Platform platform, RawDataType rawDataType)
     141  {
    101142    RawBioAssay rba = dc.newItem(RawBioAssay.class);
    102     rba.setRawDataType(rawDataType);
     143    rba.setPlatform(platform, rawDataType);
    103144    rba.setName("New raw bioassay");
    104145    return rba;
     146  }
     147 
     148  /**
     149    Create a new raw bioassay for a specific platform variant.
     150    If the variant is locked to a specific raw data type, the <code>rawDataType</code>
     151    parameter is ignored. If the variant isn't locked the raw data type
     152    is required and must be a database-based raw data type. Ie.
     153    {@link RawDataType#isStoredInDb()} must return true.
     154
     155   
     156    @param dc The <code>DbControl</code> which will be used for
     157      permission checking and database access
     158    @param variant The platform variant of the new raw bioassay, null is not allowed
     159    @param rawDataType The raw data type of the raw bioassay (required if
     160      the platform isn't locked to a specific raw data type)
     161    @return The new <code>RawBioAssay</code> item
     162    @since 2.5
     163  */
     164  public static RawBioAssay getNew(DbControl dc, PlatformVariant variant, RawDataType rawDataType)
     165  {
     166    RawBioAssay rba = dc.newItem(RawBioAssay.class);
     167    rba.setVariant(variant, rawDataType);
     168    rba.setName("New raw bioassay");
     169    return rba;
    105170  }
    106171
     
    204269  }
    205270  // -------------------------------------------
     271  /*
     272    From the FileStoreEnabled interface
     273    -------------------------------------------
     274  */
     275  /**
     276    @since 2.5
     277  */
     278  public FileSet getFileSet()
     279  {
     280    DbControl dc = getDbControl();
     281    FileSet fs = dc.getItem(FileSet.class, getData().getFileSet(), this);
     282    if (fs == null)
     283    {
     284      fs = FileSet.getNew(dc, this);
     285      getData().setFileSet(fs.getData());
     286      dc.saveItemIf(this, fs, false);
     287    }
     288    return fs;
     289  }
     290  /**
     291    @since 2.5
     292  */
     293  public boolean hasFileSet()
     294  {
     295    return getData().getFileSet() != null;
     296  }
     297  /**
     298    @since 2.5
     299  */
     300  public Platform getPlatform()
     301  {
     302    return getDbControl().getItem(Platform.class, getData().getPlatform());
     303  }
     304  /**
     305    @since 2.5
     306  */
     307  public PlatformVariant getVariant()
     308  {
     309    return getDbControl().getItem(PlatformVariant.class, getData().getVariant());
     310  }
     311  /**
     312    Get the file set from the array design, if it exists.
     313    @since 2.5
     314  */
     315  public Collection<FileSet> getParentFileSets()
     316  {
     317    Collection<FileSet> parents = null;
     318    ArrayDesign design = getArrayDesign();
     319    if (design != null && design.hasFileSet())
     320    {
     321      parents = Collections.singleton(design.getFileSet());
     322    }
     323    return parents;
     324  }
     325  // -------------------------------------------
    206326
    207327  /*
     
    213333    <ul>
    214334    <li>An {@link Experiment} is using this raw bioassay
    215     <li>A {@link Transformation} is using this raw bioassay
     335    <li>A {@link Transformation} is using this raw bio raw data type will also be updated. The platform can't be changed
     336    if raw data has been imported to the database.assay
    216337    </ul>
    217338  */
     
    303424
    304425  /**
     426    Set the platform and raw data type of the raw bioassay. This method will
     427    set the variant to null. Use {@link #setVariant(PlatformVariant, RawDataType)} if you
     428    want to set a specific variant. If the platform is locked to a raw data type,
     429    the <code>rawDataType</code> parameter is ignored. If the platform isn't
     430    locked the raw data type must be a database-based raw data type. Ie.
     431    {@link RawDataType#isStoredInDb()} must return true.
     432
     433    @param platform The new platform, null is not allowes
     434    @param rawDataType The raw data type, required if the platform
     435      doesn't specify a raw data type
     436    @throws PermissionDeniedException If the logged in user doesn't have
     437      write permission
     438    @throws InvalidDataException If platform is null or if the raw data
     439      type is not properly specified
     440    @since 2.5
     441  */
     442  public void setPlatform(Platform platform, RawDataType rawDataType)
     443  {
     444    checkPermission(Permission.WRITE);
     445    if (platform == null) throw new InvalidUseOfNullException("platform");
     446    if (getData().getSpots() > 0)
     447    {
     448      throw new PermissionDeniedException("Not allowed to change the platform after raw data has been added");
     449    }
     450    RawDataType rdt = platform.getRawDataType();
     451    if (rdt == null)
     452    {
     453      if (rawDataType == null)
     454      {
     455        throw new InvalidUseOfNullException("rawDataType must be specified for platform: " +
     456          platform.getName());
     457      }
     458      if (!rawDataType.isStoredInDb())
     459      {
     460        throw new InvalidDataException("rawDataType can't store data in the database: " +
     461          rawDataType.getName());
     462      }
     463      rdt = rawDataType;
     464    }
     465    getData().setPlatform(platform.getData());
     466    getData().setVariant(null);
     467    getData().setRawDataType(rdt.getId());
     468  }
     469 
     470  /**
     471    Set the platform and variant of the raw bioassay. This method will
     472    automatically set the platform to {@link PlatformVariant#getPlatform()}.
     473    If the platform variant is locked to a raw data type, the raw data
     474    type is also updated. The platform variant can't be changed
     475    if raw data has been imported to the database.
     476 
     477    @param variant The new platform variant
     478    @throws PermissionDeniedException If the logged in user doesn't have
     479      write permission
     480    @throws InvalidDataException If variant is null
     481    @since 2.5
     482  */
     483  public void setVariant(PlatformVariant variant, RawDataType rawDataType)
     484  {
     485    checkPermission(Permission.WRITE);
     486    if (variant == null) throw new InvalidUseOfNullException("variant");
     487    if (getData().getSpots() > 0)
     488    {
     489      throw new PermissionDeniedException("Not allowed to change the platform after raw data has been added");
     490    }
     491    RawDataType rdt = variant.getRawDataType();
     492    if (rdt == null)
     493    {
     494      if (rawDataType == null)
     495      {
     496        throw new InvalidUseOfNullException("rawDataType must be specified for platform variant: " +
     497          variant.getName());
     498      }
     499      if (!rawDataType.isStoredInDb())
     500      {
     501        throw new InvalidDataException("rawDataType can't store data in the database: " +
     502          rawDataType.getName());
     503      }
     504      rdt = rawDataType;
     505    }
     506    getData().setVariant(variant.getData());
     507    getData().setPlatform(variant.getData().getPlatform());
     508    getData().setRawDataType(rdt.getId());
     509  }
     510 
     511  /**
     512    Check if the platform/variant of this raw bioassay has the
     513    given external ID.
     514    @param externalId The external ID to match
     515    @return TRUE if either the variant of platform matches the
     516      external ID
     517    @since 2.5
     518  */
     519  public boolean isPlatform(String externalId)
     520  {
     521    if (externalId == null) return false;
     522    if (externalId.equals(getData().getPlatform().getExternalId())) return true;
     523    if (getData().getVariant() != null)
     524    {
     525      if (externalId.equals(getData().getVariant().getExternalId())) return true;
     526    }
     527    return false;
     528  }
     529
     530  /**
     531    Check if this raw bioassay uses a file-only platform or variant.
     532    If the raw bioassay has a platform variant, the setting from the
     533    variant is returned, otherwise the setting from the platform.
     534    @return TRUE if this raw bioassay use a file-only variant / platform
     535    @since 2.5
     536  */
     537  public boolean isFileOnlyPlatform()
     538  {
     539    if (getData().getVariant() != null)
     540    {
     541      return getData().getVariant().isFileOnly();
     542    }
     543    else
     544    {
     545      return getData().getPlatform().isFileOnly();
     546    }
     547  }
     548 
     549  /**
    305550    Get the raw data type this raw bioassay uses for the raw data.
    306551    The raw data type cannot be changed once the raw bioassay has been created.
     
    314559  /**
    315560    Set the raw data type. The raw data type cannot be changed if raw
    316     data has been added.
     561    data has been added to the database.
     562   
    317563    @param rawDataType The raw data type, null is not allowed
    318564    @throws PermissionDeniedException If the logged in user doesn't have
    319565      write permission for the raw bioassay or spots has already been added
     566    @deprecated Use {@link #setPlatform(Platform, RawDataType)} or
     567      {@link #setVariant(PlatformVariant, RawDataType)} instead
    320568  */
    321569  public void setRawDataType(RawDataType rawDataType)
     
    328576      throw new PermissionDeniedException("Not allowed to change the raw data type after raw data has been added");
    329577    }
     578   
     579    PlatformData platform = rawDataType.getPlatformProxy();
     580    PlatformVariantData variant = rawDataType.getVariantProxy();
     581   
     582    getData().setPlatform(platform);
     583    getData().setVariant(variant);
    330584    getData().setRawDataType(rawDataType.getId());
    331585  }
     
    454708    checkPermission(Permission.WRITE);
    455709    if (arrayDesign != null) arrayDesign.checkPermission(Permission.USE);
    456     if (getData().getSpots() > 0)
     710    if (getData().getHasData())
    457711    {
    458712      throw new PermissionDeniedException("Not allowed to change the array design after raw data has been added");
     
    481735    checkPermission(Permission.WRITE);
    482736    if (arrayDesign != null) arrayDesign.checkPermission(Permission.USE);
     737   
     738    // No need to validate if there is no change
     739    if (arrayDesign == null && getData().getArrayDesign() == null) return;
     740    if (arrayDesign != null && arrayDesign.getData().equals(getData().getArrayDesign())) return;
     741   
     742    // Re-validate data in database if we already have db data
    483743    if (getData().getSpots() > 0 && arrayDesign != null)
    484744    {
    485       // No need to validate if there is no change
    486       if (arrayDesign.getData().equals(getData().getArrayDesign())) return;
    487  
    488       if (getRawDataType().isAffymetrix())
    489       {
    490         // Verify CEL and CDF files
    491         Affymetrix.validateCelAndCdf(this, arrayDesign, false);
    492       }
    493       else if (getRawDataType().isStoredInDb())
    494       {
    495         validateFeatures(getDbControl(), arrayDesign, true, progress);
    496       }
     745      validateFeatures(getDbControl(), arrayDesign, true, progress);
    497746    }
    498747    getData().setArrayDesign(arrayDesign == null ? null : arrayDesign.getData());
     748
     749    // Re-validate files
     750    if (hasFileSet()) getFileSet().validate(getDbControl(), true);
    499751  }
    500752
     
    512764    raw bioassay.
    513765    @return The number of spots
     766    @deprecated Use {@link #getNumDbSpots()} or {@link #getNumFileSpots()}
     767      instead. This method first checks the database and if not 0, it
     768      returns that value, otherwise it returns the number of file spots
    514769  */
    515770  public int getSpots()
    516771  {
     772    int dbSpots = getNumDbSpots();
     773    return dbSpots > 0 ? dbSpots : getNumFileSpots();
     774  }
     775 
     776  /**
     777    Get the number of spots on this raw bioassay that are
     778    stored in the database.
     779    @return The number of spots in the database
     780    @since 2.5
     781  */
     782  public int getNumDbSpots()
     783  {
    517784    return getData().getSpots();
    518785  }
    519786 
    520787  /**
     788    Get the number of spots on this raw bioassay that are
     789    stored inside files.
     790    @return The number of spots in files
     791    @since 2.5
     792  */
     793  public int getNumFileSpots()
     794  {
     795    return getData().getNumFileSpots();
     796  }
     797 
     798  /**
     799    Set the number of spots that are stored in files.
     800    @param numSpots The number of spots
     801    @since 2.5
     802  */
     803  public void setNumFileSpots(int numSpots)
     804  {
     805    checkPermission(Permission.WRITE);
     806    getData().setNumFileSpots(numSpots);
     807    getData().setHasData(numSpots > 0 || getNumDbSpots() > 0);
     808  }
     809 
     810 
     811  /**
    521812    If raw data has been added to this raw bioassay or not. Note that this method
    522     can return true even if the {@link #getSpots()} returns 0 if the raw data
    523     type uses files to store it's data.
     813    checks both data in the database and data in the form of files.
    524814  */
    525815  public boolean hasData()
     
    587877  {
    588878    checkPermission(Permission.WRITE);
    589     if (getData().getSpots() > 0)
    590     {
    591       throw new PermissionDeniedException("Not allowed to change the headers after raw data has been added");
    592     }
    593879    if (name == null) throw new InvalidUseOfNullException("header.name");
    594880    if (name.length() > MAX_HEADER_NAME_LENGTH)
     
    603889    getData().getHeaders().put(name, value);
    604890  }
     891 
     892  /**
     893    Remove all headers from the raw bioassay.
     894    @since 2.5
     895  */
     896  public void removeHeaders()
     897  {
     898    checkPermission(Permission.WRITE);
     899    getData().getHeaders().clear();
     900  }
     901
     902  /**
     903    Remove a specific header from the raw bioassay.
     904    @param name The name of the header
     905    @since 2.5
     906  */
     907  public void removeHeader(String name)
     908  {
     909    checkPermission(Permission.WRITE);
     910    getData().getHeaders().remove(name);
     911  }
     912
    605913  /**
    606914    Get the names of all raw data headers. The set is sorted by name.
     
    653961 
    654962  /**
    655     Delete the raw data that has been added to the raw bioassay. You should not
    656     call this method in the same transaction as adding raw data with the
    657     batcher from {@link #getRawDataBatcher()}.
     963    Delete the raw data that has been added to the database for this
     964    raw bioassay. You should not call this method in the same transaction as
     965    adding raw data with the batcher from {@link #getRawDataBatcher()}.
    658966
    659967    @throws PermissionDeniedException If the logged in user doesn't have
     
    675983      throw new PermissionDeniedException("The raw bioassay is used in one or more experiments: "+this);
    676984    }
    677     if (getSpots() > 0)
     985    if (getNumDbSpots() > 0)
    678986    {
    679987      RawDataBatcher rdb = RawDataBatcher.getNew(getDbControl(), this);
     
    7501058  private void validateFeatures(DbControl dc, ArrayDesign design, boolean update, ProgressReporter progress)
    7511059  {
    752     if (design.isAffyChip())
    753     {
    754       throw new InvalidDataException("The array design is an Affymetrix chip: " + design.getName());
    755     }
    7561060    if (design.hasFeatures())
    7571061    {
     
    7961100      DataResultIterator<RawData> result = rawQuery.iterate(dc);
    7971101      int numValidated = 0;
    798       int numTotal = getSpots();
     1102      int numTotal = getNumDbSpots();
    7991103      while (result.hasNext())
    8001104      {
  • trunk/src/core/net/sf/basedb/core/RawDataBatcher.java

    r3775 r3820  
    308308    rawBioAssayData.setSpots(rawBioAssayData.getSpots() + getTotalInsertCount());
    309309    rawBioAssayData.setBytes(rawBioAssayData.getBytes() + bytes);
    310     rawBioAssayData.setHasData(rawBioAssayData.getSpots() > 0);
     310    rawBioAssayData.setHasData(rawBioAssayData.getSpots() > 0 || rawBioAssayData.getNumFileSpots() > 0);
    311311    if (preloaded != null) preloaded.clear();
    312312  }
     
    443443      rawBioAssayData.setSpots(0);
    444444      rawBioAssayData.setBytes(0);
    445       rawBioAssayData.setHasData(false);
     445      rawBioAssayData.setHasData(rawBioAssayData.getNumFileSpots() > 0);
    446446    }
    447447    catch (SQLException ex)
  • trunk/src/core/net/sf/basedb/core/RawDataType.java

    r3679 r3820  
    2929import java.util.Collections;
    3030
     31import net.sf.basedb.core.data.PlatformData;
     32import net.sf.basedb.core.data.PlatformVariantData;
    3133import net.sf.basedb.core.data.RawData;
    3234
     
    4850{
    4951
    50   private final boolean isAffymetrix;
    5152  private final String id;
    5253  private final String name;
    5354  private final String description;
    54   private final String storage;
    55   private final boolean isStoredInDb;
     55  private final boolean fileOnly;
     56  private final boolean isAffymetrix;
    5657  private final int channels;
    57   private final String table;
    58   private final List<RawDataProperty> properties;
    59   private final Map<String, RawDataProperty> namedProperties;
    60   private final List<IntensityFormula> formulas;
    61   private final Map<String, IntensityFormula> namedFormulas;
    62  
    63   private final RealTable realTable;
     58  private final PlatformData platform;
     59  private final PlatformVariantData variant;
     60  private String table;
     61  private RealTable realTable;
     62  private List<RawDataProperty> properties;
     63  private Map<String, RawDataProperty> namedProperties;
     64  private List<IntensityFormula> formulas;
     65  private Map<String, IntensityFormula> namedFormulas;
     66 
    6467
    6568  /**
     
    6770    See the getter methods for a description of the parameters
    6871  */
    69   RawDataType(String id, String name, String description, int channels, String storage,
     72  RawDataType(String id, String name, String description, int channels,
     73    String table, List<RawDataProperty> properties, List<IntensityFormula> formulas)
     74  {
     75    this(id, name, description, channels, false, null, null, false, table, properties, formulas);
     76  }
     77 
     78  /**
     79    Create a new raw data type representing a file-only platform.
     80    @param platform The platform
     81  */
     82  RawDataType(PlatformData platform)
     83  {
     84    this("platform." + platform.getExternalId(), platform.getName(),
     85      platform.getDescription(), platform.getChannels(), true,
     86      platform, null,
     87      Platform.AFFYMETRIX.equals(platform.getExternalId()),
     88      null, null, null);
     89  }
     90
     91  /**
     92    Create a new raw data type representing a file-only platform variant.
     93    @param variant The platform variant
     94  */
     95  RawDataType(PlatformVariantData variant)
     96  {
     97    this("variant." + variant.getExternalId(), variant.getName(),
     98        variant.getDescription(), variant.getChannels(), true,
     99        variant.getPlatform(), variant,
     100        Platform.AFFYMETRIX.equals(variant.getPlatform().getExternalId()),
     101        null, null, null);   
     102  }
     103 
     104  private RawDataType(String id, String name, String description, int channels,
     105    boolean fileOnly, PlatformData platform, PlatformVariantData variant, boolean isAffymetrix,
    70106    String table, List<RawDataProperty> properties, List<IntensityFormula> formulas)
    71107  {
     
    73109    this.name = name;
    74110    this.description = description;
    75     this.storage = storage;
    76111    this.channels = channels;
    77     this.isStoredInDb = "database".equals(storage);
    78     this.table = isStoredInDb ? table : null;
    79     this.properties = Collections.unmodifiableList(properties);
    80     this.formulas = formulas;
    81     this.realTable = isStoredInDb ? new RealTable(table, "raw") : null;
     112    this.fileOnly = fileOnly;
     113    this.platform = platform;
     114    this.variant = variant;
     115    this.isAffymetrix = isAffymetrix;
    82116   
    83     // This is an ugly hack to support affymetrix data
    84     this.isAffymetrix = "affymetrix".equals(id);
    85    
    86     if (isStoredInDb && table == null)
     117    // For database raw data types
     118    if (!fileOnly)
    87119    {
    88       throw new InvalidDataException("No table specified for raw data type: " + id);
    89     }
    90    
    91     this.namedProperties = new HashMap<String, RawDataProperty>(properties.size());
    92     for (RawDataProperty property : properties)
    93     {
    94       if (namedProperties.put(property.getName(), property) != null)
     120      if (table == null)
    95121      {
    96         throw new BaseException("RawDataProperty[name="+property.getName()+"] is already defined for raw data type: "+name);
     122        throw new InvalidDataException("No table specified for raw data type: " + id);
     123      }
     124      this.table = table;
     125      this.realTable = new RealTable(table, "raw");
     126     
     127      // Extended properties (=columns) of the table
     128      if (properties != null)
     129      {
     130        this.properties = Collections.unmodifiableList(properties);
     131        this.namedProperties = new HashMap<String, RawDataProperty>();
     132        for (RawDataProperty property : properties)
     133        {
     134          if (namedProperties.put(property.getName(), property) != null)
     135          {
     136            throw new BaseException("RawDataProperty[name="+property.getName()+"] is already defined for raw data type: "+name);
     137          }
     138        }
     139      }
     140     
     141      // Intensity formulas
     142      if (formulas != null)
     143      {
     144        this.formulas = Collections.unmodifiableList(formulas);
     145        this.namedFormulas = new HashMap<String, IntensityFormula>();
     146        for (IntensityFormula formula : formulas)
     147        {
     148          if (namedFormulas.put(formula.getName(), formula) != null)
     149          {
     150            throw new BaseException("IntensityFormula[name="+formula.getName()+"] is already defined for raw data type: "+name);
     151          }
     152        }
    97153      }
    98154    }
    99     this.namedFormulas = new HashMap<String, IntensityFormula>(formulas.size());
    100     for (IntensityFormula formula : formulas)
    101     {
    102       if (namedFormulas.put(formula.getName(), formula) != null)
    103       {
    104         throw new BaseException("IntensityFormula[name="+formula.getName()+"] is already defined for raw data type: "+name);
    105       }
    106     }
    107    
    108   }
    109 
     155    if (this.formulas == null) this.formulas = Collections.emptyList();
     156    if (this.properties == null) this.properties = Collections.emptyList();
     157  }
     158 
    110159  /**
    111160    Get the id of this raw data type. This value is the same as the
     
    121170  /**
    122171    If this raw data type is the Affymetrix raw data type.
     172    @deprecated Use {@link #getPlatform(DbControl)} and compare
     173      the external ID with {@link Platform#AFFYMETRIX}
    123174  */
    124175  public boolean isAffymetrix()
    125176  {
    126177    return isAffymetrix;
     178  }
     179 
     180  /**
     181    Get the platform that this raw data type is associated with. Only
     182    raw data types representing file-only platforms are associated
     183    with that platform. If {@link #isStoredInDb()} returns true this
     184    method will always return null.
     185   
     186    @param dc The DbControl to use for database access
     187    @return A Platform item or null if this raw data type
     188      isn't associated with a platform
     189    @since 2.5
     190  */
     191  public Platform getPlatform(DbControl dc)
     192  {
     193    return platform == null ? null : Platform.getById(dc, platform.getId());
     194  }
     195
     196  /**
     197    Get the platform variant that this raw data type is associated with. Only
     198    raw data types representing file-only variants are associated
     199    with that variant.
     200   
     201    @param dc The DbControl to use for database access
     202    @return A Platform item or null if this raw data type
     203      isn't associated with a variant
     204    @since 2.5
     205  */
     206  public PlatformVariant getVariant(DbControl dc)
     207  {
     208    return variant == null ? null : PlatformVariant.getById(dc, variant.getId());
     209  }
     210
     211  /**
     212    Needed to make {@link RawBioAssay#setRawDataType(RawDataType)}
     213    backwards compatible. Platforms that are not file-only will
     214    get the {@link Platform#GENERIC} platform.
     215    @since 2.5
     216  */
     217  PlatformData getPlatformProxy()
     218  {
     219    return platform == null ? RawDataTypes.generic : platform;
     220  }
     221 
     222  /**
     223    Needed to make {@link RawBioAssay#setRawDataType(RawDataType)}
     224    backwards compatible.
     225    @since 2.5
     226  */
     227  PlatformVariantData getVariantProxy()
     228  {
     229    return variant;
    127230  }
    128231 
     
    169272
    170273  /**
    171     If the raw data of this raw data type is stored in the database
     274    If the raw data of this raw data type can be stored in the database
    172275    or not.
    173276    @see #getTableName()
     
    175278  public boolean isStoredInDb()
    176279  {
    177     return isStoredInDb;
     280    return !fileOnly;
    178281  }
    179282 
     
    205308 
    206309  /**
    207     Get a list of {@link RawDataProperty}s with definitions for the
     310    Get a list of {@link RawDataProperty}:s with definitions for the
    208311    extra properties that has been defined for this raw data type.
    209312
  • trunk/src/core/net/sf/basedb/core/RawDataTypes.java

    r3679 r3820  
    2626package net.sf.basedb.core;
    2727
     28import net.sf.basedb.core.data.PlatformData;
     29import net.sf.basedb.core.data.PlatformVariantData;
    2830import net.sf.basedb.core.dbengine.DbEngine;
    2931import net.sf.basedb.util.Values;
    3032import net.sf.basedb.util.XMLUtil;
    3133
     34import java.util.HashMap;
    3235import java.util.HashSet;
    3336import java.util.List;
     
    6669  private static Map<String, RawDataType> rawDataTypes = null;
    6770
     71  private static Map<String, RawDataType> platformTypes = null;
     72 
     73  private static Set<RawDataType> all = null;
     74 
     75  static PlatformData generic = null;
     76 
    6877  /**
    6978    The DTD which is used to validate the XML file.
     
    8291    if (isInitialised) return;
    8392    rawDataTypes = new TreeMap<String, RawDataType>();
     93    all = new HashSet<RawDataType>();
    8494    loadRawDataTypesFile();
    8595    isInitialised = true;
     96  }
     97 
     98  /**
     99    Load file-only platforms and create raw data types for them.
     100    @since 2.5
     101  */
     102  static synchronized void initPlatforms()
     103  {
     104    org.hibernate.Session session = null;
     105    org.hibernate.Transaction tx = null;
     106   
     107    try
     108    {
     109      platformTypes = new HashMap<String, RawDataType>();
     110      session = HibernateUtil.newSession();
     111      tx = HibernateUtil.newTransaction(session);
     112     
     113      org.hibernate.Query query = HibernateUtil.createQuery(session,
     114        "FROM PlatformData pfd WHERE pfd.fileOnly = true");
     115      for (PlatformData platform : HibernateUtil.loadList(PlatformData.class, query))
     116      {
     117        RawDataType rdt = new RawDataType(platform);
     118        platformTypes.put(rdt.getId(), rdt);
     119        all.add(rdt);
     120      }
     121     
     122      query = HibernateUtil.createQuery(session,
     123        "FROM PlatformVariantData pfv WHERE pfv.fileOnly = true");
     124      for (PlatformVariantData variant : HibernateUtil.loadList(PlatformVariantData.class, query))
     125      {
     126        RawDataType rdt = new RawDataType(variant);
     127        platformTypes.put(rdt.getId(), rdt);
     128        all.add(rdt);
     129      }
     130
     131      query = HibernateUtil.getPredefinedQuery(session,
     132        "GET_PLATFORM_FOR_EXTERNAL_ID");
     133      query.setString("externalId", Platform.GENERIC);
     134      generic = HibernateUtil.loadData(PlatformData.class, query);
     135    }
     136    finally
     137    {
     138      if (tx != null) HibernateUtil.commit(tx);
     139      if (session != null) HibernateUtil.close(session);
     140    }
    86141  }
    87142 
     
    94149    if (rawDataTypes != null) rawDataTypes.clear();
    95150    rawDataTypes = null;
     151    if (platformTypes != null) platformTypes.clear();
     152    platformTypes = null;
     153    if (all != null) all.clear();
     154    all = null;
    96155  }
    97156
     
    119178
    120179  /**
    121     Get a collection with all raw data types that has been defined.
     180    Get a collection with all raw data types that has been defined. This method
     181    only returns both database and file-only raw data types. To
     182    get file-only raw data types use {@link #getFileOnlyRawDataTypes()}
    122183    @return A <code>Collection</code> containing {@link RawDataType} objects
     184      where {@link RawDataType#isStoredInDb()} returns true
    123185  */
    124186  public static Collection<RawDataType> getRawDataTypes()
    125187  {
    126     return Collections.unmodifiableCollection(rawDataTypes.values());
     188    return Collections.unmodifiableCollection(all);
     189  }
     190 
     191  /**
     192    Get the raw data types that are representations of file-only
     193    {@link Platform}:s.
     194    @return A <code>Collection</code> containing {@link RawDataType} objects
     195      where {@link RawDataType#isStoredInDb()} returns false
     196    @since 2.5
     197  */
     198  public static Collection<RawDataType> getFileOnlyRawDataTypes()
     199  {
     200    return Collections.unmodifiableCollection(platformTypes.values());
    127201  }
    128202
     
    136210  public static RawDataType getRawDataType(String id)
    137211  {
    138     return id == null ? null : rawDataTypes.get(id);
     212    if (id == null) return null;
     213    if (id.startsWith("platform."))
     214    {
     215      return getPlatformRawDataType(id);
     216    }
     217    else if (id.startsWith("variant."))
     218    {
     219      return getVariantRawDataType(id);
     220    }
     221    else
     222    {
     223      return rawDataTypes.get(id);
     224    }
     225  }
     226 
     227  private static RawDataType getPlatformRawDataType(String id)
     228  {
     229    RawDataType rdt = platformTypes.get(id);
     230    if (rdt != null) return rdt;
     231   
     232    org.hibernate.Session session = null;
     233    org.hibernate.Transaction tx = null;
     234    try
     235    {
     236      session = HibernateUtil.newSession();
     237      tx = HibernateUtil.newTransaction(session);
     238      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     239        "GET_PLATFORM_FOR_EXTERNAL_ID");
     240      query.setString("externalId", id.substring(9));
     241      PlatformData platform = HibernateUtil.loadData(PlatformData.class, query);
     242      if (platform == null || !platform.isFileOnly()) return null;
     243      rdt = new RawDataType(platform);
     244      platformTypes.put(id, rdt);
     245      all.add(rdt);
     246    }
     247    finally
     248    {
     249      if (tx != null) HibernateUtil.commit(tx);
     250      if (session != null) HibernateUtil.close(session);
     251    }
     252    return rdt;
     253  }
     254 
     255  private static RawDataType getVariantRawDataType(String id)
     256  {
     257    RawDataType rdt = platformTypes.get(id);
     258    if (rdt != null) return rdt;
     259   
     260    org.hibernate.Session session = null;
     261    org.hibernate.Transaction tx = null;
     262    try
     263    {
     264      session = HibernateUtil.newSession();
     265      tx = HibernateUtil.newTransaction(session);
     266      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     267        "GET_PLATFORMVARIANT_FOR_EXTERNAL_ID");
     268      query.setString("externalId", id.substring(9));
     269      PlatformVariantData variant = HibernateUtil.loadData(PlatformVariantData.class, query);
     270      if (variant == null || !variant.isFileOnly()) return null;
     271      rdt = new RawDataType(variant);
     272      platformTypes.put(id, rdt);
     273      all.add(rdt);
     274    }
     275    finally
     276    {
     277      if (tx != null) HibernateUtil.commit(tx);
     278      if (session != null) HibernateUtil.close(session);
     279    }
     280    return rdt;
    139281  }
    140282
     
    182324        usedNames.add("table:" + table);
    183325      }
     326      else
     327      {
     328        throw new ConfigurationException("Attribute storage='" + storage +
     329          "' is no longer supported. Please remove declaration for <rawdatatype id='" + id +
     330          "'> from " + Application.getRawDataTypesFile());
     331      }
    184332      if (channels <= 0)
    185333      {
     
    189337      List<RawDataProperty> properties = loadProperties(el, channels);
    190338      List<IntensityFormula> formulas = loadIntensityFormulas(el, channels);
    191       RawDataType rdt = new RawDataType(id, name, description, channels, storage, table, properties, formulas);
     339      RawDataType rdt = new RawDataType(id, name, description, channels,
     340          table, properties, formulas);
    192341      rawDataTypes.put(id, rdt);
     342      all.add(rdt);
    193343    }
    194344  }
  • trunk/src/core/net/sf/basedb/core/Scan.java

    r3679 r3820  
    299299      use permission for the scan
    300300    @throws BaseException If there is another error
     301    @deprecated Use {@link RawBioAssay#getNew(DbControl, Platform, RawDataType)}
     302      or {@link RawBioAssay#getNew(DbControl, PlatformVariant, RawDataType)} instead
    301303  */
    302304  public RawBioAssay newRawBioAssay(RawDataType rawDataType)
  • trunk/src/core/net/sf/basedb/core/SpotImages.java

    r3679 r3820  
    452452      final float halfSpotsize = -spotsize / 2;
    453453      final int spotImagesPerImage = NUM_SPOT_IMAGES * NUM_SPOT_IMAGES;
    454       final int totalSpots = getRawBioAssay().getSpots();
     454      final int totalSpots = getRawBioAssay().getNumDbSpots();
    455455      int lastImageNumber = 0;
    456456
  • trunk/src/core/net/sf/basedb/core/SystemItem.java

    r3679 r3820  
    2424*/
    2525package net.sf.basedb.core;
     26
     27import net.sf.basedb.core.data.SystemData;
    2628
    2729/**
     
    5658{
    5759  /**
     60    The maximum length of the system ID that can be stored in the database.
     61    @see #getSystemId()
     62  */
     63  public static final int MAX_SYSTEM_ID_LENGTH =
     64    SystemData.MAX_SYSTEM_ID_LENGTH;
     65 
     66 
     67  /**
    5868    Get the system id for the item.
    5969    @return The id of the item or null if it is not a system item
  • trunk/src/core/net/sf/basedb/core/Update.java

    r3784 r3820  
    2929import java.sql.SQLException;
    3030import java.sql.Statement;
     31import java.util.Arrays;
    3132import java.util.Collections;
    3233import java.util.Date;
     
    3940import org.hibernate.mapping.Table;
    4041
    41 import affymetrix.fusion.cdf.FusionCDFData;
    42 
    43 import net.sf.basedb.core.data.AnyToAnyData;
    4442import net.sf.basedb.core.data.ArrayDesignData;
    4543import net.sf.basedb.core.data.DataCubeData;
     
    5351import net.sf.basedb.core.data.PluginConfigurationData;
    5452import net.sf.basedb.core.data.PluginDefinitionData;
     53import net.sf.basedb.core.data.RawBioAssayData;
    5554import net.sf.basedb.core.data.SchemaVersionData;
    5655import net.sf.basedb.core.data.TransformationData;
     56import net.sf.basedb.core.data.keyring.PluginKeys;
    5757import net.sf.basedb.core.dbengine.DbEngine;
    5858import net.sf.basedb.core.dbengine.TableInfo;
     
    491491    </td>
    492492  </tr>
    493 
     493 
    494494  <tr>
    495495    <td>42</td>
    496496    <td>
    497       <ul>
    498       <li>Added {@link net.sf.basedb.core.data.ArrayDesignData#getNumFeatures()}
    499       </ul>
    500       The update will query the database or check the CDF file to get
    501       the information.
    502     </td>
    503   </tr>
    504  
     497      No longer used.
     498    </td>
     499  </tr>
     500
    505501  <tr>
    506502    <td>43</td>
     
    511507    </td>
    512508  </tr>
     509
     510  <tr>
     511    <td>44</td>
     512    <td>
     513      <ul>
     514      <li>Added {@link Platform}, {@link DataFileType} and
     515        a lot of related classes.
     516      </ul>
     517      The update will set a platform for all array designs and
     518      raw bioassays. For Affymetrix data it will move the CEL and CDF files
     519      from AnyToAny links into FileSet:s.
     520    </td>
     521  </tr>
     522
    513523
    514524  </table>
     
    726736      }
    727737
    728       /*
    729       if (schemaVersion < 43)
    730       {
    731         if (progress != null) progress.display((int)(42*progress_factor), "--Updating schema version: " + schemaVersion + " -> 43...");
    732         schemaVersion = setSchemaVersionInTransaction(session, 43);
    733         - or -
    734         schemaVersion = updateToSchemaVersion43(session);
    735       }
    736       ... etc...
    737       */
     738      if (schemaVersion < 44)
     739      {
     740        if (progress != null) progress.display((int)(43*progress_factor), "--Updating schema version: " + schemaVersion + " -> 44...");
     741        schemaVersion = updateToSchemaVersion44(sc);
     742      }
    738743
    739744      sc.logout();
     
    16051610
    16061611  /**
    1607     Count the number of features for all array designs. For Affymetrix designs
    1608     the CDF file is checked.
     1612    Has been replaced with {@link #updateToSchemaVersion44(SessionControl)}
    16091613    @return The new schema version (=42)
    16101614  */
     
    16121616  {
    16131617    final int schemaVersion = 42;
    1614     org.hibernate.Transaction tx = null;
    1615     try
    1616     {
    1617       tx = HibernateUtil.newTransaction(session);
    1618  
    1619       org.hibernate.Query query = HibernateUtil.createQuery(session,
    1620         "SELECT ad FROM ArrayDesignData ad");
    1621       org.hibernate.Query countQuery = HibernateUtil.getPredefinedQuery(session,
    1622         "COUNT_FEATURES_FOR_ARRAYDESIGN");
    1623       org.hibernate.Query cdfQuery = HibernateUtil.getPredefinedQuery(session,
    1624         "GET_ANYTOANY_FOR_NAME");
    1625       cdfQuery.setInteger("fromType", Item.ARRAYDESIGN.getValue());
    1626       cdfQuery.setString("name", Affymetrix.CDF_LINK_NAME);
    1627      
    1628       List<ArrayDesignData> designs = HibernateUtil.loadList(ArrayDesignData.class, query);
    1629       for (ArrayDesignData design : designs)
    1630       {
    1631         int numFeatures = -1;
    1632         try
    1633         {
    1634           if (!design.getHasFeatures())
    1635           {
    1636             numFeatures = 0;
    1637           }
    1638           else  if (design.isAffyChip())
    1639           {
    1640             // Get CDF file and the number of features
    1641             cdfQuery.setInteger("fromId", design.getId());
    1642             AnyToAnyData cdfLink = HibernateUtil.loadData(AnyToAnyData.class, cdfQuery);
    1643             FileData cdf = null;
    1644             if (cdfLink != null)
    1645             {
    1646               cdf = HibernateUtil.loadData(session, FileData.class, cdfLink.getToId());
    1647             }
    1648             if (cdf != null)
    1649             {
    1650               FusionCDFData cdfData = new FusionCDFData();
    1651               cdfData.setFileName(File.getAbsolutePath(cdf.getInternalName()).getPath());
    1652               cdfData.readHeader();
    1653               numFeatures = cdfData.getHeader().getNumProbeSets();
    1654             }
    1655             else
    1656             {
    1657               numFeatures = 0;
    1658             }
    1659           }
    1660           else
    1661           {
    1662             countQuery.setInteger("arrayDesign", design.getId());
    1663             numFeatures = HibernateUtil.loadData(Long.class, countQuery).intValue();
    1664           }
    1665         }
    1666         catch (Throwable t)
    1667         {
    1668           log.error("Could not set number of features on array design: " + design, t);
    1669         }
    1670         design.setNumFeatures(numFeatures);
    1671       }
    1672 
    1673  
    1674       // Update the schema version number
    1675       setSchemaVersion(session, schemaVersion);
    1676  
    1677       // Commit the changes
    1678       HibernateUtil.commit(tx);
    1679       log.info("updateToSchemaVersion42: OK");
    1680     }
    1681     catch (BaseException ex)
    1682     {
    1683       if (tx != null) HibernateUtil.rollback(tx);
    1684       log.error("updateToSchemaVersion42: FAILED", ex);
    1685       throw ex;
    1686     }
    16871618    return schemaVersion;   
    16881619  }
     
    17281659  }
    17291660
     1661  /**
     1662    <ul>
     1663    <li>Set a platform for array designs and raw bioassays
     1664    <li>Change experiment raw data type if it is "affymetrix" to "platform.affymetrix"
     1665    <li>Move CEL and CDF files into FileSet:s
     1666    <li>Remove filters on ArrayDesign.isAffyChip property
     1667    <li>Add READ permission to PLATFORM and DATAFILETYPE for all plug-ins
     1668      working with ARRAYDESIGN or RAWBIOASSAY
     1669    </ul>
     1670  */
     1671  @SuppressWarnings("deprecation")
     1672  private static int updateToSchemaVersion44(SessionControl sc)
     1673  {
     1674    final int schemaVersion = 44;
     1675    DbControl dc = null;
     1676    try
     1677    {
     1678      dc = sc.newDbControl();
     1679      org.hibernate.Session session = dc.getHibernateSession();
     1680 
     1681      // Items that we need
     1682      Platform affymetrix = Platform.getByExternalId(dc, Platform.AFFYMETRIX);
     1683      Platform generic = Platform.getByExternalId(dc, Platform.GENERIC);
     1684      DataFileType cdfType = DataFileType.getByExternalId(dc, DataFileType.AFFYMETRIX_CDF);
     1685      DataFileType celType = DataFileType.getByExternalId(dc, DataFileType.AFFYMETRIX_CEL);
     1686      RawDataType affyRaw = affymetrix.getRawDataType();
     1687     
     1688      // Query to count number of features in db
     1689      org.hibernate.Query countQuery = HibernateUtil.getPredefinedQuery(session,
     1690        "COUNT_FEATURES_FOR_ARRAYDESIGN");
     1691
     1692      // Load array designs
     1693      org.hibernate.Query designQuery = HibernateUtil.createQuery(session,
     1694        "SELECT ad FROM ArrayDesignData ad WHERE ad.platform is null");
     1695      List<ArrayDesignData> arrayDesigns =
     1696        HibernateUtil.loadList(ArrayDesignData.class, designQuery);
     1697      for (ArrayDesignData dd : arrayDesigns)
     1698      {
     1699        ArrayDesign design = dc.getItem(ArrayDesign.class, dd);
     1700        if (design.getData().isAffyChip())
     1701        {
     1702          design.setPlatform(affymetrix);
     1703          AnyToAny anyCdf = null;
     1704          try
     1705          {
     1706            anyCdf = AnyToAny.getByName(dc, design, Affymetrix.CDF_LINK_NAME);
     1707          }
     1708          catch (Throwable t)
     1709          {}
     1710          AnyToAny.unlinkFrom(dc, design, Affymetrix.CDF_LINK_NAME);
     1711          if (anyCdf != null)
     1712          {
     1713            File cdfFile = (File)anyCdf.getTo();
     1714            FileSet fileSet = design.getFileSet();
     1715            fileSet.setMember(cdfFile, cdfType);
     1716            fileSet.validate(dc, true);
     1717          }
     1718        }
     1719        else
     1720        {
     1721          design.setPlatform(generic);
     1722          countQuery.setInteger("arrayDesign", design.getId());
     1723          int dbFeatures = HibernateUtil.loadData(Long.class, countQuery).intValue();
     1724          design.getData().setNumDbFeatures(dbFeatures);
     1725        }
     1726      }
     1727     
     1728      // Load rawbioassays
     1729      org.hibernate.Query rbaQuery = HibernateUtil.createQuery(session,
     1730        "SELECT rba FROM RawBioAssayData rba WHERE rba.platform is null");
     1731      List<RawBioAssayData> rawBioAssays =
     1732        HibernateUtil.loadList(RawBioAssayData.class, rbaQuery);
     1733      for (RawBioAssayData dd : rawBioAssays)
     1734      {
     1735        RawBioAssay rba = dc.getItem(RawBioAssay.class, dd);
     1736        if ("affymetrix".equals(rba.getData().getRawDataType()))
     1737        {
     1738          rba.getData().setPlatform(affymetrix.getData());
     1739          rba.getData().setRawDataType(affyRaw.getId());
     1740          rba.getData().setSpots(0); // No db spots in affy files
     1741          AnyToAny anyCel = null;
     1742          try
     1743          {
     1744            anyCel = AnyToAny.getByName(dc, rba, Affymetrix.CEL_LINK_NAME);
     1745          }
     1746          catch (Throwable t)
     1747          {}
     1748          AnyToAny.unlinkFrom(dc, rba, Affymetrix.CEL_LINK_NAME);
     1749          if (anyCel != null)
     1750          {
     1751            File celFile = (File)anyCel.getTo();
     1752            FileSet fileSet = rba.getFileSet();
     1753            fileSet.setMember(celFile, celType);
     1754            fileSet.validate(dc, true);
     1755          }
     1756        }
     1757        else
     1758        {
     1759          rba.getData().setPlatform(generic.getData());
     1760        }
     1761      }
     1762 
     1763      // Change raw data type for 'affymetrix' experiments to 'platform.affymetrix'
     1764      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     1765        "CHANGE_EXPERIMENT_RAWDATATYPE");
     1766      /*
     1767        UPDATE ExperimentData
     1768        SET rawDataType = :newRawDataType
     1769        WHERE rawDataType = :oldRawDataType
     1770      */
     1771      query.setString("oldRawDataType", "affymetrix");
     1772      query.setString("newRawDataType", affyRaw.getId());
     1773      HibernateUtil.executeUpdate(query);
     1774     
     1775      // Update property filters on 'rawDataType=affymetrix' to 'platform.affymetrix'
     1776      query = HibernateUtil.getPredefinedSQLQuery(session,
     1777        "UPDATE_PROPERTY_FILTER_VALUE");
     1778      /*
     1779        UPDATE [PropertyFilters]
     1780        SET [value] = :newValue
     1781        WHERE [property] = :property AND [value] = :oldValue
     1782       */
     1783      query.setString("property", "rawDataType");
     1784      query.setString("oldValue", "affymetrix");
     1785      query.setString("newValue", affyRaw.getId());
     1786      HibernateUtil.executeUpdate(query);
     1787     
     1788      // Remove filters on the 'affyChip' property
     1789      query = HibernateUtil.getPredefinedSQLQuery(session,
     1790        "DELETE_PROPERTY_FILTER");
     1791      /*
     1792        DELETE FROM PropertyFilters pf
     1793        WHERE pf.property = :property
     1794       */
     1795      query.setString("property", "affyChip");
     1796      HibernateUtil.executeUpdate(query);
     1797
     1798      // Add READ permission to PLATFORM and DATAFILETYPE for all plug-ins
     1799      // working with ARRAYDESIGN or RAWBIOASSAY
     1800      int adKeyId = SystemItems.getRoleKeyId(Item.ARRAYDESIGN);
     1801      int rbaKeyId = SystemItems.getRoleKeyId(Item.RAWBIOASSAY);
     1802     
     1803      org.hibernate.Query pQuery = HibernateUtil.getPredefinedQuery(session,
     1804        "GET_PLUGINS_WITH_KEYS");
     1805      /*
     1806        SELECT DISTINCT pk.pluginDefinitionId
     1807        FROM PluginKeys pk WHERE pk.keyId IN (:keys)
     1808      */
     1809      pQuery.setParameterList("keys",
     1810        Arrays.asList( new Integer[] { adKeyId, rbaKeyId }), Type.INT.getHibernateType());
     1811      List<Integer> pluginIds = HibernateUtil.loadList(Integer.class, pQuery);
     1812      for (int pluginId : pluginIds)
     1813      {
     1814        addPluginPermission(session, pluginId, Item.PLATFORM, 0, 2046);
     1815        addPluginPermission(session, pluginId, Item.DATAFILETYPE, 0, 2046);
     1816      }
     1817     
     1818      // Update the schema version number
     1819      setSchemaVersion(session, schemaVersion);
     1820 
     1821      // Commit the changes
     1822      dc.commit();
     1823      log.info("updateToSchemaVersion44: OK");
     1824    }
     1825    catch (BaseException ex)
     1826    {
     1827      log.error("updateToSchemaVersion44: FAILED", ex);
     1828      throw ex;
     1829    }
     1830    finally
     1831    {
     1832      if (dc != null) dc.close();
     1833    }
     1834    return schemaVersion;   
     1835  }
     1836
     1837  private static void addPluginPermission(org.hibernate.Session session, int pluginId, Item itemType, int granted, int denied)
     1838  {
     1839    PluginKeys pk = new PluginKeys();
     1840    pk.setPluginDefinitionId(pluginId);
     1841    pk.setKeyId(SystemItems.getRoleKeyId(itemType));
     1842    if (session.get(PluginKeys.class, pk) == null)
     1843    {
     1844      pk.setGranted(granted);
     1845      pk.setDenied(denied);
     1846      session.save(pk);
     1847    }
     1848  }
     1849 
    17301850  /**
    17311851    Adjust the existing items in the database to be compatible with the latest mappings.
     
    20622182        }
    20632183       
    2064         if (schemaVersion < 42)
    2065         {
    2066           // Set numFeatures to 0 for all ArrayDesign
     2184        if (schemaVersion < 44)
     2185        {
     2186          // Set numDbFeatures and numFileFeatures to 0 for all ArrayDesign
    20672187          // Later we will count or check the CDF file.
    20682188          org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     
    20702190          /*
    20712191            UPDATE ArrayDesignData ad
    2072             SET ad.numFeatures = 0
    2073             WHERE ad.numFeatures IS NULL
     2192            SET ad.numDbFeatures = 0, ad.numFileFeatures = 0
     2193            WHERE ad.numDbFeatures IS NULL OR ad.numFileFeatures IS NULL
     2194          */
     2195          HibernateUtil.executeUpdate(query);
     2196
     2197          // Set numFileSpots to 0 for all RawBioassays
     2198          // Later we will count or check the CEL file.
     2199          query = HibernateUtil.getPredefinedQuery(session,
     2200            "SET_NUMFILESPOTS_ON_RAWBIOASSAY");
     2201          /*
     2202            UPDATE RawBioAssayData rbd
     2203            SET rbd.numFileSpots = 0
     2204            WHERE rbd.numFileSpots IS NULL
    20742205          */
    20752206          HibernateUtil.executeUpdate(query);
  • trunk/src/core/net/sf/basedb/core/data/ArrayDesignData.java

    r3741 r3820  
    4040public class ArrayDesignData
    4141  extends AnnotatedData
     42  implements FileStoreEnabledData
    4243{
    4344  public ArrayDesignData()
    4445  {}
    4546
     47  /*
     48    From the FileStoreEnabledData interface
     49    -------------------------------------------
     50  */
     51  private FileSetData fileSet;
     52  public FileSetData getFileSet()
     53  {
     54     return fileSet;
     55  }
     56  public void setFileSet(FileSetData fileSet)
     57  {
     58     this.fileSet = fileSet;
     59  }
     60  // -------------------------------------------
     61 
     62  private PlatformData platform;
     63  /**
     64    Get the platform this raw bioassay uses
     65    @since 2.5
     66    @hibernate.many-to-one outer-join="false"
     67    @hibernate.column name="`platform_id`" not-null="true"
     68  */
     69  public PlatformData getPlatform()
     70  {
     71    return platform;
     72  }
     73  public void setPlatform(PlatformData platform)
     74  {
     75    this.platform = platform;
     76  }
     77 
     78  private PlatformVariantData variant;
     79  /**
     80    Get the platform variant this raw bioassay uses, or null.
     81    @since 2.5
     82    @hibernate.many-to-one outer-join="false"
     83    @hibernate.column name="`variant_id`"
     84  */
     85  public PlatformVariantData getVariant()
     86  {
     87    return variant;
     88  }
     89  public void setVariant(PlatformVariantData variant)
     90  {
     91    this.variant = variant;
     92  }
     93 
    4694  private boolean affyChip;
    4795  /**
    4896    Check if this design is an Affymetrix chip.
    49     @hibernate.property column="`affy_chip`" type="boolean" not-null="true" update="false"
     97    @hibernate.property column="`affy_chip`" type="boolean" not-null="true"
     98    @deprecated Has been replaced by platform
    5099  */
    51100  public boolean isAffyChip()
     
    53102    return affyChip;
    54103  }
     104  /**
     105    @deprecated Has been replaced by platform
     106  */
    55107  public void setAffyChip(boolean affyChip)
    56108  {
     
    72124  }
    73125
    74   private int features;
    75   /**
    76     The number of features on this array design
    77     @hibernate.property column="`features`" type="int" not-null="true"
    78   */
    79   public int getNumFeatures()
    80   {
    81     return features;
    82   }
    83   public void setNumFeatures(int features)
    84   {
    85     this.features = features;
     126  private int dbFeatures;
     127  /**
     128    The number of features on this array design that are stored in
     129    the database.
     130    @hibernate.property column="`db_features`" type="int" not-null="true"
     131    @since 2.5
     132  */
     133  public int getNumDbFeatures()
     134  {
     135    return dbFeatures;
     136  }
     137  public void setNumDbFeatures(int dbFeatures)
     138  {
     139    this.dbFeatures = dbFeatures;
     140  }
     141 
     142  private int fileFeatures;
     143  /**
     144    The number of features on this array design that are stored inside
     145    files.
     146    @hibernate.property column="`file_features`" type="int" not-null="true"
     147    @since 2.5
     148  */
     149  public int getNumFileFeatures()
     150  {
     151    return fileFeatures;
     152  }
     153  public void setNumFileFeatures(int fileFeatures)
     154  {
     155    this.fileFeatures = fileFeatures;
    86156  }
    87157 
  • trunk/src/core/net/sf/basedb/core/data/RawBioAssayData.java

    r3679 r3820  
    4343public class RawBioAssayData
    4444  extends AnnotatedData
    45   implements DiskConsumableData
     45  implements DiskConsumableData, FileStoreEnabledData
    4646{
    4747
     
    6464  }
    6565  // -------------------------------------------
    66 
     66  /*
     67    From the FileStoreEnabledData interface
     68    -------------------------------------------
     69  */
     70  private FileSetData fileSet;
     71  public FileSetData getFileSet()
     72  {
     73     return fileSet;
     74  }
     75  public void setFileSet(FileSetData fileSet)
     76  {
     77     this.fileSet = fileSet;
     78  }
     79  // -------------------------------------------
     80 
     81  private PlatformData platform;
     82  /**
     83    Get the platform this raw bioassay uses.
     84    @since 2.5
     85    @hibernate.many-to-one outer-join="false"
     86    @hibernate.column name="`platform_id`" not-null="true"
     87  */
     88  public PlatformData getPlatform()
     89  {
     90    return platform;
     91  }
     92  public void setPlatform(PlatformData platform)
     93  {
     94    this.platform = platform;
     95  }
     96 
     97  private PlatformVariantData variant;
     98  /**
     99    Get the platform variant this raw bioassay uses, or null.
     100    @since 2.5
     101    @hibernate.many-to-one outer-join="false"
     102    @hibernate.column name="`variant_id`"
     103  */
     104  public PlatformVariantData getVariant()
     105  {
     106    return variant;
     107  }
     108  public void setVariant(PlatformVariantData variant)
     109  {
     110    this.variant = variant;
     111  }
     112 
    67113  private ScanData scan;
    68114  /**
     
    166212  private int spots;
    167213  /**
    168     The number of data spots in this raw bio assay.
     214    The number of data spots in this raw bio assay, that
     215    are stored in the database.
    169216    @hibernate.property column="`spots`" type="int" not-null="true"
     217    @since 2.5
    170218  */
    171219  public int getSpots()
     
    178226  }
    179227
     228  private int fileSpots;
     229  /**
     230    The number of spots on this raw bioassay that are stored inside
     231    files.
     232    @hibernate.property column="`file_spots`" type="int" not-null="true"
     233    @since 2.5
     234  */
     235  public int getNumFileSpots()
     236  {
     237    return fileSpots;
     238  }
     239  public void setNumFileSpots(int fileSpots)
     240  {
     241    this.fileSpots = fileSpots;
     242  }
     243 
    180244  private long bytes;
    181245  /**
  • trunk/src/core/net/sf/basedb/core/data/SystemData.java

    r3679 r3820  
    6565  extends IdentifiableData
    6666{
     67
     68  /**
     69    The maximum length of the system ID of the item that can be
     70    stored in the database.
     71    @see #getSystemId()
     72    @since 2.5
     73  */
     74  public static int MAX_SYSTEM_ID_LENGTH = 255;
     75   
    6776  /**
    6877    Get the system id for the item.
  • trunk/src/core/net/sf/basedb/core/query/Hql.java

    r3679 r3820  
    4646{
    4747
     48  /**
     49    Log core events.
     50  */
     51  private static final org.apache.log4j.Logger log =
     52    org.apache.log4j.LogManager.getLogger("net.sf.basedb.core.query.Hql");
     53 
     54 
    4855  /**
    4956    A property can only contain the characters a-zA-Z0-9 and period(.)
     
    158165  {
    159166    if (property == null && alias == null) throw new InvalidUseOfNullException("property and alias");
    160     if (property != null && !PROPERTY_REGEXP.matcher(property).matches())
    161     {
    162       throw new InvalidDataException("Property '"+property+"' has one or more invalid characters. Only a-z, A-Z, 0-9 and . is allowed.");
     167    if (property != null)
     168    {
     169      if (!PROPERTY_REGEXP.matcher(property).matches())
     170      {
     171        throw new InvalidDataException("Property '"+property+"' has one or more invalid characters. Only a-z, A-Z, 0-9 and . is allowed.");
     172      }
     173      if (property.endsWith("affyChip"))
     174      {
     175        log.warn("Property 'affyChip' has been deprecated. " +
     176            "Use 'platform.externalId' and compare it to Platform.AFFYMETRIX");
     177      }
    163178    }
    164179    if (alias != null && !ALIAS_REGEXP.matcher(alias).matches())
  • trunk/src/core/net/sf/basedb/util/ClassUtil.java

    r3679 r3820  
    106106  }
    107107
     108  /**
     109    Check if a specified class exists and, optionally, if it has public no-argument
     110    constructor and implements a set of specific interfaces or superclasses.
     111   
     112    @param loader The classloader used to load the class, or null
     113      to use the default classloader
     114    @param name The fully qualified name of class to check
     115    @param publicNoArgConstructor TRUE to check if a public no-argument constructor exists
     116    @param interfaces An array of class objects representing interfaces or superclasses
     117      that the class to check must implement or extend
     118    @return The <code>Class</code> object for the named class
     119    @throws ClassNotFoundException If a class with the specified name isn't found
     120    @throws NoSuchMethodException If a public no-argument constructor isn't found
     121    @throws ClassCastException If the class doesn't implement or extend all of
     122      the interfaces/superclasses
     123    @since 2.5
     124  */
     125  public static Class<?> checkAndLoadClass(ClassLoader loader, String name,
     126    boolean publicNoArgConstructor, Class<?>... interfaces)
     127    throws ClassNotFoundException, NoSuchMethodException, ClassCastException
     128  {
     129    if (loader == null) loader = ClassUtil.class.getClassLoader();
     130    Class<?> clazz = loader.loadClass(name);
     131    if (publicNoArgConstructor)
     132    {
     133      clazz.getConstructor((Class<?>[])null);
     134    }
     135    if (interfaces != null)
     136    {
     137      for (Class<?> iFace : interfaces)
     138      {
     139        if (iFace != null && !iFace.isAssignableFrom(clazz))
     140        {
     141          throw new ClassCastException("Class '" + name + "' is not a '" + iFace.getName() + "'");
     142        }
     143      }
     144    }
     145    return clazz;
     146  }
    108147
    109148}
  • trunk/src/core/net/sf/basedb/util/IntensityCalculatorUtil.java

    r3679 r3820  
    197197        if (progress != null)
    198198        {
    199           progress.display((int)percent, "Mapping reporters for " + rba.getSpots() + " spots");
     199          progress.display((int)percent, "Mapping reporters for " + rba.getNumDbSpots() + " spots");
    200200          percent += stepSize;
    201201        }
     
    306306      for (RawBioAssay rba : rawBioAssays)
    307307      {
    308         totalSpots += rba.getSpots();
     308        totalSpots += rba.getNumDbSpots();
    309309      }
    310310      interval = totalSpots / 50;
  • trunk/src/plugins/core/net/sf/basedb/plugins/CdfFileReporterImporter.java

    r3675 r3820  
    4545import net.sf.basedb.core.ArrayDesign;
    4646import net.sf.basedb.core.BaseException;
     47import net.sf.basedb.core.DataFileType;
    4748import net.sf.basedb.core.DbControl;
    4849import net.sf.basedb.core.File;
    4950import net.sf.basedb.core.FileParameterType;
     51import net.sf.basedb.core.FileStoreUtil;
    5052import net.sf.basedb.core.InvalidDataException;
    5153import net.sf.basedb.core.Item;
     
    5759import net.sf.basedb.core.Operator;
    5860import net.sf.basedb.core.Permission;
     61import net.sf.basedb.core.Platform;
    5962import net.sf.basedb.core.PluginParameter;
    6063import net.sf.basedb.core.ProgressReporter;
     
    6568import net.sf.basedb.core.StringParameterType;
    6669import net.sf.basedb.core.Type;
     70import net.sf.basedb.core.filehandler.CdfFileHandler;
    6771import net.sf.basedb.core.plugin.About;
    6872import net.sf.basedb.core.plugin.AboutImpl;
     
    156160  /**
    157161    Request create and write access to Reporter:s
    158     and read access to File:s ArrayDesign:s and ReporterType:s.
     162    and read access to File:s ArrayDesign:s, ReporterType:s,
     163    Platform:s and DataFileType:s
    159164  */
    160165  public Collection<Permissions> getPermissions()
     
    166171      permissions.add(new Permissions(Item.FILE, null, EnumSet.of(Permission.READ)));
    167172      permissions.add(new Permissions(Item.ARRAYDESIGN, null, EnumSet.of(Permission.READ)));
     173      permissions.add(new Permissions(Item.PLATFORM, null, EnumSet.of(Permission.READ)));
     174      permissions.add(new Permissions(Item.DATAFILETYPE, null, EnumSet.of(Permission.READ)));
    168175    }
    169176    return permissions;
     
    178185      File cdfFile = (File)job.getValue("file");
    179186      cdfFile = File.getById(dc, cdfFile.getId());
    180       FusionCDFData cdf = Affymetrix.loadCdfFile(cdfFile);
     187      FusionCDFData cdf = new CdfFileHandler().loadCdfFile(cdfFile);
    181188 
    182189      // Import data from it
     
    225232      }
    226233      ArrayDesign design = (ArrayDesign)item;
    227       if (!design.isAffyChip())
     234      if (!design.isPlatform(Platform.AFFYMETRIX))
    228235      {
    229236        message = "The array design is not an Affymetrix chip";
     
    231238      else
    232239      {
    233         File cdfFile = Affymetrix.getCdfFile(design);
    234         if (cdfFile == null)
    235         {
    236           throw new InvalidDataException("The array design doesn't have a CDF file");
     240        if (!FileStoreUtil.hasDataFile(design.getDbControl(), design, DataFileType.AFFYMETRIX_CDF, true))
     241        {
     242          throw new InvalidDataException("The array design doesn't have a valid CDF file");
    237243        }
    238244      }
     
    274280        // Verify that the file is a CDF file
    275281        File cdfFile = (File)request.getParameterValue("file");
    276         FusionCDFData cdf = Affymetrix.loadCdfFile(cdfFile);
     282        FusionCDFData cdf = new CdfFileHandler().loadCdfFile(cdfFile);
    277283       
    278284        storeValue(job, request, ri.getParameter("file"));
     
    383389          int currentArrayDesignId = sc.getCurrentContext(Item.ARRAYDESIGN).getId();
    384390          design = ArrayDesign.getById(dc, currentArrayDesignId);
    385           cdfFile = Affymetrix.getCdfFile(design);
     391          cdfFile = FileStoreUtil.getDataFile(dc, design, DataFileType.AFFYMETRIX_CDF);
    386392          presets = Arrays.asList(new File[] { cdfFile } );
    387393        }
  • trunk/src/plugins/core/net/sf/basedb/plugins/IlluminaRawDataImporter.java

    r3675 r3820  
    4040import net.sf.basedb.core.BaseException;
    4141import net.sf.basedb.core.BasicItem;
     42import net.sf.basedb.core.DataFileType;
    4243import net.sf.basedb.core.DbControl;
    4344import net.sf.basedb.core.Experiment;
     45import net.sf.basedb.core.File;
    4446import net.sf.basedb.core.Include;
    4547import net.sf.basedb.core.InvalidDataException;
     
    5052import net.sf.basedb.core.Job;
    5153import net.sf.basedb.core.Permission;
     54import net.sf.basedb.core.Platform;
    5255import net.sf.basedb.core.PluginParameter;
    5356import net.sf.basedb.core.Protocol;
     
    380383  protected void beginData()
    381384  {
     385    File rawDataFile = (File)job.getValue("file");
    382386    this.dc = sc.newDbControl();
    383387    try
    384388    {
    385       this.rawBioAssays = extractAndCreateRawBioAssays(dc, ffp.getColumnHeaders(), verifyColumns);
     389      this.rawBioAssays = extractAndCreateRawBioAssays(dc, ffp.getColumnHeaders(), verifyColumns, rawDataFile);
    386390      // We must commit to be able to insert raw data
    387391      // In case of a later failure the end() method should delete the raw bioassays again
     
    452456      {
    453457        if (experiment != null) experiment = Experiment.getById(dc, experiment.getId());
     458        DataFileType rawDataType = DataFileType.getByExternalId(dc, DataFileType.GENERIC_RAW_DATA);
    454459        for (BatchAndMapHolder holder : holders)
    455460        {
     
    459464            experiment.addRawBioAssay(holder.rba);
    460465          }
     466          holder.rba.getFileSet().getMember(rawDataType).setValid(true, null);
    461467        }
    462468        dc.commit();
     
    499505    error.
    500506  */
    501   private List<RawBioAssay> extractAndCreateRawBioAssays(DbControl dc, List<String> headers, boolean verifyColumns)
    502   {
     507  private List<RawBioAssay> extractAndCreateRawBioAssays(DbControl dc, List<String> headers,
     508    boolean verifyColumns, File rawDataFile)
     509  {
     510    // Holds the created raw bioassays
    503511    List<RawBioAssay> list = new LinkedList<RawBioAssay>();
     512    // Load the generic raw data file type
     513    DataFileType rawDataType = DataFileType.getByExternalId(dc, DataFileType.GENERIC_RAW_DATA);
    504514    // Maps: array name -> set of extended property names
    505515    Map<String, Set<String>> arrayNames = new HashMap<String, Set<String>>();
     
    528538          {
    529539            arrayNames.put(arrayName, new HashSet<String>());
    530             RawBioAssay rba = RawBioAssay.getNew(dc, illumina);
     540            Platform generic = Platform.getByExternalId(dc, Platform.GENERIC);
     541            RawBioAssay rba = RawBioAssay.getNew(dc, generic, illumina);
    531542            rba.setName(arrayName);
    532543            if (scan != null) rba.setScan(scan);
    533544            if (protocol != null) rba.setProtocol(protocol);
    534545            if (software != null) rba.setSoftware(software);
     546            if (rawDataFile != null) rba.getFileSet().setMember(rawDataFile, rawDataType);
    535547            for (Line headerLine : headerLines)
    536548            {
  • trunk/src/plugins/core/net/sf/basedb/plugins/IntensityCalculatorPlugin.java

    r3679 r3820  
    365365                "' is not part of the experiment '" + experiment.getName()+"'");
    366366            }
    367             numSpots += rba.getSpots();
     367            numSpots += rba.getNumDbSpots();
    368368          }
    369369        }
  • trunk/src/plugins/core/net/sf/basedb/plugins/PrintMapFlatFileImporter.java

    r3679 r3820  
    3030import net.sf.basedb.core.BaseException;
    3131import net.sf.basedb.core.BlockInfo;
     32import net.sf.basedb.core.DataFileType;
    3233import net.sf.basedb.core.DbControl;
    3334import net.sf.basedb.core.FeatureBatcher;
     35import net.sf.basedb.core.File;
     36import net.sf.basedb.core.FileParameterType;
     37import net.sf.basedb.core.FileSetMember;
     38import net.sf.basedb.core.FileStoreUtil;
    3439import net.sf.basedb.core.FileType;
    3540import net.sf.basedb.core.IntegerUtil;
     
    122127
    123128  private ArrayDesign arrayDesign;
     129  private FileSetMember printMapMember;
    124130  private ItemParameterType<ArrayDesign> arrayDesignType;
    125131  private PluginParameter<ArrayDesign> arrayDesignParameter;
     
    150156  }
    151157  /**
    152     Request write access to ArrayDesign:s, read access to Plate:s, Reporter:s
    153     and File:s.
     158    Request write access to ArrayDesign:s, read access to Plate:s, Reporter:s,
     159    DataFileType:s, Platform:s and File:s.
    154160  */
    155161  public Collection<Permissions> getPermissions()
     
    161167      permissions.add(new Permissions(Item.REPORTER, null, EnumSet.of(Permission.READ)));
    162168      permissions.add(new Permissions(Item.FILE, null, EnumSet.of(Permission.READ)));
     169      permissions.add(new Permissions(Item.PLATFORM, null, EnumSet.of(Permission.READ)));
     170      permissions.add(new Permissions(Item.DATAFILETYPE, null, EnumSet.of(Permission.READ)));
    163171    }
    164172    return permissions;
     
    188196    {
    189197      ArrayDesign ad = (ArrayDesign)item;
    190       if (ad.isAffyChip())
    191       {
    192         message = "Affy array designs are not supported";
    193       }
    194       else if (ad.hasFeatures())
     198      if (ad.isFileOnlyPlatform())
     199      {
     200        message = "Array design is using a file-only platform";
     201      }
     202      else if (ad.getNumDbFeatures() > 0)
    195203      {
    196204        throw new PermissionDeniedException("The array design already has features");
     
    301309    arrayDesign = (ArrayDesign)job.getValue("arrayDesign");
    302310    arrayDesign = ArrayDesign.getById(dc, arrayDesign.getId());
    303     if (arrayDesign.hasFeatures())
     311    File reporterMapFile = (File)job.getValue("file");
     312    printMapMember = FileStoreUtil.setGenericDataFile(dc, arrayDesign,
     313        FileType.PRINT_MAP, DataFileType.GENERIC_PRINT_MAP, reporterMapFile);
     314    if (arrayDesign.getNumDbFeatures() > 0)
    304315    {
    305316      throw new PermissionDeniedException("The array design already has features: " + arrayDesign.getName()+" ["+arrayDesign.getId()+"]");
     
    447458    throws BaseException
    448459  {
     460    if (printMapMember != null) printMapMember.setValid(success, null);
    449461    if (blocks != null) blocks.clear();
    450462    try
     
    503515      List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>();
    504516      parameters.add(arrayDesignParameter);
     517
     518      ArrayDesign design = null;
     519      int currentArrayDesignId = sc.getCurrentContext(Item.ARRAYDESIGN).getId();
     520      List<File> printMapFiles = null;
     521      dc = sc.newDbControl();
     522      try
     523      {
     524        design = ArrayDesign.getById(dc, currentArrayDesignId);
     525        printMapFiles = FileStoreUtil.getGenericDataFiles(dc, design, FileType.PRINT_MAP);
     526      }
     527      catch (Throwable t)
     528      {}
     529      finally
     530      {
     531        if (dc != null) dc.close();
     532      }
     533     
     534      // The print map file to import from - if a file already hase
     535      // been attached to the array design use it as a default choice
     536      PluginParameter<File> fileParameter = new PluginParameter<File>(
     537        "file",
     538        "Print map file",
     539        "The file with printing information to import features from",
     540        new FileParameterType(printMapFiles == null || printMapFiles.isEmpty() ?
     541          null : printMapFiles.get(0), true, 1)
     542      );
    505543      parameters.add(fileParameter);
    506544      parameters.add(getCharsetParameter(null, null, null));
  • trunk/src/plugins/core/net/sf/basedb/plugins/RawDataFlatFileImporter.java

    r3679 r3820  
    2626
    2727import net.sf.basedb.core.BaseException;
     28import net.sf.basedb.core.DataFileType;
    2829import net.sf.basedb.core.DbControl;
     30import net.sf.basedb.core.File;
     31import net.sf.basedb.core.FileParameterType;
     32import net.sf.basedb.core.FileSetMember;
     33import net.sf.basedb.core.FileStoreUtil;
    2934import net.sf.basedb.core.FileType;
    3035import net.sf.basedb.core.Item;
     
    215220  private RawDataBatcher batcher;
    216221  private RawBioAssay rawBioAssay;
    217  
     222  private FileSetMember rawDataMember;
     223
    218224  private Mapper reporterMapper;
    219225  private Mapper blockMapper;
     
    243249  }
    244250  /**
    245     Request write access to RawBioAssay:s and read access to ArrayDesign:s, File:s
    246     and Reporter:s.
     251    Request write access to RawBioAssay:s and read access to ArrayDesign:s, File:s,
     252     Reporter:s, Platform:s and DataFileType:s
    247253  */
    248254  public Collection<Permissions> getPermissions()
     
    254260      permissions.add(new Permissions(Item.FILE, null, EnumSet.of(Permission.READ)));
    255261      permissions.add(new Permissions(Item.REPORTER, null, EnumSet.of(Permission.READ)));
     262      permissions.add(new Permissions(Item.PLATFORM, null, EnumSet.of(Permission.READ)));
     263      permissions.add(new Permissions(Item.DATAFILETYPE, null, EnumSet.of(Permission.READ)));
    256264    }
    257265    return permissions;
     
    297305        message = "Raw data for raw data type '" + rdt + "' is not stored in the database";
    298306      }
    299       else if (rba.hasData())
     307      else if (rba.getNumDbSpots() > 0)
    300308      {
    301309        throw new PermissionDeniedException("The raw bioassay already has data.");
     
    450458    dc = sc.newDbControl();
    451459    rawBioAssay = (RawBioAssay)job.getValue("rawBioAssay");
    452     dc.reattachItem(rawBioAssay);
     460    File rawDataFile = (File)job.getValue("file");
     461    rawBioAssay = RawBioAssay.getById(dc, rawBioAssay.getId());
     462    rawDataMember = FileStoreUtil.setGenericDataFile(dc, rawBioAssay,
     463      FileType.RAW_DATA, DataFileType.GENERIC_RAW_DATA, rawDataFile);
     464   
    453465    batcher = rawBioAssay.getRawDataBatcher();
    454466    numInserted = 0;
     
    514526    throws BaseException
    515527  {
     528    if (rawDataMember != null) rawDataMember.setValid(success, null);
     529
    516530    try
    517531    {
     
    630644      );
    631645      parameters.add(rawBioAssayParameter);
    632       parameters.add(fileParameter);
     646
     647      RawBioAssay rba = null;
     648      int currentRawBioAssayId = sc.getCurrentContext(Item.RAWBIOASSAY).getId();
     649      List<File> rawDataFiles = null;
     650      dc = sc.newDbControl();
     651      try
     652      {
     653        rba = RawBioAssay.getById(dc, currentRawBioAssayId);
     654        rawDataFiles = FileStoreUtil.getGenericDataFiles(dc, rba, FileType.RAW_DATA);
     655      }
     656      catch (Throwable t)
     657      {}
     658      finally
     659      {
     660        if (dc != null) dc.close();
     661      }
     662     
     663      // The raw data file to import from - if a file already hase
     664      // been attached to the raw bioassay use it as a default choice
     665      PluginParameter<File> fileParameter = new PluginParameter<File>(
     666        "file",
     667        "Raw data file",
     668        "The file that contains the raw data that you want to import",
     669        new FileParameterType(rawDataFiles == null || rawDataFiles.isEmpty() ?
     670          null : rawDataFiles.get(0), true, 1)
     671      );
     672      parameters.add(fileParameter);     
    633673      parameters.add(getCharsetParameter(null, null, (String)configuration.getValue(CHARSET)));
    634674      parameters.add(getDecimalSeparatorParameter(null, null, (String)configuration.getValue(DECIMAL_SEPARATOR)));
  • trunk/src/plugins/core/net/sf/basedb/plugins/ReporterMapFlatFileImporter.java

    r3679 r3820  
    3030import net.sf.basedb.core.BaseException;
    3131import net.sf.basedb.core.BlockInfo;
     32import net.sf.basedb.core.DataFileType;
    3233import net.sf.basedb.core.DbControl;
    3334import net.sf.basedb.core.FeatureBatcher;
     35import net.sf.basedb.core.File;
     36import net.sf.basedb.core.FileParameterType;
     37import net.sf.basedb.core.FileSetMember;
     38import net.sf.basedb.core.FileStoreUtil;
    3439import net.sf.basedb.core.FileType;
    3540import net.sf.basedb.core.InvalidUseOfNullException;
     
    173178  private FeatureBatcher batcher;
    174179  private ReporterBatcher reporterBatcher;
     180  private FileSetMember reporterMapMember;
    175181  private ArrayDesign arrayDesign;
    176182  private Map<BlockInfo, ArrayDesignBlock> blocks;
     
    216222  }
    217223  /**
    218     Request write access to ArrayDesign:s, read access to Reporter:s
    219     and File:s.
     224    Request write access to ArrayDesign:s, read access to Reporter:s,
     225    DataFileType:s, Platform:s and File:s.
    220226  */
    221227  public Collection<Permissions> getPermissions()
     
    226232      permissions.add(new Permissions(Item.REPORTER, null, EnumSet.of(Permission.READ)));
    227233      permissions.add(new Permissions(Item.FILE, null, EnumSet.of(Permission.READ)));
     234      permissions.add(new Permissions(Item.PLATFORM, null, EnumSet.of(Permission.READ)));
     235      permissions.add(new Permissions(Item.DATAFILETYPE, null, EnumSet.of(Permission.READ)));
    228236    }
    229237    return permissions;
     
    263271    {
    264272      ArrayDesign ad = (ArrayDesign)item;
    265       if (ad.isAffyChip())
    266       {
    267         message = "Affy array designs are not supported";
    268       }
    269       else if (ad.hasFeatures())
     273      if (ad.isFileOnlyPlatform())
     274      {
     275        message = "Array design is using a file-only platform";
     276      }
     277      else if (ad.getNumDbFeatures() > 0)
    270278      {
    271279        throw new PermissionDeniedException("The array design already has features");
     
    398406    dc = sc.newDbControl();
    399407    arrayDesign = (ArrayDesign)job.getValue("arrayDesign");
    400     dc.reattachItem(arrayDesign);
    401     if (arrayDesign.hasFeatures())
     408    File reporterMapFile = (File)job.getValue("file");
     409    arrayDesign = ArrayDesign.getById(dc, arrayDesign.getId());
     410    reporterMapMember = FileStoreUtil.setGenericDataFile(dc, arrayDesign,
     411        FileType.REPORTER_MAP, DataFileType.GENERIC_REPORTER_MAP, reporterMapFile);
     412    if (arrayDesign.getNumDbFeatures() > 0)
    402413    {
    403414      throw new PermissionDeniedException("The array design already has features. "+arrayDesign.getName()+"["+arrayDesign.getId()+"]");
     
    486497  {
    487498    if (blocks != null) blocks.clear();
     499    if (reporterMapMember != null) reporterMapMember.setValid(success, null);
    488500    try
    489501    {
     
    542554      List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>();
    543555      parameters.add(arrayDesignParameter);
     556
     557      ArrayDesign design = null;
     558      int currentArrayDesignId = sc.getCurrentContext(Item.ARRAYDESIGN).getId();
     559      List<File> reporterMapFiles = null;
     560      dc = sc.newDbControl();
     561      try
     562      {
     563        design = ArrayDesign.getById(dc, currentArrayDesignId);
     564        reporterMapFiles = FileStoreUtil.getGenericDataFiles(dc, design, FileType.REPORTER_MAP);
     565      }
     566      catch (Throwable t)
     567      {}
     568      finally
     569      {
     570        if (dc != null) dc.close();
     571      }
     572     
     573      // The reporter map file to import from - if a file already hase
     574      // been attached to the array design use it as a default choice
     575      PluginParameter<File> fileParameter = new PluginParameter<File>(
     576        "file",
     577        "Reporter map file",
     578        "The file with reporter information to import features from",
     579        new FileParameterType(reporterMapFiles == null || reporterMapFiles.isEmpty() ?
     580          null : reporterMapFiles.get(0), true, 1)
     581      );
    544582      parameters.add(fileParameter);
    545583      parameters.add(getCharsetParameter(null, null, (String)configuration.getValue(CHARSET)));
  • trunk/src/test/TestAll.java

    r3700 r3820  
    102102    results.put("TestPlateMapping", TestPlateMapping.test_all());
    103103
     104    // Experimental platforms and data file types
     105    results.put("TestDataFileType", TestDataFileType.test_all());
     106    results.put("TestPlatform", TestPlatform.test_all());
     107   
    104108    // Array LIMS -- Arrays
    105109    results.put("TestArrayDesign", TestArrayDesign.test_all());
    106 //    results.put("TestAffyChip", TestAffyChip.test_all());
    107110    results.put("TestArrayBatch", TestArrayBatch.test_all());
    108111    results.put("TestArraySlide", TestArraySlide.test_all());
  • trunk/src/test/TestAnalyzePluginUtil.java

    r3679 r3820  
    3131import net.sf.basedb.core.Item;
    3232import net.sf.basedb.core.Permission;
     33import net.sf.basedb.core.Platform;
    3334import net.sf.basedb.core.RawBioAssay;
    3435import net.sf.basedb.core.RawDataBatcher;
     
    5960      for (int i = 0; i < rawBioAssays; i++)
    6061      {
    61         int rawBioAssayId = TestRawBioAssay.test_create("genepix", 0, 0, 0, 0, false);
     62        int rawBioAssayId = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, 0, false);
    6263       
    6364        FlatFileParser parser = new FlatFileParser();
  • trunk/src/test/TestAnnotation.java

    r3789 r3820  
    6161    int booleanId = TestAnnotationType.test_create(null, Type.BOOLEAN, true, null, Item.ARRAYDESIGN, 1, null, true);
    6262    int enumId = TestAnnotationType.test_create(null, Type.INT, 3, null, Item.ARRAYDESIGN, 1, new Object[] { 1, 2, 3, 4, 5 }, false);
    63     int arrayDesignId = TestArrayDesign.test_create(true, false);
     63    int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, true);
    6464
    6565    // Annotate the array design and list the annotations
     
    7676
    7777    // Test: inherit annotations
    78     int rawBioAssayId = TestRawBioAssay.test_create("genepix", 0, 0, 0, arrayDesignId, false);
     78    int rawBioAssayId = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, arrayDesignId, false);
    7979    test_inherit_annotation(rawBioAssayId, intAnnotationId);
    8080    test_inherit_annotation(rawBioAssayId, stringAnnotationId);
  • trunk/src/test/TestArrayBatch.java

    r3679 r3820  
    3434import net.sf.basedb.core.ItemQuery;
    3535import net.sf.basedb.core.ItemResultList;
     36import net.sf.basedb.core.Platform;
    3637
    3738public class TestArrayBatch
     
    5253    write_header();
    5354    // Standard tests: create, load, list
    54     int arraydesign_id = TestArrayDesign.test_create(false, false);
     55    int arraydesign_id = TestArrayDesign.test_create(Platform.GENERIC, false);
    5556    int id = test_create(arraydesign_id, true);
    5657    int id2 = test_create(arraydesign_id, false);
  • trunk/src/test/TestArrayDesign.java

    r3679 r3820  
    3131import net.sf.basedb.core.Feature;
    3232import net.sf.basedb.core.FeatureBatcher;
     33import net.sf.basedb.core.File;
     34import net.sf.basedb.core.FileSetMember;
     35import net.sf.basedb.core.DataFileType;
    3336import net.sf.basedb.core.Item;
    3437import net.sf.basedb.core.Permission;
     
    3639import net.sf.basedb.core.DataResultIterator;
    3740import net.sf.basedb.core.Plate;
     41import net.sf.basedb.core.Platform;
    3842import net.sf.basedb.core.Reporter;
    3943import net.sf.basedb.core.ReporterBatcher;
     
    6670    write_header();
    6771    // Standard tests: create, load, list
    68     int id = test_create(true, false);
    69     int id2 = test_create(false, false);
    70     int id3 = test_create(true, true);
    71     int id4 = test_create(false, true);
     72    int id = test_create(Platform.GENERIC, true);
     73    int id2 = test_create(Platform.GENERIC, false);
     74    int id3 = test_create(Platform.AFFYMETRIX, true);
     75    int id4 = test_create(Platform.AFFYMETRIX, false);
    7276    test_load(id);
    7377    test_list(-1);
     
    9094    int[] plateIds = TestPlate.test_import_from_file("data/test.plate96.import.txt",
    9195      "Plate\\tRow\\tColumn\\tCluster ID\\tClone ID\\tGene Symbol\\tBarcode", plateType, 0, 1, 2, 4);
    92     int id5 = test_create(false, false);
     96    int id5 = test_create(Platform.GENERIC, false);
    9397    test_add_plates(id5, plateIds);
    9498   
     
    98102    test_add_features_from_wells(id5, plateIds, 10);
    99103   
     104    // Array designs with data in files
     105    int cdfId = TestFile.test_create("data/test.affymetrix.cdf", false, false);
     106    test_set_file(id3, DataFileType.AFFYMETRIX_CDF, cdfId);
     107    test_list_files(id3, 1);
     108
    100109    if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter();
    101110    // Standard test: Delete
     
    109118    TestPlateType.test_delete(plateType);
    110119    TestPlateGeometry.test_delete(plateGeometry);
    111    
     120    TestFile.test_delete(cdfId);
    112121    TestReporter.test_delete();
    113122
     
    116125  }
    117126
    118   static int test_create(boolean setAll, boolean affyChip)
     127  static int test_create(String platformId, boolean setAll)
    119128  {
    120129    if (!TestUtil.hasPermission(Permission.CREATE, Item.ARRAYDESIGN)) return 0;
     
    124133    {
    125134      dc = TestUtil.getDbControl();
    126       ArrayDesign ad = ArrayDesign.getNew(dc, affyChip);
     135      Platform platform = Platform.getByExternalId(dc, platformId);
     136      ArrayDesign ad = ArrayDesign.getNew(dc, platform);
    127137      if (setAll)
    128138      {
     
    133143      dc.commit();
    134144      id = ad.getId();
     145      dc = TestUtil.getDbControl();
     146      dc.reattachItem(ad);
    135147      write_item(0, ad);
    136148      write("--Create array design OK");
     
    260272    if (!TestUtil.getSilent())
    261273    {
    262       write(i+":\t"+ad.getId()+"\t"+ad.getName()+"\t"+ad.getDescription()+"\t"+ad.isAnnotated()+"\t"+ad.isAffyChip());
     274      write(i+":\t"+ad.getId()+"\t"+ad.getName()+"\t"+ad.getDescription()+"\t"+ad.isAnnotated()+"\t"+ad.getPlatform());
    263275    }
    264276  }
     
    282294  }
    283295
     296  static void write_item(int i, FileSetMember member)
     297    throws BaseException
     298  {
     299    if (!TestUtil.getSilent())
     300    {
     301      System.out.println(i+":\t"+member.getId()+"\t"+member.getFile().getName()+"\t"+
     302        member.getDataFileType().getName());
     303    }
     304  }
     305 
    284306  static void write(String message)
    285307  {
     
    363385      dc = TestUtil.getDbControl();
    364386      ArrayDesign ad = ArrayDesign.getById(dc, arrayDesignId);
    365       if (ad.isAffyChip())
     387      if (Platform.AFFYMETRIX.equals(ad.getPlatform().getExternalId()))
    366388      {
    367389        throw new BaseException("Cannot add features from wells on an affy arraydesign");
     
    434456      }
    435457      dc.commit();
    436       write_item(0, ad);
    437458      write("--Add plates to array design OK");
    438459    }
     
    574595  }
    575596
     597  static void test_set_file(int arrayDesignId, String fileType, int fileId)
     598  {
     599    if (arrayDesignId == 0 || fileId == 0) return;
     600    DbControl dc = null;
     601    try
     602    {
     603      dc = TestUtil.getDbControl();
     604      ArrayDesign ad = ArrayDesign.getById(dc, arrayDesignId);
     605      DataFileType type = DataFileType.getByExternalId(dc, fileType);
     606      File file = File.getById(dc, fileId);
     607      ad.getFileSet().setMember(file, type);
     608      ad.getFileSet().validate(dc, true);
     609      dc.commit();
     610      write("--Set file OK ("+fileType+")");
     611    }
     612    catch (Throwable ex)
     613    {
     614      write("--Set file FAILED ("+fileType+")");
     615      ex.printStackTrace();
     616      ok = false;
     617    }
     618    finally
     619    {
     620      if (dc != null) dc.close();
     621    }
     622  }
     623   
     624  static void test_list_files(int arrayDesignId, int expectedResults)
     625  {
     626    if (arrayDesignId == 0) return;
     627    DbControl dc = null;
     628    try
     629    {
     630      dc = TestUtil.getDbControl();
     631      ArrayDesign ad = ArrayDesign.getById(dc, arrayDesignId);
     632      ItemResultList<FileSetMember> l = ad.getFileSet().getMembers().list(dc);
     633      for (int i = 0; i<l.size(); i++)
     634      {
     635        write_item(i, l.get(i));
     636      }
     637      if (expectedResults >= 0 && expectedResults != l.size())
     638      {
     639        throw new BaseException("Expected "+expectedResults+" results, not "+l.size());
     640      }
     641      write("--List files OK ("+l.size()+")");
     642    }
     643    catch (Throwable ex)
     644    {
     645      write("--List files FAILED");
     646      ex.printStackTrace();
     647      ok = false;
     648    }
     649    finally
     650    {
     651      if (dc != null) dc.close();
     652    }
     653  }
    576654}
    577655
  • trunk/src/test/TestArrayDesignBlock.java

    r3679 r3820  
    3030import net.sf.basedb.core.DbControl;
    3131import net.sf.basedb.core.ItemResultList;
     32import net.sf.basedb.core.Platform;
    3233
    3334 
     
    5556    write("++Testing array design block");
    5657    write_header();
    57     int arrayDesignId = TestArrayDesign.test_create(false, false);
     58    int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false);
    5859    // Standard tests: create, load, list
    5960    int nbr = 10;
  • trunk/src/test/TestArraySlide.java

    r3679 r3820  
    99import net.sf.basedb.core.ItemQuery;
    1010import net.sf.basedb.core.ItemResultList;
     11import net.sf.basedb.core.Platform;
    1112
    1213/*
     
    5051    write_header();
    5152    // Standard tests: create, load, list
    52     int arraydesign_id = TestArrayDesign.test_create(true, false);
     53    int arraydesign_id = TestArrayDesign.test_create(Platform.GENERIC, true);
    5354    int arraybatch_id = TestArrayBatch.test_create(arraydesign_id, false);
    5455    int id = test_create(arraybatch_id, true);
  • trunk/src/test/TestBioAsssaySetExporter.java

    r3675 r3820  
    1212import net.sf.basedb.core.Item;
    1313import net.sf.basedb.core.ItemQuery;
     14import net.sf.basedb.core.Platform;
    1415import net.sf.basedb.core.RawBioAssay;
    1516import net.sf.basedb.core.RawDataBatcher;
     
    277278    {
    278279      dc = TestUtil.getDbControl();
    279       RawBioAssay rba = RawBioAssay.getNew(dc, RawDataTypes.getRawDataType("genepix"));
     280      Platform generic = Platform.getByExternalId(dc, Platform.GENERIC);
     281      RawBioAssay rba = RawBioAssay.getNew(dc, generic, RawDataTypes.getRawDataType("genepix"));
    280282      AnnotationType at = AnnotationType.getById(dc, annotationTypeId);
    281283     
  • trunk/src/test/TestDirty.java

    r3719 r3820  
    7373   
    7474    // Test import raw data
    75     int arrayDesignId = TestArrayDesign.test_create(false, false);
     75    int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false);
    7676    TestArrayDesign.test_import_from_file(arrayDesignId, "data/test.import.dirty.txt",
    7777        "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", 0, 2, 1, 4);
    7878   
    79     int rawBioAssayId = TestRawBioAssay.test_create("genepix", 0, 0, 0, arrayDesignId, false);
     79    int rawBioAssayId = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, arrayDesignId, false);
    8080    int fileId = TestFile.test_create("data/test.import.dirty.txt", false, false);
    8181   
     
    9292    TestJob.test_delete(jobId);
    9393    TestPluginConfiguration.test_delete(pluginConfigurationId);
    94     TestFile.test_delete(fileId);
    9594    TestRawBioAssay.test_delete(rawBioAssayId);
    9695    TestArrayDesign.test_delete(arrayDesignId);
     96    TestFile.test_delete(fileId);
    9797    TestReporter.test_delete();
    9898    write("++Testing import of dirty data "+(ok ? "OK" : "Failed")+"\n");
  • trunk/src/test/TestExperiment.java

    r3679 r3820  
    7878      "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", "\\t", 4, 3);
    7979   
    80     int arrayDesignId = TestArrayDesign.test_create(false, false);
     80    int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false);
    8181    TestArrayDesign.test_import_from_file(arrayDesignId, "data/test.rawdata.import.txt",
    8282      "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", 0, 2, 1, 4);
    8383   
    84     int rbaId1 = TestRawBioAssay.test_create("genepix", 0, 0, 0, arrayDesignId, false);
    85     int rbaId2 = TestRawBioAssay.test_create("genepix", 0, 0, 0, arrayDesignId, false);
     84    int rbaId1 = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, arrayDesignId, false);
     85    int rbaId2 = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, arrayDesignId, false);
    8686    TestRawBioAssay.test_import_from_file(rbaId1, "data/test.rawdata.import.txt");
    8787    TestRawBioAssay.test_import_from_file(rbaId2, "data/test.rawdata.import.txt");
     
    293293    {
    294294      System.out.println(i+":\t"+rba.getId()+"\t"+rba.getName()+"\t"+rba.getDescription()+
    295         "\t"+rba.getRawDataType().getName()+"\t"+rba.getSpots()+"\t"+rba.getBytes()+"\t"+rba.getArrayDesign()+
     295        "\t"+rba.getRawDataType().getName()+"\t"+rba.getNumDbSpots()+"\t"+rba.getBytes()+"\t"+rba.getArrayDesign()+
    296296        "\t"+rba.getSoftware()+"\t"+rba.getProtocol());
    297297    }
  • trunk/src/test/TestHybridization.java

    r3679 r3820  
    4848    test_load(id);
    4949
    50     int arrayDesignId = TestArrayDesign.test_create(false, false);
     50    int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false);
    5151    int arrayBatchId = TestArrayBatch.test_create(arrayDesignId, false);
    5252    int arraySlideId = TestArraySlide.test_create(arrayBatchId, false);
  • trunk/src/test/TestPrintMapFlatFileImporter.java

    r3719 r3820  
    99import net.sf.basedb.core.ParameterType;
    1010import net.sf.basedb.core.Permission;
     11import net.sf.basedb.core.Platform;
    1112import net.sf.basedb.core.PluginConfigurationRequest;
    1213import net.sf.basedb.core.PluginDefinition;
     
    6364   
    6465    // Create ArrayDesign needed for print map import
    65     int arrayDesignId = TestArrayDesign.test_create(false, false);
     66    int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false);
    6667    int plateGeometryId = TestPlateGeometry.test_create(16, 24, false);
    6768    int plateTypeId = TestPlateType.test_create(plateGeometryId, false);
  • trunk/src/test/TestProject.java

    r3679 r3820  
    100100    {     
    101101      dc = TestUtil.getDbControl();     
    102       int adId = TestArrayDesign.test_create(false, false);     
     102      int adId = TestArrayDesign.test_create(Platform.GENERIC, false);     
    103103      ArrayDesign ad = ArrayDesign.getById(dc, adId);
    104104      Project p = Project.getById(dc, id);
  • trunk/src/test/TestRawBioAssay.java

    r3679 r3820  
    5353    int hybridizationId = TestHybridization.test_create(0, false);
    5454    int scanId = TestScan.test_create(hybridizationId, 0, 0, false);
    55     int arrayDesignId = TestArrayDesign.test_create(false, false);
     55    int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false);
    5656    TestReporter.test_import_from_file("data/test.rawdata.import.txt",
    5757      "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", "\\t", 4, 3);
     
    6262   
    6363    // Standard tests: create, load, list
    64     int id = test_create("genepix", scanId, softwareId, protocolId, arrayDesignId, true);
    65     int id2 = test_create("genepix", 0, 0, 0, 0, false);
     64    int id = test_create(Platform.GENERIC, "genepix", scanId, softwareId, protocolId, arrayDesignId, true);
     65    int id2 = test_create(Platform.GENERIC, "genepix", 0, 0, 0, 0, false);   
     66    int id3 = test_create(Platform.AFFYMETRIX, null, 0, 0, 0, 0, false);
    6667   
    6768    test_load(id);
    6869   
    69     // Test adding raw data
    70    
     70    // Test adding raw data -- stored in database
    7171    test_add_rawdata(id2, 10);
    7272    test_import_from_file(id, "data/test.rawdata.import.txt");
    73    
    7473    test_load(id);
    75    
    7674    test_list(-1);
    7775    write_raw_data_header();
    7876    test_list_raw_data(id, 10, 5, 0, true);
    7977   
     78    // Test adding raw data -- stored in files
     79    int celId = TestFile.test_create("data/test.affymetrix.cel", false, false);
     80    test_set_file(id3, "affymetrix.cel", celId);
     81    test_list_files(id3, 1);
     82    test_list_file_types(id3, 1);
     83   
    8084    if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter();
    8185    test_delete_raw_data(id);
     
    8488    test_delete(id);
    8589    test_delete(id2);
    86 
     90    test_delete(id3);
     91
     92    TestFile.test_delete(celId);
    8793    TestScan.test_delete(scanId);
    8894    TestHybridization.test_delete(hybridizationId);
     
    95101  }
    96102
    97   static int test_create(String rawDataType, int scanId, int softwareId, int protocolId, int arrayDesignId, boolean setAll)
     103  static int test_create(String platformId, String rawDataType, int scanId, int softwareId, int protocolId, int arrayDesignId, boolean setAll)
    98104  {
    99105    if (!TestUtil.hasPermission(Permission.CREATE, Item.RAWBIOASSAY)) return 0;
     
    103109    {
    104110      dc = TestUtil.getDbControl();
    105       RawBioAssay rba = RawBioAssay.getNew(dc, RawDataTypes.getRawDataType(rawDataType));
     111      Platform platform = Platform.getByExternalId(dc, platformId);
     112      RawBioAssay rba = RawBioAssay.getNew(dc, platform, RawDataTypes.getRawDataType(rawDataType));
    106113      if (setAll)
    107114      {
     
    234241    if (!TestUtil.getSilent())
    235242    {
    236       write("   \tID \tName      \tDescription\tData type\tSpots\tBytes\tArray Design\tSoftware\tProtocol");
    237       write("-- \t-- \t--------- \t-----------\t---------\t-----\t-----\t------------\t--------\t--------");
     243      write("   \tID \tName      \tDescription\tData type\tDb spots\tFile spots\tBytes\tArray Design\tSoftware\tProtocol");
     244      write("-- \t-- \t--------- \t-----------\t---------\t--------\t-----------\t-----\t------------\t--------\t--------");
    238245    }
    239246  }
     
    252259    {
    253260      System.out.println(i+":\t"+rba.getId()+"\t"+rba.getName()+"\t"+rba.getDescription()+
    254         "\t"+rba.getRawDataType().getName()+"\t"+rba.getSpots()+"\t"+rba.getBytes()+"\t"+rba.getArrayDesign()+
     261        "\t"+rba.getRawDataType().getName()+"\t"+rba.getNumDbSpots()+"\t"+rba.getNumFileSpots() +
     262        "\t"+rba.getBytes()+"\t"+rba.getArrayDesign()+
    255263        "\t"+rba.getSoftware()+"\t"+rba.getProtocol());
    256264    }
     
    268276    }
    269277  }
     278 
     279  static void write_item(int i, FileSetMember member)
     280    throws BaseException
     281  {
     282    if (!TestUtil.getSilent())
     283    {
     284      System.out.println(i+":\t"+member.getId()+"\t"+member.getFile().getName()+"\t"+
     285        member.getDataFileType().getName());
     286    }
     287  }
     288 
     289  static void write_item(int i, DataFileType type)
     290    throws BaseException
     291  {
     292    if (!TestUtil.getSilent())
     293    {
     294      System.out.println(i+":\t"+type.getId()+"\t"+type.getName()+"\t"+
     295        type.getDescription());
     296    }
     297  }
     298
    270299 
    271300  static void write(String message)
     
    500529  }
    501530
     531  static void test_set_file(int rawBioAssayId, String fileType, int fileId)
     532  {
     533    if (rawBioAssayId == 0 || fileId == 0) return;
     534    DbControl dc = null;
     535    try
     536    {
     537      dc = TestUtil.getDbControl();
     538      RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId);
     539      DataFileType type = DataFileType.getByExternalId(dc, fileType);
     540      File file = File.getById(dc, fileId);
     541      rba.getFileSet().setMember(file, type);
     542      dc.commit();
     543      write("--Set file OK ("+fileType+")");
     544    }
     545    catch (Throwable ex)
     546    {
     547      write("--Set file FAILED ("+fileType+")");
     548      ex.printStackTrace();
     549      ok = false;
     550    }
     551    finally
     552    {
     553      if (dc != null) dc.close();
     554    }
     555  }
     556 
     557  static void test_list_files(int rawBioAssayId, int expectedResults)
     558  {
     559    if (rawBioAssayId == 0) return;
     560    DbControl dc = null;
     561    try
     562    {
     563      dc = TestUtil.getDbControl();
     564      RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId);
     565      ItemResultList<FileSetMember> l = rba.getFileSet().getMembers().list(dc);
     566      for (int i = 0; i<l.size(); i++)
     567      {
     568        write_item(i, l.get(i));
     569      }
     570      if (expectedResults >= 0 && expectedResults != l.size())
     571      {
     572        throw new BaseException("Expected "+expectedResults+" results, not "+l.size());
     573      }
     574      write("--List files OK ("+l.size()+")");
     575    }
     576    catch (Throwable ex)
     577    {
     578      write("--List files FAILED");
     579      ex.printStackTrace();
     580      ok = false;
     581    }
     582    finally
     583    {
     584      if (dc != null) dc.close();
     585    }
     586  }
     587 
     588  static void test_list_file_types(int rawBioAssayId, int expectedResults)
     589  {
     590    if (rawBioAssayId == 0) return;
     591    DbControl dc = null;
     592    try
     593    {
     594      dc = TestUtil.getDbControl();
     595      RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId);
     596      ItemResultList<DataFileType> l = rba.getFileSet().getMemberTypes().list(dc);
     597      for (int i = 0; i<l.size(); i++)
     598      {
     599        write_item(i, l.get(i));
     600      }
     601      if (expectedResults >= 0 && expectedResults != l.size())
     602      {
     603        throw new BaseException("Expected "+expectedResults+" results, not "+l.size());
     604      }
     605      write("--List file types OK ("+l.size()+")");
     606    }
     607    catch (Throwable ex)
     608    {
     609      write("--List file types FAILED");
     610      ex.printStackTrace();
     611      ok = false;
     612    }
     613    finally
     614    {
     615      if (dc != null) dc.close();
     616    }
     617  }
    502618}
  • trunk/src/test/TestRawDataFlatFileImporter.java

    r3719 r3820  
    4545    TestReporter.test_import_from_file("data/test.rawdata.import.txt", "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", "\\t", 4, 3);
    4646    int fileId = TestFile.test_create("data/test.rawdata.import.txt", false, false);
    47     int arrayDesignId = TestArrayDesign.test_create(false, false);
     47    int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false);
    4848    TestArrayDesign.test_import_from_file(arrayDesignId, "data/test.rawdata.import.txt", "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", 0, 2, 1, 4);
    49     int rawBioAssayId = TestRawBioAssay.test_create("genepix", 0, 0, 0, arrayDesignId, true);
     49    int rawBioAssayId = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, arrayDesignId, true);
    5050   
    5151    // Create plugin configuration and job
  • trunk/src/test/TestReporterMapFlatFileImporter.java

    r3719 r3820  
    3232import net.sf.basedb.core.ParameterType;
    3333import net.sf.basedb.core.Permission;
     34import net.sf.basedb.core.Platform;
    3435import net.sf.basedb.core.PluginConfiguration;
    3536import net.sf.basedb.core.PluginDefinition;
     
    6162    // Create reporter type and upload file
    6263    int reporterTypeId = TestReporterType.test_create();
    63     int arrayDesignId = TestArrayDesign.test_create(false, false);
     64    int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false);
    6465    int fileId = TestFile.test_create("data/test.reportermap.import.txt", false, false);
    6566   
  • trunk/src/test/TestSpotImages.java

    r3719 r3820  
    6161    write("++Testing spot images import");
    6262   
    63     int rawBioAssayId = TestRawBioAssay.test_create("genepix", 0, 0, 0, 0, false);
     63    int rawBioAssayId = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", 0, 0, 0, 0, false);
    6464    TestReporter.test_import_from_file("data/test.rawdata.import.txt", "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", "\\t", 4, 3);
    6565    TestRawBioAssay.test_import_from_file(rawBioAssayId, "data/test.rawdata.import.txt");
  • trunk/src/test/net/sf/basedb/test/merge/MergeTest.java

    r2938 r3820  
    4646import net.sf.basedb.core.Job;
    4747import net.sf.basedb.core.MappingBatcher;
     48import net.sf.basedb.core.Platform;
    4849import net.sf.basedb.core.PluginDefinition;
    4950import net.sf.basedb.core.PositionBatcher;
     
    104105      // Array design
    105106      dc = TestUtil.getDbControl();
    106       ArrayDesign design = createArrayDesign(dc, "Array design for merge test");
     107      Platform generic = Platform.getByExternalId(dc, Platform.GENERIC);
     108      ArrayDesign design = createArrayDesign(dc, generic, "Array design for merge test");
    107109      dc.commit();
    108110     
     
    113115      // Raw bioassays
    114116      dc = TestUtil.getDbControl();
    115       RawBioAssay rba1 = createRawBioAssay(dc, "Raw bioassay for merge test #1", design);
    116       RawBioAssay rba2 = createRawBioAssay(dc, "Raw bioassay for merge test #2", design);
     117      RawDataType genepix = RawDataTypes.getRawDataType("genepix");
     118      RawBioAssay rba1 = createRawBioAssay(dc, generic, genepix, "Raw bioassay for merge test #1", design);
     119      RawBioAssay rba2 = createRawBioAssay(dc, generic, genepix, "Raw bioassay for merge test #2", design);
    117120      dc.commit();
    118121     
     
    182185    Create an array design.
    183186  */
    184   public static ArrayDesign createArrayDesign(DbControl dc, String name)
     187  public static ArrayDesign createArrayDesign(DbControl dc, Platform platform, String name)
    185188  {
    186189    TestUtil.write("--Creating array design: " + name + "\n");
    187     ArrayDesign design = ArrayDesign.getNew(dc, false);
     190    ArrayDesign design = ArrayDesign.getNew(dc, platform);
    188191    design.setName(name);
    189192   
     
    220223    Create a raw bioassay.
    221224  */
    222   public static RawBioAssay createRawBioAssay(DbControl dc, String name, ArrayDesign design)
     225  public static RawBioAssay createRawBioAssay(DbControl dc, Platform platform, RawDataType rawDataType, String name, ArrayDesign design)
    223226  {
    224227    TestUtil.write("--Creating raw bioassay: " + name + "\n");
    225     RawBioAssay rba = RawBioAssay.getNew(dc, RawDataTypes.getRawDataType("genepix"));
     228    RawBioAssay rba = RawBioAssay.getNew(dc, platform, rawDataType);
    226229    rba.setName(name);
    227230    rba.setArrayDesign(design);
  • trunk/src/test/net/sf/basedb/test/performance/PrepareTest.java

    r3675 r3820  
    3838import net.sf.basedb.core.ItemQuery;
    3939import net.sf.basedb.core.Job;
     40import net.sf.basedb.core.Platform;
    4041import net.sf.basedb.core.PluginConfiguration;
    4142import net.sf.basedb.core.ProgressReporter;
     
    8788      dc = TestUtil.getDbControl();
    8889
     90      // We use the GENERIC platform
     91      Platform generic = Platform.getByExternalId(dc, Platform.GENERIC);
     92     
    8993      // Create experiment
    9094      experiment = Util.findExperiment(dc, "PerformanceTest");
     
    98102      if (design == null)
    99103      {
    100         design = Util.createArrayDesign(dc, "PerformanceTest");
     104        design = Util.createArrayDesign(dc, generic, "PerformanceTest");
    101105      }   
    102106     
  • trunk/src/test/net/sf/basedb/test/performance/RawDataTest.java

    r3675 r3820  
    3131import net.sf.basedb.core.ItemParameterType;
    3232import net.sf.basedb.core.Job;
     33import net.sf.basedb.core.Platform;
    3334import net.sf.basedb.core.PluginConfiguration;
    3435import net.sf.basedb.core.RawBioAssay;
     36import net.sf.basedb.core.RawDataType;
    3537import net.sf.basedb.core.RawDataTypes;
    3638import net.sf.basedb.core.StringParameterType;
     
    6466      // Create raw bioassays
    6567      dc = TestUtil.getDbControl();
     68      Platform generic = Platform.getByExternalId(dc, Platform.GENERIC);
     69      RawDataType genepix = RawDataTypes.getRawDataType("genepix");
    6670     
    6771      // Load prepared items
     
    7680      for (int i = 0; i < numIterations; ++i)
    7781      {
    78         rba[i] = createRawBioAssay(dc, "PerformanceTest #" + (startNum + i), design);
     82        rba[i] = createRawBioAssay(dc, generic, genepix, "PerformanceTest #" + (startNum + i), design);
    7983      }
    8084      dc.commit();
     
    134138    Create a raw bioassay.
    135139  */
    136   public static RawBioAssay createRawBioAssay(DbControl dc, String name, ArrayDesign design)
     140  public static RawBioAssay createRawBioAssay(DbControl dc, Platform platform, RawDataType rawDataType, String name, ArrayDesign design)
    137141  {
    138142    TestUtil.write("--Creating raw bioassay: " + name + "\n");
    139     RawBioAssay rba = RawBioAssay.getNew(dc, RawDataTypes.getRawDataType("genepix"));
     143    RawBioAssay rba = RawBioAssay.getNew(dc, platform, rawDataType);
    140144    rba.setName(name);
    141145    rba.setArrayDesign(design);
  • trunk/src/test/net/sf/basedb/test/performance/Util.java

    r3675 r3820  
    3333import net.sf.basedb.core.Include;
    3434import net.sf.basedb.core.ItemQuery;
     35import net.sf.basedb.core.Platform;
    3536import net.sf.basedb.core.RawDataType;
    3637import net.sf.basedb.core.RawDataTypes;
     
    8990    Create an array design.
    9091  */
    91   public static ArrayDesign createArrayDesign(DbControl dc, String name)
     92  public static ArrayDesign createArrayDesign(DbControl dc, Platform platform, String name)
    9293  {
    9394    TestUtil.write("--Creating array design: " + name + "\n");
    94     ArrayDesign design = ArrayDesign.getNew(dc, false);
     95    ArrayDesign design = ArrayDesign.getNew(dc, platform);
    9596    design.setName(name);
    9697    dc.saveItem(design);
  • trunk/src/test/net/sf/basedb/test/roles/PowerUserTest.java

    r3675 r3820  
    4848import net.sf.basedb.core.PlateGeometry;
    4949import net.sf.basedb.core.PlateType;
     50import net.sf.basedb.core.Platform;
    5051import net.sf.basedb.core.PluginConfiguration;
    5152import net.sf.basedb.core.PluginDefinition;
     
    7576  <li>Create file formats for import:
    7677  <li>Import plates:
    77   <li>Create array design: {@link #createArrayDesign(DbControl, String)}
     78  <li>Create array design: {@link #createArrayDesign(DbControl, Platform, String)}
    7879  <li>Import features:
    7980  <li>Create array batch: {@link #createArrayBatch(DbControl, String, ArrayDesign, Hardware, Protocol)}
     
    156157     
    157158      dc = TestUtil.getDbControl();
    158       ArrayDesign design = createArrayDesign(dc, "Array design A");
     159      Platform generic = Platform.getByExternalId(dc, Platform.GENERIC);
     160      ArrayDesign design = createArrayDesign(dc, generic, "Array design A");
    159161      dc.commit();
    160162
     
    283285    Create an array design.
    284286  */
    285   public static ArrayDesign createArrayDesign(DbControl dc, String name)
     287  public static ArrayDesign createArrayDesign(DbControl dc, Platform platform, String name)
    286288  {
    287289    TestUtil.write("--Creating array design: " + name + "\n");
    288     ArrayDesign design = ArrayDesign.getNew(dc, false);
     290    ArrayDesign design = ArrayDesign.getNew(dc, platform);
    289291    design.setName(name);
    290292   
  • trunk/src/test/net/sf/basedb/test/roles/UserTest.java

    r2938 r3820  
    4242import net.sf.basedb.core.Label;
    4343import net.sf.basedb.core.LabeledExtract;
     44import net.sf.basedb.core.Platform;
    4445import net.sf.basedb.core.PluginConfiguration;
    4546import net.sf.basedb.core.Project;
    4647import net.sf.basedb.core.RawBioAssay;
     48import net.sf.basedb.core.RawDataType;
    4749import net.sf.basedb.core.RawDataTypes;
    4850import net.sf.basedb.core.Sample;
     
    121123     
    122124      // Raw bioassays
    123       RawBioAssay rba1 = createRawBioAssay(dc, "Raw bioassay A.00h", sc1);
    124       RawBioAssay rba2 = createRawBioAssay(dc, "Raw bioassay A.24h", sc2);
    125       RawBioAssay rba1DyeSwap = createRawBioAssay(dc, "Raw bioassay A.00h (dye-swap)", sc1DyeSwap);
    126       RawBioAssay rba2DyeSwap = createRawBioAssay(dc, "Raw bioassay A.24h (dye-swap)", sc2DyeSwap);
     125      Platform generic = Platform.getByExternalId(dc, Platform.GENERIC);
     126      RawDataType genepix = RawDataTypes.getRawDataType("genepix");
     127      RawBioAssay rba1 = createRawBioAssay(dc, generic, genepix, "Raw bioassay A.00h", sc1);
     128      RawBioAssay rba2 = createRawBioAssay(dc, generic, genepix, "Raw bioassay A.24h", sc2);
     129      RawBioAssay rba1DyeSwap = createRawBioAssay(dc, generic, genepix, "Raw bioassay A.00h (dye-swap)", sc1DyeSwap);
     130      RawBioAssay rba2DyeSwap = createRawBioAssay(dc, generic, genepix, "Raw bioassay A.24h (dye-swap)", sc2DyeSwap);
    127131      inheritAnnotations(dc, rba1, s1, bioSource);
    128132      inheritAnnotations(dc, rba2, s2, bioSource);
     
    281285    Create a raw bioassay.
    282286  */
    283   public static RawBioAssay createRawBioAssay(DbControl dc, String name, Scan scan)
     287  public static RawBioAssay createRawBioAssay(DbControl dc, Platform platform, RawDataType rawDataType, String name, Scan scan)
    284288  {
    285289    TestUtil.write("--Creating raw bioassay: " + name + "\n");
    286     RawBioAssay rba = RawBioAssay.getNew(dc, RawDataTypes.getRawDataType("genepix"));
     290    RawBioAssay rba = RawBioAssay.getNew(dc, platform, rawDataType);
    287291    rba.setName(name);
    288292    rba.setScan(scan);
  • trunk/www/include/menu.jsp

    r3679 r3820  
    666666    }
    667667    %>
     668    <%
     669    // Administrate -> Platforms menu
     670    final boolean hasPlatforms = sc.hasPermission(Permission.READ, Item.PLATFORM);
     671    final boolean hasFileSetMemberTypes = sc.hasPermission(Permission.READ, Item.DATAFILETYPE);
     672    final boolean hasTopPlatforms = hasPlatforms || hasFileSetMemberTypes;
     673    if (hasTopPlatforms)
     674    {
     675      %>
     676      <m:menu
     677        id="platforms"
     678        style="display: none"
     679        >
     680        <m:menuitem
     681          title="Experimental platforms"
     682          onclick="<%="Menu.openUrl('"+root+"admin/platforms/index.jsp?ID="+ID+"')"%>"
     683          tooltip="<%=hasPlatforms ? "Administrate experimental platforms" : "You do not have permission to administrate experimental platforms"%>"
     684          enabled="<%=hasPlatforms%>"
     685        />
     686        <m:menuitem
     687          title="Data file types"
     688          onclick="<%="Menu.openUrl('"+root+"admin/datafiletypes/index.jsp?ID="+ID+"')"%>"
     689          tooltip="<%=hasFileSetMemberTypes ? "Administrate data file types" : "You do not have permission to administrate data file types"%>"
     690          enabled="<%=hasFileSetMemberTypes%>"
     691        />
     692      </m:menu>
     693      <%
     694    }
     695    %>
    668696   
    669697    <%
     
    731759      hasUsers || hasGroups || hasRoles || hasQuota || hasTypes || hasPlugins ||
    732760      hasSoftware || hasHardware || hasProtocols || hasClients || hasNews ||
    733       hasDiskUsage || hasServer;
     761      hasDiskUsage || hasServer || hasTopPlatforms;
    734762
    735763    if (hasAdministrate)
     
    803831        />
    804832        <m:menuseparator />
     833        <m:submenu
     834          subid="platforms"
     835          title="Platforms"
     836          tooltip="Administrate experimental platforms"
     837          enabled="<%=hasTopPlatforms%>"
     838        />
    805839        <m:submenu
    806840          subid="types"
  • trunk/www/include/scripts/main.js

    r3719 r3820  
    263263    var regExp = new RegExp(className);
    264264    obj.className = obj.className.replace(className, '');
     265  }
     266 
     267  this.addOrRemoveClass = function(obj, className, addIfTrue)
     268  {
     269    if (addIfTrue)
     270    {
     271      this.addClass(obj, className);
     272    }
     273    else
     274    {
     275      this.removeClass(obj, className);
     276    }
    265277  }
    266278 
     
    425437    this.controllers['EXTRAVALUETYPE'] = { url:'admin/extravaluetypes/index.jsp', width:500, height:360 };
    426438    this.controllers['EXTRAVALUE'] = { url:'views/experiments/extravalues/index.jsp', width:500, height:340, edit:false };
     439    this.controllers['PLATFORM'] = { url:'admin/platforms/index.jsp', width:540, height:400 };
     440    this.controllers['PLATFORMVARIANT'] = { url:'admin/platforms/variants/index.jsp', width:540, height:400 };
     441    this.controllers['DATAFILETYPE'] = { url:'admin/datafiletypes/index.jsp', width:600, height:480 };
    427442  }
    428443 
     
    10911106  this.isInteger = function(value)
    10921107  {
    1093     return (value.search(/^\d+$/) != -1);
     1108    return (value.search(/^\-?\d+$/) != -1);
    10941109  }
    10951110
  • trunk/www/include/styles/main.css

    r3719 r3820  
    168168  background: #D0F0FF;
    169169}
    170 
     170input.unchangeable, select.unchangeable, textarea.unchangeable {
     171  background: #FFF0D0;
     172}
    171173a.disabled {
    172174  color: #666666;
     
    205207.selectoptionheader, .defaultheader {
    206208    font-weight: bold;
     209}
     210
     211.selectoptionindent {
     212  padding-left: 1em;
    207213}
    208214
  • trunk/www/lims/arraydesigns/edit_design.jsp

    r3679 r3820  
    3535  import="net.sf.basedb.core.ArrayDesign"
    3636  import="net.sf.basedb.core.File"
    37   import="net.sf.basedb.core.Affymetrix"
     37  import="net.sf.basedb.core.Platform"
     38  import="net.sf.basedb.core.PlatformVariant"
     39  import="net.sf.basedb.core.RawDataType"
    3840  import="net.sf.basedb.core.ItemQuery"
    3941  import="net.sf.basedb.core.ItemResultList"
     
    6567  ArrayDesign design = null;
    6668 
    67   boolean readCurrentCdfFile = true;
    68   File currentCdfFile = null;
    69 
    70   // Load recently used items
    71   List<File> recentFiles = (List<File>)cc.getRecent(dc, Item.FILE);
     69  boolean deniedPlatform = false;
     70  Platform currentPlatform = null;
     71  PlatformVariant currentVariant = null;
    7272 
    7373  if (itemId == 0)
     
    8282    title = "Edit array design -- " + HTML.encodeTags(design.getName());
    8383   
    84     if (design.isAffyChip())
    85     {
    86       try
    87       {
    88         currentCdfFile = Affymetrix.getCdfFile(design);
    89       }
    90       catch (PermissionDeniedException ex)
    91       {
    92         readCurrentCdfFile = false;
    93       }
    94     }
     84    try
     85    {
     86      currentPlatform = design.getPlatform();
     87      currentVariant = design.getVariant();
     88    }
     89    catch (PermissionDeniedException ex)
     90    {
     91      deniedPlatform = true;
     92    }
     93    design.checkPermission(Permission.WRITE);
    9594  }
    96   if (design != null && !design.hasPermission(Permission.WRITE))
    97   {
    98     throw new PermissionDeniedException(Permission.WRITE, itemType.toString());
    99   }
     95
     96  ItemQuery<Platform> platformQuery = Platform.getQuery();
     97  platformQuery.order(Orders.asc(Hql.property("name")));
     98  platformQuery.setCacheResult(true);
     99  ItemResultList<Platform> platforms = platformQuery.list(dc);
     100
     101  ItemQuery<PlatformVariant> variantQuery = PlatformVariant.getQuery();
     102  variantQuery.order(Orders.asc(Hql.property("name")));
     103  variantQuery.setCacheResult(true);
     104  ItemResultList<PlatformVariant> variants = variantQuery.list(dc);
     105 
    100106  final String clazz = "class=\"text\"";
    101107  final String requiredClazz = "class=\"text required\"";
     
    103109
    104110  <base:page type="popup" title="<%=title%>">
    105   <base:head scripts="tabcontrol.js,annotations.js" styles="tabcontrol.css">
     111  <base:head scripts="tabcontrol.js,annotations.js,platforms.js" styles="tabcontrol.css">
    106112    <script language="JavaScript">
    107113    // Validate the "ArrayDesign" tab
     
    132138          Annotations.addInheritedAnnotationsToForm(frames.inheritedAnnotations, frm);
    133139        }
     140        if (dataFilesLoaded)
     141        {
     142          Platforms.addDataFilesToForm(frames.datafiles, frm);
     143        }
    134144        frm.submit();
    135145      }
     
    139149    var inheritedAnnotationsLoaded = false;
    140150    var parentsChanged = false;
     151    var dataFilesLoaded = false;
     152    var platformChanged = false;
    141153    function switchTab(tabControlId, tabId)
    142154    {
     155      var frm = document.forms['design'];
    143156      if (TabControl.setActiveTab(tabControlId, tabId))
    144157      {
     
    155168          parentsChanged = false;
    156169        }
     170        else if (tabId == 'datafiles' && (platformChanged || !dataFilesLoaded))
     171        {
     172          var platform = Platforms.getSelectedPlatform(frm.platform);
     173          var variant = Platforms.getSelectedVariant(frm.platform);
     174          Platforms.loadDataFilesFrame(frames.datafiles, '<%=ID%>', '<%=itemType.name()%>', <%=design == null ? 0 : design.getId()%>, platform == null ? 0 : platform.id, variant == null ? 0 : variant.id);
     175          dataFilesLoaded = true;
     176          platformChanged = false;
     177        }
    157178      }
    158179    }
     
    162183      return new Array();
    163184    }
    164 
    165     function selectFileOnClick()
    166     {
    167       var frm = document.forms['design'];
    168       if (frm.affy_chip && !frm.affy_chip.checked)
    169       {
    170         if (!confirm('CDF-files are only used for Affymetrix chips.\nDo you want to activate the checkbox'))
    171         {
    172           return;
    173         }
    174         frm.affy_chip.checked = true;
    175       }
    176       var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SelectOne&callback=setFileCallback';
    177       if (frm.cdffile_id.length > 1)
    178       {
    179         var id = Math.abs(parseInt(frm.cdffile_id[1].value));       
    180         url += '&item_id='+id;
    181       }
    182       url += '&filter:STRING:name=%25.cdf';
    183       Main.openPopup(url, 'SelectFile', 1000, 700);
    184     }
    185     function setFileCallback(id, name)
    186     {
    187       var frm = document.forms['design'];
    188       var list = frm.cdffile_id;
    189       if (list.length < 2 || list[1].value == '0') // >
    190       {
    191         Forms.addListOption(list, 1, new Option());
    192       }
    193       list[1].value = id;
    194       list[1].text = name;
    195       list.selectedIndex = 1;
    196     }
    197 
    198     function affyChipOnClick()
    199     {
    200       var frm = document.forms['design'];
    201       if (!frm.affy_chip.checked)
    202       {
    203         frm.cdffile_id.selectedIndex = 0;
    204       }
    205       else if (frm.cdffile_id.length > 1)
    206       {
    207         frm.cdffile_id.selectedIndex = 1;
    208       }
     185   
     186    function platformOnChange()
     187    {
     188      platformChanged = true;
    209189    }
    210190
     
    221201      }
    222202      %>
     203      initPlatforms(<%=currentPlatform == null ? 0 : currentPlatform.getId()%>, <%=currentVariant == null ? 0 : currentVariant.getId()%>);
     204    }
     205   
     206    function initPlatforms(platformId, variantId)
     207    {
     208      <%
     209      for (Platform p : platforms)
     210      {
     211        RawDataType rdt = p.isFileOnly() ? null : p.getRawDataType();
     212        %>
     213        var p<%=p.getId()%> = new Platform(<%=p.getId()%>, '<%=HTML.javaScriptEncode(p.getExternalId())%>', '<%=HTML.javaScriptEncode(p.getName())%>', <%=p.isFileOnly()%>, '<%=rdt == null ? "" : rdt.getId()%>');
     214        <%
     215      }
     216      for (PlatformVariant v : variants)
     217      {
     218        RawDataType rdt = v.isFileOnly() ? null : v.getRawDataType();
     219        Platform p = v.getPlatform();
     220        %>
     221        var v<%=v.getId()%> = new Variant(p<%=p.getId()%>, <%=v.getId()%>, '<%=HTML.javaScriptEncode(v.getExternalId())%>', '<%=HTML.javaScriptEncode(v.getName())%>', <%=v.isFileOnly()%>, '<%=rdt == null ? "" : rdt.getId()%>');
     222        <%
     223      }
     224      %>
     225      var frm = document.forms['design'];
     226      Platforms.populateList(frm.platform, platformId, variantId);
    223227    }
    224228    </script>
     
    241245      </tr>
    242246      <tr>
    243         <td class="prompt">Affy chip</td>
     247        <td class="prompt">Platform</td>
    244248        <td>
     249          <select name="platform" onchange="platformOnChange()" class="required"
     250            <%=deniedPlatform ? "disabled" : "" %>>
    245251          <%
    246           if (design != null)
     252          if (deniedPlatform)
    247253          {
    248254            %>
    249             <%=design.isAffyChip() ? "yes" : "no"%>
    250             <%
    251           }
    252           else
    253           {
    254             %>
    255             <input type="checkbox" name="affy_chip" value="1"
    256               onclick="affyChipOnClick()"
    257               <%=Values.getBoolean(cc.getPropertyValue("affyChip")) ? "checked" : ""%>>
    258               (can't be changed later)
     255            <option value="-1">- denied -
    259256            <%
    260257          }
    261258          %>
     259          </select>
    262260        </td>
    263261      </tr>
    264       <%
    265       if (design == null || design.isAffyChip())
    266       {
    267         %>
    268         <tr id="cdfFile">
    269           <td class="prompt">CDF file</td>
    270           <td>
    271             <base:select
    272               id="cdffile_id"
    273               clazz="selectionlist"
    274               required="false"
    275               current="<%=currentCdfFile%>"
    276               denied="<%=!readCurrentCdfFile%>"
    277               recent="<%=recentFiles%>"
    278               newitem="<%=design == null%>"
    279               onselect="selectFileOnClick()"
    280             />
    281           </td>
    282         </tr>
    283         <%
    284       }
    285       %>
    286262      <tr valign=top>
    287263        <td class="prompt">Description</td>
     
    295271      </table>
    296272      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
     273    </t:tab>
     274
     275    <t:tab id="datafiles" title="Data files" helpid="datafiles.edit">
     276      <iframe name="datafiles" id="idDatafiles" src="../../common/datafiles/wait.jsp"
     277        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
     278        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
    297279    </t:tab>
    298280   
  • trunk/www/lims/arraydesigns/index.jsp

    r3741 r3820  
    3434  import="net.sf.basedb.core.ArrayDesign"
    3535  import="net.sf.basedb.core.Affymetrix"
     36  import="net.sf.basedb.core.Platform"
     37  import="net.sf.basedb.core.PlatformVariant"
    3638  import="net.sf.basedb.core.Plate"
    3739  import="net.sf.basedb.core.File"
    3840  import="net.sf.basedb.core.FileType"
     41  import="net.sf.basedb.core.FileSet"
     42  import="net.sf.basedb.core.Path"
     43  import="net.sf.basedb.core.DataFileType"
    3944  import="net.sf.basedb.core.ItemQuery"
    4045  import="net.sf.basedb.core.ItemResultIterator"
     
    6065<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
    6166<%!
    62   private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,affyChip,numFeatures,description");
     67  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,platform,numDbFeatures,numFileFeatures,description");
    6368  private static final Item itemType = Item.ARRAYDESIGN;
    6469%>
     
    135140    dc = sc.newDbControl();
    136141    ArrayDesign design = (ArrayDesign)cc.getObject("item");
     142   
     143    String[] pv = request.getParameter("platform").split(":");
     144    int platformId = Values.getInt(pv[0], -1);
     145    int variantId = pv.length > 1 ? Values.getInt(pv[1], -1) : -1;
     146    Platform platform = platformId > 0 ? Platform.getById(dc, platformId) : null;
     147    PlatformVariant variant = variantId > 0 ? PlatformVariant.getById(dc, variantId) : null;
    137148    if (design == null)
    138149    {
    139       boolean isAffy = Values.getBoolean(request.getParameter("affy_chip"));
    140       design = ArrayDesign.getNew(dc, isAffy);
     150      if (variant != null)
     151      {
     152        design = ArrayDesign.getNew(dc, variant);
     153      }
     154      else
     155      {
     156        design = ArrayDesign.getNew(dc, platform);
     157      }
    141158      message = "Array design created";
    142159      dc.saveItem(design);
     
    145162    {
    146163      dc.reattachItem(design);
     164      if (variant != null)
     165      {
     166        design.setVariant(variant);
     167      }
     168      else
     169      {
     170        design.setPlatform(platform);
     171      }
    147172      message = "Array design updated";
    148173    }
    149174    design.setName(Values.getStringOrNull(request.getParameter("name")));
    150175    design.setDescription(Values.getStringOrNull(request.getParameter("description")));
    151     if (design.isAffyChip())
    152     {
    153       int cdfFileId = Values.getInt(request.getParameter("cdffile_id"), -1);
    154       if (cdfFileId >= 0) // < 0 = denied or unchanged
    155       {
    156         File cdfFile = cdfFileId == 0 ? null : File.getById(dc, cdfFileId);
    157         Affymetrix.setCdfFile(design, cdfFile);
    158         if (cdfFile != null) cc.setRecent(cdfFile, maxRecent);
    159       }
    160     }
    161 
     176
     177    // Data files tab
     178    boolean validate = Values.getBoolean(request.getParameter("datafiles.validate"));
     179    boolean metadata = Values.getBoolean(request.getParameter("datafiles.metadata"));
     180    Base.updateFiles(dc, design, request, validate, metadata, cc, maxRecent);
     181   
    162182    // Annotations tab
    163183    Base.updateAnnotations(dc, design, design, request);
  • trunk/www/lims/arraydesigns/list_designs.jsp

    r3741 r3820  
    3333  import="net.sf.basedb.core.ArrayBatch"
    3434  import="net.sf.basedb.core.Affymetrix"
     35  import="net.sf.basedb.core.Platform"
     36  import="net.sf.basedb.core.PlatformVariant"
    3537  import="net.sf.basedb.core.File"
    3638  import="net.sf.basedb.core.AnnotationType"
     
    9597  final boolean createBatchPermission = sc.hasPermission(Permission.CREATE, Item.ARRAYBATCH);   
    9698
     99  // Get all platforms
     100  final ItemQuery<Platform> platformQuery = Platform.getQuery();
     101  platformQuery.order(Orders.asc(Hql.property("name")));
     102  platformQuery.setCacheResult(true);
     103  Enumeration<String, String> platforms = new Enumeration<String, String>();
     104  for (Platform p : platformQuery.list(dc))
     105  {
     106    platforms.add(Integer.toString(p.getId()), p.getName());
     107  }
     108 
    97109  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
    98110  annotationTypes = annotationTypeQuery.list(dc);
     
    242254      />
    243255      <tbl:columndef
    244         id="affyChip"
    245         property="affyChip"
    246         datatype="boolean"
    247         title="Affy chip"
    248         sortable="true"
    249         filterable="true"
    250         exportable="true"
    251       />
    252       <tbl:columndef
    253         id="cdfFile"
    254         title="CDF file"
    255       />
    256       <tbl:columndef
    257256        id="hasFeatures"
    258257        property="hasFeatures"
     
    264263      />
    265264      <tbl:columndef
    266         id="numFeatures"
    267         property="numFeatures"
     265        id="numDbFeatures"
     266        property="numDbFeatures"
    268267        datatype="int"
    269         title="Num features"
     268        title="Db features"
    270269        sortable="true"
    271270        filterable="true"
    272271        exportable="true"
    273272      />
     273      <tbl:columndef
     274        id="numFileFeatures"
     275        property="numFileFeatures"
     276        datatype="int"
     277        title="File features"
     278        sortable="true"
     279        filterable="true"
     280        exportable="true"
     281      />
     282      <tbl:columndef
     283        id="platform"
     284        property="platform"
     285        sortproperty="platform.name"
     286        exportproperty="platform.name"
     287        datatype="int"
     288        enumeration="<%=platforms%>"
     289        title="Platform"
     290        sortable="true"
     291        filterable="true"
     292        exportable="true"
     293      /> 
     294      <tbl:columndef
     295        id="variant"
     296        property="variant.name"
     297        datatype="string"
     298        title="Variant"
     299        sortable="true"
     300        filterable="true"
     301        exportable="true"
     302      /> 
    274303      <tbl:columndef
    275304        id="batches"
     
    493522                  onclick="itemOnClick(<%=writePermission ? "event" : null%>, <%=itemId%>)"
    494523                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
    495                 <tbl:cell column="affyChip"><%=item.isAffyChip()%></tbl:cell>
    496                 <tbl:cell column="cdfFile">
    497                 <%
    498                 if (item.isAffyChip())
    499                 {
    500                   File cdfFile = null;
    501                   boolean readCdfFile = true;
    502                   try
    503                   {
    504                     cdfFile = Affymetrix.getCdfFile(item);
    505                   }
    506                   catch (PermissionDeniedException ex)
    507                   {
    508                     readCdfFile = false;
    509                   }
    510                   %>
    511                   <%=Base.getLinkedFile(ID, cdfFile, !readCdfFile, true, true, root)%>
    512                   <%
    513                 }
    514                 %>
    515                 </tbl:cell>
     524                <tbl:cell column="platform"
     525                  ><base:propertyvalue
     526                    item="<%=item%>"
     527                    property="platform"
     528                    enableEditLink="<%=mode.hasEditLink()%>"
     529                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
     530                  /></tbl:cell>
     531                <tbl:cell column="variant"
     532                  ><base:propertyvalue
     533                    item="<%=item%>"
     534                    property="variant"
     535                    enableEditLink="<%=mode.hasEditLink()%>"
     536                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
     537                  /></tbl:cell>
    516538                <tbl:cell column="hasFeatures"><%=item.hasFeatures() ? "yes" : "no"%></tbl:cell>
    517                 <tbl:cell column="numFeatures"><%=item.getNumFeatures()%></tbl:cell>
     539                <tbl:cell column="numDbFeatures"><%=item.getNumDbFeatures()%></tbl:cell>
     540                <tbl:cell column="numFileFeatures"><%=item.getNumFileFeatures()%></tbl:cell>
    518541                <tbl:cell column="batches">
    519542                  <%
  • trunk/www/lims/arraydesigns/view_design.jsp

    r3741 r3820  
    3636  import="net.sf.basedb.core.Permission"
    3737  import="net.sf.basedb.core.AnnotationType"
     38  import="net.sf.basedb.core.FileSet"
     39  import="net.sf.basedb.core.FileSetMember"
     40  import="net.sf.basedb.core.DataFileType"
    3841  import="net.sf.basedb.core.AnnotationSet"
    3942  import="net.sf.basedb.core.ArrayDesign"
     
    268271      </tr>
    269272      <tr>
    270         <td class="prompt">Affy chip</td>
    271         <td><%=design.isAffyChip() ? "yes" : "no"%></td>
     273        <td class="prompt">Platform</td>
     274        <td><base:propertyvalue item="<%=design%>" property="platform" /></td>
    272275      </tr>
    273       <%
    274       if (design.isAffyChip())
    275       {
    276         boolean readCurrentCdfFile = true;
    277         File currentCdfFile = null;
    278         try
    279         {
    280           currentCdfFile = Affymetrix.getCdfFile(design);
    281         }
    282         catch (PermissionDeniedException ex)
    283         {
    284           readCurrentCdfFile = false;
    285         }
    286         %>
    287         <tr>
    288           <td class="prompt">CDF file</td>
    289           <td>
    290             <%=Base.getLinkedFile(ID, currentCdfFile, !readCurrentCdfFile, true, true, root)%>
    291             <%
    292             if (currentCdfFile != null)
    293             {
    294               try
    295               {
    296                 PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.CdfFileReporterImporter");
    297                 %>
    298                 [<a href="javascript:verifyReporters()">verify reporters</a>]
    299                 <%
    300               }
    301               catch (Throwable t)
    302               {}
    303             }
    304             %>
    305           </td>
    306         </tr>
    307         <%
    308       }
    309       %>
     276      <tr>
     277        <td class="prompt">Variant</td>
     278        <td><base:propertyvalue item="<%=design%>" property="variant" /></td>
     279      </tr>
    310280      <tr>
    311281        <td class="prompt">Features</td>
    312         <td><%=design.hasFeatures() ? "yes (" + design.getNumFeatures() + ")" : "no"%></td>
     282        <td><%=design.hasFeatures() ? "yes (db: " + design.getNumDbFeatures() + "; file: " + design.getNumFileFeatures() + ")" : "no"%></td>
    313283      </tr>
    314284      <tr>
     
    321291      </tr>
    322292      </table>
     293     
     294     
     295      <jsp:include page="../../common/datafiles/list_files.jsp">
     296        <jsp:param name="item_type" value="<%=itemType.name()%>" />
     297        <jsp:param name="item_id" value="<%=itemId%>" />
     298        <jsp:param name="ID" value="<%=ID%>" />
     299      </jsp:include>
    323300     
    324301      <%
  • trunk/www/views/experiments/edit_experiment.jsp

    r3679 r3820  
    5454  import="net.sf.basedb.clients.web.util.HTML"
    5555  import="net.sf.basedb.util.Values"
     56  import="net.sf.basedb.util.Enumeration"
    5657  import="net.sf.basedb.util.formatter.Formatter"
    5758  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     
    152153        return false;
    153154      }
     155      if (frm.rawdatatype)
     156      {
     157        if (frm.rawdatatype[frm.rawdatatype.selectedIndex].value == '')
     158        {
     159          alert("You must select a raw data type");
     160          frm.rawdatatype.focus();
     161          return false;
     162        }
     163      }
    154164      return true;
    155165    }