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 net.sf.basedb.core.DataFileType; |
5623 |
06 May 11 |
nicklas |
25 |
import net.sf.basedb.core.DbControl; |
5623 |
06 May 11 |
nicklas |
26 |
import net.sf.basedb.core.RawBioAssay; |
5623 |
06 May 11 |
nicklas |
27 |
import net.sf.basedb.util.extensions.ActionFactory; |
5623 |
06 May 11 |
nicklas |
28 |
import net.sf.basedb.util.extensions.InvokationContext; |
5623 |
06 May 11 |
nicklas |
29 |
|
5623 |
06 May 11 |
nicklas |
30 |
/** |
5623 |
06 May 11 |
nicklas |
Action factory for creating CEL file validators. |
5623 |
06 May 11 |
nicklas |
32 |
|
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 |
36 |
*/ |
5623 |
06 May 11 |
nicklas |
37 |
public class CelValidationFactory |
5623 |
06 May 11 |
nicklas |
38 |
implements ActionFactory<CelValidationAction> |
5623 |
06 May 11 |
nicklas |
39 |
{ |
5623 |
06 May 11 |
nicklas |
40 |
|
5623 |
06 May 11 |
nicklas |
41 |
public CelValidationFactory() |
5623 |
06 May 11 |
nicklas |
42 |
{} |
5623 |
06 May 11 |
nicklas |
43 |
|
5623 |
06 May 11 |
nicklas |
44 |
/* |
5623 |
06 May 11 |
nicklas |
From the ActionFactory interface |
5623 |
06 May 11 |
nicklas |
46 |
-------------------------------- |
5623 |
06 May 11 |
nicklas |
47 |
*/ |
5623 |
06 May 11 |
nicklas |
48 |
@Override |
5623 |
06 May 11 |
nicklas |
49 |
public boolean prepareContext(InvokationContext<? super CelValidationAction> context) |
5623 |
06 May 11 |
nicklas |
50 |
{ |
5623 |
06 May 11 |
nicklas |
51 |
Object item = context.getClientContext().getCurrentItem(); |
5623 |
06 May 11 |
nicklas |
52 |
boolean isInContext = false; |
5623 |
06 May 11 |
nicklas |
53 |
if (item instanceof RawBioAssay) |
5623 |
06 May 11 |
nicklas |
54 |
{ |
5623 |
06 May 11 |
nicklas |
// Validation context |
5623 |
06 May 11 |
nicklas |
56 |
RawBioAssay rba = (RawBioAssay)item; |
5623 |
06 May 11 |
nicklas |
57 |
isInContext = AffymetrixUtil.isAffymetrix(rba); |
5623 |
06 May 11 |
nicklas |
58 |
} |
5623 |
06 May 11 |
nicklas |
59 |
else if (item instanceof DataFileType) |
5623 |
06 May 11 |
nicklas |
60 |
{ |
5623 |
06 May 11 |
nicklas |
// Do we support validating the given file type? |
5623 |
06 May 11 |
nicklas |
62 |
DataFileType fileType = (DataFileType)item; |
5623 |
06 May 11 |
nicklas |
63 |
isInContext = DataFileType.AFFYMETRIX_CEL.equals(fileType.getExternalId()); |
5623 |
06 May 11 |
nicklas |
64 |
} |
5623 |
06 May 11 |
nicklas |
65 |
return isInContext; |
5623 |
06 May 11 |
nicklas |
66 |
} |
5623 |
06 May 11 |
nicklas |
67 |
|
5623 |
06 May 11 |
nicklas |
68 |
|
5623 |
06 May 11 |
nicklas |
69 |
@Override |
5623 |
06 May 11 |
nicklas |
70 |
public CelValidationAction[] getActions(InvokationContext<? super CelValidationAction> context) |
5623 |
06 May 11 |
nicklas |
71 |
{ |
5623 |
06 May 11 |
nicklas |
72 |
Object item = context.getClientContext().getCurrentItem(); |
5623 |
06 May 11 |
nicklas |
73 |
RawBioAssay ownerItem = null; |
5623 |
06 May 11 |
nicklas |
74 |
if (item instanceof RawBioAssay) |
5623 |
06 May 11 |
nicklas |
75 |
{ |
5623 |
06 May 11 |
nicklas |
76 |
ownerItem = (RawBioAssay)item; |
5623 |
06 May 11 |
nicklas |
77 |
} |
5623 |
06 May 11 |
nicklas |
78 |
|
5623 |
06 May 11 |
nicklas |
79 |
CelValidationAction[] actions = null; |
5623 |
06 May 11 |
nicklas |
80 |
if (ownerItem != null) |
5623 |
06 May 11 |
nicklas |
81 |
{ |
5623 |
06 May 11 |
nicklas |
82 |
DbControl dc = context.getClientContext().getDbControl(); |
5623 |
06 May 11 |
nicklas |
83 |
actions = new CelValidationAction[] { new CelValidationAction(dc, ownerItem) }; |
5623 |
06 May 11 |
nicklas |
84 |
} |
5623 |
06 May 11 |
nicklas |
85 |
return actions; |
5623 |
06 May 11 |
nicklas |
86 |
} |
5623 |
06 May 11 |
nicklas |
87 |
// ----------------------------------- |
5623 |
06 May 11 |
nicklas |
88 |
|
5623 |
06 May 11 |
nicklas |
89 |
} |