Changeset 472
- Timestamp:
- Nov 12, 2007, 5:50:07 PM (16 years ago)
- Location:
- trunk/uk/ac/ebi/Tab2MageImporter
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/uk/ac/ebi/Tab2MageImporter/README.txt
r457 r472 63 63 When the import has finished, you can check and review the uploaded experiment by navigating through base2 web client, using the menu. If you have provided your email server name. You would receive an email message on the status of the import. 64 64 65 ========================================================= 66 Pooling Implementation 67 -------------------------------- 68 The tab2mage importer runs in a pooled or non- pooled state. 69 A pooling protocol - Protocol[pool] must be specified for experiments that involve pooling, otherwise the importer would run in a non-pool state. 70 71 One stage pooling - > biosource to sample, sample to extract or extract to labeled extract is fully supported 72 73 Multiple stage pooling: biosource to sample and sample to extract supported. Note that Multi stage pooling involving labeled extract is not supported. 74 75 Please check pooling notes link on the download page for more information 76 77 For usability and consistency on the biomaterial user interface, do run the same experiment twice. An imported experiment (with raw data and meta-data) that involves pooling may only be loaded once. 78 65 79 =========================================================== 66 80 AnnotationTypes and Cv Importer -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/Helper.java
r463 r472 82 82 } 83 83 Path path = new Path(pathString, Path.Type.FILE); 84 85 84 file= File.getByPath(dc, path, true); 86 85 file.setMimeType("text/plain"); //set the type of the file … … 135 134 { 136 135 String fileName= file.getName(); 137 //System.out.println("\nThe file name is: " + fileName );138 136 String ext= fileName.substring(fileName.lastIndexOf(".") + 1); 139 137 ext = ext.toLowerCase(); 140 //System.out.printf("The file ext is: %s\n", ext); 141 return ext; 138 return ext; 142 139 } 143 140 … … 370 367 return p; 371 368 } 369 370 /** 371 validates the directory parameter specified by user 372 @param file, the zip file. its directory, is checked for the existence of directoryName given by the user 373 @param directoryName, the name of the directory specified by the user 374 @return TRUE if directory exist and FALSE otherwise 375 */ 376 public static boolean validateDirectory (SessionControl sc ,File file, String directoryName) 377 { 378 DbControl dc = sc.newDbControl(); 379 try 380 { 381 file = File.getById(dc, file.getId()); 382 return Directory.exists(dc, file.getDirectory(), directoryName); 383 } 384 finally 385 { 386 if (dc != null) dc.close(); 387 } 388 } 372 389 } -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/ZipUnpacker.java
r463 r472 9 9 import java.io.IOException; 10 10 import java.io.InputStream; 11 import java.text.SimpleDateFormat; 11 12 import java.util.Date; 13 import java.util.Locale; 12 14 import java.util.zip.ZipEntry; 13 15 import java.util.zip.ZipInputStream; 14 16 15 import net.sf.basedb.core. DatabaseException;17 import net.sf.basedb.core.BaseException; 16 18 import net.sf.basedb.core.DbControl; 17 19 import net.sf.basedb.core.Directory; 18 20 import net.sf.basedb.core.File; 21 import net.sf.basedb.core.ItemAlreadyExistsException; 19 22 import net.sf.basedb.core.Location; 20 23 import net.sf.basedb.core.PluginDefinition; … … 57 60 Unpacks a zip file, checking that there is enough space to accommodate 58 61 the zip file once it is unpacked. 59 @throws NutribasePluginException 60 */ 61 public void unpack() throws NutribasePluginException 62 */ 63 public void unpack(String dirName) 62 64 { 63 65 log.info("Begin to unpack the files"); … … 73 75 if (hasSpace) 74 76 { 77 createSubDirectory( file, user, dirName); 78 // now call the method to unpack the zip files 79 PluginDefinition zipFilePlugin = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.ZipFileUnpacker"); 80 FileUnpacker unpacker = zipFilePlugin.newInstance(net.sf.basedb.plugins.ZipFileUnpacker.class, null, dc.getSessionControl(), null, null); 81 numUnpackedFiles=unpacker.unpack(dc, unzippedFilesDirectory,file.getDownloadStream(0), false,null); 82 } 83 else // if space is not enough 84 { 85 throw new BaseException("User do not have the required Disk Space. Please contact your BASE administrator or remove some files"); 86 } 87 dc.commit(); 88 inStream.close(); 89 } 90 catch (Throwable exc) 91 { 92 dc.close(); 93 log.info("File cannot be unpacked", exc); 94 new BaseException("File cannot be unpacked :" +exc.getMessage()); 95 } 96 finally 97 { 98 if (dc!=null) 99 dc.close(); 100 } 101 } 102 103 104 /** 105 Unpacks a zip file, checking that there is enough space to accommodate 106 the zip file once it is unpacked. 107 @throws NutribasePluginException 108 */ 109 public void unpack() 110 { 111 log.info("Begin to unpack the files"); 112 DbControl dc=null; 113 try 114 { 115 dc= sc.newDbControl(); 116 if (file==null) 117 return; 118 InputStream inStream = file.getDownloadStream(0); 119 //check if the logged in user has sufficient disk space. if yes go ahead with the unpacking 120 boolean hasSpace= checkUserQuota(inStream, dc); 121 if (hasSpace) 122 { 75 123 createSubDirectory( file, user); 76 124 // now call the method to unpack the zip files … … 81 129 else // if space is not enough 82 130 { 83 throw new NutribasePluginException("User do not have the required Disk Space. Please contact your NutriBASE administrator or remove some files");131 throw new BaseException("User do not have the required Disk Space. Please contact your BASE administrator or remove some files"); 84 132 } 85 133 dc.commit(); … … 90 138 dc.close(); 91 139 log.info("File cannot be unpacked", exc); 92 new NutribasePluginException(exc.getMessage());140 new BaseException(exc.getMessage()); 93 141 } 94 142 finally … … 98 146 } 99 147 } 100 148 101 149 /** 102 150 checks user quota … … 122 170 { 123 171 log.error("[disk space: "+remainingSpace+ " ] insufficient for unzipping of file size [" +zipFileSize + "] -- please contact your BASE administrator or remove some files"); 124 throw new NutribasePluginException("[disk space: "+remainingSpace+ " ] insufficient for unzipping of file size [" +zipFileSize + "] -- please contact your BASE administrator or remove some files");172 throw new BaseException("[disk space: "+remainingSpace+ " ] insufficient for unzipping of file size [" +zipFileSize + "] -- please contact your BASE administrator or remove some files"); 125 173 } 126 174 else if ( remainingSpace > zipFileSize || quotaValue==-1 ) … … 153 201 catch (IOException ioe) 154 202 { 155 throw new NutribasePluginException("zip file size could not be obtained " + ioe.getMessage());203 throw new BaseException("zip file size could not be obtained " + ioe.getMessage()); 156 204 } 157 205 return totalSize; … … 161 209 @param zipFile, the zip file to unpack 162 210 @param user, currently logged-in user 211 @param 212 213 */ 214 public void createSubDirectory(File zipFile, User user, String dirName) 215 { 216 DbControl dc=null; 217 try 218 { 219 dc = sc.newDbControl(); 220 //get the parent directory 221 Directory zipFileDir = zipFile.getDirectory(); 222 log.info("zipFile is located in dir " + zipFile.getPath()); 223 Directory d = Directory.getById(dc, zipFileDir.getId()); 224 //String timeStamp = getTime("ddMMyy_HHmmss"); // can be added to the time directory name 225 Directory subDir = d.newSubDirectory(); 226 subDir.setName(dirName); 227 subDir.setDescription("Unzippped directory created at "+new Date()); 228 if (subDir.isInDatabase()) 229 { 230 throw new ItemAlreadyExistsException("The Directory ["+ subDir.getPath().toString()+ "] already exists"); 231 } 232 else if (!subDir.isInDatabase()) 233 { 234 dc.saveItem(subDir); 235 } 236 dc.commit(); 237 setUnzippedFilesDirectory(subDir); 238 } 239 catch (Throwable ex) 240 { 241 log.error("--Create subdirectory FAILED", ex); 242 } 243 finally 244 { 245 if (dc!=null) dc.close(); 246 } 247 248 } 249 250 /** 251 create a sub-directory to contain the unzip files 252 @param zipFile, the zip file to unpack 253 @param user, currently logged-in user 254 @param 163 255 164 256 */ … … 174 266 Directory d = Directory.getById(dc, zipFileDir.getId()); 175 267 Directory subDir = d.newSubDirectory(); 268 String fileName = zipFile.getName(); 269 String fileNameNoExt = fileName.substring(0, fileName.indexOf(".")); 270 subDir.setName(fileNameNoExt); 271 subDir.setDescription("Unzippped directory created at "+new Date()); 176 272 if (subDir.isInDatabase()) 177 273 { 178 throw new DatabaseException("The Directory ["+ subDir.getPath().toString()+ "] already exists");274 throw new ItemAlreadyExistsException("The Directory ["+ subDir.getPath().toString()+ "] already exists"); 179 275 } 180 276 else if (!subDir.isInDatabase()) 181 277 { 182 String fileName = zipFile.getName(); 183 String fileNameNoExt = fileName.substring(0, fileName.indexOf(".")); 184 subDir.setName(fileNameNoExt); 185 subDir.setDescription("Unzippped directory created at "+new Date()); 186 dc.saveItem(subDir); 278 dc.saveItem(subDir); 187 279 } 188 280 dc.commit(); … … 192 284 { 193 285 log.error("--Create subdirectory FAILED", ex); 286 //throw new BaseException(); 194 287 } 195 288 finally … … 200 293 } 201 294 202 203 295 void setUnzippedFilesDirectory(Directory unzippedFilesDirectory) 204 296 { … … 210 302 return unzippedFilesDirectory; 211 303 } 304 305 private String getTime(String pattern) 306 { 307 SimpleDateFormat formatter; 308 Locale currentLocale = Locale.getDefault(); 309 formatter = new SimpleDateFormat(pattern, currentLocale); 310 String timeStamp = formatter.format(new Date()); 311 return timeStamp; 312 } 212 313 }
Note: See TracChangeset
for help on using the changeset viewer.