5623 |
06 May 11 |
nicklas |
1 |
/** |
5623 |
06 May 11 |
nicklas |
$Id$ |
5623 |
06 May 11 |
nicklas |
3 |
|
5623 |
06 May 11 |
nicklas |
Copyright (C) 2011 Nicklas Nordborg |
5623 |
06 May 11 |
nicklas |
5 |
|
5623 |
06 May 11 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
5623 |
06 May 11 |
nicklas |
Available at http://base.thep.lu.se/ |
5623 |
06 May 11 |
nicklas |
8 |
|
5623 |
06 May 11 |
nicklas |
BASE is free software; you can redistribute it and/or |
5623 |
06 May 11 |
nicklas |
modify it under the terms of the GNU General Public License |
5623 |
06 May 11 |
nicklas |
as published by the Free Software Foundation; either version 3 |
5623 |
06 May 11 |
nicklas |
of the License, or (at your option) any later version. |
5623 |
06 May 11 |
nicklas |
13 |
|
5623 |
06 May 11 |
nicklas |
BASE is distributed in the hope that it will be useful, |
5623 |
06 May 11 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5623 |
06 May 11 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5623 |
06 May 11 |
nicklas |
GNU General Public License for more details. |
5623 |
06 May 11 |
nicklas |
18 |
|
5623 |
06 May 11 |
nicklas |
You should have received a copy of the GNU General Public License |
5623 |
06 May 11 |
nicklas |
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 |
Action for validation of CDF files in a file set. The |
5623 |
06 May 11 |
nicklas |
CDF file must be connected with an {@link ArrayDesign}. |
5623 |
06 May 11 |
nicklas |
<p> |
5623 |
06 May 11 |
nicklas |
37 |
|
5623 |
06 May 11 |
nicklas |
This class is just a wrapper for {@link CdfValidator} so |
5623 |
06 May 11 |
nicklas |
that we can hook the validation into the extensions system. |
5623 |
06 May 11 |
nicklas |
40 |
|
5623 |
06 May 11 |
nicklas |
@author Nicklas |
5623 |
06 May 11 |
nicklas |
@since 3.0 |
5623 |
06 May 11 |
nicklas |
@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 |
Create a new action. |
5623 |
06 May 11 |
nicklas |
@param dc An open DbControl |
5623 |
06 May 11 |
nicklas |
@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 |
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 |
} |