--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.db.layer0.adapter;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.simantics.db.RequestProcessor;\r
+import org.simantics.db.Resource;\r
+\r
+public interface GenericRelationIndex {\r
+\r
+ /*\r
+ * Returns indexed results based on this relation with given constants that\r
+ * fulfill the specified search string.\r
+ */\r
+ List<Map<String, Object>> query(RequestProcessor session, String search, String bindingPattern, Object[] constants, int maxResultCount);\r
+ List<Resource> queryResources(RequestProcessor session, String search, String bindingPattern, Object[] constants, int maxResultCount);\r
+\r
+ /*\r
+ * Returns indexed results based on this relation with given constants.\r
+ * \r
+ * TODO: index listing is not useful like this for large indices. It needs\r
+ * support for listing the contents in a piecewise fashion, iterating\r
+ * through the complete index in slices.\r
+ */\r
+ List<Map<String, Object>> list(RequestProcessor session, String bindingPattern, Object[] constants, int maxResultCount);\r
+\r
+ /*\r
+ * Starts to track changes in this relation. Updates an index using the\r
+ * IndexedRelations service.\r
+ */\r
+ void trackAndIndex(RequestProcessor processor, Resource input);\r
+ void untrack(RequestProcessor processor, Resource input);\r
+\r
+ /*\r
+ * Rebuilds this index\r
+ */\r
+ void reset(RequestProcessor processor, Resource input);\r
+ \r
+ /*\r
+ * The observer is fired whenever changes to the relation are observed. This\r
+ * is applicable only after trackAndIndex has been called.\r
+ */\r
+ void addListener(RequestProcessor processor, Resource model, Runnable observer);\r
+ void removeListener(RequestProcessor processor, Resource model, Runnable observer);\r
+\r
+}\r