Changeset 3569


Ignore:
Timestamp:
Jul 19, 2007, 8:29:50 AM (16 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #684: AbstractAnalysisPlugin? should not include [Item.BIOASSAYS, Type.LIST] in it's GuiContext:s

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/plugin/AbstractAnalysisPlugin.java

    r3501 r3569  
    2424package net.sf.basedb.core.plugin;
    2525
    26 import java.util.Arrays;
    2726import java.util.Collections;
    28 import java.util.HashSet;
    2927import java.util.Set;
    3028
     
    5654 
    5755  /**
     56    GuiContext = [Item.BIOASSAYSET, GuiContext.Type.ITEM]
     57    @since 2.4
     58  */
     59  protected static final GuiContext CONTEXT_BIOASSAYSET =
     60    new GuiContext(Item.BIOASSAYSET, GuiContext.Type.ITEM);
     61
     62  /**
     63    GuiContext = [Item.BIOASSAY, GuiContext.Type.LIST]
     64    @since 2.4
     65  */
     66  protected static final GuiContext CONTEXT_BIOASSAYS =
     67    new GuiContext(Item.BIOASSAY, GuiContext.Type.LIST);
     68 
     69  /**
    5870    The default gui contexts where it makes sense to use an analysis plugin.
    5971    Override for the {@link InteractivePlugin#getGuiContexts()} method to
    60     specify other contexts. This set can't be modified.
     72    specify other contexts. This set can't be modified. This set only
     73    includes the {@link #CONTEXT_BIOASSAYSET}.
    6174  */
    6275  protected static final Set<GuiContext> defaultGuiContexts =
    63     Collections.unmodifiableSet(new HashSet<GuiContext>(
    64         Arrays.asList(
    65           new GuiContext(Item.BIOASSAYSET, GuiContext.Type.ITEM),
    66           new GuiContext(Item.BIOASSAY, GuiContext.Type.LIST)
    67         )
    68       ));
     76    Collections.singleton(CONTEXT_BIOASSAYSET);
    6977 
    7078  /**
     
    126134  }
    127135  /**
    128     Check that the item is a bioassayset.
     136    Check that the item is a bioassayset and that the logged in user has
     137    permission to use the current experiment.
    129138    @return null if the item is a bioassayset, an error message otherwise
    130     @throws PermissionDeniedException If the logged in user dosent have
    131       permission to use the Experiment.
     139    @throws PermissionDeniedException If the logged in user dosen't have
     140      permission to use the Experiment
    132141  */
    133142  public String isInContext(GuiContext context, Object item)
    134143  {
    135144    String message = null;
    136     if (defaultGuiContexts.contains(context))
     145    Experiment e = null;
     146    if (context.equals(CONTEXT_BIOASSAYSET))
    137147    {
    138148      if (item == null)
     
    147157      {
    148158        BioAssaySet bas = (BioAssaySet)item;
    149         Experiment e = bas.getExperiment();
    150         e.checkPermission(Permission.USE);
    151       }
    152     }
     159        e = bas.getExperiment();
     160      }
     161    }
     162    else
     163    {
     164      DbControl dc = sc.newDbControl();
     165      try
     166      {
     167        e = getCurrentExperiment(dc);
     168      }
     169      finally
     170      {
     171        if (dc != null) dc.close();
     172      }
     173    }
     174    if (e != null) e.checkPermission(Permission.USE);
    153175    return message;
    154176  }
  • trunk/src/plugins/core/net/sf/basedb/plugins/FormulaFilter.java

    r3501 r3569  
    5656import java.util.Arrays;
    5757import java.util.Collection;
     58import java.util.Collections;
    5859import java.util.EnumSet;
    5960import java.util.HashSet;
     
    9293
    9394  private static final Set<Permissions> permissions = new HashSet<Permissions>();
     95  private static final Set<GuiContext> guiContexts = Collections.unmodifiableSet(
     96    new HashSet<GuiContext>(Arrays.asList(CONTEXT_BIOASSAYSET, CONTEXT_BIOASSAYS))
     97  );
    9498
    9599  private RequestInformation configureJob;
     
    208212    -------------------------------------------
    209213  */
     214  @Override
     215  public Set<GuiContext> getGuiContexts()
     216  {
     217    return guiContexts;
     218  }
    210219  public RequestInformation getRequestInformation(GuiContext context, String command)
    211220    throws BaseException
Note: See TracChangeset for help on using the changeset viewer.