Ignore:
Timestamp:
Dec 6, 2007, 1:04:50 PM (14 years ago)
Author:
mbayer
Message:

have implemented a skeleton writer class which writes a dummy tab2mage file

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/DataBean.java

    r512 r513  
    4343  String pooling;
    4444  String zipFile;
     45  String experimentId;
    4546 
    4647 
     
    356357  {
    357358    this.zipFile = zipFile;
     359  }
     360  public String getExperimentId()
     361  {
     362    return experimentId;
     363  }
     364  public void setExperimentId(String experimentId)
     365  {
     366    this.experimentId = experimentId;
    358367  }
    359368 
  • branches/uk_ac_ebi_Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/Tab2MageImporter.java

    r512 r513  
    99import java.io.InputStream;
    1010import java.util.Arrays;
     11import java.util.Calendar;
    1112import java.util.Collections;
    1213import java.util.LinkedList;
     
    2526import net.sf.basedb.core.Item;
    2627import net.sf.basedb.core.Job;
     28import net.sf.basedb.core.Path;
    2729import net.sf.basedb.core.PluginConfigurationRequest;
    2830import net.sf.basedb.core.PluginParameter;
     
    4143import net.sf.basedb.core.plugin.Request;
    4244import net.sf.basedb.core.plugin.Response;
     45import net.sf.basedb.util.formatter.DateFormatter;
    4346import uk.ac.ebi.nugo.common.Helper;
    4447import uk.ac.ebi.nugo.common.ZipUnpacker;
     
    101104
    102105  private static final Set<GuiContext> guiContexts = Collections.singleton(experimentItemGuiContext);
     106 
    103107
    104108//  =====================================================c'tor================================== 
     
    120124  {   
    121125    //add all the parameter names to a String array for processing
    122     String [] paramNames = new String []{"domain","accession","qualityControl","experimentalDesign",
     126    String [] paramNames = new String []{"experimentId","domain","accession","qualityControl","experimentalDesign",
    123127            "experimentName","description","releaseDate","submissionDate","submitter","organization",
    124128            "publicationTitle","authors","journal","volume","issue","pages","year","pubmedId","treatmentProtocol",
     
    129133            "tissues","pooling","zipFile"};
    130134       
    131     // next create the parameter type
     135    // next create the parameter type - everyone is a String here
    132136    StringParameterType stringPT = new StringParameterType(255, null, true);
    133137   
     
    188192      }
    189193    }
    190     catch (Throwable ex)
    191     {
     194    catch (Exception ex)
     195    {
     196      System.out.println("exception in configure method");
    192197      ex.printStackTrace();
    193       response.setError(ex.getMessage(), Arrays.asList(ex));
     198      //response.setError(ex.getMessage(), Arrays.asList(ex));
    194199    }
    195200
     
    213218  public String isInContext(GuiContext context, Object item)
    214219  {
     220    System.out.println("isInContext called");
     221   
    215222    String message = null;
    216223    if (item == null)
     
    224231    }
    225232    else
    226     {
    227       Experiment exp = (Experiment) item;
    228       RawDataType rawDataType = exp.getRawDataType();
     233    {   
     234      Experiment exp = (Experiment)item;
     235      RawDataType rawDataType = exp.getRawDataType(); 
    229236      if (!Tab2MageHelper.supportedPlatforms(rawDataType.getId().toLowerCase()))
    230237      {
     
    342349    System.out.println("running Tab2MageImporter plugin");
    343350    response.setDone("Import plugin ended successfully");
    344     /*
     351
    345352   
    346353    DbControl dc=null;
     
    354361      User user= User.getById(dc, sc.getLoggedInUserId());
    355362
    356 
    357        //obtain all job parameters
    358 
    359       File file = (File) job.getValue("file");
    360       file= File.getById(dc, file.getId());
    361 
    362       String directoryName = (String)job.getValue("directory");
    363 
    364       String tab2MageFileName= (String) job.getValue("tab2mageFileName");
    365       hostName= (String) job.getValue("emailHost");
    366 
    367       if ((Boolean)job.getValue("overwrite") != null) overwrite = (Boolean)job.getValue("overwrite");
    368       if ((Boolean)job.getValue("validation") != null)  validation = (Boolean)job.getValue("validation");
    369 
    370       Experiment experiment= (Experiment)job.getValue("experiment");
    371       experiment= Experiment.getById(dc,experiment.getId());
     363      String tab2MageFileName= "tab2mage.txt";
     364      String zipFileName = (String)job.getValue("zipFile");
     365     
     366      File zipFile = File.getByPath(dc, new Path(zipFileName, Path.Type.FILE), false);
     367     
     368      // figure out where the zip file is located
     369      Directory zipFileDir = zipFile.getDirectory();
     370      System.out.println("zipFile is located in dir " + zipFileDir.toString());
     371
     372      // make a new subdir in that dir
     373      // the zip file should then be unzipped in here
     374      // give it the same name as that of the zip file plus a timestamp
     375      String timeStamp = new DateFormatter("ddMMyy_HHmmss").format(Calendar.getInstance().getTime());
     376      Directory subDir = Directory.getNew(dc, zipFileDir);
     377      String fileNameNoExt = zipFile.getName().substring(0, zipFile.getName().indexOf("."));
     378      System.out.println("new subDir = " + fileNameNoExt + timeStamp);
     379      subDir.setName(fileNameNoExt + timeStamp);
     380
     381      // save the new subDir
     382      dc.saveItem(subDir);
     383
     384//      String directoryName = (String)job.getValue("directory");
     385//      hostName= (String) job.getValue("emailHost");
     386//      if ((Boolean)job.getValue("overwrite") != null) overwrite = (Boolean)job.getValue("overwrite");
     387//      if ((Boolean)job.getValue("validation") != null)  validation = (Boolean)job.getValue("validation");
     388
     389      //get the experiment object that our data is meant to be imported into
     390      //this will be the experiment that the user is running the import from
     391      String experimentId= (String)job.getValue("experimentId");
     392      Experiment experiment= Experiment.getById(dc,Integer.parseInt(experimentId));
     393           
    372394      RawDataType rdt= experiment.getRawDataType(); // experiment platform
    373395
    374       String statusp=(String)job.getValue("statusPath");
    375       File statusFile=Helper.processFilePath(user,overwrite, sc,statusp);
     396//      String statusp=(String)job.getValue("statusPath");
     397//      File statusFile=Helper.processFilePath(user,overwrite, sc,statusp);
    376398
    377399        //FILE UNZIP MODULE: unzip the files into user specified directory
    378400         
    379       ZipUnpacker importUnpacker = new ZipUnpacker(file, user, sc);
    380       importUnpacker.unpack(directoryName);
     401      ZipUnpacker importUnpacker = new ZipUnpacker(zipFile, user, sc);
     402      importUnpacker.unpack(subDir.getName());
    381403      Directory dir= importUnpacker.getUnzippedFilesDirectory(); // this may return the id of the unzipped file directory instead
    382404      if (dir==null)
     
    396418      //use code from tab2mage exporter to do so
    397419     
     420      //PluginConfigurationRequest pcRequest = (PluginConfigurationRequest) sc.getSessionSetting("plugin.configure.request");     
     421      Tab2MageWriter t2mWriter = new Tab2MageWriter(request, dir,dc);
     422      t2mWriter.writeTab2MageFile();
     423     
     424     
    398425      /////////////////////////////////////////////////////////////////////////////////////////////////
    399426     
    400 
     427/*
    401428
    402429        //VALIDATION MODULE
     
    539566      }
    540567      // -- end of messaging module
    541      
     568      */
    542569      dc.commit();
    543570      response.setDone("Import plugin ended successfully");
     
    553580    }
    554581   
    555     */
     582   
    556583
    557584  }
Note: See TracChangeset for help on using the changeset viewer.