incubator-hise-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r.@apache.org
Subject svn commit: r915840 - in /incubator/hise/trunk: hise-services/src/main/java/org/apache/hise/engine/ hise-services/src/main/java/org/apache/hise/engine/jaxws/ hise-services/src/main/java/org/apache/hise/lang/ hise-services/src/main/java/org/apache/hise/...
Date Wed, 24 Feb 2010 16:08:22 GMT
Author: rr
Date: Wed Feb 24 16:08:22 2010
New Revision: 915840

URL: http://svn.apache.org/viewvc?rev=915840&view=rev
Log:
HISE-21: Added presentation subject and presentation description rendering

Modified:
    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/engine/jaxws/TaskOperationsImpl.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/lang/TaskDefinition.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskEvaluator.java
    incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/TaskEvaluatorTest.java
    incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml

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=915840&r1=915839&r2=915840&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
Wed Feb 24 16:08:22 2010
@@ -91,7 +91,7 @@
         log.debug("registering route " + ti.taskKey + " -> " + ti.taskDefinition.getTaskName());
         
         if (tasks.containsKey(ti.taskDefinition.getTaskName()) || tasksMap.containsKey(ti.taskKey))
{
-            throw new IllegalArgumentException("Unable to deploy " + ti + " is already deployed.");
+            log.warn("Unable to deploy " + ti + " is already deployed.");
         }
         
         tasksMap.put(ti.taskKey, ti.taskDefinition.getTaskName());

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java?rev=915840&r1=915839&r2=915840&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java
(original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java
Wed Feb 24 16:08:22 2010
@@ -118,7 +118,7 @@
         
         List<org.apache.hise.dao.Task> k = hiseEngine.getHiseDao().getUserTasks(query);
         for (org.apache.hise.dao.Task u : k) {
-            TTask t = convertTask(u);
+            TTask t = convertTask(u.getId());
             l.add(t);
         }
         return l;
@@ -238,7 +238,10 @@
     // return TStatus.fromValue(in.toString());
     // }
     
-    private static TTask convertTask(org.apache.hise.dao.Task u) {
+    private TTask convertTask(Long id) {
+        Task task = Task.load(hiseEngine, id);
+        org.apache.hise.dao.Task u = task.getTaskDto();
+
         TTask t = new TTask();
         t.setId("" + u.getId());
         t.setTaskType(u.isNotification() ? "NOTIFICATION" : "TASK");
@@ -246,13 +249,15 @@
         t.setActivationTime(u.getActivationTime());
         if (u.getActualOwner() != null) t.setActualOwner(u.getActualOwner());
         t.setCreatedBy(u.getCreatedBy());
+        t.setPresentationName(task.getTaskEvaluator().getPresentationName());
+        t.setPresentationSubject(task.getTaskEvaluator().evalPresentationSubject());
         t.setName(u.getTaskDefinitionName());
         t.setStatus(TStatus.valueOf(u.getStatus().toString()));
         return t;
     }
 
     public org.apache.hise.lang.xsd.htda.TTask getTaskInfo(String identifier) throws IllegalArgumentFault
{
-        return convertTask(hiseEngine.getHiseDao().find(org.apache.hise.dao.Task.class, Long.parseLong(identifier)));
+        return convertTask(hiseEngine.getHiseDao().find(org.apache.hise.dao.Task.class, Long.parseLong(identifier)).getId());
     }
 
     public TTaskQueryResultSet query(String selectClause, String whereClause, String orderByClause,
Integer maxTasks, Integer taskIndexOffset) throws IllegalArgumentFault, IllegalStateFault
{
@@ -372,8 +377,9 @@
     }
 
     public String getTaskDescription(String identifier, String contentType) throws IllegalArgumentFault
{
-        // TODO Auto-generated method stub
-        return null;
+        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
+        t.setCurrentUser(getUserString());
+        return t.getTaskEvaluator().evalPresentationDescription();
     }
 
     public void nominate(String identifier, TOrganizationalEntity organizationalEntity) throws
IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/lang/TaskDefinition.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/lang/TaskDefinition.java?rev=915840&r1=915839&r2=915840&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/lang/TaskDefinition.java
(original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/lang/TaskDefinition.java
Wed Feb 24 16:08:22 2010
@@ -19,6 +19,8 @@
 
 package org.apache.hise.lang;
 
+import java.util.Collections;
+import java.util.List;
 import java.util.Map;
 
 import javax.xml.namespace.QName;
@@ -31,6 +33,8 @@
 import org.apache.hise.lang.xsd.htd.TLiteral;
 import org.apache.hise.lang.xsd.htd.TNotification;
 import org.apache.hise.lang.xsd.htd.TPeopleAssignments;
+import org.apache.hise.lang.xsd.htd.TPresentationElements;
+import org.apache.hise.lang.xsd.htd.TPresentationParameters;
 import org.apache.hise.lang.xsd.htd.TPriority;
 import org.apache.hise.lang.xsd.htd.TTask;
 import org.apache.hise.lang.xsd.htd.TTaskInterface;
@@ -324,6 +328,21 @@
     public String getOutcomeExpression() {
         return tTask.getOutcome().getContent().get(0).toString();
     }
+    
+    public TPresentationElements getPresentationElements() {
+    	return isNotification() ? tNote.getPresentationElements() : tTask.getPresentationElements();
+    }
+    
+    public List<org.apache.hise.lang.xsd.htd.TPresentationParameter> getPresentationParameters()
{
+    	TPresentationElements v = getPresentationElements();
+    	if (v != null) {
+    		TPresentationParameters u = v.getPresentationParameters();
+    		if (u != null) {
+    			return u.getPresentationParameter();
+    		}
+    	}
+    	return Collections.EMPTY_LIST;
+    }
 
     /**
      * Returns namespace URI for namespace registered in HumanInteractionsManager.

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=915840&r1=915839&r2=915840&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
Wed Feb 24 16:08:22 2010
@@ -44,6 +44,7 @@
 import org.apache.hise.lang.xsd.htd.TFrom;
 import org.apache.hise.lang.xsd.htd.TGenericHumanRole;
 import org.apache.hise.lang.xsd.htd.TPeopleAssignments;
+import org.apache.hise.lang.xsd.htd.TPresentationParameter;
 import org.apache.hise.lang.xsd.htd.TToPart;
 import org.apache.hise.lang.xsd.htd.TToParts;
 import org.apache.hise.utils.DOMUtils;
@@ -214,4 +215,50 @@
     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;
+    	}
+    }
+    
+    public XQueryEvaluator buildPresentationEvaluator() {
+        XQueryEvaluator evaluator = buildQueryEvaluator();
+        for (TPresentationParameter p : task.getTaskDefinition().getPresentationParameters())
{
+            XQueryEvaluator evaluator2 = buildQueryEvaluator();
+            Object v = evaluator2.evaluateExpression(XmlUtils.getStringContent(p.getContent()),
null).get(0);
+            __log.debug("evaluated presentationParameter: " + 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>)";
+    }
+    
+    
+    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);
+    }
+    
+    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);
+    }
 }

Modified: incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/TaskEvaluatorTest.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/TaskEvaluatorTest.java?rev=915840&r1=915839&r2=915840&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/TaskEvaluatorTest.java
(original)
+++ incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/TaskEvaluatorTest.java
Wed Feb 24 16:08:22 2010
@@ -1,5 +1,6 @@
 package org.apache.hise;
 
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
@@ -56,7 +57,15 @@
         Object r = e.evaluateExpression("declare namespace htd='http://www.example.org/WS-HT';
for $i in htd:literal/htd:organizationalEntity/htd:users/htd:user return string($i)", DOMUtils.parse(getClass().getResourceAsStream("/taskEvaluator.xml")).getFirstChild());
         Assert.assertTrue(r.toString().equals("[user1, user2]"));
     }
-    
+
+    @Test
+    public void testEval4() throws Exception {
+        XQueryEvaluator e = new XQueryEvaluator();
+        e.bindVariable(QName.valueOf("abc"), "val");
+        Object r = e.evaluateExpression(TaskEvaluator.getTemplateExpr(Collections.singletonList((Object)
"123 {$abc} 345")), null);
+        Assert.assertEquals(r.toString(), "[123 val 345]");
+    }
+
     @Test
     public void testEvalOutcome() throws Exception {
         XQueryEvaluator e = new XQueryEvaluator();

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=915840&r1=915839&r2=915840&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 Wed Feb 24
16:08:22 2010
@@ -114,19 +114,28 @@
                 <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("request")/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("request")/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("request")/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>
             



Mime
View raw message