use of org.uberfire.ext.metadata.model.KProperty in project kie-wb-common by kiegroup.
the class SharedPart method toIndexElements.
@Override
public List<KProperty<?>> toIndexElements() {
final List<KProperty<?>> indexElements = new ArrayList<>();
// Impact Analysis reference
ValueSharedPartIndexTerm sharedPartTerm = new ValueSharedPartIndexTerm(this.partName, this.partType);
indexElements.add(new KPropertyImpl<>(sharedPartTerm.getTerm(), sharedPartTerm.getValue()));
return indexElements;
}
use of org.uberfire.ext.metadata.model.KProperty in project kie-wb-common by kiegroup.
the class ResourceReference method toIndexElements.
@Override
public List<KProperty<?>> toIndexElements() {
final List<KProperty<?>> indexElements = new ArrayList<>();
// Impact Analysis references
if (resourceFQN != null) {
ValueReferenceIndexTerm refTerm = new ValueReferenceIndexTerm(this.resourceFQN, this.resourceType);
indexElements.add(new KPropertyImpl<>(refTerm.getTerm(), refTerm.getValue()));
}
if (this.fieldNamepartReferenceMap != null) {
fieldNamepartReferenceMap.values().forEach((refPartTerm) -> indexElements.add(new KPropertyImpl<>(refPartTerm.getTerm(), refPartTerm.getValue())));
}
return indexElements;
}
use of org.uberfire.ext.metadata.model.KProperty in project kie-wb-common by kiegroup.
the class AbstractFileIndexer method toKObject.
/**
* This method should not be overridden by implementation classes!
* </p>
* However, we can not make this method final because otherwise Weld/Errai will complain
* when they try to make proxy beans.
*/
@Override
public KObject toKObject(Path path) {
KObject index = null;
try {
// create a builder with the default information
IndexBuilder builder = fillIndexBuilder(path);
Set<KProperty<?>> indexElements = null;
if (builder != null) {
// build index document
indexElements = builder.build();
} else {
indexElements = Collections.emptySet();
}
index = KObjectUtil.toKObject(path, IndexTerm.REFACTORING_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.KProperty in project kie-wb-common by kiegroup.
the class Resource method toIndexElements.
@Override
public List<KProperty<?>> toIndexElements() {
final List<KProperty<?>> indexElements = new ArrayList<>();
ValueResourceIndexTerm resTerm = new ValueResourceIndexTerm(resourceFQN, resourceType);
indexElements.add(new KPropertyImpl<>(resTerm.getTerm(), resTerm.getValue()));
parts.entrySet().forEach((part) -> {
ValuePartIndexTerm partTerm = new ValuePartIndexTerm(part.getKey(), part.getValue());
indexElements.add(new KPropertyImpl<>(partTerm.getTerm(), partTerm.getValue()));
});
return indexElements;
}
use of org.uberfire.ext.metadata.model.KProperty in project kie-wb-common by kiegroup.
the class FindResourcePartsQueryValidIndexTermsTest method testIndexJavaFilesAndFindResourcePartsQuery.
@Test
public void testIndexJavaFilesAndFindResourcePartsQuery() throws Exception {
// setup
ioService();
// Add test files
String pojo1FileName = "Pojo1.java";
Path path = basePath.resolve(pojo1FileName);
String javaSourceText = loadText("../" + pojo1FileName);
ioService().write(path, javaSourceText);
// 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).getClusterId());
{
final Query query = new SingleTermQueryBuilder(new ValueResourceIndexTerm("*", ResourceType.JAVA, TermSearchType.WILDCARD)).build();
List<KObject> hits = getConfig().getIndexProvider().findByQuery(index, query, 10);
assertEquals(1, hits.size());
List<Pair<String, String>> expectedValues = initExpectedValues();
KObject doc = null;
for (KObject kObject : hits) {
doc = kObject;
for (KProperty<?> property : doc.getProperties()) {
String fieldVal = property.getValue().toString();
if (fieldVal.startsWith("git://")) {
if (fieldVal.contains(pojo1FileName)) {
break;
}
} else {
continue;
}
}
}
assertContains(expectedValues, doc);
}
{
HashSet<ValueIndexTerm> queryTerms = new HashSet<ValueIndexTerm>();
queryTerms.add(new ValuePartIndexTerm("o_BigDecimal", PartType.FIELD));
final RefactoringPageRequest request = new RefactoringPageRequest(FindResourcePartsQuery.NAME, queryTerms, 0, 10);
try {
final PageResponse<RefactoringPageRow> response = service.query(request);
assertNotNull("No documents found!", response);
assertEquals(1, response.getPageRowList().size());
} catch (IllegalArgumentException e) {
e.printStackTrace();
fail("Could not execute query: " + e.getMessage());
}
}
;
}
Aggregations