4740 |
05 Feb 09 |
nicklas |
1 |
/** |
4740 |
05 Feb 09 |
nicklas |
$Id$ |
4740 |
05 Feb 09 |
nicklas |
3 |
|
4740 |
05 Feb 09 |
nicklas |
Copyright (C) 2008 Nicklas Nordborg |
4740 |
05 Feb 09 |
nicklas |
5 |
|
4740 |
05 Feb 09 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
4740 |
05 Feb 09 |
nicklas |
Available at http://base.thep.lu.se/ |
4740 |
05 Feb 09 |
nicklas |
8 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is free software; you can redistribute it and/or |
4740 |
05 Feb 09 |
nicklas |
modify it under the terms of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
as published by the Free Software Foundation; either version 3 |
4740 |
05 Feb 09 |
nicklas |
of the License, or (at your option) any later version. |
4740 |
05 Feb 09 |
nicklas |
13 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is distributed in the hope that it will be useful, |
4740 |
05 Feb 09 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4740 |
05 Feb 09 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4740 |
05 Feb 09 |
nicklas |
GNU General Public License for more details. |
4740 |
05 Feb 09 |
nicklas |
18 |
|
4740 |
05 Feb 09 |
nicklas |
You should have received a copy of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4740 |
05 Feb 09 |
nicklas |
21 |
*/ |
4740 |
05 Feb 09 |
nicklas |
22 |
package net.sf.basedb.util.overview.validator; |
4740 |
05 Feb 09 |
nicklas |
23 |
|
4740 |
05 Feb 09 |
nicklas |
24 |
import net.sf.basedb.core.BioSource; |
5651 |
08 Jun 11 |
nicklas |
25 |
import net.sf.basedb.core.DbControl; |
5651 |
08 Jun 11 |
nicklas |
26 |
import net.sf.basedb.core.Item; |
4740 |
05 Feb 09 |
nicklas |
27 |
import net.sf.basedb.util.overview.Fix; |
5651 |
08 Jun 11 |
nicklas |
28 |
import net.sf.basedb.util.overview.OverviewContext; |
4740 |
05 Feb 09 |
nicklas |
29 |
import net.sf.basedb.util.overview.Validator; |
4740 |
05 Feb 09 |
nicklas |
30 |
import net.sf.basedb.util.overview.Node; |
4740 |
05 Feb 09 |
nicklas |
31 |
|
4740 |
05 Feb 09 |
nicklas |
32 |
/** |
4740 |
05 Feb 09 |
nicklas |
Validator implementation for biosources. Validation rules: |
4740 |
05 Feb 09 |
nicklas |
<ul> |
4740 |
05 Feb 09 |
nicklas |
<li>Missing item: {@link Validator#MISSING_BIOSOURCE} |
4740 |
05 Feb 09 |
nicklas |
<li>Access denied: {@link Validator#DENIED_BIOSOURCE} |
4740 |
05 Feb 09 |
nicklas |
</ul> |
4740 |
05 Feb 09 |
nicklas |
38 |
|
4740 |
05 Feb 09 |
nicklas |
@author Nicklas |
4740 |
05 Feb 09 |
nicklas |
@version 2.10 |
4740 |
05 Feb 09 |
nicklas |
@base.modified $Date$ |
4740 |
05 Feb 09 |
nicklas |
42 |
*/ |
4740 |
05 Feb 09 |
nicklas |
43 |
public class BioSourceValidator |
4764 |
16 Feb 09 |
nicklas |
44 |
extends NameableNodeValidator<BioSource> |
4740 |
05 Feb 09 |
nicklas |
45 |
{ |
4740 |
05 Feb 09 |
nicklas |
46 |
|
4740 |
05 Feb 09 |
nicklas |
47 |
public BioSourceValidator() |
4740 |
05 Feb 09 |
nicklas |
48 |
{ |
4740 |
05 Feb 09 |
nicklas |
49 |
super(Validator.MISSING_BIOSOURCE, Validator.DENIED_BIOSOURCE); |
4740 |
05 Feb 09 |
nicklas |
50 |
} |
4740 |
05 Feb 09 |
nicklas |
51 |
|
4740 |
05 Feb 09 |
nicklas |
52 |
/* |
4740 |
05 Feb 09 |
nicklas |
From BasicValidator class |
4740 |
05 Feb 09 |
nicklas |
54 |
------------------------- |
4740 |
05 Feb 09 |
nicklas |
55 |
*/ |
5651 |
08 Jun 11 |
nicklas |
56 |
@Override |
5651 |
08 Jun 11 |
nicklas |
57 |
public void postValidate(DbControl dc, OverviewContext context, Node node, Node parentNode) |
5651 |
08 Jun 11 |
nicklas |
58 |
{ |
5651 |
08 Jun 11 |
nicklas |
59 |
super.postValidate(dc, context, node, parentNode); |
5651 |
08 Jun 11 |
nicklas |
60 |
|
5689 |
11 Aug 11 |
nicklas |
// If parent node contains a sample, check the subtypes |
5651 |
08 Jun 11 |
nicklas |
62 |
if (parentNode != null && parentNode.getItemType() == Item.SAMPLE) |
5651 |
08 Jun 11 |
nicklas |
63 |
{ |
5651 |
08 Jun 11 |
nicklas |
64 |
SampleValidator.checkParentBioSourceSubtype(dc, context, parentNode, node); |
5651 |
08 Jun 11 |
nicklas |
65 |
} |
5651 |
08 Jun 11 |
nicklas |
66 |
} |
5651 |
08 Jun 11 |
nicklas |
67 |
|
4740 |
05 Feb 09 |
nicklas |
68 |
/** |
4740 |
05 Feb 09 |
nicklas |
@return Suggested fix is to add a biosource to the parent sample. |
4740 |
05 Feb 09 |
nicklas |
70 |
*/ |
4740 |
05 Feb 09 |
nicklas |
71 |
@Override |
5651 |
08 Jun 11 |
nicklas |
72 |
protected Fix getMissingItemFix(DbControl dc, Node sampleNode) |
4740 |
05 Feb 09 |
nicklas |
73 |
{ |
4740 |
05 Feb 09 |
nicklas |
74 |
return new Fix("Add biosource to sample", sampleNode.getItem()); |
4740 |
05 Feb 09 |
nicklas |
75 |
} |
4740 |
05 Feb 09 |
nicklas |
76 |
// ---------------------------- |
5651 |
08 Jun 11 |
nicklas |
77 |
|
4740 |
05 Feb 09 |
nicklas |
78 |
} |