Search in sources :

Example 1 with DataModelExtension

use of org.kie.workbench.common.services.datamodel.spi.DataModelExtension in project kie-wb-common by kiegroup.

the class LRUDataModelOracleCache method loadExtensionsForPackage.

private void loadExtensionsForPackage(final PackageDataModelOracleBuilder dmoBuilder, final Package pkg) {
    final org.uberfire.java.nio.file.Path nioPackagePath = Paths.convert(pkg.getPackageMainResourcesPath());
    List<DataModelExtension> extensions = stream(dataModelExtensionsProvider.spliterator(), false).collect(toList());
    for (final DataModelExtension extension : extensions) {
        Filter<org.uberfire.java.nio.file.Path> filter = extension.getFilter();
        final Collection<org.uberfire.java.nio.file.Path> extensionFiles = fileDiscoveryService.discoverFiles(nioPackagePath, filter);
        extensionFiles.stream().map(file -> extension.getExtensions(file, ioService.readAllString(file))).forEach(mappings -> mappings.forEach(mapping -> dmoBuilder.addExtension(mapping.getKind(), mapping.getValues())));
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) FileDiscoveryService(org.guvnor.common.services.backend.file.FileDiscoveryService) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) DataModelExtension(org.kie.workbench.common.services.datamodel.spi.DataModelExtension) ArrayList(java.util.ArrayList) Package(org.guvnor.common.services.project.model.Package) Paths(org.uberfire.backend.server.util.Paths) Inject(javax.inject.Inject) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Observes(javax.enterprise.event.Observes) GlobalsFileFilter(org.kie.workbench.common.services.backend.file.GlobalsFileFilter) InvalidateDMOModuleCacheEvent(org.guvnor.common.services.project.builder.events.InvalidateDMOModuleCacheEvent) PortablePreconditions(org.kie.soup.commons.validation.PortablePreconditions) Named(javax.inject.Named) Instance(javax.enterprise.inject.Instance) Path(org.uberfire.backend.vfs.Path) BuildInfoService(org.kie.workbench.common.services.backend.builder.service.BuildInfoService) KieModuleMetaData(org.kie.scanner.KieModuleMetaData) Collection(java.util.Collection) KieModule(org.kie.workbench.common.services.shared.project.KieModule) EnumerationsFileFilter(org.kie.workbench.common.services.backend.file.EnumerationsFileFilter) PackageDataModelOracleBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.packages.PackageDataModelOracleBuilder) InvalidateDMOPackageCacheEvent(org.guvnor.common.services.project.builder.events.InvalidateDMOPackageCacheEvent) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) StreamSupport.stream(java.util.stream.StreamSupport.stream) LRUCache(org.guvnor.common.services.backend.cache.LRUCache) IOService(org.uberfire.io.IOService) DirectoryStream(org.uberfire.java.nio.file.DirectoryStream) ApplicationScoped(javax.enterprise.context.ApplicationScoped) MVELEvaluator(org.kie.soup.project.datamodel.commons.util.MVELEvaluator) Filter(org.uberfire.java.nio.file.DirectoryStream.Filter) DataModelExtension(org.kie.workbench.common.services.datamodel.spi.DataModelExtension)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 StreamSupport.stream (java.util.stream.StreamSupport.stream)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Observes (javax.enterprise.event.Observes)1 Instance (javax.enterprise.inject.Instance)1 Inject (javax.inject.Inject)1 Named (javax.inject.Named)1 LRUCache (org.guvnor.common.services.backend.cache.LRUCache)1 FileDiscoveryService (org.guvnor.common.services.backend.file.FileDiscoveryService)1 InvalidateDMOModuleCacheEvent (org.guvnor.common.services.project.builder.events.InvalidateDMOModuleCacheEvent)1 InvalidateDMOPackageCacheEvent (org.guvnor.common.services.project.builder.events.InvalidateDMOPackageCacheEvent)1 Package (org.guvnor.common.services.project.model.Package)1 KieModuleMetaData (org.kie.scanner.KieModuleMetaData)1 PortablePreconditions (org.kie.soup.commons.validation.PortablePreconditions)1 MVELEvaluator (org.kie.soup.project.datamodel.commons.util.MVELEvaluator)1 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)1 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)1