├── .gitignore ├── LICENSE-ASL-2.0.txt ├── README.md ├── rewards-basic ├── README.md ├── pom.xml ├── reward-basic.jmx └── src │ └── main │ ├── java │ └── org │ │ └── jbpm │ │ └── examples │ │ ├── util │ │ ├── RewardsUserGroupCallback.java │ │ └── StartupBean.java │ │ └── web │ │ ├── ProcessServlet.java │ │ └── TaskServlet.java │ ├── resources │ └── META-INF │ │ └── persistence.xml │ └── webapp │ ├── WEB-INF │ ├── jboss-web.xml │ └── web.xml │ ├── index.jsp │ ├── startProcess.jsp │ └── task.jsp └── rewards-cdi-jsf ├── README.md ├── pom.xml └── src └── main ├── java └── org │ └── jbpm │ └── examples │ ├── util │ ├── RewardsApplicationScopedProducer.java │ ├── RewardsIdentityProvider.java │ ├── RewardsUserGroupCallback.java │ ├── StartupBean.java │ └── WebUtil.java │ └── web │ ├── ProcessBean.java │ └── TaskBean.java ├── resources └── META-INF │ ├── persistence.xml │ └── services │ └── javax.enterprise.inject.spi.Extension └── webapp ├── WEB-INF ├── beans.xml ├── faces-config.xml ├── jboss-web.xml ├── templates │ └── default.xhtml └── web.xml ├── approveTask.xhtml ├── index.html ├── index.xhtml ├── listTasks.xhtml └── startProcess.xhtml /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | *.iml 3 | *.idea 4 | .classpath 5 | .gitignore 6 | .project 7 | .settings 8 | 9 | -------------------------------------------------------------------------------- /LICENSE-ASL-2.0.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | jbpm-6-examples 2 | =============== 3 | 4 | Web examples for jBPM 6.2. Distributed under Apache Software License 2.0. Steps to try them can be found in their folders. 5 | 6 | - rewards-basic 7 | - demonstrates jBPM EJB services in combination with servlets and JSP 8 | 9 | - rewards-cdi-jsf 10 | - demonstrates jBPM CDI services in combination with CDI beans and JSF 11 | 12 | -------------------------------------------------------------------------------- /rewards-basic/README.md: -------------------------------------------------------------------------------- 1 | rewards-basic 2 | ============= 3 | 4 | This is an example web application for jBPM 6. It was created by forking the rewards-basic application by Toshiya 5 | Kobayashi: 6 | https://github.com/tkobayas/jbpm5example/tree/master/rewards-basic 7 | 8 | Also the project structure has changed from Java EE 5 to Java EE 6. 9 | The further upgrade was from jBPM 6.0 core APIs to jBPM 6.2 services. 10 | 11 | This simple example aims to provide an example usage of: 12 | - Human tasks 13 | - jBPM EJB services 14 | - Deployment service 15 | - Process service 16 | - Runtime data service 17 | - User task service 18 | - Persistence configuration 19 | - JSP frontend 20 | - Maven build 21 | 22 | ### Steps to run 23 | - Make sure you have at least JDK 6 and Maven 3 installed 24 | - Make sure you have installed org.jbpm.examples:rewards:1.0 maven artifact from [https://github 25 | .com/jsvitak/jbpm-6-examples-assets](https://github.com/jsvitak/jbpm-6-examples-assets) into your local maven repository 26 | - Download JBoss EAP 6.4 from [JBoss](http://www.jboss.org/products/eap/download/) 27 | - Start the application server, for example: 28 | ```sh 29 | cd jboss-eap-6.4.0/bin 30 | ./standalone.sh 31 | ``` 32 | - Build and deploy the example application: 33 | ```sh 34 | cd jbpm-6-examples/rewards-basic 35 | mvn clean package 36 | mvn jboss-as:deploy 37 | ``` 38 | - Visit http://localhost:8080/rewards-basic/ with a web browser 39 | - [Start Reward Process] is to start a new process 40 | - [Jiri's Task] is to list Jiri's tasks and approve them 41 | - [Mary's Task] is to list Mary's tasks and approve them 42 | 43 | 44 | -------------------------------------------------------------------------------- /rewards-basic/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.jbpm.examples 7 | rewards-basic 8 | 6.2.0-SNAPSHOT 9 | war 10 | rewards-basic 11 | 12 | 13 | UTF-8 14 | 6.2.0.Final-redhat-4 15 | 16 | 17 | 18 | 19 | 20 | org.jbpm 21 | jbpm-bom 22 | ${jbpm.version} 23 | import 24 | pom 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | javax.servlet 33 | servlet-api 34 | 2.5 35 | provided 36 | 37 | 38 | org.jboss.spec.javax.ejb 39 | jboss-ejb-api_3.1_spec 40 | 1.0.2.Final 41 | 42 | 43 | org.jboss.spec.javax.annotation 44 | jboss-annotations-api_1.1_spec 45 | 1.0.1.Final 46 | 47 | 48 | 49 | org.kie 50 | kie-api 51 | 52 | 53 | org.jbpm 54 | jbpm-human-task-core 55 | 56 | 57 | org.jbpm 58 | jbpm-kie-services 59 | 60 | 61 | org.jbpm 62 | jbpm-services-api 63 | 64 | 65 | org.jbpm 66 | jbpm-services-ejb-api 67 | 68 | 69 | org.jbpm 70 | jbpm-services-ejb-impl 71 | 72 | 73 | 74 | 75 | dom4j 76 | dom4j 77 | 1.6.1.redhat-6 78 | provided 79 | 80 | 81 | 82 | 83 | 84 | jboss-public-repository 85 | https://repository.jboss.org/nexus/content/groups/public-jboss/ 86 | 87 | 88 | rh-repository 89 | http://maven.repository.redhat.com/techpreview/all 90 | 91 | 92 | 93 | 94 | jboss-public-plugin-repository 95 | https://repository.jboss.org/nexus/content/groups/public-jboss/ 96 | 97 | 98 | 99 | 100 | 101 | 102 | org.jboss.as.plugins 103 | jboss-as-maven-plugin 104 | 7.7.Final 105 | 106 | 107 | org.wildfly.plugins 108 | wildfly-maven-plugin 109 | 1.1.0.Alpha2 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /rewards-basic/reward-basic.jmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | false 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | continue 16 | 17 | false 18 | 5 19 | 20 | 5 21 | 2 22 | 1358396881000 23 | 1358396881000 24 | false 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | false 34 | krisv 35 | = 36 | true 37 | recipient 38 | 39 | 40 | 41 | localhost 42 | 8080 43 | 44 | 45 | 46 | 47 | /rewards-basic/process 48 | POST 49 | true 50 | false 51 | true 52 | false 53 | 4 54 | false 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | localhost 63 | 8080 64 | 65 | 66 | 67 | 68 | /rewards-basic/task?user=jiri&cmd=list 69 | GET 70 | true 71 | false 72 | true 73 | false 74 | 4 75 | false 76 | 77 | 78 | 79 | 80 | false 81 | 82 | saveConfig 83 | 84 | 85 | true 86 | true 87 | true 88 | 89 | true 90 | true 91 | true 92 | true 93 | false 94 | true 95 | true 96 | false 97 | false 98 | true 99 | false 100 | false 101 | false 102 | false 103 | false 104 | 0 105 | true 106 | 107 | 108 | 109 | 110 | 111 | 112 | false 113 | taskId 114 | <td>(.*)</td> 115 | $1$ 116 | 117 | 2 118 | 119 | 120 | 121 | 122 | false 123 | true 124 | false 125 | 126 | 127 | 128 | false 129 | 130 | saveConfig 131 | 132 | 133 | true 134 | true 135 | true 136 | 137 | true 138 | true 139 | true 140 | true 141 | false 142 | true 143 | true 144 | false 145 | false 146 | true 147 | false 148 | false 149 | false 150 | false 151 | false 152 | 0 153 | true 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | false 165 | jiri 166 | = 167 | true 168 | user 169 | 170 | 171 | false 172 | ${taskId} 173 | = 174 | true 175 | taskId 176 | 177 | 178 | false 179 | approve 180 | = 181 | true 182 | cmd 183 | 184 | 185 | 186 | localhost 187 | 8080 188 | 189 | 190 | 191 | 192 | /rewards-basic/task 193 | GET 194 | true 195 | false 196 | true 197 | false 198 | 4 199 | false 200 | 201 | 202 | 203 | 204 | false 205 | 206 | saveConfig 207 | 208 | 209 | true 210 | true 211 | true 212 | 213 | true 214 | true 215 | true 216 | true 217 | false 218 | true 219 | true 220 | false 221 | false 222 | true 223 | false 224 | false 225 | false 226 | false 227 | false 228 | 0 229 | true 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | localhost 241 | 8080 242 | 243 | 244 | 245 | 246 | /rewards-basic/task?user=mary&cmd=list 247 | GET 248 | true 249 | false 250 | true 251 | false 252 | 4 253 | false 254 | 255 | 256 | 257 | 258 | false 259 | 260 | saveConfig 261 | 262 | 263 | true 264 | true 265 | true 266 | 267 | true 268 | true 269 | true 270 | true 271 | false 272 | true 273 | true 274 | false 275 | false 276 | true 277 | false 278 | false 279 | false 280 | false 281 | false 282 | 0 283 | true 284 | 285 | 286 | 287 | 288 | 289 | 290 | false 291 | taskId 292 | <td>(.*)</td> 293 | $1$ 294 | 295 | 2 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | false 304 | mary 305 | = 306 | true 307 | user 308 | 309 | 310 | false 311 | ${taskId} 312 | = 313 | true 314 | taskId 315 | 316 | 317 | false 318 | approve 319 | = 320 | true 321 | cmd 322 | 323 | 324 | 325 | localhost 326 | 8080 327 | 328 | 329 | 330 | 331 | /rewards-basic/task 332 | GET 333 | true 334 | false 335 | true 336 | false 337 | 4 338 | false 339 | 340 | 341 | 342 | 343 | false 344 | 345 | saveConfig 346 | 347 | 348 | true 349 | true 350 | true 351 | 352 | true 353 | true 354 | true 355 | true 356 | false 357 | true 358 | true 359 | false 360 | false 361 | true 362 | false 363 | false 364 | false 365 | false 366 | false 367 | 0 368 | true 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | -------------------------------------------------------------------------------- /rewards-basic/src/main/java/org/jbpm/examples/util/RewardsUserGroupCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015, Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.jbpm.examples.util; 18 | 19 | import org.kie.api.task.UserGroupCallback; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | public class RewardsUserGroupCallback implements UserGroupCallback { 25 | 26 | public boolean existsUser(String userId) { 27 | return userId.equals("jiri") || userId.equals("mary") || userId.equals("Administrator"); 28 | } 29 | 30 | public boolean existsGroup(String groupId) { 31 | return groupId.equals("PM") || groupId.equals("HR"); 32 | } 33 | 34 | public List getGroupsForUser(String userId, 35 | List groupIds, List allExistingGroupIds) { 36 | List groups = new ArrayList(); 37 | if (userId.equals("jiri")) 38 | groups.add("PM"); 39 | else if (userId.equals("mary")) 40 | groups.add("HR"); 41 | return groups; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /rewards-basic/src/main/java/org/jbpm/examples/util/StartupBean.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015, Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.jbpm.examples.util; 18 | 19 | import org.jbpm.kie.services.impl.KModuleDeploymentUnit; 20 | import org.jbpm.services.api.model.DeploymentUnit; 21 | import org.jbpm.services.ejb.api.DeploymentServiceEJBLocal; 22 | 23 | import javax.annotation.PostConstruct; 24 | import javax.ejb.EJB; 25 | import javax.ejb.Singleton; 26 | import javax.ejb.Startup; 27 | 28 | @Singleton 29 | @Startup 30 | public class StartupBean { 31 | 32 | public static final String DEPLOYMENT_ID = "org.jbpm.examples:rewards:1.0"; 33 | 34 | @EJB 35 | DeploymentServiceEJBLocal deploymentService; 36 | 37 | @PostConstruct 38 | public void init() { 39 | System.setProperty("org.jbpm.ht.callback", "custom"); 40 | System.setProperty("org.jbpm.ht.custom.callback", "org.jbpm.examples.util.RewardsUserGroupCallback"); 41 | String[] gav = DEPLOYMENT_ID.split(":"); 42 | DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(gav[0], gav[1], gav[2]); 43 | deploymentService.deploy(deploymentUnit); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /rewards-basic/src/main/java/org/jbpm/examples/web/ProcessServlet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015, Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.jbpm.examples.web; 18 | 19 | 20 | import org.jbpm.examples.util.StartupBean; 21 | import org.jbpm.services.ejb.api.ProcessServiceEJBLocal; 22 | 23 | import javax.ejb.EJB; 24 | import javax.servlet.RequestDispatcher; 25 | import javax.servlet.ServletContext; 26 | import javax.servlet.ServletException; 27 | import javax.servlet.http.HttpServlet; 28 | import javax.servlet.http.HttpServletRequest; 29 | import javax.servlet.http.HttpServletResponse; 30 | import java.io.IOException; 31 | import java.util.HashMap; 32 | import java.util.Map; 33 | 34 | 35 | public class ProcessServlet extends HttpServlet { 36 | 37 | private static final long serialVersionUID = 1L; 38 | 39 | @EJB 40 | private ProcessServiceEJBLocal processService; 41 | 42 | @Override 43 | protected void doPost(HttpServletRequest req, HttpServletResponse res) 44 | throws ServletException, IOException { 45 | 46 | String recipient = req.getParameter("recipient"); 47 | 48 | long processInstanceId = -1; 49 | try { 50 | Map params = new HashMap(); 51 | params.put("recipient", recipient); 52 | processInstanceId = processService.startProcess(StartupBean.DEPLOYMENT_ID, 53 | "org.jbpm.examples.rewards", params); 54 | System.out.println("Process instance " + processInstanceId + " has been successfully started."); 55 | } catch (Exception e) { 56 | throw new ServletException(e); 57 | } 58 | 59 | req.setAttribute("message", "process instance (id = " 60 | + processInstanceId + ") has been started."); 61 | 62 | ServletContext context = this.getServletContext(); 63 | RequestDispatcher dispatcher = context 64 | .getRequestDispatcher("/index.jsp"); 65 | dispatcher.forward(req, res); 66 | } 67 | } -------------------------------------------------------------------------------- /rewards-basic/src/main/java/org/jbpm/examples/web/TaskServlet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015, Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.jbpm.examples.web; 18 | 19 | import org.jbpm.examples.util.StartupBean; 20 | import org.jbpm.services.ejb.api.RuntimeDataServiceEJBLocal; 21 | import org.jbpm.services.ejb.api.UserTaskServiceEJBLocal; 22 | import org.jbpm.services.task.commands.CompleteTaskCommand; 23 | import org.jbpm.services.task.commands.CompositeCommand; 24 | import org.jbpm.services.task.commands.StartTaskCommand; 25 | import org.kie.api.task.model.TaskSummary; 26 | 27 | import javax.ejb.EJB; 28 | import javax.servlet.RequestDispatcher; 29 | import javax.servlet.ServletContext; 30 | import javax.servlet.ServletException; 31 | import javax.servlet.http.HttpServlet; 32 | import javax.servlet.http.HttpServletRequest; 33 | import javax.servlet.http.HttpServletResponse; 34 | import java.io.IOException; 35 | import java.util.List; 36 | 37 | public class TaskServlet extends HttpServlet { 38 | 39 | private static final long serialVersionUID = 1L; 40 | 41 | @EJB 42 | private UserTaskServiceEJBLocal userTaskService; 43 | 44 | @EJB 45 | private RuntimeDataServiceEJBLocal runtimeDataService; 46 | 47 | @Override 48 | protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { 49 | 50 | String cmd = req.getParameter("cmd"); 51 | String user = req.getParameter("user"); 52 | 53 | if (cmd.equals("list")) { 54 | 55 | List taskList; 56 | try { 57 | taskList = runtimeDataService.getTasksAssignedAsPotentialOwner(user, null); 58 | } catch (Exception e) { 59 | throw new ServletException(e); 60 | } 61 | req.setAttribute("taskList", taskList); 62 | ServletContext context = this.getServletContext(); 63 | RequestDispatcher dispatcher = context.getRequestDispatcher("/task.jsp"); 64 | dispatcher.forward(req, res); 65 | 66 | } else if (cmd.equals("approve")) { 67 | 68 | String message; 69 | long taskId = Long.parseLong(req.getParameter("taskId")); 70 | try { 71 | CompositeCommand compositeCommand = new CompositeCommand(new CompleteTaskCommand(taskId, user, null), 72 | new StartTaskCommand(taskId, user)); 73 | userTaskService.execute(StartupBean.DEPLOYMENT_ID, compositeCommand); 74 | message = "Task (id = " + taskId + ") has been completed by " + user; 75 | System.out.println(message); 76 | } catch (Exception e) { 77 | message = "Task operation failed. Please retry : " + e.getMessage(); 78 | throw new ServletException(e); 79 | } 80 | req.setAttribute("message", message); 81 | ServletContext context = this.getServletContext(); 82 | RequestDispatcher dispatcher = context.getRequestDispatcher("/index.jsp"); 83 | dispatcher.forward(req, res); 84 | 85 | } 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /rewards-basic/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | org.hibernate.ejb.HibernatePersistence 13 | java:jboss/datasources/ExampleDS 14 | META-INF/JBPMorm.xml 15 | META-INF/Taskorm.xml 16 | META-INF/TaskAuditorm.xml 17 | 18 | org.drools.persistence.info.SessionInfo 19 | org.drools.persistence.info.WorkItemInfo 20 | 21 | org.jbpm.persistence.processinstance.ProcessInstanceInfo 22 | 23 | org.jbpm.persistence.correlation.CorrelationKeyInfo 24 | org.jbpm.persistence.correlation.CorrelationPropertyInfo 25 | 26 | org.jbpm.process.audit.ProcessInstanceLog 27 | org.jbpm.process.audit.NodeInstanceLog 28 | org.jbpm.process.audit.VariableInstanceLog 29 | 30 | org.jbpm.runtime.manager.impl.jpa.ContextMappingInfo 31 | 32 | org.jbpm.services.task.impl.model.AttachmentImpl 33 | org.jbpm.services.task.impl.model.ContentImpl 34 | org.jbpm.services.task.impl.model.BooleanExpressionImpl 35 | org.jbpm.services.task.impl.model.CommentImpl 36 | org.jbpm.services.task.impl.model.DeadlineImpl 37 | org.jbpm.services.task.impl.model.DelegationImpl 38 | org.jbpm.services.task.impl.model.EscalationImpl 39 | org.jbpm.services.task.impl.model.GroupImpl 40 | org.jbpm.services.task.impl.model.I18NTextImpl 41 | org.jbpm.services.task.impl.model.NotificationImpl 42 | org.jbpm.services.task.impl.model.EmailNotificationImpl 43 | org.jbpm.services.task.impl.model.EmailNotificationHeaderImpl 44 | org.jbpm.services.task.impl.model.PeopleAssignmentsImpl 45 | org.jbpm.services.task.impl.model.ReassignmentImpl 46 | org.jbpm.services.task.impl.model.TaskImpl 47 | org.jbpm.services.task.impl.model.TaskDataImpl 48 | org.jbpm.services.task.impl.model.UserImpl 49 | 50 | org.jbpm.services.task.audit.impl.model.AuditTaskImpl 51 | org.jbpm.services.task.audit.impl.model.BAMTaskSummaryImpl 52 | org.jbpm.services.task.audit.impl.model.TaskEventImpl 53 | 54 | org.jbpm.kie.services.impl.store.DeploymentStoreEntry 55 | 56 | true 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /rewards-basic/src/main/webapp/WEB-INF/jboss-web.xml: -------------------------------------------------------------------------------- 1 | 2 | rewards-basic 3 | -------------------------------------------------------------------------------- /rewards-basic/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | rewards-basic 6 | 7 | 8 | 9 | ProcessServlet 10 | org.jbpm.examples.web.ProcessServlet 11 | 12 | 13 | TaskServlet 14 | org.jbpm.examples.web.TaskServlet 15 | 16 | 17 | 18 | ProcessServlet 19 | /process 20 | 21 | 22 | TaskServlet 23 | /task 24 | 25 | 26 | 27 | 28 | index.jsp 29 | 30 | 31 | -------------------------------------------------------------------------------- /rewards-basic/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" %> 2 | 3 | 4 | 5 | 6 | Rewards Basic example 7 | 8 | 9 |

Rewards Basic example

10 |

<%= request.getAttribute("message") == null ? "" : request.getAttribute("message") %>

11 | 16 | 17 | -------------------------------------------------------------------------------- /rewards-basic/src/main/webapp/startProcess.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" %> 2 | 3 | 4 | 5 | 6 | Start a process 7 | 8 | 9 |

Select a recipient

10 |
11 | 12 | 13 |
14 | 15 | -------------------------------------------------------------------------------- /rewards-basic/src/main/webapp/task.jsp: -------------------------------------------------------------------------------- 1 | <%@ page import="org.kie.api.task.model.TaskSummary" %> 2 | <%@ page import="java.util.List" %> 3 | <%@ page contentType="text/html;charset=UTF-8" %> 4 | 5 | 6 | 7 | 8 | Task management 9 | 10 | 11 | <% String user = request.getParameter("user"); %> 12 |

<%= user %>'s Task

13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | <% for (TaskSummary task : (List)request.getAttribute("taskList")) { %> 21 | 22 | 23 | 24 | 25 | 26 | 27 | <% } %> 28 |
Task NameTask IdProcessInstance IdAction
<%= task.getName() %><%= task.getId() %><%= task.getProcessInstanceId() %>Approve
29 | 30 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/README.md: -------------------------------------------------------------------------------- 1 | rewards-cdi-jsf 2 | =============== 3 | 4 | This simple rewards-cdi-jsf example web application is a modification of rewards-basic application 5 | to demonstrate jBPM 6.2 services in combination with CDI and JSF frameworks, in particular: 6 | - Human tasks including data passing and forms 7 | - jBPM CDI services 8 | - Deployment service 9 | - Process service 10 | - Runtime data service 11 | - User task service 12 | - Persistence configuration 13 | - Context and Dependency Injection beans 14 | - Java Server Faces frontend 15 | - Maven build 16 | 17 | ### Steps to run 18 | - Make sure you have at least JDK 6 and Maven 3 installed 19 | - Make sure you have installed org.jbpm.examples:rewards:1.0 maven artifact from [https://github 20 | .com/jsvitak/jbpm-6-examples-assets](https://github.com/jsvitak/jbpm-6-examples-assets) into your local maven repository 21 | - Download JBoss EAP 6.4 from [JBoss](http://www.jboss.org/products/eap/download/) 22 | - Start the application server, for example: 23 | ```sh 24 | cd jboss-eap-6.4.0/bin 25 | ./standalone.sh 26 | ``` 27 | - Build and deploy the example application: 28 | ```sh 29 | cd jbpm-6-examples/rewards-cdi-jsf 30 | mvn clean package 31 | mvn jboss-as:deploy 32 | ``` 33 | - Visit [http://localhost:8080/rewards-jsf/](http://localhost:8080/rewards-cdi-jsf/) with a web browser 34 | - [Start Reward Process] is to start a new process 35 | - [Jiri's Task] is to list Jiri's tasks and approve them 36 | - [Mary's Task] is to list Mary's tasks and approve them 37 | 38 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.jbpm.examples 7 | rewards-cdi-jsf 8 | 6.2.0-SNAPSHOT 9 | war 10 | rewards-cdi-jsf 11 | 12 | 13 | UTF-8 14 | 1.0.7.Final 15 | 6.2.0.Final-redhat-4 16 | 17 | 18 | 19 | 20 | 21 | org.jboss.bom 22 | jboss-javaee-6.0-with-hibernate 23 | ${jboss.bom.version} 24 | pom 25 | import 26 | 27 | 28 | org.jbpm 29 | jbpm-bom 30 | ${jbpm.version} 31 | import 32 | pom 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.hibernate.javax.persistence 41 | hibernate-jpa-2.0-api 42 | provided 43 | 44 | 45 | org.jboss.spec.javax.faces 46 | jboss-jsf-api_2.1_spec 47 | provided 48 | 49 | 50 | 51 | org.kie 52 | kie-api 53 | 54 | 55 | org.jbpm 56 | jbpm-human-task-core 57 | 58 | 59 | org.jbpm 60 | jbpm-kie-services 61 | 62 | 63 | org.jbpm 64 | jbpm-services-api 65 | 66 | 67 | org.jbpm 68 | jbpm-services-cdi 69 | 70 | 71 | 72 | 73 | dom4j 74 | dom4j 75 | 1.6.1.redhat-6 76 | provided 77 | 78 | 79 | 80 | 81 | 82 | jboss-public-repository 83 | https://repository.jboss.org/nexus/content/groups/public-jboss/ 84 | 85 | 86 | rh-repository 87 | http://maven.repository.redhat.com/techpreview/all 88 | 89 | 90 | 91 | 92 | jboss-public-plugin-repository 93 | https://repository.jboss.org/nexus/content/groups/public-jboss/ 94 | 95 | 96 | 97 | 98 | 99 | 100 | org.jboss.as.plugins 101 | jboss-as-maven-plugin 102 | 7.7.Final 103 | 104 | 105 | org.wildfly.plugins 106 | wildfly-maven-plugin 107 | 1.1.0.Alpha2 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/java/org/jbpm/examples/util/RewardsApplicationScopedProducer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015, Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.jbpm.examples.util; 18 | 19 | import org.jbpm.services.api.DeploymentService; 20 | import org.jbpm.services.cdi.Kjar; 21 | import org.jbpm.services.task.audit.JPATaskLifeCycleEventListener; 22 | import org.kie.api.task.TaskLifeCycleEventListener; 23 | 24 | import javax.enterprise.context.ApplicationScoped; 25 | import javax.enterprise.inject.Instance; 26 | import javax.enterprise.inject.Produces; 27 | import javax.enterprise.util.AnnotationLiteral; 28 | import javax.inject.Inject; 29 | import javax.persistence.EntityManagerFactory; 30 | import javax.persistence.Persistence; 31 | import javax.persistence.PersistenceUnit; 32 | 33 | @ApplicationScoped 34 | public class RewardsApplicationScopedProducer { 35 | 36 | @PersistenceUnit(unitName = "org.jbpm.domain") 37 | private EntityManagerFactory emf; 38 | 39 | @Produces 40 | public EntityManagerFactory produceEntityManagerFactory() { 41 | if (this.emf == null) { 42 | this.emf = Persistence 43 | .createEntityManagerFactory("org.jbpm.domain"); 44 | } 45 | return this.emf; 46 | } 47 | 48 | @Inject 49 | @Kjar 50 | private Instance deploymentService; 51 | 52 | @Produces 53 | public DeploymentService produceDeploymentService() { 54 | return deploymentService.select(new AnnotationLiteral() {}).get(); 55 | } 56 | 57 | @Produces 58 | public TaskLifeCycleEventListener produceAuditListener() { 59 | return new JPATaskLifeCycleEventListener(true); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/java/org/jbpm/examples/util/RewardsIdentityProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015, Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.jbpm.examples.util; 18 | 19 | import org.kie.internal.identity.IdentityProvider; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | public class RewardsIdentityProvider implements IdentityProvider { 25 | 26 | private List roles = new ArrayList(); 27 | 28 | @Override 29 | public String getName() { 30 | return "system"; 31 | } 32 | 33 | @Override 34 | public List getRoles() { 35 | return roles; 36 | } 37 | 38 | @Override 39 | public boolean hasRole(String s) { 40 | return true; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/java/org/jbpm/examples/util/RewardsUserGroupCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015, Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.jbpm.examples.util; 18 | 19 | import org.kie.api.task.UserGroupCallback; 20 | 21 | import javax.enterprise.context.ApplicationScoped; 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | @ApplicationScoped 26 | public class RewardsUserGroupCallback implements UserGroupCallback { 27 | 28 | public boolean existsUser(String userId) { 29 | return userId.equals("jiri") || userId.equals("mary") || userId.equals("Administrator"); 30 | } 31 | 32 | public boolean existsGroup(String groupId) { 33 | return groupId.equals("PM") || groupId.equals("HR"); 34 | } 35 | 36 | public List getGroupsForUser(String userId, 37 | List groupIds, List allExistingGroupIds) { 38 | List groups = new ArrayList(); 39 | if (userId.equals("jiri")) 40 | groups.add("PM"); 41 | else if (userId.equals("mary")) 42 | groups.add("HR"); 43 | return groups; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/java/org/jbpm/examples/util/StartupBean.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015, Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.jbpm.examples.util; 18 | 19 | import org.jbpm.kie.services.impl.KModuleDeploymentUnit; 20 | import org.jbpm.services.api.DeploymentService; 21 | import org.jbpm.services.api.model.DeploymentUnit; 22 | import org.jbpm.services.cdi.Kjar; 23 | import org.kie.internal.runtime.cdi.BootOnLoad; 24 | 25 | import javax.annotation.PostConstruct; 26 | import javax.enterprise.context.ApplicationScoped; 27 | import javax.inject.Inject; 28 | 29 | @ApplicationScoped 30 | @BootOnLoad 31 | public class StartupBean { 32 | 33 | public static final String DEPLOYMENT_ID = "org.jbpm.examples:rewards:1.0"; 34 | 35 | @Inject 36 | @Kjar 37 | DeploymentService deploymentService; 38 | 39 | @PostConstruct 40 | public void init() { 41 | String[] gav = DEPLOYMENT_ID.split(":"); 42 | DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(gav[0], gav[1], gav[2]); 43 | deploymentService.deploy(deploymentUnit); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/java/org/jbpm/examples/util/WebUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015, Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.jbpm.examples.util; 18 | 19 | import javax.annotation.PostConstruct; 20 | import javax.enterprise.context.RequestScoped; 21 | import javax.enterprise.inject.Produces; 22 | import javax.enterprise.inject.spi.InjectionPoint; 23 | import javax.faces.context.FacesContext; 24 | import java.util.logging.Logger; 25 | 26 | @RequestScoped 27 | public class WebUtil { 28 | 29 | private FacesContext facesContext; 30 | 31 | @PostConstruct 32 | private void init() { 33 | facesContext = FacesContext.getCurrentInstance(); 34 | } 35 | 36 | @Produces 37 | public FacesContext produceFacesContext() { 38 | return facesContext; 39 | } 40 | 41 | @Produces 42 | public Logger produceLog(InjectionPoint injectionPoint) { 43 | return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/java/org/jbpm/examples/web/ProcessBean.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015, Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.jbpm.examples.web; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | import java.util.logging.Level; 22 | import java.util.logging.Logger; 23 | 24 | import javax.enterprise.inject.Model; 25 | import javax.faces.context.FacesContext; 26 | import javax.inject.Inject; 27 | 28 | import org.jbpm.examples.util.StartupBean; 29 | import org.jbpm.services.api.ProcessService; 30 | 31 | @Model 32 | public class ProcessBean { 33 | 34 | @Inject 35 | ProcessService processService; 36 | 37 | @Inject 38 | FacesContext facesContext; 39 | 40 | @Inject 41 | Logger logger; 42 | 43 | private String recipient; 44 | private int reward = 200; 45 | 46 | public void setRecipient(String recipient) { 47 | this.recipient = recipient; 48 | } 49 | 50 | public String getRecipient() { 51 | return recipient; 52 | } 53 | 54 | public int getReward() { 55 | return reward; 56 | } 57 | 58 | public void setReward(int reward) { 59 | this.reward = reward; 60 | } 61 | 62 | public String startProcess() { 63 | String message; 64 | long processInstanceId = -1; 65 | try { 66 | Map params = new HashMap(); 67 | params.put("recipient", recipient); 68 | params.put("reward", reward); 69 | processInstanceId = processService.startProcess(StartupBean.DEPLOYMENT_ID, 70 | "org.jbpm.examples.rewards", params); 71 | message = "Process instance " + processInstanceId + " has been successfully started." ; 72 | logger.info(message); 73 | } catch (Exception e) { 74 | message = "Unable to start the business process."; 75 | logger.log(Level.SEVERE, message, e); 76 | } 77 | facesContext.getExternalContext().getFlash() 78 | .put("msg", message); 79 | return "index.xhtml?faces-redirect=true"; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/java/org/jbpm/examples/web/TaskBean.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015, Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.jbpm.examples.web; 18 | 19 | import java.util.HashMap; 20 | import java.util.List; 21 | import java.util.Map; 22 | import java.util.logging.Level; 23 | import java.util.logging.Logger; 24 | 25 | import javax.enterprise.inject.Model; 26 | import javax.enterprise.inject.Produces; 27 | import javax.faces.context.FacesContext; 28 | import javax.inject.Inject; 29 | 30 | import org.jbpm.examples.util.StartupBean; 31 | import org.jbpm.services.api.RuntimeDataService; 32 | import org.jbpm.services.api.UserTaskService; 33 | import org.jbpm.services.task.commands.CompleteTaskCommand; 34 | import org.jbpm.services.task.commands.CompositeCommand; 35 | import org.jbpm.services.task.commands.StartTaskCommand; 36 | import org.kie.api.task.model.Task; 37 | import org.kie.api.task.model.TaskSummary; 38 | 39 | @Model 40 | public class TaskBean { 41 | 42 | @Inject 43 | private UserTaskService userTaskService; 44 | 45 | @Inject 46 | private RuntimeDataService runtimeDataService; 47 | 48 | @Inject 49 | FacesContext facesContext; 50 | 51 | @Inject 52 | Logger logger; 53 | 54 | private String comment; 55 | private Map content; 56 | private Task task; 57 | private long taskId; 58 | private String user; 59 | private List tasks; 60 | 61 | public String getComment() { 62 | return comment; 63 | } 64 | 65 | public void setComment(String comment) { 66 | this.comment = comment; 67 | } 68 | 69 | public Map getContent() { 70 | return content; 71 | } 72 | 73 | public void setContent(Map content) { 74 | this.content = content; 75 | } 76 | 77 | public Task getTask() { 78 | return task; 79 | } 80 | 81 | public void setTask(Task task) { 82 | this.task = task; 83 | } 84 | 85 | public long getTaskId() { 86 | return taskId; 87 | } 88 | 89 | public void setTaskId(long taskId) { 90 | this.taskId = taskId; 91 | } 92 | 93 | public String getUser() { 94 | return user; 95 | } 96 | 97 | public void setUser(String user) { 98 | this.user = user; 99 | } 100 | 101 | @Produces 102 | public List getTasks() { 103 | return tasks; 104 | } 105 | 106 | 107 | public void retrieveTasks () { 108 | String message; 109 | try { 110 | tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(user, null); 111 | message = "Retrieved " + tasks.size() + " task(s) for user " + user + "."; 112 | logger.info(message); 113 | } catch (Exception e) { 114 | message = "Cannot retrieve task list for user " + user + "."; 115 | logger.log(Level.SEVERE, message, e); 116 | facesContext.getExternalContext().getFlash() 117 | .put("msg", message); 118 | } 119 | } 120 | 121 | public void queryTask() { 122 | String message; 123 | try { 124 | task = userTaskService.getTask(taskId); 125 | content = userTaskService.getTaskInputContentByTaskId(taskId); 126 | message = "Loaded task " + taskId + "."; 127 | logger.info(message); 128 | } catch (Exception e) { 129 | message = "Unable to query for task with id = " + taskId; 130 | logger.log(Level.SEVERE, message, e); 131 | facesContext.getExternalContext().getFlash() 132 | .put("msg", message); 133 | } 134 | } 135 | 136 | public String approveTask() { 137 | String message; 138 | try { 139 | Map outputParams = new HashMap(); 140 | outputParams.put("out_comment", comment); 141 | CompositeCommand compositeCommand = new CompositeCommand(new CompleteTaskCommand(taskId, user, 142 | outputParams), 143 | new StartTaskCommand(taskId, user)); 144 | userTaskService.execute(StartupBean.DEPLOYMENT_ID, compositeCommand); 145 | message = "Task (id = " + taskId + ") has been completed by " + user; 146 | logger.info(message); 147 | } catch (Exception e) { 148 | message = "Unable to approve the task " + taskId + "."; 149 | logger.log(Level.SEVERE, message, e); 150 | } 151 | facesContext.getExternalContext().getFlash() 152 | .put("msg", message); 153 | return "index.xhtml?faces-redirect=true"; 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | org.hibernate.ejb.HibernatePersistence 13 | java:jboss/datasources/ExampleDS 14 | META-INF/JBPMorm.xml 15 | META-INF/Taskorm.xml 16 | META-INF/TaskAuditorm.xml 17 | META-INF/Servicesorm.xml 18 | 19 | org.drools.persistence.info.SessionInfo 20 | org.drools.persistence.info.WorkItemInfo 21 | 22 | org.jbpm.persistence.processinstance.ProcessInstanceInfo 23 | 24 | org.jbpm.persistence.correlation.CorrelationKeyInfo 25 | org.jbpm.persistence.correlation.CorrelationPropertyInfo 26 | 27 | org.jbpm.process.audit.ProcessInstanceLog 28 | org.jbpm.process.audit.NodeInstanceLog 29 | org.jbpm.process.audit.VariableInstanceLog 30 | 31 | org.jbpm.runtime.manager.impl.jpa.ContextMappingInfo 32 | 33 | org.jbpm.services.task.impl.model.AttachmentImpl 34 | org.jbpm.services.task.impl.model.ContentImpl 35 | org.jbpm.services.task.impl.model.BooleanExpressionImpl 36 | org.jbpm.services.task.impl.model.CommentImpl 37 | org.jbpm.services.task.impl.model.DeadlineImpl 38 | org.jbpm.services.task.impl.model.DelegationImpl 39 | org.jbpm.services.task.impl.model.EscalationImpl 40 | org.jbpm.services.task.impl.model.GroupImpl 41 | org.jbpm.services.task.impl.model.I18NTextImpl 42 | org.jbpm.services.task.impl.model.NotificationImpl 43 | org.jbpm.services.task.impl.model.EmailNotificationImpl 44 | org.jbpm.services.task.impl.model.EmailNotificationHeaderImpl 45 | org.jbpm.services.task.impl.model.PeopleAssignmentsImpl 46 | org.jbpm.services.task.impl.model.ReassignmentImpl 47 | org.jbpm.services.task.impl.model.TaskImpl 48 | org.jbpm.services.task.impl.model.TaskDataImpl 49 | org.jbpm.services.task.impl.model.UserImpl 50 | 51 | org.jbpm.services.task.audit.impl.model.AuditTaskImpl 52 | org.jbpm.services.task.audit.impl.model.BAMTaskSummaryImpl 53 | org.jbpm.services.task.audit.impl.model.TaskEventImpl 54 | 55 | org.jbpm.kie.services.impl.store.DeploymentStoreEntry 56 | 57 | true 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension: -------------------------------------------------------------------------------- 1 | org.kie.internal.runtime.cdi.BootOnLoadExtension -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/webapp/WEB-INF/faces-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/webapp/WEB-INF/jboss-web.xml: -------------------------------------------------------------------------------- 1 | 2 | rewards-cdi-jsf 3 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/webapp/WEB-INF/templates/default.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | rewards-jsf example 9 | 10 | 11 | 12 |
13 |
14 | 15 |
16 |
17 | 18 | [Template content will be inserted here] 19 | 20 |
21 |
22 |
23 | 24 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | rewards-cdi-jsf 5 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/webapp/approveTask.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Task Id 21 | #{taskBean.task.id} 22 | Created by 23 | #{taskBean.task.taskData.createdBy.id} 24 | Task Status 25 | #{taskBean.task.taskData.status} 26 | Recipient 27 | #{taskBean.content.get("in_recipient")} 28 | Reward 29 | #{taskBean.content.get("in_reward")} 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/webapp/index.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 |

Welcome to rewards-jsf example!

8 |
    9 |
  • Start a business process
  • 10 |
  • Jiri's tasks
  • 11 |
  • Mary's tasks
  • 12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/webapp/listTasks.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | User #{taskBean.user} has no pending tasks. 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /rewards-cdi-jsf/src/main/webapp/startProcess.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | --------------------------------------------------------------------------------