[jbpm-commits] JBoss JBPM SVN: r5771 - in jbpm4/trunk/modules: examples and 5 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Oct 22 08:55:53 EDT 2009
Author: heiko.braun at jboss.com
Date: 2009-10-22 08:55:53 -0400 (Thu, 22 Oct 2009)
New Revision: 5771
Added:
jbpm4/trunk/modules/examples/src/test/resources/process_forms.css
Modified:
jbpm4/trunk/modules/db/jbpm4-db.iml
jbpm4/trunk/modules/examples/jbpm4-examples.iml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/taskform/request_vacation.ftl
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/taskform/verify_request.ftl
jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/AbstractFormDispatcher.java
jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/ProcessFormDispatcher.java
jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/TaskFormDispatcher.java
jbpm4/trunk/modules/test-base/test-base.iml
jbpm4/trunk/modules/test-db/jbpm4-test-db.iml
Log:
Fix BPMC-21: CSS for task forms
Modified: jbpm4/trunk/modules/db/jbpm4-db.iml
===================================================================
--- jbpm4/trunk/modules/db/jbpm4-db.iml 2009-10-22 09:06:27 UTC (rev 5770)
+++ jbpm4/trunk/modules/db/jbpm4-db.iml 2009-10-22 12:55:53 UTC (rev 5771)
@@ -11,9 +11,8 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="pvm" />
<orderEntry type="module" module-name="toplevel" />
- <orderEntry type="module" module-name="api" />
- <orderEntry type="module" module-name="test-base" />
<orderEntry type="module" module-name="jpdl" />
+ <orderEntry type="module" module-name="test-base" />
<orderEntry type="module-library" exported="">
<library name="M2 Dep: antlr:antlr:jar:2.7.6:compile">
<CLASSES>
Modified: jbpm4/trunk/modules/examples/jbpm4-examples.iml
===================================================================
--- jbpm4/trunk/modules/examples/jbpm4-examples.iml 2009-10-22 09:06:27 UTC (rev 5770)
+++ jbpm4/trunk/modules/examples/jbpm4-examples.iml 2009-10-22 12:55:53 UTC (rev 5771)
@@ -10,10 +10,9 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="pvm" exported="" />
- <orderEntry type="module" module-name="toplevel" />
- <orderEntry type="module" module-name="api" />
- <orderEntry type="module" module-name="test-base" />
- <orderEntry type="module" module-name="jpdl" />
+ <orderEntry type="module" module-name="toplevel" exported="" />
+ <orderEntry type="module" module-name="jpdl" exported="" />
+ <orderEntry type="module" module-name="test-base" exported="" />
<orderEntry type="module-library" exported="">
<library name="M2 Dep: jboss:jboss-j2ee:jar:4.2.2.GA:compile">
<CLASSES>
@@ -392,39 +391,39 @@
<SOURCES />
</library>
</orderEntry>
- <orderEntry type="module-library">
- <library name="M2 Dep: antlr:antlr:jar:2.7.6:test">
+ <orderEntry type="module-library" exported="">
+ <library name="M2 Dep: junit:junit:jar:3.8.2:runtime">
<CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar!/" />
+ <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/junit/junit/3.8.2/junit-3.8.2.jar!/" />
</CLASSES>
<JAVADOC />
- <SOURCES />
+ <SOURCES>
+ <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/junit/junit/3.8.2/junit-3.8.2-sources.jar!/" />
+ </SOURCES>
</library>
</orderEntry>
- <orderEntry type="module-library">
- <library name="M2 Dep: commons-collections:commons-collections:jar:3.1:test">
+ <orderEntry type="module-library" exported="">
+ <library name="M2 Dep: antlr:antlr:jar:2.7.6:runtime">
<CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/commons-collections/commons-collections/3.1/commons-collections-3.1.jar!/" />
+ <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar!/" />
</CLASSES>
<JAVADOC />
- <SOURCES>
- <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/commons-collections/commons-collections/3.1/commons-collections-3.1-sources.jar!/" />
- </SOURCES>
+ <SOURCES />
</library>
</orderEntry>
- <orderEntry type="module-library">
- <library name="M2 Dep: junit:junit:jar:3.8.2:runtime">
+ <orderEntry type="module-library" exported="">
+ <library name="M2 Dep: commons-collections:commons-collections:jar:3.1:runtime">
<CLASSES>
- <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/junit/junit/3.8.2/junit-3.8.2.jar!/" />
+ <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/commons-collections/commons-collections/3.1/commons-collections-3.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
- <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/junit/junit/3.8.2/junit-3.8.2-sources.jar!/" />
+ <root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/commons-collections/commons-collections/3.1/commons-collections-3.1-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
- <orderEntry type="module-library">
- <library name="M2 Dep: org.hibernate:hibernate-core:jar:3.3.1.GA:test">
+ <orderEntry type="module-library" exported="">
+ <library name="M2 Dep: org.hibernate:hibernate-core:jar:3.3.1.GA:runtime">
<CLASSES>
<root url="jar://$MODULE_DIR$/../../../../../../../.m2/repository/org/hibernate/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar!/" />
</CLASSES>
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/taskform/request_vacation.ftl
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/taskform/request_vacation.ftl 2009-10-22 09:06:27 UTC (rev 5770)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/taskform/request_vacation.ftl 2009-10-22 12:55:53 UTC (rev 5771)
@@ -1,4 +1,9 @@
<html>
+<head>
+ <style type="text/css">
+ ${CSS!".body {font-family:sans-serif;}"}
+ </style>
+</head>
<body>
<form action="${form.action}" method="POST" enctype="multipart/form-data">
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/taskform/verify_request.ftl
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/taskform/verify_request.ftl 2009-10-22 09:06:27 UTC (rev 5770)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/taskform/verify_request.ftl 2009-10-22 12:55:53 UTC (rev 5771)
@@ -1,4 +1,9 @@
<html>
+<head>
+ <style type="text/css">
+ ${CSS!".body {font-family:sans-serif;}"}
+ </style>
+</head>
<body>
<form action="${form.action}" method="POST" enctype="multipart/form-data">
Added: jbpm4/trunk/modules/examples/src/test/resources/process_forms.css
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/process_forms.css (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/process_forms.css 2009-10-22 12:55:53 UTC (rev 5771)
@@ -0,0 +1,5 @@
+
+body {
+ font-family:sans-serif;
+ background-color: #ffffff;
+}
\ No newline at end of file
Modified: jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/AbstractFormDispatcher.java
===================================================================
--- jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/AbstractFormDispatcher.java 2009-10-22 09:06:27 UTC (rev 5770)
+++ jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/AbstractFormDispatcher.java 2009-10-22 12:55:53 UTC (rev 5771)
@@ -21,23 +21,14 @@
*/
package org.jbpm.integration.console.forms;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
+import java.io.*;
import java.util.Map;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.naming.InitialContext;
-import org.jbpm.api.Configuration;
-import org.jbpm.api.JbpmException;
-import org.jbpm.api.ProcessEngine;
+import org.jbpm.api.*;
import freemarker.template.DefaultObjectWrapper;
import freemarker.template.Template;
@@ -54,6 +45,8 @@
// private static final Log log =
// LogFactory.getLog(AbstractFormDispatcher.class);
+ public static final String PROCESSFORMS_CSS = "process_forms.css";
+
protected final static String WEB_CONTEXT = "/gwt-console-server/rs";
protected ProcessEngine processEngine;
@@ -147,4 +140,35 @@
return merged;
}
+
+ protected String streamToString(InputStream is)
+ {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ StringBuilder sb = new StringBuilder();
+ String line = null;
+
+ try
+ {
+ while ((line = reader.readLine()) != null)
+ {
+ sb.append(line + "\n");
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Failed to read " + PROCESSFORMS_CSS, e);
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Failed to close stream " + PROCESSFORMS_CSS, e);
+ }
+ }
+ return sb.toString();
+ }
}
Modified: jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/ProcessFormDispatcher.java
===================================================================
--- jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/ProcessFormDispatcher.java 2009-10-22 09:06:27 UTC (rev 5770)
+++ jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/ProcessFormDispatcher.java 2009-10-22 12:55:53 UTC (rev 5771)
@@ -21,6 +21,12 @@
*/
package org.jbpm.integration.console.forms;
+import org.jboss.bpm.console.server.plugin.FormAuthorityRef;
+import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.RepositoryService;
+
+import javax.activation.DataHandler;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
@@ -28,13 +34,6 @@
import java.util.List;
import java.util.Map;
-import javax.activation.DataHandler;
-
-import org.jboss.bpm.console.server.plugin.FormAuthorityRef;
-import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
-import org.jbpm.api.ProcessDefinition;
-import org.jbpm.api.RepositoryService;
-
/**
* Processes form data to start processes.
*
@@ -108,10 +107,25 @@
// outcome directive
renderContext.put(OUTCOME_DIRECTIVE_NAME, new OutcomeDirective());
+
+ // global css
+ InputStream css = loadCSS(procDef.getDeploymentId());
+ if(css!=null)
+ renderContext.put("CSS", streamToString(css));
result = processTemplate(startFormResourceName, template, renderContext);
}
return result;
}
+
+ private InputStream loadCSS(String deploymentId)
+ {
+ RepositoryService repoService = processEngine.getRepositoryService();
+
+ InputStream in = repoService.getResourceAsStream(
+ deploymentId, PROCESSFORMS_CSS
+ );
+ return in;
+ }
}
Modified: jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/TaskFormDispatcher.java
===================================================================
--- jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/TaskFormDispatcher.java 2009-10-22 09:06:27 UTC (rev 5770)
+++ jbpm4/trunk/modules/integration/form-plugin/src/main/java/org/jbpm/integration/console/forms/TaskFormDispatcher.java 2009-10-22 12:55:53 UTC (rev 5771)
@@ -22,6 +22,9 @@
package org.jbpm.integration.console.forms;
import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
@@ -32,20 +35,16 @@
import org.jboss.bpm.console.server.plugin.FormAuthorityRef;
import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
-import org.jbpm.api.Execution;
-import org.jbpm.api.ExecutionService;
-import org.jbpm.api.ProcessDefinition;
-import org.jbpm.api.RepositoryService;
-import org.jbpm.api.TaskService;
+import org.jbpm.api.*;
import org.jbpm.api.task.Task;
/**
* Processes form data to complete tasks.
- *
+ *
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
public class TaskFormDispatcher extends AbstractFormDispatcher implements FormDispatcherPlugin {
-
+
public TaskFormDispatcher() {
super();
}
@@ -78,14 +77,15 @@
TaskService taskService = processEngine.getTaskService();
ExecutionService executionService = processEngine.getExecutionService();
RepositoryService repoService = processEngine.getRepositoryService();
+
Task task = taskService.getTask(ref.getReferenceId());
String executionId = task.getExecutionId();
Execution execution = executionService.findExecutionById(executionId);
String procInstId = execution.getProcessInstance().getId();
ProcessDefinition procDef = repoService.createProcessDefinitionQuery()
- .processDefinitionId(execution.getProcessDefinitionId())
- .uniqueResult();
+ .processDefinitionId(execution.getProcessDefinitionId())
+ .uniqueResult();
// check if a template exists
String name = task.getFormResourceName();
@@ -119,10 +119,15 @@
OutcomeDirective outcomeDirective = new OutcomeDirective();
Set<String> outcomes = taskService.getOutcomes(task.getId());
for (String outcome : outcomes) {
- outcomeDirective.getValues().add(outcome);
+ outcomeDirective.getValues().add(outcome);
}
renderContext.put(OUTCOME_DIRECTIVE_NAME, outcomeDirective);
+ // global css
+ InputStream css = loadCSS(task.getExecutionId());
+ if(css!=null)
+ renderContext.put("CSS", streamToString(css));
+
// process variables
renderContext.putAll(processContext);
@@ -130,4 +135,19 @@
return result;
}
+ private InputStream loadCSS(String executionId)
+ {
+ RepositoryService repoService = processEngine.getRepositoryService();
+ ExecutionService execService = processEngine.getExecutionService();
+
+ ProcessInstance instance = execService.createProcessInstanceQuery()
+ .processInstanceId(executionId)
+ .uniqueResult();
+
+ ProcessDefinition definition = repoService.createProcessDefinitionQuery()
+ .processDefinitionId(instance.getProcessDefinitionId()).uniqueResult();
+
+ InputStream in = repoService.getResourceAsStream(definition.getDeploymentId(), PROCESSFORMS_CSS);
+ return in;
+ }
}
Modified: jbpm4/trunk/modules/test-base/test-base.iml
===================================================================
--- jbpm4/trunk/modules/test-base/test-base.iml 2009-10-22 09:06:27 UTC (rev 5770)
+++ jbpm4/trunk/modules/test-base/test-base.iml 2009-10-22 12:55:53 UTC (rev 5771)
@@ -9,7 +9,6 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="toplevel" exported="" />
- <orderEntry type="module" module-name="api" exported="" />
<orderEntry type="module-library" exported="">
<library name="M2 Dep: dom4j:dom4j:jar:1.6.1:compile">
<CLASSES>
Modified: jbpm4/trunk/modules/test-db/jbpm4-test-db.iml
===================================================================
--- jbpm4/trunk/modules/test-db/jbpm4-test-db.iml 2009-10-22 09:06:27 UTC (rev 5770)
+++ jbpm4/trunk/modules/test-db/jbpm4-test-db.iml 2009-10-22 12:55:53 UTC (rev 5771)
@@ -11,9 +11,8 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="pvm" exported="" />
<orderEntry type="module" module-name="toplevel" />
- <orderEntry type="module" module-name="api" />
- <orderEntry type="module" module-name="test-base" />
<orderEntry type="module" module-name="jpdl" />
+ <orderEntry type="module" module-name="test-base" />
<orderEntry type="module-library" exported="">
<library name="M2 Dep: jboss:jboss-j2ee:jar:4.2.2.GA:compile">
<CLASSES>
More information about the jbpm-commits
mailing list