src/core/net/sf/basedb/util/overview/validator/ExperimentValidator.java

Code
Comments
Other
Rev Date Author Line
4740 05 Feb 09 nicklas 1 /**
4740 05 Feb 09 nicklas 2   $Id$
4740 05 Feb 09 nicklas 3
4740 05 Feb 09 nicklas 4   Copyright (C) 2008 Nicklas Nordborg
4740 05 Feb 09 nicklas 5
4740 05 Feb 09 nicklas 6   This file is part of BASE - BioArray Software Environment.
4740 05 Feb 09 nicklas 7   Available at http://base.thep.lu.se/
4740 05 Feb 09 nicklas 8
4740 05 Feb 09 nicklas 9   BASE is free software; you can redistribute it and/or
4740 05 Feb 09 nicklas 10   modify it under the terms of the GNU General Public License
4740 05 Feb 09 nicklas 11   as published by the Free Software Foundation; either version 3
4740 05 Feb 09 nicklas 12   of the License, or (at your option) any later version.
4740 05 Feb 09 nicklas 13
4740 05 Feb 09 nicklas 14   BASE is distributed in the hope that it will be useful,
4740 05 Feb 09 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
4740 05 Feb 09 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4740 05 Feb 09 nicklas 17   GNU General Public License for more details.
4740 05 Feb 09 nicklas 18
4740 05 Feb 09 nicklas 19   You should have received a copy of the GNU General Public License
4740 05 Feb 09 nicklas 20   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.DbControl;
4740 05 Feb 09 nicklas 25 import net.sf.basedb.core.Experiment;
4740 05 Feb 09 nicklas 26 import net.sf.basedb.core.Project;
4740 05 Feb 09 nicklas 27 import net.sf.basedb.core.RawDataType;
4740 05 Feb 09 nicklas 28 import net.sf.basedb.util.overview.Fix;
4740 05 Feb 09 nicklas 29 import net.sf.basedb.util.overview.OverviewContext;
4740 05 Feb 09 nicklas 30 import net.sf.basedb.util.overview.Validator;
4740 05 Feb 09 nicklas 31 import net.sf.basedb.util.overview.Node;
4740 05 Feb 09 nicklas 32
4740 05 Feb 09 nicklas 33 /**
4740 05 Feb 09 nicklas 34   Validator implementation for experiments. Validation rules:
4740 05 Feb 09 nicklas 35   <ul>
4740 05 Feb 09 nicklas 36   <li>Non-default raw data type: {@link Validator#NONDEFAULT_RAWDATATYPE}
4740 05 Feb 09 nicklas 37   </ul>
4740 05 Feb 09 nicklas 38
4740 05 Feb 09 nicklas 39   @author Nicklas
4740 05 Feb 09 nicklas 40   @version 2.10
4740 05 Feb 09 nicklas 41   @base.modified $Date$
4740 05 Feb 09 nicklas 42 */
4740 05 Feb 09 nicklas 43 public class ExperimentValidator
4764 16 Feb 09 nicklas 44   extends NameableNodeValidator<Experiment>
4740 05 Feb 09 nicklas 45 {
4740 05 Feb 09 nicklas 46   
4740 05 Feb 09 nicklas 47   public ExperimentValidator()
4740 05 Feb 09 nicklas 48   {
4740 05 Feb 09 nicklas 49     super(null, null);
4740 05 Feb 09 nicklas 50   }
4740 05 Feb 09 nicklas 51   
4740 05 Feb 09 nicklas 52   /* 
4740 05 Feb 09 nicklas 53     From BasicValidator class
4740 05 Feb 09 nicklas 54     -------------------------
4740 05 Feb 09 nicklas 55   */
4740 05 Feb 09 nicklas 56   @Override
4740 05 Feb 09 nicklas 57   public void postValidate(DbControl dc, OverviewContext context, Node node, Node parentNode)
4740 05 Feb 09 nicklas 58   {
4740 05 Feb 09 nicklas 59     super.postValidate(dc, context, node, parentNode);
4740 05 Feb 09 nicklas 60     Project project = context.getProject();
4740 05 Feb 09 nicklas 61     Experiment experiment = (Experiment)node.getItem();
4740 05 Feb 09 nicklas 62     if (project != null)
4740 05 Feb 09 nicklas 63     {
4816 16 Mar 09 martin 64       project = Project.getById(dc, project.getId());
4740 05 Feb 09 nicklas 65       RawDataType projectDefault = project.getDefaultRawDataType();
4740 05 Feb 09 nicklas 66       if (projectDefault != null && experiment.getRawDataType() != projectDefault)
4740 05 Feb 09 nicklas 67       {
4740 05 Feb 09 nicklas 68         context.createFailure(Validator.NONDEFAULT_RAWDATATYPE, node, null,
4740 05 Feb 09 nicklas 69             new Fix("Change default raw data type of project", project)
4740 05 Feb 09 nicklas 70           );
4740 05 Feb 09 nicklas 71       }
4740 05 Feb 09 nicklas 72     }
4740 05 Feb 09 nicklas 73   }
4740 05 Feb 09 nicklas 74
4740 05 Feb 09 nicklas 75   /**
4740 05 Feb 09 nicklas 76     @return Always null
4740 05 Feb 09 nicklas 77   */
4740 05 Feb 09 nicklas 78   @Override
5651 08 Jun 11 nicklas 79   protected Fix getMissingItemFix(DbControl dc, Node parentNode)
4740 05 Feb 09 nicklas 80   {
4740 05 Feb 09 nicklas 81     return null;
4740 05 Feb 09 nicklas 82   }
4740 05 Feb 09 nicklas 83   // ----------------------------
4740 05 Feb 09 nicklas 84 }