- From: Jean-Guilhem Rouel via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 11 Aug 2009 13:43:02 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/org/w3c/unicorn/tasklist
In directory hutz:/tmp/cvs-serv6157/org/w3c/unicorn/tasklist
Modified Files:
RDFUnmarshaller.java RDFUnmarshallerJena.java
TasksListUnmarshaller.java TaskListUnmarshallerBeans.java
Task.java
Log Message:
Code cleanup
Index: RDFUnmarshallerJena.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/tasklist/RDFUnmarshallerJena.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- RDFUnmarshallerJena.java 26 Aug 2008 15:26:37 -0000 1.3
+++ RDFUnmarshallerJena.java 11 Aug 2009 13:43:00 -0000 1.4
@@ -26,11 +26,12 @@
/**
* @author Damien LEROY
- *
+ *
*/
public class RDFUnmarshallerJena implements RDFUnmarshaller {
- private static final Log logger = LogFactory.getLog("org.w3c.unicorn.tasklist");
+ private static final Log logger = LogFactory
+ .getLog("org.w3c.unicorn.tasklist");
private static final Model MODEL = ModelFactory.createDefaultModel();
@@ -39,59 +40,82 @@
private static Resource RESOURCE_TASK = null;
private static Property PROPERTY_DESCRIPTION = 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_OBSERVER = null;
+
private static Property PROPERTY_PARAMETER = null;
+
private static Property PROPERTY_REFERENCE = null;
+
private static Property PROPERTY_TYPE = null;
+
private static Property PROPERTY_VALUE = null;
static {
- RDFUnmarshallerJena.MODEL.read(
- org.w3c.unicorn.util.Property.get("TASKLIST_RDF_MODEL"),
- null);
+ RDFUnmarshallerJena.MODEL.read(org.w3c.unicorn.util.Property
+ .get("TASKLIST_RDF_MODEL"), null);
// define resource use to find information into the RDF graph
- RDFUnmarshallerJena.RESOURCE_TASK = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"Task");
+ RDFUnmarshallerJena.RESOURCE_TASK = RDFUnmarshallerJena.MODEL
+ .getProperty(RDFUnmarshallerJena.UCN_NAMESPACE + "Task");
// define property use to find information into the RDF graph
- RDFUnmarshallerJena.PROPERTY_DESCRIPTION = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"description");
- 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_OBSERVER = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"observer");
- RDFUnmarshallerJena.PROPERTY_PARAMETER = RDFUnmarshallerJena.MODEL.getProperty(RDFUnmarshallerJena.UCN_NAMESPACE+"parameter");
- 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");
+ RDFUnmarshallerJena.PROPERTY_DESCRIPTION = RDFUnmarshallerJena.MODEL
+ .getProperty(RDFUnmarshallerJena.UCN_NAMESPACE + "description");
+ 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_OBSERVER = RDFUnmarshallerJena.MODEL
+ .getProperty(RDFUnmarshallerJena.UCN_NAMESPACE + "observer");
+ RDFUnmarshallerJena.PROPERTY_PARAMETER = RDFUnmarshallerJena.MODEL
+ .getProperty(RDFUnmarshallerJena.UCN_NAMESPACE + "parameter");
+ 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");
}
private Map<String, Observer> mapOfObserver = null;
+
private Map<String, Task> mapOfTask = null;
+
private Model aModel = null;
/**
* Default constructor.
- *
+ *
*/
- public RDFUnmarshallerJena () {
+ public RDFUnmarshallerJena() {
RDFUnmarshallerJena.logger.trace("Constructor");
this.aModel = ModelFactory.createDefaultModel();
}
/**
* Adds a Model with the given URL to this aModel.
- * @param aURL The URL to add.
+ *
+ * @param aURL
+ * The URL to add.
*/
- public void addURL (final URL aURL) throws IOException {
+ public void addURL(final URL aURL) throws IOException {
RDFUnmarshallerJena.logger.trace("addURL");
if (RDFUnmarshallerJena.logger.isDebugEnabled()) {
- RDFUnmarshallerJena.logger.debug("URL : "+aURL+".");
+ RDFUnmarshallerJena.logger.debug("URL : " + aURL + ".");
}
final Model aModel = ModelFactory.createDefaultModel();
aModel.read(aURL.openStream(), null);
@@ -100,67 +124,88 @@
/**
* Adds a name (with its language) to the given task.
- * @param aTask The task to name.
- * @param aLiteral The name of the task.
+ *
+ * @param aTask
+ * The task to name.
+ * @param aLiteral
+ * The name of the task.
*/
- private void addLongName (final Task aTask, final Literal aLiteral) {
- RDFUnmarshallerJena.logger.debug(
- "LongName lang:" + aLiteral.getLanguage() +
- " value:" + aLiteral.getString() + ".");
+ private void addLongName(final Task aTask, final Literal aLiteral) {
+ RDFUnmarshallerJena.logger.debug("LongName lang:"
+ + aLiteral.getLanguage() + " value:" + aLiteral.getString()
+ + ".");
aTask.addLongName(aLiteral.getLanguage(), aLiteral.getString());
}
/**
* Adds a description (with its language) to the given task.
- * @param aTask The task to describe.
- * @param aLiteral The description of the task.
+ *
+ * @param aTask
+ * The task to describe.
+ * @param aLiteral
+ * The description of the task.
*/
- private void addDescription (final Task aTask, final Literal aLiteral) {
- RDFUnmarshallerJena.logger.debug(
- "Description lang:" + aLiteral.getLanguage() +
- " value:" + aLiteral.getString() + ".");
+ private void addDescription(final Task aTask, final Literal aLiteral) {
+ RDFUnmarshallerJena.logger.debug("Description lang:"
+ + aLiteral.getLanguage() + " value:" + aLiteral.getString()
+ + ".");
aTask.addDescription(aLiteral.getLanguage(), aLiteral.getString());
}
/**
* Adds a name (with its language) to the given parameter.
- * @param aTask The parameter to name.
- * @param aLiteral The name of the parameter.
+ *
+ * @param aTask
+ * The parameter to name.
+ * @param aLiteral
+ * The name of the parameter.
*/
- private void addLongName (final Parameter aParameter, final Literal aLiteral) {
- RDFUnmarshallerJena.logger.debug(
- "Parameter long name lang:" + aLiteral.getLanguage() +
- " value:" + aLiteral.getString() + ".");
+ private void addLongName(final Parameter aParameter, final Literal aLiteral) {
+ RDFUnmarshallerJena.logger.debug("Parameter long name lang:"
+ + aLiteral.getLanguage() + " value:" + aLiteral.getString()
+ + ".");
aParameter.addLongName(aLiteral.getLanguage(), aLiteral.getString());
}
/**
* Adds a name (with its language) to the given value.
- * @param aTask The value to name.
- * @param aLiteral The name of the value.
+ *
+ * @param aTask
+ * The value to name.
+ * @param aLiteral
+ * The name of the value.
*/
- private void addLongName (final Value aValue, final Literal aLiteral) {
- RDFUnmarshallerJena.logger.debug(
- "Value long name lang:" + aLiteral.getLanguage() +
- " value:" + aLiteral.getString() + ".");
+ private void addLongName(final Value aValue, final Literal aLiteral) {
+ RDFUnmarshallerJena.logger.debug("Value long name lang:"
+ + aLiteral.getLanguage() + " value:" + aLiteral.getString()
+ + ".");
aValue.addLongName(aLiteral.getLanguage(), aLiteral.getString());
}
/**
* Adds a mapping to the given value.
- * @param value The value to map.
- * @param aMapping The mapping for the value.
+ *
+ * @param value
+ * The value to map.
+ * @param aMapping
+ * The mapping for the value.
*/
- private void addMapping (final Value aValue, final Resource aMapping) {
+ private void addMapping(final Value aValue, final Resource aMapping) {
RDFUnmarshallerJena.logger.trace("addMapping");
if (RDFUnmarshallerJena.logger.isDebugEnabled()) {
- RDFUnmarshallerJena.logger.debug("Value : "+aValue.getName()+".");
- RDFUnmarshallerJena.logger.debug("Mapping : "+aMapping.getLocalName()+".");
+ RDFUnmarshallerJena.logger.debug("Value : " + aValue.getName()
+ + ".");
+ RDFUnmarshallerJena.logger.debug("Mapping : "
+ + aMapping.getLocalName() + ".");
}
// TODO verifier ce brol
- final String sObserver = aMapping.getProperty(RDFUnmarshallerJena.PROPERTY_OBSERVER).getLiteral().getString();
- final String sParameter = aMapping.getProperty(RDFUnmarshallerJena.PROPERTY_PARAMETER).getLiteral().getString();
- final String sValue = aMapping.getProperty(RDFUnmarshallerJena.PROPERTY_VALUE).getLiteral().getString();
+ final String sObserver = aMapping.getProperty(
+ RDFUnmarshallerJena.PROPERTY_OBSERVER).getLiteral().getString();
+ final String sParameter = aMapping.getProperty(
+ RDFUnmarshallerJena.PROPERTY_PARAMETER).getLiteral()
+ .getString();
+ final String sValue = aMapping.getProperty(
+ RDFUnmarshallerJena.PROPERTY_VALUE).getLiteral().getString();
final Mapping oMapping = new Mapping();
oMapping.setObserver(this.mapOfObserver.get(sObserver));
oMapping.setParam(sParameter);
@@ -169,71 +214,74 @@
/**
* Adds a value to the given parameter.
- * @param aParameter The parameter to consider.
- * @param aValue The value to add.
+ *
+ * @param aParameter
+ * The parameter to consider.
+ * @param aValue
+ * The value to add.
*/
- private void addValue (final Parameter aParameter, final Resource aValue) {
- final String sValue =
- aValue.getProperty(RDFUnmarshallerJena.PROPERTY_VALUE).getLiteral().getString();
+ private void addValue(final Parameter aParameter, final Resource aValue) {
+ final String sValue = aValue.getProperty(
+ RDFUnmarshallerJena.PROPERTY_VALUE).getLiteral().getString();
final Value oValue = aParameter.getValue(sValue);
if (null == oValue) {
- RDFUnmarshallerJena.logger.warn(
- "Value " + sValue +
- " not found in parameter " + aParameter.getName() + ".");
+ RDFUnmarshallerJena.logger.warn("Value " + sValue
+ + " not found in parameter " + aParameter.getName() + ".");
return;
}
RDFUnmarshallerJena.logger.debug("Parameter value : " + sValue + ".");
// find and add longName of the Value
- for (
- final StmtIterator siLongName = aValue.listProperties(
- RDFUnmarshallerJena.PROPERTY_LONGNAME);
- siLongName.hasNext();) {
+ for (final StmtIterator siLongName = aValue
+ .listProperties(RDFUnmarshallerJena.PROPERTY_LONGNAME); siLongName
+ .hasNext();) {
final Literal lLongName = siLongName.nextStatement().getLiteral();
this.addLongName(oValue, lLongName);
} // find and add longName of the Value
// TODO completer l'ajout de Value
// find and add mapping of the Value
- for (
- final StmtIterator siMapping = aValue.listProperties(
- RDFUnmarshallerJena.PROPERTY_HASMAPPING);
- siMapping.hasNext();) {
- final Resource aMapping = (Resource) siMapping.nextStatement().getObject();
+ for (final StmtIterator siMapping = aValue
+ .listProperties(RDFUnmarshallerJena.PROPERTY_HASMAPPING); siMapping
+ .hasNext();) {
+ final Resource aMapping = (Resource) siMapping.nextStatement()
+ .getObject();
this.addMapping(oValue, aMapping);
} // find and add mapping of the Value
}
/**
* Adds a parameter to the given task.
- * @param aTask The task to consider.
- * @param aParameter The parameter to add.
+ *
+ * @param aTask
+ * The task to consider.
+ * @param aParameter
+ * The parameter to add.
*/
- private void addParameter (final Task aTask, final Resource aParameter) {
- final String sParameterReference =
- aParameter.getProperty(RDFUnmarshallerJena.PROPERTY_REFERENCE).getLiteral().getString();
- final Parameter oParameter = aTask.getMapOfParameter().get(sParameterReference);
+ private void addParameter(final Task aTask, final Resource aParameter) {
+ final String sParameterReference = aParameter.getProperty(
+ RDFUnmarshallerJena.PROPERTY_REFERENCE).getLiteral()
+ .getString();
+ final Parameter oParameter = aTask.getMapOfParameter().get(
+ sParameterReference);
if (null == oParameter) {
- RDFUnmarshallerJena.logger.warn(
- "Parameter " + sParameterReference +
- " not found in task " + aTask.getID() + ".");
+ RDFUnmarshallerJena.logger.warn("Parameter " + sParameterReference
+ + " not found in task " + aTask.getID() + ".");
return;
}
- RDFUnmarshallerJena.logger.debug("Parameter : "+sParameterReference+".");
+ RDFUnmarshallerJena.logger.debug("Parameter : " + sParameterReference
+ + ".");
// find and add longName of the Parameter
- for (
- StmtIterator siLongName = aParameter.listProperties(
- RDFUnmarshallerJena.PROPERTY_LONGNAME);
- siLongName.hasNext();) {
+ for (StmtIterator siLongName = aParameter
+ .listProperties(RDFUnmarshallerJena.PROPERTY_LONGNAME); siLongName
+ .hasNext();) {
final Literal lLongName = siLongName.nextStatement().getLiteral();
this.addLongName(oParameter, lLongName);
} // find and add longName of the Parameter
// find and add value of the Parameter
- for (
- final StmtIterator siValue = this.aModel.listStatements(
- aParameter,
- RDFUnmarshallerJena.PROPERTY_HASVALUE,
- (RDFNode) null);
- siValue.hasNext();) {
- final Resource aValue = (Resource) siValue.nextStatement().getObject();
+ for (final StmtIterator siValue = this.aModel.listStatements(
+ aParameter, RDFUnmarshallerJena.PROPERTY_HASVALUE,
+ (RDFNode) null); siValue.hasNext();) {
+ final Resource aValue = (Resource) siValue.nextStatement()
+ .getObject();
if (null == aValue) {
RDFUnmarshallerJena.logger.error("Resource value == null.");
continue;
@@ -244,46 +292,47 @@
/**
* Adds a task to this object.
- * @param aTask The task to add.
+ *
+ * @param aTask
+ * The task to add.
* @throws Exception
*/
- private void addTask (final Resource aTask) throws Exception {
- final Statement aReference = aTask.getProperty(RDFUnmarshallerJena.PROPERTY_REFERENCE);
- final Task oTask = this.mapOfTask.get(aReference.getLiteral().getString());
+ private void addTask(final Resource aTask) throws Exception {
+ final Statement aReference = aTask
+ .getProperty(RDFUnmarshallerJena.PROPERTY_REFERENCE);
+ final Task oTask = this.mapOfTask.get(aReference.getLiteral()
+ .getString());
if (oTask == null) {
// TODO creer et initialiser une Task si les informations peuvent
// TODO etre mise uniquement dans le fichier rdf
- RDFUnmarshallerJena.logger.error(
- "No task with reference : " +
- aReference.getLiteral().getString() +
- ".");
- throw new Exception("No task with reference : "+aReference.getLiteral().getString()+".");
+ RDFUnmarshallerJena.logger.error("No task with reference : "
+ + aReference.getLiteral().getString() + ".");
+ throw new Exception("No task with reference : "
+ + aReference.getLiteral().getString() + ".");
}
- RDFUnmarshallerJena.logger.debug("Reference : "+aReference.getObject().toString()+".");
+ RDFUnmarshallerJena.logger.debug("Reference : "
+ + aReference.getObject().toString() + ".");
// find and add longName of the task
- for (
- final StmtIterator siLongName = aTask.listProperties(
- RDFUnmarshallerJena.PROPERTY_LONGNAME);
- siLongName.hasNext();) {
+ for (final StmtIterator siLongName = aTask
+ .listProperties(RDFUnmarshallerJena.PROPERTY_LONGNAME); siLongName
+ .hasNext();) {
final Literal lLongName = siLongName.nextStatement().getLiteral();
this.addLongName(oTask, lLongName);
} // find and add longName of the task
// find and add description of the task
- for (
- final StmtIterator siDescription = aTask.listProperties(
- RDFUnmarshallerJena.PROPERTY_DESCRIPTION);
- siDescription.hasNext();) {
- final Literal lDescription = siDescription.nextStatement().getLiteral();
+ for (final StmtIterator siDescription = aTask
+ .listProperties(RDFUnmarshallerJena.PROPERTY_DESCRIPTION); siDescription
+ .hasNext();) {
+ final Literal lDescription = siDescription.nextStatement()
+ .getLiteral();
this.addDescription(oTask, lDescription);
} // find and add description of the task
// find and add Parameter of the task
- for (
- final StmtIterator siParameter = this.aModel.listStatements(
- aTask,
- RDFUnmarshallerJena.PROPERTY_HASPARAMETER,
- (RDFNode) null);
- siParameter.hasNext();) {
- final Resource aParameter = (Resource) siParameter.nextStatement().getObject();
+ for (final StmtIterator siParameter = this.aModel.listStatements(aTask,
+ RDFUnmarshallerJena.PROPERTY_HASPARAMETER, (RDFNode) null); siParameter
+ .hasNext();) {
+ final Resource aParameter = (Resource) siParameter.nextStatement()
+ .getObject();
if (null == aParameter) {
RDFUnmarshallerJena.logger.error("Resource parameter == null.");
continue;
@@ -292,19 +341,18 @@
} // find and add Parameter of the task
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.w3c.unicorn.util.Unmarshaller#unmarshal(java.net.URL)
*/
- public void unmarshal () throws Exception {
+ public void unmarshal() throws Exception {
RDFUnmarshallerJena.logger.trace("unmarshal");
// find and add task
- for (
- final StmtIterator siTask = this.aModel.listStatements(
- null,
- RDFUnmarshallerJena.PROPERTY_TYPE,
- RDFUnmarshallerJena.RESOURCE_TASK);
- siTask.hasNext();) {
+ for (final StmtIterator siTask = this.aModel.listStatements(null,
+ RDFUnmarshallerJena.PROPERTY_TYPE,
+ RDFUnmarshallerJena.RESOURCE_TASK); siTask.hasNext();) {
final Resource aTask = siTask.nextStatement().getSubject();
this.addTask(aTask);
} // find and add task
@@ -313,29 +361,32 @@
/**
* @return Returns the observers.
- *//*
- public Map<String, Observer> getMapOfObserver () {
- return this.mapOfObserver;
- }*/
+ */
+ /*
+ * public Map<String, Observer> getMapOfObserver () { return
+ * this.mapOfObserver; }
+ */
/**
- * @param mapOfTask The observers to set.
+ * @param mapOfTask
+ * The observers to set.
*/
- public void setMapOfObserver (final Map<String, Observer> mapOfObserver) {
+ public void setMapOfObserver(final Map<String, Observer> mapOfObserver) {
this.mapOfObserver = mapOfObserver;
}
/**
* @return Returns the tasks.
*/
- public Map<String, Task> getMapOfTask () {
+ public Map<String, Task> getMapOfTask() {
return this.mapOfTask;
}
/**
- * @param mapOfTask The tasks to set.
+ * @param mapOfTask
+ * The tasks to set.
*/
- public void setMapOfTask (final Map<String, Task> mapOfTask) {
+ public void setMapOfTask(final Map<String, Task> mapOfTask) {
this.mapOfTask = mapOfTask;
}
Index: RDFUnmarshaller.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/tasklist/RDFUnmarshaller.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- RDFUnmarshaller.java 31 Aug 2006 09:09:26 -0000 1.1.1.1
+++ RDFUnmarshaller.java 11 Aug 2009 13:43:00 -0000 1.2
@@ -11,13 +11,15 @@
/**
* @author Damien LEROY
- *
+ *
*/
public interface RDFUnmarshaller extends Unmarshaller {
public abstract Map<String, Task> getMapOfTask();
- public abstract void setMapOfObserver (final Map<String, Observer> mapOfObserver);
- public abstract void setMapOfTask (final Map<String, Task> mapOfTask);
+ public abstract void setMapOfObserver(
+ final Map<String, Observer> mapOfObserver);
+
+ public abstract void setMapOfTask(final Map<String, Task> mapOfTask);
}
Index: TaskListUnmarshallerBeans.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/tasklist/TaskListUnmarshallerBeans.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- TaskListUnmarshallerBeans.java 12 Sep 2008 18:01:51 -0000 1.12
+++ TaskListUnmarshallerBeans.java 11 Aug 2009 13:43:00 -0000 1.13
@@ -1,4 +1,4 @@
- package org.w3c.unicorn.tasklist;
+package org.w3c.unicorn.tasklist;
import java.io.IOException;
import java.net.URL;
@@ -21,7 +21,6 @@
import org.w3.unicorn.tasklist.TUi;
import org.w3.unicorn.tasklist.TaskType;
import org.w3.unicorn.tasklist.TasklistDocument;
-import org.w3.unicorn.tasklist.TasklistType;
import org.w3.unicorn.tasklist.ThenType;
import org.w3.unicorn.tasklist.ValueType;
import org.w3c.unicorn.Framework;
@@ -43,31 +42,31 @@
/**
* Unmarshals the tasklist thanks to the XMLBeans tools.
- *
+ *
* @author Florent Batard, Jonathan Barouh
- *
+ *
*/
public class TaskListUnmarshallerBeans implements TasksListUnmarshaller {
private TasklistDocument aTaskList;
- private static final Log logger = LogFactory.getLog("org.w3c.unicorn.tasklist");
-
- private int NodeID=0;
+ private static final Log logger = LogFactory
+ .getLog("org.w3c.unicorn.tasklist");
+ private int NodeID = 0;
/**
* The tasklist corresponding to the xml file
*/
- private Map<String,Task> mapOfTask;
+ private Map<String, Task> mapOfTask;
/**
* The observers' list used to check some constraints on the tasks
*/
private Map<String, Observer> mapOfObserver;
-
- public TaskListUnmarshallerBeans(){}
+ public TaskListUnmarshallerBeans() {
+ }
public TaskListUnmarshallerBeans(final Map<String, Observer> mapOfObserver) {
TaskListUnmarshallerBeans.logger.trace("Constructor");
@@ -75,8 +74,6 @@
this.mapOfObserver = mapOfObserver;
}
-
-
private void addTask(final TaskType aTask) throws ParameterException {
TaskListUnmarshallerBeans.logger.trace("addTask");
@@ -86,15 +83,16 @@
}
if (TaskListUnmarshallerBeans.logger.isDebugEnabled()) {
- TaskListUnmarshallerBeans.logger.trace("Add task : " + aTask.getId());
+ TaskListUnmarshallerBeans.logger.trace("Add task : "
+ + aTask.getId());
}
final Task aTaskCurrent = new Task();
-// Create the execution level tree
+ // Create the execution level tree
aTaskCurrent.setID(aTask.getId());
aTaskCurrent.setTree(this.ExpandTree(aTask));
-// parameters
+ // parameters
final ParametersType aParameters = aTask.getParameters();
if (aParameters != null) {
final ParameterType[] listOfParameter;
@@ -114,19 +112,14 @@
Parameter aParameter = null;
if (sObserver != null && !"".equals(sObserver)) {
- aParameter = getParameterFromObserver(
- sName,
- sObserver,
- aTUi,
- sDefaultValues,
- aParamType);
- }
- else {
+ aParameter = getParameterFromObserver(sName, sObserver,
+ aTUi, sDefaultValues, aParamType);
+ } else {
// Values
final Map<String, Value> mapOfValue = new LinkedHashMap<String, Value>();
- for (final ValueType aValue :
- aParameterBeans.getValueArray()) {
+ for (final ValueType aValue : aParameterBeans
+ .getValueArray()) {
// name of the value
String sValueName = aValue.getName();
@@ -136,11 +129,15 @@
// Mappings of the value
final Map<String, List<Mapping>> mapOfMapping = new LinkedHashMap<String, List<Mapping>>();
- for (final MappedType aMappedBeans : aValue.getMappedArray()) {
- final Mapping aMapping = this.createMapping(aMappedBeans);
+ for (final MappedType aMappedBeans : aValue
+ .getMappedArray()) {
+ final Mapping aMapping = this
+ .createMapping(aMappedBeans);
if (aMapping != null) {
- final String sObs = aMapping.getObserver().getID();
- List<Mapping> listOfMapping = mapOfMapping.get(sObs);
+ final String sObs = aMapping.getObserver()
+ .getID();
+ List<Mapping> listOfMapping = mapOfMapping
+ .get(sObs);
if (null == listOfMapping) {
listOfMapping = new ArrayList<Mapping>();
mapOfMapping.put(sObs, listOfMapping);
@@ -148,19 +145,12 @@
listOfMapping.add(aMapping);
}
}
- mapOfValue.put(
- sValueName,
- new Value(
- mapOfMapping,
- sValueName));
+ mapOfValue.put(sValueName, new Value(mapOfMapping,
+ sValueName));
}
- aParameter = this.createParameter(
- aParamType,
- sName,
- aTUi,
- sDefaultValues,
- mapOfValue);
+ aParameter = this.createParameter(aParamType, sName, aTUi,
+ sDefaultValues, mapOfValue);
}
if (aParameter != null) {
@@ -169,27 +159,29 @@
}
}
- this.mapOfTask.put(aTaskCurrent.getID(),aTaskCurrent);
+ this.mapOfTask.put(aTaskCurrent.getID(), aTaskCurrent);
}
-
/**
* Creates a usable mapping from a JAXB-generated one.
- * @param aMappedJAXB the JAXB-generated mapping
+ *
+ * @param aMappedJAXB
+ * the JAXB-generated mapping
* @return the created mapping
*/
- private Mapping createMapping (final MappedType aMapped) {
+ private Mapping createMapping(final MappedType aMapped) {
TaskListUnmarshallerBeans.logger.trace("createMapping");
// The mapped observer
final String sMappingObserver = aMapped.getObserver();
- final Observer aObserverMapped = this.mapOfObserver.get(sMappingObserver);
+ final Observer aObserverMapped = this.mapOfObserver
+ .get(sMappingObserver);
if (aObserverMapped == null) {
- TaskListUnmarshallerBeans.logger.error(
- "The observer " + sMappingObserver +
- " does not seem to exist... Skipping mapping.");
+ TaskListUnmarshallerBeans.logger.error("The observer "
+ + sMappingObserver
+ + " does not seem to exist... Skipping mapping.");
return null;
}
@@ -206,11 +198,10 @@
// The list of mapped input methods
- final List<TInputMethod.Enum> listOfTInputMethodBeans =
- new ArrayList<TInputMethod.Enum>();
+ final List<TInputMethod.Enum> listOfTInputMethodBeans = new ArrayList<TInputMethod.Enum>();
for (Object methodString : aMapped.getInputmethod()) {
- listOfTInputMethodBeans.add(
- TInputMethod.Enum.forString(methodString.toString()));
+ listOfTInputMethodBeans.add(TInputMethod.Enum
+ .forString(methodString.toString()));
}
// by default a parameter is mapped to all input methods
if (listOfTInputMethodBeans.size() == 0) {
@@ -220,38 +211,37 @@
}
/*
- * For each input method, we check that the mapped observer:
- * - can handle this input method
- * - has a parameter with the corresponding name for this input
- * method
- * - can handle this value for this parameter
+ * For each input method, we check that the mapped observer: - can
+ * handle this input method - has a parameter with the corresponding
+ * name for this input method - can handle this value for this parameter
*/
for (final TInputMethod.Enum aTInputMethod : listOfTInputMethodBeans) {
final EnumInputMethod aEnumInputMethod;
- aEnumInputMethod = TaskListUnmarshallerBeans.getEnumInputMethod(aTInputMethod);
+ aEnumInputMethod = TaskListUnmarshallerBeans
+ .getEnumInputMethod(aTInputMethod);
// the observer can handle this input method
if (aObserverMapped.getInputMethod(aEnumInputMethod) == null) {
- TaskListUnmarshallerBeans.logger.warn(
- sMappingObserver + " does not support " +
- aEnumInputMethod.value() + " input method.");
+ TaskListUnmarshallerBeans.logger.warn(sMappingObserver
+ + " does not support " + aEnumInputMethod.value()
+ + " input method.");
continue;
}
final CallParameter aCallParameterMapped;
- aCallParameterMapped = aObserverMapped.getInputMethod(aEnumInputMethod).getCallParameterByName(sMappingParam);
+ aCallParameterMapped = aObserverMapped.getInputMethod(
+ aEnumInputMethod).getCallParameterByName(sMappingParam);
// the parameter exists
if (aCallParameterMapped == null) {
- TaskListUnmarshallerBeans.logger.error(
- sMappingObserver + " does not have " +
- "a parameter named " + sMappingParam + ".");
+ TaskListUnmarshallerBeans.logger.error(sMappingObserver
+ + " does not have " + "a parameter named "
+ + sMappingParam + ".");
continue;
}
// the value exists
if (!aCallParameterMapped.contains(sMappingValue)) {
- TaskListUnmarshallerBeans.logger.error(
- "Parameter " + sMappingParam +
- " does not accept " + sMappingValue +
- " as a value.");
+ TaskListUnmarshallerBeans.logger.error("Parameter "
+ + sMappingParam + " does not accept " + sMappingValue
+ + " as a value.");
continue;
}
listOfEnumInputMethod.add(aEnumInputMethod);
@@ -261,36 +251,36 @@
return null;
}
- return new Mapping(
- aObserverMapped,
- sMappingParam,
- sMappingValue/*,
- listOfEnumInputMethod*/);
+ return new Mapping(aObserverMapped, sMappingParam, sMappingValue/*
+ * ,
+ * listOfEnumInputMethod
+ */);
}
-
- private Parameter getParameterFromObserver (
- final String sParamName,
- final String sObserverName,
- final TUi.Enum aTUi,
- final String sDefaultValues,
- final TParamType.Enum aTParamType) throws ParameterException {
+ private Parameter getParameterFromObserver(final String sParamName,
+ final String sObserverName, final TUi.Enum aTUi,
+ final String sDefaultValues, final TParamType.Enum aTParamType)
+ throws ParameterException {
TaskListUnmarshallerBeans.logger.trace("getParameterFromObserver");
if (TaskListUnmarshallerBeans.logger.isDebugEnabled()) {
- TaskListUnmarshallerBeans.logger.debug("Parameter name : "+sParamName+".");
- TaskListUnmarshallerBeans.logger.debug("Observer name : "+sObserverName+".");
- TaskListUnmarshallerBeans.logger.debug("TUi : "+aTUi+".");
- TaskListUnmarshallerBeans.logger.debug("Default values : "+sDefaultValues+".");
- TaskListUnmarshallerBeans.logger.debug("TParamType : "+aTParamType+".");
+ TaskListUnmarshallerBeans.logger.debug("Parameter name : "
+ + sParamName + ".");
+ TaskListUnmarshallerBeans.logger.debug("Observer name : "
+ + sObserverName + ".");
+ TaskListUnmarshallerBeans.logger.debug("TUi : " + aTUi + ".");
+ TaskListUnmarshallerBeans.logger.debug("Default values : "
+ + sDefaultValues + ".");
+ TaskListUnmarshallerBeans.logger.debug("TParamType : "
+ + aTParamType + ".");
}
final Observer aObserver = this.mapOfObserver.get(sObserverName);
// does the requested observer exist?
if (aObserver == null) {
- TaskListUnmarshallerBeans.logger.warn(
- "The parameter " + sParamName + "refers to a " +
- "non-existing observer: " + sObserverName + ".");
+ TaskListUnmarshallerBeans.logger.warn("The parameter " + sParamName
+ + "refers to a " + "non-existing observer: "
+ + sObserverName + ".");
return null;
}
@@ -302,23 +292,27 @@
final Map<String, Value> mapOfValue = new LinkedHashMap<String, Value>();
// iterate over the observer's methods
- final Map<EnumInputMethod, InputMethod> mapOfInputMethod = aObserver.getMapOfInputMethod();
+ final Map<EnumInputMethod, InputMethod> mapOfInputMethod = aObserver
+ .getMapOfInputMethod();
for (final EnumInputMethod aEnumInputMethod : mapOfInputMethod.keySet()) {
- final InputMethod aInputMethod = mapOfInputMethod.get(aEnumInputMethod);
+ final InputMethod aInputMethod = mapOfInputMethod
+ .get(aEnumInputMethod);
if (aInputMethod.getCallParameter().getName().equals(sParamName)) {
// the referenced parameter is an input one for the current
// method, so it must be ignored
- TaskListUnmarshallerBeans.logger.info(
- "The referenced parameter is an input one for the current method, so it must be ignored.");
+ TaskListUnmarshallerBeans.logger
+ .info("The referenced parameter is an input one for the current method, so it must be ignored.");
continue;
}
final CallMethod aCallMethod = aInputMethod.getCallMethod();
- final CallParameter aCallParameter = aCallMethod.getCallParameterByName(sParamName);
+ final CallParameter aCallParameter = aCallMethod
+ .getCallParameterByName(sParamName);
// A parameter with this name exists for this method
if (aCallParameter != null) {
- for (final String sValue : aCallParameter.getListOfPossibleValue()) {
+ for (final String sValue : aCallParameter
+ .getListOfPossibleValue()) {
final Value aValueCurrent = mapOfValue.get(sValue);
if (aValueCurrent != null) {
// the newly created parameter already contains a
@@ -326,22 +320,20 @@
// we know that the created parameter contains exactly
// ONE mapping for this value
- //aValueCurrent.getMappings().get(sObserverName).get(0).addInputMethod(aEnumInputMethod);
- }
- else {
+ // aValueCurrent.getMappings().get(sObserverName).get(0).addInputMethod(aEnumInputMethod);
+ } else {
// the newly created parameter does not contain a
// similar value
final LocalizedString aInternationalizedMessageValueName;
aInternationalizedMessageValueName = new LocalizedString();
// TODO Add localized names in RDF contract
- aInternationalizedMessageValueName.addLocalization("en", sValue);
+ aInternationalizedMessageValueName.addLocalization(
+ "en", sValue);
final List<EnumInputMethod> mapOfNewInputMethod = new ArrayList<EnumInputMethod>();
mapOfNewInputMethod.add(aEnumInputMethod);
- final Mapping aMapping = new Mapping(
- aObserver,
- sParamName,
- sValue);
+ final Mapping aMapping = new Mapping(aObserver,
+ sParamName, sValue);
final List<Mapping> listOfMapping = new ArrayList<Mapping>();
listOfMapping.add(aMapping);
@@ -352,74 +344,69 @@
final Value aValueToAdd = new Value(
aInternationalizedMessageValueName,
- mapOfListOfMapping,
- sValue);
+ mapOfListOfMapping, sValue);
mapOfValue.put(sValue, aValueToAdd);
}
}
}
}
- return this.createParameter(
- aTParamType,
- sParamName,
- aTUi,
- sDefaultValues,
- mapOfValue);
+ return this.createParameter(aTParamType, sParamName, aTUi,
+ sDefaultValues, mapOfValue);
}
-
/**
* Create the tree from a TaskType element
- *
+ *
* @param myTask
* the task to transform into a tree
*/
public TLTNode ExpandTree(TaskType myTask) {
- TaskListUnmarshallerBeans.logger.trace("Creation of the tree based on the Task "
- + myTask.getId());
+ TaskListUnmarshallerBeans.logger
+ .trace("Creation of the tree based on the Task "
+ + myTask.getId());
TLTNode root = new TLTNode();
root.setID(NodeID++);
for (ExecType exec : myTask.getRoutine().getExecArray()) {
- final Observer obs=Framework.mapOfObserver.get(exec.getValue());
- root.addExec(new TLTExec(exec.getId(), obs,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));
+ root.addIf(fillIfs(myTask, iflist));
}
return root;
}
/**
* Recursion over the Then tag to fill the tree
- *
+ *
* @param myThen
* the ThenType node for the recursion
* @return the node created
*/
- private TLTNode FillNode(TaskType myTask,ThenType myThen) {
+ private TLTNode FillNode(TaskType myTask, ThenType myThen) {
TaskListUnmarshallerBeans.logger.trace("Creation of a then branch ");
TLTNode node = new TLTNode();
node.setID(NodeID++);
for (ExecType exec : myThen.getExecArray()) {
- final Observer obs=Framework.mapOfObserver.get(exec.getValue());
- node.addExec(new TLTExec(exec.getId(),obs, 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));
+ node.addIf(fillIfs(myTask, iflist));
}
return node;
}
/**
* Created the Ifnode in the tree
- *
+ *
* @param ifs
* the IfType node template to create the Ifnode
* @return the node created
*/
- private TLTIf fillIfs(TaskType myTask,IfType ifs) {
+ private TLTIf fillIfs(TaskType myTask, IfType ifs) {
TaskListUnmarshallerBeans.logger.trace("Creation of an If ");
// Create the if node
TLTIf ifnode = new TLTIf();
@@ -431,9 +418,11 @@
for (CondType condlist : myTask.getConds().getCondArray()) {
if (condlist.getId().equals(cond)) {
- TaskListUnmarshallerBeans.logger.trace("Creation of a condition " + cond);
+ TaskListUnmarshallerBeans.logger
+ .trace("Creation of a condition " + cond);
myCond.setId(condlist.getId());
- final Observer obs=Framework.mapOfObserver.get(condlist.getObserver());
+ final Observer obs = Framework.mapOfObserver.get(condlist
+ .getObserver());
myCond.setObserver(obs);
myCond
.setResult(condlist.getResult().equals("passed") ? true
@@ -450,36 +439,37 @@
// 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()));
+ TaskListUnmarshallerBeans.logger
+ .trace("Call recursion for the Then ");
+ 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()));
+ TaskListUnmarshallerBeans.logger
+ .trace("Call recursion for the else");
+ ifnode.setIfNotOk(FillNode(myTask, ifs.getElse()));
}
}
return ifnode;
}
-
-
-
- private org.w3c.unicorn.tasklist.parameters.Parameter createParameter (
- final TParamType.Enum aTParamType,
- final String sName,
- final TUi.Enum aTUi,
- final String sDefaultValues,
+ private org.w3c.unicorn.tasklist.parameters.Parameter createParameter(
+ final TParamType.Enum aTParamType, final String sName,
+ final TUi.Enum aTUi, final String sDefaultValues,
final Map<String, Value> mapOfValue) throws ParameterException {
TaskListUnmarshallerBeans.logger.trace("createParameter");
if (TaskListUnmarshallerBeans.logger.isDebugEnabled()) {
- TaskListUnmarshallerBeans.logger.debug("TParamType : "+aTParamType+".");
- TaskListUnmarshallerBeans.logger.debug("Name : "+sName+".");
- TaskListUnmarshallerBeans.logger.debug("TUi : "+aTUi+".");
- TaskListUnmarshallerBeans.logger.debug("Default values : "+sDefaultValues+".");
- TaskListUnmarshallerBeans.logger.debug("Map of value : "+mapOfValue+".");
+ TaskListUnmarshallerBeans.logger.debug("TParamType : "
+ + aTParamType + ".");
+ TaskListUnmarshallerBeans.logger.debug("Name : " + sName + ".");
+ TaskListUnmarshallerBeans.logger.debug("TUi : " + aTUi + ".");
+ TaskListUnmarshallerBeans.logger.debug("Default values : "
+ + sDefaultValues + ".");
+ TaskListUnmarshallerBeans.logger.debug("Map of value : "
+ + mapOfValue + ".");
}
- final org.w3c.unicorn.tasklist.parameters.Parameter aParameter = ParameterFactory.getParameter(aTParamType);
+ final org.w3c.unicorn.tasklist.parameters.Parameter aParameter = ParameterFactory
+ .getParameter(aTParamType);
if (null == aParameter) {
return null;
}
@@ -490,55 +480,53 @@
return aParameter;
}
-
/**
* Wraps a TInputMethod instance on an EnumInputMethod
+ *
* @param aTInputMethod
* @return
*/
- private static EnumInputMethod getEnumInputMethod (final TInputMethod.Enum aTInputMethod) {
+ private static EnumInputMethod getEnumInputMethod(
+ final TInputMethod.Enum aTInputMethod) {
switch (aTInputMethod.intValue()) {
- case TInputMethod.INT_DIRECT:
- return EnumInputMethod.DIRECT;
- case TInputMethod.INT_FILE:
- return EnumInputMethod.UPLOAD;
- case TInputMethod.INT_URI:
- return EnumInputMethod.URI;
- default:
- return EnumInputMethod.URI;
+ case TInputMethod.INT_DIRECT:
+ return EnumInputMethod.DIRECT;
+ case TInputMethod.INT_FILE:
+ return EnumInputMethod.UPLOAD;
+ case TInputMethod.INT_URI:
+ return EnumInputMethod.URI;
+ default:
+ return EnumInputMethod.URI;
}
}
-
-
public Map<String, org.w3c.unicorn.tasklist.Task> getMapOfTask() {
TaskListUnmarshallerBeans.logger.trace("getMapOfTask");
return this.mapOfTask;
}
- public void addURL(URL aURL) throws IOException{
+ public void addURL(URL aURL) throws IOException {
TaskListUnmarshallerBeans.logger.trace("addURL");
if (TaskListUnmarshallerBeans.logger.isDebugEnabled()) {
- TaskListUnmarshallerBeans.logger.debug("URL : "+aURL+".");
+ TaskListUnmarshallerBeans.logger.debug("URL : " + aURL + ".");
}
- try {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- this.aTaskList = TasklistDocument.Factory.parse(aURL.openStream());
- } catch (XmlException e) {
- TaskListUnmarshallerBeans.logger.error("Parsing error in TasklistUnmarshaller",e);
- e.printStackTrace();
- }
+ try {
+ this.aTaskList = TasklistDocument.Factory.parse(aURL.openStream());
+ } catch (XmlException e) {
+ TaskListUnmarshallerBeans.logger.error(
+ "Parsing error in TasklistUnmarshaller", e);
+ e.printStackTrace();
+ }
}
-
-
public void unmarshal() throws Exception {
TaskListUnmarshallerBeans.logger.trace("unmarshal tasklist");
// creates the tasklist without computing references
for (final TaskType aTask : this.aTaskList.getTasklist().getTaskArray()) {
if (this.mapOfTask.containsKey(aTask.getId())) {
- TaskListUnmarshallerBeans.logger.warn("Task with id "+aTask.getId()+" already defined.");
+ TaskListUnmarshallerBeans.logger.warn("Task with id "
+ + aTask.getId() + " already defined.");
} else {
this.addTask(aTask);
}
@@ -546,8 +534,10 @@
// computes and replaces references by their corresponding observations
// and parameters
- for (final org.w3c.unicorn.tasklist.Task aTask : this.mapOfTask.values()) {
- TaskListUnmarshallerBeans.logger.debug("Expand task : "+aTask.getID()+".");
+ for (final org.w3c.unicorn.tasklist.Task aTask : this.mapOfTask
+ .values()) {
+ TaskListUnmarshallerBeans.logger.debug("Expand task : "
+ + aTask.getID() + ".");
aTask.setTree(aTask.expandNode(mapOfTask, aTask.getTree()));
}
Index: TasksListUnmarshaller.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/tasklist/TasksListUnmarshaller.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- TasksListUnmarshaller.java 26 Aug 2008 15:26:37 -0000 1.3
+++ TasksListUnmarshaller.java 11 Aug 2009 13:43:00 -0000 1.4
@@ -12,14 +12,16 @@
* TasksListUnmarshaller<br />
* Created: May 30, 2006 5:54:45 PM<br />
* Interface used to retreive a list of tasks
+ *
* @author Jean-Guilhem ROUEL
*/
public interface TasksListUnmarshaller extends Unmarshaller {
- /**
- * Returns the map of tasks.
- * @return Returns the tasks.
- */
- public abstract Map<String, org.w3c.unicorn.tasklist.Task> getMapOfTask();
-
+ /**
+ * Returns the map of tasks.
+ *
+ * @return Returns the tasks.
+ */
+ public abstract Map<String, org.w3c.unicorn.tasklist.Task> getMapOfTask();
+
}
Index: Task.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/tasklist/Task.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Task.java 19 Sep 2008 18:57:12 -0000 1.4
+++ Task.java 11 Aug 2009 13:43:00 -0000 1.5
@@ -8,17 +8,16 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+
import javax.activation.MimeType;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.w3c.unicorn.contract.Observer;
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;
-import org.w3c.unicorn.contract.Observer;
/**
* Task<br />
@@ -26,9 +25,6 @@
*/
public class Task {
- private static final Log logger = LogFactory
- .getLog("org.w3c.unicorn.tasklist");
-
/**
* Id of the task
*/
@@ -44,7 +40,6 @@
*/
private LocalizedString aLocalizedStringDescription;
-
/**
* Parameters of the task
*/
@@ -56,16 +51,10 @@
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.
*/
@@ -76,7 +65,7 @@
this.mapOfTaskParameter = new LinkedHashMap<String, Parameter>();
this.listOfReference = new ArrayList<String>();
}
-
+
/**
* Allows to display the tree of execution level
*
@@ -89,29 +78,28 @@
}
for (TLTIf ifs : root.getIfList()) {
displayTree(ifs.getIfOk());
- for (TLTCond conds : ifs.getCondArray())
+ 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;
+ this.root = root;
}
-
-
/**
* Creates a new Task.
@@ -275,7 +263,6 @@
this.mapOfTaskParameter.put(aParameter.getName(), aParameter);
}
-
/**
* Returns a list of tasknames referenced bye this task
*
@@ -285,221 +272,104 @@
return this.listOfReference;
}
- public List<Observer> getAllObservers() {
- if(this.getTree() != null) {
- return this.getTree().getAllObservers();
- }
- return new ArrayList<Observer>();
- }
-
- // MimeType's equals() doesn't work as expected
- // so it's easier to store the String representation
- // of mime types :-/
- public List<String> getSupportedMimeTypes() {
- List<String> res = new ArrayList<String>();
- List<Observer> observers = getAllObservers();
- for(Observer o : observers) {
- List<MimeType> mimes = o.getSupportedMimeTypes();
- for(MimeType m : mimes) {
- if(!res.contains(m.toString())) {
- res.add(m.toString());
- }
- }
- }
- return res;
- }
-
- /**
- * 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.
- *
- * @param 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
- // it's because he add reference in this.references
- for (final String sReference : this.listOfReference) {
- listOfOldReference.add(sReference);
- }
-
- 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");
- 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)) {
- 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");
- continue;
- }
- this.listOfReference.add(sNewReference);
- this.merge(aTaskCurrentRef);
- }
+ public List<Observer> getAllObservers() {
+ if (this.getTree() != null) {
+ return this.getTree().getAllObservers();
}
+ return new ArrayList<Observer>();
}
- */
- /**
- * Merges another task with this one
- *
- * @param aNotherTask
- * the task to merge
- */
- /*
- 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
- */
- /*
- 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);
- if (this.mapOfObservation.containsKey(sObservationID)) {
- this.mapOfObservation.get(sObservationID).merge(aObservation);
- } else {
- this.mapOfObservation.put(sObservationID, aObservation);
- }
- }
- }
-*/
- /**
- * Merges parameters of another task with this one.
- *
- * @param aNotherTask
- * the other task to merge
- */
- 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) {
- aLocalParameter.merge(aNotherParameter);
- } else {
- this.mapOfTaskParameter.put(sParameterName, aNotherParameter);
+ // MimeType's equals() doesn't work as expected
+ // so it's easier to store the String representation
+ // of mime types :-/
+ public List<String> getSupportedMimeTypes() {
+ List<String> res = new ArrayList<String>();
+ List<Observer> observers = getAllObservers();
+ for (Observer o : observers) {
+ List<MimeType> mimes = o.getSupportedMimeTypes();
+ for (MimeType m : mimes) {
+ if (!res.contains(m.toString())) {
+ res.add(m.toString());
+ }
}
}
+ return res;
}
-
-
public void mergeSubtask(final Map<String, Task> mapOfTask, Task subtask) {
for (TLTExec exec : subtask.getTree().getExecutionList()) {
- if (exec.getType().equals("observation"))
+ if (exec.getType().equals("observation")) {
this.root.addExec(exec);
- else if (exec.getType().equals("subtask")) {
+ } else if (exec.getType().equals("subtask")) {
Task newTask = mapOfTask.get(exec.getValue());
- newTask.expandNode(mapOfTask,newTask.getTree());
- mergeSubtask(mapOfTask,newTask);
+ 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 = 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);
+
+ 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;
+ 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
@@ -511,6 +381,7 @@
this.listOfReference.add(sReference);
}
+ @Override
public String toString() {
final int iStringBufferSize = 5000;
final String sVariableSeparator = "\n";
@@ -526,5 +397,4 @@
return aStringBuffer.toString();
}
-
}
Received on Tuesday, 11 August 2009 13:43:46 UTC