use of org.kie.soup.project.datamodel.commons.types.TypeResolver in project drools by kiegroup.
the class ModelGenerator method generateModel.
public static void generateModel(KnowledgeBuilderImpl kbuilder, InternalKnowledgePackage pkg, PackageDescr packageDescr, PackageModel packageModel, boolean isPattern) {
TypeResolver typeResolver = pkg.getTypeResolver();
packageModel.addImports(pkg.getTypeResolver().getImports());
packageModel.addGlobals(pkg.getGlobals());
packageModel.addAccumulateFunctions(pkg.getAccumulateFunctions());
packageModel.setInternalKnowledgePackage(pkg);
new WindowReferenceGenerator(packageModel, typeResolver).addWindowReferences(kbuilder, packageDescr.getWindowDeclarations());
packageModel.addAllFunctions(packageDescr.getFunctions().stream().map(FunctionGenerator::toFunction).collect(toList()));
for (RuleDescr descr : packageDescr.getRules()) {
if (descr instanceof QueryDescr) {
QueryGenerator.processQueryDef(kbuilder, typeResolver, packageModel, (QueryDescr) descr, isPattern);
}
}
for (RuleDescr descr : packageDescr.getRules()) {
if (descr instanceof QueryDescr) {
QueryGenerator.processQuery(kbuilder, packageModel, (QueryDescr) descr);
} else {
processRule(kbuilder, typeResolver, packageModel, packageDescr, descr, isPattern);
}
}
}
use of org.kie.soup.project.datamodel.commons.types.TypeResolver in project drools by kiegroup.
the class TypeDeclarationNameResolver method resolveTypes.
public void resolveTypes(Collection<? extends PackageDescr> packageDescrs, List<TypeDefinition> unresolvedTypes) {
for (PackageDescr packageDescr : packageDescrs) {
TypeResolver typeResolver = kbuilder.getPackageRegistry(packageDescr.getName()).getTypeResolver();
ensureQualifiedDeclarationName(unresolvedTypes, packageDescr, typeResolver);
}
for (PackageDescr packageDescr : packageDescrs) {
TypeResolver typeResolver = kbuilder.getPackageRegistry(packageDescr.getName()).getTypeResolver();
qualifyNames(unresolvedTypes, packageDescr, typeResolver);
}
}
use of org.kie.soup.project.datamodel.commons.types.TypeResolver in project drools by kiegroup.
the class ClassTypeResolverTest method testResolveFullTypeName.
@Test
public void testResolveFullTypeName() throws Exception {
final TypeResolver resolver = new ClassTypeResolver(new HashSet(), Thread.currentThread().getContextClassLoader());
resolver.addImport("org.drools.core.test.model.Cheese");
resolver.addImport("org.drools.core.test.model.FirstClass");
assertEquals("org.drools.core.test.model.Cheese", resolver.getFullTypeName("Cheese"));
assertEquals("org.drools.core.test.model.FirstClass", resolver.getFullTypeName("FirstClass"));
}
use of org.kie.soup.project.datamodel.commons.types.TypeResolver in project drools by kiegroup.
the class GeneratorHelper method getTypeResolver.
static TypeResolver getTypeResolver(final InvokerStub stub, final WorkingMemory workingMemory, final ClassLoader classLoader) {
InternalKnowledgePackage pkg = workingMemory.getKnowledgeBase().getPackage(stub.getPackageName());
TypeResolver typeResolver = pkg == null ? null : pkg.getTypeResolver();
if (typeResolver == null) {
Set<String> imports = new HashSet<String>();
for (String imp : stub.getPackageImports()) {
imports.add(imp);
}
typeResolver = new ClassTypeResolver(imports, classLoader, stub.getPackageName());
}
return typeResolver;
}
Aggregations