1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.layer0.adapter;
14 import java.util.List;
17 import org.simantics.db.RequestProcessor;
18 import org.simantics.db.Resource;
20 public interface GenericRelationIndex {
23 * Returns indexed results based on this relation with given constants that
24 * fulfill the specified search string.
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);
30 * Returns indexed results based on this relation with given constants.
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.
36 List<Map<String, Object>> list(RequestProcessor session, String bindingPattern, Object[] constants, int maxResultCount);
39 * Starts to track changes in this relation. Updates an index using the
40 * IndexedRelations service.
42 void trackAndIndex(RequestProcessor processor, Resource input);
43 void untrack(RequestProcessor processor, Resource input);
48 void reset(RequestProcessor processor, Resource input);
51 * The observer is fired whenever changes to the relation are observed. This
52 * is applicable only after trackAndIndex has been called.
54 void addListener(RequestProcessor processor, Resource model, Runnable observer);
55 void removeListener(RequestProcessor processor, Resource model, Runnable observer);