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.exception.DatabaseException;
21 import org.simantics.db.layer0.genericrelation.Dependencies;
22 import org.simantics.operation.Layer0X;
23 import org.simantics.scl.runtime.function.FunctionImpl5;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
28 * dependenciesSearchFunction:
29 * (IProgressMonitor, ReadGraph, model : Resource, query : String, maxResults : Integer) -> QueryResult
31 * @author Tuukka Lehtonen
33 public class DependenciesSearchFunction extends FunctionImpl5<IProgressMonitor, ReadGraph, Resource, SearchQuery, Integer, SearchResult> {
35 private static final Logger LOGGER = LoggerFactory.getLogger(DependenciesSearchFunction.class);
38 public SearchResult apply(IProgressMonitor monitor, ReadGraph graph, Resource model, SearchQuery query, Integer maxResults) {
40 Collection<Map<String, Object>> results = Searching.performSearch(graph,
41 Layer0X.getInstance(graph).Dependencies, model,
42 query.escapedWithForcedCase(false, false).getQuery(Dependencies.FIELD_NAME_SEARCH, Dependencies.FIELD_TYPES_SEARCH),
45 return Searching.generateDependenciesSearchResult(graph, results);
46 } catch (DatabaseException e) {
47 LOGGER.error("Search query {} failed", query, e);