use of org.drools.compiler.lang.descr.CompositePackageDescr in project drools by kiegroup.
the class KnowledgeBuilderImpl method buildOtherDeclarations.
protected void buildOtherDeclarations(Collection<CompositePackageDescr> packages) {
for (CompositePackageDescr packageDescr : packages) {
setAssetFilter(packageDescr.getFilter());
PackageRegistry pkgRegistry = getPackageRegistry(packageDescr.getNamespace());
processOtherDeclarations(pkgRegistry, packageDescr);
setAssetFilter(null);
}
}
use of org.drools.compiler.lang.descr.CompositePackageDescr in project drools by kiegroup.
the class KnowledgeBuilderImpl method buildTypeDeclarations.
protected void buildTypeDeclarations(Collection<CompositePackageDescr> packages) {
Map<String, AbstractClassTypeDeclarationDescr> unprocesseableDescrs = new HashMap<>();
List<TypeDefinition> unresolvedTypes = new ArrayList<>();
List<AbstractClassTypeDeclarationDescr> unsortedDescrs = new ArrayList<>();
for (CompositePackageDescr packageDescr : packages) {
unsortedDescrs.addAll(packageDescr.getTypeDeclarations());
unsortedDescrs.addAll(packageDescr.getEnumDeclarations());
}
getTypeBuilder().processTypeDeclarations(packages, unsortedDescrs, unresolvedTypes, unprocesseableDescrs);
for (CompositePackageDescr packageDescr : packages) {
for (ImportDescr importDescr : packageDescr.getImports()) {
getPackageRegistry(packageDescr.getNamespace()).addImport(importDescr);
}
}
}
use of org.drools.compiler.lang.descr.CompositePackageDescr in project drools by kiegroup.
the class KnowledgeBuilderImpl method findChildrenRulesToBeRemoved.
private Collection<RuleImpl> findChildrenRulesToBeRemoved(PackageDescr packageDescr, Collection<RuleImpl> rulesToBeRemoved) {
Collection<String> childrenRuleNamesToBeRemoved = new HashSet<>();
Collection<RuleImpl> childrenRulesToBeRemoved = new HashSet<>();
for (RuleImpl rule : rulesToBeRemoved) {
if (rule.hasChildren()) {
for (RuleImpl child : rule.getChildren()) {
if (!rulesToBeRemoved.contains(child)) {
// if a rule has a child rule not marked to be removed ...
childrenRulesToBeRemoved.add(child);
childrenRuleNamesToBeRemoved.add(child.getName());
// ... remove the child rule but also add it back to the PackageDescr in order to readd it when also the parent rule will be readded ...
RuleDescr toBeReadded = new RuleDescr(child.getName());
toBeReadded.setNamespace(packageDescr.getNamespace());
packageDescr.addRule(toBeReadded);
}
}
}
}
// ... add a filter to the PackageDescr to also consider the readded children rules as updated together with the parent one
if (!childrenRuleNamesToBeRemoved.isEmpty()) {
((CompositePackageDescr) packageDescr).addFilter((type, pkgName, assetName) -> childrenRuleNamesToBeRemoved.contains(assetName) ? AssetFilter.Action.UPDATE : AssetFilter.Action.DO_NOTHING);
}
return childrenRulesToBeRemoved;
}
use of org.drools.compiler.lang.descr.CompositePackageDescr in project drools by kiegroup.
the class KnowledgeBuilderImpl method buildRules.
protected void buildRules(Collection<CompositePackageDescr> packages) {
for (CompositePackageDescr packageDescr : packages) {
setAssetFilter(packageDescr.getFilter());
PackageRegistry pkgRegistry = getPackageRegistry(packageDescr.getNamespace());
compileKnowledgePackages(packageDescr, pkgRegistry);
setAssetFilter(null);
}
wireAllRules();
processKieBaseTypes();
for (CompositePackageDescr packageDescr : packages) {
setAssetFilter(packageDescr.getFilter());
compileRete(packageDescr);
setAssetFilter(null);
}
}
use of org.drools.compiler.lang.descr.CompositePackageDescr in project drools by kiegroup.
the class ModelBuilderImpl method buildRules.
protected void buildRules(Collection<CompositePackageDescr> packages) {
if (hasErrors()) {
// if Error while generating pojo do not try compile rule as they very likely depends hence fail too.
return;
}
for (CompositePackageDescr packageDescr : packages) {
setAssetFilter(packageDescr.getFilter());
PackageRegistry pkgRegistry = getPackageRegistry(packageDescr.getNamespace());
compileKnowledgePackages(packageDescr, pkgRegistry);
setAssetFilter(null);
PackageModel pkgModel = packageModels.remove(pkgRegistry.getPackage().getName());
pkgModel.setOneClassPerRule(oneClassPerRule);
if (getResults(ResultSeverity.ERROR).isEmpty()) {
packageSources.put(pkgModel.getName(), sourcesGenerator.apply(pkgModel));
}
}
}
Aggregations