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.workbench.search;
14 import java.util.Collection;
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;
27 * dependenciesSearchFunction:
28 * (IProgressMonitor, ReadGraph, model : Resource, query : String, maxResults : Integer) -> QueryResult
30 * @author Tuukka Lehtonen
32 public class DependenciesSearchFunction extends FunctionImpl5<IProgressMonitor, ReadGraph, Resource, SearchQuery, Integer, SearchResult> {
35 public SearchResult apply(IProgressMonitor monitor, ReadGraph graph, Resource model, SearchQuery query, Integer maxResults) {
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),
42 return Searching.generateDependenciesSearchResult(graph, results);
43 } catch (DatabaseException e) {
44 Logger.defaultLogError(e);