
jadex.bdi.examples.booktrading.seller.ExecuteOrderPlan Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-bdi Show documentation
Show all versions of jadex-applications-bdi Show documentation
The Jadex BDI applications package contain
several example applications, benchmarks and
testcases using BDI agents.
The newest version!
package jadex.bdi.examples.booktrading.seller;
import jadex.bdi.examples.booktrading.common.NegotiationReport;
import jadex.bdi.examples.booktrading.common.Order;
import jadex.bdi.runtime.Plan;
import java.util.Date;
/**
* Execute the order by setting execution price and date.
*/
public class ExecuteOrderPlan extends Plan
{
/**
* The body method is called on the
* instatiated plan instance from the scheduler.
*/
public void body()
{
// Extract order data.
Integer price = (Integer)getParameter("proposal").getValue();
Order order = (Order)getParameter("proposal_info").getValue();
// getLogger().info("Execute order plan: "+price+" "+order);
// Initiate payment and delivery.
// IGoal pay = createGoal("payment");
// pay.getParameter("order").setValue(order);
// dispatchSubgoalAndWait(pay);
// IGoal delivery = createGoal("delivery");
// delivery.getParameter("order").setValue(order);
// dispatchSubgoalAndWait(delivery);
// Save successful transaction data.
order.setState(Order.DONE);
order.setExecutionPrice(price);
order.setExecutionDate(new Date(getTime()));
String report = "Sold for: "+price;
NegotiationReport nr = new NegotiationReport(order, report, getTime());
getBeliefbase().getBeliefSet("negotiation_reports").addFact(nr);
getParameter("result").setValue(price);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy