]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.workbench.search/src/org/simantics/workbench/search/DependenciesSearchFunction.java
Move platform to only work with JDK's >= 11
[simantics/platform.git] / bundles / org.simantics.workbench.search / src / org / simantics / workbench / search / DependenciesSearchFunction.java
index 28baffad9b4cff411e5035eee00857db88b329c2..d270124f1d84e674878e5267ad60eafc2c92d885 100644 (file)
@@ -1,46 +1,52 @@
-/*******************************************************************************\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
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.workbench.search;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.genericrelation.Dependencies;
+import org.simantics.operation.Layer0X;
+import org.simantics.scl.runtime.function.FunctionImpl5;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * dependenciesSearchFunction:
+ *      (IProgressMonitor, ReadGraph, model : Resource, query : String, maxResults : Integer) -> QueryResult
+ * 
+ * @author Tuukka Lehtonen
+ */
+public class DependenciesSearchFunction extends FunctionImpl5<IProgressMonitor, ReadGraph, Resource, SearchQuery, Integer, SearchResult> {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(DependenciesSearchFunction.class);
+
+    @Override
+    public SearchResult apply(IProgressMonitor monitor, ReadGraph graph, Resource model, SearchQuery query, Integer maxResults) {
+        try {
+            Collection<Map<String, Object>> results = Searching.performSearch(graph,
+                    Layer0X.getInstance(graph).Dependencies, model,
+                    query.escapedWithForcedCase(false, false).getQuery(Dependencies.FIELD_NAME_SEARCH, Dependencies.FIELD_TYPES_SEARCH),
+                    maxResults);
+
+            return Searching.generateDependenciesSearchResult(graph, results);
+        } catch (DatabaseException e) {
+            LOGGER.error("Search query {} failed", query, e);
+        }
+        return null;
+    }
+
+}