Changeset 3495


Ignore:
Timestamp:
Jun 14, 2007, 2:36:26 PM (14 years ago)
Author:
Nicklas Nordborg
Message:

References #625. Major features are now in place. It's a bit tricky to update the isInContext
method on all plug-ins. I need more testing time to verify that all works before I close the
ticket.

Location:
trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/src/docbook/appendix/incompatible.xml

    r3487 r3495  
    4848  <sect1 id="appendix.incompatible.2.4">
    4949    <title>BASE 2.4 release</title>
     50   
     51    <bridgehead>Plugin API</bridgehead>
     52    <para>
     53      The <methodname>InteractivePlugin.isInContext()</methodname>
     54      method may now throw exceptions to indicate error-level
     55      messages. Messages that are returned by the method are
     56      considered as a warning message and are by default no longer
     57      shown to the users.
     58      See <xref linkend="plugin_developer.api.interfaces.interactive" />
     59      and <xref linkend="webclient.configuration.preferences.plugins" />.
     60    </para>
     61   
    5062    <bridgehead>JEP parser</bridgehead>
    51    
    5263    <para>
    5364      The <methodname>Jep.nodeToExpression()</methodname>
  • trunk/doc/src/docbook/developerdoc/plugin_developer.xml

    r3487 r3495  
    711711              <para>
    712712                This method is called to check if a particular item is usable for the
    713                 plug-in. This method is only invoked from the single-item view.
    714                 Thus, <code>context.getType()</code> always returns
    715                 <constant>Type.ITEM</constant>, and <code>context.getItem()</code>
    716                 returns a value corresponding to the type of item that is passed
    717                 in the <varname>item</varname> parameter. Here is an example:
    718                
    719                 <informalexample>
     713                plug-in. This method is invoked to check if a plug-in can be used
     714                in a given context. If invoked from a list context the <parameter>item</parameter>
     715                parameter is <constant>null</constant>. 
     716                The plug-in should return <constant>null</constant> if it
     717                finds that it can be used. If the plug-in can't be used it
     718                must decide if the reason should be a warning or an error condition.
     719              </para>
     720             
     721              <para>
     722                A warning is issued by returning a string with the warning
     723                message. It should be used when the plug-in can't be used because
     724                it is unrelated to the current task. For example, a plug-in for
     725                importing Genepix data should return a warning when somebody wants
     726                to import data to an Agilent raw bioassay.
     727              </para>
     728             
     729              <para>
     730                An error message is issued by throwing an exception. This
     731                should be used when the plug-in is related to the current task
     732                but still can't do what it is supposed to do. For example,
     733                trying to import raw data if the logged in user doesn't have
     734                write permission to the raw bioassay.
     735              </para>
     736             
     737              <para>
     738                As a rule of thumb, if there is a chance that another plug-in
     739                might be able to perform the same task a warning should be used.
     740                If it is guaranteed that no other plug-in can do it an error
     741                message should be used.
     742              </para>
     743             
     744              <note>
    720745                <para>
    721                 The user has selected a specific sample and the client
    722                 application is now displaying information about that sample.
    723                 Thus, our
    724                 <varname>GuiContext</varname> =
    725                 (<constant>Item.SAMPLE</constant>,
    726                 <constant>Type.ITEM</constant>).
    727                
    728                 Now, the client application asks for a list of plug-ins supporting
    729                 this context and for each one in the list calls this method with the
    730                 current sample as the value of the <varname>item</varname> parameter.
     746                The contract of this method was changed in in BASE 2.4
     747                to allow warning and error level message. Prior to BASE
     748                2.4 all messages were treated as error message. We recommend
     749                that existing plug-ins are updated to throw exception to indicate
     750                error-level messages since the default is to not show
     751                warning messages to users.
    731752                </para>
    732                 </informalexample>
    733 
    734                 If the plug-in can do whatever it is supposed to do it should
    735                 return null, otherwise it should return a string with a message
    736                 explaining why it cannot.
    737               </para>
     753              </note>
     754             
    738755              <para>
    739756                Here is a real example from the
     
    747764                <constant>Type.ITEM</constant>),
    748765               
    749                 but the plug-in can only import data if there is no data already, and
     766                but the plug-in can only import data if the logged in user has write permission,
     767                there is no data already, and
    750768                if the raw bioassay has the same raw data type as the plug-in has been
    751769                configured for.
     
    758776<programlisting>/**
    759777   Returns null if the item is a {@link RawBioAssay} of the correct
    760    {@link RawDataType} and does not already have spots.
     778   {@link RawDataType} and doesn't already have spots.
     779   @throws PermissionDeniedException If the raw bioasssay already has raw data
     780   or if the logged in user doesn't have write permission
    761781*/
    762782public String isInContext(GuiContext context, Object item)
     
    775795      RawBioAssay rba = (RawBioAssay)item;
    776796      String rawDataType = (String)configuration.getValue("rawDataType");
    777       if (rba.getSpots() > 0)
    778       {
    779          message = "The raw bioassay already has spots: " + rba.getName();
    780       }
    781       else if (!rba.getRawDataType().getId().equals(rawDataType))
     797      RawDataType rdt = rba.getRawDataType();
     798      if (!rdt.getId().equals(rawDataType))
    782799      {
    783800         message = "Unsupported raw data type: " + rba.getRawDataType().getName();
     801      }
     802      else if (!rdt.isStoredInDb())
     803      {
     804         message = "Raw data for raw data type '" + rdt + "' is not stored in the database";
     805      }
     806      else if (rba.hasData())
     807      {
     808         throw new PermissionDeniedException("The raw bioassay already has data.");
     809      }
     810      else
     811      {
     812         rba.checkPermission(Permission.WRITE);
    784813      }
    785814   }
  • trunk/doc/src/docbook/userdoc/webclient.xml

    r3492 r3495  
    117117          <listitem>
    118118            <para>
    119             Messages are sent by plugins to notify you about finished jobs. In the
     119            Messages are sent by plug-ins to notify you about finished jobs. In the
    120120            future, you may get messages from other sources as well. As of today,
    121121            messages are not used for communication between users.
     
    687687         
    688688          <para>
    689             This tab contains settings that affect plugin execution.
     689            This tab contains settings that affect plug-in execution.
    690690          </para>
    691691         
     
    698698                <para>
    699699                Mark the checkbox if you want to have a message sent
    700                 to you when a plugin completes execution. This setting
    701                 can be overridden each time you start a plugin.
     700                to you when a plug-in completes execution. This setting
     701                can be overridden each time you start a plug-in.
    702702                </para>
    703703              </listitem>
     
    710710                <para>
    711711                  This checkbox should be marked if you want the jobs, done by
    712                   import or export plugins, to be marked as removed if they
     712                  import or export plug-ins, to be marked as removed if they
    713713                  finished successfully. This setting can be overridden each time
    714                   you start a plugin.
     714                  you start a plug-in.
     715                </para>
     716              </listitem>
     717            </varlistentry>
     718            <varlistentry>
     719              <term>
     720                <guilabel>Show warnings</guilabel>
     721              </term>
     722              <listitem>
     723                <para>
     724                  This checkbox should be marked if you want to show warning
     725                  messages from plug-ins in the <guilabel>Select plug-in</guilabel>
     726                  dialog. Warning-level messages usually originates from plug-ins
     727                  that are unrelated to the current task and are only of interest to
     728                  plug-in developers. Error messages that are related to the
     729                  current task are always shown.
    715730                </para>
    716731              </listitem>
  • trunk/src/core/net/sf/basedb/core/plugin/AbstractAnalysisPlugin.java

    r2745 r3495  
    3333import net.sf.basedb.core.ItemParameterType;
    3434import net.sf.basedb.core.Nameable;
     35import net.sf.basedb.core.Permission;
    3536import net.sf.basedb.core.PluginConfiguration;
    3637import net.sf.basedb.core.PluginParameter;
     
    120121    Check that the item is a bioassayset.
    121122    @return null if the item is a bioassayset, an error message otherwise
     123    @throws PermissionDeniedException If the
    122124  */
    123125  public String isInContext(GuiContext context, Object item)
    124126  {
    125127    String message = null;
    126     if (item == null)
    127     {
    128       message = "The object is null";
    129     }
    130     else if (!(item instanceof BioAssaySet))
    131     {
    132       message = "The object is not a BioAssaySet: " + item;
     128    if (defaultGuiContexts.contains(context))
     129    {
     130      if (item == null)
     131      {
     132        message = "The object is null";
     133      }
     134      else if (!(item instanceof BioAssaySet))
     135      {
     136        message = "The object is not a BioAssaySet: " + item;
     137      }
     138      else
     139      {
     140        BioAssaySet bas = (BioAssaySet)item;
     141        Experiment e = bas.getExperiment();
     142        e.checkPermission(Permission.USE);
     143      }
    133144    }
    134145    return message;
  • trunk/src/core/net/sf/basedb/core/plugin/InteractivePlugin.java

    r2601 r3495  
    7878  /**
    7979    Check if the plugin can be used on the specified object. The item is either
    80     a <code>BasicItem</code> or <code>BasicData</code> object. A client
    81     application should only call this method for contexts matching one of
     80    a <code>BasicItem</code> or <code>BasicData</code> object, or null if called from
     81    a list context. A client application should only call this method for
     82    contexts matching one of
    8283    the contexts in the set returned by the {@link #getGuiContexts()}
    8384    method. For {@link GuiContext.Type#ITEM} contexts an item
    8485    of the correct type should be passed as a parameter.
     86    <p>
     87    The plug-in can response with a null value indicating success,
     88    a warning-level message or throw an exception to indicate an
     89    error-level message. Client application should normally only
     90    show error-level messages to users, unless the user has
     91    requested to see warning messages.
     92    <p>
     93    NOTE! Before BASE 2.4 all messages were treated as error-level
     94    messages.
    8595   
    8696    @param context The current context of the client application,
     
    90100      context
    91101    @return <code>Null</code> if the plugin can use that item, or
    92       a message explaining why the plugin can't be used
     102      a warning-level message explaining why the plugin can't be used
     103    @throws RuntimeException With an error-leve message explaining
     104      why the plug-in can't be used
    93105  */
    94106  public String isInContext(GuiContext context, Object item);
  • trunk/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java

    r3421 r3495  
    304304        }
    305305      }
    306       catch (Exception e)
    307       {
    308         message = e.getMessage();
    309         e.printStackTrace();
    310       }
    311306      finally
    312307      {
  • trunk/src/plugins/core/net/sf/basedb/plugins/CdfFileReporterImporter.java

    r3482 r3495  
    4848import net.sf.basedb.core.File;
    4949import net.sf.basedb.core.FileParameterType;
     50import net.sf.basedb.core.InvalidDataException;
    5051import net.sf.basedb.core.Item;
    5152import net.sf.basedb.core.ItemContext;
     
    228229        message = "The array design is not an Affymetrix chip";
    229230      }
    230       File cdfFile = null;
    231       try
    232       {
    233           cdfFile = Affymetrix.getCdfFile(design);
    234       }
    235       catch (Throwable t)
    236       {}
    237       if (cdfFile == null)
    238       {
    239         message = "The array design doesn't have a CDF file (or you don't have permission to read it)";
     231      else
     232      {
     233        File cdfFile = Affymetrix.getCdfFile(design);
     234        if (cdfFile == null)
     235        {
     236          throw new InvalidDataException("The array design doesn't have a CDF file");
     237        }
    240238      }
    241239    }
  • trunk/src/plugins/core/net/sf/basedb/plugins/IntensityCalculatorPlugin.java

    r2745 r3495  
    296296        return "Raw data for raw data type '" + e.getRawDataType() + "' is not stored in the database.";
    297297      }
     298      else
     299      {
     300        e.checkPermission(Permission.USE);
     301      }
    298302    }
    299303    catch (Throwable ex)
  • trunk/src/plugins/core/net/sf/basedb/plugins/PluginConfigurationExporter.java

    r3011 r3495  
    114114  public String isInContext(GuiContext context, Object item)
    115115  {
    116     String message = null;
    117     if (context.equals(configList))
    118     {
    119       if (item == null)
    120       {
    121         message = "The object is null";
    122       }
    123       else if (!(item instanceof PluginConfiguration))
    124       {
    125         message = "The object is not a list of PluginConfiguration: " + item;
    126       }
    127     }
    128     return message;
     116    return null;
    129117  }
    130118
  • trunk/src/plugins/core/net/sf/basedb/plugins/PluginConfigurationImporter.java

    r2992 r3495  
    130130  public String isInContext(GuiContext context, Object item)
    131131  {
    132     String message = null;
    133     if (context.equals(pluginConfigurationList))
    134     {
    135       if (item == null)
    136       {
    137         message = "The item is null";
    138       }
    139       else if (!(item instanceof PluginConfiguration))
    140       {
    141         message = "The object is not a PluginConfiguration: " + item;
    142       }
    143     }
    144     return message;
     132    return null;
    145133  }
    146134
  • trunk/src/plugins/core/net/sf/basedb/plugins/PrintMapFlatFileImporter.java

    r2992 r3495  
    186186    {
    187187      ArrayDesign ad = (ArrayDesign)item;
    188       if (ad.hasFeatures())
    189       {
    190         message = "The array design already has features: " + ad.getName();
    191       }
    192       else if (ad.isAffyChip())
    193       {
    194         message = "Affy array designs are not supported: " + ad.getName();
     188      if (ad.isAffyChip())
     189      {
     190        message = "Affy array designs are not supported";
     191      }
     192      else if (ad.hasFeatures())
     193      {
     194        throw new PermissionDeniedException("The array design already has features");
     195      }
     196      else
     197      {
     198        ad.checkPermission(Permission.WRITE);
    195199      }
    196200    }
  • trunk/src/plugins/core/net/sf/basedb/plugins/RawDataFlatFileImporter.java

    r3493 r3495  
    3232import net.sf.basedb.core.ItemParameterType;
    3333import net.sf.basedb.core.Permission;
     34import net.sf.basedb.core.PermissionDeniedException;
    3435import net.sf.basedb.core.PluginParameter;
    3536import net.sf.basedb.core.RawBioAssay;
     
    268269    Returns null if the item is a {@link RawBioAssay} of the correct
    269270    {@link RawDataType} and doesn't already have spots.
     271    @throws PermissionDeniedException If the raw bioasssay already has raw data
     272      or if the logged in user doesn't have write permission
    270273  */
    271274  public String isInContext(GuiContext context, Object item)
     
    285288      String rawDataType = (String)configuration.getValue("rawDataType");
    286289      RawDataType rdt = rba.getRawDataType();
    287       if (rba.hasData())
    288       {
    289         message = "The raw bioassay already has data: " + rba.getName();
     290      if (!rdt.getId().equals(rawDataType))
     291      {
     292        message = "Unsupported raw data type: " + rba.getRawDataType().getName();
    290293      }
    291294      else if (!rdt.isStoredInDb())
     
    293296        message = "Raw data for raw data type '" + rdt + "' is not stored in the database";
    294297      }
    295       else if (!rdt.getId().equals(rawDataType))
    296       {
    297         message = "Unsupported raw data type: " + rba.getRawDataType().getName();
     298      else if (rba.hasData())
     299      {
     300        throw new PermissionDeniedException("The raw bioassay already has data.");
     301      }
     302      else
     303      {
     304        rba.checkPermission(Permission.WRITE);
    298305      }
    299306    }
  • trunk/src/plugins/core/net/sf/basedb/plugins/ReporterFlatFileImporter.java

    r3493 r3495  
    237237    Null if the context is {@link Item#REPORTERLIST} and the
    238238    item is a {@link ReporterList}.
     239    @throws PermissionDeniedException If the user doesn't have write permission
     240      to the reporter list
    239241  */
    240242  public String isInContext(GuiContext context, Object item)
     
    250252      {
    251253        message = "The object is not a ReporterList: " + item;
     254      }
     255      else
     256      {
     257        ReporterList rl = (ReporterList)item;
     258        rl.checkPermission(Permission.WRITE);
    252259      }
    253260    }
  • trunk/src/plugins/core/net/sf/basedb/plugins/ReporterMapFlatFileImporter.java

    r3493 r3495  
    244244    Returns null if the item is a {@link ArrayDesign} that doesn't already have
    245245    any features and isn't an affy design.
     246    @throws PermissionDeniedException If the array design already has features
     247      or if the logged in user doesn't have write permission
    246248  */
    247249  public String isInContext(GuiContext context, Object item)
     
    259261    {
    260262      ArrayDesign ad = (ArrayDesign)item;
    261       if (ad.hasFeatures())
     263      if (ad.isAffyChip())
    262264      {
    263         message = "The array design already has features: " + ad.getName();
     265        message = "Affy array designs are not supported";
    264266      }
    265       else if (ad.isAffyChip())
     267      else if (ad.hasFeatures())
    266268      {
    267         message = "Affy array designs are not supported: " + ad.getName();
     269        throw new PermissionDeniedException("The array design already has features");
     270      }
     271      else
     272      {
     273        ad.checkPermission(Permission.WRITE);
    268274      }
    269275    }
  • trunk/www/common/import/index.jsp

    r3438 r3495  
    115115    dc.close();
    116116
    117     boolean showWarnings = Values.getBoolean(sc.getUserClientSetting("plugins.showWarnings"), true);
     117    boolean showWarnings = Values.getBoolean(sc.getUserClientSetting("plugins.showWarnings"), false);
    118118    int totalPlugins = ContextUtil.countUsuablePlugins(contextResult);
    119119    Set<String> contextMessages = ContextUtil.getContextMessages(contextResult, showWarnings, true);
  • trunk/www/common/plugin/index.jsp

    r3480 r3495  
    154154    dc.close();
    155155
    156     boolean showWarnings = Values.getBoolean(sc.getUserClientSetting("plugins.showWarnings"), true);
     156    boolean showWarnings = Values.getBoolean(sc.getUserClientSetting("plugins.showWarnings"), false);
    157157    int totalPlugins = ContextUtil.countUsuablePlugins(contextResult);
    158158    Set<String> contextMessages = ContextUtil.getContextMessages(contextResult, showWarnings, true);
     
    173173    sc.setSessionSetting("MESSAGES", contextMessages);
    174174    sc.setSessionSetting("PLUGINS", contextResult);
    175     if (false && totalPlugins == 1 && contextMessages.size() == 0)
     175    if (totalPlugins == 1 && contextMessages.size() == 0)
    176176    {
    177177      // Only one plug-in exists, go directly to parameter input page
  • trunk/www/my_base/user/preferences.jsp

    r3492 r3495  
    440440      </td>
    441441    </tr>
     442    <tr>
     443      <td class="prompt">Show warnings</td>     
     444      <td>
     445        <%
     446        boolean showWarnings = Values.getBoolean(sc.getUserClientSetting("plugins.showWarnings"), false);
     447        %>
     448        <input type="checkbox" name="show_warnings" value="1" <%=showWarnings ? "checked" : "" %>>
     449        <a href="javascript:document.forms['preferences'].show_warnings.click();">Show plug-in warning messages when starting a new job.</a>
     450      </td>
     451    </tr>
    442452    </table>
    443453  </t:tab>
  • trunk/www/my_base/user/submit_user.jsp

    r3492 r3495  
    130130    sc.setUserClientSetting("plugins.sendmessage", Values.getString(request.getParameter("sendmessage"), "0"));
    131131    sc.setUserClientSetting("plugins.removejob", Values.getString(request.getParameter("removejob"), "0"));
     132    sc.setUserClientSetting("plugins.showWarnings", Values.getString(request.getParameter("show_warnings"), "0"));
    132133   
    133134    // Recent items tab
Note: See TracChangeset for help on using the changeset viewer.