Changeset 3587


Ignore:
Timestamp:
Jul 20, 2007, 3:45:13 PM (14 years ago)
Author:
Martin Svensson
Message:

References #686 Two more coreplugins are updated
AbstractAnalysisPlugin? got a method to set restriction on using selected bioassays

Location:
trunk/src
Files:
3 edited

Legend:

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

    r3585 r3587  
    3131import net.sf.basedb.core.BioAssaySet;
    3232import net.sf.basedb.core.DbControl;
     33import net.sf.basedb.core.DynamicSpotQuery;
    3334import net.sf.basedb.core.Experiment;
    3435import net.sf.basedb.core.Item;
     
    4041import net.sf.basedb.core.StringParameterType;
    4142import net.sf.basedb.core.Transformation;
     43import net.sf.basedb.core.VirtualColumn;
     44import net.sf.basedb.core.query.Dynamic;
     45import net.sf.basedb.core.query.Expression;
     46import net.sf.basedb.core.query.Expressions;
     47import net.sf.basedb.core.query.Restrictions;
    4248
    4349/**
     
    414420  }
    415421
    416  
     422  /**
     423    Restricts a query to only include values from listed bioassays
     424      @param query The query to set restriction on
     425      @param bioAssays A list with bioassays the restriction should include
     426      @return A DynamicSpotQuery object. The query parameter is restricted if bioAssays holds item(s),
     427        otherwise it will it will be the same
     428      @since 2.4
     429  */
     430  protected DynamicSpotQuery restrictSource(DynamicSpotQuery query, List<BioAssay> bioAssays)
     431  {
     432    if ( (bioAssays != null) && !bioAssays.isEmpty() )
     433    {
     434      Expression[] selectedColumns = new Expression[bioAssays.size()];
     435      for (int i=0; i<selectedColumns.length; i++)
     436      {
     437        BioAssay ba = bioAssays.get(i);
     438        selectedColumns[i] = Expressions.integer(ba.getDataCubeColumnNo());
     439      }       
     440      query.restrict(Restrictions.in(
     441          Dynamic.column(VirtualColumn.COLUMN),
     442          selectedColumns));
     443    }
     444    return query;
     445  }
    417446}
  • trunk/src/plugins/core/net/sf/basedb/plugins/JepExtraValueCalculator.java

    r3584 r3587  
    2323*/
    2424package net.sf.basedb.plugins;
    25 
    26 import java.util.ArrayList;
    27 import java.util.Arrays;
    28 import java.util.Collection;
    29 import java.util.Collections;
    30 import java.util.EnumSet;
    31 import java.util.HashSet;
    32 import java.util.List;
    33 import java.util.Set;
    3425
    3526import net.sf.basedb.core.BaseException;
     
    6051import net.sf.basedb.core.query.Dynamic;
    6152import net.sf.basedb.core.query.Expression;
    62 import net.sf.basedb.core.query.Expressions;
    6353import net.sf.basedb.core.query.Hql;
    6454import net.sf.basedb.core.query.Orders;
    65 import net.sf.basedb.core.query.Restrictions;
    6655import net.sf.basedb.core.query.Selects;
    6756import net.sf.basedb.util.BioAssaySetUtil;
     57
     58import java.util.ArrayList;
     59import java.util.Arrays;
     60import java.util.Collection;
     61import java.util.Collections;
     62import java.util.EnumSet;
     63import java.util.HashSet;
     64import java.util.List;
     65import java.util.Set;
    6866
    6967/**
     
    169167      Expression extraExpression = BioAssaySetUtil.createJepExpression(dc, source, expression, false);
    170168      query.select(Selects.expression(extraExpression, "xtra"));
    171       // If one or more bioassays are selected-restrict to them.
    172       if (bioAssays != null && !bioAssays.isEmpty())
    173       {
    174         Expression[] selectedColumns = new Expression[bioAssays.size()];
    175         for (int i=0; i<selectedColumns.length; i++)
    176         {
    177           BioAssay ba = bioAssays.get(i);
    178           selectedColumns[i] = Expressions.integer(ba.getDataCubeColumnNo());
    179         }       
    180         query.restrict(Restrictions.in(
    181             Dynamic.column(VirtualColumn.COLUMN),
    182             selectedColumns));
    183       }
     169      // Restrict to selected bioassays if there are any
     170      query = restrictSource(query, bioAssays);
    184171
    185172      if (progress != null) progress.display(10, "Calculating extra value ("+source.getNumSpots()+" total)...");
  • trunk/src/plugins/core/net/sf/basedb/plugins/JepIntensityTransformer.java

    r3473 r3587  
    2727import java.util.Arrays;
    2828import java.util.Collection;
     29import java.util.Collections;
    2930import java.util.EnumSet;
    3031import java.util.HashSet;
     
    3334
    3435import net.sf.basedb.core.BaseException;
     36import net.sf.basedb.core.BioAssay;
    3537import net.sf.basedb.core.BioAssaySet;
    3638import net.sf.basedb.core.DbControl;
     
    9294
    9395  private static final Set<Permissions> permissions = new HashSet<Permissions>();
     96  private static final Set<GuiContext> guiContexts = Collections.unmodifiableSet(
     97      new HashSet<GuiContext>(Arrays.asList(CONTEXT_BIOASSAYSET, CONTEXT_BIOASSAYS)));
    9498
    9599  private RequestInformation configureJob;
     
    139143      // Get all parameters
    140144      BioAssaySet source = getSourceBioAssaySet(dc);
     145      List<BioAssay> bioAssays = getSourceBioAssays(dc);
    141146      String childName = Values.getString((String)job.getValue(CHILD_NAME), source.getName());
    142147      String childDescription = (String)job.getValue(CHILD_DESCRIPTION);
     
    163168      query.select(Dynamic.select(VirtualColumn.COLUMN));
    164169      query.select(Dynamic.select(VirtualColumn.POSITION));
     170     
     171      // Restrict to selected bioassays
     172      restrictSource(query, bioAssays);
    165173
    166174      // Transformation expressions
     
    208216    -------------------------------------------
    209217  */
     218  @Override
     219  public Set<GuiContext> getGuiContexts()
     220  {
     221    return guiContexts;
     222  }
     223 
    210224  public RequestInformation getRequestInformation(GuiContext context, String command)
    211225    throws BaseException
     
    235249        // Source bioassay set
    236250        storeValue(job, request, ri.getParameter(SOURCE_BIOASSAYSET));
     251       
     252        // Selected bioassays
     253        storeValue(job, request, ri.getParameter(SOURCE_BIOASSAYS));
    237254       
    238255        // Child name, description and transformation
     
    275292        // Source and child bioassay set parameters
    276293        parameters.add(getSourceBioAssaySetParameter(null, null));
     294        parameters.add(getSourceBioAssaysParameter(null, null));
    277295        parameters.add(getChildNameParameter(null, null, bas.getName()));
    278296        parameters.add(getChildDescriptionParameter(null, null, null));
Note: See TracChangeset for help on using the changeset viewer.