- From: Florent Batard via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 26 Aug 2008 15:26:39 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/org/w3c/unicorn/tasklist
In directory hutz:/tmp/cvs-serv7798/org/w3c/unicorn/tasklist
Modified Files:
TaskListUnmarshallerBeans.java Task.java
RDFUnmarshallerJena.java TasksListUnmarshaller.java
Removed Files:
TasksListUnmarshallerJAXB.java Observation.java
Log Message:
Changes for all the tasklist management
Index: RDFUnmarshallerJena.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/tasklist/RDFUnmarshallerJena.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- RDFUnmarshallerJena.java 17 Jun 2008 13:45:32 -0000 1.2
+++ RDFUnmarshallerJena.java 26 Aug 2008 15:26:37 -0000 1.3
@@ -8,13 +8,9 @@
import java.net.URL;
import java.util.Map;
-import javax.activation.MimeType;
-import javax.activation.MimeTypeParseException;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.unicorn.contract.Observer;
-import org.w3c.unicorn.generated.tasklist.TPriority;
import org.w3c.unicorn.tasklist.parameters.Mapping;
import org.w3c.unicorn.tasklist.parameters.Parameter;
import org.w3c.unicorn.tasklist.parameters.Value;
@@ -43,15 +39,12 @@
private static Resource RESOURCE_TASK = null;
private static Property PROPERTY_DESCRIPTION = null;
- private static Property PROPERTY_HANDLE = null;
private static Property PROPERTY_HASMAPPING = null;
private static Property PROPERTY_HASPARAMETER = null;
private static Property PROPERTY_HASVALUE = null;
private static Property PROPERTY_LONGNAME = null;
- private static Property PROPERTY_MIMETYPE = null;
private static Property PROPERTY_OBSERVER = null;
private static Property PROPERTY_PARAMETER = null;
- private static Property PROPERTY_PRIORITY = null;
private static Property PROPERTY_REFERENCE = null;
private static Property PROPERTY_TYPE = null;
private static Property PROPERTY_VALUE = null;
@@ -66,15 +59,12 @@
// define property use to find information into the RDF graph
RDFUnmarshallerJena.PROPERTY_DESCRIPTION = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"description");
- RDFUnmarshallerJena.PROPERTY_HANDLE = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"handle");
RDFUnmarshallerJena.PROPERTY_HASMAPPING = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"hasMapping");
RDFUnmarshallerJena.PROPERTY_HASPARAMETER = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"hasParameter");
RDFUnmarshallerJena.PROPERTY_HASVALUE = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"hasValue");
RDFUnmarshallerJena.PROPERTY_LONGNAME = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"longName");
- RDFUnmarshallerJena.PROPERTY_MIMETYPE = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"mimetype");
RDFUnmarshallerJena.PROPERTY_OBSERVER = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"observer");
RDFUnmarshallerJena.PROPERTY_PARAMETER = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"parameter");
- RDFUnmarshallerJena.PROPERTY_PRIORITY = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"priority");
RDFUnmarshallerJena.PROPERTY_REFERENCE = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"reference");
RDFUnmarshallerJena.PROPERTY_TYPE = RDFUnmarshallerJena.MODEL.getProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
RDFUnmarshallerJena.PROPERTY_VALUE = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"value");
@@ -253,28 +243,6 @@
}
/**
- * Adds a handler to the given task.
- * @param aTask The task to consider.
- * @param aHandler The handler to add.
- * @throws MimeTypeParseException
- */
- private void addHandler (final Task aTask, final Resource aHandler) throws MimeTypeParseException {
- RDFUnmarshallerJena.logger.trace("addHandler");
- final String sMimeType = aHandler.getProperty(RDFUnmarshallerJena.PROPERTY_MIMETYPE).getLiteral().getString();
- final String sObserver = aHandler.getProperty(RDFUnmarshallerJena.PROPERTY_OBSERVER).getLiteral().getString();
- final String sPriority = aHandler.getProperty(RDFUnmarshallerJena.PROPERTY_PRIORITY).getLiteral().getString();
- if (RDFUnmarshallerJena.logger.isDebugEnabled()) {
- RDFUnmarshallerJena.logger.debug("Task : "+aTask.getID()+".");
- RDFUnmarshallerJena.logger.debug("Observer : "+sObserver+".");
- RDFUnmarshallerJena.logger.debug("Mime type : "+sMimeType+".");
- RDFUnmarshallerJena.logger.debug("Priority : "+sPriority+".");
- }
- aTask.getMapOfObservation().get(sObserver).addMimeType(
- new MimeType(sMimeType),
- TPriority.fromValue(sPriority));
- }
-
- /**
* Adds a task to this object.
* @param aTask The task to add.
* @throws Exception
@@ -322,20 +290,6 @@
}
this.addParameter(oTask, aParameter);
} // find and add Parameter of the task
- // find and add Handler of the Task
- for (
- final StmtIterator siHandler = this.aModel.listStatements(
- aTask,
- RDFUnmarshallerJena.PROPERTY_HANDLE,
- (RDFNode) null);
- siHandler.hasNext();) {
- final Resource aHandler = (Resource) siHandler.nextStatement().getObject();
- if (null == aHandler) {
- RDFUnmarshallerJena.logger.error("Resource handler == null.");
- continue;
- }
- this.addHandler(oTask, aHandler);
- } // find and add Handler of the Task
}
/* (non-Javadoc)
Index: TasksListUnmarshaller.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/tasklist/TasksListUnmarshaller.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- TasksListUnmarshaller.java 29 Jul 2008 14:03:14 -0000 1.2
+++ TasksListUnmarshaller.java 26 Aug 2008 15:26:37 -0000 1.3
@@ -6,7 +6,6 @@
import java.util.Map;
-import org.w3c.unicorn.tasklisttree.TLTNode;
import org.w3c.unicorn.util.Unmarshaller;
/**
Index: TaskListUnmarshallerBeans.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/tasklist/TaskListUnmarshallerBeans.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- TaskListUnmarshallerBeans.java 30 Jul 2008 14:43:29 -0000 1.6
+++ TaskListUnmarshallerBeans.java 26 Aug 2008 15:26:36 -0000 1.7
@@ -28,6 +28,7 @@
import org.w3c.unicorn.contract.EnumInputMethod;
import org.w3c.unicorn.contract.InputMethod;
import org.w3c.unicorn.contract.Observer;
+import org.w3c.unicorn.Framework;
import org.w3c.unicorn.exceptions.ParameterException;
import org.w3c.unicorn.tasklist.parameters.Mapping;
import org.w3c.unicorn.tasklist.parameters.Parameter;
@@ -45,6 +46,7 @@
private static final Log logger = LogFactory.getLog("org.w3c.unicorn.tasklist");
+ private int NodeID=0;
/**
@@ -81,11 +83,9 @@
}
final Task aTaskCurrent = new Task();
- aTaskCurrent.setTree(this.ExpandTree(aTask));
-
-// id
+// Create the execution level tree
aTaskCurrent.setID(aTask.getId());
-
+ aTaskCurrent.setTree(this.ExpandTree(aTask));
// parameters
final ParametersType aParameters = aTask.getParameters();
@@ -361,17 +361,17 @@
* the task to transform into a tree
*/
public TLTNode ExpandTree(TaskType myTask) {
- int level=0;
TaskListUnmarshallerBeans.logger.trace("Creation of the tree based on the Task "
+ myTask.getId());
TLTNode root = new TLTNode();
- root.setLevel(level++);
+ root.setID(NodeID++);
for (ExecType exec : myTask.getRoutine().getExecArray()) {
- root.addExec(new TLTExec(exec.getId(), exec.getValue(), exec
+ final Observer obs=Framework.mapOfObserver.get(exec.getValue());
+ root.addExec(new TLTExec(exec.getId(), obs,exec.getValue(), exec
.getType(), exec.getParam()));
}
for (IfType iflist : myTask.getRoutine().getIfArray()) {
- root.addIf(fillIfs(myTask,iflist,level));
+ root.addIf(fillIfs(myTask,iflist));
}
return root;
}
@@ -383,16 +383,17 @@
* the ThenType node for the recursion
* @return the node created
*/
- private TLTNode FillNode(TaskType myTask,ThenType myThen,int level) {
+ private TLTNode FillNode(TaskType myTask,ThenType myThen) {
TaskListUnmarshallerBeans.logger.trace("Creation of a then branch ");
TLTNode node = new TLTNode();
- node.setLevel(level++);
+ node.setID(NodeID++);
for (ExecType exec : myThen.getExecArray()) {
- node.addExec(new TLTExec(exec.getId(), exec.getValue(), exec
+ final Observer obs=Framework.mapOfObserver.get(exec.getValue());
+ node.addExec(new TLTExec(exec.getId(),obs, exec.getValue(), exec
.getType(), exec.getParam()));
}
for (IfType iflist : myThen.getIfArray()) {
- node.addIf(fillIfs(myTask,iflist,level));
+ node.addIf(fillIfs(myTask,iflist));
}
return node;
}
@@ -404,7 +405,7 @@
* the IfType node template to create the Ifnode
* @return the node created
*/
- private TLTIf fillIfs(TaskType myTask,IfType ifs,int level) {
+ private TLTIf fillIfs(TaskType myTask,IfType ifs) {
TaskListUnmarshallerBeans.logger.trace("Creation of an If ");
// Create the if node
TLTIf ifnode = new TLTIf();
@@ -418,7 +419,8 @@
if (condlist.getId().equals(cond)) {
TaskListUnmarshallerBeans.logger.trace("Creation of a condition " + cond);
myCond.setId(condlist.getId());
- myCond.setObserver(condlist.getObserver());
+ final Observer obs=Framework.mapOfObserver.get(condlist.getObserver());
+ myCond.setObserver(obs);
myCond
.setResult(condlist.getResult().equals("passed") ? true
: false);
@@ -435,11 +437,11 @@
// Add recursively the inner ifs in the then part
if (ifs.getThen() != null) {
TaskListUnmarshallerBeans.logger.trace("Call recursion for the Then ");
- ifnode.setIfOk(FillNode(myTask,ifs.getThen(),level));
+ ifnode.setIfOk(FillNode(myTask,ifs.getThen()));
// Add recursively the inner if in the else part
if (ifs.getElse() != null) {
TaskListUnmarshallerBeans.logger.trace("Call recursion for the else");
- ifnode.setIfNotOk(FillNode(myTask,ifs.getElse(),level));
+ ifnode.setIfNotOk(FillNode(myTask,ifs.getElse()));
}
}
return ifnode;
@@ -531,7 +533,7 @@
// and parameters
for (final org.w3c.unicorn.tasklist.Task aTask : this.mapOfTask.values()) {
TaskListUnmarshallerBeans.logger.debug("Expand task : "+aTask.getID()+".");
- aTask.expand(this.mapOfTask);
+ aTask.setTree(aTask.expandNode(mapOfTask, aTask.getTree()));
}
}
--- TasksListUnmarshallerJAXB.java DELETED ---
Index: Task.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/tasklist/Task.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Task.java 31 Aug 2006 09:09:26 -0000 1.1.1.1
+++ Task.java 26 Aug 2008 15:26:37 -0000 1.2
@@ -13,7 +13,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.w3.unicorn.tasklist.ExecType;
+import org.w3.unicorn.tasklist.TaskType;
+import org.w3.unicorn.tasklist.IfType;
+import org.w3.unicorn.tasklist.ThenType;
+import org.w3.unicorn.tasklist.CondType;
import org.w3c.unicorn.tasklist.parameters.Parameter;
+import org.w3c.unicorn.tasklisttree.TLTCond;
+import org.w3c.unicorn.tasklisttree.TLTExec;
+import org.w3c.unicorn.tasklisttree.TLTIf;
+import org.w3c.unicorn.tasklisttree.TLTNode;
import org.w3c.unicorn.util.LocalizedString;
/**
@@ -22,93 +31,133 @@
*/
public class Task {
- private static final Log logger = LogFactory.getLog("org.w3c.unicorn.tasklist");
+ private static final Log logger = LogFactory
+ .getLog("org.w3c.unicorn.tasklist");
/**
* Id of the task
*/
private String sID;
-
+
/**
* Longnames of the task
*/
private LocalizedString aLocalizedStringLongName;
-
+
/**
* Descriptions of the task
*/
private LocalizedString aLocalizedStringDescription;
-
- /**
- * Observation of the task
- */
- private Map<String, Observation> mapOfObservation;
+
/**
* Parameters of the task
*/
private Map<String, Parameter> mapOfTaskParameter;
-
+
/**
* References to other tasks
*/
private List<String> listOfReference;
-
+
/**
* Used to expand the task
*/
private boolean bExpandingOrExpanded = false;
-
+
+ /**
+ * Root of the execution level tree
+ */
+ private TLTNode root;
+
+
/**
* Creates a new Task.
*/
- public Task () {
+ public Task() {
this.sID = "";
this.aLocalizedStringLongName = new LocalizedString();
this.aLocalizedStringDescription = new LocalizedString();
- this.mapOfObservation = new LinkedHashMap<String, Observation>();
this.mapOfTaskParameter = new LinkedHashMap<String, Parameter>();
this.listOfReference = new ArrayList<String>();
}
/**
+ * Allows to display the tree of execution level
+ *
+ * @param root
+ * the node to display
+ */
+ public void displayTree(TLTNode root) {
+ for (TLTExec exec : root.getExecutionList()) {
+ System.out.println(exec);
+ }
+ for (TLTIf ifs : root.getIfList()) {
+ displayTree(ifs.getIfOk());
+ for (TLTCond conds : ifs.getCondArray())
+ System.out.println(conds);
+ displayTree(ifs.getIfNotOk());
+ }
+ }
+
+ /**
+ * Get the root of the execution level tree
+ * @return the root of the tree
+ */
+ public TLTNode getTree() {
+ return this.root;
+ }
+
+
+ /**
+ * Set the root of the execution level tree
+ */
+ public void setTree(TLTNode root) {
+ this.root=root;
+ }
+
+
+
+ /**
* Creates a new Task.
+ *
* @param aLocalizedStringDescription
* @param sID
* @param aLocalizedStringLongName
* @param mapOfParameter
* @param mapOfObservation
*/
- public Task (
- final String sID,
- final LocalizedString aLocalizedStringDescription,
+ public Task(final String sID,
+ final LocalizedString aLocalizedStringDescription,
final LocalizedString aLocalizedStringLongName,
- final Map<String, Parameter> mapOfParameter,
- final Map<String, Observation> mapOfObservation) {
+ final Map<String, Parameter> mapOfParameter) {
super();
this.aLocalizedStringDescription = aLocalizedStringDescription;
this.sID = sID;
this.aLocalizedStringLongName = aLocalizedStringLongName;
this.mapOfTaskParameter = mapOfParameter;
- this.mapOfObservation = mapOfObservation;
this.listOfReference = new ArrayList<String>();
}
-
+
/**
* Returns the internationalized description of this task
+ *
* @return Returns the description.
*/
- public LocalizedString getDescription () {
+ public LocalizedString getDescription() {
return this.aLocalizedStringDescription;
}
/**
* Returns a localized description of this task
- * @param sLang requested locale (e.g. en, fr, zn-ch, ...)
+ *
+ * @param sLang
+ * requested locale (e.g. en, fr, zn-ch, ...)
* @return the localized description corresponding to the locale
*/
- public String getDescription (final String sLang) {
- final String sDesc = this.aLocalizedStringDescription.getLocalization(sLang);
+ public String getDescription(final String sLang) {
+ final String sDesc = this.aLocalizedStringDescription
+ .getLocalization(sLang);
if (sDesc == null) {
return "";
}
@@ -117,23 +166,29 @@
/**
* Sets the internationalized description of this task
- * @param aLocalizedString The description to set.
+ *
+ * @param aLocalizedString
+ * The description to set.
*/
- public void setDescription (final LocalizedString aLocalizedString) {
+ public void setDescription(final LocalizedString aLocalizedString) {
this.aLocalizedStringDescription = aLocalizedString;
}
/**
* Adds a localized description to this task
- * @param sLang the locale of the description
- * @param sDesc the localized description of this task
+ *
+ * @param sLang
+ * the locale of the description
+ * @param sDesc
+ * the localized description of this task
*/
- public void addDescription (final String sLang, final String sDesc) {
+ public void addDescription(final String sLang, final String sDesc) {
this.aLocalizedStringDescription.addLocalization(sLang, sDesc);
}
/**
* Gets the id of this task
+ *
* @return Returns the id.
*/
public String getID() {
@@ -142,115 +197,108 @@
/**
* Sets the id of this task
- * @param sID The id to set.
+ *
+ * @param sID
+ * The id to set.
*/
- public void setID (final String sID) {
+ public void setID(final String sID) {
this.sID = sID;
}
/**
* Returns the itnernationalized long name of this task
+ *
* @return Returns the longname.
*/
- public LocalizedString getLongName () {
+ public LocalizedString getLongName() {
return this.aLocalizedStringLongName;
}
-
+
/**
* Returns a localized long name of this task
- * @param sLang requested locale (e.g. en, fr, zn-ch, ...)
+ *
+ * @param sLang
+ * requested locale (e.g. en, fr, zn-ch, ...)
* @return the localized long name corresponding to the locale
*/
- public String getLongName (final String sLang) {
- final String sName = this.aLocalizedStringLongName.getLocalization(sLang);
+ public String getLongName(final String sLang) {
+ final String sName = this.aLocalizedStringLongName
+ .getLocalization(sLang);
if (sName == null) {
return "";
}
return sName;
}
-
+
/**
* Sets the internationalized long name of this task
- * @param aLocalizedString The longname to set.
+ *
+ * @param aLocalizedString
+ * The longname to set.
*/
- public void setLongName (final LocalizedString aLocalizedString) {
+ public void setLongName(final LocalizedString aLocalizedString) {
this.aLocalizedStringLongName = aLocalizedString;
}
-
+
/**
* Adds a localized long name to this task
- * @param sLang the locale of the long name
- * @param sLongName the localized long name of this task
+ *
+ * @param sLang
+ * the locale of the long name
+ * @param sLongName
+ * the localized long name of this task
*/
- public void addLongName (final String sLang, final String sLongName) {
+ public void addLongName(final String sLang, final String sLongName) {
this.aLocalizedStringLongName.addLocalization(sLang, sLongName);
}
-
+
/**
* Returns the parameters list of this task
+ *
* @return Returns the parameters.
*/
- public Map<String, Parameter> getMapOfParameter () {
+ public Map<String, Parameter> getMapOfParameter() {
return this.mapOfTaskParameter;
}
-
+
/**
* Sets the parameters list of this task
- * @param mapOfParameter The parameters to set.
+ *
+ * @param mapOfParameter
+ * The parameters to set.
*/
- public void setMapOfParameter (final Map<String, Parameter> mapOfParameter) {
+ public void setMapOfParameter(final Map<String, Parameter> mapOfParameter) {
this.mapOfTaskParameter = mapOfParameter;
}
-
+
/**
* Adds a parameter to this task
+ *
* @param aParameter
*/
- public void addParameter (final Parameter aParameter) {
+ public void addParameter(final Parameter aParameter) {
this.mapOfTaskParameter.put(aParameter.getName(), aParameter);
}
-
- /**
- * Returns the observations composing this task
- * @return Returns the observations.
- */
- public Map<String, Observation> getMapOfObservation() {
- return this.mapOfObservation;
- }
- /**
- * Sets the observations of this task
- * @param mapOfObservation The observations to set.
- */
- public void setMapOfObservation (final Map<String, Observation> mapOfObservation) {
- this.mapOfObservation = mapOfObservation;
- }
/**
- * Adds an observation to this task
- * @param sName name of the observation
- * @param aObservation the observation to add
- */
- public void addObservation (final String sName, final Observation aObservation) {
- this.mapOfObservation.put(sName, aObservation);
- }
-
- /**
- * Returns a list of tasknames referenced bye this task
+ * Returns a list of tasknames referenced bye this task
+ *
* @return Returns the references.
*/
- public List<String> getListOfReference () {
+ public List<String> getListOfReference() {
return this.listOfReference;
}
-
+
/**
* Recursively expands this task and referenced ones and merges observations
- * and parameters.<br/>
- * If a task A includes a task B that includes a task C, expand will put
- * both B and C in A's referenced tasks.
+ * and parameters.<br/> If a task A includes a task B that includes a task
+ * C, expand will put both B and C in A's referenced tasks.
+ *
* @param mapOfTask
*/
- public void expand (final Map<String, Task> mapOfTask) {
+ /*
+ public void expand(final Map<String, Task> mapOfTask) {
this.bExpandingOrExpanded = true;
final List<String> listOfOldReference = new ArrayList<String>();
// re-ask why there build another list of reference
@@ -261,30 +309,32 @@
for (final String sReference : listOfOldReference) {
final Task aTask = mapOfTask.get(sReference);
-
+
if (aTask == null) {
- Task.logger.error("The task " + sReference + " directly referenced " +
- "by the task" + this.getID() + " does not seem to" +
- " exist... Ignoring reference");
+ Task.logger.error("The task " + sReference
+ + " directly referenced " + "by the task"
+ + this.getID() + " does not seem to"
+ + " exist... Ignoring reference");
continue;
}
-
+
this.merge(aTask);
-
+
if (!aTask.bExpandingOrExpanded) {
aTask.expand(mapOfTask);
}
-
+
for (final String sNewReference : aTask.listOfReference) {
- if (this.listOfReference.contains(sNewReference) || this.sID.equals(sNewReference)) {
+ if (this.listOfReference.contains(sNewReference)
+ || this.sID.equals(sNewReference)) {
continue;
}
final Task aTaskCurrentRef = mapOfTask.get(sNewReference);
if (aTaskCurrentRef == null) {
- Task.logger.error("The task " + sReference + " recursively" +
- " referenced by the task" + getID() +
- " does not seem to exist... Ignoring " +
- "reference");
+ Task.logger.error("The task " + sReference + " recursively"
+ + " referenced by the task" + getID()
+ + " does not seem to exist... Ignoring "
+ + "reference");
continue;
}
this.listOfReference.add(sNewReference);
@@ -292,71 +342,163 @@
}
}
}
-
+ */
+
/**
* Merges another task with this one
- * @param aNotherTask the task to merge
+ *
+ * @param aNotherTask
+ * the task to merge
*/
- private void merge (final Task aNotherTask) {
+ /*
+ private void merge(final Task aNotherTask) {
this.mergeObservations(aNotherTask);
this.mergeParameters(aNotherTask);
}
-
+*/
/**
* Merges observations of another task with this one
- * @param aNotherTask the task to merge
+ *
+ * @param aNotherTask
+ * the task to merge
*/
- private void mergeObservations (final Task aNotherTask) {
+ /*
+ private void mergeObservations(final Task aNotherTask) {
Task.logger.trace("mergeObservations");
if (Task.logger.isDebugEnabled()) {
Task.logger.debug("Other task : " + aNotherTask + ".");
}
- final Map<String, Observation> mapOfObservation = aNotherTask.getMapOfObservation();
- for (final String sObservationID : mapOfObservation.keySet()) {
- final Observation aObservation = mapOfObservation.get(sObservationID);
+ final Map<String, Observation> mapOfObservation = aNotherTask
+ .getMapOfObservation();
+ for (final String sObservationID : mapOfObservation.keySet()) {
+ final Observation aObservation = mapOfObservation
+ .get(sObservationID);
if (this.mapOfObservation.containsKey(sObservationID)) {
this.mapOfObservation.get(sObservationID).merge(aObservation);
- }
- else {
+ } else {
this.mapOfObservation.put(sObservationID, aObservation);
}
}
}
-
+*/
/**
* Merges parameters of another task with this one.
- * @param aNotherTask the other task to merge
+ *
+ * @param aNotherTask
+ * the other task to merge
*/
- private void mergeParameters (final Task aNotherTask) {
- final Map<String, Parameter> mapOfParameter = aNotherTask.getMapOfParameter();
+ private void mergeParameters(final Task aNotherTask) {
+ final Map<String, Parameter> mapOfParameter = aNotherTask
+ .getMapOfParameter();
for (final String sParameterName : mapOfParameter.keySet()) {
- final Parameter aLocalParameter = this.mapOfTaskParameter.get(sParameterName);
- final Parameter aNotherParameter = mapOfParameter.get(sParameterName);
- if(aLocalParameter != null) {
+ final Parameter aLocalParameter = this.mapOfTaskParameter
+ .get(sParameterName);
+ final Parameter aNotherParameter = mapOfParameter
+ .get(sParameterName);
+ if (aLocalParameter != null) {
aLocalParameter.merge(aNotherParameter);
- }
- else {
+ } else {
this.mapOfTaskParameter.put(sParameterName, aNotherParameter);
}
}
}
+
+
+ public void mergeSubtask(final Map<String, Task> mapOfTask, Task subtask) {
+ for (TLTExec exec : subtask.getTree().getExecutionList()) {
+ if (exec.getType().equals("observation"))
+ this.root.addExec(exec);
+ else if (exec.getType().equals("subtask")) {
+ Task newTask = mapOfTask.get(exec.getValue());
+ newTask.expandNode(mapOfTask,newTask.getTree());
+ mergeSubtask(mapOfTask,newTask);
+ }
+
+ }
+ for (TLTIf tltIf : subtask.getTree().getIfList()) {
+ this.root.addIf(tltIf);
+ }
+ }
+
+ /**
+ *
+ */
+ public TLTNode expandNode(final Map<String, Task> mapOfTask, TLTNode aRoot) {
+ aRoot.bExpandingOrExpanded = true;
+
+ TLTNode finalRoot = new TLTNode();
+
+ for (TLTExec exec : aRoot.getExecutionList()) {
+ if (exec.getType().equals("subtask")) {
+ finalRoot = mergeNode(mapOfTask, finalRoot,
+ mapOfTask.get(exec.getValue()).getTree());
+ }
+ else if (exec.getType().equals("observation")) {
+ finalRoot.addExec(exec);
+ }
+ }
+
+ for (TLTIf tltIf : aRoot.getIfList()) {
+ tltIf = expandIf(mapOfTask, tltIf);
+ finalRoot.addIf(tltIf);
+ }
+
+ return finalRoot;
+ }
+
+
+ public TLTNode mergeNode(final Map<String,Task> mapOfTask, TLTNode firstNode,
+ TLTNode secondNode) {
+ TLTNode finalNode = firstNode;
+ for (TLTExec exec : secondNode.getExecutionList()) {
+ if (exec.getType().equals("observation"))
+ finalNode.addExec(exec);
+ else if (exec.getType().equals("subtask")) {
+ TLTNode newNode = mapOfTask.get(exec.getValue()).getTree();
+ if (!mapOfTask.get(exec.getValue()).getTree().bExpandingOrExpanded)
+ newNode =
+ expandNode(mapOfTask,mapOfTask.get(exec.getValue()).getTree());
+ finalNode = mergeNode(mapOfTask,finalNode,newNode);
+ }
+ }
+ for (TLTIf tltIf : secondNode.getIfList()) {
+ tltIf = expandIf(mapOfTask,tltIf);
+ finalNode.addIf(tltIf);
+ }
+ return finalNode;
+ }
+
+
+ public TLTIf expandIf(final Map<String,Task> mapOfTask, TLTIf tltIf) {
+ if (!tltIf.getIfOk().bExpandingOrExpanded) {
+ TLTNode tltIfOk = expandNode(mapOfTask,tltIf.getIfOk());
+ tltIf.setIfOk(tltIfOk);
+ }
+ if (!tltIf.getIfNotOk().bExpandingOrExpanded) {
+ TLTNode tltIfNotOk = expandNode(mapOfTask,tltIf.getIfNotOk());
+ tltIf.setIfNotOk(tltIfNotOk);
+ }
+ return tltIf;
+ }
+
/**
* Adds a reference to another task
- * @param sReference the referenced task
+ *
+ * @param sReference
+ * the referenced task
*/
- public void addReference (final String sReference) {
+ public void addReference(final String sReference) {
this.listOfReference.add(sReference);
}
-
- public String toString () {
+
+ public String toString() {
final int iStringBufferSize = 5000;
final String sVariableSeparator = "\n";
final StringBuffer aStringBuffer = new StringBuffer(iStringBufferSize);
aStringBuffer.append("ID:").append(sID);
aStringBuffer.append(sVariableSeparator);
- aStringBuffer.append("observations:").append(this.mapOfObservation);
aStringBuffer.append(sVariableSeparator);
aStringBuffer.append("parameters:").append(this.mapOfTaskParameter);
aStringBuffer.append(sVariableSeparator);
@@ -365,18 +507,5 @@
return aStringBuffer.toString();
}
- /**
- * Test if the mimetype is handle by a observer in this task.
- * @param aMimeType The mimetype to test.
- * @return Result of the test.
- */
- public boolean allowMimeType (final MimeType aMimeType) {
- for (final Observation aObservation : this.mapOfObservation.values()) {
- if (aObservation.allowMimeType(aMimeType)) {
- return true;
- }
- }
- return false;
- }
}
--- Observation.java DELETED ---
Received on Tuesday, 26 August 2008 15:27:15 UTC