Ignore:
Timestamp:
Jun 14, 2007, 2:36:26 PM (15 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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   }
Note: See TracChangeset for help on using the changeset viewer.