Changeset 446


Ignore:
Timestamp:
Oct 30, 2007, 3:17:24 PM (16 years ago)
Author:
dominic
Message:

added ebi-utils api update

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 release
     1,____ News on changes
    22
    3 This file will contain information about changes iin subsequent releases.
     3The ebi-utils api has been updated
  • trunk/uk/ac/ebi/AnnotationTypeCvImporter/build.xml

    r390 r446  
    3131    description="compile the common ebi -plugin util classes"
    3232    >
     33    <mkdir dir="${bin.plugins}"/>
    3334    <javac
    3435      encoding="ISO-8859-1"
  • trunk/uk/ac/ebi/AnnotationTypeCvImporter/src/uk/ac/ebi/nugo/common/Helper.java

    r422 r446  
    1111import net.sf.basedb.core.ArrayDesign;
    1212import net.sf.basedb.core.ArraySlide;
     13import net.sf.basedb.core.BaseException;
    1314import net.sf.basedb.core.BioSource;
    1415import net.sf.basedb.core.DbControl;
     16import net.sf.basedb.core.Directory;
    1517import net.sf.basedb.core.Extract;
    1618import net.sf.basedb.core.File;
     
    2325import net.sf.basedb.core.Path;
    2426import net.sf.basedb.core.Sample;
     27import net.sf.basedb.core.SessionControl;
    2528import net.sf.basedb.core.Type;
    2629import net.sf.basedb.core.User;
     
    3134/**
    3235  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
    3537  @version 1.0
    3638*/
     
    6870 
    6971   
     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   }
    70109  /**
    71110    Displays the content of the map. Helps to check that the content displayed is correct.
     
    109148    of a tab2mage file
    110149    @param atName , annotation type name
    111     @return annotationTypes,  <code>AnnotationType</code>
     150    @return annotationType,  <code>AnnotationType</code>
    112151   */
    113152  public static AnnotationType getAnnotationTypeByName(String atName, DbControl dc)
     
    211250    return  ar;
    212251  }
    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
    222253 
    223254  /**
     
    311342      return le;   
    312343  }
     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  }
    313372}
  • 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*/
    48package uk.ac.ebi.nugo.common;
    59
     
    1317  @author Dominic Oyeniran
    1418  @version 1.0
    15   @base.modified $Date
    1619 */
    1720public enum Tab2MageConstants
     
    193196    The parameter header
    194197   */
    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  ;
    196210 
    197211  /**
  • trunk/uk/ac/ebi/AnnotationTypeCvImporter/src/uk/ac/ebi/nugo/common/ValueFormatter.java

    r422 r446  
    1616/**
    1717  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 code
    1918  @author Dominic Oyeniran
    2019  @email oyeniran@ebi.ac.uk
  • trunk/uk/ac/ebi/AnnotationTypeCvImporter/src/uk/ac/ebi/nugo/common/ZipUnpacker.java

    r422 r446  
    1313import java.util.zip.ZipInputStream;
    1414
     15import net.sf.basedb.core.DatabaseException;
    1516import net.sf.basedb.core.DbControl;
    1617import net.sf.basedb.core.Directory;
     
    3132/**
    3233    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,
    3435    @author Dominic Oyeniran
    3536    @email oyeniran@ebi.ac.uk
    36     @see BatchDataImport.java and BatchLoader plugin developed by Misha Bayer.
    37    
    3837   
    3938 */
     
    7574      {
    7675        createSubDirectory( file, user);
    77         // now call the mathod to unpack the zip files
     76        // now call the method to unpack the zip files
    7877        PluginDefinition zipFilePlugin = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.ZipFileUnpacker");
    7978        FileUnpacker unpacker = zipFilePlugin.newInstance(net.sf.basedb.plugins.ZipFileUnpacker.class, null, dc.getSessionControl(), null, null);
     
    115114    //unlimited storage (e.g. for user root) will return -1
    116115    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 );
    118117    long currentDiskUsage = user.getDiskUsage(totalQuotaType, Location.PRIMARY);
    119118      //check whether remaining disk space and zip file size are compatible
    120119    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 );
    122121    if(remainingSpace < zipFileSize && quotaValue!=-1)
    123122    {
     
    172171      //get the parent directory
    173172      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());
    175174      Directory d = Directory.getById(dc, zipFileDir.getId());
    176175      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();
    184189        setUnzippedFilesDirectory(subDir);
    185190    }
    186191    catch (Throwable ex)
    187192    {
    188       log.error("--Create subdirectory FAILED");
     193      log.error("--Create subdirectory FAILED", ex);
    189194    }
    190195    finally
  • trunk/uk/ac/ebi/AnnotationTypeCvImporter/src/uk/ac/ebi/nugo/plugins/AnnotationTypeCvImporter.java

    r395 r446  
    3535import net.sf.basedb.util.parser.Mapper;
    3636import net.sf.basedb.util.Values;
     37import uk.ac.ebi.nugo.common.ValueFormatter;
    3738
    3839
     
    511512          if (category != null)
    512513          {
    513             List<String> annotationTypeCategory= Values.getList(columnMappings.get("categoryColumnMapping").getValue(data),";");
     514            List<String> annotationTypeCategory= ValueFormatter.getList(columnMappings.get("categoryColumnMapping").getValue(data),";");
    514515           
    515516            for (int i=0, z=annotationTypeCategory.size(); i<z;i++)
     
    540541          if (enumeration)
    541542            annotationType.setValues
    542               (Values.getList(columnMappings.get("cvValueColumnMapping").getValue(data),";"));
     543              (ValueFormatter.getList(columnMappings.get("cvValueColumnMapping").getValue(data),";"));
    543544         
    544545          itemType= columnMappings.get("itemTypeColumnMapping").getValue(data);
     
    546547          {
    547548            Item[] items=Item.values();
    548             List<String> itemTypes=Values.getList(columnMappings.get("itemTypeColumnMapping").getValue(data),separator); 
     549            List<String> itemTypes=ValueFormatter.getList(columnMappings.get("itemTypeColumnMapping").getValue(data),separator); 
    549550            for (String itemType: itemTypes)
    550551            {
Note: See TracChangeset for help on using the changeset viewer.