bdi4jade

Details

diff --git a/bdi-jade/.classpath b/bdi-jade/.classpath
index fcca24e..c21aed9 100644
--- a/bdi-jade/.classpath
+++ b/bdi-jade/.classpath
@@ -7,5 +7,6 @@
 	<classpathentry kind="lib" path="lib/jade-4.3.2.jar"/>
 	<classpathentry kind="lib" path="lib/commons-logging-1.1.3.jar"/>
 	<classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
+	<classpathentry kind="lib" path="/bdi-jade-extensions/lib/weka.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/bdi-jade/models/bdi4jade-models.asta b/bdi-jade/models/bdi4jade-models.asta
index 539b846..8440024 100644
Binary files a/bdi-jade/models/bdi4jade-models.asta and b/bdi-jade/models/bdi4jade-models.asta differ
diff --git a/bdi-jade-test/src/bdi4jade/examples/capabilities/AssociatedMiddle1Capability.java b/bdi-jade-test/src/bdi4jade/examples/capabilities/AssociatedMiddle1Capability.java
new file mode 100644
index 0000000..c1bacf8
--- /dev/null
+++ b/bdi-jade-test/src/bdi4jade/examples/capabilities/AssociatedMiddle1Capability.java
@@ -0,0 +1,60 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011  Ingrid Nunes
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+// 
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+
+package bdi4jade.examples.capabilities;
+
+import bdi4jade.annotation.GoalOwner;
+import bdi4jade.annotation.TransientBelief;
+import bdi4jade.goal.Goal;
+import bdi4jade.plan.DefaultPlan;
+import bdi4jade.plan.Plan;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class AssociatedMiddle1Capability extends
+		AssociatedMiddle1ParentCapability {
+
+	@GoalOwner(capability = AssociatedMiddle1Capability.class, internal = false)
+	public static class AssociatedMiddle1ExternalGoal implements Goal {
+		private static final long serialVersionUID = 7656633869373580240L;
+	}
+
+	@GoalOwner(capability = AssociatedMiddle1Capability.class, internal = true)
+	public static class AssociatedMiddle1InternalGoal implements Goal {
+		private static final long serialVersionUID = 7656633869373580240L;
+	}
+
+	private static final long serialVersionUID = 377413312476720846L;
+
+	@TransientBelief
+	private String associatedMiddle1Belief = "ASSOCIATED_MIDDLE_1_BELIEF";
+
+	@bdi4jade.annotation.Plan
+	private Plan externalGoalPlan = new DefaultPlan(
+			AssociatedMiddle1ExternalGoal.class, SuccessPlanBody.class);
+
+	@bdi4jade.annotation.Plan
+	private Plan internalGoalPlan = new DefaultPlan(
+			AssociatedMiddle1InternalGoal.class, SuccessPlanBody.class);
+
+}
diff --git a/bdi-jade-test/src/bdi4jade/examples/capabilities/AssociatedMiddle1ParentCapability.java b/bdi-jade-test/src/bdi4jade/examples/capabilities/AssociatedMiddle1ParentCapability.java
new file mode 100644
index 0000000..16ea017
--- /dev/null
+++ b/bdi-jade-test/src/bdi4jade/examples/capabilities/AssociatedMiddle1ParentCapability.java
@@ -0,0 +1,61 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011  Ingrid Nunes
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+// 
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+
+package bdi4jade.examples.capabilities;
+
+import bdi4jade.annotation.GoalOwner;
+import bdi4jade.annotation.TransientBelief;
+import bdi4jade.core.Capability;
+import bdi4jade.goal.Goal;
+import bdi4jade.plan.DefaultPlan;
+import bdi4jade.plan.Plan;
+
+/**
+ * @author Ingrid Nunes
+ *
+ */
+public class AssociatedMiddle1ParentCapability extends Capability {
+
+	@GoalOwner(capability = AssociatedMiddle1ParentCapability.class, internal = false)
+	public static class AssociatedMiddle1ParentExternalGoal implements Goal {
+		private static final long serialVersionUID = 7656633869373580240L;
+	}
+
+	@GoalOwner(capability = AssociatedMiddle1ParentCapability.class, internal = true)
+	public static class AssociatedMiddle1ParentInternalGoal implements Goal {
+		private static final long serialVersionUID = 7656633869373580240L;
+	}
+
+	private static final long serialVersionUID = 377413312476720846L;
+
+	@TransientBelief
+	private String associatedMiddle1ParentBelief = "ASSOCIATED_MIDDLE_1_PARENT_BELIEF";
+
+	@bdi4jade.annotation.Plan
+	private Plan externalGoalPlan = new DefaultPlan(
+			AssociatedMiddle1ParentExternalGoal.class, SuccessPlanBody.class);
+
+	@bdi4jade.annotation.Plan
+	private Plan internalGoalPlan = new DefaultPlan(
+			AssociatedMiddle1ParentInternalGoal.class, SuccessPlanBody.class);
+
+}
diff --git a/bdi-jade-test/src/bdi4jade/examples/capabilities/AssociatedTopCapability.java b/bdi-jade-test/src/bdi4jade/examples/capabilities/AssociatedTopCapability.java
new file mode 100644
index 0000000..665944b
--- /dev/null
+++ b/bdi-jade-test/src/bdi4jade/examples/capabilities/AssociatedTopCapability.java
@@ -0,0 +1,60 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011  Ingrid Nunes
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+// 
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+
+package bdi4jade.examples.capabilities;
+
+import bdi4jade.annotation.GoalOwner;
+import bdi4jade.annotation.TransientBelief;
+import bdi4jade.core.Capability;
+import bdi4jade.goal.Goal;
+import bdi4jade.plan.DefaultPlan;
+import bdi4jade.plan.Plan;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class AssociatedTopCapability extends Capability {
+
+	@GoalOwner(capability = AssociatedTopCapability.class, internal = false)
+	public static class AssociatedTopExternalGoal implements Goal {
+		private static final long serialVersionUID = 7656633869373580240L;
+	}
+
+	@GoalOwner(capability = AssociatedTopCapability.class, internal = true)
+	public static class AssociatedTopInternalGoal implements Goal {
+		private static final long serialVersionUID = 7656633869373580240L;
+	}
+
+	private static final long serialVersionUID = 377413312476720846L;
+
+	@TransientBelief
+	private String associatedTopBelief = "ASSOCIATED_TOP_BELIEF";
+
+	@bdi4jade.annotation.Plan
+	private Plan externalGoalPlan = new DefaultPlan(
+			AssociatedTopExternalGoal.class, SuccessPlanBody.class);
+
+	@bdi4jade.annotation.Plan
+	private Plan internalGoalPlan = new DefaultPlan(
+			AssociatedTopInternalGoal.class, SuccessPlanBody.class);
+
+}
diff --git a/bdi-jade-test/src/bdi4jade/examples/capabilities/Middle1Capability.java b/bdi-jade-test/src/bdi4jade/examples/capabilities/Middle1Capability.java
index 9d34f90..380944a 100644
--- a/bdi-jade-test/src/bdi4jade/examples/capabilities/Middle1Capability.java
+++ b/bdi-jade-test/src/bdi4jade/examples/capabilities/Middle1Capability.java
@@ -22,8 +22,8 @@
 
 package bdi4jade.examples.capabilities;
 
+import bdi4jade.annotation.AssociatedCapability;
 import bdi4jade.annotation.GoalOwner;
-import bdi4jade.annotation.PartCapability;
 import bdi4jade.annotation.TransientBelief;
 import bdi4jade.core.Capability;
 import bdi4jade.goal.Goal;
@@ -63,6 +63,9 @@ public class Middle1Capability extends Middle1ParentCapability {
 	@TransientBelief
 	private String middle1Belief = "MIDDLE1_BELIEF";
 
+	@AssociatedCapability
+	private Capability associatedMiddle1Capability = new AssociatedMiddle1Capability();
+
 	@bdi4jade.annotation.Plan
 	private Plan testPlan = new DefaultPlan(TestGoal.class, TestPlanBody.class);
 
diff --git a/bdi-jade-test/src/bdi4jade/examples/capabilities/TestPlanBody.java b/bdi-jade-test/src/bdi4jade/examples/capabilities/TestPlanBody.java
index 2bfc753..9665093 100644
--- a/bdi-jade-test/src/bdi4jade/examples/capabilities/TestPlanBody.java
+++ b/bdi-jade-test/src/bdi4jade/examples/capabilities/TestPlanBody.java
@@ -38,7 +38,7 @@ import bdi4jade.plan.planbody.AbstractPlanBody;
 public class TestPlanBody extends AbstractPlanBody {
 
 	enum TestStep {
-		BELIEF, BOTTOM_EXTERNAL_GOAL, BOTTOM_INTERNAL_GOAL, COMPLETED, MIDDLE2_EXTERNAL_GOAL, MY_EXTERNAL_GOAL, MY_INTERNAL_GOAL, MY_PARENT_INTERNAL_GOAL, TOP_EXTERNAL_GOAL, TOP_INTERNAL_GOAL, TOP_PARENT_INTERNAL_GOAL;
+		BELIEF, BOTTOM_EXTERNAL_GOAL, BOTTOM_INTERNAL_GOAL, COMPLETED, MIDDLE2_EXTERNAL_GOAL, MY_EXTERNAL_GOAL, MY_INTERNAL_GOAL, MY_PARENT_INTERNAL_GOAL, TOP_EXTERNAL_GOAL, TOP_INTERNAL_GOAL, TOP_PARENT_INTERNAL_GOAL, ASSOCIATED_MIDDLE_1_INTERNAL_GOAL, ASSOCIATED_MIDDLE_1_EXTERNAL_GOAL, ASSOCIATED_MIDDLE_1_PARENT_INTERNAL_GOAL, ASSOCIATED_MIDDLE_1_PARENT_EXTERNAL_GOAL, ASSOCIATED_TOP_INTERNAL_GOAL, ASSOCIATED_TOP_EXTERNAL_GOAL;
 	}
 
 	private static final Log log = LogFactory.getLog(TestPlanBody.class);
@@ -57,6 +57,12 @@ public class TestPlanBody extends AbstractPlanBody {
 	private Belief<String, String> topBelief;
 	@bdi4jade.annotation.Belief
 	private Belief<String, String> topParentBelief;
+	@bdi4jade.annotation.Belief
+	private Belief<String, String> associatedMiddle1Belief;
+	@bdi4jade.annotation.Belief
+	private Belief<String, String> associatedMiddle1ParentBelief;
+	@bdi4jade.annotation.Belief
+	private Belief<String, String> associatedTopBelief;
 
 	public void action() {
 		switch (step) {
@@ -70,6 +76,10 @@ public class TestPlanBody extends AbstractPlanBody {
 			log.info("These should be null:");
 			log.info("middle2Belief: " + middle2Belief);
 			log.info("bottomBelief: " + bottomBelief);
+			log.info("associatedTopBelief: " + associatedTopBelief);
+			log.info("associatedMiddle1Belief: " + associatedMiddle1Belief);
+			log.info("associatedMiddle1ParentBelief: "
+					+ associatedMiddle1ParentBelief);
 
 			log.info("Testing plans...");
 			dispatchSubgoalAndListen(new Middle1Capability.Middle1ExternalGoal());
@@ -152,6 +162,46 @@ public class TestPlanBody extends AbstractPlanBody {
 			this.step = TestStep.BOTTOM_INTERNAL_GOAL;
 			break;
 		case BOTTOM_INTERNAL_GOAL:
+			dispatchSubgoalAndListen(new AssociatedMiddle1Capability.AssociatedMiddle1ExternalGoal());
+			this.step = TestStep.ASSOCIATED_MIDDLE_1_EXTERNAL_GOAL;
+			break;
+		case ASSOCIATED_MIDDLE_1_EXTERNAL_GOAL:
+			goalEvent = getGoalEvent();
+			if (goalEvent == null) {
+				return;
+			} else {
+				printGoal(goalEvent, true);
+				Goal goal = new AssociatedMiddle1Capability.AssociatedMiddle1InternalGoal();
+				printGoal(goal, dispatchSubgoal(goal), false);
+			}
+			this.step = TestStep.ASSOCIATED_MIDDLE_1_INTERNAL_GOAL;
+			break;
+		case ASSOCIATED_MIDDLE_1_INTERNAL_GOAL:
+			dispatchSubgoalAndListen(new AssociatedMiddle1ParentCapability.AssociatedMiddle1ParentExternalGoal());
+			this.step = TestStep.ASSOCIATED_MIDDLE_1_PARENT_EXTERNAL_GOAL;
+			break;
+		case ASSOCIATED_MIDDLE_1_PARENT_EXTERNAL_GOAL:
+			goalEvent = getGoalEvent();
+			if (goalEvent == null) {
+				return;
+			} else {
+				printGoal(goalEvent, true);
+				Goal goal = new AssociatedMiddle1ParentCapability.AssociatedMiddle1ParentInternalGoal();
+				printGoal(goal, dispatchSubgoal(goal), false);
+			}
+			this.step = TestStep.ASSOCIATED_MIDDLE_1_PARENT_INTERNAL_GOAL;
+			break;
+		case ASSOCIATED_MIDDLE_1_PARENT_INTERNAL_GOAL:
+			Goal goal = new AssociatedTopCapability.AssociatedTopExternalGoal();
+			printGoal(goal, dispatchSubgoal(goal), false);
+			this.step = TestStep.ASSOCIATED_TOP_EXTERNAL_GOAL;
+			break;
+		case ASSOCIATED_TOP_EXTERNAL_GOAL:
+			goal = new AssociatedTopCapability.AssociatedTopInternalGoal();
+			printGoal(goal, dispatchSubgoal(goal), false);
+			this.step = TestStep.ASSOCIATED_TOP_INTERNAL_GOAL;
+			break;
+		case ASSOCIATED_TOP_INTERNAL_GOAL:
 			this.step = TestStep.COMPLETED;
 			break;
 		case COMPLETED:
diff --git a/bdi-jade-test/src/bdi4jade/examples/capabilities/TopCapability.java b/bdi-jade-test/src/bdi4jade/examples/capabilities/TopCapability.java
index 3dfec01..da6c8c2 100644
--- a/bdi-jade-test/src/bdi4jade/examples/capabilities/TopCapability.java
+++ b/bdi-jade-test/src/bdi4jade/examples/capabilities/TopCapability.java
@@ -22,6 +22,7 @@
 
 package bdi4jade.examples.capabilities;
 
+import bdi4jade.annotation.AssociatedCapability;
 import bdi4jade.annotation.GoalOwner;
 import bdi4jade.annotation.PartCapability;
 import bdi4jade.annotation.TransientBelief;
@@ -47,6 +48,9 @@ public class TopCapability extends TopParentCapability {
 
 	private static final long serialVersionUID = -8981563986693758609L;
 
+	@AssociatedCapability
+	private Capability associatedTopCapability = new AssociatedTopCapability();
+
 	@bdi4jade.annotation.Plan
 	private Plan externalGoalPlan = new DefaultPlan(TopExternalGoal.class,
 			SuccessPlanBody.class);