use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm in project kie-wb-common by kiegroup.
the class CalledElementFormProvider method getBusinessProcessIDs.
public Map<Object, String> getBusinessProcessIDs() {
final Set<ValueIndexTerm> queryTerms = new HashSet<ValueIndexTerm>() {
{
add(new ValueResourceIndexTerm("*", ResourceType.BPMN2, ValueIndexTerm.TermSearchType.WILDCARD));
}
};
List<RefactoringPageRow> results = queryService.query(FindBpmnProcessIdsQuery.NAME, queryTerms);
Map<Object, String> businessProcessIDs = new TreeMap<Object, String>();
for (RefactoringPageRow row : results) {
Map<String, Path> mapRow = (Map<String, Path>) row.getValue();
for (String rKey : mapRow.keySet()) {
businessProcessIDs.put(rKey, rKey);
}
}
return businessProcessIDs;
}
use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm in project kie-wb-common by kiegroup.
the class MultipleTermQueryBuilder method build.
public Query build() {
BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
for (ValueIndexTerm valueTerm : terms) {
Query termQuery = getQuery(valueTerm);
queryBuilder.add(termQuery, Occur.MUST);
}
BooleanQuery query = queryBuilder.build();
return query;
}
use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm in project kie-wb-common by kiegroup.
the class FindRulesByModuleQuery method toQuery.
@Override
public Query toQuery(final Set<ValueIndexTerm> terms) {
checkNotNullAndNotEmpty(terms);
ValuePackageNameIndexTerm packageTerm = null;
ValueModuleRootPathIndexTerm projectTerm = null;
ValueResourceIndexTerm ruleTerm = null;
for (ValueIndexTerm term : terms) {
if (term instanceof ValuePackageNameIndexTerm) {
packageTerm = (ValuePackageNameIndexTerm) term;
} else if (term instanceof ValueModuleRootPathIndexTerm) {
projectTerm = (ValueModuleRootPathIndexTerm) term;
} else if (term instanceof ValueResourceIndexTerm) {
ruleTerm = (ValueResourceIndexTerm) term;
}
}
SearchEmptyQueryBuilder queryBuilder = new SearchEmptyQueryBuilder().addTerm(packageTerm).addTerm(projectTerm);
if (ruleTerm != null) {
queryBuilder.addTerm(ruleTerm);
} else {
queryBuilder.addRuleNameWildCardTerm();
}
return queryBuilder.build();
}
use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm in project kie-wb-common by kiegroup.
the class FindDataTypesQueryTest method testDesignerFindDataTypesQuery.
@Test
public void testDesignerFindDataTypesQuery() {
FindDataTypesQuery query = new FindDataTypesQuery();
Set<ValueIndexTerm> queryTerms = new HashSet<>();
try {
query.validateTerms(queryTerms);
fail("The required java term is missing, but no exception was thrown.");
} catch (IllegalArgumentException iae) {
assertTrue("Incorrect error message: " + iae.getMessage(), iae.getMessage().contains("At least 1 term"));
}
queryTerms = new HashSet<>();
queryTerms.add(new ValueSharedPartIndexTerm("not-rule-flow", PartType.ACTIVATION_GROUP));
try {
query.validateTerms(queryTerms);
fail("The required java term is missing, but no exception was thrown.");
} catch (IllegalArgumentException iae) {
assertTrue("Incorrect error message: " + iae.getMessage(), iae.getMessage().contains(ERROR_MSG));
}
queryTerms = new HashSet<>();
queryTerms.add(new ValueSharedPartIndexTerm("not-rule-flow", PartType.ACTIVATION_GROUP));
queryTerms.add(new ValueResourceIndexTerm("java.class", ResourceType.JAVA));
try {
query.validateTerms(queryTerms);
fail("The activation term is not acceptable here, but no exception was thrown.");
} catch (IllegalArgumentException iae) {
assertTrue("Incorrect error message: " + iae.getMessage(), iae.getMessage().contains(ERROR_MSG));
}
queryTerms = new HashSet<>();
queryTerms.add(new ValueResourceIndexTerm("java.class", ResourceType.JAVA));
query.validateTerms(queryTerms);
}
use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm in project drools-wb by kiegroup.
the class IndexRuleAttributeNameAndValueTest method testIndexDrlRuleAttributeNameAndValue.
@Test
public void testIndexDrlRuleAttributeNameAndValue() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("drl1.drl");
final String drl = loadText("drl1.drl");
ioService().write(path, drl);
// wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
Thread.sleep(5000);
List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath.getFileSystem()).getClusterId());
{
final BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
queryBuilder.add(new TermQuery(new Term((new SharedPartIndexTerm(PartType.RULEFLOW_GROUP)).getTerm())), BooleanClause.Occur.MUST);
queryBuilder.add(new TermQuery(new Term("nonexistent")), BooleanClause.Occur.MUST);
searchFor(index, queryBuilder.build(), 0);
}
// This note replaces an earlier note, if it doesn't make sense, delete or ignore it.
// Both pieces of info (that it's a ruleflow group, and that the ruleflow group is called "myruleflowgroup")
// are present in the same field ("shared:ruleflowgroup" => "myruleflowgroup"), so this only returns
// documents that match that field (as opposed to the structure we had before).
{
final BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
ValueIndexTerm termVals = new ValueSharedPartIndexTerm("myruleflowgroup", PartType.RULEFLOW_GROUP);
queryBuilder.add(new TermQuery(new Term(termVals.getTerm(), termVals.getValue())), BooleanClause.Occur.MUST);
searchFor(index, queryBuilder.build(), 1);
}
}
Aggregations