@Override
public void handleEvent(SocialEvent e, Object... args) {
//logger.debug("Participant Handle by: "+participant.getRoleId()+"\n"+e);
if (e.getElementChanged().getElType() == SocialStateElementType.COMMITMENT) {
Commitment c = (Commitment) e.getElementChanged();
if (c.getLifeCycleStatus() == LifeCycleState.CONDITIONAL) {
try {
if (c.getCreditor().equals(participant.getRoleId())
&& c.getDebtor().equals(
new RoleId(
CNPArtifactTimerMaxPart.INITIATOR_ROLE,
RoleId.GENERIC_ROLE))
&& c.getConsequent().equals(
new CompositeExpression(
LogicalOperatorType.OR,
new Fact("accept"), new Fact(
"reject")))) {
myAgent.addBehaviour(commitToDoneOrFailureIfAccept());
}
} catch (MissingOperandException
| WrongOperandsNumberException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
else if (c.getLifeCycleStatus() == LifeCycleState.DETACHED) {
try {
if (c.getDebtor().equals(participant.getRoleId())
&& c.getCreditor().equals(
new RoleId(
CNPArtifactTimerMaxPart.INITIATOR_ROLE,
RoleId.GENERIC_ROLE))
&& c.getConsequent().equals(
new CompositeExpression(
LogicalOperatorType.OR,
new Fact("done"), new Fact(
"failure")))) {
myAgent.addBehaviour(fulfilledCommitToAcceptOrReject());