use of org.drools.core.definitions.InternalKnowledgePackage in project drools by kiegroup.
the class KnowledgeBaseImpl method getFactType.
public FactType getFactType(String packageName, String typeName) {
String name = packageName + "." + typeName;
readLock();
try {
for (InternalKnowledgePackage pkg : this.pkgs.values()) {
FactType type = pkg.getFactType(name);
if (type != null) {
return type;
}
}
return null;
} finally {
readUnlock();
}
}
use of org.drools.core.definitions.InternalKnowledgePackage in project drools by kiegroup.
the class KnowledgeBaseImpl method processAllTypesDeclaration.
public void processAllTypesDeclaration(List<InternalKnowledgePackage> pkgs) {
List<TypeDeclaration> allTypeDeclarations = new ArrayList<TypeDeclaration>();
// Add all Type Declarations, this has to be done first incase packages cross reference each other during build process.
for (InternalKnowledgePackage newPkg : pkgs) {
// we have to do this before the merging, as it does some classloader resolving
if (newPkg.getTypeDeclarations() != null) {
allTypeDeclarations.addAll(newPkg.getTypeDeclarations().values());
}
}
Collections.sort(allTypeDeclarations);
String lastType = null;
try {
// add type declarations according to the global order
for (TypeDeclaration newDecl : allTypeDeclarations) {
lastType = newDecl.getTypeClassName();
InternalKnowledgePackage newPkg = null;
for (InternalKnowledgePackage kpkg : pkgs) {
if (kpkg.getTypeDeclarations().containsKey(newDecl.getTypeName())) {
newPkg = kpkg;
break;
}
}
processTypeDeclaration(newDecl, newPkg);
}
} catch (ClassNotFoundException e) {
throw new RuntimeException("unable to resolve Type Declaration class '" + lastType + "'", e);
}
}
use of org.drools.core.definitions.InternalKnowledgePackage in project drools by kiegroup.
the class KnowledgeBaseImpl method removeRule.
public void removeRule(final String packageName, final String ruleName) {
enqueueModification(() -> {
final InternalKnowledgePackage pkg = pkgs.get(packageName);
if (pkg == null) {
throw new IllegalArgumentException("Package name '" + packageName + "' does not exist for this Rule Base.");
}
RuleImpl rule = pkg.getRule(ruleName);
if (rule == null) {
throw new IllegalArgumentException("Rule name '" + ruleName + "' does not exist in the Package '" + packageName + "'.");
}
this.eventSupport.fireBeforeRuleRemoved(rule);
this.reteooBuilder.removeRules(Collections.singletonList(rule));
this.eventSupport.fireAfterRuleRemoved(rule);
pkg.removeRule(rule);
addReloadDialectDatas(pkg.getDialectRuntimeRegistry());
});
}
use of org.drools.core.definitions.InternalKnowledgePackage in project drools by kiegroup.
the class PhreakPropagationContext method getAccessibleProperties.
private List<String> getAccessibleProperties(InternalWorkingMemory workingMemory, Class<?> classType, String pkgName) {
if (pkgName.equals("java.lang") || pkgName.equals("java.util")) {
return Collections.EMPTY_LIST;
}
InternalKnowledgePackage pkg = workingMemory.getKnowledgeBase().getPackage(pkgName);
TypeDeclaration tdecl = pkg != null ? pkg.getTypeDeclaration(classType) : null;
return tdecl != null ? tdecl.getAccessibleProperties() : Collections.EMPTY_LIST;
}
use of org.drools.core.definitions.InternalKnowledgePackage in project drools by kiegroup.
the class TraitField method inspectForTraitability.
private boolean inspectForTraitability(Object value, WorkingMemory wm) {
InternalKnowledgePackage pack = wm.getKnowledgeBase().getPackage(value.getClass().getPackage().getName());
if (pack != null) {
TypeDeclaration decl = pack.getTypeDeclaration(value.getClass());
if (decl != null) {
return decl.getTypeClassDef().isFullTraiting();
}
}
Traitable tbl = value.getClass().getAnnotation(Traitable.class);
return tbl != null && tbl.logical();
}
Aggregations