Changeset 3796


Ignore:
Timestamp:
Sep 27, 2007, 10:05:24 PM (16 years ago)
Author:
Nicklas Nordborg
Message:

Merged log:trunk#3775:3995 into filedb branch

Location:
branches/filedb
Files:
1 deleted
27 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/filedb/build.xml

    r3783 r3796  
    10781078    <mkdir dir="${docbook.html.out}/userdoc/trashcan"/>
    10791079    <mkdir dir="${docbook.html.out}/userdoc/webclient"/>
     1080    <mkdir dir="${docbook.html.out}/userdoc/overview"/>
    10801081    <mkdir dir="${docbook.html.out}/faqs" />
    10811082    <mkdir dir="${docbook.html.out}/appendix" />
  • branches/filedb/doc/src/docbook/appendix/menuguide.xml

    r3675 r3796  
    3737      <listitem>
    3838        <simpara>
    39           <link linkend="menuguide.tables.config">Config</link>
     39          <link linkend="menuguide.tables.config">Configurations</link>
    4040        </simpara>
    4141      </listitem>
  • branches/filedb/doc/src/docbook/developerdoc/api_overview.xml

    r3783 r3796  
    824824          The <classname>PlatformData</classname> holds information about a
    825825          platform. A platform can have one or more <classname>PlatformVariant</classname>:s.
    826           Both the platform and variant are identified by a system ID that
     826          Both the platform and variant are identified by an external ID that
    827827          is fixed and can't be changed. <emphasis>Affymetrix</emphasis>
    828828          and <emphasis>Illumina</emphasis> are examples of platforms.
     
    837837        <para>
    838838          Each platform and it's variant can be connected to one or more
    839           <classname>FileSetMemberTypeData</classname> items. This item
     839          <classname>DataFileTypeData</classname> items. This item
    840840          describes the kind of files that are used to hold data for
    841841          the platform and/or variant. The file types are re-usable between
     
    848848        <para>
    849849          The file type is also identified
    850           by a fixed, non-changable system ID. The <varname>itemType</varname>
     850          by a fixed, non-changable external ID. The <varname>itemType</varname>
    851851          property tells us what type of item the file holds data for (ie.
    852852          array design or raw bioassay). It also links to a <classname>FileType</classname>
     
    857857          get another file.
    858858        </para>
     859        <para>
     860          The <varname>required</varname> flag in <classname>PlatformFileTypeData</classname>
     861          is used to signal that the file is a required file. This will, however, not be
     862          enforeced by the core. It is intended to be used by client applications
     863          for creating a better GUI and/or validation of an experiment.
     864        </para>
    859865
    860866      </sect3>
    861867     
    862868      <sect3 id="data_api.platforms.files">
    863         <title>Files</title>
     869        <title>Data files</title>
    864870       
    865871        <para>
    866872          An item must implement the <interfacename>FileStoreEnabledData</interfacename>
    867873          interface to be able to store data in files instead of in the database.
    868           The interface creates a link to a <classname>FileSetData</classname> object.
    869           In a file set it is only possible to store one file for each
    870           <classname>FileSetMemberTypeData</classname> item.
     874          The interface creates a link to a <classname>FileSetData</classname> object,
     875          which is can hold several <classname>FileSetMemberData</clasname> items.
     876          Each member points to specific <classname>FileData</classname> item.
     877          A file set can only store one file of each type.
    871878        </para>
    872879       
     
    10301037        <para>
    10311038          Given that we have a <interfacename>FileStoreEnabled</interfacename>
    1032           item we use the <methodname>FileSetMemberType.getQuery()</methodname>
     1039          item we use the <methodname>DataFileType.getQuery()</methodname>
    10331040          method to find which file types that can be used for that
    10341041          item. Internally, the <methodname>getQuery()</methodname>
     
    10391046          a platform or variant the query will only return file types
    10401047          that are associated with the given item type, but not with any specific
    1041           platform. In any case, we get a list of <classname>FileSetMemberType</classname>
     1048          platform. In any case, we get a list of <classname>DataFileType</classname>
    10421049          items, each one representing a specific file type that
    10431050          we should ask the user about. Examples:
     
    10691076DbControl dc = ...
    10701077FileStoreEnabled item = ...
    1071 ItemQuery&lt;FileSetMemberType&gt; query =
    1072    FileSetMemberType.getQuery(item);
    1073 List&lt;FileSetMemberType&gt; types = query.list(dc);
     1078ItemQuery&lt;DataFileType&gt; query =
     1079   DataFileType.getQuery(item);
     1080List&lt;DataFileType&gt; types = query.list(dc);
    10741081// We now have a list of file types...
    10751082// ... ask the user to select a file for each one of them
     
    10991106          and metadata extraction is automatically done by the core when a
    11001107          file is added to a file set. The process is partly pluggable
    1101           since each <classname>FileSetMemberType</classname> can name a class
     1108          since each <classname>DataFileType</classname> can name a class
    11021109          that should do the validation and/or metadata extraction.
    11031110          Here is the general outline:
     
    11061113        <programlisting>
    11071114FileStoreEnabled item = ...
    1108 FileSetMemberType type = ...
     1115DataFileType type = ...
    11091116File file = ...
    11101117FileSetMember member = new FileSetMember(file, type);
    11111118
    1112 FileValidator validator = type.getValidator();
    1113 MetadataReader metadata = type.getMetadataReader();
     1119DataFileValidator validator = type.getValidator();
     1120DataFileMetadataReader metadata = type.getMetadataReader();
    11141121validator.setFile(member);
    11151122validator.setItem(item);
     
    11351142        <para>
    11361143          All validators and meta data extractors should extend
    1137           the <classname>AbstractFileHandler</classname> class. The reason
    1138           is that we may want to add more methods to the <interfacename>FileHandler</interfacename>
    1139           interface in the future. The <classname>AbstractFileHandler</classname> will
     1144          the <classname>AbstractDataFileHandler</classname> class. The reason
     1145          is that we may want to add more methods to the <interfacename>DataFileHandler</interfacename>
     1146          interface in the future. The <classname>AbstractDataFileHandler</classname> will
    11401147          be used to provide default implementations for backwards compatibility.
    11411148        </para>
  • branches/filedb/doc/src/docbook/developerdoc/documentation.xml

    r3715 r3796  
    982982            <tip>
    983983              <para>
    984               Change your BASE <link linkend="webclient.configuration.preferences"
    985                 >preferences</link> to a smaller font size or use
    986               the zoom functionality in the web browser to make more information
    987               fit in the same image width.
     984                Change your BASE preferences, see
     985                <xref linkend="webclient.configuration.preferences" />,
     986                to a smaller font size or use the zoom functionality in the web
     987                browser to make more information fit in the same image width.
    988988              </para>
    989989            </tip>
  • branches/filedb/doc/src/docbook/userdoc/index.xml

    r3783 r3796  
    2929  <?dbhtml dir="userdoc"?>
    3030  <title>User documentation</title>
    31   <include file="userdoc_overview.xml"/>
     31  <include file="overview.xml"/>
    3232  <include file="webclient.xml"/>
    3333  <include file="project_permission.xml"/>
  • branches/filedb/doc/src/docbook/userdoc/project_permission.xml

    r3684 r3796  
    107107            <listitem>
    108108              <para>
    109               Permission to change the owner of an item. This is implemented
    110               as a <link linkend="webclient.items.takeownership">Take ownership</link>
    111               function in the web client, where you can take the ownership of
    112               items that you do not already own.
     109                Permission to change the owner of an item. This is implemented as a
     110                <synopsis>Take ownership</synopsis> function in the web client
     111                (<xref linkend="webclient.items.takeownership" />), where you can
     112                take the ownership of items that you do not already own.
    113113              </para>
    114114            </listitem>
     
    386386            <listitem>
    387387              <para>
    388               The easiest way and the one you will probably
    389               use most of the time is to use the
    390               <link linkend="webclient.intro.menubar">menu bar</link> shortcut.
    391               Look in the menu for the project icon (<guiicon><inlinemediaobject>
    392               <imageobject><imagedata fileref="figures/project.gif" format="GIF" /></imageobject>
    393               </inlinemediaobject></guiicon>). Next to it, the name of the active project
    394               is displayed. If you see <guilabel>- none -</guilabel> here, it
    395               means that no project is active. Click on the icon or project name
    396               to open a drop-down menu and select a project to set as the active
    397               project. If another project is already active it will automatically
    398               be unactivated.
     388                The easiest way and the one you will probably use most of the time
     389                is to use the menu bar shortcut. Look in the menu for the project
     390                icon
     391                (<guiicon>
     392                  <inlinemediaobject>
     393                    <imageobject>
     394                      <imagedata fileref="figures/project.gif" format="GIF" />
     395                    </imageobject>
     396                  </inlinemediaobject>
     397                </guiicon>).
     398                Next to it, the name of the active project is displayed. If you see
     399                <guilabel>- none -</guilabel>
     400                here, it means that no project is active. Click on the icon or
     401                project name to open a drop-down menu and select a project to set as
     402                the active project. If another project is already active it will
     403                automatically be inactivated.
    399404              </para>
    400405            </listitem>
  • branches/filedb/doc/src/docbook/userdoc/webclient.xml

    r3675 r3796  
    10061006            the same protocol is used the next time you create another extract.
    10071007            In fact, BASE will remember as many items as specified by
    1008             the <link linkend="webclient.configuration.preferences.appearance">
    1009             <guilabel>Recently used items</guilabel></link> setting (default is 4),
    1010             allowing you to quickly select one of those protocols.
     1008            the
     1009            <guilabel>Recently used items</guilabel> setting (default is 4),
     1010            allowing you to quickly select one of those protocols.
     1011            <xref linkend="webclient.configuration.preferences.appearance"/>
     1012            contains more information about the setting.
    10111013            </para>
    10121014          </listitem>
     
    11011103          You can restore deleted items either from the trashcan,
    11021104          from the list view or from the single-item view. This section only covers the last two
    1103           cases. The trashcan has a <link linkend="trashcan">chapter of it's own</link>.
     1105          cases. The trashcan has a section of it's own(<xref linkend="trashcan"/>).
    11041106        </para>
    11051107
     
    13221324     
    13231325      <para>
    1324         Use the <link linkend="webclient.intro.menubar">menu</link> to
    1325         open a page listing items. Most list pages can only
    1326         list one type of items. For example: use the
    1327         <menuchoice><guimenu>View</guimenu><guimenuitem>Samples</guimenuitem></menuchoice>
    1328         menu to list samples and the
    1329         <menuchoice><guimenu>View</guimenu><guimenuitem>Experiments</guimenuitem></menuchoice>
    1330         menu to list experiments.
     1326        Use the menu to open a page listing items. Most list pages can only list one type of
     1327        items. For example: use the
     1328        <menuchoice>
     1329          <guimenu>View</guimenu>
     1330          <guimenuitem>Samples</guimenuitem>
     1331        </menuchoice>
     1332        menu to list samples and the
     1333        <menuchoice>
     1334          <guimenu>View</guimenu>
     1335          <guimenuitem>Experiments</guimenuitem>
     1336        </menuchoice>
     1337        menu to list experiments.
    13311338      </para>
    1332      
     1339
    13331340      <tip>
    13341341        An example of a list page that can list
     
    16801687              <listitem>
    16811688                <para><guilabel>Other&hellip;</guilabel> -
    1682                   Open the <link linkend="webclient.itemlist.columns">configure columns dialog box</link>.</para>
     1689                  Open the configure columns dialog box, described in
     1690                  <xref linkend="webclient.itemlist.columns"/>.</para>
    16831691              </listitem>
    16841692            </itemizedlist>
  • branches/filedb/src/core/net/sf/basedb/core/Install.java

    r3793 r3796  
    107107    method.
    108108  */
    109   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(42).intValue();
     109  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(43).intValue();
    110110 
    111111  public static synchronized void createTables(boolean update, final ProgressReporter progress)
  • branches/filedb/src/core/net/sf/basedb/core/InvalidPathException.java

    r3679 r3796  
    4343  public InvalidPathException(String path)
    4444  {
    45     super("Invalid path: " + path);
     45    super(path);
    4646  }
    4747
  • branches/filedb/src/core/net/sf/basedb/core/ItemContext.java

    r3679 r3796  
    898898    // Tempoarary storage for all associations that must be left joined
    899899    Set<String> leftJoins = autoLeftJoin ? new HashSet<String>() : null;
     900    Set<String> sortedProperties = autoLeftJoin ? new HashSet<String>() : null;
    900901   
    901902    // Add sort order information
     
    930931          if (dotIndex >= 0)
    931932          {
    932             leftJoins.add(sortProperty.substring(0, dotIndex));
     933            String toJoin = sortProperty.substring(0, dotIndex);
     934            leftJoins.add(toJoin);
     935            sortedProperties.add(toJoin);
    933936          }
    934937        }
     
    995998    {
    996999      int i = 0;
     1000      // Use fetch joins for columns appearing in the ORDER BY clause
     1001      // if the query is distinct and the database requires it
     1002      boolean selectOrderBy = query.isDistinct() &&
     1003        HibernateUtil.getDbEngine().selectOrderByColumnsIfDistinct();
    9971004      for (String property : leftJoins)
    9981005      {
     1006        boolean fetch = selectOrderBy && sortedProperties.contains(property);
    9991007        if (property.startsWith("@")) property = property.substring(1);
    10001008        i++;
    1001         query.join(Hql.leftJoin(property, "alj"+i));
     1009        query.join(Hql.leftJoin(null, property, "alj"+i, null, fetch));
    10021010      }
    10031011    }
  • branches/filedb/src/core/net/sf/basedb/core/Job.java

    r3719 r3796  
    997997    throws InvalidDataException, PermissionDeniedException, BaseException
    998998  {
     999    checkPermission(Permission.WRITE);
     1000    if (name == null) throw new InvalidUseOfNullException("name");
    9991001    if (getStatus() == Status.EXECUTING)
    10001002    {
     
    10021004    }
    10031005    getData().setStatus(Status.WAITING.getValue());
    1004     setParameterValuesInternal(name, label, description, parameterType, Arrays.asList(value));
     1006    setParameterValuesInternal(name, label, description, parameterType, Arrays.asList(value), true);
    10051007  }
    10061008 
     
    10461048    throws InvalidDataException, PermissionDeniedException, BaseException
    10471049  {
     1050    checkPermission(Permission.WRITE);
     1051    if (name == null) throw new InvalidUseOfNullException("name");
    10481052    if (getStatus() == Status.EXECUTING)
    10491053    {
     
    10511055    }
    10521056    getData().setStatus(Status.WAITING.getValue());
    1053     setParameterValuesInternal(name, label, description, parameterType, values);
     1057    setParameterValuesInternal(name, label, description, parameterType, values, true);
    10541058  }
    10551059 
     
    11111115    @param values A list containing the new values, null or empty to remove the
    11121116      configuration values
     1117    @param validate If validation by {@link ParameterType#validate(String, List)}
     1118      is needed or not
    11131119    @throws PermissionDeniedException If the logged in user doesn't have
    11141120      write permission
     
    11171123    @throws BaseException If there is another error
    11181124  */
    1119   void setParameterValuesInternal(String name, String label, String description, ParameterType<?> parameterType, List<?> values)
     1125  void setParameterValuesInternal(String name, String label, String description,
     1126    ParameterType<?> parameterType, List<?> values, boolean validate)
    11201127    throws InvalidDataException, PermissionDeniedException, BaseException
    11211128  {
    1122     checkPermission(Permission.WRITE);
    1123     if (name == null) throw new InvalidUseOfNullException("name");
    11241129    ParameterValueData old = null;
    11251130    if (values == null || values.size() == 0)
     
    11301135    {
    11311136      if (parameterType == null) throw new InvalidUseOfNullException("parameterType");
    1132       parameterType.validate(name, values);
     1137      if (validate) parameterType.validate(name, values);
    11331138      ParameterValueData<?> parameterValue = parameterType.newParameterValueData();
    11341139      parameterValue.setLabel(label);
  • branches/filedb/src/core/net/sf/basedb/core/ParameterType.java

    r3679 r3796  
    218218      if (!items.contains(value))
    219219      {
    220         throw new InvalidDataException("The value '" + value + "' isn't in the list of allowed values.");
     220        throw new InvalidDataException("The value '" + value + "' isn't in the list of allowed values for parameter '" + name + "'.");
    221221      }
    222222    }
  • branches/filedb/src/core/net/sf/basedb/core/ParameterValuesImpl.java

    r3679 r3796  
    161161    if (writeProtected)
    162162    {
    163       throw new PermissionDeniedException(Permission.WRITE, "Job parameter: "+name);
    164     }
     163      throw new PermissionDeniedException(Permission.WRITE, "Parameter: "+name);
     164    }
     165    if (name == null) throw new InvalidUseOfNullException("name");
     166    if (type == null) throw new InvalidUseOfNullException("type[name=" + name + "]");
    165167    if (value == null && type.getNotNull()) value = type.getDefaultValue();
     168    type.validate(name, value);
    166169    List<T> l = new ArrayList<T>(1);
    167170    l.add(value);
     
    176179    if (writeProtected)
    177180    {
    178       throw new PermissionDeniedException(Permission.WRITE, "Job parameter: "+name);
    179     }
     181      throw new PermissionDeniedException(Permission.WRITE, "Parameter: "+name);
     182    }
     183    if (name == null) throw new InvalidUseOfNullException("name");
     184    if (type == null) throw new InvalidUseOfNullException("type[name=" + name + "]");
    180185    if ((values == null || values.size() == 0) && type.getNotNull() && type.getDefaultValue() != null)
    181186    {
    182187      values = Arrays.asList(type.getDefaultValue());
    183188    }
     189    type.validate(name, values);
    184190    parameters.put(name, values);
    185191    parameterTypes.put(name, type);
     
    203209      if (pp == null)
    204210      {
    205         job.setParameterValuesInternal(name, null, null, parameterTypes.get(name), parameters.get(name));
     211        job.setParameterValuesInternal(name, null, null,
     212          parameterTypes.get(name), parameters.get(name), false);
    206213      }
    207214      else
    208215      {
    209         job.setParameterValuesInternal(name, pp.getLabel(), pp.getDescription(), parameterTypes.get(name), parameters.get(name));
     216        job.setParameterValuesInternal(name, pp.getLabel(), pp.getDescription(),
     217          parameterTypes.get(name), parameters.get(name), false);
    210218      }
    211219    }
     
    223231      if (pp == null)
    224232      {
    225         config.setParameterValues(name, null, null, parameterTypes.get(name), parameters.get(name));
     233        config.setParameterValuesInternal(name, null, null,
     234          parameterTypes.get(name), parameters.get(name), false);
    226235      }
    227236      else
    228237      {
    229         config.setParameterValues(name, pp.getLabel(), pp.getDescription(), parameterTypes.get(name), parameters.get(name));
     238        config.setParameterValuesInternal(name, pp.getLabel(), pp.getDescription(),
     239          parameterTypes.get(name), parameters.get(name), false);
    230240      }
    231241    }
  • branches/filedb/src/core/net/sf/basedb/core/Path.java

    r3679 r3796  
    143143      }
    144144      filename = parts[parts.length-1];
     145      if (!Path.isValidName(filename))
     146      {
     147        throw new InvalidPathException("Path contains invalid characters ("+Path.INVALID_CHARACTERS+"): "+path);
     148      }
    145149      parts[parts.length-1] = "";
    146150    }
  • branches/filedb/src/core/net/sf/basedb/core/PathParameterType.java

    r3675 r3796  
    8787    Checks if the value is a valif {@link Path} value.
    8888    @param value The value to test
    89     @throws InvalidDataException If the value is not a string or too long
     89    @throws InvalidDataException If the value is not a valid path
    9090  */
    9191  void validateValue(String name, String value)
    9292    throws InvalidDataException
    9393  {
    94     new Path(value, pathType);
     94    try
     95    {
     96      new Path(value, pathType);
     97    }
     98    catch (InvalidPathException ex)
     99    {
     100      throw new InvalidPathException("Path for parameter '"+ name + "' is invalid: " + ex.getMessage());
     101    }
    95102  }
    96103  /**
  • branches/filedb/src/core/net/sf/basedb/core/PluginConfiguration.java

    r3783 r3796  
    428428    checkPermission(Permission.WRITE);
    429429    if (name == null) throw new InvalidUseOfNullException("name");
    430    
     430    setParameterValuesInternal(name, label, description, parameterType, values, true);
     431  }
     432
     433  /**
     434    Set the values of a configuration parameter.
     435    @param name The name of the configuration parameter
     436    @param label The label of the parameter (optional)
     437    @param description A description of the parameter (optional)
     438    @param parameterType The type of the parameter
     439    @param values A list containing the new values, null or empty to remove the
     440      configuration values
     441    @param validate If validation by {@link ParameterType#validate(String, List)}
     442      is needed or not
     443    @throws PermissionDeniedException If the logged in user doesn't have
     444      write permission
     445    @throws InvalidDataException If name is null or the new value doesn't
     446      validate against the parameter type
     447    @throws BaseException If there is another error
     448  */
     449  void setParameterValuesInternal(String name, String label, String description,
     450    ParameterType<?> parameterType, List<?> values, boolean validate)
     451    throws InvalidDataException, PermissionDeniedException, BaseException
     452  {
     453
    431454    VersionedParameter param = new VersionedParameter(name, getNewParameterVersion());
    432    
    433455    if (values == null || values.size() == 0)
    434456    {
     
    438460    {
    439461      if (parameterType == null) throw new InvalidUseOfNullException("parameterType");
    440       parameterType.validate(name, values);
     462      if (validate) parameterType.validate(name, values);
    441463      ParameterValueData<?> parameterValue = parameterType.newParameterValueData();
    442464      parameterValue.setLabel(label);
     
    446468    }
    447469  }
    448 
     470 
    449471  /**
    450472    Copy all parameter values from another plugin configuration. This method
  • branches/filedb/src/core/net/sf/basedb/core/Update.java

    r3741 r3796  
    474474    <td>40</td>
    475475    <td>
    476       Change invalid property filter on 'guiContexts.itemType' to
    477       '$ctx.itemType'.
     476      Used to "Change invalid property filter on 'guiContexts.itemType' to
     477      '$ctx.itemType'", but since the source problem never was fixed this is now
     478      done in 43.
    478479    </td>
    479480  </tr>
     
    499500      The update will query the database or check the CDF file to get
    500501      the information.
     502    </td>
     503  </tr>
     504 
     505  <tr>
     506    <td>43</td>
     507    <td>
     508      Change invalid property filter on 'guiContexts.itemType' to
     509      '$ctx.itemType'". Was originally fixed by 40, but since the source
     510      problem never was fixed it must be done again.
    501511    </td>
    502512  </tr>
     
    697707        schemaVersion = updateToSchemaVersion39(session);
    698708      }
    699      
    700       if (schemaVersion < 40)
    701       {
    702         if (progress != null) progress.display((int)(39*progress_factor), "--Updating schema version: " + schemaVersion + " -> 40...");       
    703         schemaVersion = updateToSchemaVersion40(session);
    704       }
    705      
     709         
    706710      if (schemaVersion < 41)
    707711      {
     
    714718        if (progress != null) progress.display((int)(41*progress_factor), "--Updating schema version: " + schemaVersion + " -> 42...");
    715719        schemaVersion = updateToSchemaVersion42(session);
     720      }
     721     
     722      if (schemaVersion < 43)
     723      {
     724        if (progress != null) progress.display((int)(42*progress_factor), "--Updating schema version: " + schemaVersion + " -> 43...");       
     725        schemaVersion = updateToSchemaVersion43(session);
    716726      }
    717727
     
    15891599      if (tx != null) HibernateUtil.rollback(tx);
    15901600      log.error("updateToSchemaVersion39: FAILED", ex);
    1591       throw ex;
    1592     }
    1593     return schemaVersion;   
    1594   }
    1595 
    1596   /**
    1597     Update property filter on 'guiContexts.itemType' to '$ctx.itemType'
    1598     @return The new schema version (=40)
    1599   */
    1600   private static int updateToSchemaVersion40(org.hibernate.Session session)
    1601   {
    1602     final int schemaVersion = 40;
    1603     org.hibernate.Transaction tx = null;
    1604     try
    1605     {
    1606       tx = HibernateUtil.newTransaction(session);
    1607  
    1608       // Change property values
    1609       org.hibernate.Query query = HibernateUtil.getPredefinedSQLQuery(session,
    1610           "UPDATE_PROPERTY_FILTER");
    1611       /*
    1612         UPDATE PropertyFilters pf
    1613         SET pf.property = :newProperty
    1614         WHERE pf.property = :oldProperty
    1615        */
    1616       query.setString("oldProperty", "guiContexts.itemType");
    1617       query.setString("newProperty", "$ctx.itemType");
    1618       HibernateUtil.executeUpdate(query);
    1619 
    1620       // Update the schema version number
    1621       setSchemaVersion(session, schemaVersion);
    1622  
    1623       // Commit the changes
    1624       HibernateUtil.commit(tx);
    1625       log.info("updateToSchemaVersion40: OK");
    1626     }
    1627     catch (BaseException ex)
    1628     {
    1629       if (tx != null) HibernateUtil.rollback(tx);
    1630       log.error("updateToSchemaVersion40: FAILED", ex);
    16311601      throw ex;
    16321602    }
     
    17181688  }
    17191689 
    1720  
     1690  /**
     1691    Update property filter on 'guiContexts.itemType' to '$ctx.itemType'
     1692    @return The new schema version (=43)
     1693  */
     1694  private static int updateToSchemaVersion43(org.hibernate.Session session)
     1695  {
     1696    final int schemaVersion = 43;
     1697    org.hibernate.Transaction tx = null;
     1698    try
     1699    {
     1700      tx = HibernateUtil.newTransaction(session);
     1701 
     1702      // Change property values
     1703      org.hibernate.Query query = HibernateUtil.getPredefinedSQLQuery(session,
     1704          "UPDATE_PROPERTY_FILTER");
     1705      /*
     1706        UPDATE PropertyFilters pf
     1707        SET pf.property = :newProperty
     1708        WHERE pf.property = :oldProperty
     1709       */
     1710      query.setString("oldProperty", "guiContexts.itemType");
     1711      query.setString("newProperty", "$ctx.itemType");
     1712      HibernateUtil.executeUpdate(query);
     1713 
     1714      // Update the schema version number
     1715      setSchemaVersion(session, schemaVersion);
     1716 
     1717      // Commit the changes
     1718      HibernateUtil.commit(tx);
     1719      log.info("updateToSchemaVersion40: OK");
     1720    }
     1721    catch (BaseException ex)
     1722    {
     1723      if (tx != null) HibernateUtil.rollback(tx);
     1724      log.error("updateToSchemaVersion40: FAILED", ex);
     1725      throw ex;
     1726    }
     1727    return schemaVersion;   
     1728  }
     1729
    17211730  /**
    17221731    Adjust the existing items in the database to be compatible with the latest mappings.
  • branches/filedb/src/core/net/sf/basedb/util/overview/ExperimentOverview.java

    r3675 r3796  
    283283   
    284284    // Load 'Required for MIAME' annotation types (parameter='false' must also be set)
    285     ItemQuery<AnnotationType> query = initQuery(AnnotationType.getQuery(null), "name");
     285    ItemQuery<AnnotationType> query = initQuery(AnnotationType.getQuery(null), null, "name");
    286286    query.restrict(
    287287      Restrictions.eq(
     
    556556    Node efNode = new Node("experimental.factors", "Experimental factors", rootNode);
    557557    Experiment experiment = (Experiment)rootNode.getItem();
    558     ItemQuery<AnnotationType> efQuery = initQuery(experiment.getExperimentalFactors(), "name");
     558    ItemQuery<AnnotationType> efQuery = initQuery(experiment.getExperimentalFactors(), null, "name");
    559559    for (AnnotationType ef : efQuery.list(dc))
    560560    {
     
    574574    Node rawBioAssaysNode = new Node("rawbioassays", "Raw bioassays", rootNode);
    575575    Experiment experiment = (Experiment)rootNode.getItem();
    576     ItemQuery<RawBioAssay> rbaQuery = initQuery(experiment.getRawBioAssays(), "name");
     576    ItemQuery<RawBioAssay> rbaQuery = initQuery(experiment.getRawBioAssays(), null, "name");
    577577    Set<BasicItem> arrayDesigns = new HashSet<BasicItem>();
    578578    for (RawBioAssay rba : rbaQuery.list(dc))
     
    801801    Node imagesNode = new Node("images", "Images", scanNode);
    802802    Scan scan = (Scan)scanNode.getItem();
    803     ItemQuery<Image> imageQuery = initQuery(scan.getImages(), "name");
     803    ItemQuery<Image> imageQuery = initQuery(scan.getImages(), null, "name");
    804804    for (Image image : imageQuery.list(dc))
    805805    {
     
    831831    Hybridization hyb = (Hybridization)hybNode.getItem();
    832832    ItemQuery<LabeledExtract> leQuery =
    833       (ItemQuery<LabeledExtract>)initQuery(hyb.getCreationEvent().getSources(), "label.name");
     833      (ItemQuery<LabeledExtract>)initQuery(hyb.getCreationEvent().getSources(), null, "label.name");
    834834    int added = 0;
    835835    int channels = experiment.getRawDataType().getChannels();
     
    935935   
    936936    ItemQuery<LabeledExtract> sourceQuery =
    937       initQuery((ItemQuery<LabeledExtract>)product.getCreationEvent().getSources(), "name");
     937      initQuery((ItemQuery<LabeledExtract>)product.getCreationEvent().getSources(), null, "name");
    938938   
    939939    int added = 0;
     
    10581058   
    10591059    ItemQuery<Extract> sourceQuery =
    1060       initQuery((ItemQuery<Extract>)product.getCreationEvent().getSources(), "name");
     1060      initQuery((ItemQuery<Extract>)product.getCreationEvent().getSources(), null, "name");
    10611061   
    10621062    int added = 0;
     
    11621162   
    11631163    ItemQuery<Sample> sourceQuery =
    1164       initQuery((ItemQuery<Sample>)product.getCreationEvent().getSources(), "name");
     1164      initQuery((ItemQuery<Sample>)product.getCreationEvent().getSources(), null, "name");
    11651165   
    11661166    int added = 0;
     
    15341534    AnnotationSet as = annotatable != null && annotatable.isAnnotated() ?
    15351535        annotatable.getAnnotationSet() : null;
    1536     ItemQuery<AnnotationType> parameterQuery = initQuery(protocol.getParameters(), "name");
     1536    ItemQuery<AnnotationType> parameterQuery = initQuery(protocol.getParameters(), null, "name");
    15371537    List<AnnotationType> parameters = parameterQuery.list(dc);
    15381538    Node parameterNode = null;
     
    15821582      annotationsNode = new Node("annotations", "Annotations", parentNode);
    15831583      AnnotationSet as = parent.getAnnotationSet();
    1584       ItemQuery<Annotation> annotationQuery = initQuery(as.getAnnotations(), "annotationType.name");
     1584      ItemQuery<Annotation> annotationQuery = initQuery(as.getAnnotations(), null, "annotationType.name");
    15851585   
    15861586      for (Annotation a : annotationQuery.list(dc))
     
    16621662      annotationTypes.clear();
    16631663      AnnotationSet as = parent.getAnnotationSet();
    1664       ItemQuery<Annotation> annotationQuery = initQuery(as.getAllInheritedAnnotations(), "annotationType.name");
     1664      ItemQuery<Annotation> annotationQuery = initQuery(as.getAllInheritedAnnotations(), "at", "name");
     1665      annotationQuery.join(Hql.innerJoin(null, "annotationType", "at", true));
    16651666      List<Annotation> inherited = annotationQuery.list(dc);
    16661667      if (inherited.size() > 0)
     
    17271728    Set include options and sorting order for a query.
    17281729  */
    1729   private <T extends BasicItem> ItemQuery<T> initQuery(ItemQuery<T> query, String sortProperty)
     1730  private <T extends BasicItem> ItemQuery<T> initQuery(ItemQuery<T> query, String sortAlias, String sortProperty)
    17301731  {
    17311732    query.include(Include.MINE, Include.IN_PROJECT, Include.SHARED, Include.OTHERS);
    1732     query.order(Orders.asc(Hql.property(sortProperty)));
     1733    query.order(Orders.asc(Hql.property(sortAlias, sortProperty)));
    17331734    return query;
    17341735  }
  • branches/filedb/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java

    r3783 r3796  
    13771377        if (bas == null)
    13781378        {
    1379           bas = t.newProduct(null, "new", false);
     1379          bas = t.newProduct("new", "new", false);
    13801380        }
    13811381        spotBatcher = bas.getSpotBatcher();
  • branches/filedb/src/plugins/core/net/sf/basedb/plugins/PackedFileExporter.java

    r3675 r3796  
    376376    // Prepare for compression
    377377    String rootPath = rootDir.getPath().toString();
     378    if (!rootPath.endsWith("/")) rootPath += "/";
    378379    out.setMimeType(packer.getMimeType());
    379380    out.setFilename(generateDefaultName(packer, rootDir, itemsToPack));
     
    405406     
    406407      // Remove rootPath from entryPath
    407       entryPath = entryPath.substring(rootPath.length()+1);
     408      entryPath = entryPath.substring(rootPath.length());
    408409     
    409410      // Update progress
     
    657658  private String generateDefaultPath(FilePacker packer, Directory rootDir, Collection<Nameable> selectedItems)
    658659  {
    659     String defaultPath = rootDir == null ? "~/" : rootDir.getPath().toString() + "/";
     660    String defaultPath = rootDir == null ? "~/" : rootDir.getPath().toString();
     661    if (!defaultPath.endsWith("/")) defaultPath += "/";
    660662    defaultPath +=  generateDefaultName(packer, rootDir, selectedItems);
    661663    return defaultPath;
  • branches/filedb/src/test/TestAnnotation.java

    r3783 r3796  
    2626
    2727import net.sf.basedb.core.*;
     28import net.sf.basedb.core.query.Hql;
     29import net.sf.basedb.core.query.Orders;
    2830
    2931import java.util.Date;
     
    8183    // Test: list inherited annotations and annotation sets
    8284    test_list_inherited_annotations(rawBioAssayId, 2);
     85    test_list_allinherited_annotations(rawBioAssayId, 9);
    8386    test_list_inherited_annotationsets(rawBioAssayId, 1);
    8487    test_list_inheriting_annotationsets(arrayDesignId, 1);
     
    342345    }
    343346  }
     347 
     348  static void test_list_allinherited_annotations(int rawBioAssayId, int expectedResults)
     349  {
     350    if (rawBioAssayId == 0) return;
     351    DbControl dc = null;
     352    try
     353    {
     354      dc = TestUtil.getDbControl();
     355      RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId);
     356      ItemQuery<Annotation> query = rba.getAnnotationSet().getAllInheritedAnnotations();
     357      query.join(Hql.innerJoin(null, "annotationType", "at", true));
     358      query.order(Orders.asc(Hql.property("at", "name")));
     359      List<Annotation> l = query.list(dc);
     360      for (int i = 0; i<l.size(); i++)
     361      {
     362        write_item(i, l.get(i));
     363      }
     364      if (expectedResults >= 0 && expectedResults != l.size())
     365      {
     366        throw new BaseException("Expected "+expectedResults+" results, not "+l.size());
     367      }
     368      write("--List all inherited annotations OK ("+l.size()+")");
     369    }
     370    catch (Throwable ex)
     371    {
     372      write("--List all inherited annotations FAILED");
     373      ex.printStackTrace();
     374      ok = false;
     375    }
     376    finally
     377    {
     378      if (dc != null) dc.close();
     379    }
     380  }
    344381
    345382  static void test_list_inherited_annotationsets(int rawBioAssayId, int expectedResults)
  • branches/filedb/src/test/TestPath.java

    r3679 r3796  
    4242  {
    4343    write("++Testing path");
    44     test_create("/filename", Path.Type.FILE);
    45     test_create("/directory/filename", Path.Type.FILE);
    46     test_create("/directory/subdirectory/filename", Path.Type.FILE);
    47     test_create("~userlogin/filename", Path.Type.FILE);
    48     test_create("~userlogin/directory/filename", Path.Type.FILE);
    49     test_create("~userlogin/directory/subdirectory/filename", Path.Type.FILE);
    50     test_create("~/filename", Path.Type.FILE);
    51     test_create("~/directory/filename", Path.Type.FILE);
    52     test_create("~/directory/subdirectory/filename", Path.Type.FILE);
     44    test_create("/filename", Path.Type.FILE, false);
     45    test_create("/directory/filename", Path.Type.FILE, false);
     46    test_create("/directory/subdirectory/filename", Path.Type.FILE, false);
     47    test_create("~userlogin/filename", Path.Type.FILE, false);
     48    test_create("~userlogin/directory/filename", Path.Type.FILE, false);
     49    test_create("~userlogin/directory/subdirectory/filename", Path.Type.FILE, false);
     50    test_create("~/filename", Path.Type.FILE, false);
     51    test_create("~/directory/filename", Path.Type.FILE, false);
     52    test_create("~/directory/subdirectory/filename", Path.Type.FILE, false);
    5353
    54     test_create("/", Path.Type.DIRECTORY);
    55     test_create("/directory", Path.Type.DIRECTORY);
    56     test_create("/directory/subdirectory", Path.Type.DIRECTORY);
    57     test_create("/directory/subdirectory/subsub", Path.Type.DIRECTORY);
    58     test_create("~userlogin", Path.Type.DIRECTORY);
    59     test_create("~userlogin/directory", Path.Type.DIRECTORY);
    60     test_create("~userlogin/directory/subdirectory", Path.Type.DIRECTORY);
    61     test_create("~userlogin/directory/subdirectory/subsub", Path.Type.DIRECTORY);
    62     test_create("~", Path.Type.DIRECTORY);
    63     test_create("~/directory", Path.Type.DIRECTORY);
    64     test_create("~/directory/subdirectory", Path.Type.DIRECTORY);
    65     test_create("~/directory/subdirectory/subsub", Path.Type.DIRECTORY);
     54    test_create("/", Path.Type.DIRECTORY, false);
     55    test_create("/directory", Path.Type.DIRECTORY, false);
     56    test_create("/directory/subdirectory", Path.Type.DIRECTORY, false);
     57    test_create("/directory/subdirectory/subsub", Path.Type.DIRECTORY, false);
     58    test_create("~userlogin", Path.Type.DIRECTORY, false);
     59    test_create("~userlogin/directory", Path.Type.DIRECTORY, false);
     60    test_create("~userlogin/directory/subdirectory", Path.Type.DIRECTORY, false);
     61    test_create("~userlogin/directory/subdirectory/subsub", Path.Type.DIRECTORY, false);
     62    test_create("~", Path.Type.DIRECTORY, false);
     63    test_create("~/directory", Path.Type.DIRECTORY, false);
     64    test_create("~/directory/subdirectory", Path.Type.DIRECTORY, false);
     65    test_create("~/directory/subdirectory/subsub", Path.Type.DIRECTORY, false);
    6666
    6767    test_valid_name("abc", true);
     
    7777    test_valid_name("|abc", false);
    7878   
     79    test_create("/file<name>", Path.Type.FILE, true);
     80    test_create("/dire<ctory>/filename", Path.Type.FILE, true);
     81    test_create("/directory/file<name>", Path.Type.FILE, true);
     82    test_create("/sub<dir>", Path.Type.DIRECTORY, true);
     83    test_create("/directory/sub<dir>", Path.Type.DIRECTORY, true);
     84   
    7985    test_replace_invalid("abc", ".", "abc");
    8086    test_replace_invalid("~abc", ".", ".abc");
     
    8591  }
    8692 
    87   static void test_create(String path, Path.Type type)
     93  static void test_create(String path, Path.Type type, boolean shouldFail)
    8894  {
    8995    try
     
    95101        throw new Exception("Original path ("+path+") is different from path: "+pp);
    96102      }
    97       write("--Path " + p.getType() + ": '"+p+"' OK");
     103      if (shouldFail)
     104      {
     105        write("--Path '"+path+"' FAILED");
     106        new Throwable("Expected test to fail but it didn't.").printStackTrace();
     107        ok = false;
     108      }
     109      else
     110      {
     111        write("--Path " + p.getType() + ": '"+p+"' OK");
     112      }
    98113    }
    99114    catch (Throwable ex)
    100115    {
    101       write("--Path '"+path+"' FAILED");
    102       ex.printStackTrace();
    103       ok = false;
     116      if (!shouldFail)
     117      {
     118        write("--Path '"+path+"' FAILED");
     119        ex.printStackTrace();
     120        ok = false;
     121      }
     122      else
     123      {
     124        write("--Path " + type + ": '"+path+"' OK");
     125      }
    104126    }
    105127  }
  • branches/filedb/www/common/annotations/list_annotations.jsp

    r3679 r3796  
    8383  {
    8484    ItemQuery<Annotation> inheritedQuery = as.getAllInheritedAnnotations();
     85    // Need FETCH JOIN because Postgres don't like the DISTINCT keyword
     86    // if we sort on a non-selected column See ticket #731
     87    inheritedQuery.join(Hql.innerJoin(null, "annotationType", "at", true));
    8588    inheritedQuery.order(Orders.asc(Hql.property("annotationSet")));
    86     inheritedQuery.order(Orders.asc(Hql.property("annotationType.name")));
     89    inheritedQuery.order(Orders.asc(Hql.property("at", "name")));
    8790    inheritedAnnotations = inheritedQuery.list(dc);
    8891  }
  • branches/filedb/www/views/reporters/index.jsp

    r3679 r3796  
    4141  import="net.sf.basedb.core.DataQuery"
    4242  import="net.sf.basedb.core.PermissionDeniedException"
     43  import="net.sf.basedb.core.BaseException"
    4344  import="net.sf.basedb.util.RemovableUtil"
    4445  import="net.sf.basedb.util.ShareableUtil"
     
    175176    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    176177    ReporterBatcher batcher = ReporterBatcher.getNew(dc);
    177     batcher.delete(cc.getId());
    178     batcher.close();
    179     dc.commit();
    180     redirect = listPage;
     178    try
     179    {
     180      batcher.delete(cc.getId());
     181      batcher.close();
     182      dc.commit();   
     183      redirect = listPage;
     184    }
     185    catch (BaseException bex)
     186    {
     187      message = "The reporter can not be deleted. " +
     188        "Probably because it is used by other items";
     189      redirect = viewPage + "&popmessage="+HTML.urlEncode(message);
     190    }
    181191  }
    182192  else if ("DeleteItems".equals(cmd))
     
    186196    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    187197    ReporterBatcher batcher = ReporterBatcher.getNew(dc);
     198    batcher.setBatchSize(1);
     199    int notDeleted = 0;
    188200    for (int reporterId : cc.getSelected())
    189201    {
    190       batcher.delete(reporterId);
    191     }
    192     batcher.close();
     202      try
     203      {
     204        batcher.delete(reporterId);
     205      }
     206      catch (BaseException bex)
     207      {
     208        notDeleted++;
     209      }     
     210    }   
    193211    dc.commit();
    194     redirect = listPage;
     212    message = notDeleted > 0 ? notDeleted + " reporters can not be deleted. " +
     213        "Probably because they are used by other items" : null;
     214    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
    195215  }
    196216  else if ("ExportItems".equals(cmd))
Note: See TracChangeset for help on using the changeset viewer.