]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.workbench.search/src/org/simantics/workbench/search/DependenciesSearchFunction.java
Index tokenized lowercase versions of name and types for UI searches
[simantics/platform.git] / bundles / org.simantics.workbench.search / src / org / simantics / workbench / search / DependenciesSearchFunction.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.workbench.search;
13
14 import java.util.Collection;
15 import java.util.Map;
16
17 import org.eclipse.core.runtime.IProgressMonitor;
18 import org.simantics.db.ReadGraph;
19 import org.simantics.db.Resource;
20 import org.simantics.db.common.utils.Logger;
21 import org.simantics.db.exception.DatabaseException;
22 import org.simantics.db.layer0.genericrelation.Dependencies;
23 import org.simantics.operation.Layer0X;
24 import org.simantics.scl.runtime.function.FunctionImpl5;
25
26 /**
27  * dependenciesSearchFunction:
28  *      (IProgressMonitor, ReadGraph, model : Resource, query : String, maxResults : Integer) -> QueryResult
29  * 
30  * @author Tuukka Lehtonen
31  */
32 public class DependenciesSearchFunction extends FunctionImpl5<IProgressMonitor, ReadGraph, Resource, SearchQuery, Integer, SearchResult> {
33
34     @Override
35     public SearchResult apply(IProgressMonitor monitor, ReadGraph graph, Resource model, SearchQuery query, Integer maxResults) {
36         try {
37             Collection<Map<String, Object>> results = Searching.performSearch(graph,
38                     Layer0X.getInstance(graph).Dependencies, model,
39                     query.escapedWithForcedCase(false, false).getQuery(Dependencies.FIELD_NAME_SEARCH, Dependencies.FIELD_TYPES_SEARCH),
40                     maxResults);
41
42             return Searching.generateDependenciesSearchResult(graph, results);
43         } catch (DatabaseException e) {
44             Logger.defaultLogError(e);
45         }
46         return null;
47     }
48
49 }