You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hise-commits@incubator.apache.org by rr...@apache.org on 2010/07/15 11:34:05 UTC

svn commit: r964389 - in /incubator/hise/trunk: hise-bundle/src/main/resources/META-INF/spring/ hise-services/src/main/java/org/apache/hise/api/ hise-services/src/main/java/org/apache/hise/engine/ hise-services/src/main/java/org/apache/hise/runtime/ hi...

Author: rr
Date: Thu Jul 15 11:34:04 2010
New Revision: 964389

URL: http://svn.apache.org/viewvc?rev=964389&view=rev
Log:
HISE-49: 3.2.1 Using Logical People Groups (Thanks to Piotr Zagórski)

Added:
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/api/PeopleQueryProvider.java
    incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/PeoplePovider.java
Modified:
    incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEEngineImpl.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskEvaluator.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/utils/DOMUtils.java
    incubator/hise/trunk/hise-test-example-osgi/pom.xml
    incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/SampleUsers.java
    incubator/hise/trunk/hise-test-example-osgi/src/main/resources/META-INF/spring/hise-itest.xml
    incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml
    incubator/hise/trunk/itest/hise-soapui-project.xml

Modified: incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml?rev=964389&r1=964388&r2=964389&view=diff
==============================================================================
--- incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml (original)
+++ incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml Thu Jul 15 11:34:04 2010
@@ -58,6 +58,9 @@
     <property name="hiseDao" ref="hiseDao"/>
     <property name="hiseScheduler" ref="hiseScheduler"/>
     <property name="hiseUserDetails" ref="hiseUserDetails"/>
+    <property name="peopleQueryProviders">
+        <osgi:list interface="org.apache.hise.api.PeopleQueryProvider" cardinality="0..N"/>
+    </property>
   </bean>
 
   <osgi:service id="hiseEngineOsgi" ref="hiseEngine" interface="org.apache.hise.api.HISEEngine" />

Added: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/api/PeopleQueryProvider.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/api/PeopleQueryProvider.java?rev=964389&view=auto
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/api/PeopleQueryProvider.java (added)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/api/PeopleQueryProvider.java Thu Jul 15 11:34:04 2010
@@ -0,0 +1,66 @@
+package org.apache.hise.api;
+
+import java.util.List;
+import java.util.Map;
+import javax.xml.namespace.QName;
+
+/**
+ *
+ * @author pzg at touk.pl
+ */
+public interface PeopleQueryProvider {
+
+    public static enum RecordType {
+
+        USER, GROUP;
+    }
+
+    public boolean providesQuery(QName queryName);
+
+    public List<QueryRecord> query(QName queryName, Map<String, Parameter> parameters);
+
+    public class Parameter {
+        private String name;
+        private QName type;
+        private Object value;
+
+        public Parameter(String name, QName type, Object value) {
+            this.name = name;
+            this.type = type;
+            this.value = value;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public QName getType() {
+            return type;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+    }
+
+    public class QueryRecord {
+
+        private String name;
+        private RecordType type;
+
+        public QueryRecord(String name, RecordType type) {
+            this.name = name;
+            this.type = type;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public RecordType getType() {
+            return type;
+        }
+
+    }
+}

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEEngineImpl.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEEngineImpl.java?rev=964389&r1=964388&r2=964389&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEEngineImpl.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEEngineImpl.java Thu Jul 15 11:34:04 2010
@@ -19,6 +19,7 @@
 
 package org.apache.hise.engine;
 
+import java.util.ArrayList;
 import org.apache.commons.lang.Validate;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -40,6 +41,9 @@ import javax.xml.namespace.QName;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import org.apache.hise.api.PeopleQueryProvider;
+import org.apache.hise.api.PeopleQueryProvider.Parameter;
+import org.apache.hise.api.PeopleQueryProvider.QueryRecord;
 
 public class HISEEngineImpl implements HISEEngine {
 
@@ -52,6 +56,8 @@ public class HISEEngineImpl implements H
     private HISEUserDetails hiseUserDetails;
     
     private HISEScheduler hiseScheduler;
+
+    private List<PeopleQueryProvider> peopleQueryProviders;
     
     public HISEDao getHiseDao() {
         return hiseDao;
@@ -77,6 +83,14 @@ public class HISEEngineImpl implements H
         this.hiseScheduler = hiseScheduler;
     }
 
+    public List<PeopleQueryProvider> getPeopleQueryProviders() {
+        return peopleQueryProviders;
+    }
+
+    public void setPeopleQueryProviders(List<PeopleQueryProvider> peopleQueryProviders) {
+        this.peopleQueryProviders = peopleQueryProviders;
+    }
+
     public static QName getCanonicalQName(QName q) {
         String ns = q.getNamespaceURI();
         ns = ns.endsWith("/") ? ns.substring(0, ns.length() - 1) : ns;
@@ -183,6 +197,15 @@ public class HISEEngineImpl implements H
         }
     }
     
+    public List<QueryRecord> peopleQuery(QName queryName, Map<String, Parameter> parameters) {
+        List<QueryRecord> queryRecords = new ArrayList<QueryRecord>();
+        for(PeopleQueryProvider provider: peopleQueryProviders) {
+            queryRecords.addAll(provider.query(queryName, parameters));
+        }
+
+        return queryRecords;
+    }
+    
 //    /**
 //     * {@inheritDoc}
 //     */

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java?rev=964389&r1=964388&r2=964389&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java Thu Jul 15 11:34:04 2010
@@ -211,16 +211,16 @@ public class Task {
         taskDto.setEscalated(false);
         taskDto.setNotification(false);
         taskDto.setSkippable(true);
+        taskDto.setPeopleAssignments(t.getTaskEvaluator().evaluatePeopleAssignments());
         engine.getHiseDao().persist(taskDto);
         t.taskDto = taskDto;
+
         try {
             t.setStatus(Status.CREATED);
         } catch (HiseIllegalStateException e) {
             throw new IllegalStateException(e);
         }
 
-        taskDto.setPeopleAssignments(t.getTaskEvaluator().evaluatePeopleAssignments());
-
         try {
             t.setStatus(Status.READY);
         } catch (HiseIllegalStateException e) {
@@ -233,9 +233,6 @@ public class Task {
             t.__log.warn("Could not nominate owner.");
         }
         
-             
-        
-        taskDto.setSkippable(true);
         return t;
 
         // recalculatePresentationParameters();

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskEvaluator.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskEvaluator.java?rev=964389&r1=964388&r2=964389&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskEvaluator.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskEvaluator.java Thu Jul 15 11:34:04 2010
@@ -31,11 +31,11 @@ import java.util.Vector;
 import javax.xml.bind.JAXBElement;
 import javax.xml.namespace.QName;
 
-import net.sf.saxon.value.DurationValue;
-
-import org.apache.commons.lang.NotImplementedException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hise.api.PeopleQueryProvider.Parameter;
+import org.apache.hise.api.PeopleQueryProvider.QueryRecord;
+import org.apache.hise.api.PeopleQueryProvider.RecordType;
 import org.apache.hise.dao.GenericHumanRole;
 import org.apache.hise.dao.TaskOrgEntity;
 import org.apache.hise.dao.TaskOrgEntity.OrgEntityType;
@@ -52,24 +52,21 @@ import org.apache.hise.lang.xsd.htd.TToP
 import org.apache.hise.utils.DOMUtils;
 import org.apache.hise.utils.XQueryEvaluator;
 import org.apache.hise.utils.XmlUtils;
-import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
-import org.w3c.dom.bootstrap.DOMImplementationRegistry;
 
 public class TaskEvaluator {
-    
-    private Log __log = LogFactory.getLog(TaskEvaluator.class);
 
+    private Log __log = LogFactory.getLog(TaskEvaluator.class);
     private Task task;
-    
-    
+
     public TaskEvaluator(Task task) {
         this.task = task;
 
     }
 
     public static class HtdFunctions {
+
         public static Node getInput(String part) {
             TaskEvaluator te = (TaskEvaluator) XQueryEvaluator.contextObjectTL.get();
             try {
@@ -83,7 +80,7 @@ public class TaskEvaluator {
             }
         }
     }
-    
+
     public XQueryEvaluator buildQueryEvaluator() {
         XQueryEvaluator evaluator = new XQueryEvaluator();
         evaluator.setContextObject(this);
@@ -94,7 +91,7 @@ public class TaskEvaluator {
         evaluator.declareNamespace("wsa", "http://www.w3.org/2005/08/addressing");
         return evaluator;
     }
-    
+
     public Integer evaluatePriority() {
         return Integer.parseInt("" + evaluateExpression(task.getTaskDefinition().getPriority()));
     }
@@ -102,15 +99,14 @@ public class TaskEvaluator {
     private List evaluateExpression(TExpression expr) {
         return buildQueryEvaluator().evaluateExpression(XmlUtils.getStringContent(expr.getContent()), null);
     }
-    
+
     public Date evaluateDeadline(TDeadline deadline) {
         return (Date) buildQueryEvaluator().evaluateExpression("$currentEventDateTime + xs:dayTimeDuration(" + XmlUtils.getStringContent(deadline.getFor().getContent()) + ")", null).get(0);
     }
-    
+
     public Set<TaskOrgEntity> evaluatePeopleAssignments() {
         Set<TaskOrgEntity> result = new HashSet<TaskOrgEntity>();
         TPeopleAssignments p = task.getTaskDefinition().getPeopleAssignments();
-        Vector<TaskOrgEntity> vec=new Vector<TaskOrgEntity>();
  
         for (JAXBElement<TGenericHumanRole> r : p.getGenericHumanRole()) {
             GenericHumanRole assignmentRole = GenericHumanRole.valueOf(r.getName().getLocalPart().toUpperCase());
@@ -128,30 +124,69 @@ public class TaskEvaluator {
     public Set<TaskOrgEntity> evaluateGenericHumanRole(TGenericHumanRole role, GenericHumanRole assignmentRole) {
         Set<TaskOrgEntity> result = new HashSet<TaskOrgEntity>();
 
+        XQueryEvaluator evaluator = buildQueryEvaluator();
         TFrom f = role.getFrom();
+        Element literal = DOMUtils.findElement(QName.valueOf("{http://www.example.org/WS-HT}literal"), f.getContent());
+
         if (f.getLogicalPeopleGroup() != null) {
-            throw new NotImplementedException();
-        } else {
-            Element e = DOMUtils.findElement(QName.valueOf("{http://www.example.org/WS-HT}literal"), f.getContent());
-            if (e != null) {
-            	
-                for (String user : (List<String>) buildQueryEvaluator().evaluateExpression("for $i in htd:literal/htd:organizationalEntity/htd:users/htd:user return string($i)", e)) {
+            QName lpgName = f.getLogicalPeopleGroup();
+            List<Element> elements = DOMUtils.findElements(QName.valueOf("{http://www.example.org/WS-HT}argument"), f.getContent());
+
+            Map<String, Parameter> arguments = new HashMap<String, Parameter>();            
+
+            for (Element argument : elements) {
+                if (argument != null && !argument.getAttribute("name").isEmpty()) {
+                    String argumentName = argument.getAttribute("name");
+                    List ret = evaluator.evaluateExpression(argument.getTextContent(), argument);
+
+                    if (!ret.isEmpty()) {
+                        String arg = (String) ret.get(0);
+                        //TODO type from logicalPeopleGroup definition, validation?, casting?
+                        arguments.put(argumentName, new Parameter(argumentName, new QName("http://www.w3.org/2001/XMLSchema", "string"), arg));
+                    }
+                }
+            }
+
+            List<QueryRecord> qrs = task.getHiseEngine().peopleQuery(lpgName, arguments);
+
+            //TODO check if user, group exists?
+            for (QueryRecord qr : qrs) {
+                if (RecordType.USER.equals(qr.getType())) {
                     TaskOrgEntity x = new TaskOrgEntity();
                     x.setGenericHumanRole(assignmentRole);
-                    x.setName(user);
+                    x.setName(qr.getName());
                     x.setType(OrgEntityType.USER);
                     x.setTask(task.getTaskDto());
                     result.add(x);
-                }
-                for (String group : (List<String>) buildQueryEvaluator().evaluateExpression(" for $i in htd:literal/htd:organizationalEntity/htd:groups/htd:group return string($i)", e)) {
+                } else if (RecordType.GROUP.equals(qr.getType())) {
                     TaskOrgEntity x = new TaskOrgEntity();
                     x.setGenericHumanRole(assignmentRole);
-                    x.setName(group);
+                    x.setName(qr.getName());
                     x.setType(OrgEntityType.GROUP);
                     x.setTask(task.getTaskDto());
                     result.add(x);
                 }
             }
+
+        } else if (literal != null) {
+            for (String user : (List<String>) buildQueryEvaluator().evaluateExpression("for $i in htd:literal/htd:organizationalEntity/htd:users/htd:user return string($i)", literal)) {
+                TaskOrgEntity x = new TaskOrgEntity();
+                x.setGenericHumanRole(assignmentRole);
+                x.setName(user);
+                x.setType(OrgEntityType.USER);
+                x.setTask(task.getTaskDto());
+                result.add(x);
+            }
+            for (String group : (List<String>) buildQueryEvaluator().evaluateExpression(" for $i in htd:literal/htd:organizationalEntity/htd:groups/htd:group return string($i)", literal)) {
+                TaskOrgEntity x = new TaskOrgEntity();
+                x.setGenericHumanRole(assignmentRole);
+                x.setName(group);
+                x.setType(OrgEntityType.GROUP);
+                x.setTask(task.getTaskDto());
+                result.add(x);
+            }
+        } else {
+            //TODO 3.2.3 Using Expressions
         }
         return result;
     }
@@ -159,7 +194,7 @@ public class TaskEvaluator {
     public Node createEprFromHeader(Node header) {
         return (Node) buildQueryEvaluator().evaluateExpression("<wsa:EndpointReference  >{ */wsa:ReplyTo/* }</wsa:EndpointReference>", header).get(0);
     }
-    
+
     // private Set<TaskOrgEntity> evaluatePeopleGroup(String groupName) {
     // HashSet<TaskOrgEntity> s = new HashSet<TaskOrgEntity>();
     // TaskOrgEntity o = new TaskOrgEntity();
@@ -168,13 +203,13 @@ public class TaskEvaluator {
     // s.add(o);
     // return s;
     // }
-    
+
     public Node evaluateOutcome(boolean outcome) {
         XQueryEvaluator evaluator = buildQueryEvaluator();
         evaluator.bindVariable(QName.valueOf("outcome"), outcome);
         return (Node) evaluator.evaluateExpression(task.getTaskDefinition().getOutcomeExpression(), null).get(0);
     }
-    
+
     /**
      * TODO approve???
      */
@@ -183,21 +218,23 @@ public class TaskEvaluator {
         return (Node) evaluator.evaluateExpression("<htd:taskId>{$taskId}</htd:taskId>", null).get(0);
     }
 
-    
+
     public static String getEscalationKey(TEscalation e, boolean isCompletion) {
         return e.getName() + ";" + (isCompletion ? "COMPLETION" : "START");
     }
-    
+
     public static class EscalationResult {
+
         public final TEscalation escalation;
         public final boolean isCompletion;
+
         public EscalationResult(TEscalation escalation, boolean isCompletion) {
             super();
             this.escalation = escalation;
             this.isCompletion = isCompletion;
         }
     }
-    
+
     public EscalationResult findEscalation(String name) {
         EscalationResult r = null;
         TDeadlines d = task.getTaskDefinition().getDeadlines();
@@ -216,10 +253,10 @@ public class TaskEvaluator {
                 }
             }
         }
-        
+
         return null;
     }
-    
+
     public Map<String, Node> evaluateToParts(TToParts toParts) {
         Map<String, Node> result = new HashMap<String, Node>();
         if (toParts != null) {
@@ -230,19 +267,19 @@ public class TaskEvaluator {
         }
         return result;
     }
-    
+
     public static Node defaultHeader() {
         return DOMUtils.parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<soapenv:Header xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"/>").getDocumentElement();
     }
-    
+
     public String getPresentationName() {
-    	try {
-    		return XmlUtils.getStringContent(task.getTaskDefinition().getPresentationElements().getName().get(0).getContent());
-    	} catch (Throwable t) {
-    		return null;
-    	}
+        try {
+            return XmlUtils.getStringContent(task.getTaskDefinition().getPresentationElements().getName().get(0).getContent());
+        } catch (Throwable t) {
+            return null;
+        }
     }
-    
+
     public XQueryEvaluator buildPresentationEvaluator() {
         XQueryEvaluator evaluator = buildQueryEvaluator();
         for (TPresentationParameter p : task.getTaskDefinition().getPresentationParameters()) {
@@ -256,35 +293,35 @@ public class TaskEvaluator {
                 __log.warn("Could not evaluate presentationParameter: " + p.getName());
             }
             __log.debug("evaluated presentationParameter: " + p.getName() + " = " + v);
-        	evaluator.bindVariable(QName.valueOf(p.getName()), v);
+            evaluator.bindVariable(QName.valueOf(p.getName()), v);
         }
         return evaluator;
     }
-    
+
     public static String getTemplateExpr(List<Object> expr) {
-    	return "xs:string(<v>" + XmlUtils.getStringContent(expr) + "</v>)";
+        return "xs:string(<v>" + XmlUtils.getStringContent(expr) + "</v>)";
     }
-    
-    
+
+
     public String evalPresentationSubject() {
-    	String subjectExpr;
-    	try {
-	    	subjectExpr = getTemplateExpr(task.getTaskDefinition().getPresentationElements().getSubject().get(0).getContent());
-		} catch (Throwable t) {
-			return null;
-		}
-		XQueryEvaluator e = buildPresentationEvaluator();
-		return "" + e.evaluateExpression(subjectExpr, null).get(0);
+        String subjectExpr;
+        try {
+            subjectExpr = getTemplateExpr(task.getTaskDefinition().getPresentationElements().getSubject().get(0).getContent());
+        } catch (Throwable t) {
+            return null;
+        }
+        XQueryEvaluator e = buildPresentationEvaluator();
+        return "" + e.evaluateExpression(subjectExpr, null).get(0);
     }
-    
+
     public String evalPresentationDescription() {
-    	String descExpr;
-    	try {
-	    	descExpr = getTemplateExpr(task.getTaskDefinition().getPresentationElements().getDescription().get(0).getContent());
-		} catch (Throwable t) {
-			return null;
-		}
-		XQueryEvaluator e = buildPresentationEvaluator();
-		return "" + e.evaluateExpression(descExpr, null).get(0);
+        String descExpr;
+        try {
+            descExpr = getTemplateExpr(task.getTaskDefinition().getPresentationElements().getDescription().get(0).getContent());
+        } catch (Throwable t) {
+            return null;
+        }
+        XQueryEvaluator e = buildPresentationEvaluator();
+        return "" + e.evaluateExpression(descExpr, null).get(0);
     }
 }

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/utils/DOMUtils.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/utils/DOMUtils.java?rev=964389&r1=964388&r2=964389&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/utils/DOMUtils.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/utils/DOMUtils.java Thu Jul 15 11:34:04 2010
@@ -20,61 +20,23 @@
 package org.apache.hise.utils;
 
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.StringReader;
 import java.io.StringWriter;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
-import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.stream.StreamSource;
 import javax.xml.xpath.XPathFactory;
 
-import net.sf.saxon.Configuration;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.xerces.dom.DOMOutputImpl;
 import org.apache.xerces.impl.Constants;
 import org.apache.xml.serialize.DOMSerializerImpl;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
-import org.w3c.dom.Attr;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.CharacterData;
-import org.w3c.dom.Comment;
 import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-import org.w3c.dom.TypeInfo;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
 
 public class DOMUtils {
     
@@ -106,6 +68,22 @@ public class DOMUtils {
         }
         return null;
     }
+
+    public static List<Element> findElements(QName elementName, List<Object> content) {
+        List<Element> elements = new ArrayList<Element>();
+
+        for (Object o : content) {
+            if (o instanceof Element) {
+                Element u = (Element) o;
+                QName n = new QName(u.getNamespaceURI(), u.getLocalName());
+                if (n.equals(elementName)) {
+                    elements.add(u);
+                }
+            }
+        }
+        return elements;
+
+    }
     
     /**
      * Convert a DOM node to a stringified XML representation.

Modified: incubator/hise/trunk/hise-test-example-osgi/pom.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-test-example-osgi/pom.xml?rev=964389&r1=964388&r2=964389&view=diff
==============================================================================
--- incubator/hise/trunk/hise-test-example-osgi/pom.xml (original)
+++ incubator/hise/trunk/hise-test-example-osgi/pom.xml Thu Jul 15 11:34:04 2010
@@ -79,9 +79,8 @@ org.apache.hise,
                         <Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
 
 
-                        <!--
-                        <Export-Package>org.apache.hise*,org.w3._2001.xmlschema</Export-Package>
-                        -->
+
+                        <Export-Package>org.apache.hise.test</Export-Package>
                         <DynamicImport-Package>*</DynamicImport-Package>
                         <!--
                         <Require-Bundle>

Added: incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/PeoplePovider.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/PeoplePovider.java?rev=964389&view=auto
==============================================================================
--- incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/PeoplePovider.java (added)
+++ incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/PeoplePovider.java Thu Jul 15 11:34:04 2010
@@ -0,0 +1,37 @@
+
+package org.apache.hise.test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import javax.xml.namespace.QName;
+import org.apache.hise.api.PeopleQueryProvider;
+
+/**
+ *
+ * @author pzg at touk.pl
+ */
+public class PeoplePovider implements PeopleQueryProvider {
+
+    QName regionEmployees = new QName("", "regionEmployees");
+
+    QName[] supportedQueries = {regionEmployees};
+
+    public boolean providesQuery(QName queryName) {
+        return Arrays.asList(supportedQueries).contains(queryName);
+    }
+
+    public List<QueryRecord> query(QName queryName, Map<String, Parameter> parameters) {
+        List<QueryRecord> qrs = new ArrayList<QueryRecord>();
+        if(!regionEmployees.equals(queryName) || parameters.get("region") == null) {
+            return qrs;
+        }
+        String region = (String) parameters.get("region").getValue();        
+        QueryRecord queryRecord = new QueryRecord("region_" + region, RecordType.GROUP);
+        qrs.add(queryRecord);
+
+        return qrs;
+    }
+
+}

Modified: incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/SampleUsers.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/SampleUsers.java?rev=964389&r1=964388&r2=964389&view=diff
==============================================================================
--- incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/SampleUsers.java (original)
+++ incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/SampleUsers.java Thu Jul 15 11:34:04 2010
@@ -74,7 +74,22 @@ public class SampleUsers {
                     o.getUserGroups().add(someGroup);
                     hiseEngine.getHiseDao().persist(o);
                 }
-                
+
+                OrgEntity regionUsa = new OrgEntity();
+                {
+                    OrgEntity g = regionUsa;
+                    g.setName("region_usa");
+                    g.setType(TaskOrgEntity.OrgEntityType.GROUP);
+                    hiseEngine.getHiseDao().persist(g);
+                }
+                {
+                    OrgEntity o = new OrgEntity();
+                    o.setName("usa_employee");
+                    o.setType(TaskOrgEntity.OrgEntityType.USER);
+                    o.setUserPassword("usa_employee");
+                    o.getUserGroups().add(regionUsa);
+                    hiseEngine.getHiseDao().persist(o);
+                }
                 
                 addUser("user1", "user1pass");
                 addUser("user2", "user2pass");

Modified: incubator/hise/trunk/hise-test-example-osgi/src/main/resources/META-INF/spring/hise-itest.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-test-example-osgi/src/main/resources/META-INF/spring/hise-itest.xml?rev=964389&r1=964388&r2=964389&view=diff
==============================================================================
--- incubator/hise/trunk/hise-test-example-osgi/src/main/resources/META-INF/spring/hise-itest.xml (original)
+++ incubator/hise/trunk/hise-test-example-osgi/src/main/resources/META-INF/spring/hise-itest.xml Thu Jul 15 11:34:04 2010
@@ -31,5 +31,9 @@ xmlns:osgi="http://www.springframework.o
         <property name="hiseEngine" ref="hiseEngine"></property>
         <property name="transactionManager" ref="transactionManager"></property>
     </bean>
+
+    <osgi:service interface="org.apache.hise.api.PeopleQueryProvider">
+        <bean class="org.apache.hise.test.PeoplePovider"/>
+    </osgi:service>
   
 </beans>

Modified: incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml?rev=964389&r1=964388&r2=964389&view=diff
==============================================================================
--- incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml (original)
+++ incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml Thu Jul 15 11:34:04 2010
@@ -10,7 +10,7 @@ Business Machines Corporation, Oracle In
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     xmlns:tns="http://www.insurance.example.com/claims"
     targetNamespace="http://www.insurance.example.com/claims"
-    xsi:schemaLocation="http://www.example.org/WS-HT file:/usr/share/schemas/ws-humantask.xsd">
+    xsi:schemaLocation="http://www.example.org/WS-HT ws-humantask.xsd">
     
     <!-- 
         
@@ -27,7 +27,7 @@ Business Machines Corporation, Oracle In
     
     <htd:logicalPeopleGroups>
     
-    	<htd:logicalPeopleGroup name="lpg1">
+    	<htd:logicalPeopleGroup name="regionEmployees">
             <htd:documentation xml:lang="en-US">Employee group.</htd:documentation>
             <htd:parameter name="region" type="xsd:string"/>
         </htd:logicalPeopleGroup>
@@ -43,7 +43,11 @@ Business Machines Corporation, Oracle In
             
             <htd:documentation xml:lang="en-US">This task is used to handle claims that require manual approval. </htd:documentation>
             <htd:interface portType="tns:ClaimsHandlingPT" operation="approve" responsePortType="tns:ClaimsResolvingPT" responseOperation="resolve"/>
-            <htd:priority> htd:getInput("ClaimApprovalRequest")/priority </htd:priority>
+            <htd:priority> 
+                declare namespace cla="http://www.insurance.example.com/claims";
+                declare namespace htd="http://www.example.org/WS-HT";            
+                htd:getInput("ClaimApprovalRequest")/cla:priority
+            </htd:priority>
             
             <htd:peopleAssignments>
             	<htd:potentialOwners>
@@ -83,13 +87,6 @@ Business Machines Corporation, Oracle In
                     </htd:literal>
                   </htd:from>
                 </htd:businessAdministrators>
-<!-- 
-                <htd:businessAdministrators>
-                    <htd:from logicalPeopleGroup="lpg1">
-                        <htd:argument name="region"> htd:getInput("ClahimApprovalRequest")/region </htd:argument>
-                    </htd:from>
-                </htd:businessAdministrators>
-                 -->
                 
             	<htd:taskStakeholders>
                   <htd:from>
@@ -213,7 +210,11 @@ xs:double(htd:getInput("ClaimApprovalReq
             
             <htd:documentation xml:lang="en-US">This task is used to handle claims that require manual approval. </htd:documentation>
             <htd:interface portType="tns:ClaimsHandlingPT" operation="approve2" responsePortType="tns:ClaimsHandlingCallbackPT" responseOperation="approvalResponse"/>
-            <htd:priority> htd:getInput("ClaimApprovalRequest")/prio </htd:priority>
+            <htd:priority>
+                declare namespace cla="http://www.insurance.example.com/claims";
+                declare namespace htd="http://www.example.org/WS-HT";
+                htd:getInput("ClaimApprovalRequest")/cla:priority
+            </htd:priority>
             
             <htd:peopleAssignments>
             	
@@ -287,19 +288,28 @@ xs:double(htd:getInput("ClaimApprovalReq
                 <htd:presentationParameters>
                     
                     <htd:presentationParameter name="firstname" type="xsd:string">
-                        htd:getInput("ClaimApprovalRequest")/cust/firstname </htd:presentationParameter>
-                    
+declare namespace cla="http://www.insurance.example.com/claims";
+declare namespace htd="http://www.example.org/WS-HT";
+xs:string(htd:getInput("ClaimApprovalRequest")/cla:cust/cla:firstname)
+</htd:presentationParameter>
+
                     <htd:presentationParameter name="lastname" type="xsd:string">
-                        htd:getInput("ClaimApprovalRequest")/cust/lastname </htd:presentationParameter>
-                    
+declare namespace cla="http://www.insurance.example.com/claims";
+declare namespace htd="http://www.example.org/WS-HT";
+xs:string(htd:getInput("ClaimApprovalRequest")/cla:cust/cla:lastname)
+</htd:presentationParameter>
+
                     <htd:presentationParameter name="euroAmount" type="xsd:double">
-                        htd:getInput("ClaimApprovalRequest")/amount </htd:presentationParameter>
+declare namespace cla="http://www.insurance.example.com/claims";
+declare namespace htd="http://www.example.org/WS-HT";
+xs:double(htd:getInput("ClaimApprovalRequest")/cla:amount)
+</htd:presentationParameter>
                         
                 </htd:presentationParameters>
                 
-                <htd:subject xml:lang="en-US"> Approve the insurance claim for PLN $euroAmount$ on behalf of $firstname$ $lastname$ </htd:subject>
+                <htd:subject xml:lang="en-US"> Approve the insurance claim for PLN {$euroAmount} on behalf of {$firstname} {$lastname} </htd:subject>
 
-                <htd:description xml:lang="en-US" contentType="text/plain"> Approve this claim following corporate guideline #4711.0815/7 ... </htd:description>
+                <htd:description xml:lang="en-US" contentType="text/plain"> Approve this claim following corporate guideline #4711.0815/7 for {$firstname} {$lastname} </htd:description>
 
             </htd:presentationElements>
             
@@ -345,19 +355,28 @@ xs:double(htd:getInput("ClaimApprovalReq
                 <htd:presentationParameters>
                     
                     <htd:presentationParameter name="firstname" type="xsd:string">
-                        htd:getInput("ClaimApprovalRequest")/cust/firstname </htd:presentationParameter>
-                    
+declare namespace cla="http://www.insurance.example.com/claims";
+declare namespace htd="http://www.example.org/WS-HT";
+xs:string(htd:getInput("ClaimApprovalRequest")/cla:cust/cla:firstname)
+</htd:presentationParameter>
+
                     <htd:presentationParameter name="lastname" type="xsd:string">
-                        htd:getInput("ClaimApprovalRequest")/cust/lastname </htd:presentationParameter>
-                    
+declare namespace cla="http://www.insurance.example.com/claims";
+declare namespace htd="http://www.example.org/WS-HT";
+xs:string(htd:getInput("ClaimApprovalRequest")/cla:cust/cla:lastname)
+</htd:presentationParameter>
+
                     <htd:presentationParameter name="euroAmount" type="xsd:double">
-                        htd:getInput("ClaimApprovalRequest")/amount </htd:presentationParameter>
+declare namespace cla="http://www.insurance.example.com/claims";
+declare namespace htd="http://www.example.org/WS-HT";
+xs:double(htd:getInput("ClaimApprovalRequest")/cla:amount)
+</htd:presentationParameter>
                         
                 </htd:presentationParameters>
                 
-                <htd:subject xml:lang="en-US"> Approve the insurance claim for PLN $euroAmount$ on behalf of $firstname$ $lastname$ </htd:subject>
+                <htd:subject xml:lang="en-US"> Approve the insurance claim for PLN {$euroAmount} on behalf of {$firstname} {$lastname} </htd:subject>
 
-                <htd:description xml:lang="en-US" contentType="text/plain"> Approve this claim following corporate guideline #4711.0815/7 ... </htd:description>
+                <htd:description xml:lang="en-US" contentType="text/plain"> Approve this claim following corporate guideline #4711.0815/7 for {$firstname} {$lastname} </htd:description>
 
             </htd:presentationElements>
 
@@ -430,7 +449,11 @@ xs:double(htd:getInput("ClaimApprovalReq
             
             <htd:documentation xml:lang="en-US">This task is used to handle claims that require manual approval. </htd:documentation>
             <htd:interface portType="tns:ClaimsHandlingPT" operation="approve" responsePortType="tns:ClaimsResolvingPT" responseOperation="resolve"/>
-            <htd:priority> htd:getInput("ClaimApprovalRequest")/priority </htd:priority>
+            <htd:priority>
+                declare namespace cla="http://www.insurance.example.com/claims";
+                declare namespace htd="http://www.example.org/WS-HT";
+                htd:getInput("ClaimApprovalRequest")/cla:priority
+            </htd:priority>
             
             <htd:peopleAssignments>
             	<htd:potentialOwners>
@@ -475,6 +498,16 @@ xs:double(htd:getInput("ClaimApprovalReq
                     </htd:literal>
                   </htd:from>
                 </htd:businessAdministrators>
+
+                <htd:businessAdministrators>
+                    <htd:from logicalPeopleGroup="regionEmployees">
+                        <htd:argument name="region">
+                            declare namespace cla="http://www.insurance.example.com/claims";
+                            declare namespace htd="http://www.example.org/WS-HT";
+                            xs:string(htd:getInput("ClaimApprovalRequest")/cla:region)
+                        </htd:argument>
+                    </htd:from>
+                </htd:businessAdministrators>
                 
             	<htd:taskStakeholders>
                   <htd:from>
@@ -518,7 +551,7 @@ xs:double(htd:getInput("ClaimApprovalReq
                         
                 </htd:presentationParameters>
                 
-<htd:subject xml:lang="en-US"> Approve the insurance claim for PLN {$euroAmount} on behalf of {$firstname} {$lastname} </htd:subject>
+                <htd:subject xml:lang="en-US"> Approve the insurance claim for PLN {$euroAmount} on behalf of {$firstname} {$lastname} </htd:subject>
 
                 <htd:description xml:lang="en-US" contentType="text/plain"> Approve this claim following corporate guideline #4711.0815/7 for {$firstname} {$lastname} </htd:description>
 

Modified: incubator/hise/trunk/itest/hise-soapui-project.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/itest/hise-soapui-project.xml?rev=964389&r1=964388&r2=964389&view=diff
==============================================================================
--- incubator/hise/trunk/itest/hise-soapui-project.xml (original)
+++ incubator/hise/trunk/itest/hise-soapui-project.xml Thu Jul 15 11:34:04 2010
@@ -16,7 +16,7 @@
   ~ KIND, either express or implied.  See the License for the
   ~ specific language governing permissions and limitations
   ~ under the License.
-  --><con:soapui-project name="hise" resourceRoot="" soapui-version="3.5.1" abortOnError="false" runType="SEQUENTIAL" xmlns:con="http://eviware.com/soapui/config"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.actions.iface.tools.soapui.TestRunnerAction@values-local"><![CDATA[<xml-fragment xmlns:con="http://eviware.com/soapui/config">
+  --><con:soapui-project name="hise" resourceRoot="" soapui-version="3.0.1" abortOnError="false" runType="SEQUENTIAL" xmlns:con="http://eviware.com/soapui/config"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.actions.iface.tools.soapui.TestRunnerAction@values-local"><![CDATA[<xml-fragment xmlns:con="http://eviware.com/soapui/config">
   <con:entry key="Global Properties" value=""/>
   <con:entry key="TestSuite" value="SampleTests"/>
   <con:entry key="Report to Generate" value=""/>
@@ -3924,7 +3924,16 @@ count(*/*/htd:getMyTasksResponse)</path>
       </xsd:getMyTasks>
    </soapenv:Body>
 </soapenv:Envelope>]]></con:request><con:assertion type="SOAP Response"/><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XQuery Match"><con:configuration><path>declare namespace htd = 'http://www.example.org/WS-HT/api/xsd';
-count(*/*/htd:getMyTasksResponse)</path><content>&lt;xml-fragment>1&lt;/xml-fragment></content><allowWildcards>false</allowWildcards></con:configuration></con:assertion><con:assertion type="SOAP Fault Assertion"/><con:credentials><con:username>someUser</con:username><con:password>someUser</con:password><con:domain>abc</con:domain></con:credentials><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.example.org/WS-HT/api/wsdl/taskOperations/getMyTasksRequest"/><con:wsrmConfig version="1.2"/></con:request></con:config></con:testStep><con:testStep type="request" name="getTaskInfo - Request"><con:settings/><con:config xsi:type="con:RequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:interface>taskOperationsSOAP</con:interface><con:operation>getTaskInfo</con:operation><con:request name="getTaskInfo - Request" outgoingWss="" incomingWss="" timeout="" wssPasswordType="Passw
 ordDigest"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>${#Project#destination}/taskOperations/</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.example.org/WS-HT/api/xsd">
+count(*/*/htd:getMyTasksResponse)</path><content>&lt;xml-fragment>1&lt;/xml-fragment></content><allowWildcards>false</allowWildcards></con:configuration></con:assertion><con:assertion type="SOAP Fault Assertion"/><con:credentials><con:username>someUser</con:username><con:password>someUser</con:password><con:domain>abc</con:domain></con:credentials><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.example.org/WS-HT/api/wsdl/taskOperations/getMyTasksRequest"/><con:wsrmConfig version="1.2"/></con:request></con:config></con:testStep><con:testStep type="request" name="getMyTasks-region"><con:settings/><con:config xsi:type="con:RequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:interface>taskOperationsSOAP</con:interface><con:operation>getMyTasks</con:operation><con:request name="getMyTasks-region" outgoingWss="" incomingWss="" wssPasswordType="PasswordDigest"><con:sett
 ings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@wss-time-to-live"/><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>${#Project#destination}/taskOperations/</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.example.org/WS-HT/api/xsd">
+   <soapenv:Body>
+      <xsd:getMyTasks>
+         <xsd:taskType>ALL</xsd:taskType>
+         <xsd:genericHumanRole>BUSINESSADMINISTRATORS</xsd:genericHumanRole>
+         <xsd:maxTasks>10</xsd:maxTasks>
+      </xsd:getMyTasks>
+   </soapenv:Body>
+</soapenv:Envelope>]]></con:request><con:assertion type="SOAP Response"/><con:assertion type="Schema Compliance"><con:configuration><definition/></con:configuration></con:assertion><con:assertion type="XQuery Match"><con:configuration><path>declare namespace htd = 'http://www.example.org/WS-HT/api/xsd';
+count(*/*/htd:getMyTasksResponse)</path><content>&lt;xml-fragment>1&lt;/xml-fragment></content><allowWildcards>false</allowWildcards></con:configuration></con:assertion><con:assertion type="SOAP Fault Assertion"/><con:credentials><con:username>usa_employee</con:username><con:password>usa_employee</con:password><con:domain/></con:credentials><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="http://www.example.org/WS-HT/api/wsdl/taskOperations/getMyTasksRequest"/><con:wsrmConfig version="1.2"/></con:request></con:config></con:testStep><con:testStep type="request" name="getTaskInfo - Request"><con:settings/><con:config xsi:type="con:RequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:interface>taskOperationsSOAP</con:interface><con:operation>getTaskInfo</con:operation><con:request name="getTaskInfo - Request" outgoingWss="" incomingWss="" timeout="" wssPasswordType="PasswordDige
 st"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>${#Project#destination}/taskOperations/</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.example.org/WS-HT/api/xsd">
    <soapenv:Header/>
    <soapenv:Body>
       <xsd:getTaskInfo>