JBoss JBPM SVN: r6759 - in jbpm3/branches/jbpm-3.2-soa/core/src: test/java/org/jbpm/jbpm2787 and 1 other directory.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-10-13 01:11:34 -0400 (Wed, 13 Oct 2010)
New Revision: 6759
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2787/JBPM2787Test.java
Log:
SOA-2369 increase default job processing timeout to 90 seconds, and reset JBPM2787Test to default value
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2010-10-12 04:32:16 UTC (rev 6758)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2010-10-13 05:11:34 UTC (rev 6759)
@@ -61,7 +61,7 @@
private List processDefinitionIds;
- protected static final long JOB_TIMEOUT = 60 * 1000;
+ protected static final long JOB_TIMEOUT = 90 * 1000;
protected void setUp() throws Exception {
super.setUp();
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2787/JBPM2787Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2787/JBPM2787Test.java 2010-10-12 04:32:16 UTC (rev 6758)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2787/JBPM2787Test.java 2010-10-13 05:11:34 UTC (rev 6759)
@@ -63,7 +63,7 @@
processInstanceIds[i] = processInstance.getId();
}
- processJobs(2 * JOB_TIMEOUT);
+ processJobs();
for (int i = 0; i < INSTANCE_COUNT; i++) {
ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceIds[i]);
13 years, 6 months
JBoss JBPM SVN: r6758 - jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2787.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-10-12 00:32:16 -0400 (Tue, 12 Oct 2010)
New Revision: 6758
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2787/JBPM2787Test.java
Log:
SOA-2369 increase JBPM2787Test timeout to counter possible surge in network or database load
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2787/JBPM2787Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2787/JBPM2787Test.java 2010-10-12 01:40:26 UTC (rev 6757)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm2787/JBPM2787Test.java 2010-10-12 04:32:16 UTC (rev 6758)
@@ -63,7 +63,7 @@
processInstanceIds[i] = processInstance.getId();
}
- processJobs();
+ processJobs(2 * JOB_TIMEOUT);
for (int i = 0; i < INSTANCE_COUNT; i++) {
ProcessInstance processInstance = jbpmContext.loadProcessInstance(processInstanceIds[i]);
13 years, 7 months
JBoss JBPM SVN: r6757 - jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe and 12 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-10-11 21:40:26 -0400 (Mon, 11 Oct 2010)
New Revision: 6757
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/BusinessCalendar.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/DayPart.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/Duration.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/Holiday.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/VariableInstance.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/converter/SerializableToByteArrayConverter.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/Timer.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/calendar/BusinessCalendarTest.java
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/calendar/HolidayTest.java
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm1776/JBPM1776Test.java
jbpm3/branches/jbpm-3.2-soa/soa-distribution/build.xml
projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/config/ConfigurationLocator.java
projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/impl/UpdatesHashMap.java
projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/identity/action/DeleteMembershipActionListener.java
projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskform/ui/UITaskFormTransitionButton.java
projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskformlayout/ui/UIDataCell.java
projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskformlayout/ui/UIDataForm.java
projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskformlayout/ui/UIDataSection.java
Log:
remove static business calendar from Timer;
inline and deprecate BusinessCalendar.getCalendar
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/BusinessCalendar.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/BusinessCalendar.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/BusinessCalendar.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -24,7 +24,6 @@
import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
-import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -108,7 +107,7 @@
}
public Date findStartOfNextDay(Date date) {
- Calendar calendar = getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
@@ -126,7 +125,7 @@
}
Date findEndOfPreviousDay(Date date) {
- Calendar calendar = getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, -1);
calendar.set(Calendar.HOUR_OF_DAY, 23);
@@ -144,7 +143,7 @@
}
public Day findDay(Date date) {
- Calendar calendar = getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return getWeekDays()[calendar.get(Calendar.DAY_OF_WEEK)];
}
@@ -182,7 +181,8 @@
return findDayPart(date) != null;
}
+ /** @deprecated call {@link Calendar#getInstance()} directly */
public static Calendar getCalendar() {
- return new GregorianCalendar();
+ return Calendar.getInstance();
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/DayPart.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/DayPart.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/DayPart.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -49,7 +49,7 @@
throw new IllegalArgumentException("failed to parse day part start time: " + dayPartText);
}
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.setTime(startTime);
startHour = calendar.get(Calendar.HOUR_OF_DAY);
startMinute = calendar.get(Calendar.MINUTE);
@@ -76,7 +76,7 @@
}
public Date add(Date date, Duration duration) {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
@@ -111,7 +111,7 @@
}
public boolean isStartAfter(Date time) {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.setTime(time);
int hour = calendar.get(Calendar.HOUR_OF_DAY);
@@ -120,7 +120,7 @@
}
boolean endsBefore(Date time) {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.setTime(time);
int hour = calendar.get(Calendar.HOUR_OF_DAY);
@@ -128,7 +128,7 @@
}
public boolean includes(Date time) {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.setTime(time);
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
@@ -138,7 +138,7 @@
}
public Date getStartTime(Date time) {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.setTime(time);
calendar.set(Calendar.HOUR_OF_DAY, startHour);
calendar.set(Calendar.MINUTE, startMinute);
@@ -146,7 +146,7 @@
}
Date getEndTime(Date time) {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.setTime(time);
calendar.set(Calendar.HOUR_OF_DAY, endHour);
calendar.set(Calendar.MINUTE, endMinute);
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/Duration.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/Duration.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/Duration.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -277,7 +277,7 @@
public Date addTo(Date date) {
if (field == Calendar.MILLISECOND) return new Date(date.getTime() + amount);
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(field, (int) amount);
return calendar.getTime();
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/Holiday.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/Holiday.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/calendar/Holiday.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -84,7 +84,7 @@
}
// now set endDate to the end of the day, rather then the beginning
// take the start of the next day as the end of the endDate
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.setTime(end);
calendar.add(Calendar.DATE, 1);
endDate = calendar.getTime();
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/VariableInstance.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/VariableInstance.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/VariableInstance.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -34,8 +34,7 @@
import org.jbpm.util.ClassUtil;
/**
- * is a jbpm-internal class that serves as a base class for classes that store variable values
- * in the database.
+ * base for classes that store variable values in the database.
*/
public abstract class VariableInstance implements Serializable {
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/converter/SerializableToByteArrayConverter.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/converter/SerializableToByteArrayConverter.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/context/exe/converter/SerializableToByteArrayConverter.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -68,11 +68,11 @@
ObjectInputStream objectStream = new ObjectInputStream(memoryStream);
return objectStream.readObject();
}
- catch (IOException ex) {
- throw new JbpmException("failed to read object", ex);
+ catch (IOException e) {
+ throw new JbpmException("failed to deserialize object", e);
}
- catch (ClassNotFoundException ex) {
- throw new JbpmException("serialized object class not found", ex);
+ catch (ClassNotFoundException e) {
+ throw new JbpmException("serialized class not found", e);
}
}
@@ -94,11 +94,11 @@
};
return objectStream.readObject();
}
- catch (IOException ex) {
- throw new JbpmException("failed to read object", ex);
+ catch (IOException e) {
+ throw new JbpmException("failed to deserialize object", e);
}
- catch (ClassNotFoundException ex) {
- throw new JbpmException("serialized object class not found", ex);
+ catch (ClassNotFoundException e) {
+ throw new JbpmException("serialized class not found", e);
}
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/Timer.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/Timer.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/Timer.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -21,8 +21,6 @@
private static final long serialVersionUID = 1L;
- private static BusinessCalendar businessCalendar = new BusinessCalendar();
-
private String name;
private String repeat;
private String transitionName;
@@ -83,6 +81,7 @@
Duration interval = new Duration(repeat);
long currentTime = System.currentTimeMillis();
+ BusinessCalendar businessCalendar = new BusinessCalendar();
Date repeatDate = getDueDate();
do {
repeatDate = businessCalendar.add(repeatDate, interval);
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -121,18 +121,18 @@
taskInstance.initializeVariables();
// calculate due date
- String dueDateString;
- if (task != null && (dueDateString = task.getDueDate()) != null) {
+ String dueDateText;
+ if (task != null && (dueDateText = task.getDueDate()) != null) {
Date dueDate;
// evaluate base date expression
- if (dueDateString.startsWith("#{") || dueDateString.startsWith("${")) {
- int braceIndex = dueDateString.indexOf('}');
+ if (dueDateText.startsWith("#{") || dueDateText.startsWith("${")) {
+ int braceIndex = dueDateText.indexOf('}');
if (braceIndex == -1) {
- throw new JbpmException("invalid due date, closing brace missing: " + dueDateString);
+ throw new JbpmException("invalid due date, closing brace missing: " + dueDateText);
}
- String baseDateExpression = dueDateString.substring(0, braceIndex + 1);
+ String baseDateExpression = dueDateText.substring(0, braceIndex + 1);
Object result = JbpmExpressionEvaluator
.evaluate(baseDateExpression, executionContext);
@@ -141,21 +141,22 @@
baseDate = (Date) result;
}
else if (result instanceof Calendar) {
- baseDate = ((Calendar) result).getTime();
+ Calendar calendar = (Calendar) result;
+ baseDate = calendar.getTime();
}
else {
throw new JbpmException(baseDateExpression + " returned " + result
+ " instead of date or calendar");
}
- String durationString = dueDateString.substring(braceIndex + 1).trim();
- if (durationString.length() > 0) {
- char durationSeparator = durationString.charAt(0);
+ String durationText = dueDateText.substring(braceIndex + 1).trim();
+ if (durationText.length() > 0) {
+ char durationSeparator = durationText.charAt(0);
if (durationSeparator != '+' && durationSeparator != '-') {
throw new JbpmException("invalid due date, '+' or '-' missing after expression: "
- + dueDateString);
+ + dueDateText);
}
- dueDate = new BusinessCalendar().add(baseDate, new Duration(durationString));
+ dueDate = new BusinessCalendar().add(baseDate, new Duration(durationText));
}
else {
dueDate = baseDate;
@@ -163,8 +164,7 @@
}
// take current time as base date
else {
- dueDate = new BusinessCalendar()
- .add(Clock.getCurrentTime(), new Duration(dueDateString));
+ dueDate = new BusinessCalendar().add(Clock.getCurrentTime(), new Duration(dueDateText));
}
taskInstance.setDueDate(dueDate);
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/calendar/BusinessCalendarTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/calendar/BusinessCalendarTest.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/calendar/BusinessCalendarTest.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -31,7 +31,7 @@
static BusinessCalendar businessCalendar = new BusinessCalendar();
public void testNonBusinessSecondAddition() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 7, 10, 30, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -44,7 +44,7 @@
}
public void testNonBusinessMinuteAddition() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 7, 11, 55, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -56,7 +56,7 @@
}
public void testNonBusinessFractionalDurationAddition() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2008, Calendar.FEBRUARY, 5, 6, 30, 45);
calendar.set(Calendar.MILLISECOND, 125);
Date start = calendar.getTime();
@@ -69,7 +69,7 @@
}
public void testNonBusinessDayAddition() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.FEBRUARY, 5, 6, 30, 45);
calendar.set(Calendar.MILLISECOND, 125);
Date start = calendar.getTime();
@@ -81,7 +81,7 @@
}
public void testNonBusinessWeekAddition() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2008, Calendar.FEBRUARY, 5, 6, 30, 45);
calendar.set(Calendar.MILLISECOND, 125);
Date start = calendar.getTime();
@@ -93,7 +93,7 @@
}
public void testNonBusinessMonthAddition() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2008, Calendar.FEBRUARY, 5, 6, 30, 45);
calendar.set(Calendar.MILLISECOND, 125);
Date start = calendar.getTime();
@@ -105,7 +105,7 @@
}
public void testNonBusinessYearAddition() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2008, Calendar.FEBRUARY, 5, 6, 30, 45);
calendar.set(Calendar.MILLISECOND, 125);
Date start = calendar.getTime();
@@ -117,7 +117,7 @@
}
public void testBusinessDurationAdditionOverBusinessTime() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 7, 11, 55, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -129,7 +129,7 @@
}
public void testBusinessDurationAdditionOverLunchBreak() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 7, 11, 55, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -143,7 +143,7 @@
}
public void testBusinessDurationAdditionOverDayBreak() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 7, 16, 55, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -157,7 +157,7 @@
}
public void testBusinessDurationAdditionOverHoliday() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2010, Calendar.NOVEMBER, 10, 16, 55, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -173,7 +173,7 @@
}
public void testBusinessDurationAdditionOverWeekend() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 8, 16, 55, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -189,7 +189,7 @@
}
public void testTwoBusinessHoursOverLunch() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 7, 11, 15, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -203,7 +203,7 @@
}
public void testBusinessDurationAdditionOutsideBusinessHours() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 8, 12, 15, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -217,7 +217,7 @@
}
public void testBusinessDurationAdditionOutsideBusinessHoursOverWeekend() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 8, 12, 15, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -235,7 +235,7 @@
}
public void testBusinessFractionalDurationAddition() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.FEBRUARY, 7, 9, 30, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -252,7 +252,7 @@
}
public void testBusinessDayAddition() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.FEBRUARY, 7, 9, 30, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -264,7 +264,7 @@
}
public void testBusinessWeekAddition() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.FEBRUARY, 7, 9, 30, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -277,7 +277,7 @@
}
public void testBusinessMonthAddition() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2010, Calendar.FEBRUARY, 8, 9, 30, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -290,7 +290,7 @@
}
public void testBusinessYearAddition() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2010, Calendar.FEBRUARY, 8, 9, 30, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/calendar/HolidayTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/calendar/HolidayTest.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/calendar/HolidayTest.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -34,7 +34,7 @@
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Holiday holiday = new Holiday("21/07/2005", dateFormat, null);
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2005);
calendar.set(Calendar.MONTH, Calendar.JULY);
calendar.set(Calendar.DAY_OF_MONTH, 21);
@@ -62,7 +62,7 @@
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Holiday holiday = new Holiday("1/7/2005 - 31/8/2005", dateFormat, null);
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2005);
calendar.set(Calendar.MONTH, Calendar.JULY);
calendar.set(Calendar.DAY_OF_MONTH, 1);
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm1072/JBPM1072Test.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -21,7 +21,6 @@
*/
package org.jbpm.jbpm1072;
-import org.jbpm.JbpmConfiguration;
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.Event;
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm1776/JBPM1776Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm1776/JBPM1776Test.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm1776/JBPM1776Test.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -39,7 +39,7 @@
static BusinessCalendar businessCalendar = new BusinessCalendar();
public void testNonBusinessSecondSubtraction() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 7, 10, 30, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -52,7 +52,7 @@
}
public void testNonBusinessMinuteSubtraction() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 7, 11, 55, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -64,7 +64,7 @@
}
public void testNonBusinessFractionalDurationSubtraction() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2008, Calendar.FEBRUARY, 5, 6, 30, 45);
calendar.set(Calendar.MILLISECOND, 125);
Date start = calendar.getTime();
@@ -77,7 +77,7 @@
}
public void testNonBusinessDaySubtraction() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.FEBRUARY, 5, 6, 30, 45);
calendar.set(Calendar.MILLISECOND, 125);
Date start = calendar.getTime();
@@ -89,7 +89,7 @@
}
public void testNonBusinessWeekSubtraction() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2008, Calendar.FEBRUARY, 5, 6, 30, 45);
calendar.set(Calendar.MILLISECOND, 125);
Date start = calendar.getTime();
@@ -101,7 +101,7 @@
}
public void testNonBusinessMonthSubtraction() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2008, Calendar.FEBRUARY, 5, 6, 30, 45);
calendar.set(Calendar.MILLISECOND, 125);
Date start = calendar.getTime();
@@ -113,7 +113,7 @@
}
public void testNonBusinessYearSubtraction() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2008, Calendar.FEBRUARY, 5, 6, 30, 45);
calendar.set(Calendar.MILLISECOND, 125);
Date start = calendar.getTime();
@@ -125,7 +125,7 @@
}
public void testBusinessDurationSubtractionOverBusinessTime() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 7, 11, 55, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -137,7 +137,7 @@
}
public void testBusinessDurationSubtractionOverLunchBreak() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 7, 12, 35, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -151,7 +151,7 @@
}
public void testBusinessDurationSubtractionOverDayBreak() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 8, 9, 5, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -165,7 +165,7 @@
}
public void testBusinessDurationSubtractionOverHoliday() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2010, Calendar.NOVEMBER, 12, 9, 5, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -181,7 +181,7 @@
}
public void testBusinessDurationSubtractionOverWeekend() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 11, 9, 5, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -197,7 +197,7 @@
}
public void testTwoBusinessHoursOverLunch() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 7, 13, 45, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -211,7 +211,7 @@
}
public void testBusinessDurationSubtractionOutsideBusinessHours() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 8, 12, 15, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -225,7 +225,7 @@
}
public void testBusinessDurationSubtractionOutsideBusinessHoursOverWeekend() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.APRIL, 11, 12, 15, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -243,7 +243,7 @@
}
public void testBusinessDaySubtraction() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.FEBRUARY, 21, 9, 30, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -255,7 +255,7 @@
}
public void testBusinessWeekSubtraction() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2005, Calendar.MARCH, 14, 9, 30, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -268,7 +268,7 @@
}
public void testBusinessMonthSubtraction() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2010, Calendar.MAY, 7, 9, 30, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
@@ -281,7 +281,7 @@
}
public void testBusinessYearSubtraction() {
- Calendar calendar = BusinessCalendar.getCalendar();
+ Calendar calendar = Calendar.getInstance();
calendar.set(2011, Calendar.FEBRUARY, 9, 9, 30, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
Modified: jbpm3/branches/jbpm-3.2-soa/soa-distribution/build.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/soa-distribution/build.xml 2010-10-09 17:55:08 UTC (rev 6756)
+++ jbpm3/branches/jbpm-3.2-soa/soa-distribution/build.xml 2010-10-12 01:40:26 UTC (rev 6757)
@@ -1,4 +1,4 @@
-<project name="jBPM SOA Sub-Builder" default="default">
+<project name="jBPM SOA Sub-Builder">
<!--
!! Define convenience variables for this build file here. Avoid duplicate properties existed in dependencies!
Modified: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/config/ConfigurationLocator.java
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/config/ConfigurationLocator.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/config/ConfigurationLocator.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -75,7 +75,7 @@
this.elemName = elemName;
}
- private String getName() {
+ String getName() {
return elemName;
}
}
@@ -105,7 +105,7 @@
private static final class ElementIterable implements Iterable<Element> {
private final Element element;
- private ElementIterable(final Element element) {
+ ElementIterable(final Element element) {
this.element = element;
}
Modified: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/impl/UpdatesHashMap.java
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/impl/UpdatesHashMap.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/impl/UpdatesHashMap.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -17,9 +17,9 @@
private static final long serialVersionUID = 1L;
- private final Map<String,Object> backingMap;
- private final Set<String> updates;
- private final Set<String> deletes;
+ final Map<String,Object> backingMap;
+ final Set<String> updates;
+ final Set<String> deletes;
public UpdatesHashMap() {
backingMap = new HashMap<String, Object>();
Modified: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/identity/action/DeleteMembershipActionListener.java
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/identity/action/DeleteMembershipActionListener.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/identity/action/DeleteMembershipActionListener.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -36,7 +36,7 @@
final ELContext elContext = facesContext.getELContext();
final User user = (User) userExpression.getValue(elContext);
final long membershipId = ((Long)membershipIdExpression.getValue(elContext)).longValue();
- final Set<Membership> membershipSet = (Set<Membership>) user.getMemberships();
+ final Set<Membership> membershipSet = user.getMemberships();
final Iterator<Membership> it = membershipSet.iterator();
while (it.hasNext()) {
Membership membership = it.next();
Modified: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskform/ui/UITaskFormTransitionButton.java
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskform/ui/UITaskFormTransitionButton.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskform/ui/UITaskFormTransitionButton.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -49,11 +49,11 @@
transition = state.transition;
}
- private static final class State implements Serializable {
+ static final class State implements Serializable {
private static final long serialVersionUID = 1L;
- private Object superState;
- private String transition;
+ Object superState;
+ String transition;
}
}
Modified: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskformlayout/ui/UIDataCell.java
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskformlayout/ui/UIDataCell.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskformlayout/ui/UIDataCell.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -86,14 +86,14 @@
super.restoreState(context, state.superState);
}
- public static class State implements Serializable {
+ static class State implements Serializable {
private static final long serialVersionUID = 1L;
- private Object superState;
+ Object superState;
- private String headerClass;
- private String headerStyle;
- private String styleClass;
- private String style;
+ String headerClass;
+ String headerStyle;
+ String styleClass;
+ String style;
}
}
Modified: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskformlayout/ui/UIDataForm.java
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskformlayout/ui/UIDataForm.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskformlayout/ui/UIDataForm.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -123,18 +123,18 @@
super.restoreState(context, state.superState);
}
- public static class State implements Serializable {
+ static class State implements Serializable {
private static final long serialVersionUID = 1L;
- private Object superState;
+ Object superState;
- private int columns;
- private boolean columnsSet;
- private String headerClass;
- private String headerStyle;
- private String footerClass;
- private String footerStyle;
- private String styleClass;
- private String style;
+ int columns;
+ boolean columnsSet;
+ String headerClass;
+ String headerStyle;
+ String footerClass;
+ String footerStyle;
+ String styleClass;
+ String style;
}
}
Modified: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskformlayout/ui/UIDataSection.java
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskformlayout/ui/UIDataSection.java 2010-10-09 17:55:08 UTC (rev 6756)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/taskformlayout/ui/UIDataSection.java 2010-10-12 01:40:26 UTC (rev 6757)
@@ -108,16 +108,16 @@
super.restoreState(context, state.superState);
}
- public static class State implements Serializable {
+ static class State implements Serializable {
private static final long serialVersionUID = 1L;
- private Object superState;
+ Object superState;
- private String headerClass;
- private String headerStyle;
- private String footerClass;
- private String footerStyle;
- private String styleClass;
- private String style;
+ String headerClass;
+ String headerStyle;
+ String footerClass;
+ String footerStyle;
+ String styleClass;
+ String style;
}
}
13 years, 7 months
JBoss JBPM SVN: r6756 - jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor.
by do-not-reply@jboss.org
Author: rebody
Date: 2010-10-09 13:55:08 -0400 (Sat, 09 Oct 2010)
New Revision: 6756
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/DispatcherThread.java
Log:
JBPM-2930 don't let idle interval grow too large
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/DispatcherThread.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/DispatcherThread.java 2010-10-09 17:42:11 UTC (rev 6755)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/DispatcherThread.java 2010-10-09 17:55:08 UTC (rev 6756)
@@ -28,17 +28,17 @@
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.cmd.CommandService;
-/** this thread is responsible for acquiring jobs in the job that need to be
+/** this thread is responsible for acquiring jobs in the job that need to be
* executed and then let the JobExecutor dispatch the acquired ids to one of the
- * JobExecutorThreads in the pool. There is only one dispatcher thread per
- * JobExecutor.
- *
+ * JobExecutorThreads in the pool. There is only one dispatcher thread per
+ * JobExecutor.
+ *
* @author Tom Baeyens, Guillaume Porcher
*/
public class DispatcherThread extends Thread {
private static final Log log = Log.getLog(DispatcherThread.class.getName());
-
+
protected JobExecutor jobExecutor;
protected volatile boolean isActive = true;
protected boolean checkForNewJobs;
@@ -57,6 +57,7 @@
public void run() {
log.info("starting " + getName());
currentIdleInterval = jobExecutor.getIdleMillis();
+
try {
while (isActive) {
try {
@@ -105,7 +106,9 @@
}
// after an exception, the current idle interval is doubled to prevent
// continuous exception generation when e.g. the db is unreachable
- currentIdleInterval = currentIdleInterval * 2;
+ if (currentIdleInterval < jobExecutor.getIdleMillisMax()){
+ currentIdleInterval = currentIdleInterval * 2;
+ }
}
}
} finally {
@@ -151,7 +154,7 @@
public void deactivate() {
deactivate(false);
}
-
+
public void deactivate(boolean join) {
if (isActive) {
log.debug("deactivating "+getName());
13 years, 7 months
JBoss JBPM SVN: r6755 - in jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test: hibernatelongid and 3 other directories.
by do-not-reply@jboss.org
Author: rebody
Date: 2010-10-09 13:42:11 -0400 (Sat, 09 Oct 2010)
New Revision: 6755
Modified:
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/custom/type/jbpm.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/repocache/jbpm_alternative.cfg.xml
Log:
fix test-cfg
Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/custom/type/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/custom/type/jbpm.cfg.xml 2010-10-09 17:40:53 UTC (rev 6754)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/custom/type/jbpm.cfg.xml 2010-10-09 17:42:11 UTC (rev 6755)
@@ -85,6 +85,7 @@
<hibernate-session />
<repository-session />
<db-session />
+ <query-session />
<message-session />
<timer-session />
Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml 2010-10-09 17:40:53 UTC (rev 6754)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml 2010-10-09 17:42:11 UTC (rev 6755)
@@ -83,6 +83,7 @@
<hibernate-session />
<repository-session />
<db-session />
+ <query-session />
<message-session />
<timer-session />
Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.cfg.xml 2010-10-09 17:40:53 UTC (rev 6754)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.cfg.xml 2010-10-09 17:42:11 UTC (rev 6755)
@@ -81,6 +81,7 @@
<hibernate-session />
<db-session />
+ <query-session />
<repository-session />
<message-session />
<timer-session />
Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.cfg.xml 2010-10-09 17:40:53 UTC (rev 6754)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.cfg.xml 2010-10-09 17:42:11 UTC (rev 6755)
@@ -83,6 +83,7 @@
<hibernate-session />
<repository-session />
<db-session />
+ <query-session />
<message-session />
<timer-session />
Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/repocache/jbpm_alternative.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/repocache/jbpm_alternative.cfg.xml 2010-10-09 17:40:53 UTC (rev 6754)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/repocache/jbpm_alternative.cfg.xml 2010-10-09 17:42:11 UTC (rev 6755)
@@ -45,6 +45,7 @@
<transaction-context>
<repository-session />
<db-session />
+ <query-session />
<message-session />
<timer-session />
13 years, 7 months
JBoss JBPM SVN: r6754 - jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/processengine.
by do-not-reply@jboss.org
Author: rebody
Date: 2010-10-09 13:40:53 -0400 (Sat, 09 Oct 2010)
New Revision: 6754
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/processengine/SpringProcessEngine.java
Log:
JBPM-2927 remove hibernate package from SpringProcessEngine.
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/processengine/SpringProcessEngine.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/processengine/SpringProcessEngine.java 2010-10-09 17:16:11 UTC (rev 6753)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/processengine/SpringProcessEngine.java 2010-10-09 17:40:53 UTC (rev 6754)
@@ -21,10 +21,8 @@
*/
package org.jbpm.pvm.internal.processengine;
-import org.hibernate.cfg.Configuration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.orm.hibernate3.LocalSessionFactoryBean;
import org.jbpm.api.ProcessEngine;
import org.jbpm.internal.log.Log;
@@ -32,7 +30,6 @@
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.PvmEnvironment;
import org.jbpm.pvm.internal.env.SpringContext;
-import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
/**
* this environment factory will see only the singleton beans.
@@ -61,12 +58,6 @@
springProcessEngine.applicationContext = applicationContext;
springProcessEngine.initializeProcessEngine(configuration);
- LocalSessionFactoryBean localSessionFactoryBean = springProcessEngine.get(LocalSessionFactoryBean.class);
- Configuration hibernateConfiguration = localSessionFactoryBean.getConfiguration();
- springProcessEngine.processEngineWireContext
- .getWireDefinition()
- .addDescriptor(new ProvidedObjectDescriptor(hibernateConfiguration, true));
-
springProcessEngine.checkDb(configuration);
} else {
13 years, 7 months
JBoss JBPM SVN: r6753 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/hibernate and 1 other directories.
by do-not-reply@jboss.org
Author: rebody
Date: 2010-10-09 13:16:11 -0400 (Sat, 09 Oct 2010)
New Revision: 6753
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SqlActivity.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/QuerySession.java
Log:
JBPM-2927 remove hibernate package from HqlActivity and SqlActivity
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java 2010-10-09 12:11:46 UTC (rev 6752)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java 2010-10-09 17:16:11 UTC (rev 6753)
@@ -21,13 +21,15 @@
*/
package org.jbpm.jpdl.internal.activity;
-import org.hibernate.Query;
-import org.hibernate.Session;
+import java.util.HashMap;
+import java.util.Map;
+
import org.jbpm.api.JbpmException;
import org.jbpm.api.model.OpenExecution;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+import org.jbpm.pvm.internal.session.QuerySession;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
@@ -35,6 +37,7 @@
/**
* @author Tom Baeyens
+ * @author Huisheng Xu
*/
public class HqlActivity extends JpdlAutomaticActivity {
@@ -51,60 +54,51 @@
public void perform(OpenExecution execution) {
EnvironmentImpl environment = EnvironmentImpl.getCurrent();
- if (environment==null) {
- throw new JbpmException("no environment for jpdl activity "+HqlBinding.TAG);
+ if (environment == null) {
+ throw new JbpmException("no environment for jpdl activity " + HqlBinding.TAG);
}
- Session session = environment.get(Session.class);
- Query q = createQuery(session);
-
- if (parametersDescriptor!=null) {
- for (Descriptor valueDescriptor: parametersDescriptor.getValueDescriptors()) {
+ Map<String, Object> params = new HashMap<String, Object>();
+ if (parametersDescriptor != null) {
+ for (Descriptor valueDescriptor : parametersDescriptor.getValueDescriptors()) {
String parameterName = valueDescriptor.getName();
Object value = WireContext.create(valueDescriptor, (ScopeInstanceImpl) execution);
- applyParameter(q, parameterName, value);
+ params.put(parameterName, value);
}
}
- Object result = null;
- if (isUpdate) {
- result = q.executeUpdate();
- } else if (isResultUnique) {
- result = q.uniqueResult();
- } else {
- result = q.list();
- }
+ QuerySession querySession = environment.get(QuerySession.class);
+ Object result = querySession.execute(query,
+ this.getQueryType(),
+ params,
+ isUpdate,
+ isResultUnique);
+
execution.setVariable(resultVariableName, result);
}
- protected Query createQuery(Session session) {
- return session.createQuery(query);
- }
-
- public void applyParameter(Query q, String parameterName, Object value) {
- if (value instanceof String) {
- q.setString(parameterName, (String) value);
- } else if (value instanceof Long) {
- q.setLong(parameterName, (Long) value);
- } else {
- log.error("unknown hql parameter type: "+value.getClass().getName());
- }
- }
-
public void setQuery(String query) {
this.query = query;
}
+
public void setParametersDescriptor(ListDescriptor parametersDescriptor) {
this.parametersDescriptor = parametersDescriptor;
}
+
public void setResultUnique(boolean isResultUnique) {
this.isResultUnique = isResultUnique;
}
+
public void setResultVariableName(String resultVariableName) {
this.resultVariableName = resultVariableName;
}
+
public void setUpdate(boolean isUpdate) {
this.isUpdate = isUpdate;
}
+
+ protected String getQueryType() {
+ return "hql";
+ }
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SqlActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SqlActivity.java 2010-10-09 12:11:46 UTC (rev 6752)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SqlActivity.java 2010-10-09 17:16:11 UTC (rev 6753)
@@ -21,17 +21,15 @@
*/
package org.jbpm.jpdl.internal.activity;
-import org.hibernate.Query;
-import org.hibernate.Session;
-
/**
* @author Tom Baeyens
+ * @author Huisheng Xu
*/
public class SqlActivity extends HqlActivity {
private static final long serialVersionUID = 1L;
- protected Query createQuery(Session session) {
- return session.createSQLQuery(query);
+ protected String getQueryType() {
+ return "sql";
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java 2010-10-09 12:11:46 UTC (rev 6752)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java 2010-10-09 17:16:11 UTC (rev 6753)
@@ -31,6 +31,7 @@
import org.hibernate.Query;
import org.hibernate.Session;
+import org.jbpm.api.JbpmException;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.QueryOperator;
import org.jbpm.api.identity.Group;
@@ -695,4 +696,32 @@
String objectName = (String)propertyMap.get("objectName");
return (ProcessDefinitionImpl) repositorySession.getObject(deploymentId, objectName);
}
+
+ // ~ ======================================================================
+
+ public Object execute(String queryString,
+ String queryType,
+ Map<String, Object> params,
+ boolean isUpdate,
+ boolean isUnique) {
+ Query query = null;
+
+ if ("sql".equalsIgnoreCase(queryType)) {
+ query = session.createSQLQuery(queryString);
+ } else if ("hql".equalsIgnoreCase(queryType)) {
+ query = session.createQuery(queryString);
+ } else {
+ throw new JbpmException("Unsupported query type : " + queryString);
+ }
+
+ query.setProperties(params);
+
+ if (isUpdate) {
+ return query.executeUpdate();
+ } else if (isUnique) {
+ return query.uniqueResult();
+ } else {
+ return query.list();
+ }
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/QuerySession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/QuerySession.java 2010-10-09 12:11:46 UTC (rev 6752)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/QuerySession.java 2010-10-09 17:16:11 UTC (rev 6753)
@@ -21,6 +21,7 @@
*/
package org.jbpm.pvm.internal.session;
+import java.util.Map;
import org.jbpm.pvm.internal.query.QueryProperty;
/**
@@ -30,4 +31,6 @@
*/
public interface QuerySession {
Object query(QueryProperty queryProperty);
+
+ Object execute(String queryString, String queryType, Map<String, Object> params, boolean isUpdate, boolean isUnique);
}
13 years, 7 months
JBoss JBPM SVN: r6752 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/hibernate and 2 other directories.
by do-not-reply@jboss.org
Author: rebody
Date: 2010-10-09 08:11:46 -0400 (Sat, 09 Oct 2010)
New Revision: 6752
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/ProcessInstanceQueryTest.java
Log:
JBPM-2688 support query processDefinitionKey in ProcessInstanceQuery
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java 2010-10-09 10:16:53 UTC (rev 6751)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java 2010-10-09 12:11:46 UTC (rev 6752)
@@ -29,38 +29,44 @@
/** query for ongoing {@linkplain ProcessInstance process instances}
* exclusively. refer to {@link HistoryProcessInstanceQuery} for
* queries that include finished process instances.
- *
+ *
* @author Tom Baeyens
*/
public interface ProcessInstanceQuery {
-
+
/** key property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
String PROPERTY_KEY = "key";
-
+
/** select only process instances for the given process definition */
ProcessInstanceQuery processDefinitionId(String processDefinitionId);
+ /** select only process instances for the given key of process definition. */
+ ProcessInstanceQuery processDefinitionKey(String processDefinitionKey);
+
/** select only a specific process instances using the process instance id */
ProcessInstanceQuery processInstanceId(String processInstanceId);
-
+
/** select only specific process instances using a business key */
ProcessInstanceQuery processInstanceKey(String processInstanceKey);
-
+
/** select only process instances that were started be given user */
ProcessInstanceQuery initiator(String userId);
-
+
/** select only process instances for the given process definition, allows to specify query operand */
ProcessInstanceQuery processDefinitionId(QueryOperator operator, String... processDefinitionId);
+ /** select only process instances for the given process definition, allows to specify query operand */
+ ProcessInstanceQuery processDefinitionKey(QueryOperator operator, String... processDefinitionKey);
+
/** select only a specific process instances using the process instance id, allows to specify query operand */
ProcessInstanceQuery processInstanceId(QueryOperator operator, String... processInstanceId);
-
+
/** select only specific process instances using a business key, allows to specify query operand */
ProcessInstanceQuery processInstanceKey(QueryOperator operator, String... processInstanceKey);
/** select only process instances that were started be given user, allows to specify query operand */
ProcessInstanceQuery initiator(QueryOperator operator, String... userId);
-
+
/** select only suspended process definitions */
ProcessInstanceQuery suspended();
@@ -81,8 +87,8 @@
/** execute the query and obtain the unique {@link ProcessInstance} */
ProcessInstance uniqueResult();
-
- /** execute a count(*) query and returns number of results */
+
+ /** execute a count(*) query and returns number of results */
long count();
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java 2010-10-09 10:16:53 UTC (rev 6751)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java 2010-10-09 12:11:46 UTC (rev 6752)
@@ -71,11 +71,12 @@
public Object query(QueryProperty queryProperty) {
if (DeploymentImpl.class.getName().equals(queryProperty.getKey())
- || ExecutionImpl.class.getName().equals(queryProperty.getKey())
|| JobImpl.class.getName().equals(queryProperty.getKey())
|| MessageImpl.class.getName().equals(queryProperty.getKey())
|| TimerImpl.class.getName().equals(queryProperty.getKey())) {
return queryDefault(queryProperty);
+ } else if (ExecutionImpl.class.getName().equals(queryProperty.getKey())) {
+ return queryProcessInstance(queryProperty);
} else if (TaskImpl.class.getName().equals(queryProperty.getKey())) {
return queryTask(queryProperty);
} else if (ProcessDefinitionImpl.class.getName().equals(queryProperty.getKey())) {
@@ -117,6 +118,60 @@
return executeQuery(buff.toString(), params, queryProperty);
}
+ // ~ ======================================================================
+
+ protected Object queryProcessInstance(QueryProperty queryProperty) {
+ StringBuilder buff = new StringBuilder();
+ String key = queryProperty.getKey();
+
+ // select, from
+ if (queryProperty.getResultType() == QueryProperty.RESULT_TYPE_COUNT) {
+ buff.append("select count(distinct e) from ")
+ .append(key)
+ .append(" e");
+ } else {
+ buff.append("select distinct e from ")
+ .append(key)
+ .append(" e");
+ }
+
+ // where
+ Map params = new HashMap();
+ boolean isAlreadyAddWhere = false;
+ if (queryProperty.hasCondition("processDefinitionKey")) {
+ QueryCondition condition = queryProperty.getCondition("processDefinitionKey");
+ Object processDefinitionKey = condition.getValue();
+ buff.append(", ")
+ .append(DeploymentProperty.class.getName())
+ .append(" as idProperty, ")
+ .append(DeploymentProperty.class.getName())
+ .append(" as keyProperty ")
+ .append(" where idProperty.objectName = keyProperty.objectName ")
+ .append(" and idProperty.deployment = keyProperty.deployment ")
+ .append(" and idProperty.stringValue = e.processDefinitionId ")
+ .append(" and keyProperty.stringValue ")
+ .append(condition.getOperator());
+ if (condition.getOperator() == QueryOperator.IN || condition.getOperator() == QueryOperator.NOT_IN) {
+ buff.append(" (:processDefinitionKey) ");
+ } else {
+ buff.append(" :processDefinitionKey ");
+ }
+
+ params.put("processDefinitionKey", processDefinitionKey);
+
+ isAlreadyAddWhere = true;
+ queryProperty.removeCondition("processDefinitionKey");
+ }
+ this.appendWhereClause(buff, queryProperty, params, isAlreadyAddWhere);
+
+ // order by
+ this.appendOrderClause(buff, queryProperty);
+
+ return this.executeQuery(buff.toString(), params, queryProperty);
+ }
+
+ // ~ ======================================================================
+
protected Object queryTask(QueryProperty queryProperty) {
if (queryProperty.hasCondition("candidate")) {
return queryTaskWithParticipant(queryProperty);
@@ -228,6 +283,8 @@
return this.executeQuery(buff.toString(), params, queryProperty);
}
+ // ~ ======================================================================
+
protected Object queryProcessDefinition(QueryProperty queryProperty) {
StringBuilder buff = new StringBuilder();
@@ -290,6 +347,8 @@
}
}
+ // ~ ======================================================================
+
protected Object queryHistoryActivityInstance(QueryProperty queryProperty) {
StringBuilder buff = new StringBuilder();
String key = queryProperty.getKey();
@@ -363,6 +422,8 @@
return this.executeQuery(buff.toString(), params, queryProperty);
}
+ // ~ ======================================================================
+
protected Object queryHistoryDetail(QueryProperty queryProperty) {
StringBuilder buff = new StringBuilder();
String key = queryProperty.getKey();
@@ -412,6 +473,8 @@
return this.executeQuery(buff.toString(), params, queryProperty);
}
+ // ~ ======================================================================
+
protected Object queryHistoryProcessInstance(QueryProperty queryProperty) {
StringBuilder buff = new StringBuilder();
String key = queryProperty.getKey();
@@ -461,6 +524,8 @@
return this.executeQuery(buff.toString(), params, queryProperty);
}
+ // ~ ======================================================================
+
protected Object queryHistoryTask(QueryProperty queryProperty) {
StringBuilder buff = new StringBuilder();
String key = queryProperty.getKey();
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java 2010-10-09 10:16:53 UTC (rev 6751)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java 2010-10-09 12:11:46 UTC (rev 6752)
@@ -57,6 +57,7 @@
private static final long serialVersionUID = 1L;
protected String[] processDefinitionId;
+ protected String[] processDefinitionKey;
protected String[] processInstanceId;
protected String[] processInstanceKey;
protected Boolean suspended;
@@ -73,12 +74,12 @@
}
public ProcessInstanceQuery orderAsc(String property) {
- orders.put(property, "asc");
+ orders.put("e." + property, "asc");
return this;
}
public ProcessInstanceQuery orderDesc(String property) {
- orders.put(property, "desc");
+ orders.put("e." + property, "desc");
return this;
}
@@ -97,6 +98,11 @@
return this;
}
+ public ProcessInstanceQuery processDefinitionKey(String processDefinitionKey) {
+ this.processDefinitionKey = new String[] { processDefinitionKey };
+ return this;
+ }
+
public ProcessInstanceQuery suspended() {
this.suspended = true;
return this;
@@ -128,6 +134,12 @@
return this;
}
+ public ProcessInstanceQuery processDefinitionKey(QueryOperator operator, String... processDefinitionKey) {
+ this.processDefinitionKey = processDefinitionKey;
+ parameterOperators.put("processDefinitionKey", operator);
+ return this;
+ }
+
public ProcessInstanceQuery processInstanceId(QueryOperator operator, String... processInstanceId) {
this.processInstanceId = processInstanceId;
parameterOperators.put("processInstanceId", operator);
@@ -172,30 +184,34 @@
}
// conditions
- queryProperty.addCondition("parent", null, QueryOperator.IS_NULL);
+ queryProperty.addCondition("e.parent", null, QueryOperator.IS_NULL);
if (suspended != null) {
if (suspended.equals(Boolean.TRUE)) {
- queryProperty.addCondition("state", ExecutionImpl.STATE_SUSPENDED, QueryOperator.EQUALS);
+ queryProperty.addCondition("e.state", ExecutionImpl.STATE_SUSPENDED, QueryOperator.EQUALS);
} else {
- queryProperty.addCondition("state", ExecutionImpl.STATE_SUSPENDED, QueryOperator.NOT_EQUALS);
+ queryProperty.addCondition("e.state", ExecutionImpl.STATE_SUSPENDED, QueryOperator.NOT_EQUALS);
}
}
if (processInstanceId != null) {
- queryProperty.addCondition("id", processInstanceId, findOperator("processInstanceId"));
+ queryProperty.addCondition("e.id", processInstanceId, findOperator("processInstanceId"));
}
if (processDefinitionId != null) {
- queryProperty.addCondition("processDefinitionId", processDefinitionId, findOperator("processDefinitionId"));
+ queryProperty.addCondition("e.processDefinitionId", processDefinitionId, findOperator("processDefinitionId"));
}
+ if (processDefinitionKey != null) {
+ queryProperty.addCondition("processDefinitionKey", processDefinitionKey, findOperator("processDefinitionKey"));
+ }
+
if (processInstanceKey != null) {
- queryProperty.addCondition("key", processInstanceKey, findOperator("processInstanceKey"));
+ queryProperty.addCondition("e.key", processInstanceKey, findOperator("processInstanceKey"));
}
if (initiator != null) {
- queryProperty.addCondition("initiator", initiator, findOperator("initiator"));
+ queryProperty.addCondition("e.initiator", initiator, findOperator("initiator"));
}
// orders
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/ProcessInstanceQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/ProcessInstanceQueryTest.java 2010-10-09 10:16:53 UTC (rev 6751)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/ProcessInstanceQueryTest.java 2010-10-09 12:11:46 UTC (rev 6752)
@@ -123,6 +123,26 @@
assertEquals(6, processInstances.size());
}
+ public void testQueryByProcessDefinitionKey() {
+ startTestProcesses(10, 6);
+
+ //ProcessDefinition definitionProcess1 =
+ // repositoryService.createProcessDefinitionQuery().processDefinitionKey(TEST_PROCESS_1_KEY).uniqueResult();
+ //ProcessDefinition definitionProcess2 =
+ // repositoryService.createProcessDefinitionQuery().processDefinitionKey(TEST_PROCESS_2_KEY).uniqueResult();
+
+
+ List<ProcessInstance> processInstances = executionService.createProcessInstanceQuery()
+ .processDefinitionKey(TEST_PROCESS_1_KEY)
+ .list();
+ assertEquals(10, processInstances.size());
+
+ processInstances = executionService.createProcessInstanceQuery()
+ .processDefinitionKey(TEST_PROCESS_2_KEY)
+ .list();
+ assertEquals(6, processInstances.size());
+ }
+
public void testQueryBySuspended() {
startTestProcesses(6, 0); // Don't start any instance of test process 2
13 years, 7 months
JBoss JBPM SVN: r6751 - in jbpm4/trunk/modules/pvm/src: main/java/org/jbpm/pvm/internal/hibernate and 23 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-10-09 06:16:53 -0400 (Sat, 09 Oct 2010)
New Revision: 6751
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetHistoryVariableNamesCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskSkip.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableCreate.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableUpdate.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryVariableImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableOutDefinitionSet.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/EnvironmentBindings.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/QuerySession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CharacterDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextRefDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DoubleDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FloatDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IntegerDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JobExecutorDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/LongDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/MapDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/NullDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/AbstractOperation.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/FieldOperation.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/cal/BusinessCalendarTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/el/ExpressionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/UelExpressionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronExpression.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronTrigger.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/svc/RetryInterceptorTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/binding/TransactionBindingTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java
Log:
address unused imports, unneeded casts and raw type references
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -51,7 +51,7 @@
DbSession dbSession = environment.get(DbSession.class);
if (taskId != null) {
- TaskImpl task = (TaskImpl) dbSession.get(TaskImpl.class, Long.parseLong(taskId));
+ TaskImpl task = dbSession.get(TaskImpl.class, Long.parseLong(taskId));
if (task == null) {
throw new JbpmException("task " + taskId + " was not found");
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CheckDbCmd.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -27,7 +27,6 @@
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.id.PropertyImpl;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.processengine.ProcessEngineImpl;
import org.jbpm.pvm.internal.session.DbSession;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -85,7 +85,7 @@
}
}
- DeploymentImpl deployment = (DeploymentImpl) dbSession.get(DeploymentImpl.class, Long.parseLong(deploymentId));
+ DeploymentImpl deployment = dbSession.get(DeploymentImpl.class, Long.parseLong(deploymentId));
if (log.isDebugEnabled()) {
log.debug("deleting deployment " + deploymentId);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetHistoryVariableNamesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetHistoryVariableNamesCmd.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetHistoryVariableNamesCmd.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,26 +21,20 @@
*/
package org.jbpm.pvm.internal.cmd;
-import java.util.HashSet;
import java.util.Set;
import org.jbpm.api.cmd.Command;
import org.jbpm.api.cmd.Environment;
-import org.jbpm.pvm.internal.history.model.HistoryVariableImpl;
import org.jbpm.pvm.internal.session.DbSession;
/**
- * Command responsible for retrieving variable names stored as history records for given process instance id
- *
- *
+ * Command responsible for retrieving variable names stored as history records for given process
+ * instance id.
+ *
* @author Maciej Swiderski
- *
*/
public class GetHistoryVariableNamesCmd implements Command<Set<String>> {
- /**
- *
- */
private static final long serialVersionUID = 1L;
private String processInstanceId;
@@ -49,7 +43,6 @@
this.processInstanceId = processInstanceId;
}
- @SuppressWarnings("unchecked")
public Set<String> execute(Environment environment) throws Exception {
DbSession dbSession = environment.get(DbSession.class);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipantsCmd.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -27,8 +27,6 @@
import org.jbpm.api.cmd.Environment;
import org.jbpm.api.task.Participation;
import org.jbpm.pvm.internal.session.DbSession;
-import org.jbpm.pvm.internal.task.ParticipationImpl;
-import org.jbpm.pvm.internal.util.CollectionUtil;
/**
* @author Tom Baeyens
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetSubTasksCmd.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -26,8 +26,6 @@
import org.jbpm.api.cmd.Environment;
import org.jbpm.api.task.Task;
import org.jbpm.pvm.internal.session.DbSession;
-import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.pvm.internal.util.CollectionUtil;
/**
* @author Tom Baeyens
@@ -36,7 +34,7 @@
private static final long serialVersionUID = 1L;
- String parentTaskId;
+ private String parentTaskId;
public GetSubTasksCmd(String parentTaskId) {
this.parentTaskId = parentTaskId;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -56,7 +56,7 @@
DbSession dbSession = environment.get(DbSession.class);
if (taskDbid != null) {
- TaskImpl task = (TaskImpl) dbSession.get(TaskImpl.class, taskDbid);
+ TaskImpl task = dbSession.get(TaskImpl.class, taskDbid);
if (task == null) {
throw new JbpmException("task " + taskDbid + " was not found");
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -32,24 +32,24 @@
import org.hibernate.Criteria;
import org.hibernate.LockMode;
-import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hibernate.metadata.ClassMetadata;
import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
-import org.jbpm.api.job.Timer;
import org.jbpm.api.history.HistoryComment;
+import org.jbpm.api.job.Timer;
import org.jbpm.api.task.Participation;
import org.jbpm.api.task.Task;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.client.ClientExecution;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
-import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
+import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
import org.jbpm.pvm.internal.history.model.HistoryVariableImpl;
@@ -59,9 +59,9 @@
import org.jbpm.pvm.internal.identity.impl.MembershipImpl;
import org.jbpm.pvm.internal.identity.impl.UserImpl;
import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.lob.Lob;
import org.jbpm.pvm.internal.job.StartProcessTimer;
import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.pvm.internal.lob.Lob;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.processengine.ProcessEngineImpl;
import org.jbpm.pvm.internal.query.DeploymentQueryImpl;
@@ -513,23 +513,21 @@
public void initializeSchemaVersion() {
- PropertyImpl property = (PropertyImpl) session.createQuery(
- "select property " +
- "from " + PropertyImpl.class.getName() + " as property " +
- "where property.key = '" + PropertyImpl.DB_VERSION_KEY + "'"
- ).uniqueResult();
+ PropertyImpl property = (PropertyImpl) session.createCriteria(PropertyImpl.class)
+ .add(Restrictions.eq("key", PropertyImpl.DB_VERSION_KEY))
+ .uniqueResult();
if (log.isDebugEnabled()) {
- log.debug("version of jbpm library: " + ProcessEngineImpl.JBPM_LIBRARY_VERSION);
+ log.debug("jbpm library version: " + ProcessEngineImpl.JBPM_LIBRARY_VERSION);
}
if (property == null) {
- log.info("version of jbpm db schema: none");
-
- } else {
+ log.info("jbpm db schema version: none");
+ }
+ else {
String dbSchemaVersion = property.getValue();
if (log.isDebugEnabled()) {
- log.debug("version of jbpm db schema: " + dbSchemaVersion);
+ log.debug("jbpm db schema version: " + dbSchemaVersion);
}
if (!ProcessEngineImpl.JBPM_LIBRARY_VERSION.equals(dbSchemaVersion)) {
throw new JbpmException("jBPM runtime version " + ProcessEngineImpl.JBPM_LIBRARY_VERSION
@@ -540,12 +538,11 @@
/** query. */
public Set<String> findHistoryVariableNames(String processInstanceId) {
- String hql = "select hv.variableName from " + HistoryVariableImpl.class.getName() + " hv where hv.processInstanceId = '" + processInstanceId + "'";
-
- Query query = session.createQuery(hql);
- Set<String> historyVariables = new HashSet<String>(query.list());
-
- return historyVariables;
+ List<?> variableNames = session.createCriteria(HistoryVariableImpl.class)
+ .add(Restrictions.eq("processInstanceId", processInstanceId))
+ .setProjection(Projections.property("variableName"))
+ .list();
+ return new HashSet<String>(CollectionUtil.checkList(variableNames, String.class));
}
public List<Participation> findParticipants(String taskId, String swimlaneId) {
@@ -556,7 +553,7 @@
} else if (swimlaneId != null) {
criteria.add(Restrictions.eq("swimlane.dbid", Long.parseLong(swimlaneId)));
} else {
- throw new JbpmException("no task nor swimlane specified");
+ throw new JbpmException("neither task nor swimlane specified");
}
List<?> participations = criteria.list();
@@ -573,42 +570,35 @@
// repository
public List<ExecutionImpl> findExecutionsForSupend(Set<String> processDefinitionIds) {
- Query query = session.createQuery(
- "select execution " +
- "from " + ExecutionImpl.class.getName() + " as execution " +
- "where execution.processDefinitionId in (:processDefinitionIds) " +
- " and execution.state != '" + ExecutionImpl.STATE_SUSPENDED + "'"
- );
- query.setParameterList("processDefinitionIds", processDefinitionIds);
- return query.list();
+ List<?> executions = session.createCriteria(ExecutionImpl.class)
+ .add(Restrictions.in("processDefinitionId", processDefinitionIds))
+ .add(Restrictions.ne("state", ExecutionImpl.STATE_SUSPENDED))
+ .list();
+ return CollectionUtil.checkList(executions, ExecutionImpl.class);
}
public List<ExecutionImpl> findExecutionsForResume(Set<String> processDefinitionIds) {
- Query query = session.createQuery(
- "select execution " +
- "from " + ExecutionImpl.class.getName() + " as execution " +
- "where execution.processDefinitionId in (:processDefinitionIds) " +
- " and execution.state = '" + ExecutionImpl.STATE_SUSPENDED + "'"
- );
- query.setParameterList("processDefinitionIds", processDefinitionIds);
- return query.list();
+ List<?> executions = session.createCriteria(ExecutionImpl.class)
+ .add(Restrictions.in("processDefinitionId", processDefinitionIds))
+ .add(Restrictions.eq("state", ExecutionImpl.STATE_SUSPENDED))
+ .list();
+ return CollectionUtil.checkList(executions, ExecutionImpl.class);
}
- public DeploymentProperty findDeploymentPropertyByProcessDefinitionId(String processDefinitionId) {
- DeploymentProperty deploymentProperty = (DeploymentProperty) session.createQuery(
- "select deploymentProperty " +
- "from " + DeploymentProperty.class.getName() + " as deploymentProperty " +
- "where deploymentProperty.key = '" + DeploymentImpl.KEY_PROCESS_DEFINITION_ID + "' " +
- " and deploymentProperty.stringValue = '" + processDefinitionId + "' "
- ).setMaxResults(1).uniqueResult();
- return deploymentProperty;
+ public DeploymentProperty findDeploymentPropertyByProcessDefinitionId(
+ String processDefinitionId) {
+ return (DeploymentProperty) session.createCriteria(DeploymentProperty.class)
+ .add(Restrictions.eq("key", DeploymentImpl.KEY_PROCESS_DEFINITION_ID))
+ .add(Restrictions.eq("stringValue", processDefinitionId))
+ .setMaxResults(1)
+ .uniqueResult();
}
public List<Long> findDeploymentDbids() {
- return session.createQuery("select dbid from " +
- DeploymentImpl.class.getName() + " as deployment ")
- .setReadOnly(true)
- .list();
+ List<?> deploymentIds = session.createCriteria(DeploymentImpl.class)
+ .setProjection(Projections.property("dbid"))
+ .list();
+ return CollectionUtil.checkList(deploymentIds, Long.class);
}
// query
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/QuerySessionImpl.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -28,7 +28,9 @@
import java.util.List;
import java.util.Map;
-import org.jbpm.api.Deployment;
+import org.hibernate.Query;
+import org.hibernate.Session;
+
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.QueryOperator;
import org.jbpm.api.identity.Group;
@@ -48,16 +50,14 @@
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
import org.jbpm.pvm.internal.query.QueryCondition;
import org.jbpm.pvm.internal.query.QueryProperty;
-import org.jbpm.pvm.internal.session.QuerySession;
-import org.jbpm.pvm.internal.session.RepositorySession;
import org.jbpm.pvm.internal.repository.DeploymentImpl;
import org.jbpm.pvm.internal.repository.DeploymentProperty;
-import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.session.QuerySession;
+import org.jbpm.pvm.internal.session.RepositorySession;
import org.jbpm.pvm.internal.task.ParticipationImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.util.CollectionUtil;
-import org.hibernate.Session;
-import org.hibernate.Query;
-
/**
* query session implementation for hibernate.
*
@@ -108,13 +108,13 @@
}
// where
- Map params = new HashMap();
- this.appendWhereClause(buff, queryProperty, params, false);
+ Map<String, Object> params = new HashMap<String, Object>();
+ appendWhereClause(buff, queryProperty, params, false);
// order by
- this.appendOrderClause(buff, queryProperty);
+ appendOrderClause(buff, queryProperty);
- return this.executeQuery(buff.toString(), params, queryProperty);
+ return executeQuery(buff.toString(), params, queryProperty);
}
protected Object queryTask(QueryProperty queryProperty) {
@@ -149,7 +149,7 @@
log.debug("setting parameter candidateUserId: " + candidate);
}
- Map params = new HashMap();
+ Map<String, Object> params = new HashMap<String, Object>();
if (groups.isEmpty()) {
buff.append(" and participant.userId = :candidateUserId ");
@@ -187,7 +187,7 @@
return result;
}
- List<Long> taskIds = (List<Long>) result;
+ List<Long> taskIds = CollectionUtil.checkList((List<?>) result, Long.class);
if (taskIds.isEmpty()) {
return Collections.EMPTY_LIST;
}
@@ -219,7 +219,7 @@
.append(" as task ");
}
- Map params = new HashMap();
+ Map<String, Object> params = new HashMap<String, Object>();
this.appendWhereClause(buff, queryProperty, params, false);
// order by
@@ -254,7 +254,7 @@
.append("and versionProperty.objectName = idProperty.objectName ")
.append("and versionProperty.deployment = deployment ");
- Map params = new HashMap();
+ Map<String, Object> params = new HashMap<String, Object>();
this.appendWhereClause(buff, queryProperty, params, true);
// order by
@@ -263,33 +263,27 @@
String hql = buff.toString();
log.debug(hql);
- RepositorySession repositorySession = EnvironmentImpl.getFromCurrent(RepositorySession.class);
-
Query query = session.createQuery(hql).setProperties(params);
-
if (queryProperty.getResultType() == QueryProperty.RESULT_TYPE_PAGE_UNIQUE
|| queryProperty.getResultType() == QueryProperty.RESULT_TYPE_PAGE_COUNT) {
query.setFirstResult(queryProperty.getFirstResult())
.setMaxResults(queryProperty.getMaxResults());
}
+ RepositorySession repositorySession = EnvironmentImpl.getFromCurrent(RepositorySession.class);
if (queryProperty.getResultType() == QueryProperty.RESULT_TYPE_UNIQUE
|| queryProperty.getResultType() == QueryProperty.RESULT_TYPE_PAGE_UNIQUE) {
Object result = query.uniqueResult();
- if (result == null) {
- return null;
- }
- return getProcessDefinition(repositorySession, result);
+ if (result == null) return null;
+ return getProcessDefinition(repositorySession, (Map<?, ?>) result);
} else {
- Object result = query.list();
- List<?> propertyMaps = (List<?>) result;
- if (propertyMaps.isEmpty()) {
- return Collections.EMPTY_LIST;
- }
+ List<?> result = query.list();;
+ if (result.isEmpty()) return Collections.EMPTY_LIST;
List<ProcessDefinition> processDefinitions = new ArrayList<ProcessDefinition>();
- for (Object propertyObject : propertyMaps) {
- ProcessDefinitionImpl processDefinition = getProcessDefinition(repositorySession, propertyObject);
+ for (Map<?, ?> propertyMap : CollectionUtil.checkList(result, Map.class)) {
+ ProcessDefinitionImpl processDefinition =
+ getProcessDefinition(repositorySession, propertyMap);
processDefinitions.add(processDefinition);
}
return processDefinitions;
@@ -310,7 +304,7 @@
}
// where
- Map params = new HashMap();
+ Map<String, Object> params = new HashMap<String, Object>();
boolean alreadyAddWhere = false;
if (queryProperty.hasCondition("tookLessThen")) {
@@ -383,7 +377,7 @@
}
// where
- Map params = new HashMap();
+ Map<String, Object> params = new HashMap<String, Object>();
boolean alreadyAddWhere = false;
if (queryProperty.hasCondition("timeBefore")) {
@@ -432,7 +426,7 @@
}
// where
- Map params = new HashMap();
+ Map<String, Object> params = new HashMap<String, Object>();
boolean alreadyAddWhere = false;
if (queryProperty.hasCondition("endedBefore")) {
@@ -483,7 +477,7 @@
}
// where
- Map params = new HashMap();
+ Map<String, Object> params = new HashMap<String, Object>();
boolean alreadyAddWhere = false;
if (queryProperty.hasCondition("processInstanceId")) {
@@ -555,7 +549,8 @@
// ~ ======================================================================
- protected void appendWhereClause(StringBuilder buff, QueryProperty queryProperty, Map params, boolean originalAlreadyAddWhere) {
+ protected void appendWhereClause(StringBuilder buff, QueryProperty queryProperty,
+ Map<String, Object> params, boolean originalAlreadyAddWhere) {
// where
boolean alreadyAddWhere = originalAlreadyAddWhere;
for (Map.Entry<String, QueryCondition> entry : queryProperty.getConditions().entrySet()) {
@@ -629,8 +624,8 @@
}
}
- private static ProcessDefinitionImpl getProcessDefinition(RepositorySession repositorySession, Object propertyObject) {
- Map<?, ?> propertyMap = (Map<?, ?>) propertyObject;
+ private static ProcessDefinitionImpl getProcessDefinition(RepositorySession repositorySession,
+ Map<?, ?> propertyMap) {
String deploymentId = propertyMap.get("deploymentDbid").toString();
String objectName = (String)propertyMap.get("objectName");
return (ProcessDefinitionImpl) repositorySession.getObject(deploymentId, objectName);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -46,9 +46,8 @@
public void process() {
DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
- Long historyActivityInstanceDbId = execution.getHistoryActivityInstanceDbid();
- HistoryActivityInstanceImpl historyActivityInstance = (HistoryActivityInstanceImpl)
- dbSession.get(getHistoryActivityInstanceClass(), historyActivityInstanceDbId);
+ HistoryActivityInstanceImpl historyActivityInstance = dbSession.get(getHistoryActivityInstanceClass(),
+ execution.getHistoryActivityInstanceDbid());
updateHistoryActivityInstance(historyActivityInstance);
dbSession.update(historyActivityInstance);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -36,11 +36,11 @@
public void process() {
DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
- HistoryProcessInstanceImpl historyProcessInstanceImpl = (HistoryProcessInstanceImpl)
- dbSession.get(HistoryProcessInstanceImpl.class, execution.getDbid());
- historyProcessInstanceImpl.setEndTime(Clock.getTime());
- historyProcessInstanceImpl.setState(execution.getState());
- historyProcessInstanceImpl.setEndActivityName(execution.getActivityName());
- dbSession.update(historyProcessInstanceImpl);
+ HistoryProcessInstanceImpl historyProcessInstance =
+ dbSession.get(HistoryProcessInstanceImpl.class, execution.getDbid());
+ historyProcessInstance.setEndTime(Clock.getTime());
+ historyProcessInstance.setState(execution.getState());
+ historyProcessInstance.setEndActivityName(execution.getActivityName());
+ dbSession.update(historyProcessInstance);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -46,9 +46,8 @@
public void process() {
DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
- Long historyActivityInstanceDbId = execution.getHistoryActivityInstanceDbid();
- HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl)
- dbSession.get(HistoryTaskInstanceImpl.class, historyActivityInstanceDbId);
+ HistoryTaskInstanceImpl historyTaskInstance = dbSession.get(HistoryTaskInstanceImpl.class,
+ execution.getHistoryActivityInstanceDbid());
historyTaskInstance.setEndTime(Clock.getTime());
historyTaskInstance.setTransitionName(outcome);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskSkip.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskSkip.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskSkip.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -53,9 +53,8 @@
super.updateHistoryActivityInstance(historyActivityInstance);
DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
- Long historyTaskInstanceId = execution.getHistoryActivityInstanceDbid();
- HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl) dbSession
- .get(HistoryTaskInstanceImpl.class, historyTaskInstanceId);
+ HistoryTaskInstanceImpl historyTaskInstance = dbSession.get(HistoryTaskInstanceImpl.class,
+ execution.getHistoryActivityInstanceDbid());
historyTaskInstance.setEndTime(Clock.getTime());
historyTaskInstance.setTransitionName(outcome);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableCreate.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableCreate.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableCreate.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -39,15 +39,14 @@
private static final long serialVersionUID = 1L;
- Variable variable;
+ private Variable<?> variable;
- public VariableCreate(Variable variable) {
+ public VariableCreate(Variable<?> variable) {
this.variable = variable;
}
public void process() {
DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
-
dbSession.save(variable);
HistoryProcessInstanceImpl historyProcessInstance = null;
@@ -68,7 +67,7 @@
dbSession.save(historyVariable);
}
- public Variable getVariable() {
+ public Variable<?> getVariable() {
return variable;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableUpdate.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableUpdate.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/VariableUpdate.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -35,9 +35,9 @@
private static final long serialVersionUID = 1L;
- Variable variable;
+ private Variable<?> variable;
- public VariableUpdate(Variable variable) {
+ public VariableUpdate(Variable<?> variable) {
this.variable = variable;
}
@@ -48,7 +48,7 @@
historyVariable.updated(variable);
}
- public Variable getVariable() {
+ public Variable<?> getVariable() {
return variable;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryVariableImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryVariableImpl.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryVariableImpl.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -54,7 +54,8 @@
protected HistoryVariableImpl() {
}
- public HistoryVariableImpl(HistoryProcessInstanceImpl historyProcessInstance, HistoryTaskImpl historyTask, Variable variable) {
+ public HistoryVariableImpl(HistoryProcessInstanceImpl historyProcessInstance,
+ HistoryTaskImpl historyTask, Variable<?> variable) {
this.dbid = variable.getDbid();
this.historyProcessInstance = historyProcessInstance;
@@ -70,7 +71,7 @@
this.value = variable.getTextValue();
}
- public void updated(Variable variable) {
+ public void updated(Variable<?> variable) {
String newValue = variable.getTextValue();
if ( (value==null && newValue!=null)
|| (value!=null && (!value.equals(newValue)))
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,33 +21,10 @@
*/
package org.jbpm.pvm.internal.id;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jbpm.api.JbpmException;
import org.jbpm.api.cmd.Command;
import org.jbpm.api.cmd.Environment;
-import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
-import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
-import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
-import org.jbpm.pvm.internal.history.model.HistoryVariableImpl;
-import org.jbpm.pvm.internal.identity.impl.GroupImpl;
-import org.jbpm.pvm.internal.identity.impl.MembershipImpl;
-import org.jbpm.pvm.internal.identity.impl.UserImpl;
-import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.lob.Lob;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.processengine.ProcessEngineImpl;
-import org.jbpm.pvm.internal.repository.DeploymentImpl;
-import org.jbpm.pvm.internal.repository.DeploymentProperty;
import org.jbpm.pvm.internal.session.DbSession;
-import org.jbpm.pvm.internal.task.ParticipationImpl;
-import org.jbpm.pvm.internal.task.SwimlaneImpl;
-import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.pvm.internal.type.Variable;
-
/**
* @author Tom Baeyens
*/
@@ -55,8 +32,6 @@
private static final long serialVersionUID = 1L;
- private static Log log = Log.getLog(InitializePropertiesCmd.class.getName());
-
long blocksize;
public InitializePropertiesCmd(long blocksize) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -22,7 +22,6 @@
package org.jbpm.pvm.internal.id;
import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.processengine.ProcessEngineImpl;
import org.jbpm.pvm.internal.session.DbSession;
@@ -109,7 +108,7 @@
}
protected static PropertyImpl getProperty(DbSession dbSession, String key) {
- return (PropertyImpl) dbSession.get(PropertyImpl.class, key);
+ return dbSession.get(PropertyImpl.class, key);
}
public static void setDbVersionTo41(DbSession dbSession) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -22,7 +22,6 @@
import org.jbpm.pvm.internal.job.TimerImpl;
import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.session.TimerSession;
-import org.jbpm.pvm.internal.util.CollectionUtil;
/**
* Timers created with this service are committed at the end of the transaction,
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -101,7 +101,7 @@
protected <S> Variable<S> createVariableObject(String key, Object value, String typeName,
boolean isHistoryEnabled) {
// if type does not actually match S, there is a configuration error
- // and Variable.isStorable will eventually throw an exception
+ // and Variable.supports() will eventually throw an exception
@SuppressWarnings("unchecked")
Type<S> type = (Type<S>) findType(key, value, typeName);
Variable<S> variable;
@@ -112,10 +112,12 @@
log.trace("creating " + type + " variable '" + key + "'");
variable = variableClass.newInstance();
}
- catch (Exception e) {
- throw new JbpmException("couldn't instantiate variable instance class '"
- + variableClass.getName() + "'");
+ catch (InstantiationException e) {
+ throw new JbpmException("failed to instantiate " + variableClass, e);
}
+ catch (IllegalAccessException e) {
+ throw new JbpmException(getClass() + " has no access to " + variableClass, e);
+ }
Converter<?, S> converter = type.getConverter();
if (converter != null) variable.setConverter(converter);
}
@@ -169,8 +171,8 @@
}
private <S> void setVariableNoCheck(String key, Object value) {
- // if type does not actually match S, there is a configuration error
- // and Variable.isStorable will eventually throw an exception
+ // if variable does not actually store S, there is a configuration error
+ // and Variable.supports() will eventually throw an exception
@SuppressWarnings("unchecked")
Variable<S> variable = (Variable<S>) getVariableObject(key);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableOutDefinitionSet.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableOutDefinitionSet.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableOutDefinitionSet.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -27,7 +27,6 @@
import java.util.List;
import org.jbpm.pvm.internal.el.Expression;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
/**
* @author Tom Baeyens
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,9 +21,6 @@
*/
package org.jbpm.pvm.internal.query;
-import java.lang.reflect.Array;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -157,44 +154,6 @@
return QueryOperator.EQUALS;
}
- /**
- * Transforms given string (<code>parameter</code>) to an array of given type (<code>clazz</code>).
- * <code>parameter</code> will be split using separator ',' (comma).
- * Array will be populated based on split string by creating new instance of class <code>clazz</code>
- * using its constructor that accepts String argument.
- * All exceptions will be silently skipped.
- */
- @SuppressWarnings("unchecked")
- protected <T> T[] transformToArray(String paramStr, Class<T> clazz) {
- String[] parameters = paramStr.split(",");
- if (clazz == String.class) {
- return (T[]) parameters;
- }
-
- T[] ids = (T[]) Array.newInstance(clazz, parameters.length);
- try {
- Constructor<T> constructor = clazz.getConstructor(String.class);
- for (int i = 0; i < parameters.length; i++) {
- try {
- ids[i] = (T) constructor.newInstance(parameters[i]);
- }
- catch (InstantiationException e) {
- throw new JbpmException("failed to instantiate " + clazz, e);
- }
- catch (IllegalAccessException e) {
- throw new JbpmException(getClass() + " has no access to " + constructor);
- }
- catch (InvocationTargetException e) {
- throw new JbpmException(constructor + " threw exception", e.getCause());
- }
- }
- return ids;
- }
- catch (NoSuchMethodException e) {
- throw new JbpmException("string constructor not found in " + clazz, e);
- }
- }
-
protected void appendWhereClauseWithOperator(String where, String namedParam, StringBuilder hql) {
QueryOperator operator = getOperator(namedParam);
switch (operator) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/TaskQueryImpl.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -29,7 +29,6 @@
import org.jbpm.api.QueryOperator;
import org.jbpm.api.TaskQuery;
import org.jbpm.api.task.Task;
-import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.session.QuerySession;
import org.jbpm.pvm.internal.task.TaskImpl;
@@ -59,7 +58,6 @@
public class TaskQueryImpl extends AbstractQuery implements TaskQuery {
private static final long serialVersionUID = 1L;
- private static final Log log = Log.getLog(TaskQueryImpl.class.getName());
protected boolean unassigned;
protected String[] assignee;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -29,7 +29,6 @@
import org.jbpm.api.NewDeployment;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessDefinitionQuery;
-import org.jbpm.api.RepositoryService;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.cmd.CommandService;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
@@ -37,8 +36,8 @@
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
-import org.jbpm.pvm.internal.session.RepositorySession;
import org.jbpm.pvm.internal.session.DbSession;
+import org.jbpm.pvm.internal.session.RepositorySession;
import org.jbpm.pvm.internal.util.CollectionUtil;
/**
@@ -101,7 +100,7 @@
}
public DeploymentImpl getDeployment(String deploymentId) {
- return (DeploymentImpl) dbSession.get(DeploymentImpl.class, Long.parseLong(deploymentId));
+ return dbSession.get(DeploymentImpl.class, Long.parseLong(deploymentId));
}
public Object getObject(String deploymentId, String objectName) {
@@ -116,7 +115,7 @@
if (log.isTraceEnabled()) {
log.trace("loading deployment " + deploymentId + " from db");
}
- DeploymentImpl deployment = (DeploymentImpl) dbSession.get(DeploymentImpl.class, Long.parseLong(deploymentId));
+ DeploymentImpl deployment = dbSession.get(DeploymentImpl.class, Long.parseLong(deploymentId));
deployerManager.deploy(deployment);
object = repositoryCache.get(deploymentId, objectName);
if (object == null) {
@@ -199,7 +198,6 @@
* Checks if every entry in the repositoryCache is still valid.
* If the entry is not found in the database, it is deleted from the cache.
*/
- @SuppressWarnings("unchecked")
private void validateRepositoryCache() {
log.trace("Validating repository cache ... ");
Set<Long> dbIds = new HashSet<Long>(dbSession.findDeploymentDbids());
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/EnvironmentBindings.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/EnvironmentBindings.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/EnvironmentBindings.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -79,7 +79,7 @@
}
public Set<Entry<String, Object>> entrySet() {
- return Collections.EMPTY_SET;
+ return Collections.emptySet();
}
public boolean isEmpty() {
@@ -87,7 +87,7 @@
}
public Set<String> keySet() {
- return Collections.EMPTY_SET;
+ return Collections.emptySet();
}
public int size() {
@@ -95,6 +95,6 @@
}
public Collection<Object> values() {
- return Collections.EMPTY_SET;
+ return Collections.emptySet();
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/QuerySession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/QuerySession.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/QuerySession.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,7 +21,6 @@
*/
package org.jbpm.pvm.internal.session;
-import org.jbpm.api.Deployment;
import org.jbpm.pvm.internal.query.QueryProperty;
/**
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/BusinessCalendarBinding.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -28,7 +28,6 @@
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
-import java.util.StringTokenizer;
import java.util.TimeZone;
import org.jbpm.pvm.internal.cal.BusinessCalendarImpl;
@@ -42,7 +41,6 @@
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
-
/**
* @author Tom Baeyens
*/
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ManagementServiceBinding.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,16 +21,15 @@
*/
package org.jbpm.pvm.internal.wire.binding;
+import org.w3c.dom.Element;
+
import org.jbpm.pvm.internal.cmd.CommandService;
import org.jbpm.pvm.internal.svc.ManagementServiceImpl;
-import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
/**
* @author Tom Baeyens
*/
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TypesBinding.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -22,9 +22,11 @@
package org.jbpm.pvm.internal.wire.binding;
import java.io.File;
+import java.net.MalformedURLException;
import java.net.URL;
-import java.util.List;
+import org.w3c.dom.Element;
+
import org.jbpm.pvm.internal.stream.FileStreamInput;
import org.jbpm.pvm.internal.stream.ResourceStreamInput;
import org.jbpm.pvm.internal.stream.StreamInput;
@@ -33,6 +35,7 @@
import org.jbpm.pvm.internal.type.Matcher;
import org.jbpm.pvm.internal.type.Type;
import org.jbpm.pvm.internal.type.TypeMapping;
+import org.jbpm.pvm.internal.type.Variable;
import org.jbpm.pvm.internal.type.matcher.ClassNameMatcher;
import org.jbpm.pvm.internal.type.matcher.HibernateLongIdMatcher;
import org.jbpm.pvm.internal.type.matcher.HibernateStringIdMatcher;
@@ -44,12 +47,12 @@
import org.jbpm.pvm.internal.wire.descriptor.TypesDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-/** parses a descriptor for Boolean.TRUE.
- *
+/**
+ * parses a types descriptor.
+ *
* See schema docs for more details.
- *
+ *
* @author Tom Baeyens
*/
public class TypesBinding extends WireDescriptorBinding {
@@ -63,12 +66,13 @@
if (element.hasAttribute("file")) {
String fileName = element.getAttribute("file");
File file = new File(fileName);
- if (file.exists() && file.isFile()) {
+ if (file.isFile()) {
streamSource = new FileStreamInput(file);
parser.importStream(streamSource, element, parse);
- } else {
- parse.addProblem("file "+fileName+" isn't a file", element);
}
+ else {
+ parse.addProblem(fileName + " is not a normal file", element);
+ }
}
if (element.hasAttribute("resource")) {
@@ -84,24 +88,23 @@
URL url = new URL(urlText);
streamSource = new UrlStreamInput(url);
parser.importStream(streamSource, element, parse);
- } catch (Exception e) {
- parse.addProblem("couldn't open url "+urlText, e);
}
+ catch (MalformedURLException e) {
+ parse.addProblem("bad url", e, element);
+ }
}
TypesDescriptor typesDescriptor = new TypesDescriptor();
-
- List<Element> typeElements = XmlUtil.elements(element, "type");
- for (Element typeElement: typeElements) {
+ for (Element typeElement : XmlUtil.elements(element, "type")) {
TypeMapping typeMapping = parseTypeMapping(typeElement, parse, parser);
typesDescriptor.addTypeMapping(typeMapping);
}
return typesDescriptor;
}
- protected TypeMapping parseTypeMapping(Element element, Parse parse, Parser parser) {
+ protected <S> TypeMapping parseTypeMapping(Element element, Parse parse, Parser parser) {
TypeMapping typeMapping = new TypeMapping();
- Type type = new Type();
+ Type<S> type = new Type<S>();
typeMapping.setType(type);
// type name
@@ -109,96 +112,127 @@
type.setName(element.getAttribute("name"));
}
- String hibernateSessionFactoryName = XmlUtil.attribute(element, "hibernate-session-factory");
-
- // first we get the matcher
- Matcher matcher = null;
+ // first get the matcher
if (element.hasAttribute("class")) {
String className = element.getAttribute("class");
// if type="serializable"
if ("serializable".equals(className)) {
- matcher = new SerializableMatcher();
-
+ typeMapping.setMatcher(new SerializableMatcher());
+ }
// if type="hibernatable"
- } else if ("hibernatable".equals(className)) {
+ else if ("hibernatable".equals(className)) {
if (element.hasAttribute("id-type")) {
String idType = element.getAttribute("id-type");
+ String sessionFactoryName = XmlUtil.attribute(element, "hibernate-session-factory");
+
if ("long".equalsIgnoreCase(idType)) {
- matcher = new HibernateLongIdMatcher(hibernateSessionFactoryName);
- } else if ("string".equalsIgnoreCase(idType)) {
- matcher = new HibernateStringIdMatcher(hibernateSessionFactoryName);
- } else {
- parse.addProblem("id-type was not 'long' or 'string': "+idType, element);
+ typeMapping.setMatcher(new HibernateLongIdMatcher(sessionFactoryName));
}
- } else {
+ else if ("string".equalsIgnoreCase(idType)) {
+ typeMapping.setMatcher(new HibernateStringIdMatcher(sessionFactoryName));
+ }
+ else {
+ parse.addProblem("id-type was not 'long' or 'string': " + idType, element);
+ }
+ }
+ else {
parse.addProblem("id-type is required in a persistable type", element);
}
-
- // otherwise, we expect type="some.java.ClassName"
- } else {
- matcher = new ClassNameMatcher(className);
}
-
- } else {
+ // otherwise, type must be a fully qualified class name
+ else {
+ typeMapping.setMatcher(new ClassNameMatcher(className));
+ }
+ }
+ else {
// look for the matcher element
Element matcherElement = XmlUtil.element(element, "matcher");
Element matcherObjectElement = XmlUtil.element(matcherElement);
- if (matcherObjectElement!=null) {
- try {
- Descriptor descriptor = (Descriptor) parser.parseElement(matcherObjectElement, parse);
- matcher = (Matcher) WireContext.create(descriptor);
- } catch (ClassCastException e) {
- parse.addProblem("matcher is not a "+Matcher.class.getName()+": "+(matcher!=null ? matcher.getClass().getName() : "null"), element);
+ if (matcherObjectElement != null) {
+ Descriptor descriptor = (Descriptor) parser.parseElement(matcherObjectElement, parse);
+ Object obj = WireContext.create(descriptor);
+ if (obj instanceof Matcher) {
+ typeMapping.setMatcher((Matcher) obj);
}
- } else {
- parse.addProblem("no matcher specified in "+XmlUtil.toString(element), element);
+ else {
+ parse.addProblem(obj + " is not a matcher", element);
+ }
}
+ else {
+ parse.addProblem("no matcher specified in " + XmlUtil.toString(element), element);
+ }
}
- typeMapping.setMatcher(matcher);
-
// parsing the converter
- Converter converter = null;
if (element.hasAttribute("converter")) {
String converterClassName = element.getAttribute("converter");
try {
- Class<?> converterClass = ReflectUtil.classForName(converterClassName);
- converter = (Converter) converterClass.newInstance();
- } catch (Exception e) {
- parse.addProblem("couldn't instantiate converter "+converterClassName, element);
+ Class<?> clazz = ReflectUtil.classForName(converterClassName);
+ if (Converter.class.isAssignableFrom(clazz)) {
+ @SuppressWarnings("unchecked")
+ Class<? extends Converter<?, S>> converterClass = (Class<? extends Converter<?, S>>) clazz;
+ try {
+ type.setConverter(converterClass.newInstance());
+ }
+ catch (InstantiationException e) {
+ parse.addProblem("failed to instantiate " + converterClass, e, element);
+ }
+ catch (IllegalAccessException e) {
+ parse.addProblem(getClass() + " has no access to " + converterClass, e, element);
+ }
+ }
+ else {
+ parse.addProblem(clazz + " is not a converter", element);
+ }
}
- } else {
+ catch (ClassNotFoundException e) {
+ parse.addProblem("converter class not found: " + converterClassName, e, element);
+ }
+ }
+ else {
// look for the matcher element
Element converterElement = XmlUtil.element(element, "converter");
Element converterObjectElement = XmlUtil.element(converterElement);
- if (converterObjectElement!=null) {
- try {
- converter = (Converter) parser.parseElement(converterObjectElement, parse);
- } catch (ClassCastException e) {
- parse.addProblem("converter is not a "+Converter.class.getName()+": "+(converter!=null ? converter.getClass().getName() : "null"), element);
+ if (converterObjectElement != null) {
+ Object obj = parser.parseElement(converterObjectElement, parse);
+ if (obj instanceof Converter<?, ?>) {
+ // if converter does not actually produce S, there is a configuration error
+ // and Converter.supports() will eventually throw an exception
+ @SuppressWarnings("unchecked")
+ Converter<?, S> converter = (Converter<?, S>) obj;
+ type.setConverter(converter);
}
+ else {
+ parse.addProblem(obj + " is not a converter", element);
+ }
}
}
- type.setConverter(converter);
-
// parsing the variable class
-
- Class<?> variableClass = null;
if (element.hasAttribute("variable-class")) {
String variableClassName = element.getAttribute("variable-class");
try {
- variableClass = ReflectUtil.classForName(variableClassName);
- } catch (Exception e) {
- parse.addProblem("couldn't instantiate variable-class "+variableClassName, e);
+ Class<?> clazz = ReflectUtil.classForName(variableClassName);
+ if (Variable.class.isAssignableFrom(clazz)) {
+ // if variable class does not actually store S, there is a configuration error
+ // and Variable.supports() will eventually throw an exception
+ @SuppressWarnings("unchecked")
+ Class<? extends Variable<S>> variableClass = (Class<? extends Variable<S>>) clazz;
+ type.setVariableClass(variableClass);
+ }
+ else {
+ parse.addProblem(clazz + " is not a variable", element);
+ }
}
- } else {
- parse.addProblem("variable-class is required on a type: "+XmlUtil.toString(element), element);
+ catch (ClassNotFoundException e) {
+ parse.addProblem("variable class not found: " + variableClassName, e, element);
+ }
}
+ else {
+ parse.addProblem("variable-class is required on a type", element);
+ }
- type.setVariableClass(variableClass);
-
return typeMapping;
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CharacterDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CharacterDescriptor.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CharacterDescriptor.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,18 +21,17 @@
*/
package org.jbpm.pvm.internal.wire.descriptor;
-import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
/**
* @author Tom Baeyens
* @author Guillaume Porcher (documentation)
*/
-public class CharacterDescriptor extends AbstractDescriptor implements Descriptor {
+public class CharacterDescriptor extends AbstractDescriptor {
private static final long serialVersionUID = 1L;
- String text;
+ private String text;
public CharacterDescriptor() {
}
@@ -42,17 +41,10 @@
}
public Object construct(WireContext factory) {
- if (text==null) {
- return null;
- }
- return new Character( text.charAt(0) );
+ return text != null ? new Character(text.charAt(0)) : null;
}
public void setValue(Character value) {
- if (value==null) {
- text = null;
- } else {
- text = value.toString();
- }
+ text = value != null ? value.toString() : null;
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -15,11 +15,10 @@
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireException;
-
/**
* @author Tom Baeyens
*/
-public class CollectionDescriptor extends AbstractDescriptor implements Descriptor {
+public class CollectionDescriptor extends AbstractDescriptor {
private static final long serialVersionUID = 1L;
@@ -29,63 +28,73 @@
protected List<Descriptor> valueDescriptors;
protected boolean isSynchronized;
- protected CollectionDescriptor() { }
+ protected CollectionDescriptor() {
+ }
- public CollectionDescriptor(String defaultImplClassName) {
- this.className = defaultImplClassName;
+ public CollectionDescriptor(String defaultClassName) {
+ this.className = defaultClassName;
}
public Object construct(WireContext wireContext) {
- Object object = null;
+ Object object;
try {
// instantiate
Class<?> clazz = ReflectUtil.classForName(className);
- object = clazz.newInstance();
+ try {
+ object = clazz.newInstance();
+ }
+ catch (InstantiationException e) {
+ throw new WireException("failed to instantiate " + clazz, e);
+ }
+ catch (IllegalAccessException e) {
+ throw new WireException(getClass() + " has no access to " + clazz, e);
+ }
+ }
+ catch (ClassNotFoundException e) {
+ throw new WireException("collection class not found: " + className, e);
+ }
- if (isSynchronized) {
- if (object instanceof SortedSet) {
- object = Collections.synchronizedSortedSet((SortedSet) object);
- } else if (object instanceof SortedMap) {
- object = Collections.synchronizedSortedMap((SortedMap) object);
- } else if (object instanceof Set) {
- object = Collections.synchronizedSet((Set) object);
- } else if (object instanceof Map) {
- object = Collections.synchronizedMap((Map) object);
- } else if (object instanceof List) {
- object = Collections.synchronizedList((List) object);
- } else if (object instanceof Collection) {
- object = Collections.synchronizedCollection((Collection) object);
- }
+ if (isSynchronized) {
+ if (object instanceof SortedSet<?>) {
+ object = Collections.synchronizedSortedSet((SortedSet<?>) object);
}
-
- } catch (Exception e) {
- throw new WireException("couldn't create '"+(name!=null ? name : className)+"': "+e.getMessage(), e);
+ else if (object instanceof SortedMap<?, ?>) {
+ object = Collections.synchronizedSortedMap((SortedMap<?, ?>) object);
+ }
+ else if (object instanceof Set<?>) {
+ object = Collections.synchronizedSet((Set<?>) object);
+ }
+ else if (object instanceof Map<?, ?>) {
+ object = Collections.synchronizedMap((Map<?, ?>) object);
+ }
+ else if (object instanceof List<?>) {
+ object = Collections.synchronizedList((List<?>) object);
+ }
+ else if (object instanceof Collection<?>) {
+ object = Collections.synchronizedCollection((Collection<?>) object);
+ }
}
return object;
}
public void initialize(Object object, WireContext wireContext) {
+ // collection created via Class.newInstance
+ @SuppressWarnings("unchecked")
Collection<Object> collection = (Collection<Object>) object;
- try {
- if (valueDescriptors!=null) {
- for(Descriptor descriptor: valueDescriptors) {
- Object element = wireContext.create(descriptor, true);
- log.trace("adding element "+element+" to collection");
- collection.add(element);
- }
+ if (valueDescriptors != null) {
+ for (Descriptor descriptor : valueDescriptors) {
+ Object element = wireContext.create(descriptor, true);
+ log.trace("adding element " + element + " to collection");
+ collection.add(element);
}
- } catch (WireException e) {
- throw e;
- } catch (Exception e) {
- throw new WireException("couldn't initialize object '"+(name!=null ? name : className)+"'", e);
}
}
public void addValueDescriptors(List<Descriptor> otherValueDescriptors) {
- if (valueDescriptors==null) {
+ if (valueDescriptors == null) {
valueDescriptors = new ArrayList<Descriptor>();
}
- if (otherValueDescriptors!=null) {
+ if (otherValueDescriptors != null) {
valueDescriptors.addAll(otherValueDescriptors);
}
}
@@ -93,18 +102,23 @@
public String getClassName() {
return className;
}
+
public void setClassName(String className) {
this.className = className;
}
+
public List<Descriptor> getValueDescriptors() {
return valueDescriptors;
}
+
public void setValueDescriptors(List<Descriptor> valueDescriptors) {
this.valueDescriptors = valueDescriptors;
}
+
public boolean isSynchronized() {
return isSynchronized;
}
+
public void setSynchronized(boolean isSynchronized) {
this.isSynchronized = isSynchronized;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextRefDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextRefDescriptor.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ContextRefDescriptor.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -1,15 +1,14 @@
package org.jbpm.pvm.internal.wire.descriptor;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireException;
-public class ContextRefDescriptor extends AbstractDescriptor implements Descriptor {
+public class ContextRefDescriptor extends AbstractDescriptor {
private static final long serialVersionUID = 1L;
- String contextName;
+ private String contextName;
public Object construct(WireContext wireContext) {
if (contextName==null) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DoubleDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DoubleDescriptor.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/DoubleDescriptor.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,18 +21,17 @@
*/
package org.jbpm.pvm.internal.wire.descriptor;
-import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
/**
* @author Tom Baeyens
* @author Guillaume Porcher (documentation)
*/
-public class DoubleDescriptor extends AbstractDescriptor implements Descriptor {
+public class DoubleDescriptor extends AbstractDescriptor {
private static final long serialVersionUID = 1L;
- Double doubleVal;
+ private Double doubleVal;
public DoubleDescriptor() {
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FloatDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FloatDescriptor.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/FloatDescriptor.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,19 +21,17 @@
*/
package org.jbpm.pvm.internal.wire.descriptor;
-import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
-
/**
* @author Tom Baeyens
* @author Guillaume Porcher (documentation)
*/
-public class FloatDescriptor extends AbstractDescriptor implements Descriptor {
+public class FloatDescriptor extends AbstractDescriptor {
private static final long serialVersionUID = 1L;
- Double doubleVal;
+ private Double doubleVal;
public FloatDescriptor() {
}
@@ -43,17 +41,10 @@
}
public Object construct(WireContext factory) {
- if (doubleVal==null) {
- return null;
- }
- return new Float(doubleVal.floatValue());
+ return doubleVal != null ? new Float(doubleVal) : null;
}
public void setValue(Float value) {
- if (value==null) {
- doubleVal = null;
- } else {
- doubleVal = new Double(value);
- }
+ doubleVal = value != null ? new Double(value) : null;
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -25,10 +25,10 @@
import org.jbpm.pvm.internal.history.HistorySession;
import org.jbpm.pvm.internal.history.HistorySessionChain;
+import org.jbpm.pvm.internal.util.CollectionUtil;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireDefinition;
-
/**
* @author Tom Baeyens
*/
@@ -36,18 +36,22 @@
private static final long serialVersionUID = 1L;
- CollectionDescriptor listDescriptor = new ListDescriptor();
+ private ListDescriptor listDescriptor = new ListDescriptor();
public Object construct(WireContext wireContext) {
- List<HistorySession> historySessions = (List<HistorySession>) wireContext.create(listDescriptor, false);
- if (historySessions.size()==1) {
+ List<?> historySessions = (List<?>) wireContext.create(listDescriptor, false);
+ switch (historySessions.size()) {
+ case 0:
+ return null;
+ case 1:
return historySessions.get(0);
- }
- return new HistorySessionChain(historySessions);
+ default:
+ return new HistorySessionChain(CollectionUtil.checkList(historySessions, HistorySession.class));
+ }
}
public void add(CollectionDescriptor otherListDescriptor) {
- this.listDescriptor.addValueDescriptors(otherListDescriptor.getValueDescriptors());
+ listDescriptor.addValueDescriptors(otherListDescriptor.getValueDescriptors());
}
public Class<?> getType(WireDefinition wireDefinition) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IntegerDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IntegerDescriptor.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/IntegerDescriptor.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,18 +21,15 @@
*/
package org.jbpm.pvm.internal.wire.descriptor;
-import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
/**
- * <p>This {@link Descriptor} specifies an Integer.</p>
+ * <p>This specifies an Integer.</p>
*
* @author Tom Baeyens
* @author Guillaume Porcher (documentation)
- *
- * @see Descriptor
*/
-public class IntegerDescriptor extends AbstractDescriptor implements Descriptor {
+public class IntegerDescriptor extends AbstractDescriptor {
private static final long serialVersionUID = 1L;
@@ -46,17 +43,10 @@
}
public Object construct(WireContext factory) {
- if (longVal==null) {
- return null;
- }
- return new Integer(longVal.intValue());
+ return longVal != null ? new Integer(longVal.intValue()) : null;
}
public void setValue(Integer value) {
- if (value==null) {
- longVal = null;
- } else {
- longVal = new Long(value);
- }
+ longVal = value != null ? new Long(value) : value;
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JobExecutorDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JobExecutorDescriptor.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JobExecutorDescriptor.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -30,10 +30,9 @@
*/
public class JobExecutorDescriptor extends ObjectDescriptor {
private static final long serialVersionUID = 1L;
- private static final Log log = Log.getLog(JobExecutorDescriptor.class.getName());
-
+ static final Log log = Log.getLog(JobExecutorDescriptor.class.getName());
- private boolean autoStart = false;
+ private boolean autoStart;
public JobExecutorDescriptor() {
super(JobExecutor.class.getName());
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/LongDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/LongDescriptor.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/LongDescriptor.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,14 +21,13 @@
*/
package org.jbpm.pvm.internal.wire.descriptor;
-import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
/**
* @author Tom Baeyens
* @author Guillaume Porcher (documentation)
*/
-public class LongDescriptor extends AbstractDescriptor implements Descriptor {
+public class LongDescriptor extends AbstractDescriptor {
private static final long serialVersionUID = 1L;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/MapDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/MapDescriptor.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/MapDescriptor.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -6,7 +6,6 @@
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.WireException;
/**
*
@@ -38,25 +37,19 @@
}
public void initialize(Object object, WireContext wireContext) {
- Map<Object,Object> map = (Map<Object,Object>) object;
- try {
- if (keyDescriptors!=null) {
- for (int i=0; i<keyDescriptors.size(); i++) {
- Descriptor keyDescriptor = keyDescriptors.get(i);
- Descriptor valueDescriptor = valueDescriptors.get(i);
- Object key = wireContext.create(keyDescriptor, true);
- Object value = wireContext.create(valueDescriptor, true);
- map.put(key, value);
- }
+ // map created via Class.newInstance
+ @SuppressWarnings("unchecked")
+ Map<Object, Object> map = (Map<Object, Object>) object;
+ if (keyDescriptors != null) {
+ for (int i = 0; i < keyDescriptors.size(); i++) {
+ Descriptor keyDescriptor = keyDescriptors.get(i);
+ Descriptor valueDescriptor = valueDescriptors.get(i);
+ Object key = wireContext.create(keyDescriptor, true);
+ Object value = wireContext.create(valueDescriptor, true);
+ map.put(key, value);
}
- } catch (WireException e) {
- throw e;
- } catch (Exception e) {
- throw new WireException("couldn't initialize object '"+(name!=null ? name : className)+"'", e);
}
}
-
-
public List<Descriptor> getKeyDescriptors() {
return keyDescriptors;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/NullDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/NullDescriptor.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/NullDescriptor.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,18 +21,15 @@
*/
package org.jbpm.pvm.internal.wire.descriptor;
-import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
/**
- * <p>This {@link Descriptor} creates a <code>null</code> object.</p>
+ * <p>This descriptor creates a <code>null</code> object.</p>
*
* @author Tom Baeyens
* @author Guillaume Porcher (documentation)
- *
- * @see Descriptor
*/
-public class NullDescriptor extends AbstractDescriptor implements Descriptor {
+public class NullDescriptor extends AbstractDescriptor {
private static final long serialVersionUID = 1L;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -2,11 +2,10 @@
import org.jbpm.api.JbpmException;
import org.jbpm.pvm.internal.util.ReflectUtil;
-import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
/**
- * <p>This {@link Descriptor} specifies a reference to an object.
+ * <p>This descriptor specifies a reference to an object.
* The object referenced should be declared somewhere else in the wireContext.</p>
*
* <p>The constructed object is the referenced object.</p>
@@ -16,12 +15,12 @@
* @author Tom Baeyens
* @author Guillaume Porcher (documentation)
*/
-public class ReferenceDescriptor extends AbstractDescriptor implements Descriptor {
+public class ReferenceDescriptor extends AbstractDescriptor {
private static final long serialVersionUID = 1L;
- String text = null;
- String type = null;
+ private String text;
+ private String type;
// TODO add a refExpression that is evaluated with el
// the base referenced descriptor always should have delayedInitialization = false;
@@ -48,7 +47,7 @@
}
public boolean isDelayedInitializationAllowed() {
- return (init == INIT_EAGER || init == INIT_LAZY);
+ return init == INIT_EAGER || init == INIT_LAZY;
}
public void setValue(String objectName) {
this.text = objectName;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/AbstractOperation.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/AbstractOperation.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/AbstractOperation.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -28,6 +28,8 @@
protected long dbid;
protected int dbversion;
+
+ private static final long serialVersionUID = 1L;
public long getDbid() {
return dbid;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/FieldOperation.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/FieldOperation.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/operation/FieldOperation.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -2,13 +2,11 @@
import java.lang.reflect.Field;
-import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireException;
-
/**
* injects another object into a field.
*
@@ -78,6 +76,4 @@
public synchronized void setDescriptor(Descriptor valueDescriptor) {
this.descriptor = valueDescriptor;
}
-
- private static Log log = Log.getLog(FieldOperation.class.getName());
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/eventlistener/EventListenerTest.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -27,7 +27,6 @@
import org.jbpm.pvm.activities.TestConsoleTestCase;
import org.jbpm.pvm.activities.WaitState;
import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.pvm.internal.client.ClientExecution;
import org.jbpm.pvm.internal.client.ClientProcessDefinition;
public class EventListenerTest extends TestConsoleTestCase {
@@ -52,7 +51,7 @@
.endActivity()
.endProcess();
- ClientExecution execution = processDefinition.startProcessInstance();
+ processDefinition.startProcessInstance();
assertEquals("leaving a", testConsole.getLine(0));
assertEquals("second message while leaving a", testConsole.getLine(1));
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/object/ObjectExecutionModeTest.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -26,13 +26,11 @@
import org.jbpm.pvm.activities.AutomaticActivity;
import org.jbpm.pvm.activities.WaitState;
import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.pvm.internal.client.ClientExecution;
import org.jbpm.pvm.internal.client.ClientProcessDefinition;
import org.jbpm.pvm.internal.client.ClientProcessInstance;
public class ObjectExecutionModeTest extends TestCase {
-
public void testObjectExecutionMode(){
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder
.startProcess("loan")
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/cal/BusinessCalendarTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/cal/BusinessCalendarTest.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/cal/BusinessCalendarTest.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -1,10 +1,10 @@
package org.jbpm.pvm.internal.cal;
-import java.util.*;
-import junit.framework.*;
-import org.jbpm.pvm.internal.model.*;
+import java.util.Date;
+import junit.framework.TestCase;
+
public class BusinessCalendarTest extends TestCase {
public void testSubstract() {
BusinessCalendarImpl businessCalendar = new BusinessCalendarImpl();
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/el/ExpressionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/el/ExpressionTest.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/el/ExpressionTest.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -2,6 +2,7 @@
package org.jbpm.pvm.internal.el;
import java.util.*;
+
import junit.framework.*;
import org.jbpm.pvm.internal.model.*;
import org.jbpm.pvm.internal.env.*;
@@ -21,31 +22,23 @@
}
public void testMap() {
- Map map = new HashMap();
- map.put("key", "value");
-
Expression expr = Expression.create("#{map.key}");
ExecutionImpl executionImpl = new ExecutionImpl();
- executionImpl.setVariable("map", map);
+ executionImpl.setVariable("map", Collections.singletonMap("key", "value"));
assertEquals("value", expr.evaluate(executionImpl));
}
public void testList() {
- List list = new ArrayList();
- list.add("value");
-
Expression expr = Expression.create("#{list[0]}");
ExecutionImpl executionImpl = new ExecutionImpl();
- executionImpl.setVariable("list", list);
+ executionImpl.setVariable("list", Arrays.asList("value"));
assertEquals("value", expr.evaluate(executionImpl));
}
public void testArray() {
- String[] array = new String[]{"value"};
-
Expression expr = Expression.create("#{array[0]}");
ExecutionImpl executionImpl = new ExecutionImpl();
- executionImpl.setVariable("array", array);
+ executionImpl.setVariable("array", new String[] {"value"});
assertEquals("value", expr.evaluate(executionImpl));
}
@@ -69,13 +62,9 @@
}
public void testFunction() {
- List list = new ArrayList();
- list.add("1");
- list.add("2");
-
Expression expr = Expression.create("#{length(list)}");
ExecutionImpl executionImpl = new ExecutionImpl();
- executionImpl.setVariable("list", list);
+ executionImpl.setVariable("list", Arrays.asList("1", "2"));
assertEquals(2, expr.evaluate(executionImpl));
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/UelExpressionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/UelExpressionTest.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/UelExpressionTest.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,19 +21,17 @@
*/
package org.jbpm.pvm.internal.expr;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
-import java.util.HashMap;
import java.util.Map;
+
import org.jbpm.pvm.activities.WaitState;
import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-
import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.el.UelValueExpression;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.test.JbpmTestCase;
-
/**
* @author Tom Baeyens
*/
@@ -86,14 +84,11 @@
Expression.LANGUAGE_UEL_VALUE);
UelValueExpression uve = ((UelValueExpression) expression);
- Map response = new HashMap();
- List resultSet = new ArrayList();
int[] array = new int[]{0, 1, 2, 3};
+ List<?> resultSet = Collections.singletonList(array);
+ Map<?, ?> response = Collections.singletonMap("resultSet", resultSet);
- response.put("resultSet", resultSet);
- resultSet.add(array);
execution.setVariable("response", response);
-
assertEquals(Boolean.TRUE, uve.evaluate(execution));
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -37,7 +37,7 @@
*/
public class DbidGeneratorTest extends TestCase {
- private static Log log = Log.getLog(DbidGeneratorTest.class.getName());
+ static Log log = Log.getLog(DbidGeneratorTest.class.getName());
public void testDbidGenerator() {
ProcessEngine processEngine = new Configuration().buildProcessEngine();
@@ -72,7 +72,7 @@
DbidGenerator dbidGenerator = environment.get(DbidGenerator.class);
for (int i=10020; i<20020; i++) {
assertEquals(i, dbidGenerator.getNextId());
- if ((i%1000) == 0) {
+ if (i%1000 == 0) {
log.debug("just got dbid "+i+"...");
}
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronExpression.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronExpression.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronExpression.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -5,7 +5,6 @@
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.SortedSet;
@@ -185,8 +184,8 @@
protected static final Integer ALL_SPEC = new Integer(ALL_SPEC_INT);
protected static final Integer NO_SPEC = new Integer(NO_SPEC_INT);
- protected static Map monthMap = new HashMap(20);
- protected static Map dayMap = new HashMap(60);
+ protected static Map<String, Integer> monthMap = new HashMap<String, Integer>();
+ protected static Map<String, Integer> dayMap = new HashMap<String, Integer>();
static {
monthMap.put("JAN", new Integer(0));
monthMap.put("FEB", new Integer(1));
@@ -210,21 +209,21 @@
dayMap.put("SAT", new Integer(7));
}
- private String cronExpression = null;
- private TimeZone timeZone = null;
- protected transient TreeSet seconds;
- protected transient TreeSet minutes;
- protected transient TreeSet hours;
- protected transient TreeSet daysOfMonth;
- protected transient TreeSet months;
- protected transient TreeSet daysOfWeek;
- protected transient TreeSet years;
+ private String cronExpression;
+ private TimeZone timeZone;
+ protected transient TreeSet<Integer> seconds;
+ protected transient TreeSet<Integer> minutes;
+ protected transient TreeSet<Integer> hours;
+ protected transient TreeSet<Integer> daysOfMonth;
+ protected transient TreeSet<Integer> months;
+ protected transient TreeSet<Integer> daysOfWeek;
+ protected transient TreeSet<Integer> years;
- protected transient boolean lastdayOfWeek = false;
- protected transient int nthdayOfWeek = 0;
- protected transient boolean lastdayOfMonth = false;
- protected transient boolean nearestWeekday = false;
- protected transient boolean expressionParsed = false;
+ protected transient boolean lastdayOfWeek;
+ protected transient int nthdayOfWeek;
+ protected transient boolean lastdayOfMonth;
+ protected transient boolean nearestWeekday;
+ protected transient boolean expressionParsed;
/**
* Constructs a new <CODE>CronExpression</CODE> based on the specified
@@ -259,13 +258,12 @@
Calendar testDateCal = Calendar.getInstance();
testDateCal.setTime(date);
testDateCal.set(Calendar.MILLISECOND, 0);
+
Date originalDate = testDateCal.getTime();
-
testDateCal.add(Calendar.SECOND, -1);
Date timeAfter = getTimeAfter(testDateCal.getTime());
-
- return ((timeAfter != null) && (timeAfter.equals(originalDate)));
+ return timeAfter != null && timeAfter.equals(originalDate);
}
/**
@@ -377,25 +375,25 @@
try {
if (seconds == null) {
- seconds = new TreeSet();
+ seconds = new TreeSet<Integer>();
}
if (minutes == null) {
- minutes = new TreeSet();
+ minutes = new TreeSet<Integer>();
}
if (hours == null) {
- hours = new TreeSet();
+ hours = new TreeSet<Integer>();
}
if (daysOfMonth == null) {
- daysOfMonth = new TreeSet();
+ daysOfMonth = new TreeSet<Integer>();
}
if (months == null) {
- months = new TreeSet();
+ months = new TreeSet<Integer>();
}
if (daysOfWeek == null) {
- daysOfWeek = new TreeSet();
+ daysOfWeek = new TreeSet<Integer>();
}
if (years == null) {
- years = new TreeSet();
+ years = new TreeSet<Integer>();
}
int exprOn = SECOND;
@@ -525,7 +523,7 @@
i);
}
if (type == DAY_OF_WEEK && !lastdayOfMonth) {
- int val = ((Integer) daysOfMonth.last()).intValue();
+ int val = daysOfMonth.last().intValue();
if (val == NO_SPEC_INT) {
throw new ParseException(
"'?' can only be specfied for Day-of-Month -OR- Day-of-Week.",
@@ -635,8 +633,8 @@
} else {
throw new ParseException("'L' option is not valid here. (pos=" + i + ")", i);
}
- TreeSet set = getSet(type);
- set.add(new Integer(val));
+ TreeSet<Integer> set = getSet(type);
+ set.add(Integer.valueOf(val));
i++;
return i;
}
@@ -647,8 +645,8 @@
} else {
throw new ParseException("'W' option is not valid here. (pos=" + i + ")", i);
}
- TreeSet set = getSet(type);
- set.add(new Integer(val));
+ TreeSet<Integer> set = getSet(type);
+ set.add(Integer.valueOf(val));
i++;
return i;
}
@@ -669,8 +667,8 @@
i);
}
- TreeSet set = getSet(type);
- set.add(new Integer(val));
+ TreeSet<Integer> set = getSet(type);
+ set.add(Integer.valueOf(val));
i++;
return i;
}
@@ -788,7 +786,7 @@
return summary.toString();
}
- protected String getExpressionSetSummary(java.util.Set set) {
+ protected String getExpressionSetSummary(java.util.Set<Integer> set) {
if (set.contains(NO_SPEC)) {
return "?";
@@ -799,10 +797,8 @@
StringBuilder summary = new StringBuilder();
- Iterator itr = set.iterator();
boolean first = true;
- while (itr.hasNext()) {
- Integer iVal = (Integer) itr.next();
+ for (Integer iVal : set) {
String val = iVal.toString();
if (!first) {
summary.append(",");
@@ -814,7 +810,7 @@
return summary.toString();
}
- protected String getExpressionSetSummary(java.util.List list) {
+ protected String getExpressionSetSummary(java.util.List<Integer> list) {
if (list.contains(NO_SPEC)) {
return "?";
@@ -825,10 +821,8 @@
StringBuilder summary = new StringBuilder();
- Iterator itr = list.iterator();
boolean first = true;
- while (itr.hasNext()) {
- Integer iVal = (Integer) itr.next();
+ for (Integer iVal : list) {
String val = iVal.toString();
if (!first) {
summary.append(",");
@@ -859,7 +853,7 @@
protected void addToSet(int val, int end, int incr, int type)
throws ParseException {
- TreeSet set = getSet(type);
+ TreeSet<Integer> set = getSet(type);
if (type == SECOND || type == MINUTE) {
if ((val < 0 || val > 59 || end > 59) && (val != ALL_SPEC_INT)) {
@@ -958,7 +952,7 @@
}
}
- protected TreeSet getSet(int type) {
+ protected TreeSet<Integer> getSet(int type) {
switch (type) {
case SECOND:
return seconds;
@@ -1004,7 +998,7 @@
}
protected int getMonthNumber(String s) {
- Integer integer = (Integer) monthMap.get(s);
+ Integer integer = monthMap.get(s);
if (integer == null) {
return -1;
@@ -1014,7 +1008,7 @@
}
protected int getDayOfWeekNumber(String s) {
- Integer integer = (Integer) dayMap.get(s);
+ Integer integer = dayMap.get(s);
if (integer == null) {
return -1;
@@ -1048,7 +1042,7 @@
if(cl.get(Calendar.YEAR) > 2999) // prevent endless loop...
return null;
- SortedSet st = null;
+ SortedSet<Integer> st = null;
int t = 0;
int sec = cl.get(Calendar.SECOND);
@@ -1057,9 +1051,9 @@
// get second.................................................
st = seconds.tailSet(new Integer(sec));
if (st != null && st.size() != 0) {
- sec = ((Integer) st.first()).intValue();
+ sec = st.first().intValue();
} else {
- sec = ((Integer) seconds.first()).intValue();
+ sec = seconds.first().intValue();
min++;
cl.set(Calendar.MINUTE, min);
}
@@ -1073,9 +1067,9 @@
st = minutes.tailSet(new Integer(min));
if (st != null && st.size() != 0) {
t = min;
- min = ((Integer) st.first()).intValue();
+ min = st.first().intValue();
} else {
- min = ((Integer) minutes.first()).intValue();
+ min = minutes.first().intValue();
hr++;
}
if (min != t) {
@@ -1094,9 +1088,9 @@
st = hours.tailSet(new Integer(hr));
if (st != null && st.size() != 0) {
t = hr;
- hr = ((Integer) st.first()).intValue();
+ hr = st.first().intValue();
} else {
- hr = ((Integer) hours.first()).intValue();
+ hr = hours.first().intValue();
day++;
}
if (hr != t) {
@@ -1162,7 +1156,7 @@
}
} else if(nearestWeekday) {
t = day;
- day = ((Integer) daysOfMonth.first()).intValue();
+ day = daysOfMonth.first().intValue();
java.util.Calendar tcal = java.util.Calendar.getInstance();
tcal.set(Calendar.SECOND, 0);
@@ -1193,14 +1187,14 @@
tcal.set(Calendar.MONTH, mon - 1);
Date nTime = tcal.getTime();
if(nTime.before(afterTime)) {
- day = ((Integer) daysOfMonth.first()).intValue();;
+ day = daysOfMonth.first().intValue();;
mon++;
}
} else if (st != null && st.size() != 0) {
t = day;
- day = ((Integer) st.first()).intValue();
+ day = st.first().intValue();
} else {
- day = ((Integer) daysOfMonth.first()).intValue();
+ day = daysOfMonth.first().intValue();
mon++;
}
@@ -1217,7 +1211,7 @@
} else if (dayOfWSpec && !dayOfMSpec) { // get day by day of week rule
if (lastdayOfWeek) { // are we looking for the last XXX day of
// the month?
- int dow = ((Integer) daysOfWeek.first()).intValue(); // desired
+ int dow = daysOfWeek.first().intValue(); // desired
// d-o-w
int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
int daysToAdd = 0;
@@ -1260,7 +1254,7 @@
} else if (nthdayOfWeek != 0) {
// are we looking for the Nth XXX day in the month?
- int dow = ((Integer) daysOfWeek.first()).intValue(); // desired
+ int dow = daysOfWeek.first().intValue(); // desired
// d-o-w
int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
int daysToAdd = 0;
@@ -1304,11 +1298,11 @@
}
} else {
int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w
- int dow = ((Integer) daysOfWeek.first()).intValue(); // desired
+ int dow = daysOfWeek.first().intValue(); // desired
// d-o-w
st = daysOfWeek.tailSet(new Integer(cDow));
if (st != null && st.size() > 0) {
- dow = ((Integer) st.first()).intValue();
+ dow = st.first().intValue();
}
int daysToAdd = 0;
@@ -1364,9 +1358,9 @@
st = months.tailSet(new Integer(mon));
if (st != null && st.size() != 0) {
t = mon;
- mon = ((Integer) st.first()).intValue();
+ mon = st.first().intValue();
} else {
- mon = ((Integer) months.first()).intValue();
+ mon = months.first().intValue();
year++;
}
if (mon != t) {
@@ -1391,7 +1385,7 @@
st = years.tailSet(new Integer(year));
if (st != null && st.size() != 0) {
t = year;
- year = ((Integer) st.first()).intValue();
+ year = st.first().intValue();
} else {
return null; // ran out of years...
}
@@ -1448,7 +1442,7 @@
}
protected boolean isLeapYear(int year) {
- return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
+ return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
protected int getLastDayOfMonth(int monthNum, int year) {
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronTrigger.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronTrigger.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/cron/CronTrigger.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -416,7 +416,7 @@
}
Date eTime = getEndTime();
- if (eTime != null && startTime != null && eTime.before(startTime)) {
+ if (eTime != null && eTime.before(startTime)) {
throw new IllegalArgumentException(
"End time cannot be before start time");
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/svc/RetryInterceptorTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/svc/RetryInterceptorTest.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/svc/RetryInterceptorTest.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -23,26 +23,14 @@
import junit.framework.TestCase;
-import org.hibernate.Session;
import org.hibernate.StaleStateException;
-
-import org.jbpm.api.Configuration;
-import org.jbpm.api.ProcessEngine;
-import org.jbpm.api.cmd.Command;
-import org.jbpm.api.cmd.Environment;
-import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.cmd.CommandService;
-
import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException;
-
/**
* @author Huisheng Xu
*/
public class RetryInterceptorTest extends TestCase {
- private static Log log = Log.getLog(RetryInterceptorTest.class.getName());
-
public void testShouldRetryStaleStateException() {
RetryInterceptor retryInterceptor = new RetryInterceptor();
retryInterceptor.setTargetExceptionClass(StaleStateException.class);
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ListWireTest.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
import org.jbpm.pvm.internal.xml.Problem;
@@ -44,27 +45,22 @@
"</objects>"
);
- List<Object> values = (List<Object>) wireContext.get("l");
- // make a copy so that we can compare 2 ArrayLists
- values = new ArrayList<Object>(values);
-
- List<Object> expected = new ArrayList<Object>(3);
+ List<Object> expected = new ArrayList<Object>();
expected.add(Boolean.TRUE);
expected.add("v");
expected.add(null);
- assertEquals(expected, values);
+ assertEquals(expected, wireContext.get("l"));
}
public void testCustomListType() {
WireContext wireContext = createWireContext(
"<objects>" +
- " <list name='l' class='java.util.LinkedList' />" +
+ " <list name='l' class='" + LinkedList.class.getName() + "' />" +
"</objects>"
);
- Object l = wireContext.get("l");
- assertNotNull(l);
- assertEquals("java.util.LinkedList", l.getClass().getName());
+
+ assertSame(LinkedList.class, wireContext.get("l").getClass());
}
public void testInvalidListType() {
@@ -84,7 +80,8 @@
"</objects>"
);
- assertTextPresent("class "+HashSet.class.getName()+" is not a "+List.class.getName(), problems.get(0).getMsg());
+ assertTextPresent("class " + HashSet.class.getName() + " is not a " + List.class.getName(),
+ problems.get(0).getMsg());
}
public void testProblemUnknownValue() {
@@ -103,7 +100,7 @@
public static class TextElement {
String text;
}
-
+
public void testElementsWithInitialization() {
WireContext wireContext = createWireContext(
"<objects>" +
@@ -126,8 +123,10 @@
" </list>" +
"</objects>"
);
+
+ @SuppressWarnings("unchecked")
List<TextElement> l = (List<TextElement>) wireContext.get("l");
- assertEquals(l.toString(), 3, l.size());
+ assertEquals(3, l.size());
assertEquals("a", l.get(0).text);
assertEquals("b", l.get(1).text);
assertEquals("c", l.get(2).text);
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MapWireTest.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -36,7 +36,7 @@
"</objects>"
);
- Map m = (Map) wireContext.get("m");
+ Map<?, ?> m = (Map<?, ?>) wireContext.get("m");
assertEquals(m.toString(), 2, m.size());
assertNull(m.get(Boolean.TRUE));
assertEquals(new Long(5), m.get("a"));
@@ -107,7 +107,7 @@
"</objects>"
);
- Map m = (Map) wireContext.get("m");
+ Map<?, ?> m = (Map<?, ?>) wireContext.get("m");
assertEquals(m.toString(), 2, m.size());
assertEquals("null", m.get("true"));
assertEquals("5", m.get("a"));
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/RefWireTest.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -71,7 +71,7 @@
"</objects>"
);
- List l = (List) wireContext.get("l");
+ List<?> l = (List<?>) wireContext.get("l");
assertNotNull(l);
Object o = wireContext.get("o");
@@ -97,7 +97,7 @@
"</objects>"
);
- Map m = (Map) wireContext.get("m");
+ Map<?, ?> m = (Map<?, ?>) wireContext.get("m");
assertNotNull(m);
Object o = wireContext.get("o");
@@ -116,7 +116,7 @@
"</objects>"
);
- Set s = (Set) wireContext.get("s");
+ Set<?> s = (Set<?>) wireContext.get("s");
assertNotNull(s);
Object o = wireContext.get("o");
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/SetWireTest.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -19,7 +19,7 @@
"</objects>"
);
- Set s = (Set) wireContext.get("s");
+ Set<?> s = (Set<?>) wireContext.get("s");
assertEquals(s.toString(), 4, s.size());
assertTrue(s.contains(Boolean.TRUE));
assertTrue(s.contains(""));
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/binding/TransactionBindingTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/binding/TransactionBindingTest.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/binding/TransactionBindingTest.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -21,16 +21,13 @@
*/
package org.jbpm.pvm.internal.wire.binding;
-import java.util.List;
-import org.jbpm.test.BaseJbpmTestCase;
import org.jbpm.pvm.internal.tx.JtaTransaction;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.jbpm.pvm.internal.xml.Bindings;
-import org.jbpm.pvm.internal.xml.Problem;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Bindings;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.jbpm.test.BaseJbpmTestCase;
-
/**
* @author Huisheng Xu
*/
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java 2010-10-09 09:50:20 UTC (rev 6750)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java 2010-10-09 10:16:53 UTC (rev 6751)
@@ -26,14 +26,17 @@
import javax.transaction.Synchronization;
import org.hibernate.Session;
+import org.hibernate.criterion.Order;
+
import org.jbpm.api.JbpmException;
-import org.jbpm.api.cmd.Command;
import org.jbpm.api.cmd.Environment;
+import org.jbpm.api.cmd.VoidCommand;
import org.jbpm.pvm.internal.cmd.CommandService;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
import org.jbpm.pvm.internal.tx.Transaction;
+import org.jbpm.pvm.internal.util.CollectionUtil;
import org.jbpm.test.JbpmTestCase;
/**
@@ -49,33 +52,38 @@
}
public void testCommit() {
- commandService.execute(new Command<Object>() {
- public Object execute(Environment environment) {
+ commandService.execute(new VoidCommand() {
+ private static final long serialVersionUID = 1L;
+
+ protected void executeVoid(Environment environment) {
Session session = environment.get(Session.class);
session.save(new HistoryCommentImpl("if i only had the time to write code"));
- return null;
}
});
- commandService.execute(new Command<Object>() {
- public Object execute(Environment environment) {
+ commandService.execute(new VoidCommand() {
+ private static final long serialVersionUID = 1L;
+
+ protected void executeVoid(Environment environment) {
Session session = environment.get(Session.class);
- List<HistoryCommentImpl> comments = session.createQuery("from " + HistoryCommentImpl.class.getName()).list();
- assertEquals("if i only had the time to write code", comments.get(0).getMessage());
- session.delete(comments.get(0));
- return null;
+ HistoryCommentImpl comment =
+ (HistoryCommentImpl) session.createCriteria(HistoryCommentImpl.class).uniqueResult();
+ assertEquals("if i only had the time to write code", comment.getMessage());
+ session.delete(comment);
}
});
}
public static class MyOwnRuntimeException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
}
public void testRollbackRuntimeException() {
try {
- commandService.execute(new Command<Object>() {
+ commandService.execute(new VoidCommand() {
+ private static final long serialVersionUID = 1L;
- public Object execute(Environment environment) {
+ protected void executeVoid(Environment environment) {
Session session = environment.get(Session.class);
session.save(new HistoryCommentImpl("if i only had the time to write code"));
throw new MyOwnRuntimeException();
@@ -86,25 +94,27 @@
// OK
}
- commandService.execute(new Command<Object>() {
+ commandService.execute(new VoidCommand() {
+ private static final long serialVersionUID = 1L;
- public Object execute(Environment environment) {
+ protected void executeVoid(Environment environment) {
Session session = environment.get(Session.class);
- List<HistoryDetailImpl> comments = session.createQuery("from " + HistoryDetailImpl.class.getName()).list();
+ List<?> comments = session.createQuery("from " + HistoryDetailImpl.class.getName()).list();
assertEquals(0, comments.size());
- return null;
}
});
}
public static class MyOwnCheckedException extends Exception {
+ private static final long serialVersionUID = 1L;
}
public void testRollbackCheckedException() {
try {
- commandService.execute(new Command<Object>() {
+ commandService.execute(new VoidCommand() {
+ private static final long serialVersionUID = 1L;
- public Object execute(Environment environment) throws Exception {
+ protected void executeVoid(Environment environment) throws Exception {
Session session = environment.get(Session.class);
session.save(new HistoryCommentImpl("if i only had the time to write code"));
throw new MyOwnCheckedException();
@@ -116,13 +126,13 @@
assertSame(MyOwnCheckedException.class, e.getCause().getClass());
}
- commandService.execute(new Command<Object>() {
+ commandService.execute(new VoidCommand() {
+ private static final long serialVersionUID = 1L;
- public Object execute(Environment environment) {
+ protected void executeVoid(Environment environment) {
Session session = environment.get(Session.class);
- List<HistoryDetailImpl> comments = session.createQuery("from " + HistoryDetailImpl.class.getName()).list();
+ List<?> comments = session.createCriteria(HistoryDetailImpl.class).list();
assertEquals(0, comments.size());
- return null;
}
});
}
@@ -139,28 +149,30 @@
}
public void testSuccessfulSynchronization() {
- commandService.execute(new Command<Object>() {
- public Object execute(Environment environment) throws Exception {
+ commandService.execute(new VoidCommand() {
+ private static final long serialVersionUID = 1L;
+
+ protected void executeVoid(Environment environment) throws Exception {
Session session = environment.get(Session.class);
session.save(new HistoryCommentImpl("a) if i only had the time to write code"));
Transaction transaction = environment.get(Transaction.class);
SuccessfulSynchronization successfulSynchronization = new SuccessfulSynchronization();
transaction.registerSynchronization(successfulSynchronization);
- return null;
}
});
- commandService.execute(new Command<Object>() {
- public Object execute(Environment environment) {
+ commandService.execute(new VoidCommand() {
+ private static final long serialVersionUID = 1L;
+
+ protected void executeVoid(Environment environment) {
Session session = environment.get(Session.class);
- List<HistoryCommentImpl> comments = session.createQuery(
- "from " + HistoryCommentImpl.class.getName()+" as hc " +
- "order by hc.message asc ").list();
+ List<HistoryCommentImpl> comments = CollectionUtil.checkList(session.createCriteria(HistoryCommentImpl.class)
+ .addOrder(Order.asc("message"))
+ .list(), HistoryCommentImpl.class);
assertEquals("a) if i only had the time to write code", comments.get(0).getMessage());
assertEquals("b) hello from before completion", comments.get(1).getMessage());
session.delete(comments.get(0));
session.delete(comments.get(1));
- return null;
}
});
}
@@ -179,15 +191,15 @@
public void testUnsuccessfulSynchronization() {
try {
- commandService.execute(new Command<Object>() {
+ commandService.execute(new VoidCommand() {
+ private static final long serialVersionUID = 1L;
- public Object execute(Environment environment) throws Exception {
+ protected void executeVoid(Environment environment) throws Exception {
Session session = environment.get(Session.class);
session.save(new HistoryCommentImpl("a) if i only had the time to write code"));
Transaction transaction = environment.get(Transaction.class);
UnsuccessfulSynchronization unsuccessfulSynchronization = new UnsuccessfulSynchronization();
transaction.registerSynchronization(unsuccessfulSynchronization);
- return null;
}
});
fail("expected exception");
@@ -199,15 +211,14 @@
// caused
// the previous transaction to rollback
- commandService.execute(new Command<Object>() {
+ commandService.execute(new VoidCommand() {
+ private static final long serialVersionUID = 1L;
- public Object execute(Environment environment) {
+ protected void executeVoid(Environment environment) {
Session session = environment.get(Session.class);
- List<HistoryDetailImpl> comments = session.createQuery("from " + HistoryDetailImpl.class.getName()).list();
+ List<?> comments = session.createCriteria(HistoryDetailImpl.class).list();
assertEquals(0, comments.size());
- return null;
}
});
}
-
}
13 years, 7 months
JBoss JBPM SVN: r6750 - in jbpm4/trunk/modules: jpdl/src/test/java/org/jbpm/jpdl/parsing and 1 other directory.
by do-not-reply@jboss.org
Author: rebody
Date: 2010-10-09 05:50:20 -0400 (Sat, 09 Oct 2010)
New Revision: 6750
Added:
jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ObjectParsingTest.java
Modified:
jbpm4/trunk/modules/api/src/main/resources/jpdl-4.5.xsd
Log:
JBPM-2938 add attribute name declaration in jpdl-4.5.xsd.
Modified: jbpm4/trunk/modules/api/src/main/resources/jpdl-4.5.xsd
===================================================================
--- jbpm4/trunk/modules/api/src/main/resources/jpdl-4.5.xsd 2010-10-09 03:46:44 UTC (rev 6749)
+++ jbpm4/trunk/modules/api/src/main/resources/jpdl-4.5.xsd 2010-10-09 09:50:20 UTC (rev 6750)
@@ -692,6 +692,13 @@
<documentation>Reference to an object in the current environment.</documentation>
</annotation>
<complexType>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>The name of the object. Optional, serves as an identifier
+ to refer to this object from other object descriptions.
+ Also used to fetch the object programmatically.</documentation>
+ </annotation>
+ </attribute>
<attribute name="object" type="string" use="required">
<annotation>
<documentation>The name of the referred object.</documentation>
@@ -821,7 +828,24 @@
</element>
<!-- OBJECT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
- <element name="object" type="tns:wireObjectType" />
+ <element name="object">
+ <annotation>
+ <documentation>java.util.Object instance.</documentation>
+ </annotation>
+ <complexType>
+ <complexContent>
+ <extension base="tns:wireObjectType">
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>The name of the object. Optional, serves as an identifier
+ to refer to this object from other object descriptions.
+ Also used to fetch the object programmatically.</documentation>
+ </annotation>
+ </attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+ </element>
<!-- BASIC TYPES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<element name="string">
Added: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ObjectParsingTest.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ObjectParsingTest.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/ObjectParsingTest.java 2010-10-09 09:50:20 UTC (rev 6750)
@@ -0,0 +1,36 @@
+package org.jbpm.jpdl.parsing;
+
+import java.util.List;
+
+import org.jbpm.pvm.internal.xml.Problem;
+
+/**
+ * JBPM-2938.
+ * @author Huisheng Xu
+ */
+public class ObjectParsingTest extends JpdlParseTestCase {
+
+ public void testArgOneValue() {
+ String xmlString = "<process name='MyProcess' version='1' xmlns='http://jbpm.org/4.5/jpdl'>"
+ + " <start name='start'>"
+ + " <transition to='hql'/>"
+ + " </start>"
+ + " <hql name='hql' var='result'>"
+ + " <query>from ExecutionImpl where name=:name and key=:key</query>"
+ + " <parameters>"
+ + " <object name='name' expr='${name}' />"
+ + " <ref name='key' object='key' />"
+ + " </parameters>"
+ + " <transition to='end'/>"
+ + " </hql>"
+ + " <end name='end'/>"
+ + "</process>";
+
+ List<Problem> problems = jpdlParser.createParse()
+ .setString(xmlString)
+ .execute()
+ .getProblems();
+
+ assertEquals(0, problems.size());
+ }
+}
13 years, 7 months