Ignore:
Timestamp:
Dec 7, 2007, 11:56:19 AM (14 years ago)
Author:
mbayer
Message:

problem with file writing fixed - file is now actually written to directory where the zip file shave been unzipped

Location:
branches/uk_ac_ebi_Tab2MageImporter/src/uk/ac/ebi/nugo/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/uk_ac_ebi_Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/Tab2MageImporter.java

    r513 r515  
    153153    System.out.println("configure()");
    154154    String command = request.getCommand();
    155     System.out.println("command = " + command);
     155    System.out.println(" configure request = "  +request + ", command = " + request.getCommand());
    156156
    157157    try
     
    348348  {
    349349    System.out.println("running Tab2MageImporter plugin");
    350     response.setDone("Import plugin ended successfully");
    351 
     350    System.out.println(" run request = "  +request + ", command = " + request.getCommand());
     351   
    352352   
    353353    DbControl dc=null;
     
    381381      // save the new subDir
    382382      dc.saveItem(subDir);
     383     
     384      if(dc==null)
     385        dc = sc.newDbControl();
    383386
    384387//      String directoryName = (String)job.getValue("directory");
     
    415418      //now write the tab2mage file to the user's home dir on the server so it can be consumed by the plugin
    416419      //this takes all the inputs provided by the user on the custom interface (input.jsp)
    417       //give the file a unique name so we don't get any conflicts
    418       //use code from tab2mage exporter to do so
    419      
    420       //PluginConfigurationRequest pcRequest = (PluginConfigurationRequest) sc.getSessionSetting("plugin.configure.request");     
    421       Tab2MageWriter t2mWriter = new Tab2MageWriter(request, dir,dc);
     420      //give the file a unique name so we don't get any conflicts
     421      Tab2MageWriter t2mWriter = new Tab2MageWriter(job, dir,sc);
    422422      t2mWriter.writeTab2MageFile();
    423      
     423
    424424     
    425425      /////////////////////////////////////////////////////////////////////////////////////////////////
     
    567567      // -- end of messaging module
    568568      */
    569       dc.commit();
     569      //dc.commit();
    570570      response.setDone("Import plugin ended successfully");
    571571    }
  • branches/uk_ac_ebi_Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/Tab2MageWriter.java

    r514 r515  
    99import net.sf.basedb.core.PermissionDeniedException;
    1010import net.sf.basedb.core.PluginConfigurationRequest;
     11import net.sf.basedb.core.SessionControl;
     12import net.sf.basedb.core.plugin.ParameterValues;
    1113import net.sf.basedb.core.plugin.Request;
    1214
     
    1517//===================================================vars================================================
    1618 
    17   int numSubjects;
     19  int numReplicates;
    1820  int numTissues;
    1921  int numTreatments;
    20   Request pcRequest ;
    2122  Directory dir;
    22   DbControl dc;
     23  SessionControl sc;
    2324 
    2425//  ===================================================c'tor================================================
    2526 
    26   public Tab2MageWriter(Request pcRequest,Directory dir,DbControl dc )
     27  public Tab2MageWriter(ParameterValues job,Directory dir,SessionControl sc)
    2728  {
    28     this.pcRequest = pcRequest;
    2929    this.dir = dir;
    30     this.dc = dc;
     30    this.sc = sc;
     31
     32    //get values for the parameters we need here
     33    int numReplicates = Integer.parseInt((String)job.getValue("numReplicates"));
     34    int numTreatments = Integer.parseInt((String)job.getValue("numTreatments"));   
     35    String tissues = (String)job.getValue("tissues");
     36    int numTissues = tissues.split(",").length;
    3137   
    32     //get values for the parameters we need here
    33     int numSubjects = Integer.parseInt((String)pcRequest.getParameterValue("numReplicates"));
    34     int numTreatments = Integer.parseInt((String)pcRequest.getParameterValue("numTreatments"));   
    35     String tissues = (String)pcRequest.getParameterValue("tissues");
    36     int numTissues = tissues.split(",").length;
     38    System.out.println("numReplicates extracted from job = " +numReplicates);
    3739  }
    3840
     
    4850    {
    4951      //set up a file writer
     52      DbControl dc = sc.newDbControl();
    5053      net.sf.basedb.core.File t2mFile = net.sf.basedb.core.File.getNew(dc, dir);   
    51       t2mFile.setName("tab2mage.txt");
     54      System.out.println("dir for writing new tab2mage file = "+dir.getName());
     55      t2mFile.setName("tab2mage.txt");     
     56      dc.saveItem(t2mFile);
     57     
     58      if(dc==null)
     59        dc = sc.newDbControl();
     60     
    5261      Writer out= new BufferedWriter(new OutputStreamWriter(t2mFile.getUploadStream(false),"ISO-8859-1"));
    5362     
     
    5766      //close writer
    5867      if (out!= null) out.close();
     68     
     69      dc.commit();
     70      if(dc!=null)
     71        dc.close();
    5972    }
    6073    catch (Exception e)
     
    6780  {
    6881    //Number of hybridizations (NH) = Number of subjects (NS) x Number of Target Tissue (NTT) x Number of Study groups (NSG)
    69     return numSubjects * numTissues * numTreatments;
     82    return numReplicates * numTissues * numTreatments;
    7083
    7184  }
Note: See TracChangeset for help on using the changeset viewer.