Changeset 3848


Ignore:
Timestamp:
Sep 14, 2010, 12:22:53 PM (13 years ago)
Author:
Fredrik Levander
Message:

Refs #701. Refs #405. Only exporting PRIDE files for the selected sample or gel.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/servlet/src/org/proteios/action/hit/CreatePrideExportJob.java

    r3844 r3848  
    2828package org.proteios.action.hit;
    2929
    30 import java.util.ArrayList;
    31 import java.util.Calendar;
    32 import java.util.GregorianCalendar;
    33 import java.util.List;
    3430import org.proteios.action.ProteiosAction;
    3531import org.proteios.action.job.ListJobs;
     
    5349import org.proteios.core.query.Hql;
    5450import org.proteios.core.query.Restrictions;
    55 import org.proteios.gui.form.*;
    56 import org.proteios.plugins.PrideExportPlugin;
     51import org.proteios.gui.form.ExternalGelIdField;
     52import org.proteios.gui.form.FormFactory;
     53import org.proteios.gui.form.LocalSampleSelect;
     54
    5755import se.lu.thep.waf.ActionException;
    5856import se.lu.thep.waf.constraints.InvalidParameterValue;
     
    6260import se.lu.thep.waf.constraints.VString;
    6361
     62import java.util.ArrayList;
     63import java.util.List;
     64
    6465/**
    6566 * @author gregory
     
    6869    extends ProteiosAction<CreatePrideExportJob>
    6970{
    70   public static final VBoolean VEXTRAPREFIX = new VBoolean("appendPrefix", false);
     71  public static final VBoolean VEXTRAPREFIX = new VBoolean("appendPrefix",
     72    false);
    7173  public static final VFloat VCUTOFF = new VFloat("cutOff", true);
    72   public static final VString VCUTOFFSTRING = new VString("cutOffString", 0, 256, false);
     74  public static final VString VCUTOFFSTRING = new VString("cutOffString", 0,
     75    256, false);
    7376  public static final VInteger VPRIDEPROTOCOLFILEID = new VInteger(
    7477    "prideProtocolFileId", 0, false);
    75   public static final VString VEXPERIMENTTITLE = new VString("expTitle",0,256,false);
    76   public static final VString VCONTACTNAME = new VString("contactName",0,256,false);
    77   public static final VString VCONTACTINST = new VString("contactInst",0,256,false);
    78   public static final VString VCONTACTINFO = new VString("contactInfo",0,256,false);
    79   public static final VString VCONTACTEMAIL = new VString("contactEmail",0,256,false);
    80   public static final VString VCONTACTURL = new VString("contactURL",0,256,false);
     78  public static final VString VEXPERIMENTTITLE = new VString("expTitle", 0,
     79    256, false);
     80  public static final VString VCONTACTNAME = new VString("contactName", 0,
     81    256, false);
     82  public static final VString VCONTACTINST = new VString("contactInst", 0,
     83    256, false);
     84  public static final VString VCONTACTINFO = new VString("contactInfo", 0,
     85    256, false);
     86  public static final VString VCONTACTEMAIL = new VString("contactEmail", 0,
     87    256, false);
     88  public static final VString VCONTACTURL = new VString("contactURL", 0, 256,
     89    false);
    8190  public static final VBoolean VADDCONTACT = new VBoolean("addContact", false);
    82   public static final VBoolean VADDSAMPLENAME = new VBoolean("addSampleName", false);
     91  public static final VBoolean VADDSAMPLENAME = new VBoolean("addSampleName",
     92    false);
     93
    8394
    8495  /*
    8596   * (non-Javadoc)
    86    *
    8797   * @see org.proteios.action.ProteiosAction#runMe()
    8898   */
     
    118128    log.debug("filenamePrefix = \"" + filenamePrefix + "\"");
    119129    //
    120     // Check if extra prefix (gel external id or local sample id) should be used
    121     //Boolean appendExtraPrefix = getValidBoolean(VEXTRAPREFIX);
     130    // Check if extra prefix (gel external id or local sample id) should be
     131    // used
     132    // Boolean appendExtraPrefix = getValidBoolean(VEXTRAPREFIX);
    122133    Boolean appendExtraPrefix = getSessionAttribute(VEXTRAPREFIX);
    123134    log.debug("appendExtraPrefix from request = " + appendExtraPrefix);
     
    157168      if (extraPrefix != null && !extraPrefix.equals(""))
    158169      {
    159         if (!filenamePrefix.equals("") &&
    160             !filenamePrefix.endsWith("_") &&
    161             !filenamePrefix.endsWith("-") &&
    162             !filenamePrefix.endsWith("."))
     170        if (!filenamePrefix.equals("") && !filenamePrefix.endsWith("_") && !filenamePrefix
     171          .endsWith("-") && !filenamePrefix.endsWith("."))
    163172        {
    164173          // Add underscore between original prefix and extra prefix
     
    194203    // Find spectrum files in hits list
    195204    ItemQuery<Hit> hitQuery = Hit.getQuery();
    196     hitQuery.restrictPermanent(Restrictions.eq(Hql.property("project"),
    197       Hql.entity(project)));
    198     hitQuery.restrict(Restrictions.eq(Hql.property("protein"),
    199       Expressions.parameter("protein")));
     205    hitQuery.restrictPermanent(Restrictions.eq(Hql.property("project"), Hql
     206      .entity(project)));
     207    hitQuery.restrict(Restrictions.eq(Hql.property("protein"), Expressions
     208      .parameter("protein")));
    200209    hitQuery.setParameter("protein", false, null);
     210
    201211    ItemResultList<Hit> hitlist = hitQuery.list(dc);
    202212    List<File> peakListFileList = new ArrayList<File>(0);
    203     for (Hit hit: hitlist)
     213    for (Hit hit : hitlist)
    204214    {
    205215      File file = hit.getPeakListFile();
     
    231241      {
    232242        dc.close();
    233         throw new ActionException("Couldn't find plugin PrideExportPlugin.");
     243        throw new ActionException(
     244          "Couldn't find plugin PrideExportPlugin.");
    234245      }
    235246    }
     
    237248    {
    238249      throw new ActionException(
    239         "PRIDE Export plugin is not installed. " + e
    240           .getMessage());
     250        "PRIDE Export plugin is not installed. " + e.getMessage());
    241251    }
    242252    log.debug("pluginDef = " + pluginDef);
     
    245255    // Create one job per spectrum file in hits list
    246256    int total = peakListFileList.size();
    247     int i=0;
    248     for (File file: peakListFileList)
     257    int i = 0;
     258    for (File file : peakListFileList)
    249259    {
    250260      i++;
    251       String part = "("+i+"/"+total+")";
     261      String part = "(" + i + "/" + total + ")";
    252262      log.debug("file = " + file);
    253263      String outputFilename = filenamePrefix + file.getName();
     
    267277      else
    268278      {
    269         job.setName(plugin.getName() + " sample: " + localSampleId + ", title: " + expTitle + " "+part);
     279        job
     280          .setName(plugin.getName() + " sample: " + localSampleId + ", title: " + expTitle + " " + part);
    270281      }
    271282      //
    272283      Integer fileId = file.getId();
    273       job.setParameterValue("peakListFileId", new IntegerParameterType(), fileId);
     284      job.setParameterValue("peakListFileId", new IntegerParameterType(),
     285        fileId);
    274286      //
    275287      job.setParameterValue("filenamePrefix", new StringParameterType(),
     
    282294      job.setParameterValue("localSampleId", new StringParameterType(),
    283295        localSampleId);
    284       job.setParameterValue("experimentTitle", new StringParameterType(), expTitle);
     296      job.setParameterValue("experimentTitle", new StringParameterType(),
     297        expTitle);
    285298      job.setParameterValue("details", new StringParameterType(), part);
    286       job.setParameterValue("addContact", new BooleanParameterType(), addContact);
    287       job.setParameterValue("addSampleName", new BooleanParameterType(), addSampleName);
    288       job.setParameterValue("contactName", new StringParameterType(), contactName);
    289       job.setParameterValue("contactInst", new StringParameterType(), contactInst);
    290       job.setParameterValue("contactInfo", new StringParameterType(), contactInfo);
    291       job.setParameterValue("prideProtocolFileId", new IntegerParameterType(),
    292         prideProtocolFileId);
     299      job.setParameterValue("addContact", new BooleanParameterType(),
     300        addContact);
     301      job.setParameterValue("addSampleName", new BooleanParameterType(),
     302        addSampleName);
     303      job.setParameterValue("contactName", new StringParameterType(),
     304        contactName);
     305      job.setParameterValue("contactInst", new StringParameterType(),
     306        contactInst);
     307      job.setParameterValue("contactInfo", new StringParameterType(),
     308        contactInfo);
     309      job.setParameterValue("prideProtocolFileId",
     310        new IntegerParameterType(), prideProtocolFileId);
    293311      //
    294312      ItemParameterType<Project> projectParam = new ItemParameterType<Project>(
     
    304322      job.setParameterValue("directory", dirParam, dir);
    305323      job
    306         .setDescription("Output file: " + dir.getName() + "/" + outputFilename + ", FDR upper cutoff: " + fdrCutoff );
     324        .setDescription("Output file: " + dir.getName() + "/" + outputFilename + ", FDR upper cutoff: " + fdrCutoff);
    307325      dc.saveItem(job);
    308326      dc.commit();
Note: See TracChangeset for help on using the changeset viewer.