Changeset 3835


Ignore:
Timestamp:
Oct 15, 2007, 2:26:21 PM (16 years ago)
Author:
Nicklas Nordborg
Message:

References #721. Updated documentation.

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/config/dist/ehcache.xml

    r3675 r3835  
    5757  />
    5858  <cache
     59    name="net.sf.basedb.core.data.DataFileTypeData"
     60    maxElementsInMemory="100"
     61    eternal="false"
     62    timeToIdleSeconds="3600"
     63    timeToLiveSeconds="3600"
     64    overflowToDisk="false"
     65  />
     66  <cache
    5967    name="net.sf.basedb.core.data.DirectoryData"
    6068    maxElementsInMemory="100"
     
    185193  />
    186194  <cache
     195    name="net.sf.basedb.core.data.PlatformData"
     196    maxElementsInMemory="100"
     197    eternal="false"
     198    timeToIdleSeconds="3600"
     199    timeToLiveSeconds="3600"
     200    overflowToDisk="false"
     201  />
     202  <cache
     203    name="net.sf.basedb.core.data.PlatformVariantData"
     204    maxElementsInMemory="100"
     205    eternal="false"
     206    timeToIdleSeconds="3600"
     207    timeToLiveSeconds="3600"
     208    overflowToDisk="false"
     209  />
     210  <cache
    187211    name="net.sf.basedb.core.data.PluginConfigurationData"
    188212    maxElementsInMemory="100"
  • trunk/config/dist/hibernate.cfg.xml

    r3675 r3835  
    6161    />
    6262    <class-cache
     63      class="net.sf.basedb.core.data.DataFileTypeData"
     64      usage="nonstrict-read-write"
     65    />
     66    <class-cache
    6367      class="net.sf.basedb.core.data.DirectoryData"
    6468      usage="nonstrict-read-write"
     
    125129    />
    126130    <class-cache
     131      class="net.sf.basedb.core.data.PlatformData"
     132      usage="nonstrict-read-write"
     133    />
     134    <class-cache
     135      class="net.sf.basedb.core.data.PlatformVariantData"
     136      usage="nonstrict-read-write"
     137    />
     138    <class-cache
    127139      class="net.sf.basedb.core.data.PluginConfigurationData"
    128140      usage="nonstrict-read-write"
  • trunk/doc/src/docbook/appendix/incompatible.xml

    r3675 r3835  
    4545    </para>
    4646  </note>
     47 
     48  <sect1 id="appendix.incompatible.2.5">
     49    <title>BASE 2.5 release</title>
     50   
     51    <bridgehead>Raw data types</bridgehead>
     52    <para>
     53      The <sgmltag class="attribute">storage</sgmltag> attribute of the
     54      <sgmltag class="starttag">raw-data-type</sgmltag> has been deprecated
     55      for the <filename>raw-data-types.xml</filename> file. BASE will refuse
     56      to start if it finds this attribute. Raw data types which doesn't use
     57      the database for storing data should be registered as <classname>Platform</classname>:s
     58      instead.
     59    </para>
     60   
     61    <para>
     62      Applications or plug-ins that filters on the <property>rawDataType</property>
     63      property for <classname>RawBioAssay</classname> or <classname>Experiment</classname>
     64      may need to change. The ID given to raw data types that doesn't use the
     65      database for storing data are prefixed with the <constant>platform.</constant>.
     66      The ID for the Affymetrix platform has changed from <constant>affymetrix</constant>
     67      to <constant>platform.affymetrix</constant>.
     68    </para>
     69   
     70    <bridgehead>Raw bioassays</bridgehead>
     71    <para>
     72      The property <property>spots</property> which used to hold the number
     73      of spots in the database OR in the file(s) has been split into two
     74      properties:
     75    </para>
     76    <itemizedlist>
     77    <listitem>
     78      <para>
     79      <property>spots</property>: Now only holds the number of database spots
     80      </para>
     81    </listitem>
     82    <listitem>
     83      <para>
     84      <property>numFileSpots</property>: Holds the number of spots that are stored in files
     85      </para>
     86    </listitem>
     87    </itemizedlist>
     88   
     89    <para>
     90      Applications or plug-ins that filters on the <property>spots</property> property
     91      may no longer work as expected for file-only platforms, since this value is now
     92      always 0. They should use the <property>numFileSpots</property> property instead.
     93    </para>
     94   
     95    <bridgehead>Array designs</bridgehead>
     96    <para>
     97      The <methodname>ArrayDesign.isAffyChip()</methodname> method has
     98      been deprecated. Applications or plug-ins that filter on the <property>affyChip</property>
     99      property may no longer work as expected. The applications should
     100      instead filter on the <property>platform.externalId</property> and
     101      look for the value given by the constant <constant>Platform.AFFYMETRIX</constant>.
     102    </para>
     103   
     104    <programlisting>
     105// This may no longer work
     106query.restrict(
     107   Restrictions.eq(
     108      Hql.property("affyChip"),
     109      Expressions.parameter("affyChip", true, Type.BOOLEAN)
     110   )
     111);
     112
     113// Use this instead
     114query.restrict(
     115   Restrictions.eq(
     116      Hql.property("platform.externalId"),
     117      Expressions.string(Platform.AFFYMETRIX)
     118   )
     119);
     120</programlisting>
     121   
     122   
     123  </sect1>
    47124 
    48125  <sect1 id="appendix.incompatible.2.4">
  • trunk/doc/src/docbook/appendix/raw_data_types.xml

    r3757 r3835  
    4040 
    4141  <sect1 id="appendix.rawdatatypes.platforms">
    42     <title>Default platforms installed with BASE</title>
    43    
    44       <note>
    45         <title>THIS IS A DRAFT!</title>
    46         <para>
    47           This document is a draft currently beeing worked on!
    48           Changes are expected before the design is finalized.
    49         </para>
    50       </note>
     42    <title>Default platforms/variants installed with BASE</title>
    5143   
    5244    <informaltable>
     
    6355            <entry namest="platform.name" nameend="platform.id">Platform</entry>
    6456            <entry namest="variant.name" nameend="variant.id">Variants</entry>
    65             <entry namest="filetype.item" nameend="filetype.id">File types</entry>
     57            <entry namest="filetype.item" nameend="filetype.id">Data file types</entry>
    6658          </row>
    6759          <row>
     
    7971            <entry morerows="2">Generic</entry>
    8072            <entry morerows="2">generic</entry>
    81             <entry morerows="2"></entry>
    82             <entry morerows="2"></entry>
     73            <entry morerows="2">-</entry>
     74            <entry morerows="2">-</entry>
    8375
    8476            <entry morerows="1">Array design</entry>
     
    9284          <row>
    9385            <entry>Raw bioassay</entry>
    94             <entry>Raw data</entry>
     86            <entry>Generic raw data</entry>
    9587            <entry>generic.rawdata</entry>
    9688          </row>
    9789          <row>
    98             <entry morerows="2">Affymetrix</entry>
    99             <entry morerows="2">affymetrix</entry>
    100             <entry morerows="1">Expression</entry>
    101             <entry morerows="1">affymetrix.expression</entry>
     90            <entry morerows="1">Affymetrix</entry>
     91            <entry morerows="1">affymetrix</entry>
     92            <entry morerows="1">-</entry>
     93            <entry morerows="1">-</entry>
    10294            <entry>Array design</entry>
    103             <entry>CDF</entry>
     95            <entry>CDF file</entry>
    10496            <entry>affymetrix.cdf</entry>
    10597          </row>
    10698          <row>
    10799            <entry>Raw bioassay</entry>
    108             <entry>CEL</entry>
     100            <entry>CEL file</entry>
    109101            <entry>affymetrix.cel</entry>
    110           </row>
    111           <row>
    112             <entry>Snip</entry>
    113             <entry>affymetrix.snip</entry>
    114             <entry>??</entry>
    115           </row>
    116           <row>
    117             <entry>Illumina</entry>
    118             <entry>illumina</entry>
    119             <entry></entry>
    120             <entry></entry>
    121             <entry>??</entry>
    122           </row>
    123           <row>
    124             <entry namest="platform.name" nameend="filetype.id">More???</entry>
    125102          </row>
    126103        </tbody>
  • trunk/doc/src/docbook/developerdoc/api_overview.xml

    r3795 r3835  
    794794      </para>
    795795     
    796       <note>
    797         <title>THIS IS A DRAFT!</title>
    798         <para>
    799           This document is a draft currently beeing worked on!
    800           Changes are expected before the design is finalized.
    801         </para>
    802       </note>
    803      
     796      <itemizedlist>
     797        <title>See also</title>
     798        <listitem><xref linkend="core_api.data_in_files" /></listitem>
     799        <listitem><xref linkend="appendix.rawdatatypes.platforms" /></listitem>
     800      </itemizedlist>
     801         
    804802      <sect3 id="data_api.platforms.uml">
    805803        <title>UML diagram</title>
     
    867865     
    868866      <sect3 id="data_api.platforms.files">
    869         <title>Data files</title>
     867        <title>FileStoreEnabled items and data files</title>
    870868       
    871869        <para>
     
    873871          interface to be able to store data in files instead of in the database.
    874872          The interface creates a link to a <classname>FileSetData</classname> object,
    875           which is can hold several <classname>FileSetMemberData</clasname> items.
     873          which is can hold several <classname>FileSetMemberData</classname> items.
    876874          Each member points to specific <classname>FileData</classname> item.
    877           A file set can only store one file of each type.
     875          A file set can only store one file of each <classname>DataFileTypeData</classname>.
    878876        </para>
    879877       
     
    932930    <sect2 id="core_api.data_in_files">
    933931      <title>Using files to store data</title>
    934       <note>
    935         <title>THIS IS A DRAFT!</title>
    936         <para>
    937           This document is a draft currently beeing worked on!
    938           Changes are expected before the design is finalized.
    939         </para>
    940       </note>
    941932     
    942933      <para>
    943934        This section is about how BASE can use files to store data instead
    944         of importing it into the database. See <xref linkend="data_api.platforms" />
    945         for an overview of the database schema for this feature. Files can be attached
     935        of importing it into the database. Files can be attached
    946936        to any item that implements the <interfacename>FileStoreEnabled</interfacename>
    947         interface. Currently this is <classname>RawBioAssay</classname>, <classname>ArrayDesign</classname>,
    948         <classname>BioAssaySet</classname> and <classname>BioAssay</classname>. The
     937        interface. Currently this is <classname>RawBioAssay</classname>
     938        and <classname>ArrayDesign</classname>. The
    949939        ability to store data in files is not a replacement for storing data in the
    950940        database. It is possible (for some platforms/raw data types) to have data in
     
    975965        Not all three cases are supported for all types of data. This is controlled
    976966        by the <classname>Platform</classname> class, which may disallow
    977         that data is stored in the database. To check this call
    978         <methodname>getRawDataType()</methodname> which may return:
     967        that data is stored in the database. To check this call
     968        <methodname>Platform.isFileOnly()</methodname> and/or
     969        <methodname>Platform.getRawDataType()</methodname>. If the <methodname>isFileOnly()</methodname>
     970        method returns <constant>true</constant>, the platform can't store data in
     971        the database. If the value is <constant>false</constant> more information
     972        can be obtained by calling <methodname>getRawDataType()</methodname>,
     973        which may return:
    979974      </para>
    980975     
     
    10051000        has changed. The <filename>raw-data-types.xml</filename> file should
    10061001        only be used for raw data types that are stored in the database. The
    1007         <sgmltag>storage</sgmltag> tag has been deprecated and BASE will ignore
    1008         any raw data type definitions with <code>storage="file"</code>.
    1009         To replace this, each <classname>Platform</classname> that
    1010         can only store data in files also defines a "virtual" raw data type.
     1002        <sgmltag>storage</sgmltag> tag has been deprecated and BASE will refuse
     1003        to start if it finds a raw data type definitions with <code>storage="file"</code>.
    10111004      </para>
     1005     
     1006      <para>
     1007        For backwards compatibility reasons, each <classname>Platform</classname>
     1008        that can only store data in files will create "virtual" raw data type
     1009        objects internally. These raw data types all return <constant>false</constant>
     1010        from if the method <methodname>RawDataType.isStoredInDb()</methodname>
     1011        is called. They also have a back-link to the platform/variant that
     1012        created it: <methodname>RawDataType.getPlatform()</methodname>
     1013        and <methodname>RawDataType.getVariant()</methodname>. Theese two methods
     1014        will always return null when called on a raw data type that can be
     1015        stored in the database.
     1016      </para>
     1017     
     1018      <itemizedlist>
     1019        <title>See also</title>
     1020        <listitem><xref linkend="data_api.platforms" /></listitem>
     1021        <listitem><xref linkend="appendix.rawdatatypes.platforms" /></listitem>
     1022        <listitem>
     1023          <xref linkend="appendix.incompatible.2.5" xrefstyle=""/> in
     1024          <xref linkend="appendix.incompatible" />
     1025        </listitem>
     1026      </itemizedlist>
    10121027     
    10131028      <sect3 id="core_api.data_in_files.diagram">
     
    10371052        <para>
    10381053          Given that we have a <interfacename>FileStoreEnabled</interfacename>
    1039           item we use the <methodname>DataFileType.getQuery()</methodname>
    1040           method to find which file types that can be used for that
    1041           item. Internally, the <methodname>getQuery()</methodname>
    1042           method uses the <methodname>FileStoreEnabled.getPlatform()</methodname>
     1054          item we want to find out which <classname>DataFileType</classname>
     1055          items that can be used for that item. The
     1056          <methodname>DataFileType.getQuery(FileStoreEnabled)</methodname>
     1057          can be used for this. Internally, the method uses the result from
     1058          <methodname>FileStoreEnabled.getPlatform()</methodname>
    10431059          and <methodname>FileStoreEnabled.getVariant()</methodname>
    10441060          methods to restrict the query to only return file types for
    10451061          a given platform and/or variant. If the item doesn't have
    1046           a platform or variant the query will only return file types
    1047           that are associated with the given item type, but not with any specific
    1048           platform. In any case, we get a list of <classname>DataFileType</classname>
    1049           items, each one representing a specific file type that
    1050           we should ask the user about. Examples:
     1062          a platform or variant the query will return all file types
     1063          that are associated with the given item type. In any case, we get a list
     1064          of <classname>DataFileType</classname> items, each one representing a
     1065          specific file type that we should ask the user about. Examples:
    10511066        </para>
    10521067
     
    10551070          <para>
    10561071          The <constant>Affymetrix</constant> platform defines <constant>CEL</constant>
    1057           for <constant>FileType.RAW_DATA</constant>
    1058           and <constant>CDF</constant> for <constant>FileType.REPORTER_MAP</constant>.
    1059           respectively. If we have a
    1060           <classname>RawBioAssay</classname> the query will only return
     1072          as a raw data file and <constant>CDF</constant> as an array design (feature)
     1073          file. If we have a <classname>RawBioAssay</classname> the query will only return
    10611074          the CEL file type and the client can ask the user for a CEL file.
    10621075          </para>
     
    10641077        <listitem>
    10651078          <para>
    1066           More examples.... ???
     1079          The <constant>Generic</constant> platform defines <constant>PRINT_MAP</constant>
     1080          and <constant>REPORTER_MAP</constant> for array designs. If we have
     1081          an <classname>ArrayDesign</classname> the query will return those two
     1082          items.
    10671083          </para>
    10681084        </listitem>
     
    10701086     
    10711087        <para>
    1072           Here is a simple code template that might be useful.
    1073         </para>
    1074        
     1088          It might also be interesting to know the currently selected file
     1089          for each file type and if the platform has set the <varname>required</varname>
     1090          flag for a particular file type. Here is a simple code example
     1091          that may be useful to start from:
     1092        </para>
     1093     
    10751094        <programlisting>
    10761095DbControl dc = ...
    10771096FileStoreEnabled item = ...
     1097Platform platform = item.getPlatform();
     1098PlatformVariant variant = item.getVariant();
     1099
     1100// Get list of DataFileTypes used by the platform
    10781101ItemQuery&lt;DataFileType&gt; query =
    1079    DataFileType.getQuery(item);
     1102   FileStoreUtil.getQuery(item);
    10801103List&lt;DataFileType&gt; types = query.list(dc);
    1081 // We now have a list of file types...
    1082 // ... ask the user to select a file for each one of them
     1104
     1105// Always check hasFileSet() method first to avoid
     1106// creating the file set if it doesn't exists
     1107FileSet fileSet = item.hasFileSet() ?
     1108   null : item.getFileSet();
     1109   
     1110for (DataFileType type : types)
     1111{
     1112   // Get the current file, if any
     1113   FileSetMember member = fileSet == null || !fileSet.hasMember(type) ?
     1114      null : fileSet.getMember(type);
     1115   File current = member == null ?
     1116      null : member.getFile();
     1117   
     1118   // Check if a file is required by the platform
     1119   PlatformFileType pft = platform == null ?
     1120      null : platform.getFileType(type, variant);
     1121   boolean isRequired = pft == null ?
     1122      false : pft.isRequired();
     1123     
     1124   // Now we can do something with this information to
     1125   // let the user select a file ...
     1126}
    10831127</programlisting>
    10841128     
     1129        <note>
     1130          <title>Also remember to catch PermissionDeniedException</title>
     1131          <para>
     1132            The above code may look complicated, but this is mostly because
     1133            of all checks for <constant>null</constant> values. Remember
     1134            that many things are optional and may return <constant>null</constant>.
     1135            Another thing to look out for is
     1136            <exceptionname>PermissionDeniedException</exceptionname>:s. The logged in
     1137            user may not have access to all items. The above example doesn't include
     1138            any code for this since it would have made it too complex.
     1139          </para>
     1140        </note>
    10851141      </sect3>
    10861142     
    10871143      <sect3 id="core_api.data_in_files.link">
    1088         <title>Link to the selected files</title>
     1144        <title>Link, validate and extract metadata from the selected files</title>
    10891145        <para>
    10901146          When the user has selected the file(s) we must store the links
     
    10941150          Call <methodname>FileSet.setMember()</methodname> to store
    10951151          a file in the set. If a file already exists for the given file type
    1096           it is replaced, otherwise a new entry is created.
    1097         </para>
     1152          it is replaced, otherwise a new entry is created. The following
     1153          program example assumes that we have a map where <classname>File</classname>:s
     1154          are related to <classname>DataFileType</classname>:s
     1155         
     1156        </para>
     1157       
     1158        <programlisting>
     1159DbControl dc = ...
     1160FileStoreEnabled item = ...
     1161Map&lt;DataFileType, File&gt; files = ...
     1162
     1163// Store the selected files in the fileset
     1164FileSet fileSet = item.getFileSet();
     1165for (Map.Entry&lt;DataFileType, File&gt; entry : files)
     1166{
     1167   DataFileType type = entry.getKey();
     1168   File file = entry.getValue();
     1169   fileSet.setMember(type, file);
     1170}
     1171
     1172// Validate the files and extract metadata
     1173fileSet.validate(dc, true);
     1174</programlisting>
    10981175      </sect3>
    10991176     
    11001177      <sect3 id="core_api.data_in_files.validate">
    1101         <title>Validate the file and extract metadata</title>
     1178        <title>How the core validate the files and extracts metadata</title>
    11021179       
    11031180        <para>
    11041181          Validation and extraction of metadata is important since we want
    11051182          data in files to be equivalent to data in the database. The validation
    1106           and metadata extraction is automatically done by the core when a
    1107           file is added to a file set. The process is partly pluggable
    1108           since each <classname>DataFileType</classname> can name a class
    1109           that should do the validation and/or metadata extraction.
    1110           Here is the general outline:
    1111         </para>
    1112        
    1113         <programlisting>
    1114 FileStoreEnabled item = ...
    1115 DataFileType type = ...
    1116 File file = ...
    1117 FileSetMember member = new FileSetMember(file, type);
    1118 
    1119 DataFileValidator validator = type.getValidator();
    1120 DataFileMetadataReader metadata = type.getMetadataReader();
    1121 validator.setFile(member);
    1122 validator.setItem(item);
    1123 // Repeat for 'metadata' if not same as 'validator'
    1124 
    1125 validator.validate();
    1126 metadata.extractMetadata();
    1127 </programlisting>
    1128        
     1183          and metadata extraction is done by the core when the
     1184          <methodname>FileSet.validate()</methodname>.
     1185          The process is partly pluggable since each <classname>DataFileType</classname>
     1186          can name a class that should do the validation and/or metadata extraction.
     1187          Here is the general outline of what is going on:
     1188        </para>
     1189       
     1190       
     1191        <orderedlist>
     1192        <listitem>
     1193          <para>
     1194          The core checks the <classname>DataFileType</classname> of all
     1195          members in the file set and create <classname>DataFileValidator</classname>
     1196          and <classname>DataFileMetadataReader</classname> objects. Only one instance
     1197          of each class is created. If the file set contains members which has the
     1198          same validator or metadata reader, they will all share the same instance.
     1199          </para>
     1200        </listitem>
     1201       
     1202        <listitem>
     1203          <para>
     1204          Each validator/metadata reader class is initialised with calls to
     1205          <methodname>DataFileHandler.setItem()</methodname> and
     1206          <methodname>DataFileHandler.setFile()</methodname>.
     1207          </para>
     1208        </listitem>
     1209       
     1210        <listitem>
     1211          <para>
     1212          Each validator is called. The result of the validation is saved for each
     1213          file and can be retreieved by <methodname>FileSetMember.isValid()</methodname>
     1214          and <methodname>FileSetMember.getErrorMessage()</methodname>.
     1215          </para>
     1216        </listitem>
     1217       
     1218        <listitem>
     1219          <para>
     1220          Each metadata reader is called, unless the metadata reader is the same class
     1221          as the validator and the validation failed. If the metadata reader is a
     1222          different class, it is called even if the validation failed.
     1223          </para>
     1224        </listitem>
     1225        </orderedlist>
     1226
    11291227        <note>
    11301228          <title>Only one instance of each validator class is created</title>
     
    11611259       
    11621260        <programlisting>
    1163 File defaultFile = null;
    1164 RawBioAssay rba = ...;
    1165 if (rba.hasFileSet())
    1166 {
    1167    FileSet fileSet = rba.getFileSet();
    1168    List&lt;FileSetMember&gt; members =
    1169       fileSet.getMembers(FileType.RAW_DATA);
    1170    if (members.size() &gt; 0)
    1171    {
    1172       defaultFile = members.get(0).getFile();
    1173    }
    1174 }       
     1261RawBioAssay rba = ...
     1262DbControl dc = ...
     1263
     1264// Get the current raw data file, if any
     1265List&lt;File&gt; rawDataFiles = FileStoreUtil.getGenericDataFiles(dc, rba, FileType.RAW_DATA);
     1266File defaultFile = rawDataFiles.size() > 0 ?
     1267   rawDataFiles.get(0) : null;
     1268   
     1269// Create parameter asking for input file - use current as default
     1270PluginParameter&lt;File&gt; fileParameter = new PluginParameter&lt;File&gt;(
     1271   "file",
     1272   "Raw data file",
     1273   "The file that contains the raw data that you want to import",
     1274   new FileParameterType(defaultFile, true, 1)
     1275);
    11751276</programlisting>
     1277
     1278      <para>
     1279        An import plug-in should also save the file that was used to the file set:
     1280      </para>
     1281     
     1282      <programlisting>
     1283RawBioassay rba = ...
     1284// The file the user selected to import from
     1285File rawDataFile = (File)job.getValue("file");
     1286
     1287// Save the file to the fileset. The method will check which file
     1288// type the platform uses as the raw data type. As a fallback the
     1289// GENERIC_RAW_DATA type is used
     1290FileStoreUtil.setGenericDataFile(dc, rba, FileType.RAW_DATA,
     1291   DataFileType.GENERIC_RAW_DATA, rawDataFile);
     1292</programlisting>
     1293
    11761294      </sect3>
    11771295     
     
    12101328        <programlisting>
    12111329Experiment e = ...
     1330DbControl dc = ...
    12121331RawDataType rdt = e.getRawDataType();
    12131332if (!rdt.isStoredInDb())
    12141333{
    1215    Platform p = rdt.getPlatform();
    1216    PlatformVariant v = rdt.getVariant();
     1334   Platform p = rdt.getPlatform(dc);
     1335   PlatformVariant v = rdt.getVariant(dc);
    12171336   // Check that platform/variant is supported
    12181337   // ... run plug-in code ...
  • trunk/src/core/net/sf/basedb/core/DataFileType.java

    r3820 r3835  
    2929import net.sf.basedb.core.filehandler.DataFileMetadataReader;
    3030import net.sf.basedb.core.filehandler.DataFileValidator;
     31import net.sf.basedb.core.query.Expressions;
    3132import net.sf.basedb.core.query.Hql;
    3233import net.sf.basedb.core.query.Restrictions;
     
    177178  {
    178179    return new ItemQuery<DataFileType>(DataFileType.class);
     180  }
     181 
     182  /**
     183    Get a query configured to retrieve <code>DataFileType</code>:s
     184    that can be used on a given item. This method will check the
     185    {@link FileStoreEnabled#getPlatform()} and {@link FileStoreEnabled#getVariant()}
     186    values and restrict the query to only return items that can be used for
     187    that platform. If the item isn't attached to any platform or variant
     188    all data file types for the {@link Identifiable#getType()} are returned.
     189   
     190    @param item The item to get data file types for, or null
     191      to return all data file types
     192    @return An {@link ItemQuery} object
     193  */
     194  public static ItemQuery<DataFileType> getQuery(FileStoreEnabled item)
     195  {
     196    ItemQuery<DataFileType> query = new ItemQuery<DataFileType>(DataFileType.class);
     197    if (item != null)
     198    {
     199      // Restrict on itemType
     200      Item itemType = item.getType();
     201      query.restrictPermanent(
     202        Restrictions.eq(
     203          Hql.property("itemType"),
     204          Expressions.integer(itemType.getValue())
     205        )
     206      );
     207     
     208      // Restrict on platform / variant
     209      PlatformVariant variant = item.getVariant();
     210      Platform platform = variant != null ? variant.getPlatform() : item.getPlatform();
     211      if (platform != null)
     212      {
     213        query.join(Hql.innerJoin("platforms", "pft"));
     214        query.restrict(Restrictions.eq(Hql.property("pft", "platform"), Hql.entity(platform)));
     215        if (variant != null)
     216        {
     217          query.restrict(Restrictions.or(
     218            Restrictions.eq(Hql.property("pft", "variant"), null),
     219            Restrictions.eq(Hql.property("pft", "variant"), Hql.entity(variant))
     220          ));
     221        }
     222        else
     223        {
     224          query.restrict(Restrictions.eq(Hql.property("pft", "variant"), null));
     225        }
     226      }
     227    }
     228    return query;   
    179229  }
    180230
  • trunk/src/core/net/sf/basedb/core/FileSetMember.java

    r3820 r3835  
    195195  }
    196196 
     197  /**
     198    Set the validation status of this member.
     199    @param valid If the member file is valid or not, use null to
     200      indicate that no validation has been performed
     201    @param errorMessage The error message if the validation failes
     202  */
    197203  public void setValid(Boolean valid, String errorMessage)
    198204  {
  • trunk/src/core/net/sf/basedb/core/data/DataFileTypeData.java

    r3820 r3835  
    216216    @hibernate.collection-one-to-many class="net.sf.basedb.core.data.FileSetMemberData"
    217217  */
    218   Set<FileSetMemberData> getMembers()
     218  Set<FileSetMemberData> getFileSetMembers()
    219219  {
    220220    return members;
    221221  }
    222   void setMembers(Set<FileSetMemberData> members)
     222  void setFileSetMembers(Set<FileSetMemberData> members)
    223223  {
    224224    this.members = members;
  • trunk/src/core/net/sf/basedb/core/data/PlatformData.java

    r3820 r3835  
    108108  /**
    109109    If this platform can only be used with files.
    110     @hibernate.property column="`file_only`" type="boolean" not-null="true"
     110    @hibernate.property column="`file_only`" type="boolean" not-null="true" update="false"
    111111  */
    112112  public boolean isFileOnly()
     
    123123    The raw data type this platform is locked to, or null.
    124124    Only used if fileOnly=false
    125     @hibernate.property column="`rawdatatype`" type="string" length="255" not-null="false"
     125    @hibernate.property column="`rawdatatype`" type="string" length="255"
     126      not-null="false" update="false"
    126127  */
    127128  public String getRawDataType()
     
    138139    The number of channels this platform uses. Only used
    139140    if fileOnly=true
    140     @hibernate.property column="`channels`" type="int" not-null="true"
     141    @hibernate.property column="`channels`" type="int" not-null="true" update="false"
    141142  */
    142143  public int getChannels()
  • trunk/src/core/net/sf/basedb/core/data/PlatformVariantData.java

    r3820 r3835  
    106106  /**
    107107    If this platform variant can only be used with files.
    108     @hibernate.property column="`file_only`" type="boolean" not-null="true"
     108    @hibernate.property column="`file_only`" type="boolean" not-null="true" update="false"
    109109  */
    110110  public boolean isFileOnly()
     
    121121    The raw data type this platform variant is locked to, or null.
    122122    Only used if fileOnly=false
    123     @hibernate.property column="`rawdatatype`" type="string" length="255" not-null="false"
     123    @hibernate.property column="`rawdatatype`" type="string" length="255"
     124      not-null="false" update="false"
    124125  */
    125126  public String getRawDataType()
     
    136137    The number of channels this platform variant uses. Only used
    137138    if fileOnly=true
    138     @hibernate.property column="`channels`" type="int" not-null="true"
     139    @hibernate.property column="`channels`" type="int" not-null="true" update="false"
    139140  */
    140141  public int getChannels()
  • trunk/src/core/net/sf/basedb/core/filehandler/AbstractDataFileHandler.java

    r3820 r3835  
    11/*
    2   $Id$
     2  $Id:AbstractDataFileHandler.java 3820 2007-10-12 10:03:18Z nicklas $
    33
    44  Copyright (C) 2007 Nicklas Nordborg
     
    4343  @author Nicklas
    4444  @version 2.5
    45   @base.modified $Date$
     45  @base.modified $Date:2007-10-12 12:03:18 +0200 (Fri, 12 Oct 2007) $
    4646*/
    4747public abstract class AbstractDataFileHandler
     
    8282  /**
    8383    Get the file set member of a specific {@link DataFileType}.
    84     @param dataFileType The external ID of the data file type.
     84    @param dataFileType The external ID of the data file type
    8585    @return The file set member or null if no member of
    8686      that type is found
Note: See TracChangeset for help on using the changeset viewer.