incubator-hise-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r.@apache.org
Subject svn commit: r982496 - /incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskEvaluator.java
Date Thu, 05 Aug 2010 08:08:08 GMT
Author: rr
Date: Thu Aug  5 08:08:07 2010
New Revision: 982496

URL: http://svn.apache.org/viewvc?rev=982496&view=rev
Log:
HISE-62: 'Until' deadline throws NPE (fix thanks to Maciej Próchniak)

Modified:
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskEvaluator.java

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=982496&r1=982495&r2=982496&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 Aug  5 08:08:07 2010
@@ -19,47 +19,26 @@
 
 package org.apache.hise.runtime;
 
-import java.lang.reflect.InvocationTargetException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-
-import javax.xml.bind.JAXBElement;
-import javax.xml.namespace.QName;
-
 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.OrgEntity;
 import org.apache.hise.dao.PotentialDelegates;
 import org.apache.hise.dao.TaskOrgEntity;
 import org.apache.hise.dao.TaskOrgEntity.OrgEntityType;
-import org.apache.hise.engine.wsdl.IllegalStateFault;
-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.lang.xsd.htd.TExpression;
-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.TPotentialDelegatees;
-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.lang.xsd.htd.*;
 import org.apache.hise.utils.DOMUtils;
 import org.apache.hise.utils.XQueryEvaluator;
 import org.apache.hise.utils.XmlUtils;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+import java.util.*;
+
 public class TaskEvaluator {
 
     private Log __log = LogFactory.getLog(TaskEvaluator.class);
@@ -105,8 +84,18 @@ public class TaskEvaluator {
         return buildQueryEvaluator().evaluateExpression(XmlUtils.getStringContent(expr.getContent()),
null);
     }
 
+    private Object evaluateExpression(String expr) {
+        return buildQueryEvaluator().evaluateExpression(expr, null).get(0);
+    }
+
     public Date evaluateDeadline(TDeadline deadline) {
-        return (Date) buildQueryEvaluator().evaluateExpression("$currentEventDateTime + xs:dayTimeDuration("
+ XmlUtils.getStringContent(deadline.getFor().getContent()) + ")", null).get(0);
+        if (deadline.getFor() != null) {
+            String content = XmlUtils.getStringContent(deadline.getFor().getContent());
+            return (Date) evaluateExpression("$currentEventDateTime + xs:dayTimeDuration("
+ content + ")");
+        } else {
+            String content = XmlUtils.getStringContent(deadline.getUntil().getContent());
+            return (Date) evaluateExpression("xs:date('"+content+"')");
+        }                                      
     }
 
     public Set<TaskOrgEntity> evaluatePeopleAssignments() {



Mime
View raw message