src/core/net/sf/basedb/util/affymetrix/CdfValidationAction.java

Code
Comments
Other
Rev Date Author Line
5623 06 May 11 nicklas 1 /**
5623 06 May 11 nicklas 2   $Id$
5623 06 May 11 nicklas 3
5623 06 May 11 nicklas 4   Copyright (C) 2011 Nicklas Nordborg
5623 06 May 11 nicklas 5
5623 06 May 11 nicklas 6   This file is part of BASE - BioArray Software Environment.
5623 06 May 11 nicklas 7   Available at http://base.thep.lu.se/
5623 06 May 11 nicklas 8
5623 06 May 11 nicklas 9   BASE is free software; you can redistribute it and/or
5623 06 May 11 nicklas 10   modify it under the terms of the GNU General Public License
5623 06 May 11 nicklas 11   as published by the Free Software Foundation; either version 3
5623 06 May 11 nicklas 12   of the License, or (at your option) any later version.
5623 06 May 11 nicklas 13
5623 06 May 11 nicklas 14   BASE is distributed in the hope that it will be useful,
5623 06 May 11 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
5623 06 May 11 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5623 06 May 11 nicklas 17   GNU General Public License for more details.
5623 06 May 11 nicklas 18
5623 06 May 11 nicklas 19   You should have received a copy of the GNU General Public License
5623 06 May 11 nicklas 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
5623 06 May 11 nicklas 21 */
5623 06 May 11 nicklas 22 package net.sf.basedb.util.affymetrix;
5623 06 May 11 nicklas 23
5623 06 May 11 nicklas 24 import affymetrix.fusion.cdf.FusionCDFData;
5623 06 May 11 nicklas 25 import net.sf.basedb.core.ArrayDesign;
5623 06 May 11 nicklas 26 import net.sf.basedb.core.DataFileType;
5623 06 May 11 nicklas 27 import net.sf.basedb.core.DbControl;
5623 06 May 11 nicklas 28 import net.sf.basedb.core.FileSetMember;
5623 06 May 11 nicklas 29 import net.sf.basedb.core.InvalidDataException;
5623 06 May 11 nicklas 30 import net.sf.basedb.core.InvalidRelationException;
5623 06 May 11 nicklas 31 import net.sf.basedb.util.fileset.SingleFileValidationAction;
5623 06 May 11 nicklas 32
5623 06 May 11 nicklas 33 /**
5623 06 May 11 nicklas 34   Action for validation of CDF files in a file set. The
5623 06 May 11 nicklas 35   CDF file must be connected with an {@link ArrayDesign}.
5623 06 May 11 nicklas 36   <p>
5623 06 May 11 nicklas 37   
5623 06 May 11 nicklas 38   This class is just a wrapper for {@link CdfValidator} so
5623 06 May 11 nicklas 39   that we can hook the validation into the extensions system.
5623 06 May 11 nicklas 40   
5623 06 May 11 nicklas 41   @author Nicklas
5623 06 May 11 nicklas 42   @since 3.0
5623 06 May 11 nicklas 43   @base.modified $Date$
5623 06 May 11 nicklas 44 */
5623 06 May 11 nicklas 45 public class CdfValidationAction
5623 06 May 11 nicklas 46   extends SingleFileValidationAction
5623 06 May 11 nicklas 47 {
5623 06 May 11 nicklas 48
5623 06 May 11 nicklas 49   private final DbControl dc;
5623 06 May 11 nicklas 50   private final ArrayDesign design;
5623 06 May 11 nicklas 51   private final CdfValidator validator;
5623 06 May 11 nicklas 52   
5623 06 May 11 nicklas 53   /**
5623 06 May 11 nicklas 54     Create a new action. 
5623 06 May 11 nicklas 55     @param dc An open DbControl
5623 06 May 11 nicklas 56     @param design The array design the CDF file is connected with
5623 06 May 11 nicklas 57   */
5623 06 May 11 nicklas 58   public CdfValidationAction(DbControl dc, ArrayDesign design)
5623 06 May 11 nicklas 59   {
5623 06 May 11 nicklas 60     super(DataFileType.AFFYMETRIX_CDF);
5623 06 May 11 nicklas 61     this.dc = dc;
5623 06 May 11 nicklas 62     this.design = design;
5623 06 May 11 nicklas 63     this.validator = new CdfValidator();
5623 06 May 11 nicklas 64   }
5623 06 May 11 nicklas 65
5623 06 May 11 nicklas 66   /*
5623 06 May 11 nicklas 67     From the ValidationAction interface
5623 06 May 11 nicklas 68     -----------------------------------
5623 06 May 11 nicklas 69   */
5623 06 May 11 nicklas 70   @Override
5623 06 May 11 nicklas 71   public void validateAndExtractMetadata()
5623 06 May 11 nicklas 72     throws InvalidDataException, InvalidRelationException
5623 06 May 11 nicklas 73   {
5623 06 May 11 nicklas 74     FileSetMember cdfMember = getAcceptedFile();
5623 06 May 11 nicklas 75     FusionCDFData cdfData = validator.loadCdfFile(cdfMember.getFile());
5623 06 May 11 nicklas 76     validator.copyMetadata(cdfData, design);
5623 06 May 11 nicklas 77   }
5623 06 May 11 nicklas 78
5623 06 May 11 nicklas 79   @Override
5623 06 May 11 nicklas 80   public void resetMetadata()
5623 06 May 11 nicklas 81   {
5623 06 May 11 nicklas 82     validator.resetMetadata(design);
5623 06 May 11 nicklas 83   }
5623 06 May 11 nicklas 84   // -----------------------------------
5623 06 May 11 nicklas 85
5623 06 May 11 nicklas 86 }