Ignore:
Timestamp:
Aug 8, 2007, 12:40:31 PM (16 years ago)
Author:
dominic
Message:
 
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  
    4141import net.sf.basedb.core.plugin.Response;
    4242import uk.ac.ebi.nugo.plugins.lims.AffymetrixFileFormatTypes;
    43 import uk.ac.ebi.nugo.plugins.util.Tab2MageHelper;
     43import uk.ac.ebi.nugo.plugins.util.Helper;
    4444import uk.ac.ebi.nugo.plugins.util.ZipUnpacker;
    4545
     
    5656 
    5757  private RequestInformation configureJob;
    58   //private DbControl dc;
     58 
    5959  private PluginParameter<File> fileParameter;
    6060   
     
    6464      "Affymetrix Array Design Batch Importer",
    6565      "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 deisgnare supplied in a zip archive",
     66      "running the Tab2Mage importer developed at the EBI. The array deisgns must be supplied in a zip archive",
    6767      "1.0",
    6868      "@Copyright 2007, The EBI NutriBase development team",
     
    161161    {
    162162      response.setError(ex.getMessage(), Arrays.asList(ex));
    163       ex.printStackTrace();
    164163    }   
    165164  }
     
    197196      for (Role role : roles )
    198197      {
    199         //System.out.println("The user role is :"+ role);
    200198        if (role.getName().equalsIgnoreCase("administrator")) validRole = true;
    201199      }
     
    218216        Unpack Zip files
    219217       */
    220       ZipUnpacker affyArrayDesignUnpacker = new ZipUnpacker(file, user, dc);
     218      ZipUnpacker affyArrayDesignUnpacker = new ZipUnpacker(file, user, sc);
    221219      affyArrayDesignUnpacker.unpack();
    222220      /*
     
    233231      {
    234232        // get the file extension and filename
    235         String ext= Tab2MageHelper.getFileExtension(affyFile);
     233        String ext= Helper.getFileExtension(affyFile);
    236234       
    237235        //  check for validity against an enum file
     
    252250            }
    253251           
    254               // otherwise
    255         //  check if an array design with the same name exist.
     252              //  check if an array design with the same name exist.
    256253        String fileName = affyFile.getName();
    257254        String fileNameWithoutExtension = fileName.substring(0, fileName.indexOf("."));
    258               ArrayDesign ad= Tab2MageHelper.getArrayDesign(fileNameWithoutExtension, dc);
     255              ArrayDesign ad= Helper.getArrayDesign(fileNameWithoutExtension, dc);
    259256              //if no array design was found create a new one otherwise
    260257              //skip array design creation
     
    262259              {
    263260                // 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();
    266262          ArrayDesign arrayDesign= ArrayDesign.getNew(dc, true);
    267263          arrayDesign.setName(fileNameWithoutExtension);
     
    282278      {
    283279        response.setError(ex.getMessage(), Arrays.asList(ex));
    284         ex.printStackTrace();
     280       
    285281      }
    286282      finally
     
    306302      catch (Exception e)
    307303      {
    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      }
    313306      finally
    314307      {
  • trunk/uk/ac/ebi/AffyArrayDesignBatchImporter/src/uk/ac/ebi/nugo/plugins/lims/AffymetrixFileFormatTypes.java

    r358 r376  
    77
    88
    9 import java.util.EnumSet;
    10 import java.util.Set;
    119
    1210public enum AffymetrixFileFormatTypes
  • trunk/uk/ac/ebi/AffyArrayDesignBatchImporter/src/uk/ac/ebi/nugo/plugins/util/ZipUnpacker.java

    r358 r376  
    99import java.io.IOException;
    1010import java.io.InputStream;
    11 import java.text.SimpleDateFormat;
    12 import java.util.Date;
    13 import java.util.Locale;
    1411import java.util.zip.ZipEntry;
    1512import java.util.zip.ZipInputStream;
    16 
    17 import org.apache.log4j.Logger;
    18 
    19 import uk.ac.ebi.nugo.plugins.tab2mageimport.validation.Tab2MageValidationFactory;
    2013
    2114import net.sf.basedb.core.DbControl;
     
    2316import net.sf.basedb.core.File;
    2417import 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;
     18import net.sf.basedb.core.PluginDefinition;
    2819import net.sf.basedb.core.Quota;
    2920import net.sf.basedb.core.QuotaType;
     21import net.sf.basedb.core.SessionControl;
    3022import net.sf.basedb.core.SystemItems;
    3123import net.sf.basedb.core.User;
    32 import net.sf.basedb.core.PluginDefinition;
    3324import net.sf.basedb.util.zip.FileUnpacker;
     25
     26import org.apache.log4j.Logger;
    3427
    3528
     
    4639public class ZipUnpacker
    4740{
    48   protected static Logger log = Logger.getLogger(Tab2MageValidationFactory.class);
     41  protected static Logger log = Logger.getLogger(ZipUnpacker.class);
    4942  private User user;
    5043  private File file;
     
    5548  private SessionControl sc;
    5649 
    57   public ZipUnpacker(File zipFile, User user, DbControl dc)
     50  public ZipUnpacker(File zipFile, User user, SessionControl sc)
    5851  {
    5952    this.user = user;
    60     this.dc=dc;
     53    this.dc=sc.newDbControl();
    6154    this.file= zipFile;
    62     this.sc= dc.getSessionControl();
     55    //this.sc= dc.getSessionControl();
    6356  }
    6457  /**
    6558    Unpacks a zip file, checking that there is enough space to accommodate
    6659    the zip file once it is unpacked.
    67    * @throws NutribasePluginException
     60      @throws NutribasePluginException
    6861   */
    6962  public void unpack() throws NutribasePluginException
    7063  {
    71     System.out.println("Begin to unpack the files");
     64    log.info("Begin to unpack the files");
    7265    try
    7366    {
     
    9487    catch (Throwable exc)
    9588    {
     89      dc.close();
     90      log.info("File cannot be unpacked", exc);
    9691      new NutribasePluginException(exc.getMessage());
    9792    }
    9893    finally
    9994    {
    100      
     95      if (dc!=null)
     96        dc.close();
    10197    }
    10298  }
     
    160156      catch (IOException ioe)
    161157      {
    162         ioe.printStackTrace();
     158        //ioe.printStackTrace();
     159        log.error(ioe.getMessage());
    163160      }
    164161      return totalSize;
    165162    }
    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   */
    167169  public void createSubDirectory(File zipFile, User user , DbControl dc)
    168170  {
     
    170172     
    171173        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());
    173175        Directory subDir = Directory.getNew(dc, zipFileDir);
    174176        String fileName = zipFile.getName();
    175177        String fileNameNoExt = fileName.substring(0, fileName.indexOf("."));
    176         //System.out.println("new subDir = " + fileNameNoExt );
    177178        subDir.setName(fileNameNoExt);
    178  
    179         // save the new subDir
    180179        dc.saveItem(subDir);
    181180        unzippedFilesDirectory = subDir;
Note: See TracChangeset for help on using the changeset viewer.