use of org.drools.core.rule.TypeDeclaration in project drools by kiegroup.
the class NamedEntryPoint method update.
public void update(FactHandle handle, Object object, String... modifiedProperties) {
Class modifiedClass = object.getClass();
TypeDeclaration typeDeclaration = kBase.getOrCreateExactTypeDeclaration(modifiedClass);
BitMask mask = typeDeclaration.isPropertyReactive() ? calculatePositiveMask(modifiedClass, asList(modifiedProperties), typeDeclaration.getAccessibleProperties()) : AllSetBitMask.get();
update((InternalFactHandle) handle, object, mask, modifiedClass, null);
}
use of org.drools.core.rule.TypeDeclaration 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.rule.TypeDeclaration in project drools by kiegroup.
the class KnowledgePackageImpl method removeTypesGeneratedFromResource.
public List<TypeDeclaration> removeTypesGeneratedFromResource(Resource resource) {
List<TypeDeclaration> typesToBeRemoved = getTypesGeneratedFromResource(resource);
if (!typesToBeRemoved.isEmpty()) {
JavaDialectRuntimeData dialect = (JavaDialectRuntimeData) getDialectRuntimeRegistry().getDialectData("java");
for (TypeDeclaration type : typesToBeRemoved) {
if (type.getTypeClassName() != null) {
// the type declaration might not have been built up to actual class, if an error was found first
// in this case, no accessor would have been wired
classFieldAccessorStore.removeType(type);
dialect.remove(type.getTypeClassName());
if (typeResolver != null) {
typeResolver.registerClass(type.getTypeClassName(), null);
}
}
removeTypeDeclaration(type.getTypeName());
}
dialect.reload();
}
return typesToBeRemoved;
}
use of org.drools.core.rule.TypeDeclaration 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();
}
use of org.drools.core.rule.TypeDeclaration in project drools by kiegroup.
the class TraitRegistry method init.
private void init() {
TypeDeclaration thingType = new TypeDeclaration(Thing.class.getName());
thingType.setKind(TypeDeclaration.Kind.TRAIT);
thingType.setTypeClass(Thing.class);
ClassDefinition def = new ClassDefinition();
def.setClassName(thingType.getTypeClass().getName());
def.setDefinedClass(Thing.class);
addTrait(def);
ClassDefinition individualDef = new ClassDefinition();
individualDef.setClassName(Entity.class.getName());
individualDef.setDefinedClass(Entity.class);
individualDef.setInterfaces(new String[] { Serializable.class.getName(), TraitableBean.class.getName() });
individualDef.setTraitable(true);
addTraitable(individualDef);
ClassDefinition mapcoreDef = new ClassDefinition();
mapcoreDef.setClassName(MapCore.class.getName());
mapcoreDef.setDefinedClass(MapCore.class);
mapcoreDef.setInterfaces(new String[] { Serializable.class.getName(), TraitableBean.class.getName(), CoreWrapper.class.getName() });
mapcoreDef.setTraitable(true);
addTraitable(mapcoreDef);
ClassDefinition logicalMapcoreDef = new ClassDefinition();
logicalMapcoreDef.setClassName(LogicalMapCore.class.getName());
logicalMapcoreDef.setDefinedClass(LogicalMapCore.class);
logicalMapcoreDef.setInterfaces(new String[] { Serializable.class.getName(), TraitableBean.class.getName(), CoreWrapper.class.getName() });
logicalMapcoreDef.setTraitable(true, true);
addTraitable(logicalMapcoreDef);
}
Aggregations