]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/GenericRelationIndex.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / adapter / GenericRelationIndex.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.layer0.adapter;
13
14 import java.util.List;
15 import java.util.Map;
16
17 import org.simantics.db.RequestProcessor;
18 import org.simantics.db.Resource;
19
20 public interface GenericRelationIndex {
21
22     /*
23      * Returns indexed results based on this relation with given constants that
24      * fulfill the specified search string.
25      */
26     List<Map<String, Object>> query(RequestProcessor session, String search, String bindingPattern, Object[] constants, int maxResultCount);
27     List<Resource> queryResources(RequestProcessor session, String search, String bindingPattern, Object[] constants, int maxResultCount);
28
29     /*
30      * Returns indexed results based on this relation with given constants.
31      * 
32      * TODO: index listing is not useful like this for large indices. It needs
33      * support for listing the contents in a piecewise fashion, iterating
34      * through the complete index in slices.
35      */
36     List<Map<String, Object>> list(RequestProcessor session, String bindingPattern, Object[] constants, int maxResultCount);
37
38     /*
39      * Starts to track changes in this relation. Updates an index using the
40      * IndexedRelations service.
41      */
42     void trackAndIndex(RequestProcessor processor, Resource input);
43     void untrack(RequestProcessor processor, Resource input);
44
45     /*
46      * Rebuilds this index
47      */
48     void reset(RequestProcessor processor, Resource input);
49     
50     /*
51      * The observer is fired whenever changes to the relation are observed. This
52      * is applicable only after trackAndIndex has been called.
53      */
54     void addListener(RequestProcessor processor, Resource model, Runnable observer);
55     void removeListener(RequestProcessor processor, Resource model, Runnable observer);
56
57 }