incubator-hise-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r.@apache.org
Subject svn commit: r902119 - in /incubator/hise/trunk: hise-services/src/main/java/org/apache/hise/dao/ hise-services/src/main/java/org/apache/hise/runtime/ hise-services/src/main/resources/org/apache/hise/ hise-services/src/test/java/org/apache/hise/ hise-te...
Date Fri, 22 Jan 2010 15:29:57 GMT
Author: rr
Date: Fri Jan 22 15:29:56 2010
New Revision: 902119

URL: http://svn.apache.org/viewvc?rev=902119&view=rev
Log:
HISE-2: Implemented deadlines handling

Removed:
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/Deadline.java
Modified:
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/Job.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/Task.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/ResponseHandler.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/runtime/TaskLifecycle.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskStateListener.java
    incubator/hise/trunk/hise-services/src/main/resources/org/apache/hise/persistence.xml
    incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/TaskEvaluatorTest.java
    incubator/hise/trunk/hise-test-example/src/main/resources/testHtd1.xml

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/Job.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/Job.java?rev=902119&r1=902118&r2=902119&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/Job.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/Job.java Fri Jan
22 15:29:56 2010
@@ -20,6 +20,8 @@
 package org.apache.hise.dao;
 
 import java.util.Date;
+import java.util.Map;
+import java.util.TreeMap;
 
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
@@ -85,6 +87,16 @@
     public void setDetails(String details) {
         this.details = details;
     }
+    
+    @Override
+    public String toString() {
+        Map m = new TreeMap();
+        m.put("id", id);
+        m.put("task", getTask().getId());
+        m.put("action", getAction());
+        m.put("details", getDetails());
+        return m.toString();
+    }
 
     @Override
     public Object[] getKeys() {

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/Task.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/Task.java?rev=902119&r1=902118&r2=902119&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/Task.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/Task.java Fri Jan
22 15:29:56 2010
@@ -21,8 +21,10 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -265,8 +267,12 @@
     @OneToMany(mappedBy = "task", cascade = { CascadeType.PERSIST, CascadeType.MERGE })
     private List<Attachment> attachments = new ArrayList<Attachment>();
 
-    @OneToMany(mappedBy = "task", cascade = { CascadeType.PERSIST, CascadeType.MERGE })
-    private List<Deadline> deadlines = new ArrayList<Deadline>();
+//    @OneToMany(mappedBy = "task", cascade = { CascadeType.PERSIST, CascadeType.MERGE })
+//    private List<Deadline> deadlines = new ArrayList<Deadline>();
+    
+    @OneToMany(cascade = {CascadeType.ALL})
+    @JoinTable(name="DEADLINE")
+    private Set<Job> deadlines = new HashSet<Job>();
 
     /**
      * Fault information. Set when task fail method is called.
@@ -283,14 +289,22 @@
     private Map<String, PresentationParameter> presentationParameters = new HashMap<String,
PresentationParameter>();
 
 
-    public List<Deadline> getDeadlines() {
+//    public List<Deadline> getDeadlines() {
+//        return deadlines;
+//    }
+//
+//    public void setDeadlines(List<Deadline> deadlines) {
+//        this.deadlines = deadlines;
+//    }
+
+    public Set<Job> getDeadlines() {
         return deadlines;
     }
 
-    public void setDeadlines(List<Deadline> deadlines) {
+    public void setDeadlines(Set<Job> deadlines) {
         this.deadlines = deadlines;
     }
-
+    
     public String getTaskDefinitionKey() {
         return taskDefinitionKey;
     }

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=902119&r1=902118&r2=902119&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
Fri Jan 22 15:29:56 2010
@@ -19,20 +19,35 @@
 
 package org.apache.hise.runtime;
 
+import java.util.Date;
 import java.util.List;
+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.TaskOrgEntity;
 import org.apache.hise.dao.Task.Status;
 import org.apache.hise.lang.xsd.htd.TDeadline;
 import org.apache.hise.lang.xsd.htd.TDeadlines;
-import org.apache.hise.lang.xsd.htd.TExpression;
+import org.apache.hise.lang.xsd.htd.TEscalation;
+import org.apache.hise.runtime.TaskEvaluator.EscalationResult;
 
 public class DeadlineController implements TaskStateListener {
 
-    private Log __log = LogFactory.getLog(DeadlineController.class);
+    private static Log __log = LogFactory.getLog(DeadlineController.class);
+    
+    private Task task;
+
+    
+    public DeadlineController(Task task) {
+        super();
+        this.task = task;
+    }
 
-    public void stateChanged(Task task, Status oldStatus, Status newStatus) {
+    public void stateChanged(Status oldStatus, Status newStatus) {
         __log.debug(task + " " + oldStatus + " " + newStatus);
         
         TDeadlines deadlines = task.getTaskDefinition().gettTask().getDeadlines();
@@ -40,22 +55,56 @@
             deadlines = new TDeadlines();
         }
         
-        if (newStatus.equals(Status.CREATED)) {
-            //compute start deadlines
-            computeDeadlines(task, deadlines.getStartDeadline(), false);
-        } else if (newStatus.equals(Status.IN_PROGRESS)) {
-            //delete start deadlines
-            //compute completion deadlines
-        } else if (newStatus.equals(Status.COMPLETED)) {
-            //delete completion deadlines
+        if (newStatus == Status.CREATED) {
+            computeDeadlines(deadlines.getStartDeadline(), false);
+        } else if (newStatus == Status.IN_PROGRESS) {
+            deleteDeadlines();
+            computeDeadlines(deadlines.getCompletionDeadline(), true);
+        } else if (newStatus == Status.COMPLETED || newStatus == Status.FAILED) {
+            deleteDeadlines();
         }
     }
     
-    private void computeDeadlines(Task task, List<TDeadline> deadlines, boolean isCompletion)
{
+    private void deleteDeadlines() {
+        __log.debug("clearing deadlines " + task.getTaskDto().getDeadlines());
+        while (!task.getTaskDto().getDeadlines().isEmpty()) {
+            Job j = task.getTaskDto().getDeadlines().iterator().next();
+            task.getTaskDto().getDeadlines().remove(j);
+            task.getHiseEngine().getHiseDao().remove(j);
+        }
+    }
+    
+    private void computeDeadlines(List<TDeadline> deadlines, boolean isCompletion)
{
         for (TDeadline deadline : deadlines) {
-            TExpression expr = deadline.getFor();
-            Object v = task.getTaskEvaluator().evaluateExpression(expr);
-            __log.debug("deadline " + v);
+            Date fire = task.getTaskEvaluator().evaluateDeadline(deadline);
+            __log.debug("deadline fire date " + fire);
+            
+            for (TEscalation escalation : deadline.getEscalation()) {
+                Job job = new Job();
+                job.setAction("deadline");
+                job.setTask(task.getTaskDto());
+                job.setFire(fire);
+                job.setDetails(TaskEvaluator.getEscalationKey(escalation, isCompletion));
+                
+                __log.debug("registering deadline " + job);
+                task.getTaskDto().getDeadlines().add(job);
+            }
+        }
+    }
+    
+    public void deadlineCrossed(Job deadline) {
+        __log.debug("deadline crossed" + deadline);
+
+        EscalationResult e = task.getTaskEvaluator().findEscalation(deadline.getDetails());
+        if (e == null) {
+            __log.warn("Can't find escalation " + deadline.getDetails() + " in task definition
" + task);
+        } else {
+            if (e.escalation.getReassignment() != null) {
+                Set<TaskOrgEntity> result = task.getTaskEvaluator().evaluateGenericHumanRole(e.escalation.getReassignment().getPotentialOwners(),
GenericHumanRole.POTENTIALOWNERS);
+                task.forward(result);
+            } else {
+                throw new NotImplementedException();
+            }
         }
     }
 }

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/ResponseHandler.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/ResponseHandler.java?rev=902119&r1=902118&r2=902119&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/ResponseHandler.java
(original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/ResponseHandler.java
Fri Jan 22 15:29:56 2010
@@ -22,8 +22,14 @@
 import org.apache.hise.dao.Task.Status;
 
 public class ResponseHandler implements TaskStateListener {
+    private Task task;
     
-    public void stateChanged(Task task, Status oldStatus, Status newStatus) {
+    public ResponseHandler(Task task) {
+        super();
+        this.task = task;
+    }
+
+    public void stateChanged(Status oldStatus, Status newStatus) {
         boolean result = false;
         if (newStatus.equals(Status.COMPLETED)) {
             result = true;

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=902119&r1=902118&r2=902119&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 Fri
Jan 22 15:29:56 2010
@@ -23,8 +23,10 @@
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.persistence.EntityManager;
 import javax.xml.namespace.QName;
@@ -84,10 +86,12 @@
     private List<TaskStateListener> taskStateListeners;
     
     private Job currentJob;
-//    private Date currentEventDateTime = Calendar.getInstance().getTime();
+    private Date currentEventDateTime = Calendar.getInstance().getTime();
     
     private String currentUser;
     
+    private DeadlineController deadlineController;
+    
     protected Task() {}
     
     public Job getCurrentJob() {
@@ -97,6 +101,14 @@
     public void setCurrentJob(Job currentJob) {
         this.currentJob = currentJob;
     }
+    
+    public Date getCurrentEventDateTime() {
+        return currentEventDateTime;
+    }
+
+    public void setCurrentEventDateTime(Date currentEventDateTime) {
+        this.currentEventDateTime = currentEventDateTime;
+    }
 
     public String getCurrentUser() {
         return currentUser;
@@ -106,13 +118,18 @@
         this.currentUser = currentUser;
     }
 
+    public HISEEngine getHiseEngine() {
+        return hiseEngine;
+    }
+
     private Task(HISEEngine engine) {
         this.hiseEngine = engine;
         Validate.notNull(hiseEngine);
 
         taskStateListeners = new ArrayList<TaskStateListener>();
-        taskStateListeners.add(new TaskLifecycle());
-        taskStateListeners.add(new DeadlineController());
+        taskStateListeners.add(new TaskLifecycle(this));
+        deadlineController = new DeadlineController(this);
+        taskStateListeners.add(deadlineController);
 
         taskEvaluator = new TaskEvaluator(this);
     }
@@ -367,7 +384,7 @@
 
     public void setStatus(Status newStatus) {
         for (TaskStateListener l : taskStateListeners) {
-            l.stateChanged(this, taskDto.getStatus(), newStatus);
+            l.stateChanged(taskDto.getStatus(), newStatus);
         }
         taskDto.setStatus(newStatus);
     }
@@ -535,6 +552,13 @@
         taskDto.setSuspendUntil(null);
         resume();
     }
+
+    public void deadlineJobAction() {
+        taskDto.getDeadlines().remove(getCurrentJob());
+        deadlineController.deadlineCrossed(getCurrentJob());
+    }
+
+    
     
     public void resume() {
         setStatus(taskDto.getStatusBeforeSuspend());
@@ -567,13 +591,7 @@
     }
     
     public void forward(TOrganizationalEntity target) {
-        releaseOwner();
-        
-        for (TaskOrgEntity x : taskDto.getPeopleAssignments()) {
-            x.setTask(null);
-            hiseEngine.getHiseDao().remove(x);
-        }
-        taskDto.getPeopleAssignments().clear();
+        Set<TaskOrgEntity> e = new HashSet<TaskOrgEntity>();
         
         for (String user : XmlUtils.notNull(target.getUsers(), new TUserlist()).getUser())
{
             TaskOrgEntity x = new TaskOrgEntity();
@@ -581,7 +599,7 @@
             x.setName(user);
             x.setType(OrgEntityType.USER);
             x.setTask(taskDto);
-            taskDto.getPeopleAssignments().add(x);
+            e.add(x);
         }
 
         for (String group : XmlUtils.notNull(target.getGroups(), new TGrouplist()).getGroup())
{
@@ -590,11 +608,26 @@
             x.setName(group);
             x.setType(OrgEntityType.GROUP);
             x.setTask(taskDto);
-            taskDto.getPeopleAssignments().add(x);
+            e.add(x);
+        }
+        
+        forward(e);
+    }
+    
+    public void forward(Set<TaskOrgEntity> targets) {
+        __log.debug("forwarding to " + targets);
+        releaseOwner();
+        
+        for (TaskOrgEntity x : taskDto.getPeopleAssignments()) {
+            x.setTask(null);
+            hiseEngine.getHiseDao().remove(x);
         }
+        taskDto.getPeopleAssignments().clear();
+        taskDto.getPeopleAssignments().addAll(targets);
         
         tryNominateOwner();
     }
+    
 
     //    
     // /**

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=902119&r1=902118&r2=902119&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
Fri Jan 22 15:29:56 2010
@@ -19,6 +19,7 @@
 
 package org.apache.hise.runtime;
 
+import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -26,11 +27,17 @@
 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.dao.GenericHumanRole;
 import org.apache.hise.dao.TaskOrgEntity;
 import org.apache.hise.dao.TaskOrgEntity.OrgEntityType;
+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;
@@ -67,6 +74,7 @@
         evaluator.setContextObject(this);
         evaluator.declareJavaClass("http://www.example.org/WS-HT", HtdFunctions.class);
         evaluator.bindVariable(QName.valueOf("taskId"), task.getTaskDto().getId());
+        evaluator.bindVariable(QName.valueOf("currentEventDateTime"), task.getCurrentEventDateTime());
         return evaluator;
     }
     
@@ -74,41 +82,22 @@
         return Integer.parseInt("" + evaluateExpression(task.getTaskDefinition().gettTask().getPriority()));
     }
 
-    public List evaluateExpression(TExpression expr) {
+    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().gettTask().getPeopleAssignments();
 
         for (JAXBElement<TGenericHumanRole> r : p.getGenericHumanRole()) {
             GenericHumanRole assignmentRole = GenericHumanRole.valueOf(r.getName().getLocalPart().toUpperCase());
-            TGenericHumanRole role = r.getValue();
-            TFrom f = role.getFrom();
-            if (f.getLogicalPeopleGroup() != null) {
-                // TODO
-            } 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("declare
namespace htd='http://www.example.org/WS-HT'; for $i in htd:literal/htd:organizationalEntity/htd:users/htd:user
return string($i)", e)) {
-                        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("declare
namespace htd='http://www.example.org/WS-HT'; for $i in htd:literal/htd:organizationalEntity/htd:groups/htd:group
return string($i)", e)) {
-                        TaskOrgEntity x = new TaskOrgEntity();
-                        x.setGenericHumanRole(assignmentRole);
-                        x.setName(group);
-                        x.setType(OrgEntityType.GROUP);
-                        x.setTask(task.getTaskDto());
-                        result.add(x);
-                    }
-                }
-            }
+            Set<TaskOrgEntity> result2 = evaluateGenericHumanRole(r.getValue(), assignmentRole);
+            result.addAll(result2);
         }
         if (__log.isDebugEnabled()) {
             __log.debug("evaluated people assignments " + task.getTaskDefinition().getTaskName()
+ " " + result);
@@ -116,6 +105,36 @@
         return result;
     }
 
+    public Set<TaskOrgEntity> evaluateGenericHumanRole(TGenericHumanRole role, GenericHumanRole
assignmentRole) {
+        Set<TaskOrgEntity> result = new HashSet<TaskOrgEntity>();
+
+        TFrom f = role.getFrom();
+        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("declare
namespace htd='http://www.example.org/WS-HT'; for $i in htd:literal/htd:organizationalEntity/htd:users/htd:user
return string($i)", e)) {
+                    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("declare
namespace htd='http://www.example.org/WS-HT'; for $i in htd:literal/htd:organizationalEntity/htd:groups/htd:group
return string($i)", e)) {
+                    TaskOrgEntity x = new TaskOrgEntity();
+                    x.setGenericHumanRole(assignmentRole);
+                    x.setName(group);
+                    x.setType(OrgEntityType.GROUP);
+                    x.setTask(task.getTaskDto());
+                    result.add(x);
+                }
+            }
+        }
+        return result;
+    }
+
     public Node createEprFromHeader(Node header) {
         return (Node) buildQueryEvaluator().evaluateExpression("<wsa:EndpointReference
xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">{ */wsa:ReplyTo/* }</wsa:EndpointReference>",
header).get(0);
     }
@@ -140,4 +159,40 @@
         return (Node) evaluator.evaluateExpression("<htd:taskId xmlns:htd=\"xmlns:htd=http://www.example.org/WS-HT\">{$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().gettTask().getDeadlines();
+        for (TDeadline u : d.getStartDeadline()) {
+            for (TEscalation e : u.getEscalation()) {
+                if (getEscalationKey(e, false).equals(name)) {
+                    return new EscalationResult(e, false);
+                }
+            }
+        }
+
+        for (TDeadline u : d.getCompletionDeadline()) {
+            for (TEscalation e : u.getEscalation()) {
+                if (getEscalationKey(e, true).equals(name)) {
+                    return new EscalationResult(e, true);
+                }
+            }
+        }
+        
+        return null;
+    }
 }

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskLifecycle.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskLifecycle.java?rev=902119&r1=902118&r2=902119&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskLifecycle.java
(original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskLifecycle.java
Fri Jan 22 15:29:56 2010
@@ -26,9 +26,16 @@
 
 public class TaskLifecycle implements TaskStateListener {
     
-    private Log __log = LogFactory.getLog(TaskLifecycle.class);
+    private static Log __log = LogFactory.getLog(TaskLifecycle.class);
 
-    public void stateChanged(Task task, Status oldStatus, Status newStatus) {
+    private Task task;
+    
+    public TaskLifecycle(Task task) {
+        super();
+        this.task = task;
+    }
+
+    public void stateChanged(Status oldStatus, Status newStatus) {
         boolean isOk = false;
 
         // check if change is valid for current state

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskStateListener.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskStateListener.java?rev=902119&r1=902118&r2=902119&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskStateListener.java
(original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskStateListener.java
Fri Jan 22 15:29:56 2010
@@ -20,5 +20,5 @@
 package org.apache.hise.runtime;
 
 public interface TaskStateListener {
-    void stateChanged(Task task, org.apache.hise.dao.Task.Status oldStatus, org.apache.hise.dao.Task.Status
newStatus);
+    void stateChanged(org.apache.hise.dao.Task.Status oldStatus, org.apache.hise.dao.Task.Status
newStatus);
 }

Modified: incubator/hise/trunk/hise-services/src/main/resources/org/apache/hise/persistence.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/resources/org/apache/hise/persistence.xml?rev=902119&r1=902118&r2=902119&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/resources/org/apache/hise/persistence.xml
(original)
+++ incubator/hise/trunk/hise-services/src/main/resources/org/apache/hise/persistence.xml
Fri Jan 22 15:29:56 2010
@@ -21,7 +21,6 @@
     <persistence-unit name="org.apache.hise">
         <class>org.apache.hise.dao.Attachment</class>
         <class>org.apache.hise.dao.Comment</class>
-        <class>org.apache.hise.dao.Deadline</class>
         <class>org.apache.hise.dao.Fault</class>
         <class>org.apache.hise.dao.JpaBase</class>
         <class>org.apache.hise.dao.Message</class>

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=902119&r1=902118&r2=902119&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
Fri Jan 22 15:29:56 2010
@@ -1,5 +1,6 @@
 package org.apache.hise;
 
+import java.util.Date;
 import java.util.List;
 
 import javax.xml.namespace.QName;
@@ -9,6 +10,8 @@
 import net.sf.saxon.dom.NodeOverNodeInfo;
 import net.sf.saxon.om.NodeInfo;
 
+import org.apache.hise.lang.xsd.htd.TDeadline;
+import org.apache.hise.lang.xsd.htd.TDurationExpr;
 import org.apache.hise.runtime.Task;
 import org.apache.hise.runtime.TaskEvaluator;
 import org.apache.hise.utils.DOMUtils;
@@ -17,6 +20,17 @@
 import org.w3c.dom.Node;
 
 public class TaskEvaluatorTest {
+    
+    private TaskEvaluator buildTaskEvaluator() {
+        Task t = new MockTask();
+        t.setCurrentEventDateTime(new Date(1234L));
+        org.apache.hise.dao.Task t2 = new org.apache.hise.dao.Task();
+        t2.setId(1234L);
+        t.setTaskDto(t2);
+        
+        return new TaskEvaluator(t);
+    }
+    
     @Test
     public void testEval() throws Exception {
         XQueryEvaluator e = new XQueryEvaluator();
@@ -48,14 +62,22 @@
     
     @Test
     public void testEvaluateApproveResponseHeader() throws Exception {
-        Task t = new MockTask();
-        org.apache.hise.dao.Task t2 = new org.apache.hise.dao.Task();
-        t2.setId(1234L);
-        t.setTaskDto(t2);
-        
-        TaskEvaluator te = new TaskEvaluator(t);
+        TaskEvaluator te = buildTaskEvaluator();
         Node n = te.evaluateApproveResponseHeader();
         Assert.assertTrue(DOMUtils.domToString(n).contains(">1234<"));
     }
+    
+    @Test
+    public void testDeadline() throws Exception {
+        TaskEvaluator e = buildTaskEvaluator();
+
+        TDeadline deadline = new TDeadline();
+        TDurationExpr d = new TDurationExpr();
+        deadline.setFor(d);
+        d.getContent().add(new String("'PT5S'"));
+        Date r = e.evaluateDeadline(deadline);
+        Assert.assertEquals(6234L, r.getTime());
+    }
+
 
 }

Modified: incubator/hise/trunk/hise-test-example/src/main/resources/testHtd1.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-test-example/src/main/resources/testHtd1.xml?rev=902119&r1=902118&r2=902119&view=diff
==============================================================================
--- incubator/hise/trunk/hise-test-example/src/main/resources/testHtd1.xml (original)
+++ incubator/hise/trunk/hise-test-example/src/main/resources/testHtd1.xml Fri Jan 22 15:29:56
2010
@@ -83,12 +83,13 @@
                     </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>
@@ -227,11 +228,13 @@
                   </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>



Mime
View raw message