Changeset 3815


Ignore:
Timestamp:
Sep 2, 2010, 5:23:54 PM (13 years ago)
Author:
Fredrik Levander
Message:

Refs #701. Added contact info and sample name addition possibilities

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/servlet/src/locale/en/dictionary

    r3777 r3815  
    4242ActiveProject=Active Project
    4343ActiveProjectId=Active Project ID
     44AddContactInfo=Add contact info
     45AddSampleInfo=Add sample name
    4446AddDiGESeparation=Add DiGE
    4547AddFiles=Add Files
     
    687689SampleConcentrationInGramsPerLiter=Sample concentration (g/l)
    688690SampleExternalId=Sample external ID
     691SampleInfo=Sample information
    689692SampleMassInGrams=Sample mass (g)
    690693SampleName=Sample name
  • trunk/client/servlet/src/org/proteios/action/hit/CreatePrideExportJob.java

    r3741 r3815  
    3030import org.proteios.action.ProteiosAction;
    3131import org.proteios.action.job.ListJobs;
     32import org.proteios.core.BooleanParameterType;
    3233import org.proteios.core.DbControl;
    3334import org.proteios.core.Directory;
     
    7576    "prideProtocolFileId", 0, false);
    7677  public static final VString VEXPERIMENTTITLE = new VString("expTitle",0,256,false);
    77 
     78  public static final VString VCONTACTNAME = new VString("contactName",0,256,false);
     79  public static final VString VCONTACTINST = new VString("contactInst",0,256,false);
     80  public static final VString VCONTACTINFO = new VString("contactInfo",0,256,false);
     81  public static final VString VCONTACTEMAIL = new VString("contactEmail",0,256,false);
     82  public static final VString VCONTACTURL = new VString("contactURL",0,256,false);
     83  public static final VBoolean VADDCONTACT = new VBoolean("addContact", false);
     84  public static final VBoolean VADDSAMPLENAME = new VBoolean("addSampleName", false);
    7885
    7986  /*
     
    122129    }
    123130    log.debug("appendExtraPrefix = " + appendExtraPrefix);
     131    Boolean addContact = getSessionAttribute(VADDCONTACT);
     132    if (addContact == null)
     133    {
     134      addContact = new Boolean(false);
     135    }
     136    Boolean addSampleName = getSessionAttribute(VADDSAMPLENAME);
     137    if (addSampleName == null)
     138    {
     139      addSampleName = new Boolean(false);
     140    }
     141    String contactName = getSessionAttribute(VCONTACTNAME);
     142    String contactInfo = getSessionAttribute(VCONTACTINFO);
     143    String contactInst = getSessionAttribute(VCONTACTINST);
    124144    if (appendExtraPrefix != null && appendExtraPrefix)
    125145    {
     
    266286      job.setParameterValue("experimentTitle", new StringParameterType(), expTitle);
    267287      job.setParameterValue("details", new StringParameterType(), part);
     288      job.setParameterValue("addContact", new BooleanParameterType(), addContact);
     289      job.setParameterValue("addSampleName", new BooleanParameterType(), addSampleName);
     290      job.setParameterValue("contactName", new StringParameterType(), contactName);
     291      job.setParameterValue("contactInst", new StringParameterType(), contactInst);
     292      job.setParameterValue("contactInfo", new StringParameterType(), contactInfo);
    268293      job.setParameterValue("prideProtocolFileId", new IntegerParameterType(),
    269294        prideProtocolFileId);
     
    281306      job.setParameterValue("directory", dirParam, dir);
    282307      job
    283         .setDescription("Output file: " + dir.getName() + "/" + outputFilename + ", FDR upper cutoff: " + fdrCutoff);
     308        .setDescription("Output file: " + dir.getName() + "/" + outputFilename + ", FDR upper cutoff: " + fdrCutoff );
    284309      dc.saveItem(job);
    285310      dc.commit();
  • trunk/client/servlet/src/org/proteios/action/hit/PrideExport.java

    r3741 r3815  
    3939import org.proteios.gui.TitledWindow;
    4040import org.proteios.gui.Toolbar;
     41import org.proteios.gui.form.Checkbox;
     42import org.proteios.gui.form.Fieldset;
    4143import org.proteios.gui.form.Form;
     44import org.proteios.gui.form.FormFactory;
     45import org.proteios.gui.form.TextField;
    4246import org.proteios.gui.layout.RowLayout;
     47import org.proteios.gui.table.Column;
     48import org.proteios.gui.table.Table;
    4349import org.proteios.plugins.PrideExportPlugin;
    4450
    4551import se.lu.thep.waf.ActionException;
    4652import se.lu.thep.waf.constraints.InvalidParameterValue;
     53import se.lu.thep.waf.constraints.VBoolean;
    4754
    4855import java.util.ArrayList;
     
    6067  /*
    6168   * (non-Javadoc)
    62    *
    6369   * @see org.proteios.action.ProteiosAction#runMe()
    6470   */
     
    7278    String filenamePrefixDefault = new String("PrideExport_");
    7379    /*
    74      * Add timestamp to optional filename prefix in this class,
    75      * instead of in job plugin class, as we want output files
    76      * for all jobs created in the same session to share the same
    77      * timestamp, even if the jobs are not executed simultaneously.
     80     * Add timestamp to optional filename prefix in this class, instead of
     81     * in job plugin class, as we want output files for all jobs created in
     82     * the same session to share the same timestamp, even if the jobs are
     83     * not executed simultaneously.
    7884     */
    7985    // Append timestamp in YYYYMMDD_HHMM format to filename prefix
     
    8187    log.debug("filenamePrefixDefault = \"" + filenamePrefixDefault + "\"");
    8288    // Get form
    83     Form form = getFormFactory().getPrideExportForm(
    84       project, filenamePrefixDefault);
    85    
    86     //String prideExportTitle = "PRIDE " + PrideExportPlugin.PRIDE_XML_VERSION_STR + " " + getLocale().get("PrideExportAfterVersionNumber");
     89    Form form = getFormFactory().getPrideExportForm(project,
     90      filenamePrefixDefault);
     91    form.addFieldset(getContactFieldset());
     92    Fieldset fs = new Fieldset();
     93    fs.getLegendTitle().setTitle("SampleInfo");
     94    Checkbox<VBoolean> isFDR = new Checkbox<VBoolean>(
     95      CreatePrideExportJob.VADDSAMPLENAME);
     96    isFDR.setLabel("AddSampleInfo");
     97    isFDR.setValue("true");
     98    isFDR.setHelp("Replace sample info in peaklists with local sample id from hits report");
     99    fs.add(isFDR);
     100    form.addFieldset(fs);
     101    // String prideExportTitle = "PRIDE " +
     102    // PrideExportPlugin.PRIDE_XML_VERSION_STR + " " +
     103    // getLocale().get("PrideExportAfterVersionNumber");
    87104    String prideExportTitle = new String("PrideExport");
    88105    Title title = new Title(prideExportTitle);
     
    100117    form.setToolbar(tb);
    101118    ActionLink al = getActionFactory().getActionLink(
    102       SelectPrideProtocolFileStep1a.class, "NextSelectPrideProtocolFileOptional");
     119      SelectPrideProtocolFileStep1a.class,
     120      "NextSelectPrideProtocolFileOptional");
    103121    tb.add(al);
    104122    /***********************************************************************
     
    112130  }
    113131
    114  
     132
    115133  /**
    116134   * Append timestamp to filename prefix
    117135   *
    118136   * @param filenamePrefix String Original filename prefix
    119    * @return String Filename prefix with appended "YYYYMMDD_HHMM" timestamp and underscore.
     137   * @return String Filename prefix with appended "YYYYMMDD_HHMM" timestamp
     138   *         and underscore.
    120139   */
    121140  private String appendTimestampToPrefix(String filenamePrefix)
     
    143162
    144163
     164  private Fieldset getContactFieldset()
     165  {
     166    Fieldset fs = new Fieldset();
     167    fs.getLegendTitle().setTitle("SpectrumFileContactInput");
     168    Checkbox<VBoolean> isFDR = new Checkbox<VBoolean>(
     169      CreatePrideExportJob.VADDCONTACT);
     170    isFDR.setLabel("AddContactInfo");
     171    isFDR.setValue("true");
     172    isFDR.setHelp("Replace contact info in peaklists");
     173    fs.add(isFDR);
     174    TextField<String> nameF = new TextField<String>(
     175      CreatePrideExportJob.VCONTACTNAME);
     176    nameF.setValue(getOwner().getName());
     177    nameF.setLabel("Name");
     178    fs.add(nameF);
     179    TextField<String> institutionF = new TextField<String>(
     180      CreatePrideExportJob.VCONTACTINST);
     181    institutionF.setLabel("Institution");
     182    institutionF.setValue(getOwner().getOrganisation());
     183    fs.add(institutionF);
     184    TextField<String> contactInfoF = new TextField<String>(
     185      CreatePrideExportJob.VCONTACTINFO);
     186    contactInfoF.setLabel("ContactInfo");
     187    contactInfoF.setValue(getOwner().getEmail());
     188    fs.add(contactInfoF);
     189    return fs;
     190  }
     191
    145192  private static final List<Context> contexts = new ArrayList<Context>(1);
    146193  static
    147194  {
    148     TableToolbarContext context = new TableToolbarContext(
    149       "PrideExportBtn", "PrideExportBtn", PrideExport.class,
    150       Hit.class);
     195    TableToolbarContext context = new TableToolbarContext("PrideExportBtn",
     196      "PrideExportBtn", PrideExport.class, Hit.class);
    151197    context.setOrder(5);
    152198    contexts.add(context);
     
    156202  /*
    157203   * (non-Javadoc)
    158    *
    159204   * @see org.proteios.ContextEnabled#listContexts()
    160205   */
     
    163208    return contexts;
    164209  }
     210
    165211}
  • trunk/client/servlet/src/org/proteios/action/hit/SelectPrideProtocolFileStep1a.java

    r3741 r3815  
    9494    setSessionAttribute(FormFactory.VNONREQUIRED_FILENAME, filenamePrefix);
    9595    setSessionAttribute(CreatePrideExportJob.VEXTRAPREFIX, appendExtraPrefix);
     96    setSessionAttribute(CreatePrideExportJob.VADDCONTACT, getValidBoolean(CreatePrideExportJob.VADDCONTACT));
     97    setSessionAttribute(CreatePrideExportJob.VADDSAMPLENAME, getValidBoolean(CreatePrideExportJob.VADDSAMPLENAME));
     98    setSessionAttribute(CreatePrideExportJob.VCONTACTNAME, getString(CreatePrideExportJob.VCONTACTNAME));
     99    setSessionAttribute(CreatePrideExportJob.VCONTACTINFO, getString(CreatePrideExportJob.VCONTACTINFO));
     100    setSessionAttribute(CreatePrideExportJob.VCONTACTINST, getString(CreatePrideExportJob.VCONTACTINST));   
    96101    // Get original forward action
    97102    String forward2Id = getValidString(FormFactory.VFWDACTION);
  • trunk/plugin/src/org/proteios/plugins/PrideExportPlugin.java

    r3742 r3815  
    138138  private Integer prideProtocolFileId = null;
    139139  private File prideProtocolFile = null;
     140  private String contactInfo;
     141  private String contactName;
     142  private String contactInst;
     143  private Boolean addContact;
     144  private Boolean addSampleName;
    140145  /*
    141146   * Optional warning message for a successful job completion.
     
    399404        String lSampleId = (String) job.getValue("localSampleId");
    400405        experimentShortTitle = (String) job.getValue("experimentTitle");
     406        contactInfo = (String) job.getValue("contactInfo");
     407        contactName = (String) job.getValue("contactName");
     408        contactInst = (String) job.getValue("contactInst");
     409        addContact = (Boolean) job.getValue("addContact");
     410        addSampleName = (Boolean) job.getValue("addSampleName");
    401411        experimentTitle = experimentShortTitle + " " + (String) job
    402412          .getValue("details");
     
    600610      // Copy mzData XML blocks from peak list file item
    601611      // copyMzDataXMLBlocks(xmlCrudeWriter, peakListFileId);
    602       copySelectedXMLBlocks(dc, xmlCrudeWriter, peakListFileId, "mzData");
     612      if (addContact.booleanValue() && !addSampleName.booleanValue())
     613      {
     614        copySelectedXMLBlocks(dc, xmlCrudeWriter, peakListFileId,
     615          "mzData", "contact");
     616        writeContactBlock(xmlCrudeWriter);
     617        copySelectedXMLBlocks(dc, xmlCrudeWriter, peakListFileId,
     618          "/contact", "mzData");
     619       
     620      }
     621      else if (addContact.booleanValue())
     622      {
     623        copySelectedXMLBlocks(dc, xmlCrudeWriter, peakListFileId,
     624          "mzData", "admin");
     625        writeSampleBlock(xmlCrudeWriter);
     626        xmlCrudeWriter.writeStartElement("contact");
     627        xmlCrudeWriter.writeStartElementEnd();
     628        writeContactBlock(xmlCrudeWriter);
     629        copySelectedXMLBlocks(dc, xmlCrudeWriter, peakListFileId,
     630          "/contact", "mzData");
     631      }
     632      else if (!addSampleName.booleanValue())
     633      {
     634        copySelectedXMLBlocks(dc, xmlCrudeWriter, peakListFileId,
     635          "mzData", null);
     636      }
     637      else
     638      {
     639        copySelectedXMLBlocks(dc, xmlCrudeWriter, peakListFileId,
     640          "mzData", "admin");
     641        writeSampleBlock(xmlCrudeWriter);
     642        copySelectedXMLBlocks(dc, xmlCrudeWriter, peakListFileId,
     643          "contact", "mzData");
     644      }
    603645      //
    604646      boolean externalIdOrderingFlag = true;
     
    11021144        // Copy protocol block from protocol XML file
    11031145        copySelectedXMLBlocks(dc, xmlCrudeWriter, prideProtocolFileId,
    1104           "Protocol");
     1146          "Protocol", null);
    11051147      }
    11061148      else
     
    32793321  private void copySelectedXMLBlocks(DbControl dc,
    32803322      XMLCrudeWriterImpl xmlCrudeWriterImpl, Integer sourceFileId,
    3281       String selectedXmlTagName)
     3323      String selectedXmlTagName, String selectedXMLEndTag)
    32823324      throws XMLStreamException
    32833325  {
     
    33173359        "<" + selectedXmlTagName);
    33183360      // selectedXMLBlockEndLinePattern example: ".*</mzData>"
     3361
     3362      if (selectedXMLEndTag == null)
     3363      {
     3364        selectedXMLEndTag = "/"+selectedXmlTagName;
     3365      }
    33193366      String selectedXMLBlockEndLinePattern = new String(
    3320         ".*</" + selectedXmlTagName + ">");
     3367        ".*<" + selectedXMLEndTag + ">.*");
     3368      String selectedXMLBlockEnd = new String(
     3369        "<" + selectedXMLEndTag + ">");
     3370
    33213371      log
    33223372        .debug("selectedXMLBlockStartLinePattern = \"" + selectedXMLBlockStartLinePattern + "\"");
     
    33483398            firstLine = false;
    33493399          }
     3400          if (inSelectedXMLBlock && line
     3401            .matches(selectedXMLBlockEndLinePattern))
     3402          {
     3403            int end = currentLine.indexOf(selectedXMLBlockEnd) + selectedXMLBlockEnd
     3404              .length();
     3405            currentLine = currentLine.substring(0, end);
     3406            inSelectedXMLBlock = false;
     3407          }
    33503408          xmlCrudeWriterImpl.writeIndentedText(currentLine,
    33513409            extraIndentation);
    33523410        }
    33533411        // Skip part of source XML file after selected XML block
    3354         if (inSelectedXMLBlock && line
    3355           .matches(selectedXMLBlockEndLinePattern))
    3356         {
    3357           inSelectedXMLBlock = false;
    3358         }
     3412
    33593413      }
    33603414    }
     
    34013455
    34023456
     3457  private void writeContactBlock(XMLCrudeWriterImpl xmlCrudeWriter)
     3458  {
     3459    try
     3460    {
     3461      // writeStartTag("contact");
     3462      //
     3463      // writeStartTag("name");
     3464      xmlCrudeWriter.writeStartElement("name");
     3465      xmlCrudeWriter.writeStartElementEnd();
     3466      xmlCrudeWriter.writeCharacters(contactName);
     3467      // writeEndTag("name");
     3468      xmlCrudeWriter.writeEndElement("name");
     3469      //
     3470      // writeStartTag("institution");
     3471      xmlCrudeWriter.writeStartElement("institution");
     3472      xmlCrudeWriter.writeStartElementEnd();
     3473      xmlCrudeWriter.writeCharacters(contactInst);
     3474      // writeEndTag("institution");
     3475      xmlCrudeWriter.writeEndElement("institution");
     3476      xmlCrudeWriter.writeStartElement("contactInfo");
     3477      xmlCrudeWriter.writeStartElementEnd();
     3478      xmlCrudeWriter.writeCharacters(contactInfo);
     3479      xmlCrudeWriter.writeEndElement("contactInfo");
     3480      //
     3481    }
     3482    catch (XMLStreamException e)
     3483    {
     3484      log
     3485        .warn("Problem when generating xml file " + xmlFilePath + " : " + e);
     3486    }
     3487  }
     3488
     3489  private void writeSampleBlock(XMLCrudeWriterImpl xmlCrudeWriter)
     3490  {
     3491    try
     3492    {
     3493      // writeStartTag("contact");
     3494      //
     3495      // writeStartTag("name");
     3496      xmlCrudeWriter.writeStartElement("sampleName");
     3497      xmlCrudeWriter.writeStartElementEnd();
     3498      xmlCrudeWriter.writeCharacters(localSampleId);
     3499      // writeEndTag("name");
     3500      xmlCrudeWriter.writeEndElement("sampleName");
     3501      //
     3502      // writeStartTag("institution");
     3503      xmlCrudeWriter.writeStartElement("sampleDescription");
     3504      xmlCrudeWriter.writeStartElementEnd();
     3505      // writeEndTag("institution");
     3506      xmlCrudeWriter.writeEndElement("sampleDescription");
     3507      //
     3508    }
     3509    catch (XMLStreamException e)
     3510    {
     3511      log
     3512        .warn("Problem when generating xml file " + xmlFilePath + " : " + e);
     3513    }
     3514  }
    34033515  /**
    34043516   * Checks if an XML file is valid according to a specific XML Schema
Note: See TracChangeset for help on using the changeset viewer.