2006/unicorn/src/org/w3c/unicorn UnicornCall.java,1.6,1.7

Update of /sources/public/2006/unicorn/src/org/w3c/unicorn
In directory hutz:/tmp/cvs-serv13205/src/org/w3c/unicorn

Modified Files:
	UnicornCall.java 
Log Message:
created classes Ouput and Group to be xmlbeans independent

Index: UnicornCall.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/UnicornCall.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- UnicornCall.java	3 Sep 2009 16:43:21 -0000	1.6
+++ UnicornCall.java	4 Sep 2009 13:45:13 -0000	1.7
@@ -29,7 +29,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.event.EventCartridge;
-import org.w3.unicorn.tasklist.GroupType;
 import org.w3c.dom.Document;
 import org.w3c.unicorn.contract.CallParameter;
 import org.w3c.unicorn.contract.EnumInputMethod;
@@ -43,6 +42,7 @@
 import org.w3c.unicorn.request.RequestList;
 import org.w3c.unicorn.response.Response;
 import org.w3c.unicorn.response.parser.ResponseParserFactory;
+import org.w3c.unicorn.tasklist.Group;
 import org.w3c.unicorn.tasklist.Task;
 import org.w3c.unicorn.tasklist.parameters.Mapping;
 import org.w3c.unicorn.tasklist.parameters.Parameter;
@@ -599,36 +599,40 @@
 	 */
 	public LinkedHashMap<String, Response> getObservationList() {
 		
-		LinkedHashMap<String, Response> tempMap = new LinkedHashMap<String, Response>();
+		LinkedHashMap<String, Response> observationMap = new LinkedHashMap<String, Response>();
 		
-		for (GroupType group : aTask.getOutput().getGroupList()) {
+		for (Group group : aTask.getOutput().getGroupList()) {
 			if (!group.isSetType()) {
 				for (String observerId : group.getObservationList()) {
 					if(mapOfResponse.get(observerId) != null) {
-						tempMap.put(observerId, mapOfResponse.get(observerId));
+						observationMap.put(observerId, mapOfResponse.get(observerId));
 					}
 				}
 			} else {
-				String type = group.getType().toString();
-				if (type.equals("firstPassed")) {
-					
-					String passedId = null;
-					
-					for (String observerId : group.getObservationList()) {
-						if (mapOfResponse.get(observerId).isPassed()) {
-							passedId = observerId;
-							break;
+				switch (group.getType()) {
+					case FIRSTPASSED:
+						String passedId = null;
+						for (String observerId : group.getObservationList()) {
+							if (mapOfResponse.get(observerId) == null) {
+								logger.error("unknown observer id (" + observerId + ") in output group of task: " + this.getTask().getID());
+								continue;
+							}
+							if (mapOfResponse.get(observerId).isPassed()) {
+								passedId = observerId;
+								break;
+							}
 						}
-					}
-					if (passedId == null)
-						tempMap.put(group.getObservationList().get(0), mapOfResponse.get(group.getObservationList().get(0)));
-					else
-						tempMap.put(passedId, mapOfResponse.get(passedId));
+						if (passedId == null) {
+							Response resp = mapOfResponse.get(group.getObservationList().get(0));
+							if (resp != null)
+								observationMap.put(group.getObservationList().get(0), resp);
+						}
+						else 
+							observationMap.put(passedId, mapOfResponse.get(passedId));
 				}
 			}
 		}
-		
-		return tempMap;
+		return observationMap;
 	}
 	
 	public String getObserverName(String observer, String lang) {

Received on Friday, 4 September 2009 13:45:25 UTC