W3C home > Mailing lists > Public > www-validator-cvs@w3.org > August 2009

2006/unicorn/src/org/w3c/unicorn/tasklist Tasklist.java,NONE,1.1.2.1 TasksListUnmarshaller.java,1.1.2.1,1.1.2.2 TaskListUnmarshallerBeans.java,1.1.2.4,1.1.2.5 Task.java,1.1.2.2,1.1.2.3 RDFUnmarshallerJena.java,1.1.2.6,1.1.2.7 RDFUnmarshaller.java,1.1.2.1,1.1.2.2

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 20 Aug 2009 14:06:24 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1Me8HY-0004cP-JU@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/tasklist
In directory hutz:/tmp/cvs-serv17691/src/org/w3c/unicorn/tasklist

Modified Files:
      Tag: dev2
	TasksListUnmarshaller.java TaskListUnmarshallerBeans.java 
	Task.java RDFUnmarshallerJena.java RDFUnmarshaller.java 
Added Files:
      Tag: dev2
	Tasklist.java 
Log Message:
added the possibility to define the default task (selected task when ucn_task parameter is not specified) by adding ucn:default="true" to the task metadata in the corresponding rdf file. If ucn:default is to be found nowhere, the default task will be the first one found until next initialization (in this case an error is logged).

Index: RDFUnmarshallerJena.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/tasklist/Attic/RDFUnmarshallerJena.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -d -r1.1.2.6 -r1.1.2.7
--- RDFUnmarshallerJena.java	18 Aug 2009 11:51:34 -0000	1.1.2.6
+++ RDFUnmarshallerJena.java	20 Aug 2009 14:06:22 -0000	1.1.2.7
@@ -57,10 +57,12 @@
 	private static Property PROPERTY_TYPE = null;
 
 	private static Property PROPERTY_VALUE = null;
+	
+	private static Property PROPERTY_DEFAULT = null;
 
 	private Map<String, Observer> mapOfObserver = null;
 
-	private Map<String, Task> mapOfTask = null;
+	private Tasklist<String, Task> mapOfTask = null;
 
 	private Model aModel = null;
 
@@ -270,14 +272,15 @@
 		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() + ".");
 			Framework.logger.warn("> Found unused metadata for: " + aReference.getLiteral().getString());
 			return;
 		} else {
 			Framework.logger.debug("> Found metadata for: " + aReference.getLiteral().getString());
+			Statement isDefault = aTask.getProperty(RDFUnmarshallerJena.PROPERTY_DEFAULT);
+			if (isDefault != null && isDefault.getLiteral().toString().equals("true")) {
+				this.mapOfTask.setDefaultTaskId(aReference.getLiteral().getString());
+				Framework.logger.debug(">> This is the default task.");
+			}
 		}
 		RDFUnmarshallerJena.logger.debug("Reference : "
 				+ aReference.getObject().toString() + ".");
@@ -347,7 +350,7 @@
 	/**
 	 * @return Returns the tasks.
 	 */
-	public Map<String, Task> getMapOfTask() {
+	public Tasklist<String, Task> getMapOfTask() {
 		return this.mapOfTask;
 	}
 
@@ -355,7 +358,7 @@
 	 * @param mapOfTask
 	 *            The tasks to set.
 	 */
-	public void setMapOfTask(final Map<String, Task> mapOfTask) {
+	public void setMapOfTask(final Tasklist<String, Task> mapOfTask) {
 		this.mapOfTask = mapOfTask;
 	}
 
@@ -455,5 +458,14 @@
 		return UCN_NAMESPACE;
 	}
 
+	public static Property getPROPERTY_DEFAULT() {
+		return PROPERTY_DEFAULT;
+	}
+
+	public static void setPROPERTY_DEFAULT(Property pROPERTYDEFAULT) {
+		PROPERTY_DEFAULT = pROPERTYDEFAULT;
+	}
+
+	
 	
 }

Index: TaskListUnmarshallerBeans.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/tasklist/Attic/TaskListUnmarshallerBeans.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -d -r1.1.2.4 -r1.1.2.5
--- TaskListUnmarshallerBeans.java	17 Aug 2009 17:54:31 -0000	1.1.2.4
+++ TaskListUnmarshallerBeans.java	20 Aug 2009 14:06:22 -0000	1.1.2.5
@@ -59,8 +59,9 @@
 	/**
 	 * The tasklist corresponding to the xml file
 	 */
-	private Map<String, Task> mapOfTask;
-
+	//private Map<String, Task> mapOfTask;
+	private Tasklist<String, Task> mapOfTask;
+	
 	/**
 	 * The observers' list used to check some constraints on the tasks
 	 */
@@ -71,7 +72,8 @@
 
 	public TaskListUnmarshallerBeans(final Map<String, Observer> mapOfObserver) {
 		TaskListUnmarshallerBeans.logger.trace("Constructor");
-		this.mapOfTask = new LinkedHashMap<String, org.w3c.unicorn.tasklist.Task>();
+		//this.mapOfTask = new LinkedHashMap<String, org.w3c.unicorn.tasklist.Task>();
+		this.mapOfTask = new Tasklist<String, org.w3c.unicorn.tasklist.Task>();
 		this.mapOfObserver = mapOfObserver;
 	}
 
@@ -477,7 +479,7 @@
 		}
 	}
 
-	public Map<String, org.w3c.unicorn.tasklist.Task> getMapOfTask() {
+	public Tasklist<String, org.w3c.unicorn.tasklist.Task> getMapOfTask() {
 		TaskListUnmarshallerBeans.logger.trace("getMapOfTask");
 		return this.mapOfTask;
 	}

Index: RDFUnmarshaller.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/tasklist/Attic/RDFUnmarshaller.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- RDFUnmarshaller.java	11 Aug 2009 16:05:40 -0000	1.1.2.1
+++ RDFUnmarshaller.java	20 Aug 2009 14:06:22 -0000	1.1.2.2
@@ -15,11 +15,11 @@
  */
 public interface RDFUnmarshaller extends Unmarshaller {
 
-	public abstract Map<String, Task> getMapOfTask();
+	public abstract Tasklist<String, Task> getMapOfTask();
 
 	public abstract void setMapOfObserver(
 			final Map<String, Observer> mapOfObserver);
 
-	public abstract void setMapOfTask(final Map<String, Task> mapOfTask);
+	public abstract void setMapOfTask(final Tasklist<String, Task> mapOfTask);
 
 }

--- NEW FILE: Tasklist.java ---
package org.w3c.unicorn.tasklist;

import java.util.LinkedHashMap;

import org.w3c.unicorn.Framework;

public class Tasklist<K, V> extends LinkedHashMap<String, Task> {

	private static final long serialVersionUID = -868579272922431097L;

	private String defaultTaskId;

	public String getDefaultTaskId() {
		if (defaultTaskId == null) {
			String id = Framework.mapOfTask.values().toArray(new Task[0])[0].getID();
			Framework.logger.error("There is no default task defined in task rdf files. Returning first found id: \"" + id + "\" . Please add ucn:default=\"true\" to the default task.");
			this.defaultTaskId = id;
			return Framework.mapOfTask.values().toArray(new Task[0])[0].getID();
		}			
		else
			return defaultTaskId;
	}

	public void setDefaultTaskId(String defaultTaskId) {
		this.defaultTaskId = defaultTaskId;
	}

	@Override
	public java.lang.String toString() {
		String s = "";
		for (String key : this.keySet()) {
			s += get(key) + "\n";
		}
		return s;
	}

}

Index: Task.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/tasklist/Attic/Task.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -d -r1.1.2.2 -r1.1.2.3
--- Task.java	19 Aug 2009 18:52:58 -0000	1.1.2.2
+++ Task.java	20 Aug 2009 14:06:22 -0000	1.1.2.3
@@ -400,18 +400,17 @@
 		final StringBuffer aStringBuffer = new StringBuffer(iStringBufferSize);
 		
 		aStringBuffer.append(sVariableSeparator);
-		aStringBuffer.append("ID:").append(sID);
+		aStringBuffer.append(sID);
 		aStringBuffer.append(sVariableSeparator);
-		aStringBuffer.append("parameters:\n"); //.append(this.mapOfTaskParameter);
+		aStringBuffer.append("\tparameters:\n"); //.append(this.mapOfTaskParameter);
 		for (String key : mapOfTaskParameter.keySet()) {
 			Parameter param = mapOfTaskParameter.get(key);
-			aStringBuffer.append("\t" + key + " (" + param.getUiLevel() + "-" + param.getType() + ") => \n");
+			aStringBuffer.append("\t\t" + key + " (" + param.getUiLevel() + "-" + param.getType() + ") => \n");
 			for (String key1: param.getMapOfValue().keySet()) {
-				aStringBuffer.append("\t\t" + key1 + " => " + mapOfTaskParameter.get(key).getMapOfValue().get(key1) + "\n");
+				aStringBuffer.append("\t\t\t" + key1 + " => " + mapOfTaskParameter.get(key).getMapOfValue().get(key1) + "\n");
 			}
 		}
-		aStringBuffer.append(sVariableSeparator);
-		aStringBuffer.append("references:").append(this.listOfReference);
+		aStringBuffer.append("\treferences:").append(this.listOfReference);
 
 		return aStringBuffer.toString();
 	}

Index: TasksListUnmarshaller.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/tasklist/Attic/TasksListUnmarshaller.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- TasksListUnmarshaller.java	11 Aug 2009 16:05:39 -0000	1.1.2.1
+++ TasksListUnmarshaller.java	20 Aug 2009 14:06:22 -0000	1.1.2.2
@@ -4,8 +4,6 @@
 // Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.unicorn.tasklist;
 
-import java.util.Map;
-
 import org.w3c.unicorn.util.Unmarshaller;
 
 /**
@@ -22,6 +20,6 @@
 	 * 
 	 * @return Returns the tasks.
 	 */
-	public abstract Map<String, org.w3c.unicorn.tasklist.Task> getMapOfTask();
+	public abstract Tasklist<String, org.w3c.unicorn.tasklist.Task> getMapOfTask();
 
 }
Received on Thursday, 20 August 2009 14:06:34 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:38 UTC