use of org.uberfire.ext.metadata.model.KProperty 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
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, 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.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 BPMNProcessIdsResponseBuilder method testJBPM8828.
@Test
public void testJBPM8828() {
final FindBpmnProcessIdsQuery findBpmnProcessIdsQuery = new FindBpmnProcessIdsQuery();
final List<KObject> kObjects = new ArrayList<>();
kObjects.add(kObject1);
kObjects.add(kObject2);
final List<KProperty<?>> kProperties1 = new ArrayList<>();
kProperties1.add(kProperty1);
final List<KProperty<?>> kProperties2 = new ArrayList<>();
kProperties2.add(kProperty2);
final String invalidFile = "ProcessA1";
final String validFile = "ProcessB1";
final URI validURI = URI.create(validFile);
when(kObject1.getProperties()).thenReturn(kProperties1);
when(kObject1.getKey()).thenReturn(invalidFile);
when(kObject2.getProperties()).thenReturn(kProperties2);
when(kObject2.getKey()).thenReturn(validFile);
when(kProperty1.getName()).thenReturn(findBpmnProcessIdsQuery.getProcessIdResourceType().toString());
when(kProperty1.getValue()).thenReturn(invalidFile);
when(kProperty2.getName()).thenReturn(findBpmnProcessIdsQuery.getProcessIdResourceType().toString());
when(kProperty2.getValue()).thenReturn(validFile);
when(validPath.getFileName()).thenReturn(validPath);
when(validPath.toUri()).thenReturn(validURI);
when(validPath.getFileSystem()).thenReturn(fileSystem);
String exceptionString = "FILE_SYSTEM_NOT_FOUND_EXCEPTION";
when(exception.toString()).thenReturn(exceptionString);
Set<String> attribViews = new HashSet<>();
when(fileSystem.supportedFileAttributeViews()).thenReturn(attribViews);
when(ioService.get(any(URI.class))).thenAnswer(new Answer<Path>() {
public Path answer(InvocationOnMock invocation) throws FileSystemNotFoundException {
Object[] args = invocation.getArguments();
URI uri = (URI) args[0];
if (uri.getPath().compareTo(invalidFile) == 0) {
throw exception;
}
return validPath;
}
});
AbstractFindIdsQuery.BpmnProcessIdsResponseBuilder responseBuilder = new AbstractFindIdsQuery.BpmnProcessIdsResponseBuilder(ioService, findBpmnProcessIdsQuery.getProcessIdResourceType());
responseBuilder.LOGGER = logger;
List<RefactoringPageRow> response = responseBuilder.buildResponse(kObjects);
RefactoringPageRow pageRow = response.get(0);
Map<String, Path> pageRowValue = (Map<String, Path>) pageRow.getValue();
verify(logger, times(1)).error(exceptionString);
assertEquals(1, response.size(), 0);
assertEquals(1, pageRowValue.size(), 0);
assertTrue(validPath.compareTo(pageRowValue.get(validFile)) == 0);
}
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 GitKeepFileIndexerTest method testTheUsualBuild.
@Test
public void testTheUsualBuild() throws Exception {
final KieModule kieModule = mock(KieModule.class);
doReturn(kieModule).when(moduleService).resolveModule(any(Path.class));
doReturn("Module Name").when(kieModule).getModuleName();
doReturn(getPathMock("default://main@myRepository/Test")).when(kieModule).getRootPath();
final Package aPackage = mock(Package.class);
doReturn("pkgName").when(aPackage).getPackageName();
doReturn(aPackage).when(moduleService).resolvePackage(any(Path.class));
final IndexBuilder indexBuilder = indexer.fillIndexBuilder(mainPath);
final Set<KProperty<?>> properties = indexBuilder.build();
assertEquals(3, properties.size());
assertTrue(properties.contains(new KPropertyImpl<>(ModuleRootPathIndexTerm.TERM, "default://main@myRepository/Test")));
assertTrue(properties.contains(new KPropertyImpl<>(ModuleNameIndexTerm.TERM, "Module Name")));
assertTrue(properties.contains(new KPropertyImpl<>(PackageNameIndexTerm.TERM, "pkgName")));
}
Aggregations