From hise-commits-return-164-apmail-incubator-hise-commits-archive=incubator.apache.org@incubator.apache.org Thu Jul 29 16:58:20 2010 Return-Path: Delivered-To: apmail-incubator-hise-commits-archive@minotaur.apache.org Received: (qmail 32239 invoked from network); 29 Jul 2010 16:58:20 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 29 Jul 2010 16:58:20 -0000 Received: (qmail 98352 invoked by uid 500); 29 Jul 2010 16:58:20 -0000 Delivered-To: apmail-incubator-hise-commits-archive@incubator.apache.org Received: (qmail 98344 invoked by uid 500); 29 Jul 2010 16:58:20 -0000 Mailing-List: contact hise-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hise-dev@incubator.apache.org Delivered-To: mailing list hise-commits@incubator.apache.org Received: (qmail 98337 invoked by uid 99); 29 Jul 2010 16:58:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Jul 2010 16:58:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Jul 2010 16:58:17 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9F2A923889B3; Thu, 29 Jul 2010 16:57:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r980507 - in /incubator/hise/trunk: hise-services/src/main/java/org/apache/hise/engine/ hise-services/src/main/java/org/apache/hise/runtime/ hise-services/src/test/java/org/apache/hise/ hise-test-example-osgi/src/main/resources/ itest/ Date: Thu, 29 Jul 2010 16:57:00 -0000 To: hise-commits@incubator.apache.org From: rr@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100729165700.9F2A923889B3@eris.apache.org> Author: rr Date: Thu Jul 29 16:57:00 2010 New Revision: 980507 URL: http://svn.apache.org/viewvc?rev=980507&view=rev Log: HISE-18: Implement conditions evaluation inside escalations (Thanks to Michał Więcław) 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/runtime/DeadlineController.java incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.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 incubator/hise/trunk/itest/hise-soapui-project.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=980507&r1=980506&r2=980507&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 29 16:57:00 2010 @@ -190,8 +190,9 @@ public class HISEEngineImpl implements H public void executeJob(Job job) { Task t = Task.load(this, job.getTask().getId()); try { - t.setCurrentJob(job); + t.setCurrentJob(job); t.getClass().getMethod(job.getAction() + "JobAction").invoke(t); + } catch (Exception e) { throw new RuntimeException("timer job failed", e); } Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/DeadlineController.java URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/DeadlineController.java?rev=980507&r1=980506&r2=980507&view=diff ============================================================================== --- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/DeadlineController.java (original) +++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/DeadlineController.java Thu Jul 29 16:57:00 2010 @@ -24,19 +24,19 @@ import java.util.List; import java.util.Map; import java.util.Set; + import org.apache.commons.lang.NotImplementedException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hise.dao.GenericHumanRole; import org.apache.hise.dao.Job; -import org.apache.hise.dao.Message; import org.apache.hise.dao.TaskOrgEntity; import org.apache.hise.dao.Task.Status; +import org.apache.hise.lang.xsd.htd.TBooleanExpr; import org.apache.hise.lang.xsd.htd.TDeadline; import org.apache.hise.lang.xsd.htd.TDeadlines; import org.apache.hise.lang.xsd.htd.TEscalation; import org.apache.hise.runtime.TaskEvaluator.EscalationResult; -import org.apache.hise.utils.DOMUtils; import org.w3c.dom.Node; public class DeadlineController implements TaskStateListener { @@ -103,7 +103,8 @@ public class DeadlineController implemen EscalationResult e = task.getTaskEvaluator().findEscalation(deadline.getDetails()); if (e == null) { __log.warn("Can't find escalation " + deadline.getDetails() + " in task definition " + task); - } else { + } else if(checkEscalationCondition(e.escalation.getCondition())){ + Map msg = task.getTaskEvaluator().evaluateToParts(e.escalation.getToParts().size() == 0 ? null : e.escalation.getToParts().get(0)); if (e.escalation.getReassignment() != null) { @@ -112,10 +113,28 @@ public class DeadlineController implemen task.forward(result); } else if (e.escalation.getLocalNotification() != null) { Node request = msg.get("request"); + task.getHiseEngine().receiveNotification(e.escalation.getLocalNotification().getReference(), request); } else { throw new NotImplementedException(); } + }else{ + __log.debug("EscalationCondition not satisfy for escalation: " + deadline.getDetails()+" in task definition " + task); } } + + private boolean checkEscalationCondition(TBooleanExpr booleanExpr){ + if(booleanExpr == null) return true; + + List content = booleanExpr.getContent(); + String expression = (String) content.get(0); + TaskEvaluator evaluator=task.getTaskEvaluator(); + List queryResponse = evaluator.buildQueryEvaluator().evaluateExpression(expression, null); + + boolean response = false; + if (queryResponse != null && (queryResponse.get(0) instanceof Boolean)) { + response = (Boolean) queryResponse.get(0); + } + return response; + } } 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=980507&r1=980506&r2=980507&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 29 16:57:00 2010 @@ -313,7 +313,7 @@ public class Task { Map partsMap = operation.getInput().getMessage().getParts(); Node messagePart = null; - for (Part part : partsMap.values()) { + for (Part part : partsMap.values()) { String name = part.getName(); QName element = part.getElementName(); QName type = part.getTypeName(); 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=980507&r1=980506&r2=980507&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 Thu Jul 29 16:57:00 2010 @@ -8,10 +8,6 @@ import javax.xml.namespace.QName; import junit.framework.Assert; -import net.sf.saxon.dom.NodeOverNodeInfo; -import net.sf.saxon.om.NodeInfo; -import net.sf.saxon.type.TypeHierarchy; - import org.apache.cxf.helpers.IOUtils; import org.apache.hise.dao.Message; import org.apache.hise.lang.xsd.htd.TDeadline; @@ -31,6 +27,7 @@ public class TaskEvaluatorTest { org.apache.hise.dao.Task t2 = new org.apache.hise.dao.Task(); t2.setId(1234L); t2.getInput().put("request", new Message("request", "text1")); + t2.getInput().put("value", new Message("value", "10050")); t.setTaskDto(t2); return new TaskEvaluator(t); @@ -95,6 +92,33 @@ public class TaskEvaluatorTest { Date r = e.evaluateDeadline(deadline); Assert.assertEquals(6234L, r.getTime()); } + + @Test + public void testEscalationCondition() throws Exception{ + XQueryEvaluator[] e = new XQueryEvaluator[5]; + String[] condition = new String[5]; + List r[] = new List[5]; + for(int i = 0;i < 5; ++i){ + e[i] = buildTaskEvaluator().buildQueryEvaluator(); + e[i].declareNamespace("htd","http://www.example.org/WS-HT"); + } + + condition[0] = new String("xs:integer(htd:getInput('value')/b) = 100"); + condition[1] = new String("xs:integer(htd:getInput('value')/b) < 100 or xs:integer(htd:getInput('value')/b) = 100"); + condition[2] = new String("xs:integer(htd:getInput('value')/b) = 100 and xs:integer(htd:getInput('value')/c) = 50"); + condition[3]= new String("not(xs:integer(htd:getInput('value')/b) = 100)"); + condition[4]= new String("(xs:integer(htd:getInput('value')/b) = 100 or xs:integer(htd:getInput('value')/c) < 50) and xs:integer(htd:getInput('value')/c) < 10"); + + for(int i = 0; i < 5; ++i){ + r[i] = e[i].evaluateExpression(condition[i], null); + } + + Assert.assertEquals(r[0].get(0) , true); + Assert.assertEquals(r[1].get(0) , true); + Assert.assertEquals(r[2].get(0) , true); + Assert.assertEquals(r[3].get(0) , false); + Assert.assertEquals(r[4].get(0) , false); + } @Test public void testEvalGetInput() throws Exception { 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=980507&r1=980506&r2=980507&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 29 16:57:00 2010 @@ -177,8 +177,19 @@ xs:double(htd:getInput("ClaimApprovalReq - 'PT5S' + 'PT3S' + + + 4) + or htd:getInput("ClaimApprovalRequest")/cla:prio = 10) + ]]> + + + @@ -188,17 +199,17 @@ xs:double(htd:getInput("ClaimApprovalReq user3 - + - 'PT5S' + 'PT3S' @@ -215,9 +226,18 @@ xs:double(htd:getInput("ClaimApprovalReq - - 'PT10S' + + 'PT5S' + + + + + @@ -232,7 +252,7 @@ xs:double(htd:getInput("ClaimApprovalReq - + Modified: incubator/hise/trunk/itest/hise-soapui-project.xml URL: http://svn.apache.org/viewvc/incubator/hise/trunk/itest/hise-soapui-project.xml?rev=980507&r1=980506&r2=980507&view=diff ============================================================================== --- incubator/hise/trunk/itest/hise-soapui-project.xml (original) +++ incubator/hise/trunk/itest/hise-soapui-project.xml Thu Jul 29 16:57:00 2010 @@ -5886,7 +5886,129 @@ declare namespace ns4='http://www.insura declare namespace ns3='http://www.example.org/WS-HT'; declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/'; declare namespace ns1='http://www.example.org/WS-HT/api/xsd'; -<v>{//ns2:status/text()};{//ns2:name/text()};{//ns2:actualOwner/text()}</v><v>READY;ns4:Task8;</v>falseuser3user3passtruefalseSEQUENCEResponse 1 +<v>{//ns2:status/text()};{//ns2:name/text()};{//ns2:actualOwner/text()}</v><v>READY;ns4:Task8;</v>falseuser3user3passSEQUENTIALClaimsHandlingBindingapprove<xml-fragment/>UTF-8${#Project#destination}/ClaimsHandlingService/ + + soapui + + + + + + 123 + Edmund + Zorn + + 1234 + usa + 5 + 2009-01-02T12:00:00 + + + +]]>user2user2passClaimsHandlingBindingapprove<xml-fragment/>UTF-8${#Project#destination}/ClaimsHandlingService/ + + soapui + + + + + + 123 + Edmund + Zorn + + 1234 + usa + 2 + 2009-01-02T12:00:00 + + + +]]>user2user2passtid15tid26tidResponseapprove - Request 1<a>{*/*/*/text()}</a>tid1Propertiestid2Responseapprove - Request 2<a>{*/*/*/text()}</a>tid2PropertiestaskOperationsSOAPgetTaskInfo<xml-fragment/>UTF-8${#Project#destination}/taskOperations/ + + + + ${Properties#tid1} + + +]]>declare namespace ns3='http://www.example.org/WS-HT/api'; +declare namespace ns4='http://www.insurance.example.com/claims'; +declare namespace ns2='http://www.example.org/WS-HT'; +declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/'; +declare namespace ns1='http://www.example.org/WS-HT/api/xsd'; +<v>{//ns3:status/text()};{//ns3:name/text()}: +{//ns3:potentialOwners/ns2:users/ns2:user/text()}</v><v>RESERVED;ns4:Task1: +user1</v>falseuser1user1passtaskOperationsSOAPgetTaskInfo<xml-fragment/>UTF-8${#Project#destination}/taskOperations/ + + + + ${Properties#tid2} + + +]]>declare namespace ns3='http://www.example.org/WS-HT/api'; +declare namespace ns4='http://www.insurance.example.com/claims'; +declare namespace ns2='http://www.example.org/WS-HT'; +declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/'; +declare namespace ns1='http://www.example.org/WS-HT/api/xsd'; +<v>{//ns3:status/text()};{//ns3:name/text()}: +{//ns3:potentialOwners/ns2:users/ns2:user/text()}</v><v>RESERVED;ns4:Task1: +user1</v>falseuser1user1pass3500taskOperationsSOAPgetTaskInfo<xml-fragment/>UTF-8${#Project#destination}/taskOperations/ + + + + ${Properties#tid1} + + +]]>declare namespace ns3='http://www.example.org/WS-HT/api'; +declare namespace ns4='http://www.insurance.example.com/claims'; +declare namespace ns2='http://www.example.org/WS-HT'; +declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/'; +declare namespace ns1='http://www.example.org/WS-HT/api/xsd'; +<v>{//ns3:status/text()};{//ns3:name/text()}: +{//ns3:potentialOwners/ns2:users/ns2:user/text()}</v><v>RESERVED;ns4:Task1: +user3</v>falseuser1user1passtaskOperationsSOAPgetTaskInfo<xml-fragment/>UTF-8${#Project#destination}/taskOperations/ + + + + ${Properties#tid2} + + +]]>declare namespace ns3='http://www.example.org/WS-HT/api'; +declare namespace ns4='http://www.insurance.example.com/claims'; +declare namespace ns2='http://www.example.org/WS-HT'; +declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/'; +declare namespace ns1='http://www.example.org/WS-HT/api/xsd'; +<v>{//ns3:status/text()};{//ns3:name/text()}: +{//ns3:potentialOwners/ns2:users/ns2:user/text()}</v><v>RESERVED;ns4:Task1: +user1</v>falseuser1user1pass3500taskOperationsSOAPgetTaskInfo<xml-fragment/>UTF-8${#Project#destination}/taskOperations/ + + + + ${Properties#tid1} + + +]]>declare namespace ns3='http://www.example.org/WS-HT/api'; +declare namespace ns4='http://www.insurance.example.com/claims'; +declare namespace ns2='http://www.example.org/WS-HT'; +declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/'; +declare namespace ns1='http://www.example.org/WS-HT/api/xsd'; +<v>{//ns3:status/text()};{//ns3:name/text()}: +{//ns3:potentialOwners/ns2:users/ns2:user/text()}</v><v>RESERVED;ns4:Task1: +user3</v>falseuser1user1passtaskOperationsSOAPgetTaskInfo<xml-fragment/>UTF-8${#Project#destination}/taskOperations/ + + + + ${Properties#tid2} + + +]]>declare namespace ns3='http://www.example.org/WS-HT/api'; +declare namespace ns4='http://www.insurance.example.com/claims'; +declare namespace ns2='http://www.example.org/WS-HT'; +declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/'; +declare namespace ns1='http://www.example.org/WS-HT/api/xsd'; +<v>{//ns3:status/text()};{//ns3:name/text()}: +{//ns3:potentialOwners/ns2:users/ns2:user/text()}</v><v>RESERVED;ns4:Task1: +user4</v>falseuser1user1passtruefalseSEQUENCEResponse 1