[jboss-svn-commits] JBL Code SVN: r22259 - in labs/jbossrules/trunk/drools-process/drools-process-task/src: main/java/org/drools/task/query and 11 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Aug 30 12:58:29 EDT 2008
Author: mark.proctor at jboss.com
Date: 2008-08-30 12:58:28 -0400 (Sat, 30 Aug 2008)
New Revision: 22259
Added:
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/query/
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/query/TaskSummary.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/DefaultEscalatedDeadlineHandler.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/EscalatedDeadlineHandler.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/resources/org/
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/resources/org/drools/
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/resources/org/drools/task/
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/resources/org/drools/task/service/
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/resources/org/drools/task/service/OpenOwnedTasksForUser.txt
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/resources/org/drools/task/service/UnescalatedDeadlines.txt
labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/ModelPersistenceTest.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/QueryTest.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/service/TaskServiceEscalationTest.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/OpenOwnedTasksForUser.mvel
labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/UnescalatedDeadlines.mvel
Removed:
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/TaskSummary.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/TestModelPersistence.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/AllOpenTasksData.mvel
labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/service/AllOpenTasks.txt
Modified:
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/Deadline.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/TaskData.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/TaskClientHandler.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/TaskServerHandler.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/TaskService.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/utils/CollectionUtils.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/BaseTest.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/service/TaskServiceTest.java
labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/QueryResultsInEnglish.mvel
labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/QueryResultsInGerman.mvel
Log:
JBRULES-1745 WS-Human-Task
-Deadlines now have a scheduler, which schedules existing tasks on startup and new tasks.
Modified: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/Deadline.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/Deadline.java 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/Deadline.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -35,6 +35,8 @@
@JoinColumn(name = "Deadline_Escalation_Id", nullable = true)
private List<Escalation> escalations = Collections.emptyList();
+ private boolean escalated;
+
public void writeExternal(ObjectOutput out) throws IOException {
out.writeLong( id );
@@ -91,6 +93,14 @@
this.escalations = escalations;
}
+ public boolean isEscalated() {
+ return escalated;
+ }
+
+ public void setEscalated(boolean escalated) {
+ this.escalated = escalated;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
@@ -98,6 +108,8 @@
result = prime * result + ((date == null) ? 0 : date.hashCode());
result = prime * result + CollectionUtils.hashCode( documentation );
result = prime * result + CollectionUtils.hashCode( escalations );
+ result = prime * result + (escalated ? 1231 : 1237);
+ result = prime * result + (int) (id ^ (id >>> 32));
return result;
}
@@ -107,12 +119,17 @@
if ( obj == null ) return false;
if ( !(obj instanceof Deadline) ) return false;
Deadline other = (Deadline) obj;
+
if ( date == null ) {
if ( other.date != null ) return false;
} else if ( date.getTime() != other.date.getTime() ) return false;
- return CollectionUtils.equals( documentation, other.documentation ) && CollectionUtils.equals( escalations, other.escalations );
+ if ( escalated != other.escalated ) return false;
+
+ return CollectionUtils.equals( documentation, other.documentation ) && CollectionUtils.equals( escalations, other.escalations );
}
+
+
}
Modified: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/TaskData.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/TaskData.java 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/TaskData.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -14,38 +14,46 @@
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import org.drools.task.utils.CollectionUtils;
@Embeddable
-public class TaskData implements Externalizable {
- @Enumerated(EnumType.STRING)
- private Status status = Status.Created; // initial default state
-
+public class TaskData
+ implements
+ Externalizable {
+ @Enumerated(EnumType.STRING)
+ private Status status = Status.Created; // initial default state
+
@ManyToOne()
private User actualOwner;
-
+
@ManyToOne()
private User createdBy;
private Date createdOn;
-
+
private Date activationTime;
-
+
private Date expirationTime;
-
+
private boolean skipable;
+ private String associatedDocumentType;
+
+ @Lob
+ private byte[] associatedDocument;
+
@OneToMany(cascade = CascadeType.ALL)
- @JoinColumn(name = "TaskData_Comments_Id", nullable = true)
- private List<Comment> comments = Collections.emptyList();
-
+ @JoinColumn(name = "TaskData_Comments_Id", nullable = true)
+ private List<Comment> comments = Collections.emptyList();
+
@OneToMany(cascade = CascadeType.ALL)
- @JoinColumn(name = "TaskData_Attachments_Id", nullable = true)
+ @JoinColumn(name = "TaskData_Attachments_Id", nullable = true)
private List<Attachment> attachments = Collections.emptyList();
-
+
public void writeExternal(ObjectOutput out) throws IOException {
if ( status != null ) {
out.writeBoolean( true );
@@ -53,89 +61,91 @@
} else {
out.writeBoolean( false );
}
-
- if ( actualOwner != null) {
+
+ if ( actualOwner != null ) {
out.writeBoolean( true );
actualOwner.writeExternal( out );
} else {
out.writeBoolean( false );
}
-
+
if ( createdBy != null ) {
out.writeBoolean( true );
createdBy.writeExternal( out );
} else {
out.writeBoolean( false );
}
-
+
if ( createdOn != null ) {
out.writeBoolean( true );
out.writeLong( createdOn.getTime() );
} else {
out.writeBoolean( false );
}
-
+
if ( activationTime != null ) {
out.writeBoolean( true );
out.writeLong( activationTime.getTime() );
} else {
out.writeBoolean( false );
}
-
+
if ( expirationTime != null ) {
out.writeBoolean( true );
out.writeLong( expirationTime.getTime() );
} else {
out.writeBoolean( false );
}
- out.writeBoolean( skipable );
- CollectionUtils.writeCommentList( comments, out );
- CollectionUtils.writeAttachmentList( attachments, out );
- }
-
+ out.writeBoolean( skipable );
+ CollectionUtils.writeCommentList( comments,
+ out );
+ CollectionUtils.writeAttachmentList( attachments,
+ out );
+ }
+
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
- if( in.readBoolean() ) {
+ if ( in.readBoolean() ) {
status = Status.valueOf( in.readUTF() );
}
-
+
if ( in.readBoolean() ) {
actualOwner = new User();
actualOwner.readExternal( in );
}
-
+
if ( in.readBoolean() ) {
createdBy = new User();
createdBy.readExternal( in );
}
-
+
if ( in.readBoolean() ) {
createdOn = new Date( in.readLong() );
}
-
+
if ( in.readBoolean() ) {
activationTime = new Date( in.readLong() );
}
-
+
if ( in.readBoolean() ) {
expirationTime = new Date( in.readLong() );
}
-
+
skipable = in.readBoolean();
-
+
comments = CollectionUtils.readCommentList( in );
attachments = CollectionUtils.readAttachmentList( in );
-
- }
-
+
+ }
+
public Status getStatus() {
return status;
}
-
+
public void setStatus(Status status) {
this.status = status;
}
-
+
public User getActualOwner() {
return actualOwner;
}
@@ -143,7 +153,7 @@
public void setActualOwner(User actualOwner) {
this.actualOwner = actualOwner;
}
-
+
public User getCreatedBy() {
return createdBy;
}
@@ -155,47 +165,47 @@
public Date getCreatedOn() {
return createdOn;
}
-
+
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
-
+
public Date getActivationTime() {
return activationTime;
}
-
+
public void setActivationTime(Date activationTime) {
this.activationTime = activationTime;
}
-
+
public Date getExpirationTime() {
return expirationTime;
}
-
+
public void setExpirationTime(Date expirationTime) {
this.expirationTime = expirationTime;
}
-
+
public boolean isSkipable() {
return skipable;
}
-
+
public void setSkipable(boolean isSkipable) {
this.skipable = isSkipable;
}
-
+
public List<Comment> getComments() {
return comments;
}
-
+
public void setComments(List<Comment> comments) {
this.comments = comments;
}
-
+
public List<Attachment> getAttachments() {
return attachments;
}
-
+
public void setAttachments(List<Attachment> attachments) {
this.attachments = attachments;
}
@@ -220,35 +230,36 @@
if ( obj == null ) return false;
if ( !(obj instanceof TaskData) ) return false;
TaskData other = (TaskData) obj;
-
+
if ( actualOwner == null ) {
if ( other.actualOwner != null ) return false;
- } else if ( !actualOwner.equals( other.actualOwner) ) {
+ } else if ( !actualOwner.equals( other.actualOwner ) ) {
return false;
}
-
+
if ( createdBy == null ) {
if ( other.createdBy != null ) return false;
- } else if ( !createdBy.equals( other.createdBy) ) {
+ } else if ( !createdBy.equals( other.createdBy ) ) {
return false;
- }
-
+ }
+
if ( createdOn == null ) {
- if ( other.createdOn != null ) return false;
+ if ( other.createdOn != null ) return false;
} else if ( createdOn.getTime() != other.createdOn.getTime() ) return false;
if ( expirationTime == null ) {
- if ( other.expirationTime != null ) return false;
+ if ( other.expirationTime != null ) return false;
} else if ( expirationTime.getTime() != other.expirationTime.getTime() ) return false;
if ( skipable != other.skipable ) return false;
if ( status == null ) {
if ( other.status != null ) return false;
- } else if ( !status.equals( other.status ) ) return false;
+ } else if ( !status.equals( other.status ) ) return false;
if ( activationTime == null ) {
if ( other.activationTime != null ) return false;
- } else if ( activationTime.getTime() != other.activationTime.getTime() ) return false;
-
- return CollectionUtils.equals( attachments, other.attachments ) && CollectionUtils.equals( comments, other.comments );
+ } else if ( activationTime.getTime() != other.activationTime.getTime() ) return false;
+
+ return CollectionUtils.equals( attachments,
+ other.attachments ) && CollectionUtils.equals( comments,
+ other.comments );
}
-
-
+
}
Deleted: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/TaskSummary.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/TaskSummary.java 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/TaskSummary.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -1,254 +0,0 @@
-package org.drools.task;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.Serializable;
-import java.util.Date;
-
-
-public class TaskSummary implements Externalizable {
- private long id;
-
- private String name;
-
- private String subject;
-
- private String description;
-
- private Status status;
-
- private int priority;
-
- private boolean skipable;
-
- private User actualOwner;
-
- private User createdBy;
-
- private Date createdOn;
-
- private Date activationTime;
-
- private Date expirationTime;
-
-
-
- public TaskSummary(long id,
- String name,
- String subject,
- String description,
- Status status,
- int priority,
- boolean skipable,
- User actualOwner,
- User createdBy,
- Date createdOn,
- Date activationTime,
- Date expirationTime) {
- super();
- this.id = id;
- this.name = name;
- this.subject = subject;
- this.description = description;
- this.status = status;
- this.priority = priority;
- this.skipable = skipable;
- this.actualOwner = actualOwner;
- this.createdBy = createdBy;
- this.createdOn = createdOn;
- this.activationTime = activationTime;
- this.expirationTime = expirationTime;
- }
-
- public TaskSummary() {
- }
-
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeLong( id );
- out.writeUTF( name );
- out.writeUTF( subject );
- out.writeUTF( description );
- out.writeUTF( status.toString() );
- out.writeInt( priority );
- out.writeBoolean( skipable );
- actualOwner.writeExternal( out );
- createdBy.writeExternal( out );
- out.writeLong( createdOn.getTime() );
- out.writeLong( activationTime.getTime() );
- out.writeLong( expirationTime.getTime() );
- }
-
- public void readExternal(ObjectInput in) throws IOException,
- ClassNotFoundException {
- id = in.readLong();
- name = in.readUTF();
- subject = in.readUTF();
- description = in.readUTF();
- status = Status.valueOf( in.readUTF() );
- priority = in.readInt();
- skipable = in.readBoolean();
- actualOwner = new User();
- actualOwner.readExternal( in );
- createdBy = new User();
- createdBy.readExternal( in );
- createdOn = new Date( in.readLong() );
- activationTime = new Date( in.readLong() );
- expirationTime = new Date( in.readLong() );
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getSubject() {
- return subject;
- }
-
- public void setSubject(String subject) {
- this.subject = subject;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Status getStatus() {
- return status;
- }
-
- public void setStatus(Status status) {
- this.status = status;
- }
-
- public int getPriority() {
- return priority;
- }
-
- public void setPriority(int priority) {
- this.priority = priority;
- }
-
- public boolean isSkipable() {
- return skipable;
- }
-
- public void setSkipable(boolean skipable) {
- this.skipable = skipable;
- }
-
- public User getActualOwner() {
- return actualOwner;
- }
-
- public void setActualOwner(User actualOwner) {
- this.actualOwner = actualOwner;
- }
-
- public User getCreatedBy() {
- return createdBy;
- }
-
- public void setCreatedBy(User createdBy) {
- this.createdBy = createdBy;
- }
-
- public Date getCreatedOn() {
- return createdOn;
- }
-
- public void setCreatedOn(Date createdOn) {
- this.createdOn = createdOn;
- }
-
- public Date getActivationTime() {
- return activationTime;
- }
-
- public void setActivationTime(Date activationTime) {
- this.activationTime = activationTime;
- }
-
- public Date getExpirationTime() {
- return expirationTime;
- }
-
- public void setExpirationTime(Date expirationTime) {
- this.expirationTime = expirationTime;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((activationTime == null) ? 0 : activationTime.hashCode());
- result = prime * result + ((actualOwner == null) ? 0 : actualOwner.hashCode());
- result = prime * result + ((createdBy == null) ? 0 : createdBy.hashCode());
- result = prime * result + ((createdOn == null) ? 0 : createdOn.hashCode());
- result = prime * result + ((description == null) ? 0 : description.hashCode());
- result = prime * result + ((expirationTime == null) ? 0 : expirationTime.hashCode());
- result = prime * result + (int) (id ^ (id >>> 32));
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + priority;
- result = prime * result + (skipable ? 1231 : 1237);
- result = prime * result + ((status == null) ? 0 : status.hashCode());
- result = prime * result + ((subject == null) ? 0 : subject.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if ( this == obj ) return true;
- if ( obj == null ) return false;
- if ( !(obj instanceof TaskSummary) ) return false;
- TaskSummary other = (TaskSummary) obj;
- if ( activationTime == null ) {
- if ( other.activationTime != null ) return false;
- } else if ( activationTime.getTime() != other.activationTime.getTime() ) return false;
- if ( actualOwner == null ) {
- if ( other.actualOwner != null ) return false;
- } else if ( !actualOwner.equals( other.actualOwner ) ) return false;
- if ( createdBy == null ) {
- if ( other.createdBy != null ) return false;
- } else if ( !createdBy.equals( other.createdBy ) ) return false;
- if ( createdOn == null ) {
- if ( other.createdOn != null ) return false;
- } else if ( createdOn.getTime() != other.createdOn.getTime() ) return false;
- if ( description == null ) {
- if ( other.description != null ) return false;
- } else if ( !description.equals( other.description ) ) return false;
- if ( expirationTime == null ) {
- if ( other.expirationTime != null ) return false;
- } else if ( expirationTime.getTime() != other.expirationTime.getTime() ) return false;
- if ( name == null ) {
- if ( other.name != null ) return false;
- } else if ( !name.equals( other.name ) ) return false;
- if ( priority != other.priority ) return false;
- if ( skipable != other.skipable ) return false;
- if ( status == null ) {
- if ( other.status != null ) return false;
- } else if ( !status.equals( other.status ) ) return false;
- if ( subject == null ) {
- if ( other.subject != null ) return false;
- } else if ( !subject.equals( other.subject ) ) return false;
- return true;
- }
-
-}
Copied: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/query/TaskSummary.java (from rev 22239, labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/TaskSummary.java)
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/query/TaskSummary.java (rev 0)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/query/TaskSummary.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -0,0 +1,337 @@
+package org.drools.task.query;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+import java.util.Date;
+
+import org.drools.task.Status;
+import org.drools.task.User;
+
+public class TaskSummary
+ implements
+ Externalizable {
+ private long id;
+
+ private String name;
+
+ private String subject;
+
+ private String description;
+
+ private Status status;
+
+ private int priority;
+
+ private boolean skipable;
+
+ private User actualOwner;
+
+ private User createdBy;
+
+ private Date createdOn;
+
+ private Date activationTime;
+
+ private Date expirationTime;
+
+ public TaskSummary(long id,
+ String name,
+ String subject,
+ String description,
+ Status status,
+ int priority,
+ boolean skipable,
+ User actualOwner,
+ User createdBy,
+ Date createdOn,
+ Date activationTime,
+ Date expirationTime) {
+ super();
+ this.id = id;
+ this.name = name;
+ this.subject = subject;
+ this.description = description;
+ this.status = status;
+ this.priority = priority;
+ this.skipable = skipable;
+ this.actualOwner = actualOwner;
+ this.createdBy = createdBy;
+ this.createdOn = createdOn;
+ this.activationTime = activationTime;
+ this.expirationTime = expirationTime;
+ }
+
+ public TaskSummary() {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong( id );
+
+ if ( name != null ) {
+ out.writeBoolean( true );
+ out.writeUTF( name );
+ } else {
+ out.writeBoolean( false );
+ }
+ if ( subject != null ) {
+ out.writeBoolean( true );
+ out.writeUTF( subject );
+ } else {
+ out.writeBoolean( false );
+ }
+
+ if ( description != null ) {
+ out.writeBoolean( true );
+ out.writeUTF( description );
+ } else {
+ out.writeBoolean( false );
+ }
+
+ if ( status != null ) {
+ out.writeBoolean( true );
+ out.writeUTF( status.toString() );
+ } else {
+ out.writeBoolean( false );
+ }
+
+ out.writeInt( priority );
+ out.writeBoolean( skipable );
+
+ if ( actualOwner != null ) {
+ out.writeBoolean( true );
+ actualOwner.writeExternal( out );
+ } else {
+ out.writeBoolean( false );
+ }
+
+ if ( createdBy != null ) {
+ out.writeBoolean( true );
+ createdBy.writeExternal( out );
+ } else {
+ out.writeBoolean( false );
+ }
+ if ( createdOn != null ) {
+ out.writeBoolean( true );
+ out.writeLong( createdOn.getTime() );
+ } else {
+ out.writeBoolean( false );
+ }
+
+ if ( activationTime != null ) {
+ out.writeBoolean( true );
+ out.writeLong( activationTime.getTime() );
+ } else {
+ out.writeBoolean( false );
+ }
+
+ if ( expirationTime != null ) {
+ out.writeBoolean( true );
+ out.writeLong( expirationTime.getTime() );
+ } else {
+ out.writeBoolean( false );
+ }
+ }
+
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ id = in.readLong();
+
+ if ( in.readBoolean() ) {
+ name = in.readUTF();
+ }
+
+ if ( in.readBoolean() ) {
+ subject = in.readUTF();
+ }
+
+ if ( in.readBoolean() ) {
+ description = in.readUTF();
+ }
+
+ if ( in.readBoolean() ) {
+ status = Status.valueOf( in.readUTF() );
+ }
+
+ priority = in.readInt();
+ skipable = in.readBoolean();
+
+ if ( in.readBoolean() ) {
+ actualOwner = new User();
+ actualOwner.readExternal( in );
+ }
+
+ if ( in.readBoolean() ) {
+ createdBy = new User();
+ createdBy.readExternal( in );
+ }
+
+ if ( in.readBoolean() ) {
+ createdOn = new Date( in.readLong() );
+ }
+
+ if ( in.readBoolean() ) {
+ activationTime = new Date( in.readLong() );
+ }
+
+ if ( in.readBoolean() ) {
+ expirationTime = new Date( in.readLong() );
+ }
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getSubject() {
+ return subject;
+ }
+
+ public void setSubject(String subject) {
+ this.subject = subject;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
+
+ public boolean isSkipable() {
+ return skipable;
+ }
+
+ public void setSkipable(boolean skipable) {
+ this.skipable = skipable;
+ }
+
+ public User getActualOwner() {
+ return actualOwner;
+ }
+
+ public void setActualOwner(User actualOwner) {
+ this.actualOwner = actualOwner;
+ }
+
+ public User getCreatedBy() {
+ return createdBy;
+ }
+
+ public void setCreatedBy(User createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ public Date getCreatedOn() {
+ return createdOn;
+ }
+
+ public void setCreatedOn(Date createdOn) {
+ this.createdOn = createdOn;
+ }
+
+ public Date getActivationTime() {
+ return activationTime;
+ }
+
+ public void setActivationTime(Date activationTime) {
+ this.activationTime = activationTime;
+ }
+
+ public Date getExpirationTime() {
+ return expirationTime;
+ }
+
+ public void setExpirationTime(Date expirationTime) {
+ this.expirationTime = expirationTime;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((activationTime == null) ? 0 : activationTime.hashCode());
+ result = prime * result + ((actualOwner == null) ? 0 : actualOwner.hashCode());
+ result = prime * result + ((createdBy == null) ? 0 : createdBy.hashCode());
+ result = prime * result + ((createdOn == null) ? 0 : createdOn.hashCode());
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((expirationTime == null) ? 0 : expirationTime.hashCode());
+ result = prime * result + (int) (id ^ (id >>> 32));
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + priority;
+ result = prime * result + (skipable ? 1231 : 1237);
+ result = prime * result + ((status == null) ? 0 : status.hashCode());
+ result = prime * result + ((subject == null) ? 0 : subject.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( this == obj ) return true;
+ if ( obj == null ) return false;
+ if ( !(obj instanceof TaskSummary) ) return false;
+ TaskSummary other = (TaskSummary) obj;
+ if ( activationTime == null ) {
+ if ( other.activationTime != null ) return false;
+ } else if ( activationTime.getTime() != other.activationTime.getTime() ) return false;
+ if ( actualOwner == null ) {
+ if ( other.actualOwner != null ) return false;
+ } else if ( !actualOwner.equals( other.actualOwner ) ) return false;
+ if ( createdBy == null ) {
+ if ( other.createdBy != null ) return false;
+ } else if ( !createdBy.equals( other.createdBy ) ) return false;
+ if ( createdOn == null ) {
+ if ( other.createdOn != null ) return false;
+ } else if ( createdOn.getTime() != other.createdOn.getTime() ) return false;
+ if ( description == null ) {
+ if ( other.description != null ) return false;
+ } else if ( !description.equals( other.description ) ) return false;
+ if ( expirationTime == null ) {
+ if ( other.expirationTime != null ) return false;
+ } else if ( expirationTime.getTime() != other.expirationTime.getTime() ) return false;
+ if ( name == null ) {
+ if ( other.name != null ) return false;
+ } else if ( !name.equals( other.name ) ) return false;
+ if ( priority != other.priority ) return false;
+ if ( skipable != other.skipable ) return false;
+ if ( status == null ) {
+ if ( other.status != null ) return false;
+ } else if ( !status.equals( other.status ) ) return false;
+ if ( subject == null ) {
+ if ( other.subject != null ) return false;
+ } else if ( !subject.equals( other.subject ) ) return false;
+ return true;
+ }
+
+}
Property changes on: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/query/TaskSummary.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/DefaultEscalatedDeadlineHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/DefaultEscalatedDeadlineHandler.java (rev 0)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/DefaultEscalatedDeadlineHandler.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -0,0 +1,34 @@
+package org.drools.task.service;
+
+import javax.persistence.EntityManager;
+
+import org.drools.task.Deadline;
+import org.drools.task.Escalation;
+import org.drools.task.Notification;
+import org.drools.task.Reassignment;
+import org.drools.task.Task;
+
+public class DefaultEscalatedDeadlineHandler implements EscalatedDeadlineHandler {
+
+ public void executeEscalatedDeadline(Task task,
+ Deadline deadline,
+ EntityManager em) {
+
+ for ( Escalation escalation : deadline.getEscalations() ) {
+ // we won't impl constraints for now
+ //escalation.getConstraints()
+
+ for ( Notification notification : escalation.getNotifications() ) {
+ //notification.g
+ }
+
+ for ( Reassignment reassignment : escalation.getReassignments() ) {
+ //reassignment.g
+ }
+ }
+ em.getTransaction().begin();
+ deadline.setEscalated( true );
+ em.getTransaction().commit();
+ }
+
+}
Added: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/EscalatedDeadlineHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/EscalatedDeadlineHandler.java (rev 0)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/EscalatedDeadlineHandler.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -0,0 +1,13 @@
+/**
+ *
+ */
+package org.drools.task.service;
+
+import javax.persistence.EntityManager;
+
+import org.drools.task.Deadline;
+import org.drools.task.Task;
+
+public interface EscalatedDeadlineHandler {
+ public void executeEscalatedDeadline(Task task, Deadline deadline, EntityManager em);
+}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/TaskClientHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/TaskClientHandler.java 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/TaskClientHandler.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -8,7 +8,7 @@
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;
-import org.drools.task.TaskSummary;
+import org.drools.task.query.TaskSummary;
public class TaskClientHandler extends IoHandlerAdapter
{
Modified: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/TaskServerHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/TaskServerHandler.java 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/TaskServerHandler.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -9,7 +9,7 @@
import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;
import org.drools.task.Task;
-import org.drools.task.TaskSummary;
+import org.drools.task.query.TaskSummary;
public class TaskServerHandler extends IoHandlerAdapter {
private TaskService service;
@@ -34,7 +34,7 @@
break;
}
case AllOpenTasksForUserRequest : {
- List<TaskSummary> results = service.getAllOpenTasksForUser( (Long) cmd.getArguments().get( 0 ),
+ List<TaskSummary> results = service.getOpenOwnedTasksForUser( (Long) cmd.getArguments().get( 0 ),
(String) cmd.getArguments().get( 1 ) );
List args = new ArrayList( 1 );
args.add( results );
Modified: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/TaskService.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/TaskService.java 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/service/TaskService.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -3,63 +3,155 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.util.Date;
import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
import javax.persistence.Query;
+import org.drools.task.Deadline;
import org.drools.task.Group;
import org.drools.task.Task;
-import org.drools.task.TaskSummary;
import org.drools.task.User;
+import org.drools.task.query.TaskSummary;
public class TaskService {
- EntityManager em;
-
- Query allOpenTasks;
-
+ EntityManager em;
+
+ Query openOwnedTasksForUser;
+ Query unescalatedDeadlines;
+
+ ScheduledThreadPoolExecutor scheduler;
+
+ private EscalatedDeadlineHandler escalatedDeadlineHandler;
+
public TaskService(EntityManager em) {
- this.em = em;
-
- Reader reader = new InputStreamReader( getClass().getResourceAsStream( "AllOpenTasks.txt" ) );
+ this.em = em;
+
+ Reader reader = new InputStreamReader( getClass().getResourceAsStream( "OpenOwnedTasksForUser.txt" ) );
try {
- allOpenTasks = em.createQuery( toString( reader ) );
- } catch (IOException e) {
- throw new RuntimeException( "Unable to inialize TaskService, could not load query 'AllOpenTasks'" );
- }
+ openOwnedTasksForUser = em.createQuery( toString( reader ) );
+ } catch ( IOException e ) {
+ throw new RuntimeException( "Unable to inialize TaskService, could not load query 'AllOpenTasks'",
+ e );
+ }
+ scheduler = new ScheduledThreadPoolExecutor( 3 );
+
+ try {
+ reader = new InputStreamReader( getClass().getResourceAsStream( "UnescalatedDeadlines.txt" ) );
+ unescalatedDeadlines = em.createQuery( toString( reader ) );
+ long now = System.currentTimeMillis();
+ for ( Object object : unescalatedDeadlines.getResultList() ) {
+ Object[] objects = (Object[]) object;
+ long taskId = ((Long) objects[0]).longValue();
+ long deadlineId = ((Long) objects[1]).longValue();
+ Date date = (Date) objects[2];
+ scheduler.schedule( new ScheduledTaskDeadline( taskId,
+ deadlineId,
+ this ),
+ date.getTime() - now,
+ TimeUnit.MILLISECONDS );
+ }
+ } catch ( IOException e ) {
+ throw new RuntimeException( "Unable to inialize TaskService, could not load and schedule oustanding deadlines",
+ e );
+ }
}
-
+
+ public void setEscalatedDeadlineHandler(EscalatedDeadlineHandler escalatedDeadlineHandler) {
+ this.escalatedDeadlineHandler = escalatedDeadlineHandler;
+ }
+
public void addUser(User user) {
em.getTransaction().begin();
em.persist( user );
em.getTransaction().commit();
}
-
+
public void addGroup(Group group) {
em.getTransaction().begin();
em.persist( group );
em.getTransaction().commit();
- }
-
+ }
+
public void addTask(Task task) {
em.getTransaction().begin();
em.persist( task );
+ em.flush();
em.getTransaction().commit();
+ long now = System.currentTimeMillis();
+ // schedule after it's been persisted, otherwise the id's won't be assigned
+ if ( task.getDeadlines() != null ) {
+ if ( task.getDeadlines().getStartDeadlines() != null ) {
+ for ( Deadline deadline : task.getDeadlines().getStartDeadlines() ) {
+ if ( !deadline.isEscalated() ) {
+ // only escalate when true - typically this would only be true
+ // if the user is requested that the notification should never be escalated
+ Date date = deadline.getDate();
+ scheduler.schedule( new ScheduledTaskDeadline( task.getId(),
+ deadline.getId(),
+ this ),
+ date.getTime() - now,
+ TimeUnit.MILLISECONDS );
+ }
+ }
+ }
+
+ if ( task.getDeadlines().getEndDeadLines() != null ) {
+ for ( Deadline deadline : task.getDeadlines().getEndDeadLines() ) {
+ // only escalate when true - typically this would only be true
+ // if the user is requested that the notification should never be escalated
+ if ( !deadline.isEscalated() ) {
+ Date date = deadline.getDate();
+ scheduler.schedule( new ScheduledTaskDeadline( task.getId(),
+ deadline.getId(),
+ this ),
+ date.getTime() - now,
+ TimeUnit.MILLISECONDS );
+ }
+ }
+ }
+ }
}
-
+
public Task getTask(long taskId) {
- return em.find( Task.class, taskId );
+ return em.find( Task.class,
+ taskId );
}
-
- public List<TaskSummary> getAllOpenTasksForUser(long userId, String language) {
- allOpenTasks.setParameter( "currentUser", userId );
- allOpenTasks.setParameter( "language", language );
- List<TaskSummary> list = ( List<TaskSummary> ) allOpenTasks.getResultList();
+
+ public List<Object[]> getUnescalatedDeadlines() {
+ return unescalatedDeadlines.getResultList();
+ }
+
+ public List<TaskSummary> getOpenOwnedTasksForUser(long userId,
+ String language) {
+ openOwnedTasksForUser.setParameter( "currentUser",
+ userId );
+ openOwnedTasksForUser.setParameter( "language",
+ language );
+ List<TaskSummary> list = (List<TaskSummary>) openOwnedTasksForUser.getResultList();
return list;
}
-
+
+ public void executeEscalatedDeadline(long taskId,
+ long deadlineId) {
+ Task task = em.find( Task.class,
+ taskId );
+ Deadline deadline = em.find( Deadline.class,
+ deadlineId );
+
+ if ( escalatedDeadlineHandler == null ) {
+ escalatedDeadlineHandler = new DefaultEscalatedDeadlineHandler();
+ }
+
+ escalatedDeadlineHandler.executeEscalatedDeadline( task,
+ deadline,
+ em );
+ }
+
public static String toString(Reader reader) throws IOException {
int charValue = 0;
StringBuffer sb = new StringBuffer( 1024 );
@@ -68,5 +160,56 @@
sb.append( (char) charValue );
}
return sb.toString();
- }
+ }
+
+ public static class ScheduledTaskDeadline
+ implements
+ Callable {
+ private long taskId;
+ private long deadlineId;
+ private TaskService service;
+
+ public ScheduledTaskDeadline(long taskId,
+ long deadlineId,
+ TaskService service) {
+ this.taskId = taskId;
+ this.deadlineId = deadlineId;
+ this.service = service;
+ }
+
+ public long getTaskId() {
+ return taskId;
+ }
+
+ public long getDeadlineId() {
+ return deadlineId;
+ }
+
+ public Object call() throws Exception {
+ service.executeEscalatedDeadline( taskId,
+ deadlineId );
+ return null;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (deadlineId ^ (deadlineId >>> 32));
+ result = prime * result + (int) (taskId ^ (taskId >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( this == obj ) return true;
+ if ( obj == null ) return false;
+ if ( !(obj instanceof ScheduledTaskDeadline) ) return false;
+ ScheduledTaskDeadline other = (ScheduledTaskDeadline) obj;
+ if ( deadlineId != other.deadlineId ) return false;
+ if ( taskId != other.taskId ) return false;
+ return true;
+ }
+
+ }
}
Modified: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/utils/CollectionUtils.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/utils/CollectionUtils.java 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/task/utils/CollectionUtils.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -26,13 +26,20 @@
import org.drools.task.OrganizationalEntity;
import org.drools.task.Reassignment;
import org.drools.task.User;
+import org.hibernate.collection.PersistentBag;
public class CollectionUtils {
public static boolean equals(List list1, List list2) {
if ( list1 == null && list2 == null ) {
+ // both are null
return true;
}
+ if ( list1 == null || list2 == null ) {
+ // we know both aren't null, so if one is null them obviously false
+ return false;
+ }
+
if ( list1.size() != list2.size() ) {
return false;
}
Copied: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/resources/org/drools/task/service/OpenOwnedTasksForUser.txt (from rev 21985, labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/service/AllOpenTasks.txt)
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/main/resources/org/drools/task/service/OpenOwnedTasksForUser.txt (rev 0)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/main/resources/org/drools/task/service/OpenOwnedTasksForUser.txt 2008-08-30 16:58:28 UTC (rev 22259)
@@ -0,0 +1,28 @@
+select
+ new org.drools.task.query.TaskSummary(
+ t.id,
+ names.text,
+ subjects.text,
+ descriptions.text,
+ t.taskData.status,
+ t.priority,
+ t.taskData.skipable,
+ t.taskData.actualOwner,
+ t.taskData.createdBy,
+ t.taskData.createdOn,
+ t.taskData.activationTime,
+ t.taskData.expirationTime)
+from
+ Task t,
+ I18NText names,
+ I18NText subjects,
+ I18NText descriptions
+where
+ t.taskData.actualOwner.id = :currentUser and
+ names in elements( t.names) and
+ names.language = :language and
+ subjects in elements( t.subjects) and
+ subjects.language = :language and
+ descriptions in elements( t.descriptions) and
+ descriptions.language = :language and
+ t.taskData.expirationTime is null
\ No newline at end of file
Property changes on: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/resources/org/drools/task/service/OpenOwnedTasksForUser.txt
___________________________________________________________________
Name: svn:mergeinfo
+
Added: labs/jbossrules/trunk/drools-process/drools-process-task/src/main/resources/org/drools/task/service/UnescalatedDeadlines.txt
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/main/resources/org/drools/task/service/UnescalatedDeadlines.txt (rev 0)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/main/resources/org/drools/task/service/UnescalatedDeadlines.txt 2008-08-30 16:58:28 UTC (rev 22259)
@@ -0,0 +1,12 @@
+select
+ t.id,
+ d.id,
+ d.date
+from
+ Task t,
+ Deadline d
+where
+ (d in elements( t.deadlines.startDeadlines ) or d in elements( t.deadlines.endDeadlines ) ) and
+ d.escalated = false
+order by
+ d.date
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/BaseTest.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/BaseTest.java 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/BaseTest.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -36,6 +36,7 @@
import org.drools.task.Task;
import org.drools.task.TaskData;
import org.drools.task.User;
+import org.drools.task.query.TaskSummary;
import org.drools.task.service.TaskService;
import org.drools.task.utils.CollectionUtils;
import org.mvel.MVEL;
@@ -60,7 +61,7 @@
protected void setUp() throws Exception {
// Use persistence.xml configuration
emf = Persistence.createEntityManagerFactory( "org.drools.task" );
- em = emf.createEntityManager(); // Retrieve an application managed entity manager
+ em = emf.createEntityManager(); // Retrieve an application managed entity manager
taskService = new TaskService( em );
@@ -129,6 +130,7 @@
context.addImport( "Status", Status.class );
context.addImport( "Task", Task.class );
context.addImport( "TaskData", TaskData.class );
+ context.addImport( "TaskSummary", TaskSummary.class );
context.addImport( "User", User.class );
return MVEL.executeExpression( compiler.compile( context ), vars );
Added: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/ModelPersistenceTest.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/ModelPersistenceTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/ModelPersistenceTest.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -0,0 +1,360 @@
+package org.drools.task;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.Serializable;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.drools.task.Attachment;
+import org.drools.task.BooleanExpression;
+import org.drools.task.Comment;
+import org.drools.task.Deadline;
+import org.drools.task.Deadlines;
+import org.drools.task.Delegation;
+import org.drools.task.Escalation;
+import org.drools.task.Group;
+import org.drools.task.I18NText;
+import org.drools.task.Notification;
+import org.drools.task.OrganizationalEntity;
+import org.drools.task.PeopleAssignments;
+import org.drools.task.Reassignment;
+import org.drools.task.Status;
+import org.drools.task.Task;
+import org.drools.task.TaskData;
+import org.drools.task.User;
+import org.drools.task.service.TaskService;
+import org.drools.task.utils.CollectionUtils;
+import org.mvel.MVEL;
+import org.mvel.ParserContext;
+import org.mvel.compiler.ExpressionCompiler;
+import org.mvel.util.MVELClassLoader;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
+
+import junit.framework.TestCase;
+
+public class ModelPersistenceTest extends BaseTest {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testfullHibernateRoundtripWithAdditionalMVELCheck() throws Exception {
+
+ Task task1 = new Task();
+ task1.setPriority( 100 );
+
+ PeopleAssignments peopleAssignments = new PeopleAssignments();
+ task1.setPeopleAssignments( peopleAssignments );
+
+ peopleAssignments.setTaskInitiator( users.get( "darth" ) );
+
+ List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>();
+ peopleAssignments.setPotentialOwners( potentialOwners );
+ potentialOwners.add( users.get( "bobba") );
+
+ potentialOwners.add( users.get( "jabba") );
+
+ List<OrganizationalEntity> excludedOwners = new ArrayList<OrganizationalEntity>();
+ peopleAssignments.setExcludedOwners( excludedOwners );
+ excludedOwners.add( users.get( "dalai" ) );
+
+ excludedOwners.add( users.get( "christoper" ) );
+
+ List<OrganizationalEntity> stakeholders = new ArrayList<OrganizationalEntity>();
+ peopleAssignments.setTaskStakeholders( stakeholders );
+ stakeholders.add( users.get( "stuart" ) );
+ stakeholders.add( users.get( "jane" ) );
+
+ List<OrganizationalEntity> businessAdmin = new ArrayList<OrganizationalEntity>();
+ peopleAssignments.setBusinessAdministrators( businessAdmin );
+ businessAdmin.add( users.get( "peter" ) );
+ businessAdmin.add( users.get( "steve" ) );
+
+ List<OrganizationalEntity> recipients = new ArrayList<OrganizationalEntity>();
+ peopleAssignments.setRecipients( recipients );
+ recipients.add( users.get( "sly" ) );
+ recipients.add( users.get( "liz" ) );
+
+ TaskData taskData = new TaskData();
+ task1.setTaskData( taskData );
+
+ taskData.setActualOwner( users.get( "liz" ) );
+ taskData.setCreatedBy( users.get( "sly" ) );
+
+ taskData.setActivationTime( new Date( 10000000 ) );
+ taskData.setCreatedOn( new Date( 10000000 ) );
+ taskData.setExpirationTime( new Date( 10000000 ) );
+ taskData.setStatus( Status.Created );
+
+ List<Attachment> attachments = new ArrayList<Attachment>();
+ taskData.setAttachments( attachments );
+
+ Attachment attachment = new Attachment();
+ attachment.setAccessType( AccessType.Inline );
+ attachment.setAttachedAt( new Date( 10000000 ) );
+ attachment.setAttachedBy( users.get( "liz" ) );
+ attachment.setContentType( "text" );
+ attachment.setName( "file.txt" );
+ attachment.setAttachment( new byte[]{1, 0, 0, 1} );
+ attachments.add( attachment );
+
+ attachment = new Attachment();
+ attachment.setAccessType( AccessType.Url );
+ attachment.setAttachedAt( new Date( 10000000 ) );
+ attachment.setAttachedBy( users.get( "liz" ) );
+ attachment.setContentType( "text" );
+ attachment.setName( "file2.txt" );
+ attachment.setAttachment( new String( "http://domain.org/file.txt" ).getBytes() );
+ attachments.add( attachment );
+
+ List<Comment> comments = new ArrayList<Comment>();
+ taskData.setComments( comments );
+ Comment comment = new Comment();
+ comment.setAddedBy( users.get( "peter" ) );
+ comment.setAddedDate( new Date( 10000000 ) );
+ comment.setText( "this is a short comment" );
+ comments.add( comment );
+
+ comment = new Comment();
+ comment.setAddedBy( users.get( "steve" ) );
+ comment.setAddedDate( new Date( 10000000 ) );
+ comment.setText( "this is a loooooooooooooooooooooooooooooooooooooooooooooooong comment" );
+ comments.add( comment );
+
+ List<I18NText> names = new ArrayList<I18NText>();
+ task1.setNames( names );
+ List<I18NText> subjects = new ArrayList<I18NText>();
+ task1.setSubjects( subjects );
+ List<I18NText> descriptions = new ArrayList<I18NText>();
+ task1.setDescriptions( descriptions );
+
+ names.add( new I18NText( "en-UK",
+ "This is my task name" ) );
+ names.add( new I18NText( "en-DK",
+ "Dies ist mein task Name" ) );
+
+ subjects.add( new I18NText( "en-UK",
+ "This is my task subject" ) );
+ subjects.add( new I18NText( "en-DK",
+ "Das ist mein task Thema" ) );
+
+ descriptions.add( new I18NText( "en-UK",
+ "This is my task description" ) );
+ descriptions.add( new I18NText( "en-DK",
+ "Das ist mein task Beschreibung" ) );
+
+ Delegation delegation = new Delegation();
+ task1.setDelegation( delegation );
+ delegation.setAllowed( Allowed.PotentialOwners );
+
+ List<OrganizationalEntity> delegates = new ArrayList<OrganizationalEntity>();
+ delegation.setDelegates( delegates );
+ delegates.add( groups.get( "crusaders" ) );
+ delegates.add( groups.get( "knightsTempler" ) );
+
+ Deadlines deadlines = new Deadlines();
+ task1.setDeadlines( deadlines );
+
+ List<Deadline> startDeadlines = new ArrayList<Deadline>();
+ deadlines.setStartDeadlines( startDeadlines );
+ Deadline deadline = new Deadline();
+ startDeadlines.add( deadline );
+ deadline.setDate( new Date( 10000000 ) );
+ List<I18NText> docs = new ArrayList<I18NText>();
+ deadline.setDocumentation( docs );
+ docs.add( new I18NText( "en-UK",
+ "Start Deadline documentation" ) );
+ docs.add( new I18NText( "en-DK",
+ "Start Termin Dokumentation" ) );
+
+ List<Escalation> escalations = new ArrayList<Escalation>();
+ deadline.setEscalations( escalations );
+ Escalation escalation = new Escalation();
+ escalations.add( escalation );
+ escalation.setName( "My Start Escalation" );
+
+ List<BooleanExpression> constraints = new ArrayList<BooleanExpression>();
+ escalation.setConstraints( constraints );
+ constraints.add( new BooleanExpression( "mvel",
+ "true" ) );
+
+ List<Notification> notifications = new ArrayList<Notification>();
+ escalation.setNotifications( notifications );
+
+ Notification notification = new Notification();
+ notifications.add( notification );
+ notification.setPriority( 1000 );
+ docs = new ArrayList<I18NText>();
+ notification.setDocumentation( docs );
+ docs.add( new I18NText( "en-UK",
+ "Start Notification documentation" ) );
+ docs.add( new I18NText( "en-DK",
+ "Start Anmeldung Dokumentation" ) );
+
+ businessAdmin = new ArrayList<OrganizationalEntity>();
+ notification.setBusinessAdministrators( businessAdmin );
+ businessAdmin.add( users.get( "bruce" ) );
+ businessAdmin.add( users.get( "peter" ) );
+
+ recipients = new ArrayList<OrganizationalEntity>();
+ notification.setRecipients( recipients );
+ recipients.add( users.get( "tony" ) );
+ recipients.add( users.get( "darth" ) );
+
+ names = new ArrayList<I18NText>();
+ notification.setNames( names );
+ subjects = new ArrayList<I18NText>();
+ notification.setSubjects( subjects );
+ descriptions = new ArrayList<I18NText>();
+ notification.setDescriptions( descriptions );
+
+ names.add( new I18NText( "en-UK",
+ "This is my start notification name" ) );
+ names.add( new I18NText( "en-DK",
+ "Dies ist mein start anmeldung Name" ) );
+
+ subjects.add( new I18NText( "en-UK", "This is my start notification subject" ) );
+ subjects.add( new I18NText( "en-DK", "Das ist mein start anmeldung Thema" ) );
+
+ descriptions.add( new I18NText( "en-UK", "This is my start notification description" ) );
+ descriptions.add( new I18NText( "en-DK", "Das ist mein start anmeldung Beschreibung" ) );
+
+ List<Reassignment> reassignments = new ArrayList<Reassignment>();
+ escalation.setReassignments( reassignments );
+ Reassignment reassignment = new Reassignment();
+ reassignments.add( reassignment );
+
+ docs = new ArrayList<I18NText>();
+ reassignment.setDocumentation( docs );
+ docs.add( new I18NText( "en-UK", "Start Reassignment documentation" ) );
+ docs.add( new I18NText( "en-DK", "Start Neuzuweisung Dokumentation" ) );
+
+ potentialOwners = new ArrayList<OrganizationalEntity>();
+ reassignment.setPotentialOwners( potentialOwners );
+ potentialOwners.add( users.get( "bobba" ) );
+ potentialOwners.add( users.get( "luke" ) );
+
+ List<Deadline> endDeadlines = new ArrayList<Deadline>();
+ deadlines.setEndDeadlines( endDeadlines );
+ deadline = new Deadline();
+ endDeadlines.add( deadline );
+ deadline.setDate( new Date( 10000000 ) );
+ docs = new ArrayList<I18NText>();
+ deadline.setDocumentation( docs );
+ docs.add( new I18NText( "en-UK",
+ "End Deadline documentation" ) );
+ docs.add( new I18NText( "en-DK",
+ "Ende Termin Dokumentation" ) );
+
+ escalations = new ArrayList<Escalation>();
+ deadline.setEscalations( escalations );
+ escalation = new Escalation();
+ escalations.add( escalation );
+ escalation.setName( "My End Escalation" );
+
+ constraints = new ArrayList<BooleanExpression>();
+ escalation.setConstraints( constraints );
+ constraints.add( new BooleanExpression( "mvel",
+ "true" ) );
+
+ notifications = new ArrayList<Notification>();
+ escalation.setNotifications( notifications );
+
+ notification = new Notification();
+ notifications.add( notification );
+ notification.setPriority( 1000 );
+ docs = new ArrayList<I18NText>();
+ notification.setDocumentation( docs );
+ docs.add( new I18NText( "en-UK",
+ "End Notification documentation" ) );
+ docs.add( new I18NText( "en-DK",
+ "Ende Anmeldung Dokumentation" ) );
+
+ businessAdmin = new ArrayList<OrganizationalEntity>();
+ notification.setBusinessAdministrators( businessAdmin );
+ businessAdmin.add( users.get( "bobba" ) );
+ businessAdmin.add( users.get( "darth" ) );
+
+ recipients = new ArrayList<OrganizationalEntity>();
+ notification.setRecipients( recipients );
+ recipients.add( users.get( "liz" ) );
+ recipients.add( users.get( "jane" ) );
+
+ names = new ArrayList<I18NText>();
+ notification.setNames( names );
+ subjects = new ArrayList<I18NText>();
+ notification.setSubjects( subjects );
+ descriptions = new ArrayList<I18NText>();
+ notification.setDescriptions( descriptions );
+
+ names.add( new I18NText( "en-UK",
+ "This is my end notification name" ) );
+ names.add( new I18NText( "en-DK",
+ "Dies ist mein ende anmeldung Name" ) );
+
+ subjects.add( new I18NText( "en-UK", "This is my end notification subject" ) );
+ subjects.add( new I18NText( "en-DK", "Das ist mein ende anmeldung Thema" ) );
+
+ descriptions.add( new I18NText( "en-UK", "This is my end notification description" ) );
+ descriptions.add( new I18NText( "en-DK", "Das ist mein ende anmeldung Beschreibung" ) );
+
+ reassignments = new ArrayList<Reassignment>();
+ escalation.setReassignments( reassignments );
+ reassignment = new Reassignment();
+ reassignments.add( reassignment );
+
+ docs = new ArrayList<I18NText>();
+ reassignment.setDocumentation( docs );
+ docs.add( new I18NText( "en-UK", "End Reassignment documentation" ) );
+ docs.add( new I18NText( "en-DK", "Ende Neuzuweisung Dokumentation" ) );
+
+ potentialOwners = new ArrayList<OrganizationalEntity>();
+ reassignment.setPotentialOwners( potentialOwners );
+ potentialOwners.add( users.get( "stuart" ) );
+ potentialOwners.add( users.get( "dalai" ) );
+
+ taskService.addTask( task1 );
+
+ em.clear();
+
+ Task task2 = taskService.getTask( task1.getId( ) );
+
+ assertNotSame( task1,
+ task2 );
+ assertEquals( task1,
+ task2 );
+
+ Reader reader = new InputStreamReader( getClass().getResourceAsStream( "FullyPopulatedTask.mvel" ) );
+ Map vars = new HashedMap();
+ vars.put( "users", users );
+ vars.put( "groups", groups );
+ vars.put( "bytes1", new byte[]{1, 0, 0, 1} );
+ Task task3= (Task) eval( reader, vars );
+
+ assertNotSame( task1,
+ task3 );
+ assertEquals( task1,
+ task3 );
+ }
+
+}
Copied: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/QueryTest.java (from rev 22239, labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/TestModelPersistence.java)
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/QueryTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/QueryTest.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -0,0 +1,161 @@
+package org.drools.task;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.Serializable;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.drools.task.Attachment;
+import org.drools.task.BooleanExpression;
+import org.drools.task.Comment;
+import org.drools.task.Deadline;
+import org.drools.task.Deadlines;
+import org.drools.task.Delegation;
+import org.drools.task.Escalation;
+import org.drools.task.Group;
+import org.drools.task.I18NText;
+import org.drools.task.Notification;
+import org.drools.task.OrganizationalEntity;
+import org.drools.task.PeopleAssignments;
+import org.drools.task.Reassignment;
+import org.drools.task.Status;
+import org.drools.task.Task;
+import org.drools.task.TaskData;
+import org.drools.task.User;
+import org.drools.task.query.TaskSummary;
+import org.drools.task.service.EscalatedDeadlineHandler;
+import org.drools.task.service.TaskService;
+import org.drools.task.utils.CollectionUtils;
+import org.mvel.MVEL;
+import org.mvel.ParserContext;
+import org.mvel.compiler.ExpressionCompiler;
+import org.mvel.util.MVELClassLoader;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
+
+import junit.framework.TestCase;
+
+public class QueryTest extends BaseTest {
+
+ public void testOpenOwnedTasksForUser() throws Exception {
+ Map vars = new HashedMap();
+ vars.put( "users",
+ users );
+ vars.put( "groups",
+ groups );
+
+ //Reader reader;
+ Reader reader = new InputStreamReader( getClass().getResourceAsStream( "OpenOwnedTasksForUser.mvel" ) );
+ List<Task> tasks = (List<Task>) eval( reader,
+ vars );
+ for ( Task task : tasks ) {
+ taskService.addTask( task );
+ }
+
+ // Test UK I18N
+ reader = new InputStreamReader( getClass().getResourceAsStream( "QueryResultsInEnglish.mvel" ) );
+ Map<String, List<TaskSummary>> expected = (Map<String, List<TaskSummary>>) eval( reader,
+ vars );
+
+ List actual = taskService.getOpenOwnedTasksForUser( users.get( "peter" ).getId(),
+ "en-UK" );
+ assertEquals( 3,
+ actual.size() );
+ assertTrue( CollectionUtils.equals( expected.get( "peter" ),
+ actual ) );
+
+ actual = taskService.getOpenOwnedTasksForUser( users.get( "steve" ).getId(),
+ "en-UK" );
+ assertEquals( 2,
+ actual.size() );
+ assertTrue( CollectionUtils.equals( expected.get( "steve" ),
+ actual ) );
+
+ actual = taskService.getOpenOwnedTasksForUser( users.get( "darth" ).getId(),
+ "en-UK" );
+ assertEquals( 1,
+ actual.size() );
+ assertTrue( CollectionUtils.equals( expected.get( "darth" ),
+ actual ) );
+
+ // Test DK I18N
+ reader = new InputStreamReader( getClass().getResourceAsStream( "QueryResultsInGerman.mvel" ) );
+ expected = (Map<String, List<TaskSummary>>) eval( reader,
+ vars );
+
+ actual = taskService.getOpenOwnedTasksForUser( users.get( "peter" ).getId(),
+ "en-DK" );
+ assertEquals( 3,
+ actual.size() );
+ assertTrue( CollectionUtils.equals( expected.get( "peter" ),
+ actual ) );
+
+ actual = taskService.getOpenOwnedTasksForUser( users.get( "steve" ).getId(),
+ "en-DK" );
+ assertEquals( 2,
+ actual.size() );
+ assertTrue( CollectionUtils.equals( expected.get( "steve" ),
+ actual ) );
+
+ actual = taskService.getOpenOwnedTasksForUser( users.get( "darth" ).getId(),
+ "en-DK" );
+ assertEquals( 1,
+ actual.size() );
+ assertTrue( CollectionUtils.equals( expected.get( "darth" ),
+ actual ) );
+ }
+
+ public void testUnescalatedDeadlines() throws Exception {
+ Map vars = new HashedMap();
+ vars.put( "users",
+ users );
+ vars.put( "groups",
+ groups );
+ long now = System.currentTimeMillis();
+ vars.put( "now",
+ now );
+
+ //Reader reader;
+ Reader reader = new InputStreamReader( getClass().getResourceAsStream( "UnescalatedDeadlines.mvel" ) );
+ List<Task> tasks = (List<Task>) eval( reader,
+ vars );
+ for ( Task task : tasks ) {
+ taskService.addTask( task );
+ }
+
+ // should be three, one is marked as escalated
+ List<Object[]> list = taskService.getUnescalatedDeadlines();
+ assertEquals( 3,
+ list.size() );
+
+ Object[] objects = list.get( 0 );
+ assertEquals( ((Date) objects[2]).getTime(),
+ now + 4000 );
+
+ objects = list.get( 1 );
+ assertEquals( ((Date) objects[2]).getTime(),
+ now + 4500 );
+
+ objects = list.get( 2 );
+ assertEquals( ((Date) objects[2]).getTime(),
+ now + 5000 );
+ }
+
+
+
+}
Property changes on: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/QueryTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/TestModelPersistence.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/TestModelPersistence.java 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/TestModelPersistence.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -1,412 +0,0 @@
-package org.drools.task;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.Serializable;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import javax.persistence.Query;
-
-import org.apache.commons.collections.map.HashedMap;
-import org.drools.task.Attachment;
-import org.drools.task.BooleanExpression;
-import org.drools.task.Comment;
-import org.drools.task.Deadline;
-import org.drools.task.Deadlines;
-import org.drools.task.Delegation;
-import org.drools.task.Escalation;
-import org.drools.task.Group;
-import org.drools.task.I18NText;
-import org.drools.task.Notification;
-import org.drools.task.OrganizationalEntity;
-import org.drools.task.PeopleAssignments;
-import org.drools.task.Reassignment;
-import org.drools.task.Status;
-import org.drools.task.Task;
-import org.drools.task.TaskData;
-import org.drools.task.User;
-import org.drools.task.service.TaskService;
-import org.drools.task.utils.CollectionUtils;
-import org.mvel.MVEL;
-import org.mvel.ParserContext;
-import org.mvel.compiler.ExpressionCompiler;
-import org.mvel.util.MVELClassLoader;
-
-import com.thoughtworks.xstream.XStream;
-import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
-
-import junit.framework.TestCase;
-
-public class TestModelPersistence extends BaseTest {
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testfullHibernateRoundtripWithAdditionalMVELCheck() throws Exception {
-
- Task task1 = new Task();
- task1.setPriority( 100 );
-
- PeopleAssignments peopleAssignments = new PeopleAssignments();
- task1.setPeopleAssignments( peopleAssignments );
-
- peopleAssignments.setTaskInitiator( users.get( "darth" ) );
-
- List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>();
- peopleAssignments.setPotentialOwners( potentialOwners );
- potentialOwners.add( users.get( "bobba") );
-
- potentialOwners.add( users.get( "jabba") );
-
- List<OrganizationalEntity> excludedOwners = new ArrayList<OrganizationalEntity>();
- peopleAssignments.setExcludedOwners( excludedOwners );
- excludedOwners.add( users.get( "dalai" ) );
-
- excludedOwners.add( users.get( "christoper" ) );
-
- List<OrganizationalEntity> stakeholders = new ArrayList<OrganizationalEntity>();
- peopleAssignments.setTaskStakeholders( stakeholders );
- stakeholders.add( users.get( "stuart" ) );
- stakeholders.add( users.get( "jane" ) );
-
- List<OrganizationalEntity> businessAdmin = new ArrayList<OrganizationalEntity>();
- peopleAssignments.setBusinessAdministrators( businessAdmin );
- businessAdmin.add( users.get( "peter" ) );
- businessAdmin.add( users.get( "steve" ) );
-
- List<OrganizationalEntity> recipients = new ArrayList<OrganizationalEntity>();
- peopleAssignments.setRecipients( recipients );
- recipients.add( users.get( "sly" ) );
- recipients.add( users.get( "liz" ) );
-
- TaskData taskData = new TaskData();
- task1.setTaskData( taskData );
-
- taskData.setActualOwner( users.get( "liz" ) );
- taskData.setCreatedBy( users.get( "sly" ) );
-
- taskData.setActivationTime( new Date( 10000000 ) );
- taskData.setCreatedOn( new Date( 10000000 ) );
- taskData.setExpirationTime( new Date( 10000000 ) );
- taskData.setStatus( Status.Created );
-
- List<Attachment> attachments = new ArrayList<Attachment>();
- taskData.setAttachments( attachments );
-
- Attachment attachment = new Attachment();
- attachment.setAccessType( AccessType.Inline );
- attachment.setAttachedAt( new Date( 10000000 ) );
- attachment.setAttachedBy( users.get( "liz" ) );
- attachment.setContentType( "text" );
- attachment.setName( "file.txt" );
- attachment.setAttachment( new byte[]{1, 0, 0, 1} );
- attachments.add( attachment );
-
- attachment = new Attachment();
- attachment.setAccessType( AccessType.Url );
- attachment.setAttachedAt( new Date( 10000000 ) );
- attachment.setAttachedBy( users.get( "liz" ) );
- attachment.setContentType( "text" );
- attachment.setName( "file2.txt" );
- attachment.setAttachment( new String( "http://domain.org/file.txt" ).getBytes() );
- attachments.add( attachment );
-
- List<Comment> comments = new ArrayList<Comment>();
- taskData.setComments( comments );
- Comment comment = new Comment();
- comment.setAddedBy( users.get( "peter" ) );
- comment.setAddedDate( new Date( 10000000 ) );
- comment.setText( "this is a short comment" );
- comments.add( comment );
-
- comment = new Comment();
- comment.setAddedBy( users.get( "steve" ) );
- comment.setAddedDate( new Date( 10000000 ) );
- comment.setText( "this is a loooooooooooooooooooooooooooooooooooooooooooooooong comment" );
- comments.add( comment );
-
- List<I18NText> names = new ArrayList<I18NText>();
- task1.setNames( names );
- List<I18NText> subjects = new ArrayList<I18NText>();
- task1.setSubjects( subjects );
- List<I18NText> descriptions = new ArrayList<I18NText>();
- task1.setDescriptions( descriptions );
-
- names.add( new I18NText( "en-UK",
- "This is my task name" ) );
- names.add( new I18NText( "en-DK",
- "Dies ist mein task Name" ) );
-
- subjects.add( new I18NText( "en-UK",
- "This is my task subject" ) );
- subjects.add( new I18NText( "en-DK",
- "Das ist mein task Thema" ) );
-
- descriptions.add( new I18NText( "en-UK",
- "This is my task description" ) );
- descriptions.add( new I18NText( "en-DK",
- "Das ist mein task Beschreibung" ) );
-
- Delegation delegation = new Delegation();
- task1.setDelegation( delegation );
- delegation.setAllowed( Allowed.PotentialOwners );
-
- List<OrganizationalEntity> delegates = new ArrayList<OrganizationalEntity>();
- delegation.setDelegates( delegates );
- delegates.add( groups.get( "crusaders" ) );
- delegates.add( groups.get( "knightsTempler" ) );
-
- Deadlines deadlines = new Deadlines();
- task1.setDeadlines( deadlines );
-
- List<Deadline> startDeadlines = new ArrayList<Deadline>();
- deadlines.setStartDeadlines( startDeadlines );
- Deadline deadline = new Deadline();
- startDeadlines.add( deadline );
- deadline.setDate( new Date( 10000000 ) );
- List<I18NText> docs = new ArrayList<I18NText>();
- deadline.setDocumentation( docs );
- docs.add( new I18NText( "en-UK",
- "Start Deadline documentation" ) );
- docs.add( new I18NText( "en-DK",
- "Start Termin Dokumentation" ) );
-
- List<Escalation> escalations = new ArrayList<Escalation>();
- deadline.setEscalations( escalations );
- Escalation escalation = new Escalation();
- escalations.add( escalation );
- escalation.setName( "My Start Escalation" );
-
- List<BooleanExpression> constraints = new ArrayList<BooleanExpression>();
- escalation.setConstraints( constraints );
- constraints.add( new BooleanExpression( "mvel",
- "true" ) );
-
- List<Notification> notifications = new ArrayList<Notification>();
- escalation.setNotifications( notifications );
-
- Notification notification = new Notification();
- notifications.add( notification );
- notification.setPriority( 1000 );
- docs = new ArrayList<I18NText>();
- notification.setDocumentation( docs );
- docs.add( new I18NText( "en-UK",
- "Start Notification documentation" ) );
- docs.add( new I18NText( "en-DK",
- "Start Anmeldung Dokumentation" ) );
-
- businessAdmin = new ArrayList<OrganizationalEntity>();
- notification.setBusinessAdministrators( businessAdmin );
- businessAdmin.add( users.get( "bruce" ) );
- businessAdmin.add( users.get( "peter" ) );
-
- recipients = new ArrayList<OrganizationalEntity>();
- notification.setRecipients( recipients );
- recipients.add( users.get( "tony" ) );
- recipients.add( users.get( "darth" ) );
-
- names = new ArrayList<I18NText>();
- notification.setNames( names );
- subjects = new ArrayList<I18NText>();
- notification.setSubjects( subjects );
- descriptions = new ArrayList<I18NText>();
- notification.setDescriptions( descriptions );
-
- names.add( new I18NText( "en-UK",
- "This is my start notification name" ) );
- names.add( new I18NText( "en-DK",
- "Dies ist mein start anmeldung Name" ) );
-
- subjects.add( new I18NText( "en-UK", "This is my start notification subject" ) );
- subjects.add( new I18NText( "en-DK", "Das ist mein start anmeldung Thema" ) );
-
- descriptions.add( new I18NText( "en-UK", "This is my start notification description" ) );
- descriptions.add( new I18NText( "en-DK", "Das ist mein start anmeldung Beschreibung" ) );
-
- List<Reassignment> reassignments = new ArrayList<Reassignment>();
- escalation.setReassignments( reassignments );
- Reassignment reassignment = new Reassignment();
- reassignments.add( reassignment );
-
- docs = new ArrayList<I18NText>();
- reassignment.setDocumentation( docs );
- docs.add( new I18NText( "en-UK", "Start Reassignment documentation" ) );
- docs.add( new I18NText( "en-DK", "Start Neuzuweisung Dokumentation" ) );
-
- potentialOwners = new ArrayList<OrganizationalEntity>();
- reassignment.setPotentialOwners( potentialOwners );
- potentialOwners.add( users.get( "bobba" ) );
- potentialOwners.add( users.get( "luke" ) );
-
- List<Deadline> endDeadlines = new ArrayList<Deadline>();
- deadlines.setEndDeadlines( endDeadlines );
- deadline = new Deadline();
- endDeadlines.add( deadline );
- deadline.setDate( new Date( 10000000 ) );
- docs = new ArrayList<I18NText>();
- deadline.setDocumentation( docs );
- docs.add( new I18NText( "en-UK",
- "End Deadline documentation" ) );
- docs.add( new I18NText( "en-DK",
- "Ende Termin Dokumentation" ) );
-
- escalations = new ArrayList<Escalation>();
- deadline.setEscalations( escalations );
- escalation = new Escalation();
- escalations.add( escalation );
- escalation.setName( "My End Escalation" );
-
- constraints = new ArrayList<BooleanExpression>();
- escalation.setConstraints( constraints );
- constraints.add( new BooleanExpression( "mvel",
- "true" ) );
-
- notifications = new ArrayList<Notification>();
- escalation.setNotifications( notifications );
-
- notification = new Notification();
- notifications.add( notification );
- notification.setPriority( 1000 );
- docs = new ArrayList<I18NText>();
- notification.setDocumentation( docs );
- docs.add( new I18NText( "en-UK",
- "End Notification documentation" ) );
- docs.add( new I18NText( "en-DK",
- "Ende Anmeldung Dokumentation" ) );
-
- businessAdmin = new ArrayList<OrganizationalEntity>();
- notification.setBusinessAdministrators( businessAdmin );
- businessAdmin.add( users.get( "bobba" ) );
- businessAdmin.add( users.get( "darth" ) );
-
- recipients = new ArrayList<OrganizationalEntity>();
- notification.setRecipients( recipients );
- recipients.add( users.get( "liz" ) );
- recipients.add( users.get( "jane" ) );
-
- names = new ArrayList<I18NText>();
- notification.setNames( names );
- subjects = new ArrayList<I18NText>();
- notification.setSubjects( subjects );
- descriptions = new ArrayList<I18NText>();
- notification.setDescriptions( descriptions );
-
- names.add( new I18NText( "en-UK",
- "This is my end notification name" ) );
- names.add( new I18NText( "en-DK",
- "Dies ist mein ende anmeldung Name" ) );
-
- subjects.add( new I18NText( "en-UK", "This is my end notification subject" ) );
- subjects.add( new I18NText( "en-DK", "Das ist mein ende anmeldung Thema" ) );
-
- descriptions.add( new I18NText( "en-UK", "This is my end notification description" ) );
- descriptions.add( new I18NText( "en-DK", "Das ist mein ende anmeldung Beschreibung" ) );
-
- reassignments = new ArrayList<Reassignment>();
- escalation.setReassignments( reassignments );
- reassignment = new Reassignment();
- reassignments.add( reassignment );
-
- docs = new ArrayList<I18NText>();
- reassignment.setDocumentation( docs );
- docs.add( new I18NText( "en-UK", "End Reassignment documentation" ) );
- docs.add( new I18NText( "en-DK", "Ende Neuzuweisung Dokumentation" ) );
-
- potentialOwners = new ArrayList<OrganizationalEntity>();
- reassignment.setPotentialOwners( potentialOwners );
- potentialOwners.add( users.get( "stuart" ) );
- potentialOwners.add( users.get( "dalai" ) );
-
- taskService.addTask( task1 );
-
- em.clear();
-
- Task task2 = taskService.getTask( task1.getId( ) );
-
- assertNotSame( task1,
- task2 );
- assertEquals( task1,
- task2 );
-
-// XStream xstream = new XStream();
-// String xml = xstream.toXML( task1 );
-//
-// System.out.println( xml );
-//
-// Task task3 = (Task) xstream.fromXML( new InputStreamReader( getClass().getResourceAsStream( "FullyPopulatedTask.xml" ) ) );
-
- Reader reader = new InputStreamReader( getClass().getResourceAsStream( "FullyPopulatedTask.mvel" ) );
- Map vars = new HashedMap();
- vars.put( "users", users );
- vars.put( "groups", groups );
- vars.put( "bytes1", new byte[]{1, 0, 0, 1} );
- Task task3= (Task) eval( reader, vars );
-
- assertNotSame( task1,
- task3 );
- assertEquals( task1,
- task3 );
- }
-
- public void testQuery() throws Exception {
- Map vars = new HashedMap();
- vars.put( "users", users );
- vars.put( "groups", groups );
-
- //Reader reader;
- Reader reader = new InputStreamReader( getClass().getResourceAsStream( "AllOpenTasksData.mvel" ) );
- List<Task> tasks = ( List<Task> ) eval( reader, vars );
- for ( Task task : tasks) {
- taskService.addTask( task );
- }
-
- // Test UK I18N
- reader = new InputStreamReader( getClass().getResourceAsStream( "QueryResultsInEnglish.mvel" ) );
- Map<String, List<TaskSummary>> expected = ( Map<String, List<TaskSummary>> ) eval( reader, vars );
-
- List actual = taskService.getAllOpenTasksForUser( users.get( "peter" ).getId(), "en-UK" );
- assertEquals( 3, actual.size() );
- assertTrue( CollectionUtils.equals( expected.get( "peter" ), actual ) );
-
- actual = taskService.getAllOpenTasksForUser( users.get( "steve" ).getId(), "en-UK" );
- assertEquals( 2, actual.size() );
- assertTrue( CollectionUtils.equals( expected.get( "steve" ), actual ) );
-
- actual = taskService.getAllOpenTasksForUser( users.get( "darth" ).getId(), "en-UK" );
- assertEquals( 1, actual.size() );
- assertTrue( CollectionUtils.equals( expected.get( "darth" ), actual ) );
-
- // Test DK I18N
- reader = new InputStreamReader( getClass().getResourceAsStream( "QueryResultsInGerman.mvel" ) );
- expected = ( Map<String, List<TaskSummary>> ) eval( reader, vars );
-
- actual = taskService.getAllOpenTasksForUser( users.get( "peter" ).getId(), "en-DK" );
- assertEquals( 3, actual.size() );
- assertTrue( CollectionUtils.equals( expected.get( "peter" ), actual ) );
-
- actual = taskService.getAllOpenTasksForUser( users.get( "steve" ).getId(), "en-DK" );
- assertEquals( 2, actual.size() );
- assertTrue( CollectionUtils.equals( expected.get( "steve" ), actual ) );
-
- actual = taskService.getAllOpenTasksForUser( users.get( "darth" ).getId(), "en-DK" );
- assertEquals( 1, actual.size() );
- assertTrue( CollectionUtils.equals( expected.get( "darth" ), actual ) );
- }
-
-}
Added: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/service/TaskServiceEscalationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/service/TaskServiceEscalationTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/service/TaskServiceEscalationTest.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -0,0 +1,168 @@
+package org.drools.task.service;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.drools.task.BaseTest;
+import org.drools.task.Deadline;
+import org.drools.task.Task;
+import org.drools.task.service.TaskServiceEscalationTest.MockEscalatedDeadlineHandler.Item;
+
+public class TaskServiceEscalationTest extends BaseTest {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testUnescalatedDeadlines() throws Exception {
+ Map vars = new HashedMap();
+ vars.put( "users",
+ users );
+ vars.put( "groups",
+ groups );
+ long now = System.currentTimeMillis();
+ vars.put( "now",
+ now );
+
+ MockEscalatedDeadlineHandler handler = new MockEscalatedDeadlineHandler();
+ taskService.setEscalatedDeadlineHandler( handler );
+
+ //Reader reader;
+ Reader reader = new InputStreamReader( getClass().getResourceAsStream( "../UnescalatedDeadlines.mvel" ) );
+ List<Task> tasks = (List<Task>) eval( reader,
+ vars );
+ for ( Task task : tasks ) {
+ taskService.addTask( task );
+ }
+
+ Thread.sleep( 4000 );
+
+ assertEquals( 3, handler.list.size() );
+
+ Item item0 = handler.list.get( 0 );
+ assertEquals( item0.getDeadline().getDate().getTime(),
+ now + 4000 );
+
+ Item item1 = handler.list.get( 1 );
+ assertEquals( item1.getDeadline().getDate().getTime(),
+ now + 4500 );
+
+ Item item2 = handler.list.get( 2 );
+ assertEquals( item2.getDeadline().getDate().getTime(),
+ now + 5000 );
+ }
+
+ public void testUnescalatedDeadlinesOnStartup() throws Exception {
+ Map vars = new HashedMap();
+ vars.put( "users",
+ users );
+ vars.put( "groups",
+ groups );
+ long now = System.currentTimeMillis();
+ vars.put( "now",
+ now );
+
+
+
+ //Reader reader;
+ Reader reader = new InputStreamReader( getClass().getResourceAsStream( "../UnescalatedDeadlines.mvel" ) );
+ List<Task> tasks = (List<Task>) eval( reader,
+ vars );
+ em.getTransaction().begin();
+ for ( Task task : tasks ) {
+ // for this one we put the task in directly;
+ em.persist( task );
+ }
+ em.getTransaction().commit();
+
+ // now create a new service, to see if it initiates from the DB correctly
+ TaskService local = new TaskService(em);
+
+ MockEscalatedDeadlineHandler handler = new MockEscalatedDeadlineHandler();
+ local.setEscalatedDeadlineHandler( handler );
+
+ Thread.sleep( 4000 );
+
+ assertEquals( 3, handler.list.size() );
+
+ Item item0 = handler.list.get( 0 );
+ assertEquals( item0.getDeadline().getDate().getTime(),
+ now + 4000 );
+
+ Item item1 = handler.list.get( 1 );
+ assertEquals( item1.getDeadline().getDate().getTime(),
+ now + 4500 );
+
+ Item item2 = handler.list.get( 2 );
+ assertEquals( item2.getDeadline().getDate().getTime(),
+ now + 5000 );
+ }
+
+ public static class MockEscalatedDeadlineHandler
+ implements
+ EscalatedDeadlineHandler {
+
+ List<Item> list = new ArrayList<Item>();
+
+ public void executeEscalatedDeadline(Task task,
+ Deadline deadline,
+ EntityManager em) {
+ list.add( new Item( task,
+ deadline,
+ em ) );
+ }
+
+ public List<Item> getList() {
+ return this.list;
+ }
+
+ public static class Item {
+ Task task;
+ Deadline deadline;
+ EntityManager em;
+
+ public Item(Task task,
+ Deadline deadline,
+ EntityManager em) {
+ this.deadline = deadline;
+ this.em = em;
+ this.task = task;
+ }
+
+ public Task getTask() {
+ return task;
+ }
+
+ public void setTask(Task task) {
+ this.task = task;
+ }
+
+ public Deadline getDeadline() {
+ return deadline;
+ }
+
+ public void setDeadline(Deadline deadline) {
+ this.deadline = deadline;
+ }
+
+ public EntityManager getEntityManager() {
+ return em;
+ }
+
+ public void setEntityManager(EntityManager em) {
+ this.em = em;
+ }
+ }
+ }
+}
Modified: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/service/TaskServiceTest.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/service/TaskServiceTest.java 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/service/TaskServiceTest.java 2008-08-30 16:58:28 UTC (rev 22259)
@@ -11,13 +11,10 @@
import org.apache.mina.transport.socket.nio.NioSocketConnector;
import org.drools.task.BaseTest;
import org.drools.task.Task;
-import org.drools.task.TaskSummary;
-import org.drools.task.TestModelPersistence;
+import org.drools.task.query.TaskSummary;
import org.drools.task.service.TaskClientHandler.AllOpenTasksForUseResponseHandler;
import org.drools.task.utils.CollectionUtils;
-import junit.framework.TestCase;
-
public class TaskServiceTest extends BaseTest {
MinaTaskServer server;
MinaTaskClient client;
@@ -48,7 +45,7 @@
vars.put( "groups", groups );
//Reader reader;
- Reader reader = new InputStreamReader( getClass().getResourceAsStream( "../AllOpenTasksData.mvel" ) );
+ Reader reader = new InputStreamReader( getClass().getResourceAsStream( "../OpenOwnedTasksForUser.mvel" ) );
List<Task> tasks = ( List<Task> ) eval( reader, vars );
for ( Task task : tasks) {
client.addTask( task );
Deleted: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/AllOpenTasksData.mvel
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/AllOpenTasksData.mvel 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/AllOpenTasksData.mvel 2008-08-30 16:58:28 UTC (rev 22259)
@@ -1,108 +0,0 @@
-format = new java.text.SimpleDateFormat( "dd/MMM/yyyy" );
-
-tasks = [
- (with ( new Task() ) {
- priority = 20,
- taskData = (with ( new TaskData() ) {
- actualOwner = users[ 'peter' ],
- createdBy = users[ 'sly' ],
- createdOn = format.parse( "15/Jan/2008" ),
- activationTime = format.parse( "20/Jan/2008" ),
- expirationTime = format.parse( "25/Jan/2008" ),
- status = Status.Created,
- }),
- names = [ new I18NText( "en-UK", "This is my task name Jan" ),
- new I18NText( "en-DK", "Dies ist mein task Name Jan" )],
- subjects = [ new I18NText( "en-UK", "This is my task subject Jan" ),
- new I18NText( "en-DK", "Das ist mein task Thema Jan" ) ],
- descriptions = [ new I18NText( "en-UK", "This is my task description Jan" ),
- new I18NText( "en-DK", "Das ist mein task Beschreibung Jan" ) ]
- }),
- (with ( new Task() ) {
- priority = 150,
- taskData = (with ( new TaskData() ) {
- actualOwner = users[ 'steve' ],
- createdBy = users[ 'tony' ],
- createdOn = format.parse( "15/Feb/2008" ),
- activationTime = format.parse( "20/Feb/2008" ),
- expirationTime = format.parse( "25/Feb/2008" ),
- status = Status.Created,
- }),
- names = [ new I18NText( "en-UK", "This is my task name Feb" ),
- new I18NText( "en-DK", "Dies ist mein task Name Feb" )],
- subjects = [ new I18NText( "en-UK", "This is my task subject Feb" ),
- new I18NText( "en-DK", "Das ist mein task Thema Feb" ) ],
- descriptions = [ new I18NText( "en-UK", "This is my task description Feb" ),
- new I18NText( "en-DK", "Das ist mein task Beschreibung Feb" ) ]
- }),
- (with ( new Task() ) {
- priority = 90,
- taskData = (with ( new TaskData() ) {
- actualOwner = users[ 'peter' ],
- createdBy = users[ 'steve' ],
- createdOn = format.parse( "15/Mar/2008" ),
- activationTime = format.parse( "20/Mar/2008" ),
- expirationTime = format.parse( "25/Mar/2008" ),
- status = Status.Created,
- }),
- names = [ new I18NText( "en-UK", "This is my task name Mar" ),
- new I18NText( "en-DK", "Dies ist mein task Name Mar" )],
- subjects = [ new I18NText( "en-UK", "This is my task subject Mar" ),
- new I18NText( "en-DK", "Das ist mein task Thema Mar" ) ],
- descriptions = [ new I18NText( "en-UK", "This is my task description Mar" ),
- new I18NText( "en-DK", "Das ist mein task Beschreibung Mar" ) ]
- }),
- (with ( new Task() ) {
- priority = 20,
- taskData = (with ( new TaskData() ) {
- actualOwner = users[ 'darth' ],
- createdBy = users[ 'bobba' ],
- createdOn = format.parse( "15/Apr/2008" ),
- activationTime = format.parse( "20/Apr/2008" ),
- expirationTime = format.parse( "25/Apr/2008" ),
- status = Status.Created,
- }),
- names = [ new I18NText( "en-UK", "This is my task name Apr" ),
- new I18NText( "en-DK", "Dies ist mein task Name Apr" )],
- subjects = [ new I18NText( "en-UK", "This is my task subject Apr" ),
- new I18NText( "en-DK", "Das ist mein task Thema Apr" ) ],
- descriptions = [ new I18NText( "en-UK", "This is my task description Apr" ),
- new I18NText( "en-DK", "Das ist mein task Beschreibung Apr" ) ]
- }),
- (with ( new Task() ) {
- priority = 20,
- taskData = (with ( new TaskData() ) {
- actualOwner = users[ 'peter' ],
- createdBy = users[ 'steve' ],
- createdOn = format.parse( "15/May/2008" ),
- activationTime = format.parse( "20/May/2008" ),
- expirationTime = format.parse( "25/May/2008" ),
- status = Status.Created,
- }),
- names = [ new I18NText( "en-UK", "This is my task name May" ),
- new I18NText( "en-DK", "Dies ist mein task Name May" )],
- subjects = [ new I18NText( "en-UK", "This is my task subject May" ),
- new I18NText( "en-DK", "Das ist mein task Thema May" ) ],
- descriptions = [ new I18NText( "en-UK", "This is my task description May" ),
- new I18NText( "en-DK", "Das ist mein task Beschreibung May" ) ]
- }),
- (with ( new Task() ) {
- priority = 15,
- taskData = (with ( new TaskData() ) {
- actualOwner = users[ 'steve' ],
- createdBy = users[ 'steve' ],
- createdOn = format.parse( "15/Jun/2008" ),
- activationTime = format.parse( "20/Jun/2008" ),
- expirationTime = format.parse( "25/Jun/2008" ),
- status = Status.Created,
- }),
- names = [ new I18NText( "en-UK", "This is my task name Jun" ),
- new I18NText( "en-DK", "Dies ist mein task Name Jun" )],
- subjects = [ new I18NText( "en-UK", "This is my task subject Jun" ),
- new I18NText( "en-DK", "Das ist mein task Thema Jun" ) ],
- descriptions = [ new I18NText( "en-UK", "This is my task description Jun" ),
- new I18NText( "en-DK", "Das ist mein task Beschreibung Jun" ) ]
- })
-]
-
-return tasks;
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/OpenOwnedTasksForUser.mvel (from rev 22239, labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/AllOpenTasksData.mvel)
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/OpenOwnedTasksForUser.mvel (rev 0)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/OpenOwnedTasksForUser.mvel 2008-08-30 16:58:28 UTC (rev 22259)
@@ -0,0 +1,102 @@
+format = new java.text.SimpleDateFormat( "dd/MMM/yyyy" );
+
+tasks = [
+ (with ( new Task() ) {
+ priority = 20,
+ taskData = (with ( new TaskData() ) {
+ actualOwner = users[ 'peter' ],
+ createdBy = users[ 'sly' ],
+ createdOn = format.parse( "15/Jan/2008" ),
+ activationTime = format.parse( "20/Jan/2008" ),
+ status = Status.Created,
+ }),
+ names = [ new I18NText( "en-UK", "This is my task name Jan" ),
+ new I18NText( "en-DK", "Dies ist mein task Name Jan" )],
+ subjects = [ new I18NText( "en-UK", "This is my task subject Jan" ),
+ new I18NText( "en-DK", "Das ist mein task Thema Jan" ) ],
+ descriptions = [ new I18NText( "en-UK", "This is my task description Jan" ),
+ new I18NText( "en-DK", "Das ist mein task Beschreibung Jan" ) ]
+ }),
+ (with ( new Task() ) {
+ priority = 150,
+ taskData = (with ( new TaskData() ) {
+ actualOwner = users[ 'steve' ],
+ createdBy = users[ 'tony' ],
+ createdOn = format.parse( "15/Feb/2008" ),
+ activationTime = format.parse( "20/Feb/2008" ),
+ status = Status.Created,
+ }),
+ names = [ new I18NText( "en-UK", "This is my task name Feb" ),
+ new I18NText( "en-DK", "Dies ist mein task Name Feb" )],
+ subjects = [ new I18NText( "en-UK", "This is my task subject Feb" ),
+ new I18NText( "en-DK", "Das ist mein task Thema Feb" ) ],
+ descriptions = [ new I18NText( "en-UK", "This is my task description Feb" ),
+ new I18NText( "en-DK", "Das ist mein task Beschreibung Feb" ) ]
+ }),
+ (with ( new Task() ) {
+ priority = 90,
+ taskData = (with ( new TaskData() ) {
+ actualOwner = users[ 'peter' ],
+ createdBy = users[ 'steve' ],
+ createdOn = format.parse( "15/Mar/2008" ),
+ activationTime = format.parse( "20/Mar/2008" ),
+ status = Status.Created,
+ }),
+ names = [ new I18NText( "en-UK", "This is my task name Mar" ),
+ new I18NText( "en-DK", "Dies ist mein task Name Mar" )],
+ subjects = [ new I18NText( "en-UK", "This is my task subject Mar" ),
+ new I18NText( "en-DK", "Das ist mein task Thema Mar" ) ],
+ descriptions = [ new I18NText( "en-UK", "This is my task description Mar" ),
+ new I18NText( "en-DK", "Das ist mein task Beschreibung Mar" ) ]
+ }),
+ (with ( new Task() ) {
+ priority = 20,
+ taskData = (with ( new TaskData() ) {
+ actualOwner = users[ 'darth' ],
+ createdBy = users[ 'bobba' ],
+ createdOn = format.parse( "15/Apr/2008" ),
+ activationTime = format.parse( "20/Apr/2008" ),
+ status = Status.Created,
+ }),
+ names = [ new I18NText( "en-UK", "This is my task name Apr" ),
+ new I18NText( "en-DK", "Dies ist mein task Name Apr" )],
+ subjects = [ new I18NText( "en-UK", "This is my task subject Apr" ),
+ new I18NText( "en-DK", "Das ist mein task Thema Apr" ) ],
+ descriptions = [ new I18NText( "en-UK", "This is my task description Apr" ),
+ new I18NText( "en-DK", "Das ist mein task Beschreibung Apr" ) ]
+ }),
+ (with ( new Task() ) {
+ priority = 20,
+ taskData = (with ( new TaskData() ) {
+ actualOwner = users[ 'peter' ],
+ createdBy = users[ 'steve' ],
+ createdOn = format.parse( "15/May/2008" ),
+ activationTime = format.parse( "20/May/2008" ),
+ status = Status.Created,
+ }),
+ names = [ new I18NText( "en-UK", "This is my task name May" ),
+ new I18NText( "en-DK", "Dies ist mein task Name May" )],
+ subjects = [ new I18NText( "en-UK", "This is my task subject May" ),
+ new I18NText( "en-DK", "Das ist mein task Thema May" ) ],
+ descriptions = [ new I18NText( "en-UK", "This is my task description May" ),
+ new I18NText( "en-DK", "Das ist mein task Beschreibung May" ) ]
+ }),
+ (with ( new Task() ) {
+ priority = 15,
+ taskData = (with ( new TaskData() ) {
+ actualOwner = users[ 'steve' ],
+ createdBy = users[ 'steve' ],
+ createdOn = format.parse( "15/Jun/2008" ),
+ activationTime = format.parse( "20/Jun/2008" ),
+ status = Status.Created,
+ }),
+ names = [ new I18NText( "en-UK", "This is my task name Jun" ),
+ new I18NText( "en-DK", "Dies ist mein task Name Jun" )],
+ subjects = [ new I18NText( "en-UK", "This is my task subject Jun" ),
+ new I18NText( "en-DK", "Das ist mein task Thema Jun" ) ],
+ descriptions = [ new I18NText( "en-UK", "This is my task description Jun" ),
+ new I18NText( "en-DK", "Das ist mein task Beschreibung Jun" ) ]
+ })
+]
+
+return tasks;
\ No newline at end of file
Property changes on: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/OpenOwnedTasksForUser.mvel
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/QueryResultsInEnglish.mvel
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/QueryResultsInEnglish.mvel 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/QueryResultsInEnglish.mvel 2008-08-30 16:58:28 UTC (rev 22259)
@@ -2,20 +2,20 @@
[ 'peter' : [ new TaskSummary( 1, 'This is my task name Jan', 'This is my task subject Jan', 'This is my task description Jan',
Status.Created, 20, false, users[ 'peter' ], users[ 'sly' ],
- format.parse( "15/Jan/2008" ), format.parse( "20/Jan/2008" ), format.parse( "25/Jan/2008" ) ),
+ format.parse( "15/Jan/2008" ), format.parse( "20/Jan/2008" ), null ),
new TaskSummary( 1, 'This is my task name May', 'This is my task subject May', 'This is my task description May',
Status.Created, 20, false, users[ 'peter' ], users[ 'steve' ],
- format.parse( "15/May/2008" ), format.parse( "20/May/2008" ), format.parse( "25/May/2008" ) ),
+ format.parse( "15/May/2008" ), format.parse( "20/May/2008" ), null ),
new TaskSummary( 1, 'This is my task name Mar', 'This is my task subject Mar', 'This is my task description Mar',
Status.Created, 90, false, users[ 'peter' ], users[ 'steve' ],
- format.parse( "15/Mar/2008" ), format.parse( "20/Mar/2008" ), format.parse( "25/Mar/2008" ) ) ],
+ format.parse( "15/Mar/2008" ), format.parse( "20/Mar/2008" ), null ) ],
'steve' : [new TaskSummary( 1, 'This is my task name Feb', 'This is my task subject Feb', 'This is my task description Feb',
Status.Created, 150, false, users[ 'steve' ], users[ 'tony' ],
- format.parse( "15/Feb/2008" ), format.parse( "20/Feb/2008" ), format.parse( "25/Feb/2008" ) ),
+ format.parse( "15/Feb/2008" ), format.parse( "20/Feb/2008" ), null ),
new TaskSummary( 1, 'This is my task name Jun', 'This is my task subject Jun', 'This is my task description Jun',
Status.Created, 15, false, users[ 'steve' ], users[ 'steve' ],
- format.parse( "15/Jun/2008" ), format.parse( "20/Jun/2008" ), format.parse( "25/Jun/2008" ) ) ]
+ format.parse( "15/Jun/2008" ), format.parse( "20/Jun/2008" ), null ) ]
'darth' : [ new TaskSummary( 1, 'This is my task name Apr', 'This is my task subject Apr', 'This is my task description Apr',
Status.Created, 20, false, users[ 'darth' ], users[ 'bobba' ],
- format.parse( "15/Apr/2008" ), format.parse( "20/Apr/2008" ), format.parse( "25/Apr/2008" ) ) ]
+ format.parse( "15/Apr/2008" ), format.parse( "20/Apr/2008" ), null ) ]
]
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/QueryResultsInGerman.mvel
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/QueryResultsInGerman.mvel 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/QueryResultsInGerman.mvel 2008-08-30 16:58:28 UTC (rev 22259)
@@ -2,20 +2,20 @@
[ 'peter' : [ new TaskSummary( 1, 'Dies ist mein task Name Jan', 'Das ist mein task Thema Jan', 'Das ist mein task Beschreibung Jan',
Status.Created, 20, false, users[ 'peter' ], users[ 'sly' ],
- format.parse( "15/Jan/2008" ), format.parse( "20/Jan/2008" ), format.parse( "25/Jan/2008" ) ),
+ format.parse( "15/Jan/2008" ), format.parse( "20/Jan/2008" ), null ),
new TaskSummary( 1, 'Dies ist mein task Name May', 'Das ist mein task Thema May', 'Das ist mein task Beschreibung May',
Status.Created, 20, false, users[ 'peter' ], users[ 'steve' ],
- format.parse( "15/May/2008" ), format.parse( "20/May/2008" ), format.parse( "25/May/2008" ) ),
+ format.parse( "15/May/2008" ), format.parse( "20/May/2008" ),null ),
new TaskSummary( 1, 'Dies ist mein task Name Mar', 'Das ist mein task Thema Mar', 'Das ist mein task Beschreibung Mar',
Status.Created, 90, false, users[ 'peter' ], users[ 'steve' ],
- format.parse( "15/Mar/2008" ), format.parse( "20/Mar/2008" ), format.parse( "25/Mar/2008" ) ) ],
+ format.parse( "15/Mar/2008" ), format.parse( "20/Mar/2008" ), null ) ],
'steve' : [ new TaskSummary( 1, 'Dies ist mein task Name Feb', 'Das ist mein task Thema Feb', 'Das ist mein task Beschreibung Feb',
Status.Created, 150, false, users[ 'steve' ], users[ 'tony' ],
- format.parse( "15/Feb/2008" ), format.parse( "20/Feb/2008" ), format.parse( "25/Feb/2008" ) ),
+ format.parse( "15/Feb/2008" ), format.parse( "20/Feb/2008" ), null ),
new TaskSummary( 1, 'Dies ist mein task Name Jun', 'Das ist mein task Thema Jun', 'Das ist mein task Beschreibung Jun',
Status.Created, 15, false, users[ 'steve' ], users[ 'steve' ],
- format.parse( "15/Jun/2008" ), format.parse( "20/Jun/2008" ), format.parse( "25/Jun/2008" ) ) ]
+ format.parse( "15/Jun/2008" ), format.parse( "20/Jun/2008" ), null ) ]
'darth' : [ new TaskSummary( 1, 'Dies ist mein task Name Apr', 'Das ist mein task Thema Apr', 'Das ist mein task Beschreibung Apr',
Status.Created, 20, false, users[ 'darth' ], users[ 'bobba' ],
- format.parse( "15/Apr/2008" ), format.parse( "20/Apr/2008" ), format.parse( "25/Apr/2008" ) ) ]
+ format.parse( "15/Apr/2008" ), format.parse( "20/Apr/2008" ), null ) ]
]
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/UnescalatedDeadlines.mvel
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/UnescalatedDeadlines.mvel (rev 0)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/UnescalatedDeadlines.mvel 2008-08-30 16:58:28 UTC (rev 22259)
@@ -0,0 +1,121 @@
+format = new java.text.SimpleDateFormat( "dd/MMM/yyyy" );
+
+tasks = [
+ (with ( new Task() ) {
+ priority = 20,
+ taskData = (with ( new TaskData() ) {
+ actualOwner = users[ 'peter' ],
+ createdBy = users[ 'sly' ],
+ createdOn = format.parse( "15/Jan/2008" ),
+ activationTime = format.parse( "20/Jan/2008" ),
+ status = Status.Created,
+ }),
+ deadlines = ( with ( new Deadlines() ) {
+ startDeadlines = [
+ (with (new Deadline()) {
+ date = new Date( now + 4000 ),
+ escalated = false,
+ escalations = [
+ (with (new Escalation()) {
+ name = "My Start Escalation",
+ constraints = [new BooleanExpression( "mvel", "true" )],
+ notifications = [
+ (with (new Notification()) {
+ recipients = [ users['tony' ], users['darth' ] ],
+ })
+ ],
+ reassignments = [
+ (with (new Reassignment()) {
+ potentialOwners = [ users['bobba' ], users['luke' ] ]
+ })
+ ]
+
+ })
+ ]
+ })
+ ],
+ endDeadlines = [
+ (with (new Deadline()) {
+ date = new Date( now + 4500 ),
+ escalated = false,
+ escalations = [
+ (with (new Escalation()) {
+ name = "My End Escalation",
+ constraints = [new BooleanExpression( "mvel", "true" )],
+ notifications = [
+ (with (new Notification()) {
+ recipients = [ users['liz' ], users['jane' ] ],
+ })
+ ],
+ reassignments = [
+ (with (new Reassignment()) {
+ potentialOwners = [ users['stuart' ], users['dalai' ] ]
+ })
+ ]
+
+ })
+ ]
+ })
+ ]
+ })
+ }),
+ (with ( new Task() ) {
+ priority = 150,
+ taskData = (with ( new TaskData() ) {
+ actualOwner = users[ 'steve' ],
+ createdBy = users[ 'tony' ],
+ createdOn = format.parse( "15/Feb/2008" ),
+ activationTime = format.parse( "20/Feb/2008" ),
+ status = Status.Created,
+ }),
+ deadlines = ( with ( new Deadlines() ) {
+ startDeadlines = [
+ (with (new Deadline()) {
+ date = new Date( now - 1000 ),
+ escalated = true,
+ escalations = [
+ (with (new Escalation()) {
+ name = "My Start Escalation",
+ constraints = [new BooleanExpression( "mvel", "true" )],
+ notifications = [
+ (with (new Notification()) {
+ recipients = [ users['tony' ], users['darth' ] ],
+ })
+ ],
+ reassignments = [
+ (with (new Reassignment()) {
+ potentialOwners = [ users['bobba' ], users['luke' ] ]
+ })
+ ]
+
+ })
+ ]
+ })
+ ],
+ endDeadlines = [
+ (with (new Deadline()) {
+ date = new Date( now + 5000 ),
+ escalations = [
+ (with (new Escalation()) {
+ name = "My End Escalation",
+ constraints = [new BooleanExpression( "mvel", "true" )],
+ notifications = [
+ (with (new Notification()) {
+ recipients = [ users['liz' ], users['jane' ] ],
+ })
+ ],
+ reassignments = [
+ (with (new Reassignment()) {
+ potentialOwners = [ users['stuart' ], users['dalai' ] ]
+ })
+ ]
+
+ })
+ ]
+ })
+ ]
+ })
+ })
+]
+
+return tasks;
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/service/AllOpenTasks.txt
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/service/AllOpenTasks.txt 2008-08-30 15:19:37 UTC (rev 22258)
+++ labs/jbossrules/trunk/drools-process/drools-process-task/src/test/resources/org/drools/task/service/AllOpenTasks.txt 2008-08-30 16:58:28 UTC (rev 22259)
@@ -1,27 +0,0 @@
-select
- new org.drools.task.TaskSummary(
- t.id,
- names.text,
- subjects.text,
- descriptions.text,
- t.taskData.status,
- t.priority,
- t.taskData.skipable,
- t.taskData.actualOwner,
- t.taskData.createdBy,
- t.taskData.createdOn,
- t.taskData.activationTime,
- t.taskData.expirationTime)
-from
- Task t,
- I18NText names,
- I18NText subjects,
- I18NText descriptions
-where
- t.taskData.actualOwner.id = :currentUser and
- names in elements( t.names) and
- names.language = :language and
- subjects in elements( t.subjects) and
- subjects.language = :language and
- descriptions in elements( t.descriptions) and
- descriptions.language = :language
\ No newline at end of file
More information about the jboss-svn-commits
mailing list