plugins/base2/net.sf.basedb.illumina/trunk/src/net/sf/basedb/illumina/filehandler/BgxValidationFactory.java

Code
Comments
Other
Rev Date Author Line
1385 02 Sep 11 martin 1 /**
1385 02 Sep 11 martin 2   $Id:
1385 02 Sep 11 martin 3
1385 02 Sep 11 martin 4   Copyright (C) 2011 Martin Svensson
1385 02 Sep 11 martin 5
1385 02 Sep 11 martin 6   This file is part of BASE - BioArray Software Environment.
1385 02 Sep 11 martin 7   Available at http://base.thep.lu.se/
1385 02 Sep 11 martin 8
1385 02 Sep 11 martin 9   BASE is free software; you can redistribute it and/or
1385 02 Sep 11 martin 10   modify it under the terms of the GNU General Public License
1385 02 Sep 11 martin 11   as published by the Free Software Foundation; either version 3
1385 02 Sep 11 martin 12   of the License, or (at your option) any later version.
1385 02 Sep 11 martin 13
1385 02 Sep 11 martin 14   BASE is distributed in the hope that it will be useful,
1385 02 Sep 11 martin 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
1385 02 Sep 11 martin 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1385 02 Sep 11 martin 17   GNU General Public License for more details.
1385 02 Sep 11 martin 18
1385 02 Sep 11 martin 19   You should have received a copy of the GNU General Public License
1385 02 Sep 11 martin 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
1385 02 Sep 11 martin 21 */
1385 02 Sep 11 martin 22 package net.sf.basedb.illumina.filehandler;
1385 02 Sep 11 martin 23
1385 02 Sep 11 martin 24 import net.sf.basedb.core.ArrayDesign;
1385 02 Sep 11 martin 25 import net.sf.basedb.core.DataFileType;
1385 02 Sep 11 martin 26 import net.sf.basedb.core.DbControl;
1385 02 Sep 11 martin 27 import net.sf.basedb.illumina.Illumina;
1385 02 Sep 11 martin 28 import net.sf.basedb.util.extensions.ActionFactory;
1385 02 Sep 11 martin 29 import net.sf.basedb.util.extensions.InvokationContext;
1385 02 Sep 11 martin 30
1385 02 Sep 11 martin 31 /**
1385 02 Sep 11 martin 32  
1385 02 Sep 11 martin 33    @author Martin
1385 02 Sep 11 martin 34    @since 1.7
1385 02 Sep 11 martin 35   @base.modified $Date: 2011-05-06 14:09:13 +0200 (Fri, 06 May 2011) $ 
1385 02 Sep 11 martin 36 */
1385 02 Sep 11 martin 37 public class BgxValidationFactory
1385 02 Sep 11 martin 38   implements ActionFactory<BgxValidationAction>
1385 02 Sep 11 martin 39 {
1385 02 Sep 11 martin 40   public BgxValidationFactory()
1385 02 Sep 11 martin 41   {}
1385 02 Sep 11 martin 42   
1385 02 Sep 11 martin 43   /*
1385 02 Sep 11 martin 44     From the ActionFactory interface
1385 02 Sep 11 martin 45     --------------------------------
1385 02 Sep 11 martin 46   */
1385 02 Sep 11 martin 47   @Override
1385 02 Sep 11 martin 48   public BgxValidationAction[] getActions(
1385 02 Sep 11 martin 49       InvokationContext<? super BgxValidationAction> context) 
1385 02 Sep 11 martin 50   {  
1385 02 Sep 11 martin 51     BgxValidationAction[] actions = null;
1385 02 Sep 11 martin 52     Object item = context.getClientContext().getCurrentItem();
1385 02 Sep 11 martin 53     ArrayDesign ownerItem = null;
1385 02 Sep 11 martin 54     if (item instanceof ArrayDesign)
1385 02 Sep 11 martin 55     {
1385 02 Sep 11 martin 56       ownerItem = (ArrayDesign)item;
1385 02 Sep 11 martin 57     }
1385 02 Sep 11 martin 58     if (ownerItem != null)
1385 02 Sep 11 martin 59     {
1385 02 Sep 11 martin 60       DbControl dc = context.getClientContext().getDbControl();
1385 02 Sep 11 martin 61       actions = new BgxValidationAction[] { new BgxValidationAction(dc, ownerItem) };
1385 02 Sep 11 martin 62     }
1385 02 Sep 11 martin 63     
1385 02 Sep 11 martin 64     return actions;
1385 02 Sep 11 martin 65   }
1385 02 Sep 11 martin 66
1385 02 Sep 11 martin 67   @Override
1385 02 Sep 11 martin 68   public boolean prepareContext(  InvokationContext<? super BgxValidationAction> context) 
1385 02 Sep 11 martin 69   {  
1385 02 Sep 11 martin 70     Object item = context.getClientContext().getCurrentItem();
1385 02 Sep 11 martin 71     boolean isInContext = false; 
1385 02 Sep 11 martin 72     if (item instanceof ArrayDesign)
1385 02 Sep 11 martin 73     {
1385 02 Sep 11 martin 74       ArrayDesign design = (ArrayDesign)item;
1385 02 Sep 11 martin 75       isInContext = Illumina.isIllumina(design);
1385 02 Sep 11 martin 76     }
1385 02 Sep 11 martin 77     else if (item instanceof DataFileType)
1385 02 Sep 11 martin 78     {
1385 02 Sep 11 martin 79       DataFileType fileType = (DataFileType)item;
1385 02 Sep 11 martin 80       isInContext = Illumina.BGX_FILE_ID.equals(fileType.getExternalId());
1385 02 Sep 11 martin 81     }
1385 02 Sep 11 martin 82     return isInContext;
1385 02 Sep 11 martin 83   }
1385 02 Sep 11 martin 84
1385 02 Sep 11 martin 85 }