Changeset 3979


Ignore:
Timestamp:
Nov 19, 2007, 2:00:34 PM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #828: Raw data importer should be able to set annotations on the imported raw bioassay

Location:
trunk
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/Base.java

    r3888 r3979  
    2626package net.sf.basedb.clients.web;
    2727
     28import net.sf.basedb.core.AnnotatableProxy;
    2829import net.sf.basedb.core.Coloring;
    2930import net.sf.basedb.core.DataFileType;
     
    813814
    814815  /**
     816    Get a query that returns all annotation types defined for a
     817    {@link AnnotatableProxy} item.
     818    @param proxy The annotatable proxy
     819    @return An <code>ItemQuery</code> object
     820  */
     821  public static ItemQuery<AnnotationType> getAnnotationTypesQuery(AnnotatableProxy proxy)
     822  {
     823    ItemQuery<AnnotationType> q = proxy.getAnnotationTypes();
     824    if (q == null)
     825    {
     826      // A query returning no annotations
     827      q = AnnotationType.getQuery(Item.SYSTEM);
     828    }
     829    q.order(Orders.asc(Hql.property("name")));
     830    q.include(Include.ALL);
     831    return q;
     832  }
     833 
     834  /**
    815835    Get a query that returns all annotation types assigned as parameters to
    816836    a specific protocol. The query will include all possible annotation types.
  • trunk/src/core/net/sf/basedb/core/AnnotationSet.java

    r3941 r3979  
    2727import java.util.LinkedList;
    2828import java.util.List;
     29import java.util.Map;
    2930import java.util.Set;
    3031
     
    3738import net.sf.basedb.core.data.AnnotationData;
    3839import net.sf.basedb.core.data.AnnotationSetData;
     40import net.sf.basedb.core.data.AnnotationTypeData;
    3941
    4042/**
     
    276278    {
    277279      checkPermission(Permission.WRITE);
    278       if (!annotationType.isEnabledForItem(getItemType()) && 
     280      // AnnotatableProxy items allow annotations of all types
     281      boolean isAnnotatableProxy = AnnotatableProxy.class.isAssignableFrom(getItemType().getItemClass());
     282      if (!isAnnotatableProxy && !annotationType.isEnabledForItem(getItemType()) && 
    279283        !annotationType.isProtocolParameter(getItem().getProtocol()))
    280284      {
     
    605609
    606610  /**
     611    Copy annotations from another annotatable item to this annotation set.
     612    This method will copy all annotations with an annotation type that is
     613    valid for this item type. The logged in user doesn't need to have access
     614    to all annotation types. The copy will still work. The logged in user must
     615    have write permission on this annotation set.
     616   
     617    @param item The item to copy annotation from
     618    @param overwrite TRUE to overwrite existing values
     619    @since 2.5
     620  */
     621  public void copyFrom(Annotatable item, boolean overwrite)
     622  {
     623    checkPermission(Permission.WRITE);
     624    if (!item.isAnnotated()) return;
     625    AnnotationSet fromAs = item.getAnnotationSet();
     626    Item toType = this.getItemType();
     627    DbControl dc = getDbControl();
     628   
     629    Map<AnnotationTypeData, AnnotationData> toAnnotations = this.getData().getAnnotations();
     630    Map<AnnotationTypeData, AnnotationData> fromAnnotations = fromAs.getData().getAnnotations();
     631   
     632    for (Map.Entry<AnnotationTypeData, AnnotationData> entry : fromAnnotations.entrySet())
     633    {
     634      AnnotationTypeData at = entry.getKey();
     635      // Check if the target item can hold annotation of this type
     636      if (at.getItemTypes().contains(toType.getValue()))
     637      {
     638        AnnotationData to = null;
     639        if (toAnnotations.containsKey(at))
     640        {
     641          // Use existing entry unless overwrite == false
     642          if (!overwrite) continue;
     643          to = toAnnotations.get(at);
     644        }
     645        else
     646        {
     647          // Create new annotation
     648          Type valueType = Type.fromValue(at.getValueType());
     649          to = new AnnotationData();
     650          to.setAnnotationSet(this.getData());
     651          to.setAnnotationType(at);
     652          to.setValues(valueType.newParameterValueData());
     653          toAnnotations.put(at, to);
     654          Annotation newAnnotation = new Annotation(to, this);
     655          dc.saveItemIf(this, newAnnotation, false);
     656        }
     657        // Copy the values
     658        AnnotationData from = entry.getValue();
     659        to.getValues().replaceValues(from.getValues().getValues());
     660      }
     661    }
     662  }
     663 
     664 
     665  /**
    607666    Get a query that returns all annotation sets inheriting from this annotation set.
    608667    @return An <code>ItemQuery</code> object
  • trunk/src/core/net/sf/basedb/core/Install.java

    r3871 r3979  
    107107    method.
    108108  */
    109   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(45).intValue();
     109  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(46).intValue();
    110110 
    111111  public static synchronized void createTables(boolean update, final ProgressReporter progress)
     
    593593        "net.sf.basedb.core.plugin.ImmediateDownloadExporter", null);
    594594      createPluginType("Analysis filter plug-in", "Analysis plug-ins that are pure filter plug-ins should " +
    595           "implement this interface. If they do they are linked with the 'Filter bioassayset' button and" +
    596           "not just the 'Run analysis plug-in' button.",
    597           "net.sf.basedb.core.plugin.AnalysisFilterPlugin", null);
     595        "implement this interface. If they do they are linked with the 'Filter bioassayset' button and" +
     596        "not just the 'Run analysis plug-in' button.",
     597        "net.sf.basedb.core.plugin.AnalysisFilterPlugin", null);
     598      createPluginType("Annotation setter", "This interface should be implemented by plug-ins that " +
     599        "wants to hold annotations that should be copied to another items when it is executed. When " +
     600        "a plug-in implements this interface, it becomes possible to add annotation of the specified " +
     601        "types to the plugin definition and/or configuration. The plug-in must copy the annotation values " +
     602        "itself.",
     603        "net.sf.basedb.core.plugin.AnnotationSetterPlugin", null);
    598604     
    599605      createPluginDefinition("net.sf.basedb.plugins.Base1PluginExecuter", null, null, true, null, false);
  • trunk/src/core/net/sf/basedb/core/PluginConfiguration.java

    r3789 r3979  
    2525package net.sf.basedb.core;
    2626
     27import net.sf.basedb.core.plugin.AnnotationSetterPlugin;
    2728import net.sf.basedb.core.plugin.GuiContext;
    2829import net.sf.basedb.core.plugin.InteractivePlugin;
     30import net.sf.basedb.core.plugin.ParameterValues;
     31import net.sf.basedb.core.plugin.Plugin;
    2932import net.sf.basedb.core.plugin.Request;
    3033import net.sf.basedb.core.data.PluginConfigurationData;
     
    5356*/
    5457public class PluginConfiguration
    55   extends CommonItem<PluginConfigurationData>
    56   implements Transactional
     58  extends AnnotatedItem<PluginConfigurationData>
     59  implements Transactional, AnnotatableProxy
    5760{
    5861  /**
     
    239242  }
    240243  // -------------------------------------------
     244  /*
     245    From the Annotatable & AnnotatableProxy interfaces
     246    -------------------------------------------
     247  */
     248  /**
     249    @return Always null
     250    @since 2.5
     251  */
     252  public Set<Annotatable> getAnnotatableParents()
     253  {
     254    return null;
     255  }
     256  /**
     257    Get the annotation types that can be used by this configuration. This method
     258    requires that the plug-in implements the {@link AnnotationSetterPlugin} interface.
     259    @return A query or null if this plug-in doesn't use annotations
     260    @since 2.5
     261  */
     262  public ItemQuery<AnnotationType> getAnnotationTypes()
     263  {
     264    Plugin p = getPluginDefinition().newInstance(Plugin.class, null, getSessionControl(), this, null);
     265    ItemQuery<AnnotationType> query = null;
     266    if (p instanceof AnnotationSetterPlugin)
     267    {
     268      query = ((AnnotationSetterPlugin)p).getAnnotationTypes();
     269    }
     270    return query;
     271  }
     272  /**
     273    Get a message explaining what the proxy does with the annotations.
     274    @return A message or null
     275    @since 2.5
     276  */
     277  public String getAnnotationMessage()
     278  {
     279    Plugin p = getPluginDefinition().newInstance(Plugin.class, null, getSessionControl(), this, null);
     280    String message = null;
     281    if (p instanceof AnnotationSetterPlugin)
     282    {
     283      message = ((AnnotationSetterPlugin)p).getAnnotationMessage();
     284    }
     285    return message;
     286  }
     287  // -------------------------------------------
    241288
    242289  /**
     
    386433  }
    387434
     435  /**
     436    Get the configuration parameters as a {@link ParameterValues} object.
     437    @param version The version of the parameters
     438    @return A ParameterValues object
     439    @see #getParameterVersion()
     440    @since 2.5
     441  */
     442  public ParameterValues getParameterValues(int version)
     443  {
     444    return getParameterValuesImpl(getParameterVersion());
     445  }
    388446 
    389447  /**
  • trunk/src/core/net/sf/basedb/core/PluginDefinition.java

    r3871 r3979  
    2929import net.sf.basedb.core.query.Expressions;
    3030import net.sf.basedb.core.query.Hql;
     31import net.sf.basedb.core.plugin.AnnotationSetterPlugin;
    3132import net.sf.basedb.core.plugin.Permissions;
    3233import net.sf.basedb.core.plugin.Plugin;
     
    3435import net.sf.basedb.core.plugin.About;
    3536import net.sf.basedb.core.plugin.GuiContext;
     37import net.sf.basedb.core.data.AnnotationSetData;
    3638import net.sf.basedb.core.data.PluginDefinitionData;
    3739import net.sf.basedb.core.data.PluginPermission;
     
    6264public class PluginDefinition
    6365  extends SharedItem<PluginDefinitionData>
    64   implements Nameable, Removable
     66  implements Nameable, Removable, AnnotatableProxy
    6567{
    6668  /**
     
    405407  // -------------------------------------------
    406408
     409  /*
     410    From the Annotatable & AnnotatableProxy interface
     411    -------------------------------------------
     412  */
     413  /**
     414    @since 2.5
     415  */
     416  public AnnotationSet getAnnotationSet()
     417    throws PermissionDeniedException, BaseException
     418  {
     419    DbControl dc = getDbControl();
     420    AnnotationSet as = dc.getItem(AnnotationSet.class, getData().getAnnotationSet(), this);
     421    if (as == null)
     422    {
     423      as = AnnotationSet.getNew(dc, this);
     424      getData().setAnnotationSet(as.getData());
     425      dc.saveItemIf(this, as, false);
     426    }
     427    return as;
     428  }
     429  /**
     430    @since 2.5
     431  */
     432  public boolean isAnnotated()
     433  {
     434    return getData().getAnnotationSet() != null;
     435  }
     436  /**
     437    @since 2.5
     438  */
     439  public void removeAnnotations()
     440    throws PermissionDeniedException, BaseException
     441  {
     442    checkPermission(Permission.WRITE);
     443    AnnotationSetData as = getData().getAnnotationSet();
     444    if (as != null)
     445    {
     446      HibernateUtil.deleteData(getDbControl().getHibernateSession(), as);
     447      getData().setAnnotationSet(null);
     448    }
     449  }
     450  /**
     451    @return Always null
     452    @since 2.5
     453  */
     454  public Protocol getProtocol()
     455  {
     456    return null;
     457  }
     458  /**
     459    @return Always null
     460    @since 2.5
     461  */
     462  public Set<Annotatable> getAnnotatableParents()
     463  {
     464    return null;
     465  }
     466  /**
     467    Get the annotation types that can be used by this configuration. This method
     468    requires that the plug-in implements the {@link AnnotationSetterPlugin} interface.
     469    @return A query or null if this plug-in doesn't use annotations
     470    @since 2.5
     471  */
     472  public ItemQuery<AnnotationType> getAnnotationTypes()
     473  {
     474    Plugin p = newInstance(Plugin.class, null, getSessionControl(), null, null);
     475    ItemQuery<AnnotationType> query = null;
     476    if (p instanceof AnnotationSetterPlugin)
     477    {
     478      query = ((AnnotationSetterPlugin)p).getAnnotationTypes();
     479    }
     480    return query;
     481  }
     482  /**
     483    Get a message explaining what the proxy does with the annotations.
     484    @return A message or null
     485    @since 2.5
     486  */
     487  public String getAnnotationMessage()
     488  {
     489    Plugin p = newInstance(Plugin.class, null, getSessionControl(), null, null);
     490    String message = null;
     491    if (p instanceof AnnotationSetterPlugin)
     492    {
     493      message = ((AnnotationSetterPlugin)p).getAnnotationMessage();
     494    }
     495    return message;
     496  }
     497  // ------------------------------------------- 
     498 
    407499  /**
    408500    Get the class name of the Java class that implements this plugin. The
  • trunk/src/core/net/sf/basedb/core/Update.java

    r3933 r3979  
    532532    </td>
    533533  </tr>
     534 
     535  <tr>
     536    <td>46</td>
     537    <td>
     538      <ul>
     539      <li>Made {@link net.sf.basedb.core.data.PluginDefinitionData}
     540        and {@link net.sf.basedb.core.data.PluginConfigurationData}
     541        annotatable.
     542      </ul>
     543      No special database update is needed. Only increase the schema version.
     544    </td>
     545  </tr>
    534546  </table>
    535547
     
    756768        if (progress != null) progress.display((int)(44*progress_factor), "--Updating schema version: " + schemaVersion + " -> 45...");
    757769        schemaVersion = updateToSchemaVersion45(session);
     770      }
     771     
     772      if (schemaVersion < 46)
     773      {
     774        if (progress != null) progress.display((int)(45*progress_factor), "--Updating schema version: " + schemaVersion + " -> 46...");
     775        schemaVersion = setSchemaVersionInTransaction(session, 46);
    758776      }
    759777
  • trunk/src/core/net/sf/basedb/core/data/PluginConfigurationData.java

    r3948 r3979  
    3939*/
    4040public class PluginConfigurationData
    41   extends CommonData
     41  extends AnnotatedData
    4242{
    4343  public PluginConfigurationData()
  • trunk/src/core/net/sf/basedb/core/data/PluginDefinitionData.java

    r3948 r3979  
    4343public class PluginDefinitionData
    4444  extends SharedData
    45   implements RemovableData
     45  implements RemovableData, AnnotatableData
    4646{
    4747
     
    6363  }
    6464  // -------------------------------------------
    65 
     65  /*
     66    From the AnnotatableData interface
     67    -------------------------------------------
     68  */
     69  private AnnotationSetData annotationSet;
     70  public AnnotationSetData getAnnotationSet()
     71  {
     72    return annotationSet;
     73  }
     74  public void setAnnotationSet(AnnotationSetData annotationSet)
     75  {
     76    this.annotationSet = annotationSet;
     77  }
     78  // -------------------------------------------
     79 
     80 
    6681  /**
    6782    The maximum length of the class name that can be stored in the
  • trunk/src/core/net/sf/basedb/core/plugin/AbstractPlugin.java

    r3679 r3979  
    2727
    2828import net.sf.basedb.core.BaseException;
     29import net.sf.basedb.core.BooleanParameterType;
    2930import net.sf.basedb.core.DbControl;
    3031import net.sf.basedb.core.Job;
     32import net.sf.basedb.core.PluginConfiguration;
    3133import net.sf.basedb.core.SessionControl;
    3234import net.sf.basedb.core.PluginParameter;
     
    5355 
    5456  protected ParameterValues job = null;
     57 
     58  /**
     59    Section definition for grouping annotation options.
     60    @since 2.5
     61  */
     62  protected static final PluginParameter<String> annotationSection = new PluginParameter<String>(
     63    "annotationSection",
     64    "Annotations",
     65    "Options related to annotations.",
     66    null
     67  );
     68 
    5569 
    5670  /**
     
    223237  }
    224238 
     239  /**
     240    Get the plug-in configuration that this is currently in use or null.
     241    @param dc The DbControl to use for database access
     242    @return The configuration or null
     243    @since 2.5
     244  */
     245  protected PluginConfiguration getCurrentConfiguration(DbControl dc)
     246  {
     247    return configuration == null || configuration.getId() == 0 ?
     248      null : PluginConfiguration.getById(dc, configuration.getId());
     249  }
     250 
     251  /**
     252    The name of the parameter that asks if annotations should be copied or not.
     253    @see #getCopyAnnotationsParmeter(String, String, Boolean)
     254    @since 2.5
     255  */
     256  protected static final String COPY_ANNOTATIONS = "copyAnnotations";
     257 
     258  /**
     259    Parameter definition that asks if annotations should be copied from the
     260    plug-in definition/configuration to other items.
     261    @param label The label to use for the parameter or null to use the default label
     262      (Copy annotations)
     263    @param description The description to use for the parameter or null to use the
     264      default description
     265    @param defaultValue The default value
     266  */
     267  protected PluginParameter<Boolean> getCopyAnnotationsParmeter(String label, String description, Boolean defaultValue)
     268  {
     269    if (label == null) label = "Copy annotations";
     270    if (description == null)
     271    {
     272      description = "Select this option to copy annotations from the plug-in to the item.";
     273    }
     274    return new PluginParameter<Boolean>(
     275        COPY_ANNOTATIONS, label, description, defaultValue,
     276        new BooleanParameterType(defaultValue, false)
     277    );
     278  }
     279 
     280  /**
     281    The name of the parameter that asks if annotations should be overwritten or not.
     282    @see #getOverwriteAnnotationsParameters(String, String, Boolean)
     283    @since 2.5
     284  */
     285  protected static final String OVERWRITE_ANNOTATIONS = "overwriteAnnotations";
     286 
     287  /**
     288    Parameter definition that asks if copied annotations should overwrite existing
     289    annotations or not.
     290    @param label The label to use for the parameter or null to use the default label
     291      (Overwrite existing)
     292    @param description The description to use for the parameter or null to use the
     293      default description
     294    @param defaultValue The default value
     295    @since 2.5
     296  */
     297  protected PluginParameter<Boolean> getOverwriteAnnotationsParameters(String label, String description, Boolean defaultValue)
     298  {
     299    if (label == null) label = "Overwrite existing";
     300    if (description == null)
     301    {
     302      description = "If set, existing annotations will be overwritten with new values.";
     303    }
     304    return new PluginParameter<Boolean>(
     305        OVERWRITE_ANNOTATIONS, label, description, defaultValue,
     306        new BooleanParameterType(defaultValue, false)
     307    );
     308  }
     309 
     310 
    225311}
  • trunk/src/plugins/core/net/sf/basedb/plugins/RawDataFlatFileImporter.java

    r3820 r3979  
    2525package net.sf.basedb.plugins;
    2626
     27import net.sf.basedb.core.AnnotationType;
    2728import net.sf.basedb.core.BaseException;
    2829import net.sf.basedb.core.DataFileType;
     
    3738import net.sf.basedb.core.ItemNotFoundException;
    3839import net.sf.basedb.core.ItemParameterType;
     40import net.sf.basedb.core.ItemQuery;
    3941import net.sf.basedb.core.Permission;
    4042import net.sf.basedb.core.PermissionDeniedException;
     43import net.sf.basedb.core.PluginConfiguration;
    4144import net.sf.basedb.core.PluginParameter;
    4245import net.sf.basedb.core.RawBioAssay;
     
    5154import net.sf.basedb.core.plugin.About;
    5255import net.sf.basedb.core.plugin.AboutImpl;
     56import net.sf.basedb.core.plugin.AnnotationSetterPlugin;
    5357import net.sf.basedb.core.plugin.GuiContext;
    5458import net.sf.basedb.core.plugin.InteractivePlugin;
     
    8892public class RawDataFlatFileImporter
    8993  extends AbstractFlatFileImporter
    90   implements InteractivePlugin, ConfigureByExample
     94  implements InteractivePlugin, ConfigureByExample, AnnotationSetterPlugin
    9195{
    9296 
     
    262266      permissions.add(new Permissions(Item.PLATFORM, null, EnumSet.of(Permission.READ)));
    263267      permissions.add(new Permissions(Item.DATAFILETYPE, null, EnumSet.of(Permission.READ)));
     268      permissions.add(new Permissions(Item.PLUGINCONFIGURATION, null, EnumSet.of(Permission.READ)));
    264269    }
    265270    return permissions;
     
    422427        storeValue(job, request, ri.getParameter(DECIMAL_SEPARATOR));
    423428       
     429        // Annotations
     430        storeValue(job, request, ri.getParameter(COPY_ANNOTATIONS));
     431        storeValue(job, request, ri.getParameter(OVERWRITE_ANNOTATIONS));
     432       
    424433        // Error handling parameters
    425434        storeValue(job, request, defaultErrorParameter);
     
    443452  // -------------------------------------------
    444453 
     454  /**
     455    Return a query that finds annotation types for raw bioassays.
     456    @since 2.5
     457  */
     458  public ItemQuery<AnnotationType> getAnnotationTypes()
     459  {
     460    return AnnotationType.getQuery(Item.RAWBIOASSAY);
     461  }
     462  public String getAnnotationMessage()
     463  {
     464    return "The selected annotations will be copied to the raw bioassay when raw data is imported to it.";
     465  }
     466 
    445467  /*
    446468    From the AbstractFlatFileReporter class
     
    462484    rawDataMember = FileStoreUtil.setGenericDataFile(dc, rawBioAssay,
    463485      FileType.RAW_DATA, DataFileType.GENERIC_RAW_DATA, rawDataFile);
     486   
     487    PluginConfiguration cfg = getCurrentConfiguration(dc);
     488    if (cfg != null && cfg.isAnnotated() && !Boolean.FALSE.equals(job.getValue("copyAnnotations")))
     489    {
     490      boolean overwrite = Boolean.TRUE.equals(job.getValue("overwriteAnnotations"));
     491      rawBioAssay.getAnnotationSet().copyFrom(cfg, overwrite);
     492    }
    464493   
    465494    batcher = rawBioAssay.getRawDataBatcher();
     
    649678      List<File> rawDataFiles = null;
    650679      dc = sc.newDbControl();
     680      boolean configIsAnnotated = false;
    651681      try
    652682      {
    653683        rba = RawBioAssay.getById(dc, currentRawBioAssayId);
    654684        rawDataFiles = FileStoreUtil.getGenericDataFiles(dc, rba, FileType.RAW_DATA);
     685        configIsAnnotated = getCurrentConfiguration(dc).isAnnotated();
    655686      }
    656687      catch (Throwable t)
     
    674705      parameters.add(getDecimalSeparatorParameter(null, null, (String)configuration.getValue(DECIMAL_SEPARATOR)));
    675706     
     707      // Annotations section
     708      if (configIsAnnotated)
     709      {
     710        parameters.add(annotationSection);
     711        parameters.add(getCopyAnnotationsParmeter(null,
     712          "If selected, annotations are copied from the configuration to the raw " +
     713          "bioassay we are importing data to.", true));
     714        parameters.add(getOverwriteAnnotationsParameters(null, null, null));
     715      }
     716     
    676717      // Error handling parameters
    677718      parameters.add(errorSection);
  • trunk/www/admin/pluginconfigurations/edit_configuration.jsp

    r3679 r3979  
    130130
    131131  <base:page type="popup" title="<%=title%>">
    132   <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
     132  <base:head scripts="tabcontrol.js,annotations.js" styles="tabcontrol.css">
    133133    <script language="JavaScript">
    134134    // Validate the "Configuration" tab
     
    156156      if (TabControl.validateActiveTab('settings'))
    157157      {
     158        if (annotationsLoaded)
     159        {
     160          Annotations.addModifiedAnnotationsToForm(frames.annotations, frm);
     161        }
    158162        frm.configure.value = configure;
    159163        frm.submit();
     164      }
     165    }
     166
     167    var annotationsLoaded = false;
     168    function switchTab(tabControlId, tabId)
     169    {
     170      if (TabControl.setActiveTab(tabControlId, tabId))
     171      {
     172        if (tabId == 'annotations' && !annotationsLoaded)
     173        {
     174          Annotations.loadAnnotateFrame(frames.annotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
     175          annotationsLoaded = true;
     176        }
    160177      }
    161178    }
     
    205222
    206223    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
    207     <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*200)+"px;"%>"
    208       position="bottom" remember="<%=configuration != null%>">
     224    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*370)+"px;"%>"
     225      position="bottom" remember="<%=configuration != null%>" switch="switchTab">
    209226    <t:tab id="info" title="Configuration" validate="validateConfiguration()" helpid="pluginconfiguration.edit">
    210227      <table class="form" cellspacing=0>
     
    255272      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
    256273    </t:tab>
     274   
     275    <t:tab id="annotations" title="Annotations"
     276      helpid="annotations.edit" tooltip="Enter values for annotations"
     277      visible="<%=currentPlugin != null && currentPlugin.supports("net.sf.basedb.core.plugin.AnnotationSetterPlugin")%>">
     278      <iframe name="annotations" id="idAnnotations" src="../../common/annotations/wait.jsp"
     279        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
     280        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
     281    </t:tab>
     282   
    257283    </t:tabcontrol>
    258284
  • trunk/www/admin/pluginconfigurations/index.jsp

    r3679 r3979  
    171171    configuration.setName(Values.getStringOrNull(request.getParameter("name")));
    172172    configuration.setDescription(Values.getStringOrNull(request.getParameter("description")));
     173    // Annotations tab
     174    Base.updateAnnotations(dc, configuration, configuration, request);
    173175    dc.commit();
    174176    cc.removeObject("item");
  • trunk/www/admin/pluginconfigurations/view_configuration.jsp

    r3890 r3979  
    476476      </table>
    477477      </div>
     478      </t:tab>
    478479     
     480      <t:tab id="annotations" title="Annotations"
     481        tooltip="View annotation values"
     482        visible="<%=plugin != null && plugin.supports("net.sf.basedb.core.plugin.AnnotationSetterPlugin") %>">
     483        <div class="boxed">
     484        <jsp:include page="../../common/annotations/list_annotations.jsp">
     485          <jsp:param name="item_type" value="<%=itemType.name()%>" />
     486          <jsp:param name="item_id" value="<%=itemId%>" />
     487          <jsp:param name="ID" value="<%=ID%>" />
     488        </jsp:include>
     489        </div>
    479490      </t:tab>
     491     
    480492      </t:tabcontrol>
    481493
  • trunk/www/admin/plugindefinitions/edit_plugin.jsp

    r3890 r3979  
    174174
    175175  <base:page type="popup" title="<%=title%>">
    176   <base:head scripts="tabcontrol.js,linkitems.js" styles="tabcontrol.css">
     176  <base:head scripts="tabcontrol.js,annotations.js,linkitems.js" styles="tabcontrol.css">
    177177    <script language="JavaScript">
    178178    // Validate the "Plugin" tab
     
    220220        frm.allAgents.value = agents.join(',');
    221221        frm.removeAgents.value = Link.getActionIds(-1, 'A').join(',');
     222        if (annotationsLoaded)
     223        {
     224          Annotations.addModifiedAnnotationsToForm(frames.annotations, frm);
     225        }
    222226        frm.submit();
     227      }
     228    }
     229   
     230    var annotationsLoaded = false;
     231    function switchTab(tabControlId, tabId)
     232    {
     233      if (TabControl.setActiveTab(tabControlId, tabId))
     234      {
     235        if (tabId == 'annotations' && !annotationsLoaded)
     236        {
     237          Annotations.loadAnnotateFrame(frames.annotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
     238          annotationsLoaded = true;
     239        }
    223240      }
    224241    }
     
    722739
    723740    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
    724     <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*320)+"px;"%>"
    725       position="bottom" remember="<%=plugin != null%>" active="<%=selectedAgentId == -1 ? null : "agents" %>">
     741    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*370)+"px;"%>"
     742      position="bottom" remember="<%=plugin != null%>"
     743      active="<%=selectedAgentId == -1 ? null : "agents" %>" switch="switchTab">
    726744    <t:tab id="info" title="Plugin" validate="validatePlugin()" helpid="plugindefinition.edit">
    727745      <table class="form" cellspacing=0>
     
    10111029    </t:tab>
    10121030   
     1031    <t:tab id="annotations" title="Annotations"
     1032      helpid="annotations.edit" tooltip="Enter values for annotations"
     1033      visible="<%=plugin != null && !plugin.requiresConfiguration() && plugin.supports("net.sf.basedb.core.plugin.AnnotationSetterPlugin")%>">
     1034      <iframe name="annotations" id="idAnnotations" src="../../common/annotations/wait.jsp"
     1035        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
     1036        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
     1037    </t:tab>
     1038   
    10131039    </t:tabcontrol>
    10141040
  • trunk/www/admin/plugindefinitions/index.jsp

    r3871 r3979  
    338338    }
    339339   
     340    //Annotations
     341    Base.updateAnnotations(dc, plugin, plugin, request);
     342   
    340343    dc.commit();
    341344    cc.removeObject("item");
  • trunk/www/admin/plugindefinitions/view_plugin.jsp

    r3890 r3979  
    725725    </div>
    726726      </t:tab>
     727     
     728      <t:tab id="annotations" title="Annotations"
     729        tooltip="View annotation values"
     730        visible="<%=!plugin.requiresConfiguration() && plugin.supports("net.sf.basedb.core.plugin.AnnotationSetterPlugin") %>">
     731        <div class="boxed">
     732        <jsp:include page="../../common/annotations/list_annotations.jsp">
     733          <jsp:param name="item_type" value="<%=itemType.name()%>" />
     734          <jsp:param name="item_id" value="<%=itemId%>" />
     735          <jsp:param name="ID" value="<%=ID%>" />
     736        </jsp:include>
     737        </div>
     738      </t:tab>     
    727739      </t:tabcontrol>
    728740
  • trunk/www/common/annotations/annotate.jsp

    r3888 r3979  
    3939  import="net.sf.basedb.core.AnnotationSet"
    4040  import="net.sf.basedb.core.Annotation"
     41  import="net.sf.basedb.core.AnnotatableProxy"
    4142  import="net.sf.basedb.core.ItemQuery"
    4243  import="net.sf.basedb.core.Include"
     
    113114
    114115  // Queries to retrieve annotation types and protocol parameters
    115   final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType, false);
     116  boolean isProxy = item instanceof AnnotatableProxy;
     117  ItemQuery<AnnotationType> annotationTypeQuery = null;
     118  String message = null;
     119
     120  if (isProxy)
     121  {
     122    AnnotatableProxy proxy = (AnnotatableProxy)item;
     123    annotationTypeQuery = Base.getAnnotationTypesQuery(proxy);
     124    message = proxy.getAnnotationMessage();
     125  }
     126  else
     127  {
     128    annotationTypeQuery = Base.getAnnotationTypesQuery(itemType, false);
     129  }
    116130  final ItemQuery<AnnotationType> parameterQuery = Base.getProtocolParametersQuery(protocol);
    117131
     
    128142  final StringBuilder sb = new StringBuilder();
    129143  %>
    130   <base:page type="popup" title="<%=title%>">
     144<base:page type="popup" title="<%=title%>">
    131145  <base:head scripts="annotations.js,parameters.js" styles="parameters.css">
    132146 
     
    543557      </td>
    544558      <td width="50%">
     559        <%=message == null ? "" : message + "<br>"%>
    545560        <br>
    546 
    547561        <div id="valuecontainer" style="display: none;">
    548562          <b>Values</b> <span id="multiplicity"></span><br>
  • trunk/www/common/annotations/list_annotations.jsp

    r3888 r3979  
    3535  import="net.sf.basedb.core.Annotation"
    3636  import="net.sf.basedb.core.Annotatable"
     37  import="net.sf.basedb.core.AnnotatableProxy"
    3738  import="net.sf.basedb.core.Nameable"
    3839  import="net.sf.basedb.core.ItemQuery"
     
    6162try
    6263{
    63   final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType, false);
     64  final Annotatable item = (Annotatable)itemType.getById(dc, itemId);
     65  ItemQuery<AnnotationType> annotationTypeQuery = null;
     66  String message = null;
     67  boolean isProxy = item instanceof AnnotatableProxy;
     68
     69  if (isProxy)
     70  {
     71    AnnotatableProxy proxy = (AnnotatableProxy)item;
     72    annotationTypeQuery = Base.getAnnotationTypesQuery(proxy);
     73    message = proxy.getAnnotationMessage();
     74  }
     75  else
     76  {
     77    annotationTypeQuery = Base.getAnnotationTypesQuery(itemType, false);
     78  }
    6479  final List<AnnotationType> annotationTypes = annotationTypeQuery.list(dc);
    65   final Annotatable item = (Annotatable)itemType.getById(dc, itemId);
    6680  Protocol protocol = null;
    6781  boolean readProtocol = true;
     
    125139      {
    126140        %>
     141        <%=message == null ? "" : message%>
    127142        <h4 class="docked">Primary annotations</h4>
    128143        <tbl:table
     
    268283
    269284      <%
     285      if (!isProxy)
     286      {
    270287      if (inheritedAnnotations == null || inheritedAnnotations.size() == 0)
    271288      {
     
    370387        <%
    371388      }
     389      }
    372390      %>
    373391      </div>
  • trunk/www/include/scripts/main.js

    r3913 r3979  
    424424    this.controllers['MIMETYPE'] = { url:'admin/mimetypes/index.jsp', width:540, height:400 };
    425425    this.controllers['NEWS'] = { url:'admin/news/index.jsp', width:540, height:400 };
    426     this.controllers['PLUGINCONFIGURATION'] = { url:'admin/pluginconfigurations/index.jsp', width:500, height:340 };
    427     this.controllers['PLUGINDEFINITION'] = { url:'admin/plugindefinitions/index.jsp', width:720, height:440 };
     426    this.controllers['PLUGINCONFIGURATION'] = { url:'admin/pluginconfigurations/index.jsp', width:800, height:500 };
     427    this.controllers['PLUGINDEFINITION'] = { url:'admin/plugindefinitions/index.jsp', width:800, height:500 };
    428428    this.controllers['PLUGINTYPE'] = { url:'admin/plugintypes/index.jsp', width:700, height:400 };
    429429    this.controllers['JOBAGENT'] = { url:'admin/jobagents/index.jsp', width:700, height:400 };
Note: See TracChangeset for help on using the changeset viewer.