/*******************************************************************************
- * Copyright (c) 2007, 2016 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2019 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
package org.simantics.debug.ui;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.simantics.db.common.uri.UnescapedChildMapOfResource;
import org.simantics.db.common.utils.NameUtils;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.genericrelation.Dependencies;
+import org.simantics.db.layer0.genericrelation.IndexQueries;
import org.simantics.db.layer0.migration.OntologiesFromLibrary;
import org.simantics.db.layer0.variable.Variables.Role;
import org.simantics.db.request.Read;
}
}
} else {
+ String[] terms = pattern.trim().split("\\s+"); //$NON-NLS-1$
+ if (terms.length == 0) return;
+
Resource project = Simantics.peekProjectResource();
if (project != null) {
+ Layer0 L0 = Layer0.getInstance(graph);
IResourceFilter rf = resourceFilter;
- String filter = getFilterForResourceFilter(rf);
+ String filter = getFilterForResourceFilter(L0, rf);
if (!filter.isEmpty())
filter += " AND "; //$NON-NLS-1$
- filter += "Name:" + pattern + "*"; //$NON-NLS-1$ //$NON-NLS-2$
-
- Layer0 L0 = Layer0.getInstance(graph);
+
+ filter += Dependencies.FIELD_NAME_SEARCH + ":("; //$NON-NLS-1$
+ filter += Arrays.stream(terms).map(term -> "+" + IndexQueries.escape(term.toLowerCase(), false) + "*").collect(Collectors.joining(" ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ filter +=")"; //$NON-NLS-1$
Set<Resource> indexRoots = new HashSet<>();
indexRoots.addAll(graph.syncRequest(new ObjectsWithType(project, L0.ConsistsOf, L0.IndexRoot)));
this.resourceFilter = resourceFilter;
}
- private String getFilterForResourceFilter(IResourceFilter filter) {
+ private String getFilterForResourceFilter(Layer0 l0, IResourceFilter filter) {
if (filter == null || filter == ResourceSearch.FILTER_ALL)
return ""; //$NON-NLS-1$
if (filter == ResourceSearch.FILTER_RELATIONS)
- return "Types:Relation"; //$NON-NLS-1$
+ return IndexQueries.resourceIdTerm(Dependencies.FIELD_TYPE_RESOURCE, l0.Relation);
if (filter == ResourceSearch.FILTER_TYPES)
- return "Types:Type"; //$NON-NLS-1$
+ return IndexQueries.resourceIdTerm(Dependencies.FIELD_TYPE_RESOURCE, l0.Type);
return ""; //$NON-NLS-1$
}