use of org.drools.core.definitions.InternalKnowledgePackage in project drools by kiegroup.
the class KnowledgeBaseImpl method addPackages.
/**
* Add a <code>Package</code> to the network. Iterates through the
* <code>Package</code> adding Each individual <code>Rule</code> to the
* network. Before update network each referenced <code>WorkingMemory</code>
* is locked.
*
* @param newPkgs The package to add.
*/
@Override
public void addPackages(Collection<KiePackage> newPkgs) {
final List<InternalKnowledgePackage> clonedPkgs = new ArrayList<InternalKnowledgePackage>();
for (KiePackage newPkg : newPkgs) {
clonedPkgs.add(((InternalKnowledgePackage) newPkg).deepCloneIfAlreadyInUse(rootClassLoader));
}
enqueueModification(() -> internalAddPackages(clonedPkgs));
}
use of org.drools.core.definitions.InternalKnowledgePackage in project drools by kiegroup.
the class TraitFactory method getClassFieldAccessorStore.
protected ClassFieldAccessorStore getClassFieldAccessorStore() {
InternalKnowledgePackage traitPackage = kBase.getPackagesMap().get(pack);
if (traitPackage == null) {
traitPackage = new KnowledgePackageImpl(pack);
traitPackage.setClassFieldAccessorCache(kBase.getClassFieldAccessorCache());
kBase.getPackagesMap().put(pack, traitPackage);
}
return traitPackage.getClassFieldAccessorStore();
}
use of org.drools.core.definitions.InternalKnowledgePackage in project drools by kiegroup.
the class DroolsAbstractPMMLTest method getStartingRuleUnit.
protected Class<? extends RuleUnit> getStartingRuleUnit(String startingRule, InternalKnowledgeBase ikb, List<String> possiblePackages) {
RuleUnitRegistry unitRegistry = ikb.getRuleUnitRegistry();
Map<String, InternalKnowledgePackage> pkgs = ikb.getPackagesMap();
RuleImpl ruleImpl = null;
for (String pkgName : possiblePackages) {
if (pkgs.containsKey(pkgName)) {
InternalKnowledgePackage pkg = pkgs.get(pkgName);
ruleImpl = pkg.getRule(startingRule);
if (ruleImpl != null) {
RuleUnitDescr descr = unitRegistry.getRuleUnitFor(ruleImpl).orElse(null);
if (descr != null) {
return descr.getRuleUnitClass();
}
}
}
}
return null;
}
use of org.drools.core.definitions.InternalKnowledgePackage in project drools by kiegroup.
the class PMMLExecutor method startingRuleUnit.
protected Class<? extends RuleUnit> startingRuleUnit(String startingRule, String modelId, String... knownPackageNames) {
List<String> possiblePackages = calculatePossiblePackageNames(modelId, knownPackageNames);
InternalKnowledgeBase internalKnowledgeBase = (InternalKnowledgeBase) kieBase;
RuleUnitRegistry unitRegistry = internalKnowledgeBase.getRuleUnitRegistry();
Map<String, InternalKnowledgePackage> pkgs = internalKnowledgeBase.getPackagesMap();
RuleImpl ruleImpl = null;
for (String pkgName : possiblePackages) {
if (pkgs.containsKey(pkgName)) {
InternalKnowledgePackage pkg = pkgs.get(pkgName);
ruleImpl = pkg.getRule(startingRule);
if (ruleImpl != null) {
RuleUnitDescr descr = unitRegistry.getRuleUnitFor(ruleImpl).orElse(null);
if (descr != null) {
return descr.getRuleUnitClass();
}
}
}
}
return null;
}
use of org.drools.core.definitions.InternalKnowledgePackage in project drools by kiegroup.
the class ModelBuilderImpl method generatePOJOs.
protected void generatePOJOs(PackageDescr packageDescr, PackageRegistry pkgRegistry) {
InternalKnowledgePackage pkg = pkgRegistry.getPackage();
String pkgName = pkg.getName();
PackageModel model = packageModels.computeIfAbsent(pkgName, s -> {
final DialectCompiletimeRegistry dialectCompiletimeRegistry = pkgRegistry.getDialectCompiletimeRegistry();
return new PackageModel(pkgName, this.getBuilderConfiguration(), isPattern, dialectCompiletimeRegistry);
});
model.addImports(pkg.getTypeResolver().getImports());
generatePOJO(pkg, packageDescr, model);
}
Aggregations