- Timestamp:
- Aug 8, 2007, 12:40:31 PM (16 years ago)
- Location:
- trunk/uk/ac/ebi/AffyArrayDesignBatchImporter/src/uk/ac/ebi/nugo/plugins
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/uk/ac/ebi/AffyArrayDesignBatchImporter/src/uk/ac/ebi/nugo/plugins/AffyArrayDesignBatchImporter.java
r358 r376 41 41 import net.sf.basedb.core.plugin.Response; 42 42 import uk.ac.ebi.nugo.plugins.lims.AffymetrixFileFormatTypes; 43 import uk.ac.ebi.nugo.plugins.util. Tab2MageHelper;43 import uk.ac.ebi.nugo.plugins.util.Helper; 44 44 import uk.ac.ebi.nugo.plugins.util.ZipUnpacker; 45 45 … … 56 56 57 57 private RequestInformation configureJob; 58 //private DbControl dc;58 59 59 private PluginParameter<File> fileParameter; 60 60 … … 64 64 "Affymetrix Array Design Batch Importer", 65 65 "This plugin is used to import affymetrix array design into base 2. Running this plugin is a pre-requisite for " + 66 "running the Tab2Mage importer developed at the EBI. The array deisgn are supplied in a zip archive",66 "running the Tab2Mage importer developed at the EBI. The array deisgns must be supplied in a zip archive", 67 67 "1.0", 68 68 "@Copyright 2007, The EBI NutriBase development team", … … 161 161 { 162 162 response.setError(ex.getMessage(), Arrays.asList(ex)); 163 ex.printStackTrace();164 163 } 165 164 } … … 197 196 for (Role role : roles ) 198 197 { 199 //System.out.println("The user role is :"+ role);200 198 if (role.getName().equalsIgnoreCase("administrator")) validRole = true; 201 199 } … … 218 216 Unpack Zip files 219 217 */ 220 ZipUnpacker affyArrayDesignUnpacker = new ZipUnpacker(file, user, dc);218 ZipUnpacker affyArrayDesignUnpacker = new ZipUnpacker(file, user, sc); 221 219 affyArrayDesignUnpacker.unpack(); 222 220 /* … … 233 231 { 234 232 // get the file extension and filename 235 String ext= Tab2MageHelper.getFileExtension(affyFile);233 String ext= Helper.getFileExtension(affyFile); 236 234 237 235 // check for validity against an enum file … … 252 250 } 253 251 254 // otherwise 255 // check if an array design with the same name exist. 252 // check if an array design with the same name exist. 256 253 String fileName = affyFile.getName(); 257 254 String fileNameWithoutExtension = fileName.substring(0, fileName.indexOf(".")); 258 ArrayDesign ad= Tab2MageHelper.getArrayDesign(fileNameWithoutExtension, dc);255 ArrayDesign ad= Helper.getArrayDesign(fileNameWithoutExtension, dc); 259 256 //if no array design was found create a new one otherwise 260 257 //skip array design creation … … 262 259 { 263 260 // create an array design and set the name as filename without the extension 264 if (dc == null || !dc.isConnected()) 265 dc = sc.newDbControl(); 261 if (dc == null || !dc.isConnected()) dc = sc.newDbControl(); 266 262 ArrayDesign arrayDesign= ArrayDesign.getNew(dc, true); 267 263 arrayDesign.setName(fileNameWithoutExtension); … … 282 278 { 283 279 response.setError(ex.getMessage(), Arrays.asList(ex)); 284 ex.printStackTrace();280 285 281 } 286 282 finally … … 306 302 catch (Exception e) 307 303 { 308 Tab2MageHelper.write("File is not a zip file and cannot be imported by this plugin."); 309 e.printStackTrace(); 310 311 return false; 312 } 304 return false; 305 } 313 306 finally 314 307 { -
trunk/uk/ac/ebi/AffyArrayDesignBatchImporter/src/uk/ac/ebi/nugo/plugins/lims/AffymetrixFileFormatTypes.java
r358 r376 7 7 8 8 9 import java.util.EnumSet;10 import java.util.Set;11 9 12 10 public enum AffymetrixFileFormatTypes -
trunk/uk/ac/ebi/AffyArrayDesignBatchImporter/src/uk/ac/ebi/nugo/plugins/util/ZipUnpacker.java
r358 r376 9 9 import java.io.IOException; 10 10 import java.io.InputStream; 11 import java.text.SimpleDateFormat;12 import java.util.Date;13 import java.util.Locale;14 11 import java.util.zip.ZipEntry; 15 12 import java.util.zip.ZipInputStream; 16 17 import org.apache.log4j.Logger;18 19 import uk.ac.ebi.nugo.plugins.tab2mageimport.validation.Tab2MageValidationFactory;20 13 21 14 import net.sf.basedb.core.DbControl; … … 23 16 import net.sf.basedb.core.File; 24 17 import net.sf.basedb.core.Location; 25 import net.sf.basedb.core.Path; 26 import net.sf.basedb.core.SessionControl; 27 import net.sf.basedb.core.Path.Type; 18 import net.sf.basedb.core.PluginDefinition; 28 19 import net.sf.basedb.core.Quota; 29 20 import net.sf.basedb.core.QuotaType; 21 import net.sf.basedb.core.SessionControl; 30 22 import net.sf.basedb.core.SystemItems; 31 23 import net.sf.basedb.core.User; 32 import net.sf.basedb.core.PluginDefinition;33 24 import net.sf.basedb.util.zip.FileUnpacker; 25 26 import org.apache.log4j.Logger; 34 27 35 28 … … 46 39 public class ZipUnpacker 47 40 { 48 protected static Logger log = Logger.getLogger( Tab2MageValidationFactory.class);41 protected static Logger log = Logger.getLogger(ZipUnpacker.class); 49 42 private User user; 50 43 private File file; … … 55 48 private SessionControl sc; 56 49 57 public ZipUnpacker(File zipFile, User user, DbControl dc)50 public ZipUnpacker(File zipFile, User user, SessionControl sc) 58 51 { 59 52 this.user = user; 60 this.dc= dc;53 this.dc=sc.newDbControl(); 61 54 this.file= zipFile; 62 this.sc= dc.getSessionControl();55 //this.sc= dc.getSessionControl(); 63 56 } 64 57 /** 65 58 Unpacks a zip file, checking that there is enough space to accommodate 66 59 the zip file once it is unpacked. 67 *@throws NutribasePluginException60 @throws NutribasePluginException 68 61 */ 69 62 public void unpack() throws NutribasePluginException 70 63 { 71 System.out.println("Begin to unpack the files");64 log.info("Begin to unpack the files"); 72 65 try 73 66 { … … 94 87 catch (Throwable exc) 95 88 { 89 dc.close(); 90 log.info("File cannot be unpacked", exc); 96 91 new NutribasePluginException(exc.getMessage()); 97 92 } 98 93 finally 99 94 { 100 95 if (dc!=null) 96 dc.close(); 101 97 } 102 98 } … … 160 156 catch (IOException ioe) 161 157 { 162 ioe.printStackTrace(); 158 //ioe.printStackTrace(); 159 log.error(ioe.getMessage()); 163 160 } 164 161 return totalSize; 165 162 } 166 163 /** 164 create a sub-directory to contain the unzip files 165 @param zipFile, the zip file to unpack 166 @param user, currently logged-in user 167 @param dc, the database control 168 */ 167 169 public void createSubDirectory(File zipFile, User user , DbControl dc) 168 170 { … … 170 172 171 173 Directory zipFileDir = zipFile.getDirectory(); 172 System.out.println("zipFile is located in dir " + zipFileDir.toString());174 log.info("zipFile is located in dir " + zipFileDir.toString()); 173 175 Directory subDir = Directory.getNew(dc, zipFileDir); 174 176 String fileName = zipFile.getName(); 175 177 String fileNameNoExt = fileName.substring(0, fileName.indexOf(".")); 176 //System.out.println("new subDir = " + fileNameNoExt );177 178 subDir.setName(fileNameNoExt); 178 179 // save the new subDir180 179 dc.saveItem(subDir); 181 180 unzippedFilesDirectory = subDir;
Note: See TracChangeset
for help on using the changeset viewer.