Changeset 446
- Timestamp:
- Oct 30, 2007, 3:17:24 PM (16 years ago)
- Location:
- trunk/uk/ac/ebi/AnnotationTypeCvImporter
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/uk/ac/ebi/AnnotationTypeCvImporter/ChangeLog.txt
r364 r446 1 ,____ First release1 ,____ News on changes 2 2 3 Th is file will contain information about changes iin subsequent releases.3 The ebi-utils api has been updated -
trunk/uk/ac/ebi/AnnotationTypeCvImporter/build.xml
r390 r446 31 31 description="compile the common ebi -plugin util classes" 32 32 > 33 <mkdir dir="${bin.plugins}"/> 33 34 <javac 34 35 encoding="ISO-8859-1" -
trunk/uk/ac/ebi/AnnotationTypeCvImporter/src/uk/ac/ebi/nugo/common/Helper.java
r422 r446 11 11 import net.sf.basedb.core.ArrayDesign; 12 12 import net.sf.basedb.core.ArraySlide; 13 import net.sf.basedb.core.BaseException; 13 14 import net.sf.basedb.core.BioSource; 14 15 import net.sf.basedb.core.DbControl; 16 import net.sf.basedb.core.Directory; 15 17 import net.sf.basedb.core.Extract; 16 18 import net.sf.basedb.core.File; … … 23 25 import net.sf.basedb.core.Path; 24 26 import net.sf.basedb.core.Sample; 27 import net.sf.basedb.core.SessionControl; 25 28 import net.sf.basedb.core.Type; 26 29 import net.sf.basedb.core.User; … … 31 34 /** 32 35 A plugin utils class for the tab2mage export and export. 33 [TODO] This class may be merged to other utils in the main base 2 source code 34 @author Dominic Oyeniran 36 @author Dominic Oyeniran 35 37 @version 1.0 36 38 */ … … 68 70 69 71 72 public static File processFilePath (User user,boolean overwrite, SessionControl sc, String pathString) 73 { 74 DbControl dc= null; 75 File file =null; 76 try 77 { 78 dc= sc.newDbControl(); 79 if (pathString.startsWith("~/")) 80 { 81 pathString = "~"+user.getLogin()+pathString.substring(1); 82 } 83 Path path = new Path(pathString, Path.Type.FILE); 84 85 file= File.getByPath(dc, path, true); 86 file.setMimeType("text/plain"); //set the type of the file 87 if (file.isInDatabase() && !overwrite && !file.isRemoved()) 88 { 89 throw new ItemAlreadyExistsException("File[path="+path+"]"); 90 } 91 else if(!file.isInDatabase()) 92 { 93 dc.saveItem(file); 94 } 95 dc.commit(); 96 } 97 catch(Exception e) 98 { 99 dc.close(); 100 } 101 finally 102 { 103 if (dc!=null) 104 dc.close(); 105 } 106 107 return file; 108 } 70 109 /** 71 110 Displays the content of the map. Helps to check that the content displayed is correct. … … 109 148 of a tab2mage file 110 149 @param atName , annotation type name 111 @return annotationType s, <code>AnnotationType</code>150 @return annotationType, <code>AnnotationType</code> 112 151 */ 113 152 public static AnnotationType getAnnotationTypeByName(String atName, DbControl dc) … … 211 250 return ar; 212 251 } 213 /** 214 writes a string to standard output 215 @param o 216 */ 217 public static void write(String o) 218 { 219 System.out.println("&& DEBUG : "+o); 220 } 221 252 222 253 223 254 /** … … 311 342 return le; 312 343 } 344 345 346 /** 347 gets the currently looged in user default directory 348 @param sc, the seesion control 349 @return path of the user directory as a string object 350 */ 351 public static String getUserDefaultDirectory( SessionControl sc) 352 { 353 DbControl dc = sc.newDbControl(); 354 String p =""; 355 try 356 { 357 User user = User.getById(dc, sc.getLoggedInUserId()); 358 Directory dir= user.getHomeDirectory(); 359 Path path = dir.getPath(); 360 p=path.toString(); 361 } 362 catch(Exception e) 363 { 364 new BaseException(e.getMessage()); 365 } 366 finally 367 { 368 if (dc!=null) dc.close(); 369 } 370 return p; 371 } 313 372 } -
trunk/uk/ac/ebi/AnnotationTypeCvImporter/src/uk/ac/ebi/nugo/common/Tab2MageConstants.java
r395 r446 1 /** 2 * 3 */ 1 /* $Id: Tab2MageConstants.java 2006-08-08 dominic $ 2 3 This file is for NutriBASE - Nutrigenomics BioArray Software Environment. 4 A customisation of the BASE SOFTWARE. 5 Developed at the EBI , Cambridge. 6 Author: Dominic Oyeniran: oyeniran@ebi.ac.uk 7 */ 4 8 package uk.ac.ebi.nugo.common; 5 9 … … 13 17 @author Dominic Oyeniran 14 18 @version 1.0 15 @base.modified $Date16 19 */ 17 20 public enum Tab2MageConstants … … 193 196 The parameter header 194 197 */ 195 parameter(49, "Parameter"); 198 parameter(49, "Parameter"), 199 200 /** 201 The protocol header 202 */ 203 protocol(50, "Protocol"), 204 205 /** 206 nucleic acid extraction 207 */ 208 nucleicacidextraction(51, "Nucleic_Acid_Extraction"); 209 ; 196 210 197 211 /** -
trunk/uk/ac/ebi/AnnotationTypeCvImporter/src/uk/ac/ebi/nugo/common/ValueFormatter.java
r422 r446 16 16 /** 17 17 A utility class containing static methods for formatting parameter values. 18 [TODO] This class may be merged to util class in the main base 2 source code19 18 @author Dominic Oyeniran 20 19 @email oyeniran@ebi.ac.uk -
trunk/uk/ac/ebi/AnnotationTypeCvImporter/src/uk/ac/ebi/nugo/common/ZipUnpacker.java
r422 r446 13 13 import java.util.zip.ZipInputStream; 14 14 15 import net.sf.basedb.core.DatabaseException; 15 16 import net.sf.basedb.core.DbControl; 16 17 import net.sf.basedb.core.Directory; … … 31 32 /** 32 33 This class unpacks zip file provided by users into the base file structure 33 Note: Parts of the codes are authored by Misha Bayer - email: sbrn@scri.ac.uk,34 Note: Parts of the codes were authored by Misha Bayer - email: sbrn@scri.ac.uk, 34 35 @author Dominic Oyeniran 35 36 @email oyeniran@ebi.ac.uk 36 @see BatchDataImport.java and BatchLoader plugin developed by Misha Bayer.37 38 37 39 38 */ … … 75 74 { 76 75 createSubDirectory( file, user); 77 // now call the m athod to unpack the zip files76 // now call the method to unpack the zip files 78 77 PluginDefinition zipFilePlugin = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.ZipFileUnpacker"); 79 78 FileUnpacker unpacker = zipFilePlugin.newInstance(net.sf.basedb.plugins.ZipFileUnpacker.class, null, dc.getSessionControl(), null, null); … … 115 114 //unlimited storage (e.g. for user root) will return -1 116 115 long quotaValue = quota.getQuotaValue(totalQuotaType, Location.PRIMARY); 117 //System.out.println("the quota value of the user: " + user.getName()+ " is: "+quotaValue );116 log.info("the quota value of the user: " + user.getName()+ " is: "+quotaValue ); 118 117 long currentDiskUsage = user.getDiskUsage(totalQuotaType, Location.PRIMARY); 119 118 //check whether remaining disk space and zip file size are compatible 120 119 long remainingSpace = quotaValue - currentDiskUsage; 121 //System.out.println("the remaining space for user: " + user.getName()+ " is: "+remainingSpace );120 log.info("the remaining space for user: " + user.getName()+ " is: "+remainingSpace ); 122 121 if(remainingSpace < zipFileSize && quotaValue!=-1) 123 122 { … … 172 171 //get the parent directory 173 172 Directory zipFileDir = zipFile.getDirectory(); 174 //System.out.println("zipFile is located in dir " + zipFile.getPath());173 log.info("zipFile is located in dir " + zipFile.getPath()); 175 174 Directory d = Directory.getById(dc, zipFileDir.getId()); 176 175 Directory subDir = d.newSubDirectory(); 177 String fileName = zipFile.getName(); 178 String fileNameNoExt = fileName.substring(0, fileName.indexOf(".")); 179 subDir.setName(fileNameNoExt); 180 subDir.setDescription("Unzippped directory created at "+new Date()); 181 dc.saveItem(subDir); 182 dc.commit(); 183 //unzippedFilesDirectory = subDir; 176 if (subDir.isInDatabase()) 177 { 178 throw new DatabaseException("The Directory ["+ subDir.getPath().toString()+ "] already exists"); 179 } 180 else if (!subDir.isInDatabase()) 181 { 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); 187 } 188 dc.commit(); 184 189 setUnzippedFilesDirectory(subDir); 185 190 } 186 191 catch (Throwable ex) 187 192 { 188 log.error("--Create subdirectory FAILED" );193 log.error("--Create subdirectory FAILED", ex); 189 194 } 190 195 finally -
trunk/uk/ac/ebi/AnnotationTypeCvImporter/src/uk/ac/ebi/nugo/plugins/AnnotationTypeCvImporter.java
r395 r446 35 35 import net.sf.basedb.util.parser.Mapper; 36 36 import net.sf.basedb.util.Values; 37 import uk.ac.ebi.nugo.common.ValueFormatter; 37 38 38 39 … … 511 512 if (category != null) 512 513 { 513 List<String> annotationTypeCategory= Value s.getList(columnMappings.get("categoryColumnMapping").getValue(data),";");514 List<String> annotationTypeCategory= ValueFormatter.getList(columnMappings.get("categoryColumnMapping").getValue(data),";"); 514 515 515 516 for (int i=0, z=annotationTypeCategory.size(); i<z;i++) … … 540 541 if (enumeration) 541 542 annotationType.setValues 542 (Value s.getList(columnMappings.get("cvValueColumnMapping").getValue(data),";"));543 (ValueFormatter.getList(columnMappings.get("cvValueColumnMapping").getValue(data),";")); 543 544 544 545 itemType= columnMappings.get("itemTypeColumnMapping").getValue(data); … … 546 547 { 547 548 Item[] items=Item.values(); 548 List<String> itemTypes=Value s.getList(columnMappings.get("itemTypeColumnMapping").getValue(data),separator);549 List<String> itemTypes=ValueFormatter.getList(columnMappings.get("itemTypeColumnMapping").getValue(data),separator); 549 550 for (String itemType: itemTypes) 550 551 {
Note: See TracChangeset
for help on using the changeset viewer.