beliefSet.remove( node.getJustifierEntry() );
if ( beliefSet.isEmpty() ) {
if ( wasNegated ) {
defEP.getObjectStore().addHandle( beliefSet.getFactHandle(), beliefSet.getFactHandle().getObject() ); // was negated, so add back in, so main retract works
InternalFactHandle fh = jtmsBeliefSet.getNegativeFactHandle();
((NamedEntryPoint) fh.getEntryPoint()).delete( fh, (Rule) context.getRuleOrigin(), node.getJustifier() );
}
if ( !(context.getType() == PropagationContext.DELETION && context.getFactHandle() == beliefSet.getFactHandle()) ) { // don't start retract, if the FH is already in the process of being retracted
// do not if the FH is the root of the context, it means it's already in the process of retraction
InternalFactHandle fh = jtmsBeliefSet.getFactHandle();
((NamedEntryPoint) fh.getEntryPoint()).delete( fh, (Rule) context.getRuleOrigin(), node.getJustifier() );
}
} else if ( wasConflicting && !jtmsBeliefSet.isUndecided() ) {
insertBelief( node,
defEP.getObjectTypeConfigurationRegistry().getObjectTypeConf( defEP.getEntryPoint(), node.getObject() ),
jtmsBeliefSet,
context,
false,
wasNegated,
wasConflicting );
} else if ( primeChanged ) {
// we know there must be at least one more of the same type, as they are still in conflict
String value;
InternalFactHandle handle;
Object object = null;
if ( jtmsBeliefSet.isNegated() ) {
if ( ! wasNegated ) {
jtmsBeliefSet.setNegativeFactHandle( jtmsBeliefSet.getPositiveFactHandle() );
jtmsBeliefSet.setPositiveFactHandle( null );
}
value = MODE.NEGATIVE.getId();
handle = jtmsBeliefSet.getNegativeFactHandle();
// Find the new node, and update the handle to it, Negatives iterate from the last
for ( LinkedListEntry<LogicalDependency> entry = (LinkedListEntry<LogicalDependency>) jtmsBeliefSet.getLast(); entry != null; entry = (LinkedListEntry<LogicalDependency>) entry.getPrevious() ) {
if ( entry.getObject().getValue().equals( value ) ) {
object = entry.getObject().getObject();
break;
}
}
} else {
if ( wasNegated ) {
jtmsBeliefSet.setPositiveFactHandle( jtmsBeliefSet.getNegativeFactHandle() );
jtmsBeliefSet.setNegativeFactHandle( null );
}
value = MODE.POSITIVE.getId();
handle = jtmsBeliefSet.getPositiveFactHandle();
// Find the new node, and update the handle to it, Positives iterate from the front
for ( LinkedListEntry<LogicalDependency> entry = (LinkedListEntry<LogicalDependency>) jtmsBeliefSet.getFirst(); entry != null; entry = (LinkedListEntry<LogicalDependency>) entry.getNext() ) {
if ( entry.getObject().getValue() == null || entry.getObject().getValue().equals( value ) ) {
object = entry.getObject().getObject();
break;
}
}
}
// Equality might have changed on the object, so remove (which uses the handle id) and add back in
if ( handle.getObject() != object ) {
((NamedEntryPoint) handle.getEntryPoint()).getObjectStore().updateHandle( handle, object );
((NamedEntryPoint) handle.getEntryPoint() ).update( handle, true, handle.getObject(), Long.MAX_VALUE, Object.class, null );
}
}
}