jruby_activiti 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 069365f07f70a49842d0fdb3d67200b0b08167d0
4
+ data.tar.gz: 9fcb6cef01bfa9bbc1d81e11add320c6cdc65cf4
5
+ SHA512:
6
+ metadata.gz: 1252e614ff4e3130c069513edfad098b58482296214587a726e29ca3057f84302febf23dda35202d4a6dfae16191027643252d09994d6162ec1c1c4d99e1ce14
7
+ data.tar.gz: 064aa1456a40a627cf0a02c8e9a21df6d73cd0f5e9e80a2896d1f5a1dfceb07aeada1c17a38b3c9464bdc3fef9150ed2fbe3591ea4d1686c774a148b8ed7cfec
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ /.jbundler/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jruby_activiti.gemspec
4
+ gemspec
data/Jarfile ADDED
@@ -0,0 +1,3 @@
1
+ jar 'org.activiti:activiti-engine', '~> 5.18'
2
+ jar 'org.slf4j:slf4j-log4j12', '>= 1.7'
3
+ jar 'com.h2database:h2', '>= 1.4'
data/Jarfile.lock ADDED
@@ -0,0 +1,25 @@
1
+ ---
2
+ :runtime:
3
+ - org.activiti:activiti-bpmn-model:jar:5.18.0
4
+ - org.apache.commons:commons-email:jar:1.4
5
+ - org.activiti:activiti-bpmn-converter:jar:5.18.0
6
+ - com.sun.mail:javax.mail:jar:1.5.2
7
+ - log4j:log4j:jar:1.2.17
8
+ - org.slf4j:slf4j-api:jar:1.7.6
9
+ - org.yaml:snakeyaml:jar:1.14
10
+ - com.fasterxml.jackson.core:jackson-databind:jar:2.2.3
11
+ - org.activiti:activiti-image-generator:jar:5.18.0
12
+ - org.springframework:spring-core:jar:4.1.5.RELEASE
13
+ - commons-logging:commons-logging:jar:1.2
14
+ - org.slf4j:jcl-over-slf4j:jar:1.7.6
15
+ - org.mybatis:mybatis:jar:3.2.5
16
+ - com.h2database:h2:jar:1.4.190
17
+ - org.activiti:activiti-process-validation:jar:5.18.0
18
+ - com.fasterxml.jackson.core:jackson-annotations:jar:2.2.3
19
+ - joda-time:joda-time:jar:2.6
20
+ - javax.activation:activation:jar:1.1.1
21
+ - org.apache.commons:commons-lang3:jar:3.3.2
22
+ - com.fasterxml.jackson.core:jackson-core:jar:2.2.3
23
+ - org.slf4j:slf4j-log4j12:jar:1.7.12
24
+ - org.activiti:activiti-engine:jar:5.18.0
25
+ - org.springframework:spring-beans:jar:4.1.5.RELEASE
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # JrubyActiviti
2
+
3
+ Wrapping Activiti BPM in a gem. So you can directly access Activiti BPM in Ruby Web Application.
4
+ Inspired by https://github.com/boberetezeke/jruby-activiti.
5
+
6
+ ## Test Environments
7
+ JRuby-9.0.3.0, Activiti-5.18.0
8
+
9
+ ## Installation
10
+
11
+ Git clone this project.
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'jruby_activiti', path: 'xxx'
17
+ ```
18
+
19
+ create a `Jarfile`. Example:
20
+
21
+ ```
22
+ jar 'org.activiti:activiti-engine', '~> 5.18'
23
+ jar 'org.slf4j:slf4j-log4j12', '>= 1.7'
24
+ jar 'com.h2database:h2', '>= 1.4'
25
+ ```
26
+
27
+ And then execute:
28
+ ```
29
+ $ bundle install
30
+ $ jbundle install
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ Create activiti config file. `config/activiti.cfg.xml`
36
+ ```
37
+ <beans xmlns="http://www.springframework.org/schema/beans"
38
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
39
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
40
+
41
+ <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
42
+ <property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
43
+ <property name="jdbcDriver" value="org.h2.Driver" />
44
+ <property name="jdbcUsername" value="sa" />
45
+ <property name="jdbcPassword" value="" />
46
+ </bean>
47
+
48
+ </beans>
49
+ ```
50
+
51
+ Now, You can access Activiti directly by using `ActivitiEngine`. For example, in a Rails controller
52
+
53
+ ```
54
+ repositoryService = ActivitiEngine.getRepositoryService()
55
+ repositoryService.createDeployment().
56
+ addClasspathResource("config/your_bpm_xml_file.bpmn20.xml").
57
+ deploy()
58
+ ```
59
+
60
+ ## Warning
61
+ Do not create Activiti Engine in a Rails application repeatedly. Otherwise you will get exception `log writing failed. Bad file descriptor - Bad file descriptor`
62
+
63
+ ## Contributing
64
+
65
+ 1. Fork it ( https://github.com/richfisher/jruby_activiti/fork )
66
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
67
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
68
+ 4. Push to the branch (`git push origin my-new-feature`)
69
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'test'
7
+ t.pattern = "test/*_test.rb"
8
+ end
9
+
10
+ desc "Run tests"
11
+ task :default => :test
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jruby_activiti/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jruby_activiti"
8
+ spec.version = JrubyActiviti::VERSION
9
+ spec.authors = ["richfisher"]
10
+ spec.email = ["richfisher.pan@gmail.com"]
11
+ spec.summary = "Interact with Activiti BPM in Jruby, http://activiti.org/"
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/richfisher/jruby_activiti"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "minitest", '>= 5.8'
22
+
23
+ spec.add_dependency "jbundler", '>= 0.9'
24
+ end
@@ -0,0 +1,3 @@
1
+ module JrubyActiviti
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,13 @@
1
+ require "jruby_activiti/version"
2
+
3
+ require "jbundler"
4
+ Bundler.require "activiti-engine"
5
+
6
+ ActivitiConfigPath ||= "config/activiti.cfg.xml"
7
+ configuration = Java::OrgActivitiEngine::ProcessEngineConfiguration.
8
+ createProcessEngineConfigurationFromResource(ActivitiConfigPath)
9
+ ActivitiEngine = configuration.buildProcessEngine
10
+
11
+ module JrubyActiviti
12
+ # Your code goes here...
13
+ end
@@ -0,0 +1,91 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <definitions id="definitions"
3
+ targetNamespace="http://activiti.org/bpmn20"
4
+ xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
5
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
+ xmlns:activiti="http://activiti.org/bpmn">
7
+
8
+ <process id="vacationRequest" name="Vacation request">
9
+
10
+ <startEvent id="request" activiti:initiator="employeeName">
11
+ <extensionElements>
12
+ <activiti:formProperty id="numberOfDays" name="Number of days" type="long" value="1" required="true"/>
13
+ <activiti:formProperty id="startDate" name="First day of holiday (dd-MM-yyy)" datePattern="dd-MM-yyyy hh:mm" type="date" required="true" />
14
+ <activiti:formProperty id="vacationMotivation" name="Motivation" type="string" />
15
+ </extensionElements>
16
+ </startEvent>
17
+
18
+ <scriptTask id="theScriptTask" name="Execute script" scriptFormat="jruby" activiti:autoStoreVariables="false">
19
+ <script>puts "hello, this is a script task."</script>
20
+ </scriptTask>
21
+
22
+ <sequenceFlow id="flow1" sourceRef="request" targetRef="theScriptTask" />
23
+ <sequenceFlow id="flow1_1" sourceRef="theScriptTask" targetRef="handleRequest" />
24
+
25
+ <userTask id="handleRequest" name="Handle vacation request" >
26
+ <documentation>
27
+ ${employeeName} would like to take ${numberOfDays} day(s) of vacation (Motivation: ${vacationMotivation}).
28
+ </documentation>
29
+ <extensionElements>
30
+ <activiti:formProperty id="vacationApproved" name="Do you approve this vacation" type="enum" required="true">
31
+ <activiti:value id="true" name="Approve" />
32
+ <activiti:value id="false" name="Reject" />
33
+ </activiti:formProperty>
34
+ <activiti:formProperty id="managerMotivation" name="Motivation" type="string" />
35
+ </extensionElements>
36
+ <potentialOwner>
37
+ <resourceAssignmentExpression>
38
+ <formalExpression>management</formalExpression>
39
+ </resourceAssignmentExpression>
40
+ </potentialOwner>
41
+ </userTask>
42
+ <sequenceFlow id="flow2" sourceRef="handleRequest" targetRef="requestApprovedDecision" />
43
+
44
+ <exclusiveGateway id="requestApprovedDecision" name="Request approved?" />
45
+ <sequenceFlow id="flow3" sourceRef="requestApprovedDecision" targetRef="sendApprovalMail">
46
+ <conditionExpression xsi:type="tFormalExpression">${vacationApproved == 'true'}</conditionExpression>
47
+ </sequenceFlow>
48
+
49
+ <task id="sendApprovalMail" name="Send confirmation e-mail" />
50
+ <sequenceFlow id="flow4" sourceRef="sendApprovalMail" targetRef="theEnd1" />
51
+ <endEvent id="theEnd1" />
52
+
53
+ <sequenceFlow id="flow5" sourceRef="requestApprovedDecision" targetRef="adjustVacationRequestTask">
54
+ <conditionExpression xsi:type="tFormalExpression">${vacationApproved == 'false'}</conditionExpression>
55
+ </sequenceFlow>
56
+
57
+ <userTask id="adjustVacationRequestTask" name="Adjust vacation request">
58
+ <documentation>
59
+ Your manager has disapproved your vacation request for ${numberOfDays} days.
60
+ Reason: ${managerMotivation}
61
+ </documentation>
62
+ <extensionElements>
63
+ <activiti:formProperty id="numberOfDays" name="Number of days" value="${numberOfDays}" type="long" required="true"/>
64
+ <activiti:formProperty id="startDate" name="First day of holiday (dd-MM-yyy)" value="${startDate}" datePattern="dd-MM-yyyy hh:mm" type="date" required="true" />
65
+ <activiti:formProperty id="vacationMotivation" name="Motivation" value="${vacationMotivation}" type="string" />
66
+ <activiti:formProperty id="resendRequest" name="Resend vacation request to manager?" type="enum" required="true">
67
+ <activiti:value id="true" name="Yes" />
68
+ <activiti:value id="false" name="No" />
69
+ </activiti:formProperty>
70
+ </extensionElements>
71
+ <humanPerformer>
72
+ <resourceAssignmentExpression>
73
+ <formalExpression>${employeeName}</formalExpression>
74
+ </resourceAssignmentExpression>
75
+ </humanPerformer>
76
+ </userTask>
77
+ <sequenceFlow id="flow6" sourceRef="adjustVacationRequestTask" targetRef="resendRequestDecision" />
78
+
79
+ <exclusiveGateway id="resendRequestDecision" name="Resend request?" />
80
+ <sequenceFlow id="flow7" sourceRef="resendRequestDecision" targetRef="handleRequest">
81
+ <conditionExpression xsi:type="tFormalExpression">${resendRequest == 'true'}</conditionExpression>
82
+ </sequenceFlow>
83
+
84
+ <sequenceFlow id="flow8" sourceRef="resendRequestDecision" targetRef="theEnd2">
85
+ <conditionExpression xsi:type="tFormalExpression">${resendRequest == 'false'}</conditionExpression>
86
+ </sequenceFlow>
87
+ <endEvent id="theEnd2" />
88
+
89
+ </process>
90
+
91
+ </definitions>
@@ -0,0 +1,20 @@
1
+ <beans xmlns="http://www.springframework.org/schema/beans"
2
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
4
+
5
+ <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
6
+
7
+ <property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
8
+ <property name="jdbcDriver" value="org.h2.Driver" />
9
+ <property name="jdbcUsername" value="sa" />
10
+ <property name="jdbcPassword" value="" />
11
+
12
+ <property name="databaseSchemaUpdate" value="true" />
13
+
14
+ <property name="jobExecutorActivate" value="false" />
15
+
16
+ <property name="mailServerHost" value="mail.my-corp.com" />
17
+ <property name="mailServerPort" value="5025" />
18
+ </bean>
19
+
20
+ </beans>
data/test/base_test.rb ADDED
@@ -0,0 +1,61 @@
1
+ require 'test_helper'
2
+
3
+ Bundler.require "h2"
4
+
5
+ class BaseTest < Minitest::Test
6
+ def deploy_vacation_request
7
+ repositoryService = ActivitiEngine.getRepositoryService()
8
+ repositoryService.createDeployment().
9
+ addClasspathResource("test/VacationRequest.bpmn20.xml").
10
+ deploy() end
11
+
12
+ def test_create_deploy
13
+ repositoryService = ActivitiEngine.getRepositoryService()
14
+ before_count = repositoryService.createProcessDefinitionQuery().count()
15
+ deploy_vacation_request
16
+ after_count = repositoryService.createProcessDefinitionQuery().count()
17
+ assert_equal 1, after_count - before_count
18
+ end
19
+
20
+ def test_create_process_instance
21
+ deploy_vacation_request
22
+
23
+ runtime_service = ActivitiEngine.getRuntimeService();
24
+ variables = {
25
+ 'employeeName' => "Kermit",
26
+ 'numberOfDays' => 4,
27
+ 'vacationMotivation' => "I'm really tired!"
28
+ }
29
+ assert_output(/hello, this is a script task/) do
30
+ runtime_service.startProcessInstanceByKey("vacationRequest", variables);
31
+ end
32
+
33
+ instance_count = runtime_service.createProcessInstanceQuery().count()
34
+ assert_equal 1, instance_count
35
+ end
36
+
37
+ def test_task_process
38
+ deploy_vacation_request
39
+
40
+ runtime_service = ActivitiEngine.getRuntimeService();
41
+ runtime_service.startProcessInstanceByKey("vacationRequest", {});
42
+
43
+ task_service = ActivitiEngine.getTaskService();
44
+ tasks = task_service.createTaskQuery().taskCandidateGroup("management").list();
45
+ task = tasks.first
46
+ assert_equal 'Handle vacation request', task.getName
47
+
48
+ task_service = ActivitiEngine.getTaskService();
49
+ tasks = task_service.createTaskQuery().taskCandidateGroup("management").list();
50
+ task = tasks.first
51
+ task_variables = {
52
+ "vacationApproved" => "false",
53
+ "managerMotivation" => "We have a tight deadline!"
54
+ }
55
+ task_service.complete(task.getId, task_variables);
56
+
57
+ tasks = task_service.createTaskQuery().taskAssignee("Kermit").list();
58
+ task = tasks.first
59
+ assert_equal 'Adjust vacation request', task.getName
60
+ end
61
+ end
@@ -0,0 +1,6 @@
1
+ ActivitiConfigPath = "test/activiti.cfg.xml"
2
+ require 'jruby_activiti'
3
+
4
+ require 'minitest/autorun'
5
+ require 'minitest/unit'
6
+ require 'minitest/pride'
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jruby_activiti
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - richfisher
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '5.8'
19
+ name: minitest
20
+ prerelease: false
21
+ type: :development
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5.8'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0.9'
33
+ name: jbundler
34
+ prerelease: false
35
+ type: :runtime
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
41
+ description: Interact with Activiti BPM in Jruby, http://activiti.org/
42
+ email:
43
+ - richfisher.pan@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Jarfile
51
+ - Jarfile.lock
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - jruby_activiti.gemspec
56
+ - lib/jruby_activiti.rb
57
+ - lib/jruby_activiti/version.rb
58
+ - test/VacationRequest.bpmn20.xml
59
+ - test/activiti.cfg.xml
60
+ - test/base_test.rb
61
+ - test/test_helper.rb
62
+ homepage: https://github.com/richfisher/jruby_activiti
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.8
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Interact with Activiti BPM in Jruby, http://activiti.org/
86
+ test_files:
87
+ - test/VacationRequest.bpmn20.xml
88
+ - test/activiti.cfg.xml
89
+ - test/base_test.rb
90
+ - test/test_helper.rb