Search in sources :

Example 16 with CompositePackageDescr

use of org.drools.compiler.lang.descr.CompositePackageDescr in project drools by kiegroup.

the class ModelBuilderImpl method storeGeneratedPojosInPackages.

private void storeGeneratedPojosInPackages(Collection<CompositePackageDescr> packages) {
    Collection<GeneratedClassWithPackage> allGeneratedPojos = ((CanonicalModelBuildContext) getBuildContext()).getAllGeneratedPojos();
    Map<String, Class<?>> allCompiledClasses = ((CanonicalModelBuildContext) getBuildContext()).getAllCompiledClasses();
    for (CompositePackageDescr packageDescr : packages) {
        InternalKnowledgePackage pkg = getPackageRegistry(packageDescr.getNamespace()).getPackage();
        allGeneratedPojos.stream().filter(pojo -> isInPackage(pkg, pojo)).forEach(pojo -> registerType(pkg.getTypeResolver(), allCompiledClasses.get(pojo.getFullyQualifiedName())));
    }
}
Also used : TypeDeclaration(org.drools.core.rule.TypeDeclaration) DRLIdGenerator(org.drools.modelcompiler.builder.generator.DRLIdGenerator) TypeResolver(org.drools.core.addon.TypeResolver) DrlxParseUtil(org.drools.modelcompiler.builder.generator.DrlxParseUtil) ModelGenerator.generateModel(org.drools.modelcompiler.builder.generator.ModelGenerator.generateModel) HashMap(java.util.HashMap) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) TypeDeclarationFactory(org.drools.compiler.builder.impl.TypeDeclarationFactory) AbstractClassTypeDeclarationDescr(org.drools.drl.ast.descr.AbstractClassTypeDeclarationDescr) Function(java.util.function.Function) POJOGenerator.compileType(org.drools.modelcompiler.builder.generator.declaredtype.POJOGenerator.compileType) ReleaseId(org.kie.api.builder.ReleaseId) HashSet(java.util.HashSet) ImportDescr(org.drools.drl.ast.descr.ImportDescr) Drools.hasMvel(org.drools.core.util.Drools.hasMvel) Map(java.util.Map) KnowledgeBuilderConfigurationImpl(org.drools.compiler.builder.impl.KnowledgeBuilderConfigurationImpl) ResultSeverity(org.kie.internal.builder.ResultSeverity) GlobalDescr(org.drools.drl.ast.descr.GlobalDescr) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage) PackageRegistry(org.drools.compiler.compiler.PackageRegistry) ImportDeclaration(org.drools.core.rule.ImportDeclaration) PackageDescr(org.drools.drl.ast.descr.PackageDescr) Collections.emptyList(java.util.Collections.emptyList) Collection(java.util.Collection) EnumDeclarationDescr(org.drools.drl.ast.descr.EnumDeclarationDescr) ClassDefinitionFactory.createClassDefinition(org.drools.compiler.builder.impl.ClassDefinitionFactory.createClassDefinition) Collectors(java.util.stream.Collectors) List(java.util.List) UnsupportedFeatureError(org.drools.modelcompiler.builder.errors.UnsupportedFeatureError) TypeDeclarationDescr(org.drools.drl.ast.descr.TypeDeclarationDescr) BuildContext(org.drools.compiler.kie.builder.impl.BuildContext) Optional(java.util.Optional) POJOGenerator(org.drools.modelcompiler.builder.generator.declaredtype.POJOGenerator) CompositePackageDescr(org.drools.compiler.lang.descr.CompositePackageDescr) StaticJavaParser.parseImport(com.github.javaparser.StaticJavaParser.parseImport) StringUtils(org.drools.core.util.StringUtils) CompositePackageDescr(org.drools.compiler.lang.descr.CompositePackageDescr) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Aggregations

CompositePackageDescr (org.drools.compiler.lang.descr.CompositePackageDescr)16 PackageRegistry (org.drools.compiler.compiler.PackageRegistry)8 HashMap (java.util.HashMap)6 PackageDescr (org.drools.drl.ast.descr.PackageDescr)6 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)5 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)5 ImportDescr (org.drools.drl.ast.descr.ImportDescr)5 GlobalDescr (org.drools.drl.ast.descr.GlobalDescr)4 HashSet (java.util.HashSet)3 List (java.util.List)3 Map (java.util.Map)3 Optional (java.util.Optional)3 TypeDeclaration (org.drools.core.rule.TypeDeclaration)3 AbstractClassTypeDeclarationDescr (org.drools.drl.ast.descr.AbstractClassTypeDeclarationDescr)3 KiePMMLException (org.kie.pmml.api.exceptions.KiePMMLException)3 KiePMMLDroolsAST (org.kie.pmml.models.drools.ast.KiePMMLDroolsAST)3 KiePMMLOriginalTypeGeneratedType (org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType)3 StaticJavaParser.parseImport (com.github.javaparser.StaticJavaParser.parseImport)2 IOException (java.io.IOException)2 Collection (java.util.Collection)2