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