src/core/net/sf/basedb/util/overview/OverviewContext.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;
4740 05 Feb 09 nicklas 23
4740 05 Feb 09 nicklas 24 import net.sf.basedb.core.BasicItem;
4768 18 Feb 09 nicklas 25 import net.sf.basedb.core.Include;
4740 05 Feb 09 nicklas 26 import net.sf.basedb.core.ItemQuery;
4740 05 Feb 09 nicklas 27 import net.sf.basedb.core.Project;
4740 05 Feb 09 nicklas 28 import net.sf.basedb.core.query.Order;
5132 14 Oct 09 nicklas 29 import net.sf.basedb.core.snapshot.SnapshotManager;
4740 05 Feb 09 nicklas 30 import net.sf.basedb.util.overview.cache.NodeCache;
4768 18 Feb 09 nicklas 31 import net.sf.basedb.util.overview.loader.NodeLoader;
4740 05 Feb 09 nicklas 32 import net.sf.basedb.util.overview.loader.NodeLoaderFactory;
4768 18 Feb 09 nicklas 33 import net.sf.basedb.util.overview.validator.NodeValidator;
4740 05 Feb 09 nicklas 34 import net.sf.basedb.util.overview.validator.NodeValidatorFactory;
4740 05 Feb 09 nicklas 35
4740 05 Feb 09 nicklas 36 /**
4768 18 Feb 09 nicklas 37   Interface that should be implemented by overview generating
4768 18 Feb 09 nicklas 38   classes. This interface defines service methods that overview
4768 18 Feb 09 nicklas 39   generating class to {@link NodeLoader}:s and {@link NodeValidator}:s
4768 18 Feb 09 nicklas 40   so that they can do their job.
4768 18 Feb 09 nicklas 41   
4740 05 Feb 09 nicklas 42   @author Nicklas
4740 05 Feb 09 nicklas 43   @version 2.10
4740 05 Feb 09 nicklas 44   @base.modified $Date$
4740 05 Feb 09 nicklas 45 */
4740 05 Feb 09 nicklas 46 public interface OverviewContext
4740 05 Feb 09 nicklas 47 {
4740 05 Feb 09 nicklas 48
4768 18 Feb 09 nicklas 49   /**
4768 18 Feb 09 nicklas 50     Get the node loader factory that is used to create node loaders.
4768 18 Feb 09 nicklas 51     @return A node loader factory
4768 18 Feb 09 nicklas 52   */
6875 20 Apr 15 nicklas 53   @SuppressWarnings("rawtypes")
4740 05 Feb 09 nicklas 54   public NodeLoaderFactory getNodeLoaderFactory();
4740 05 Feb 09 nicklas 55   
4768 18 Feb 09 nicklas 56   /**
4768 18 Feb 09 nicklas 57     Get the node validator factory that is used to create node validators.
4768 18 Feb 09 nicklas 58     @return A node loader factory
4768 18 Feb 09 nicklas 59   */
6875 20 Apr 15 nicklas 60   @SuppressWarnings("rawtypes")
4740 05 Feb 09 nicklas 61   public NodeValidatorFactory getNodeValidatorFactory();
4768 18 Feb 09 nicklas 62
4768 18 Feb 09 nicklas 63   /**
5132 14 Oct 09 nicklas 64     Get the snapshot manager that is used to load annotation
5185 05 Nov 09 nicklas 65     values. This method may re-use an existing snapshot manager
5185 05 Nov 09 nicklas 66     as long as a transaction is active. Once the transaction has
5185 05 Nov 09 nicklas 67     been committed (or rollbacked) the snapshot manager should
5185 05 Nov 09 nicklas 68     no longer be used since it may hold inconsistent data. Note
5185 05 Nov 09 nicklas 69     that it is always safe to create a new snapshot manager.
5132 14 Oct 09 nicklas 70     @since 2.14
5132 14 Oct 09 nicklas 71   */
5132 14 Oct 09 nicklas 72   public SnapshotManager getSnapshotManager();
5132 14 Oct 09 nicklas 73   
5132 14 Oct 09 nicklas 74   /**
4768 18 Feb 09 nicklas 75     Get the project the overview is using as the "current" project.
4768 18 Feb 09 nicklas 76     This is mostly needed by validators to check if items are using
4768 18 Feb 09 nicklas 77     the project default protocols, software, etc.
4768 18 Feb 09 nicklas 78     @return A project, or null
4768 18 Feb 09 nicklas 79   */
4768 18 Feb 09 nicklas 80   public Project getProject();
4768 18 Feb 09 nicklas 81
4768 18 Feb 09 nicklas 82   /**
5076 25 Aug 09 nicklas 83     Get the validation options that are currently in effect.
5076 25 Aug 09 nicklas 84     @since 2.13
5076 25 Aug 09 nicklas 85   */
5076 25 Aug 09 nicklas 86   public ValidationOptions getValidationOptions();
5076 25 Aug 09 nicklas 87   
5076 25 Aug 09 nicklas 88   /**
4768 18 Feb 09 nicklas 89     Store an auxilliary object in the overview cache. This is a service
4768 18 Feb 09 nicklas 90     provided by the overview implementation that can be used by node
4768 18 Feb 09 nicklas 91     loaders and/or validators to store information that may be needed
4768 18 Feb 09 nicklas 92     again in the future and is  expensive to retreive (eg. from the database). 
4768 18 Feb 09 nicklas 93     This is for example used to store annotation types that have been marked 
4768 18 Feb 09 nicklas 94     as "Required by MIAME", parents to annotatable items and more.
4768 18 Feb 09 nicklas 95     <p>
4768 18 Feb 09 nicklas 96     Note! The overview impementation is not forced to implement a
4768 18 Feb 09 nicklas 97     cache, or it may optionally decide to disable the cache. Node 
4768 18 Feb 09 nicklas 98     loaders and validators should not depend on the cache for 
4768 18 Feb 09 nicklas 99     correct functionality.
4768 18 Feb 09 nicklas 100     
4768 18 Feb 09 nicklas 101     @param cacheKey The key to store the value under
4768 18 Feb 09 nicklas 102     @param value The value to store in the cache, or null to
4768 18 Feb 09 nicklas 103       remove the entry
4768 18 Feb 09 nicklas 104     @see #getCachedObject(Object)
4768 18 Feb 09 nicklas 105   */
4743 09 Feb 09 nicklas 106   public void setCachedObject(Object cacheKey, Object value);
4768 18 Feb 09 nicklas 107
4740 05 Feb 09 nicklas 108   /**
4768 18 Feb 09 nicklas 109     Retreive an object stored in the overview cache.
4768 18 Feb 09 nicklas 110     @param cacheKey The key to use for cache lookup
4768 18 Feb 09 nicklas 111     @return The object, or null if no object has been cached with the
4768 18 Feb 09 nicklas 112       given key
4768 18 Feb 09 nicklas 113     @see #setCachedObject(Object, Object)
4740 05 Feb 09 nicklas 114   */
4768 18 Feb 09 nicklas 115   public Object getCachedObject(Object cacheKey);
4768 18 Feb 09 nicklas 116
4768 18 Feb 09 nicklas 117
4768 18 Feb 09 nicklas 118   /**
4768 18 Feb 09 nicklas 119     Register the failure of a validation rule.
4768 18 Feb 09 nicklas 120     <p>
4768 18 Feb 09 nicklas 121     Note! The overview implementation is not forced to register the
4768 18 Feb 09 nicklas 122     failure, or it may optioanlly only register certain types of
4768 18 Feb 09 nicklas 123     failures.
4768 18 Feb 09 nicklas 124     
4768 18 Feb 09 nicklas 125     @param validator The validation rule that fails
4768 18 Feb 09 nicklas 126     @param node The node that was validated
4768 18 Feb 09 nicklas 127     @param message An optional message, if null the message from
4768 18 Feb 09 nicklas 128       {@link Validator#getFailureSummary()} is used
4768 18 Feb 09 nicklas 129     @param fixes Optional fixes that may be used to correct the problem
4768 18 Feb 09 nicklas 130   */
4740 05 Feb 09 nicklas 131   public Failure createFailure(Validator validator, Node node, String message, Fix... fixes);
4740 05 Feb 09 nicklas 132
4768 18 Feb 09 nicklas 133   /**
4768 18 Feb 09 nicklas 134     Same as {@link #initQuery(ItemQuery, Order...)} but easier to use when
4768 18 Feb 09 nicklas 135     sorting the items in ascending order by a single column.
4768 18 Feb 09 nicklas 136     @param query The query that should be initialised
4768 18 Feb 09 nicklas 137     @param sortby The property name to sort by (may be null)
4768 18 Feb 09 nicklas 138     @return The same query object
4768 18 Feb 09 nicklas 139   */
4768 18 Feb 09 nicklas 140   public <I extends BasicItem> ItemQuery<I> initQuery(ItemQuery<I> query, String sortby);
4768 18 Feb 09 nicklas 141
4768 18 Feb 09 nicklas 142   /**
4768 18 Feb 09 nicklas 143     Initialise a query with "global options" and optionally a sort
4768 18 Feb 09 nicklas 144     order. 
4768 18 Feb 09 nicklas 145     <p>
4768 18 Feb 09 nicklas 146     Note! The "global options" can differ between overview implementation,
4768 18 Feb 09 nicklas 147     but typically include settings some restrictions base on {@link Include}
4768 18 Feb 09 nicklas 148     options, or permissions on the query.
4768 18 Feb 09 nicklas 149     
4768 18 Feb 09 nicklas 150     @param query The query that should be initialised
4768 18 Feb 09 nicklas 151     @param sortby An array with Order objects (may be null)
4768 18 Feb 09 nicklas 152     @return The same query object
4768 18 Feb 09 nicklas 153     @see #initQuery(ItemQuery, Order...)
4768 18 Feb 09 nicklas 154   */
4768 18 Feb 09 nicklas 155   public <I extends BasicItem> ItemQuery<I> initQuery(ItemQuery<I> query, Order... sortby);
4768 18 Feb 09 nicklas 156   
4768 18 Feb 09 nicklas 157   /**
4768 18 Feb 09 nicklas 158     Get the current node cache. Node loaders may use the cache to store
4768 18 Feb 09 nicklas 159     nodes for already seen items. Then, when the same item is seen again
4768 18 Feb 09 nicklas 160     the existing node (including all children) is simply cloned. This can
4768 18 Feb 09 nicklas 161     make the performance a lot better.
4768 18 Feb 09 nicklas 162     
4768 18 Feb 09 nicklas 163     @return A node cache, or null if the current overview doesn't want
4768 18 Feb 09 nicklas 164       to use a cache
4768 18 Feb 09 nicklas 165   */
4768 18 Feb 09 nicklas 166   public NodeCache<Object> getNodeCache();
4768 18 Feb 09 nicklas 167   
4740 05 Feb 09 nicklas 168 }