X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.workbench.search%2Fsrc%2Forg%2Fsimantics%2Fworkbench%2Fsearch%2FDependenciesSearchFunction.java;h=d270124f1d84e674878e5267ad60eafc2c92d885;hp=28baffad9b4cff411e5035eee00857db88b329c2;hb=38d133f2a39bab76deed5d047fbabee4479b5373;hpb=969bd23cab98a79ca9101af33334000879fb60c5 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 index 28baffad9..d270124f1 100644 --- 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 @@ -1,46 +1,52 @@ -/******************************************************************************* - * 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.common.utils.Logger; -import org.simantics.db.exception.DatabaseException; -import org.simantics.operation.Layer0X; -import org.simantics.scl.runtime.function.FunctionImpl5; - -/** - * dependenciesSearchFunction: - * (IProgressMonitor, ReadGraph, model : Resource, query : String, maxResults : Integer) -> QueryResult - * - * @author Tuukka Lehtonen - */ -public class DependenciesSearchFunction extends FunctionImpl5 { - - @Override - public SearchResult apply(IProgressMonitor monitor, ReadGraph graph, Resource model, SearchQuery query, Integer maxResults) { - try { - Collection> results = Searching.performSearch(graph, - Layer0X.getInstance(graph).Dependencies, model, query.getQuery("Name","Types"), maxResults); - - return Searching.generateDependenciesSearchResult(graph, results); - } catch (DatabaseException e) { - Logger.defaultLogError(e); - } - return null; - } - -} +/******************************************************************************* + * 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 { + + 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> 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; + } + +}