/*******************************************************************************
- * 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
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 += 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$
- Layer0 L0 = Layer0.getInstance(graph);
-
Set<Resource> indexRoots = new HashSet<>();
indexRoots.addAll(graph.syncRequest(new ObjectsWithType(project, L0.ConsistsOf, L0.IndexRoot)));
indexRoots.addAll(graph.syncRequest(new OntologiesFromLibrary(graph.getRootLibrary())));
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$
}