jruby_activiti 1.1.1-java

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: 196b05b05eb04257cb23fe43e276d50df379ab32
4
+ data.tar.gz: 8adcb737d1ad0e5c75bf5ef6112cd05ebbe13616
5
+ SHA512:
6
+ metadata.gz: 9cad97dec7c8d6590cb7a8d6a33b196605c21251b5cf37084e3ed695aa36237baf43914d9ff05aeb6a46e534dc79d17337867ddabc82e4a0cba4c93f74f77339
7
+ data.tar.gz: 00aed058e7202a7cf471615294ab9c294edaf6e6d202e081a419f0dd718adda021e702c33a489b981a1ef972406ad9141526cd24c13958bd4dbc45f72ed380a7
data/.gitignore ADDED
@@ -0,0 +1,16 @@
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/
16
+ *.gem
data/CHANGELOG ADDED
@@ -0,0 +1,3 @@
1
+ ## v1.0.0
2
+
3
+ * Initial release
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,56 @@
1
+ # JrubyActiviti
2
+
3
+ You can directly access Activiti BPM in Ruby Web Application.
4
+
5
+ ## Test Environments
6
+ JRuby-9.0.3.0, Activiti-5.18.0
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'jruby_activiti'
14
+ ```
15
+
16
+ Run the `bundle install` command to install it.
17
+
18
+ After you install and add it to your Gemfile, you need to run the generator:
19
+
20
+ ```
21
+ rails g jruby_activiti:install
22
+ ```
23
+
24
+ It will create 3 files, edit the config/activiti.cfg.xml as your need.
25
+
26
+ ```
27
+ create Jarfile
28
+ create config/activiti.cfg.xml
29
+ create config/initializers/jruby_activiti.rb
30
+ ```
31
+
32
+ And then execute `jbundle install`
33
+
34
+ ## Usage
35
+ You can access Activiti directly by using `ActivitiEngine`. For example, in a Rails controller
36
+
37
+ ```
38
+ repositoryService = ActivitiEngine.getRepositoryService()
39
+ repositoryService.createDeployment().
40
+ addClasspathResource("config/your_bpm_xml_file.bpmn20.xml").
41
+ deploy()
42
+ ```
43
+
44
+ ## Warning
45
+ Do not create Activiti Engine in a Rails application repeatedly. Otherwise you will get exception `log writing failed. Bad file descriptor - Bad file descriptor`
46
+
47
+ ## Thanks
48
+ Inspired by https://github.com/boberetezeke/jruby-activiti
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it ( https://github.com/richfisher/jruby_activiti/fork )
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 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,25 @@
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.platform = "java"
10
+ spec.authors = ["richfisher"]
11
+ spec.email = ["richfisher.pan@gmail.com"]
12
+ spec.summary = "Interact with Activiti BPM in JRuby, https://github.com/richfisher/jruby_activiti"
13
+ spec.description = spec.summary
14
+ spec.homepage = "https://github.com/richfisher/jruby_activiti"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "minitest", '>= 5.8'
23
+
24
+ spec.add_dependency "jbundler", '>= 0.9'
25
+ end
@@ -0,0 +1,23 @@
1
+ require 'rails/generators/base'
2
+
3
+ module JrubyActiviti
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ desc "Creates a initializer and copy config files to your application."
9
+
10
+ def create_jarfile
11
+ copy_file "Jarfile", "Jarfile"
12
+ end
13
+
14
+ def create_config
15
+ copy_file "activiti.cfg.xml", "config/activiti.cfg.xml"
16
+ end
17
+
18
+ def create_initializer_file
19
+ copy_file "initializer.rb", "config/initializers/jruby_activiti.rb"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -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'
@@ -0,0 +1,14 @@
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
+ <property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
7
+ <property name="jdbcDriver" value="org.h2.Driver" />
8
+ <property name="jdbcUsername" value="sa" />
9
+ <property name="jdbcPassword" value="" />
10
+
11
+ <property name="databaseSchemaUpdate" value="true" />
12
+ </bean>
13
+
14
+ </beans>
@@ -0,0 +1 @@
1
+ ActivitiEngine = JrubyActiviti.get_engine
@@ -0,0 +1,3 @@
1
+ module JrubyActiviti
2
+ VERSION = "1.1.1"
3
+ end
@@ -0,0 +1,14 @@
1
+ require "jruby_activiti/version"
2
+
3
+ require "jbundler"
4
+ Bundler.require "activiti-engine"
5
+
6
+ ActivitiConfigPath ||= "config/activiti.cfg.xml"
7
+
8
+ module JrubyActiviti
9
+ def self.get_engine
10
+ configuration = Java::OrgActivitiEngine::ProcessEngineConfiguration.
11
+ createProcessEngineConfigurationFromResource(ActivitiConfigPath)
12
+ configuration.buildProcessEngine
13
+ end
14
+ 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,64 @@
1
+ require 'test_helper'
2
+
3
+ Bundler.require "h2"
4
+
5
+ ActivitiEngine = JrubyActiviti.get_engine
6
+
7
+ class BaseTest < Minitest::Test
8
+ def deploy_vacation_request
9
+ repositoryService = ActivitiEngine.getRepositoryService()
10
+ repositoryService.createDeployment().
11
+ addClasspathResource("test/VacationRequest.bpmn20.xml").
12
+ deploy()
13
+ end
14
+
15
+ def test_create_deploy
16
+ repositoryService = ActivitiEngine.getRepositoryService()
17
+ before_count = repositoryService.createProcessDefinitionQuery().count()
18
+ deploy_vacation_request
19
+ after_count = repositoryService.createProcessDefinitionQuery().count()
20
+ assert_equal 1, after_count - before_count
21
+ end
22
+
23
+ def test_create_process_instance
24
+ deploy_vacation_request
25
+
26
+ runtime_service = ActivitiEngine.getRuntimeService();
27
+ variables = {
28
+ 'employeeName' => "Kermit",
29
+ 'numberOfDays' => 4,
30
+ 'vacationMotivation' => "I'm really tired!"
31
+ }
32
+ assert_output(/hello, this is a script task/) do
33
+ runtime_service.startProcessInstanceByKey("vacationRequest", variables);
34
+ end
35
+
36
+ instance_count = runtime_service.createProcessInstanceQuery().count()
37
+ assert_equal 1, instance_count
38
+ end
39
+
40
+ def test_task_process
41
+ deploy_vacation_request
42
+
43
+ runtime_service = ActivitiEngine.getRuntimeService();
44
+ runtime_service.startProcessInstanceByKey("vacationRequest", {});
45
+
46
+ task_service = ActivitiEngine.getTaskService();
47
+ tasks = task_service.createTaskQuery().taskCandidateGroup("management").list();
48
+ task = tasks.first
49
+ assert_equal 'Handle vacation request', task.getName
50
+
51
+ task_service = ActivitiEngine.getTaskService();
52
+ tasks = task_service.createTaskQuery().taskCandidateGroup("management").list();
53
+ task = tasks.first
54
+ task_variables = {
55
+ "vacationApproved" => "false",
56
+ "managerMotivation" => "We have a tight deadline!"
57
+ }
58
+ task_service.complete(task.getId, task_variables);
59
+
60
+ tasks = task_service.createTaskQuery().taskAssignee("Kermit").list();
61
+ task = tasks.first
62
+ assert_equal 'Adjust vacation request', task.getName
63
+ end
64
+ 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,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jruby_activiti
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.1
5
+ platform: java
6
+ authors:
7
+ - richfisher
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-04 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, https://github.com/richfisher/jruby_activiti
42
+ email:
43
+ - richfisher.pan@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - CHANGELOG
50
+ - Gemfile
51
+ - Jarfile
52
+ - Jarfile.lock
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - jruby_activiti.gemspec
57
+ - lib/generators/jruby_activiti/install_generator.rb
58
+ - lib/generators/jruby_activiti/templates/Jarfile
59
+ - lib/generators/jruby_activiti/templates/activiti.cfg.xml
60
+ - lib/generators/jruby_activiti/templates/initializer.rb
61
+ - lib/jruby_activiti.rb
62
+ - lib/jruby_activiti/version.rb
63
+ - test/VacationRequest.bpmn20.xml
64
+ - test/activiti.cfg.xml
65
+ - test/base_test.rb
66
+ - test/test_helper.rb
67
+ homepage: https://github.com/richfisher/jruby_activiti
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.4.8
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Interact with Activiti BPM in JRuby, https://github.com/richfisher/jruby_activiti
91
+ test_files:
92
+ - test/VacationRequest.bpmn20.xml
93
+ - test/activiti.cfg.xml
94
+ - test/base_test.rb
95
+ - test/test_helper.rb