本文整理汇总了Java中org.drools.runtime.rule.FactHandle类的典型用法代码示例。如果您正苦于以下问题:Java FactHandle类的具体用法?Java FactHandle怎么用?Java FactHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FactHandle类属于org.drools.runtime.rule包,在下文中一共展示了FactHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exec
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
@Override
public void exec(FrameTask ctx) {
StatefulKnowledgeSession kbsess = kb.newStatefulKnowledgeSession();
try {
// this knowledge session will be the session for all Drools rules
kbsess.insert(ctx.getTriggerEvent());
kbsess.setGlobal("DAO", ctx.getResource(IGenericPatientObjectDAO.class));
kbsess.fireAllRules();
// Harvest all the actions out of working memory
ObjectFilter frameActionFilter = new ObjectFilter() {
@Override
public boolean accept(Object object) {
return object instanceof FrameAction;
}
};
Collection<FactHandle> actions = kbsess.getFactHandles(frameActionFilter);
for (FactHandle handle : actions) {
FrameAction action = (FrameAction) kbsess.getObject(handle);
ctx.addAction(action);
}
} finally {
// clear working memory for next transaction
kbsess.dispose();
}
}
示例2: updateFact
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
@Override
public synchronized void updateFact(Object objeto) {
if (depuracionHechosModificados)
trazas.aceptaNuevaTraza(new InfoTraza(agentId,"MRuleEngine: new fact updated: "+ objeto,
InfoTraza.NivelTraza.debug));
if (objeto==null){
trazas.aceptaNuevaTraza(new InfoTraza(agentId, "Motor de Reglas : Se intenta insertar en el motor un objeto null : ",
InfoTraza.NivelTraza.error));
}else {
FactHandle fh2 = entrypoint.insert(objeto);
entrypoint.update(fh2,objeto);
kSesion.fireAllRules();
}
}
示例3: printFactHandlesMonitoring
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
private void printFactHandlesMonitoring(String str, String rule){
Collection<FactHandle> cFH;
String s;
Iterator it;
cFH = kSesion.getFactHandles();
s = "";
it = cFH.iterator();
while( it.hasNext() ) {
s = s + " \n " + it.next() ;
}
if (str.equals("afterActivationFired")){
s = s + " \n ";
}
String info = "FactHandles WM _ " + str + " dispararse la regla " + rule +
"( current size="+ kSesion.getFactHandles().size() + "): " + s + "\n";
try {
// this.itfUsoRecursoDepuracionCognitivo.mostrarInfoAR(info);
trazas.aceptaNuevaTrazaActivReglas(agentId, info);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例4: printFacts
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
public static void printFacts(StatefulKnowledgeSession ksession) {
if (enabledDebugMode){
for (FactHandle f: ksession.getFactHandles()){
System.out.println(" "+ksession.getObject(f));
}
}
}
示例5: variableChanged
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
@Override
public void variableChanged(ReasonerVariable rVariable) {
// Iterator<FactHandle> factIterator = session.getFactHandles().iterator();
// while (factIterator.hasNext()) {
// FactHandle fact = factIterator.next();
// ReasonerVariable var = (ReasonerVariable) session.getObject(fact);
// System.out.println(var.getName());
// }
FactHandle fact = null;
try {
if (rVariable.getParent() == null) {
fact = session.getFactHandle(rVariable);
session.update(fact, rVariable);
LOGGER.debug("No parrent: " + session.getFactHandle(rVariable).toString()
+ " : " + rVariable.getName());
} else {
fact = session.getFactHandle(rVariable.getParent());
rVariable = rVariable.getParent();
session.update(fact, rVariable);
LOGGER.debug("Parent: " + session.getFactHandle(rVariable));
}
} finally {
LOGGER.debug("Updating: " + rVariable.getName());
}
}
示例6: addItem
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
public OrderLineDTO addItem(Integer itemID, BigDecimal quantity) throws TaskException {
LOG.debug("Adding item %s q: %s", itemID, quantity);
BasicItemManager helper = new BasicItemManager();
OrderLineDTO oldLine = order.getLine(itemID);
FactHandle h = null;
if (oldLine != null) {
h = handlers.get(oldLine);
}
helper.addItem(itemID, quantity, language, userId, entityId, currencyId, order, records);
OrderLineDTO retValue = helper.getLatestLine();
if (h != null) {
LOG.debug("updating");
session.update(h, retValue);
} else {
LOG.debug("inserting");
handlers.put(retValue, session.insert(retValue));
}
LOG.debug("Now order line is %s , hash: %s", retValue, retValue.hashCode());
return retValue;
}
示例7: executeStatefulRules
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
protected void executeStatefulRules(StatefulKnowledgeSession session, List context) {
handlers = new Hashtable<Object, FactHandle>();
for (Object o : context) {
if (o != null) {
LOG.debug("inserting object " + o);
handlers.put(o, session.insert(o));
} else {
LOG.warn("Attempted to insert a NULL object into the working memeory");
}
}
session.fireAllRules();
session.dispose();
handlers.clear();
handlers = null;
}
示例8: retracttFact
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
@Override
public synchronized void retracttFact(Object objeto) {
if (depuracionHechosModificados)
trazas.aceptaNuevaTraza(new InfoTraza( agentId,"MRuleEngine: new fact retracted: "+ objeto,
InfoTraza.NivelTraza.debug) );
if (objeto==null){
trazas.aceptaNuevaTraza(new InfoTraza(agentId, "Motor de Reglas : Se intenta insertar en el motor un objeto null : ",
InfoTraza.NivelTraza.error));
}else {
FactHandle fh2 = entrypoint.insert(objeto);
entrypoint.retract(fh2);
kSesion.fireAllRules();
}
}
示例9: retractFactWithoutFireRules
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
@Override
public synchronized void retractFactWithoutFireRules(Object objeto) {
if (depuracionHechosModificados)
trazas.aceptaNuevaTraza(new InfoTraza(agentId,"MRuleEngine: retractFactWithoutFireRules -> new fact retracted: "+ objeto,
InfoTraza.NivelTraza.debug));
if (objeto==null){
trazas.aceptaNuevaTraza(new InfoTraza(agentId, "Motor de Reglas : Se intenta insertar en el motor un objeto null : ",
InfoTraza.NivelTraza.error));
}else {
FactHandle fh2 = entrypoint.insert(objeto);
entrypoint.retract(fh2);
// kSesion.fireAllRules();
}
}
示例10: updateFactWithoutFireRules
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
@Override
public synchronized void updateFactWithoutFireRules(Object objeto) {
if (depuracionHechosModificados)
trazas.aceptaNuevaTraza(new InfoTraza( agentId,"MRuleEngine: updateFactWithoutFireRules-> new fact updated: "+ objeto,
InfoTraza.NivelTraza.debug));
if (objeto==null){
trazas.aceptaNuevaTraza(new InfoTraza(agentId, "Motor de Reglas : Se intenta insertar en el motor un objeto null : ",
InfoTraza.NivelTraza.error));
}else {
FactHandle fh2 = entrypoint.insert(objeto);
entrypoint.update(fh2,objeto);
// kSesion.fireAllRules();
}
}
示例11: trazarFactHandlesForRuleDebugging
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
private void trazarFactHandlesForRuleDebugging(String ruleId,String beforOrAfterRuleActivation ){
String infoAmostrar= "" ;
Boolean obtenerFactHandles = false;
if (factHandlesMonitoring_beforeActivationFired_DEBUGGING &&
beforOrAfterRuleActivation.equals(NombresPredefinidos.DROOLS_Debugging_BEFORE_RuleFired)){
obtenerFactHandles= true;
infoAmostrar = "FactHandles WM _ ANTES de dispararse la regla " + ruleId +
"( current size="+ kSesion.getFactHandles().size() + "): " +"\n";
}else if (factHandlesMonitoring_afterActivationFired_DEBUGGING &&
beforOrAfterRuleActivation.equals(NombresPredefinidos.DROOLS_Debugging_AFTER_RuleFired)){
obtenerFactHandles= true;
infoAmostrar = "FactHandles WM _ DESPUES de dispararse la regla " + ruleId +
"( current size="+ kSesion.getFactHandles().size() + "): " +"\n";
}
if (obtenerFactHandles){
Collection<FactHandle> cFH;
Iterator it;
cFH = kSesion.getFactHandles();
it = cFH.iterator();
while( it.hasNext() ) {
infoAmostrar = infoAmostrar + it.next()+ " \n " ;
}
try {
// this.itfUsoRecursoDepuracionCognitivo.mostrarInfoAR(infoAmostrar);
trazas.aceptaNuevaTrazaActivReglas(agentId, infoAmostrar);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
示例12: reinicializarSesion
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
@Override
public void reinicializarSesion() {
// Iterator it;
Collection<FactHandle> cFH = kSesion.getFactHandles();
Iterator<FactHandle> it = cFH.iterator();
while( it.hasNext() ) {
kSesion.retract(it.next());
}
}
示例13: loadEvents
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
public void loadEvents() {
ScannedRobotEvent e = new ScannedRobotEvent("pepe", 100, 10, 10, 10, 10);
FactHandle referencedFact = ksession.insert(e);
currentReferencedFacts.add(referencedFact);
// add more facts ....
DEBUG.message("Facts in active memory");
DEBUG.printFacts(ksession);
ksession.fireAllRules();
List<Action> actions = loadActions();
DEBUG.message("Resulting actions");
DEBUG.printActions(actions);
}
示例14: cleanAnteriorFacts
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
private void cleanAnteriorFacts() {
DEBUG.message("clean anterior facts");
for (FactHandle referencedFact : this.currentReferencedFacts) {
ksession.retract(referencedFact);
}
this.currentReferencedFacts.clear();
}
示例15: evaluate
import org.drools.runtime.rule.FactHandle; //导入依赖的package包/类
private FactHandle evaluate(StatefulKnowledgeSession ksession, FactHandle handle, Object obj) {
if (handle == null) {
ksession.setGlobal("delegator", new RuleTasksDelegator());
handle = ksession.insert(obj);
} else {
ksession.update(handle, obj);
}
ksession.fireAllRules();
if (log.isDebugEnabled()) {
log.debug(String.format("Rule executed for: %s ", obj));
}
return handle;
}