use of org.uberfire.ext.metadata.model.KObject in project kie-wb-common by kiegroup.
the class RefactoringQueryServiceImpl method query.
@Override
public List<RefactoringPageRow> query(final String queryName, final Set<ValueIndexTerm> queryTerms) {
PortablePreconditions.checkNotNull("queryName", queryName);
PortablePreconditions.checkNotNull("queryTerms", queryTerms);
final NamedQuery namedQuery = namedQueries.findNamedQuery(queryName);
// Validate provided terms against those required for the named query
namedQuery.validateTerms(queryTerms);
final Query query = namedQuery.toQuery(queryTerms);
final Sort sort = namedQuery.getSortOrder();
final List<KObject> kObjects = search(query, sort, () -> (0), // start index of docs to get
(numHits) -> (numHits), false);
if (!kObjects.isEmpty()) {
final ResponseBuilder responseBuilder = namedQuery.getResponseBuilder();
return responseBuilder.buildResponse(kObjects);
} else {
return Collections.emptyList();
}
}
use of org.uberfire.ext.metadata.model.KObject in project kie-wb-common by kiegroup.
the class FileDetailsResponseBuilder method buildResponse.
@Override
public List<RefactoringPageRow> buildResponse(final List<KObject> kObjects) {
final List<RefactoringPageRow> result = new ArrayList<RefactoringPageRow>(kObjects.size());
for (final KObject kObject : kObjects) {
final Path path = Paths.convert(ioService.get(URI.create(kObject.getKey())));
final RefactoringPathPageRow row = new RefactoringPathPageRow();
row.setValue(path);
result.add(row);
}
return result;
}
use of org.uberfire.ext.metadata.model.KObject in project kie-wb-common by kiegroup.
the class RuleNameResponseBuilder method buildResponse.
@Override
public List<RefactoringPageRow> buildResponse(final List<KObject> kObjects) {
// Both "child" rule and "parent" rule (when one extends another) are stored
// in the index. We therefore need to build a set of unique Rule Names
final List<RefactoringPageRow> result = new ArrayList<RefactoringPageRow>(kObjects.size());
final Set<RuleName> uniqueRuleNames = new HashSet<>();
for (final KObject kObject : kObjects) {
final Set<RuleName> ruleNames = getRuleNamesFromKObject(kObject);
uniqueRuleNames.addAll(ruleNames);
}
for (RuleName ruleName : uniqueRuleNames) {
final RefactoringRuleNamePageRow row = new RefactoringRuleNamePageRow();
row.setValue(ruleName);
result.add(row);
}
return result;
}
use of org.uberfire.ext.metadata.model.KObject in project kie-wb-common by kiegroup.
the class LibraryIndexer method toKObject.
@Override
public KObject toKObject(final Path path) {
KObject index = null;
try {
// create a builder with the default information
DefaultIndexBuilder builder = fillIndexBuilder(path);
Set<KProperty<?>> indexElements = null;
if (builder != null) {
// build index document
indexElements = builder.build();
} else {
indexElements = Collections.emptySet();
}
index = KObjectUtil.toKObject(path, LIBRARY_CLASSIFIER, indexElements);
} catch (Exception e) {
// Unexpected parsing or processing error
logger.error("Unable to index '" + path.toUri().toString() + "'.", e.getMessage(), e);
}
return index;
}
use of org.uberfire.ext.metadata.model.KObject in project kie-wb-common by kiegroup.
the class FindAllLibraryAssetsQueryTest method cleanupLibraryResults.
@Test
public void cleanupLibraryResults() {
// This is a temporary way to cleanup index results
// for library assets list and count.
// In cluster environment library index each file more than once.
// The index should be revised on next release (7.6).
KObject k1 = new KObjectImpl("", "", "clusterId1", "", "key1", new ArrayList<>(), false);
KObject k2 = new KObjectImpl("", "", "clusterId2", "", "key2", new ArrayList<>(), false);
List<KObject> kObjects = service.distinct(Arrays.asList(k1, k1, k2));
assertEquals(2, kObjects.size());
assertEquals(k1, kObjects.get(0));
assertEquals(k2, kObjects.get(1));
}
Aggregations