]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/IndexedRelations.java
a7b08deb3290775e723d830f8a6f36588ee579e2
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / genericrelation / IndexedRelations.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.genericrelation;
13
14 import java.util.Collection;
15 import java.util.List;
16 import java.util.Map;
17
18 import org.eclipse.core.runtime.IProgressMonitor;
19 import org.simantics.db.RequestProcessor;
20 import org.simantics.db.Resource;
21 import org.simantics.db.Session;
22 import org.simantics.db.layer0.adapter.GenericRelation;
23
24 /**
25  * TODO: how to use
26  * 
27  * TODO: make a statement about synchronization requirements imposed by the interface
28  * 
29  * TODO: what exceptions are the methods supposed to throw? any checked exceptions?
30  * 
31  * @author Antti Villberg
32  */
33 public interface IndexedRelations {
34
35     /**
36      * @param monitor
37      * @param search
38      * @param session
39      * @param relation
40      * @param input
41      * @param maxResultCount
42      * @return
43      * @throws IndexException
44      */
45     public List<Map<String, Object>> query(IProgressMonitor monitor, String search, RequestProcessor session,
46             Resource relation, Resource input, int maxResultCount) throws IndexException;
47
48     public List<Resource> queryResources(IProgressMonitor monitor, String search, RequestProcessor session,
49             Resource relation, Resource input, int maxResultCount) throws IndexException;
50
51     /**
52      * @param monitor
53      * @param processor
54      * @param relation
55      * @param resource
56      * @param input
57      * @param documents
58      * @throws IndexException
59      */
60     public void insert(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation,
61             Resource resource, Resource input, Collection<Object[]> documents)
62     throws IndexException;
63
64     /**
65      * @param monitor
66      * @param processor
67      * @param relation
68      * @param resource
69      * @param input
70      * @param key
71      * @param keyValues
72      * @throws IndexException
73      */
74     public void remove(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation,
75             Resource resource, Resource input, String key, Collection<Object> keyValues)
76     throws IndexException;
77
78     public void removeAll(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation,
79             Resource resource, Resource input)
80     throws IndexException;
81     
82     /**
83      * @param monitor
84      * @param processor
85      * @param relation
86      * @param resource
87      * @param input
88      * @param key
89      * @param keyValues
90      * @param documents
91      * @throws IndexException
92      */
93     public boolean replace(IProgressMonitor monitor, RequestProcessor processor, GenericRelation relation,
94             Resource resource, Resource input, String key, Collection<Object> keyValues, Collection<Object[]> documents)
95     throws IndexException;
96
97     public void reset(IProgressMonitor monitor, RequestProcessor processor, Resource resource, Resource input)
98     throws IndexException;
99
100     public void fullRebuild(IProgressMonitor monitor, RequestProcessor processor) throws IndexException;
101
102     /**
103      * Flush any memory-based index caches to disk and close down any resources
104      * related to each separate index.
105      * 
106      * Must be invoked outside of any database transactions.
107      * 
108      * @param monitor
109      * @param processor
110      * @throws IndexException
111      */
112     public void flush(IProgressMonitor monitor, Session session) throws IndexException;
113
114 }