Changeset 513 for branches/uk_ac_ebi_Tab2MageImporter/src/uk
- Timestamp:
- Dec 6, 2007, 1:04:50 PM (14 years ago)
- 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 43 43 String pooling; 44 44 String zipFile; 45 String experimentId; 45 46 46 47 … … 356 357 { 357 358 this.zipFile = zipFile; 359 } 360 public String getExperimentId() 361 { 362 return experimentId; 363 } 364 public void setExperimentId(String experimentId) 365 { 366 this.experimentId = experimentId; 358 367 } 359 368 -
branches/uk_ac_ebi_Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/Tab2MageImporter.java
r512 r513 9 9 import java.io.InputStream; 10 10 import java.util.Arrays; 11 import java.util.Calendar; 11 12 import java.util.Collections; 12 13 import java.util.LinkedList; … … 25 26 import net.sf.basedb.core.Item; 26 27 import net.sf.basedb.core.Job; 28 import net.sf.basedb.core.Path; 27 29 import net.sf.basedb.core.PluginConfigurationRequest; 28 30 import net.sf.basedb.core.PluginParameter; … … 41 43 import net.sf.basedb.core.plugin.Request; 42 44 import net.sf.basedb.core.plugin.Response; 45 import net.sf.basedb.util.formatter.DateFormatter; 43 46 import uk.ac.ebi.nugo.common.Helper; 44 47 import uk.ac.ebi.nugo.common.ZipUnpacker; … … 101 104 102 105 private static final Set<GuiContext> guiContexts = Collections.singleton(experimentItemGuiContext); 106 103 107 104 108 // =====================================================c'tor================================== … … 120 124 { 121 125 //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", 123 127 "experimentName","description","releaseDate","submissionDate","submitter","organization", 124 128 "publicationTitle","authors","journal","volume","issue","pages","year","pubmedId","treatmentProtocol", … … 129 133 "tissues","pooling","zipFile"}; 130 134 131 // next create the parameter type 135 // next create the parameter type - everyone is a String here 132 136 StringParameterType stringPT = new StringParameterType(255, null, true); 133 137 … … 188 192 } 189 193 } 190 catch (Throwable ex) 191 { 194 catch (Exception ex) 195 { 196 System.out.println("exception in configure method"); 192 197 ex.printStackTrace(); 193 response.setError(ex.getMessage(), Arrays.asList(ex));198 //response.setError(ex.getMessage(), Arrays.asList(ex)); 194 199 } 195 200 … … 213 218 public String isInContext(GuiContext context, Object item) 214 219 { 220 System.out.println("isInContext called"); 221 215 222 String message = null; 216 223 if (item == null) … … 224 231 } 225 232 else 226 { 227 Experiment exp = (Experiment) 228 RawDataType rawDataType = exp.getRawDataType(); 233 { 234 Experiment exp = (Experiment)item; 235 RawDataType rawDataType = exp.getRawDataType(); 229 236 if (!Tab2MageHelper.supportedPlatforms(rawDataType.getId().toLowerCase())) 230 237 { … … 342 349 System.out.println("running Tab2MageImporter plugin"); 343 350 response.setDone("Import plugin ended successfully"); 344 /* 351 345 352 346 353 DbControl dc=null; … … 354 361 User user= User.getById(dc, sc.getLoggedInUserId()); 355 362 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 372 394 RawDataType rdt= experiment.getRawDataType(); // experiment platform 373 395 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); 376 398 377 399 //FILE UNZIP MODULE: unzip the files into user specified directory 378 400 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()); 381 403 Directory dir= importUnpacker.getUnzippedFilesDirectory(); // this may return the id of the unzipped file directory instead 382 404 if (dir==null) … … 396 418 //use code from tab2mage exporter to do so 397 419 420 //PluginConfigurationRequest pcRequest = (PluginConfigurationRequest) sc.getSessionSetting("plugin.configure.request"); 421 Tab2MageWriter t2mWriter = new Tab2MageWriter(request, dir,dc); 422 t2mWriter.writeTab2MageFile(); 423 424 398 425 ///////////////////////////////////////////////////////////////////////////////////////////////// 399 426 400 427 /* 401 428 402 429 //VALIDATION MODULE … … 539 566 } 540 567 // -- end of messaging module 541 568 */ 542 569 dc.commit(); 543 570 response.setDone("Import plugin ended successfully"); … … 553 580 } 554 581 555 */582 556 583 557 584 }
Note: See TracChangeset
for help on using the changeset viewer.