public void handleEvent(SocialEvent e, Object... args) {
logger.debug("Updating for Participant");
if (e.getElementChanged().getElType() == SocialStateElementType.LOGICAL_EXPRESSION
&& e.getElementChanged().toString().contains("cfp")) {
logger.debug("CFP event perceived.");
RoleMessage cfp = participant.receive(ACLMessage.CFP);
t = (Task) (cfp.getContents());
logger.debug("Task message received");
// analisi del task e preparazione della proposal in base a
// qualche criterio
p = createProposal(t);
participant.propose(p, cfp.getRoleSender());
}
else if (e.getElementChanged().getElType() == SocialStateElementType.LOGICAL_EXPRESSION
&& e.getElementChanged().toString().contains("accept")) {
RoleMessage accept = participant
.receive(ACLMessage.ACCEPT_PROPOSAL);
// eventuali valutazioni
if (elaborateTask(t))
participant.done(t, accept.getRoleSender());
else
participant.failure(accept.getRoleSender());
}
else if (e.getElementChanged().getElType() == SocialStateElementType.LOGICAL_EXPRESSION
&& e.getElementChanged().toString().contains("reject")) {
RoleMessage reject = participant
.receive(ACLMessage.REJECT_PROPOSAL);
logger.debug("Proposal Rejected.");
}
logger.debug("Updating done for Participant");
}