]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.workbench.search/src/org/simantics/workbench/search/DependenciesSearchFunction.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.workbench.search / src / org / simantics / workbench / search / DependenciesSearchFunction.java
diff --git a/bundles/org.simantics.workbench.search/src/org/simantics/workbench/search/DependenciesSearchFunction.java b/bundles/org.simantics.workbench.search/src/org/simantics/workbench/search/DependenciesSearchFunction.java
new file mode 100644 (file)
index 0000000..28baffa
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************\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.workbench.search;\r
+\r
+import java.util.Collection;\r
+import java.util.Map;\r
+\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.Logger;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.operation.Layer0X;\r
+import org.simantics.scl.runtime.function.FunctionImpl5;\r
+\r
+/**\r
+ * dependenciesSearchFunction:\r
+ *      (IProgressMonitor, ReadGraph, model : Resource, query : String, maxResults : Integer) -> QueryResult\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class DependenciesSearchFunction extends FunctionImpl5<IProgressMonitor, ReadGraph, Resource, SearchQuery, Integer, SearchResult> {\r
+\r
+    @Override\r
+    public SearchResult apply(IProgressMonitor monitor, ReadGraph graph, Resource model, SearchQuery query, Integer maxResults) {\r
+        try {\r
+            Collection<Map<String, Object>> results = Searching.performSearch(graph,\r
+                    Layer0X.getInstance(graph).Dependencies, model, query.getQuery("Name","Types"), maxResults);\r
+\r
+            return Searching.generateDependenciesSearchResult(graph, results);\r
+        } catch (DatabaseException e) {\r
+            Logger.defaultLogError(e);\r
+        }\r
+        return null;\r
+    }\r
+\r
+}\r