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; |
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 |
Interface that should be implemented by overview generating |
4768 |
18 Feb 09 |
nicklas |
classes. This interface defines service methods that overview |
4768 |
18 Feb 09 |
nicklas |
generating class to {@link NodeLoader}:s and {@link NodeValidator}:s |
4768 |
18 Feb 09 |
nicklas |
so that they can do their job. |
4768 |
18 Feb 09 |
nicklas |
41 |
|
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 |
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 |
Get the node loader factory that is used to create node loaders. |
4768 |
18 Feb 09 |
nicklas |
@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 |
Get the node validator factory that is used to create node validators. |
4768 |
18 Feb 09 |
nicklas |
@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 |
Get the snapshot manager that is used to load annotation |
5185 |
05 Nov 09 |
nicklas |
values. This method may re-use an existing snapshot manager |
5185 |
05 Nov 09 |
nicklas |
as long as a transaction is active. Once the transaction has |
5185 |
05 Nov 09 |
nicklas |
been committed (or rollbacked) the snapshot manager should |
5185 |
05 Nov 09 |
nicklas |
no longer be used since it may hold inconsistent data. Note |
5185 |
05 Nov 09 |
nicklas |
that it is always safe to create a new snapshot manager. |
5132 |
14 Oct 09 |
nicklas |
@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 |
Get the project the overview is using as the "current" project. |
4768 |
18 Feb 09 |
nicklas |
This is mostly needed by validators to check if items are using |
4768 |
18 Feb 09 |
nicklas |
the project default protocols, software, etc. |
4768 |
18 Feb 09 |
nicklas |
@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 |
Get the validation options that are currently in effect. |
5076 |
25 Aug 09 |
nicklas |
@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 |
Store an auxilliary object in the overview cache. This is a service |
4768 |
18 Feb 09 |
nicklas |
provided by the overview implementation that can be used by node |
4768 |
18 Feb 09 |
nicklas |
loaders and/or validators to store information that may be needed |
4768 |
18 Feb 09 |
nicklas |
again in the future and is expensive to retreive (eg. from the database). |
4768 |
18 Feb 09 |
nicklas |
This is for example used to store annotation types that have been marked |
4768 |
18 Feb 09 |
nicklas |
as "Required by MIAME", parents to annotatable items and more. |
4768 |
18 Feb 09 |
nicklas |
<p> |
4768 |
18 Feb 09 |
nicklas |
Note! The overview impementation is not forced to implement a |
4768 |
18 Feb 09 |
nicklas |
cache, or it may optionally decide to disable the cache. Node |
4768 |
18 Feb 09 |
nicklas |
loaders and validators should not depend on the cache for |
4768 |
18 Feb 09 |
nicklas |
correct functionality. |
4768 |
18 Feb 09 |
nicklas |
100 |
|
4768 |
18 Feb 09 |
nicklas |
@param cacheKey The key to store the value under |
4768 |
18 Feb 09 |
nicklas |
@param value The value to store in the cache, or null to |
4768 |
18 Feb 09 |
nicklas |
remove the entry |
4768 |
18 Feb 09 |
nicklas |
@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 |
Retreive an object stored in the overview cache. |
4768 |
18 Feb 09 |
nicklas |
@param cacheKey The key to use for cache lookup |
4768 |
18 Feb 09 |
nicklas |
@return The object, or null if no object has been cached with the |
4768 |
18 Feb 09 |
nicklas |
given key |
4768 |
18 Feb 09 |
nicklas |
@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 |
Register the failure of a validation rule. |
4768 |
18 Feb 09 |
nicklas |
<p> |
4768 |
18 Feb 09 |
nicklas |
Note! The overview implementation is not forced to register the |
4768 |
18 Feb 09 |
nicklas |
failure, or it may optioanlly only register certain types of |
4768 |
18 Feb 09 |
nicklas |
failures. |
4768 |
18 Feb 09 |
nicklas |
124 |
|
4768 |
18 Feb 09 |
nicklas |
@param validator The validation rule that fails |
4768 |
18 Feb 09 |
nicklas |
@param node The node that was validated |
4768 |
18 Feb 09 |
nicklas |
@param message An optional message, if null the message from |
4768 |
18 Feb 09 |
nicklas |
{@link Validator#getFailureSummary()} is used |
4768 |
18 Feb 09 |
nicklas |
@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 |
Same as {@link #initQuery(ItemQuery, Order...)} but easier to use when |
4768 |
18 Feb 09 |
nicklas |
sorting the items in ascending order by a single column. |
4768 |
18 Feb 09 |
nicklas |
@param query The query that should be initialised |
4768 |
18 Feb 09 |
nicklas |
@param sortby The property name to sort by (may be null) |
4768 |
18 Feb 09 |
nicklas |
@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 |
Initialise a query with "global options" and optionally a sort |
4768 |
18 Feb 09 |
nicklas |
order. |
4768 |
18 Feb 09 |
nicklas |
<p> |
4768 |
18 Feb 09 |
nicklas |
Note! The "global options" can differ between overview implementation, |
4768 |
18 Feb 09 |
nicklas |
but typically include settings some restrictions base on {@link Include} |
4768 |
18 Feb 09 |
nicklas |
options, or permissions on the query. |
4768 |
18 Feb 09 |
nicklas |
149 |
|
4768 |
18 Feb 09 |
nicklas |
@param query The query that should be initialised |
4768 |
18 Feb 09 |
nicklas |
@param sortby An array with Order objects (may be null) |
4768 |
18 Feb 09 |
nicklas |
@return The same query object |
4768 |
18 Feb 09 |
nicklas |
@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 |
Get the current node cache. Node loaders may use the cache to store |
4768 |
18 Feb 09 |
nicklas |
nodes for already seen items. Then, when the same item is seen again |
4768 |
18 Feb 09 |
nicklas |
the existing node (including all children) is simply cloned. This can |
4768 |
18 Feb 09 |
nicklas |
make the performance a lot better. |
4768 |
18 Feb 09 |
nicklas |
162 |
|
4768 |
18 Feb 09 |
nicklas |
@return A node cache, or null if the current overview doesn't want |
4768 |
18 Feb 09 |
nicklas |
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 |
} |