bosdk 1.0.3-universal-java-1.6 → 1.1.0-universal-java-1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/{MIT-LICENSE → LICENSE} +0 -0
- data/README.rdoc +11 -2
- data/Rakefile +43 -16
- data/VERSION +1 -0
- data/bin/boirb +12 -1
- data/bosdk.gemspec +72 -31
- data/lib/bosdk.rb +1 -0
- data/lib/bosdk/enterprise_session.rb +1 -4
- data/lib/bosdk/info_object.rb +6 -1
- data/lib/bosdk/webi_instance.rb +46 -0
- data/spec/bosdk_spec.rb +21 -0
- data/spec/enterprise_session_spec.rb +134 -92
- data/spec/info_object_spec.rb +114 -76
- data/spec/webi_instance_spec.rb +112 -0
- data/spec/webi_report_engine_spec.rb +14 -8
- metadata +19 -9
data/.document
ADDED
data/.gitignore
ADDED
data/{MIT-LICENSE → LICENSE}
RENAMED
File without changes
|
data/README.rdoc
CHANGED
@@ -51,8 +51,17 @@ Disconnects @boe from the cms.
|
|
51
51
|
query(stmt)
|
52
52
|
Runs the provided query on @boe and returns the resulting InfoObject array.
|
53
53
|
|
54
|
-
|
55
|
-
Opens the specified InfoObject using a ReportEngine and returns
|
54
|
+
open_webi(docid)
|
55
|
+
Opens the specified InfoObject using a ReportEngine and returns a handle to the
|
56
|
+
WebiInstance. It also creates the following instance variables: @doc, @objs and
|
57
|
+
@vars. @doc is a handle to the WebiInstance, @objs is an alias for @doc.objects
|
58
|
+
and @vars is an alias for @doc.variables.
|
59
|
+
|
60
|
+
objects
|
61
|
+
Shortcut to @objs which is an alias for @doc.objects
|
62
|
+
|
63
|
+
variables
|
64
|
+
Shortcut to @vars which is an alias for @doc.variables
|
56
65
|
|
57
66
|
== Resources
|
58
67
|
|
data/Rakefile
CHANGED
@@ -1,26 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
1
3
|
require 'rake/clean'
|
2
4
|
|
3
|
-
|
4
|
-
CLOBBER.include %w( *.gem )
|
5
|
+
CLOBBER.include 'pkg'
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
begin
|
8
|
+
require 'jeweler'
|
9
|
+
Jeweler::Tasks.new do |gem|
|
10
|
+
gem.name = "bosdk"
|
11
|
+
gem.summary = "JRuby Business Object Java SDK wrapper"
|
12
|
+
gem.description = "A JRuby wrapper for the Business Objects Java SDK"
|
13
|
+
gem.email = "semmons99@gmail.com"
|
14
|
+
gem.homepage = "http://semmons99.github.com/bosdk"
|
15
|
+
gem.authors = ["Shane Emmons"]
|
16
|
+
gem.platform = Gem::Platform::CURRENT
|
17
|
+
gem.requirements = "An environment variable 'BOE_JAVA_LIB' pointing to the Business Objects Java SDK directory"
|
18
|
+
gem.add_development_dependency "rspec", ">= 1.3.0"
|
19
|
+
gem.add_development_dependency "hanna", ">= 0.1.12"
|
20
|
+
end
|
21
|
+
Jeweler::GemcutterTasks.new
|
22
|
+
rescue LoadError
|
23
|
+
puts "Jeweler (or a dependency) not available. Install it with gem install jeweler"
|
9
24
|
end
|
10
25
|
|
11
|
-
|
12
|
-
|
13
|
-
|
26
|
+
require 'spec/rake/spectask'
|
27
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
28
|
+
spec.libs << 'lib' << 'spec'
|
29
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
14
30
|
end
|
15
31
|
|
16
|
-
desc '
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
32
|
+
desc "Run specs with '--format specdoc'"
|
33
|
+
Spec::Rake::SpecTask.new(:specdoc) do |spec|
|
34
|
+
spec.libs << 'lib' << 'spec'
|
35
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
36
|
+
spec.spec_opts << '--format specdoc'
|
21
37
|
end
|
22
38
|
|
23
|
-
|
24
|
-
|
25
|
-
|
39
|
+
task :spec => :check_dependencies
|
40
|
+
|
41
|
+
task :default => :spec
|
42
|
+
|
43
|
+
task :test => :spec
|
44
|
+
|
45
|
+
require 'hanna/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "bosdk #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
26
53
|
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1.0
|
data/bin/boirb
CHANGED
@@ -46,7 +46,18 @@ def query(stmt)
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def open_webi(docid)
|
49
|
-
@boe.open_webi(docid) if connected?
|
49
|
+
@doc = @boe.open_webi(docid) if connected?
|
50
|
+
@objs = @doc.objects
|
51
|
+
@vars = @doc.variables
|
52
|
+
@doc
|
53
|
+
end
|
54
|
+
|
55
|
+
def objects
|
56
|
+
@objs
|
57
|
+
end
|
58
|
+
|
59
|
+
def variables
|
60
|
+
@vars
|
50
61
|
end
|
51
62
|
|
52
63
|
IRB.start_session(Kernel.binding)
|
data/bosdk.gemspec
CHANGED
@@ -1,31 +1,72 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
s.
|
8
|
-
s.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{bosdk}
|
8
|
+
s.version = "1.1.0"
|
9
|
+
s.platform = %q{universal-java-1.6}
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = ["Shane Emmons"]
|
13
|
+
s.date = %q{2010-02-09}
|
14
|
+
s.default_executable = %q{boirb}
|
15
|
+
s.description = %q{A JRuby wrapper for the Business Objects Java SDK}
|
16
|
+
s.email = %q{semmons99@gmail.com}
|
17
|
+
s.executables = ["boirb"]
|
18
|
+
s.extra_rdoc_files = [
|
19
|
+
"LICENSE",
|
20
|
+
"README.rdoc"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".document",
|
24
|
+
".gitignore",
|
25
|
+
"LICENSE",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bin/boirb",
|
30
|
+
"bosdk.gemspec",
|
31
|
+
"lib/bosdk.rb",
|
32
|
+
"lib/bosdk/enterprise_session.rb",
|
33
|
+
"lib/bosdk/info_object.rb",
|
34
|
+
"lib/bosdk/webi_instance.rb",
|
35
|
+
"lib/bosdk/webi_report_engine.rb",
|
36
|
+
"spec/bosdk_spec.rb",
|
37
|
+
"spec/enterprise_session_spec.rb",
|
38
|
+
"spec/info_object_spec.rb",
|
39
|
+
"spec/webi_instance_spec.rb",
|
40
|
+
"spec/webi_report_engine_spec.rb"
|
41
|
+
]
|
42
|
+
s.homepage = %q{http://semmons99.github.com/bosdk}
|
43
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.requirements = ["An environment variable 'BOE_JAVA_LIB' pointing to the Business Objects Java SDK directory"]
|
46
|
+
s.rubygems_version = %q{1.3.5}
|
47
|
+
s.summary = %q{JRuby Business Object Java SDK wrapper}
|
48
|
+
s.test_files = [
|
49
|
+
"spec/bosdk_spec.rb",
|
50
|
+
"spec/enterprise_session_spec.rb",
|
51
|
+
"spec/info_object_spec.rb",
|
52
|
+
"spec/webi_instance_spec.rb",
|
53
|
+
"spec/webi_report_engine_spec.rb"
|
54
|
+
]
|
55
|
+
|
56
|
+
if s.respond_to? :specification_version then
|
57
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
58
|
+
s.specification_version = 3
|
59
|
+
|
60
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
61
|
+
s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
|
62
|
+
s.add_development_dependency(%q<hanna>, [">= 0.1.12"])
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
65
|
+
s.add_dependency(%q<hanna>, [">= 0.1.12"])
|
66
|
+
end
|
67
|
+
else
|
68
|
+
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
69
|
+
s.add_dependency(%q<hanna>, [">= 0.1.12"])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
data/lib/bosdk.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'bosdk/info_object'
|
2
|
-
require 'bosdk/webi_report_engine'
|
3
|
-
|
4
1
|
module BOSDK
|
5
2
|
# Creates a wrapper around the Business Objects Java SDK.
|
6
3
|
class EnterpriseSession
|
@@ -51,7 +48,7 @@ module BOSDK
|
|
51
48
|
# Open a Webi document from the provided docid
|
52
49
|
def open_webi(docid)
|
53
50
|
@webi_report_engine ||= WebiReportEngine.new(@session, @locale)
|
54
|
-
@webi_report_engine.open(docid)
|
51
|
+
WebiInstance.new(@webi_report_engine.open(docid))
|
55
52
|
end
|
56
53
|
end
|
57
54
|
end
|
data/lib/bosdk/info_object.rb
CHANGED
@@ -10,9 +10,14 @@ module BOSDK
|
|
10
10
|
@obj = obj
|
11
11
|
end
|
12
12
|
|
13
|
+
# Returns the Business Objects ID (alias for #getID).
|
14
|
+
def docid
|
15
|
+
getID
|
16
|
+
end
|
17
|
+
|
13
18
|
# Returns true/false if #obj is a root node.
|
14
19
|
def is_root?
|
15
|
-
parent_id.nil? or parent_id == 0 or parent_id ==
|
20
|
+
parent_id.nil? or parent_id == 0 or parent_id == docid
|
16
21
|
end
|
17
22
|
|
18
23
|
# Returns the parent of #obj as an InfoObject
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module BOSDK
|
2
|
+
# Creates a wrapper around a DocumentInstance
|
3
|
+
class WebiInstance
|
4
|
+
# The underlying DocumentInstance
|
5
|
+
attr_reader :instance
|
6
|
+
|
7
|
+
# Create a new WebiInstance from the provided DocumentInstance
|
8
|
+
def initialize(instance)
|
9
|
+
@instance = instance
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns an array of hashes representing report objects.
|
13
|
+
def objects
|
14
|
+
return @objects unless @objects.nil?
|
15
|
+
objs = []
|
16
|
+
dict = @instance.getDictionary
|
17
|
+
(0 ... dict.getChildCount).each do |i|
|
18
|
+
obj = dict.getChildAt(i)
|
19
|
+
objs << {
|
20
|
+
:name => obj.getName,
|
21
|
+
:qual => obj.getQualification.toString.downcase.to_sym,
|
22
|
+
:type => obj.getType.toString.downcase.to_sym,
|
23
|
+
:object => obj,
|
24
|
+
}
|
25
|
+
end
|
26
|
+
@objects = objs
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns an array of hashes representing report variables.
|
30
|
+
def variables
|
31
|
+
return @variables unless @variables.nil?
|
32
|
+
vars = []
|
33
|
+
dict = @instance.getDictionary
|
34
|
+
dict.getVariables.each do |var|
|
35
|
+
vars << {
|
36
|
+
:name => var.getName,
|
37
|
+
:qual => var.getQualification.toString.downcase.to_sym,
|
38
|
+
:type => var.getType.toString.downcase.to_sym,
|
39
|
+
:formula => var.getFormula.getValue,
|
40
|
+
:variable => var,
|
41
|
+
}
|
42
|
+
end
|
43
|
+
@variables = vars
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/spec/bosdk_spec.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
2
|
+
require 'bosdk'
|
3
|
+
|
4
|
+
module BOSDK
|
5
|
+
describe BOSDK do
|
6
|
+
describe "#connect" do
|
7
|
+
before(:each) do
|
8
|
+
@es = mock("EnterpriseSession").as_null_object
|
9
|
+
class EnterpriseSession; end
|
10
|
+
EnterpriseSession.should_receive(:new).once.with('cms', 'Administrator', '', {:locale => "en_US"}).and_return(@es)
|
11
|
+
@es.should_receive(:disconnect).once.with.and_return
|
12
|
+
end
|
13
|
+
|
14
|
+
specify "wraps EnterpriseSession#new in a closure" do
|
15
|
+
BOSDK.connect('cms', 'Administrator', '', :locale => "en_US") do |session|
|
16
|
+
session.should == @es
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
3
2
|
require 'bosdk/enterprise_session'
|
4
3
|
|
@@ -18,111 +17,154 @@ module BOSDK
|
|
18
17
|
@es = EnterpriseSession.new('cms', 'Administrator', '')
|
19
18
|
end
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
describe "#new" do
|
21
|
+
it "should accept an optional locale setting" do
|
22
|
+
EnterpriseSession.new('cms', 'Administrator', '', :locale => 'en_CA')
|
23
|
+
end
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
describe "#connected?" do
|
27
|
+
before(:each) do
|
28
|
+
@session.should_receive(:logoff).at_most(1).with.and_return
|
29
|
+
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
+
it "returns 'true' when connected to a CMS" do
|
32
|
+
@es.connected?.should be_true
|
33
|
+
end
|
31
34
|
|
32
|
-
|
33
|
-
|
35
|
+
it "returns 'false' when not connected to a CMS" do
|
36
|
+
@es.disconnect
|
37
|
+
@es.connected?.should be_false
|
38
|
+
end
|
34
39
|
end
|
35
40
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
@es.connected?.should be_false
|
41
|
-
end
|
41
|
+
describe "#disconnect" do
|
42
|
+
before(:each) do
|
43
|
+
@session.should_receive(:logoff).once.with.and_return
|
44
|
+
end
|
42
45
|
|
43
|
-
|
44
|
-
|
46
|
+
it "should disconnect from the CMS" do
|
47
|
+
@es.disconnect
|
48
|
+
@es.connected?.should be_false
|
49
|
+
end
|
45
50
|
|
46
|
-
|
51
|
+
it "shouldn't raise an error when not connected" do
|
52
|
+
lambda{2.times{ @es.disconnect }}.should_not raise_exception
|
53
|
+
end
|
47
54
|
end
|
48
55
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
describe "#path_to_sql" do
|
57
|
+
before(:each) do
|
58
|
+
@path_query = 'path://SystemObjects/Users/Administrator@SI_ID'
|
59
|
+
@stmt = "SELECT SI_ID FROM CI_SYSTEMOBJECTS WHERE SI_KIND='User' AND SI_NAME='Administrator'"
|
60
|
+
|
61
|
+
@stateless_page_info = mock("IStatelessPageInfo").as_null_object
|
62
|
+
|
63
|
+
class PagingQueryOptions; end
|
64
|
+
PagingQueryOptions.should_receive(:new).once.with
|
65
|
+
@infostore.should_receive(:getStatelessPageInfo).once.with(@path_query, nil).and_return(@stateless_page_info)
|
66
|
+
@stateless_page_info.should_receive(:getPageSQL).once.with.and_return(@stmt)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should convert a path query to an sql query" do
|
70
|
+
@es.path_to_sql(@path_query).should == @stmt
|
71
|
+
end
|
61
72
|
end
|
62
73
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
74
|
+
describe "#query" do
|
75
|
+
context "when :type => sql" do
|
76
|
+
before(:each) do
|
77
|
+
@stmt = 'SELECT * FROM CI_INFOOBJECTS'
|
78
|
+
@infostore.should_receive(:query).once.with(@stmt).and_return([])
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should send the statement to the underlying InfoStore" do
|
82
|
+
@es.query(@stmt)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "when :type => path://" do
|
87
|
+
before(:each) do
|
88
|
+
@path_query = 'path://SystemObjects/Users/Administrator@SI_ID'
|
89
|
+
@stmt = "SELECT * FROM CI_SYSTEMOBJECTS WHERE SI_KIND='User' AND SI_NAME='Administator'"
|
90
|
+
|
91
|
+
@es.should_receive(:path_to_sql).once.with(@path_query).and_return(@stmt)
|
92
|
+
@infostore.should_receive(:query).once.with(@stmt).and_return([])
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should convert a path:// query to sql before execution" do
|
96
|
+
@es.query(@path_query)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "when :type => query://" do
|
101
|
+
before(:each) do
|
102
|
+
@path_query = 'query://{SELECT * FROM CI_INFOOBJECTS}'
|
103
|
+
@stmt = 'SELECT * FROM CI_INFOOBJECTS'
|
104
|
+
|
105
|
+
@es.should_receive(:path_to_sql).once.with(@path_query).and_return(@stmt)
|
106
|
+
@infostore.should_receive(:query).once.with(@stmt).and_return([])
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should convert a query:// query to sql before execution" do
|
110
|
+
@es.query(@path_query)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context "when :type => cuid://" do
|
115
|
+
before(:each) do
|
116
|
+
@path_query = 'cuid://ABC'
|
117
|
+
@stmt = "SELECT * FROM CI_INFOOBJECTS WHERE SI_CUID='ABC'"
|
118
|
+
|
119
|
+
@es.should_receive(:path_to_sql).once.with(@path_query).and_return(@stmt)
|
120
|
+
@infostore.should_receive(:query).once.with(@stmt).and_return([])
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should convert a cuid:// query to sql before execution" do
|
124
|
+
@es.query(@path_query)
|
125
|
+
end
|
126
|
+
end
|
68
127
|
end
|
69
128
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
specify "#open_webi should only create a WebiReportEngine once" do
|
110
|
-
@webi_report_engine = mock("WebiReportEngine").as_null_object
|
111
|
-
class WebiReportEngine; end
|
112
|
-
WebiReportEngine.should_receive(:new).once.with(@session, 'en_US').and_return(@webi_report_engine)
|
113
|
-
@webi_report_engine.should_receive(:open).twice.with("1234")
|
114
|
-
|
115
|
-
2.times{@es.open_webi("1234")}
|
116
|
-
end
|
117
|
-
|
118
|
-
specify "#open_webi should pass any specified locale" do
|
119
|
-
@webi_report_engine = mock("WebiReportEngine").as_null_object
|
120
|
-
class WebiReportEngine; end
|
121
|
-
WebiReportEngine.should_receive(:new).once.with(@session, 'en_CA').and_return(@webi_report_engine)
|
122
|
-
@webi_report_engine.should_receive(:open).once.with("1234")
|
123
|
-
|
124
|
-
es = EnterpriseSession.new('cms', 'Administrator', '', :locale => 'en_CA')
|
125
|
-
es.open_webi("1234")
|
129
|
+
describe "#open_webi" do
|
130
|
+
before(:each) do
|
131
|
+
@webi_report_engine = mock("WebiReportEngine").as_null_object
|
132
|
+
@document_instance = mock("DocumentInstance").as_null_object
|
133
|
+
@webi_instance = mock("WebiInstance").as_null_object
|
134
|
+
class WebiReportEngine; end
|
135
|
+
class WebiInstance; end
|
136
|
+
WebiInstance.should_receive(:new).at_least(1).with(@document_instance).and_return(@webi_instance)
|
137
|
+
@webi_report_engine.should_receive(:open).at_least(1).with("1234").and_return(@document_instance)
|
138
|
+
end
|
139
|
+
|
140
|
+
context "when :locale => en_US" do
|
141
|
+
before(:each) do
|
142
|
+
WebiReportEngine.should_receive(:new).once.with(@session, 'en_US').and_return(@webi_report_engine)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should create a WebiReportEngine and call #open" do
|
146
|
+
@es.open_webi("1234")
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should only create a WebiReportEngine once" do
|
150
|
+
2.times{@es.open_webi("1234")}
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should create a WebiInstance and return it" do
|
154
|
+
@es.open_webi("1234").should == @webi_instance
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context "when :locale => en_CA" do
|
159
|
+
before(:each) do
|
160
|
+
WebiReportEngine.should_receive(:new).once.with(@session, 'en_CA').and_return(@webi_report_engine)
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should pass any specified locale" do
|
164
|
+
es = EnterpriseSession.new('cms', 'Administrator', '', :locale => 'en_CA')
|
165
|
+
es.open_webi("1234")
|
166
|
+
end
|
167
|
+
end
|
126
168
|
end
|
127
169
|
end
|
128
170
|
end
|
data/spec/info_object_spec.rb
CHANGED
@@ -1,111 +1,149 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
3
2
|
require 'bosdk/info_object'
|
4
3
|
|
5
4
|
module BOSDK
|
6
5
|
describe InfoObject do
|
7
6
|
before(:each) do
|
8
|
-
# mocks
|
9
7
|
@infoobject = mock("IInfoObject").as_null_object
|
10
8
|
|
11
9
|
@obj = InfoObject.new(@infoobject)
|
12
10
|
end
|
11
|
+
|
12
|
+
describe "#docid" do
|
13
|
+
before(:each) do
|
14
|
+
@infoobject.should_receive(:getID).once.with.and_return(1)
|
15
|
+
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
@obj.is_root?.should be_true
|
18
|
-
end
|
19
|
-
|
20
|
-
specify "#is_root? should return true when #parent_id is '0'" do
|
21
|
-
@infoobject.should_receive(:parent_id).once.with.and_return(0)
|
22
|
-
|
23
|
-
@obj.is_root?.should be_true
|
24
|
-
end
|
25
|
-
|
26
|
-
specify "#is_root? should return true when #parent_id == #getID" do
|
27
|
-
@infoobject.should_receive(:parent_id).once.with.and_return(1)
|
28
|
-
@infoobject.should_receive(:getID).once.with.and_return(1)
|
29
|
-
|
30
|
-
@obj.is_root?.should be_true
|
31
|
-
end
|
32
|
-
|
33
|
-
specify "#is_root? should return false when #parent_id is not: nil, '0' or #getID" do
|
34
|
-
@infoobject.should_receive(:parent_id).once.with.and_return(1)
|
35
|
-
@infoobject.should_receive(:getID).once.with.and_return(2)
|
17
|
+
it "should call #getID and return the result" do
|
18
|
+
@obj.docid.should == 1
|
19
|
+
end
|
36
20
|
|
37
|
-
|
21
|
+
it "should only call #getID once" do
|
22
|
+
2.times{@obj.docid.should == 1}
|
23
|
+
end
|
38
24
|
end
|
39
25
|
|
40
|
-
|
41
|
-
|
26
|
+
describe "#is_root?" do
|
27
|
+
context "when #parent_id == nil" do
|
28
|
+
before(:each) do
|
29
|
+
@infoobject.should_receive(:parent_id).once.with.and_return(nil)
|
30
|
+
end
|
42
31
|
|
43
|
-
|
44
|
-
|
32
|
+
it "should return true" do
|
33
|
+
@obj.is_root?.should be_true
|
34
|
+
end
|
35
|
+
end
|
45
36
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
@infoobject.should_receive(:getParent).once.with.and_return(parent_obj)
|
37
|
+
context "when #parent_id == 0" do
|
38
|
+
before(:each) do
|
39
|
+
@infoobject.should_receive(:parent_id).once.with.and_return(0)
|
40
|
+
end
|
51
41
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
42
|
+
it "should return true" do
|
43
|
+
@obj.is_root?.should be_true
|
44
|
+
end
|
45
|
+
end
|
56
46
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
47
|
+
context "when #parent_id == #getID" do
|
48
|
+
before(:each) do
|
49
|
+
@infoobject.should_receive(:parent_id).once.with.and_return(1)
|
50
|
+
@infoobject.should_receive(:getID).once.with.and_return(1)
|
51
|
+
end
|
62
52
|
|
63
|
-
|
64
|
-
|
53
|
+
it "should return true" do
|
54
|
+
@obj.is_root?.should be_true
|
55
|
+
end
|
56
|
+
end
|
65
57
|
|
66
|
-
|
67
|
-
|
68
|
-
|
58
|
+
context "when #parent_id != nil, 0 or #getID" do
|
59
|
+
before(:each) do
|
60
|
+
@infoobject.should_receive(:parent_id).once.with.and_return(1)
|
61
|
+
@infoobject.should_receive(:getID).once.with.and_return(2)
|
62
|
+
end
|
69
63
|
|
70
|
-
|
64
|
+
it "should return false" do
|
65
|
+
@obj.is_root?.should be_false
|
66
|
+
end
|
67
|
+
end
|
71
68
|
end
|
72
69
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
70
|
+
describe "#parent" do
|
71
|
+
context "when #is_root? == true" do
|
72
|
+
before(:each) do
|
73
|
+
@infoobject.should_receive(:parent_id).once.with.and_return(nil)
|
74
|
+
end
|
77
75
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
76
|
+
it "should return nil" do
|
77
|
+
@obj.parent.should be_nil
|
78
|
+
end
|
79
|
+
end
|
82
80
|
|
83
|
-
|
81
|
+
context "when #is_root? == false" do
|
82
|
+
before(:each) do
|
83
|
+
@parent_obj = mock("IInfoObject").as_null_object
|
84
|
+
@infoobject.should_receive(:parent_id).once.with.and_return(1)
|
85
|
+
@infoobject.should_receive(:getID).once.with.and_return(2)
|
86
|
+
@infoobject.should_receive(:getParent).once.with.and_return(@parent_obj)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return results of #getParent" do
|
90
|
+
parent = @obj.parent
|
91
|
+
parent.should be_instance_of InfoObject
|
92
|
+
parent.obj.should == @parent_obj
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should only call the underlying #getParent once" do
|
96
|
+
2.times{@obj.parent}
|
97
|
+
end
|
98
|
+
end
|
84
99
|
end
|
85
100
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
101
|
+
describe "#path" do
|
102
|
+
context "when #is_root? == true" do
|
103
|
+
before(:each) do
|
104
|
+
@infoobject.should_receive(:parent_id).once.with.and_return(nil)
|
105
|
+
@infoobject.should_receive(:title).once.with.and_return('test obj')
|
106
|
+
end
|
90
107
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
108
|
+
it "should return /#title" do
|
109
|
+
@obj.path.should == '/test obj'
|
110
|
+
end
|
111
|
+
end
|
95
112
|
|
96
|
-
|
113
|
+
context "when #is_root? == false" do
|
114
|
+
before(:each) do
|
115
|
+
@parent_obj = mock("IInfoObject").as_null_object
|
116
|
+
@parent_obj.should_receive(:parent_id).once.with.and_return(nil)
|
117
|
+
@parent_obj.should_receive(:title).once.with.and_return('test parent')
|
118
|
+
|
119
|
+
@infoobject.should_receive(:parent_id).once.with.and_return(1)
|
120
|
+
@infoobject.should_receive(:getID).once.with.and_return(2)
|
121
|
+
@infoobject.should_receive(:title).once.with.and_return('test obj')
|
122
|
+
@infoobject.should_receive(:getParent).once.with.and_return(@parent_obj)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should return #parent_title/../#title" do
|
126
|
+
@obj.path.should == '/test parent/test obj'
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should only call the underlying #title, #parent#path, etc. once" do
|
130
|
+
2.times{@obj.path}
|
131
|
+
end
|
132
|
+
end
|
97
133
|
end
|
98
134
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
135
|
+
describe "#<=>" do
|
136
|
+
it "should use #title" do
|
137
|
+
objs = []
|
138
|
+
('a'..'c').to_a.reverse.each do |ltr|
|
139
|
+
obj = mock("IInfoObject").as_null_object
|
140
|
+
obj.should_receive(:title).once.with.and_return(ltr)
|
141
|
+
objs << InfoObject.new(obj)
|
142
|
+
end
|
143
|
+
|
144
|
+
sorted_objs = objs.sort
|
145
|
+
sorted_objs.should == objs.reverse
|
105
146
|
end
|
106
|
-
|
107
|
-
sorted_objs = objs.sort
|
108
|
-
sorted_objs.should == objs.reverse
|
109
147
|
end
|
110
148
|
end
|
111
149
|
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
2
|
+
require 'bosdk/webi_instance'
|
3
|
+
|
4
|
+
module BOSDK
|
5
|
+
describe WebiInstance do
|
6
|
+
before(:each) do
|
7
|
+
@document_instance = mock("DocumentInstance").as_null_object
|
8
|
+
|
9
|
+
@webi = WebiInstance.new(@document_instance)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#new" do
|
13
|
+
it "should store the passed DocumentInstance in @doc_instance" do
|
14
|
+
@webi.instance.should == @document_instance
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#objects" do
|
19
|
+
before(:each) do
|
20
|
+
@report_dictionary = mock("ReportDictionary").as_null_object
|
21
|
+
@report_expression_1 = mock("ReportExpression").as_null_object
|
22
|
+
@report_expression_2 = mock("ReportExpression").as_null_object
|
23
|
+
@object_qualification_1 = mock("ObjectQualification").as_null_object
|
24
|
+
@object_qualification_2 = mock("ObjectQualification").as_null_object
|
25
|
+
@object_type_1 = mock("ObjectType").as_null_object
|
26
|
+
@object_type_2 = mock("ObjectType").as_null_object
|
27
|
+
|
28
|
+
@document_instance.should_receive(:getDictionary).once.with.and_return(@report_dictionary)
|
29
|
+
|
30
|
+
@report_dictionary.should_receive(:getChildCount).once.with.and_return(2)
|
31
|
+
@report_dictionary.should_receive(:getChildAt).once.with(0).and_return(@report_expression_1)
|
32
|
+
@report_dictionary.should_receive(:getChildAt).once.with(1).and_return(@report_expression_2)
|
33
|
+
|
34
|
+
@report_expression_1.should_receive(:getName).once.with.and_return("Object1")
|
35
|
+
@report_expression_1.should_receive(:getQualification).once.with.and_return(@object_qualification_1)
|
36
|
+
@report_expression_1.should_receive(:getType).once.with.and_return(@object_type_1)
|
37
|
+
|
38
|
+
@report_expression_2.should_receive(:getName).once.with.and_return("Object2")
|
39
|
+
@report_expression_2.should_receive(:getQualification).once.with.and_return(@object_qualification_2)
|
40
|
+
@report_expression_2.should_receive(:getType).once.with.and_return(@object_type_2)
|
41
|
+
|
42
|
+
@object_qualification_1.should_receive(:toString).once.with.and_return("DIMENSION")
|
43
|
+
@object_qualification_2.should_receive(:toString).once.with.and_return("MEASURE")
|
44
|
+
|
45
|
+
@object_type_1.should_receive(:toString).once.with.and_return("TEXT")
|
46
|
+
@object_type_2.should_receive(:toString).once.with.and_return("NUMERIC")
|
47
|
+
|
48
|
+
@objects = [
|
49
|
+
{:name => 'Object1', :qual => :dimension, :type => :text, :object => @report_expression_1},
|
50
|
+
{:name => 'Object2', :qual => :measure, :type => :numeric, :object => @report_expression_2},
|
51
|
+
]
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return an array of report objects" do
|
55
|
+
@webi.objects.should == @objects
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should cache results" do
|
59
|
+
2.times{@webi.objects}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#variables" do
|
64
|
+
before(:each) do
|
65
|
+
@report_dictionary = mock("ReportDictionary").as_null_object
|
66
|
+
@variable_expression_1 = mock("VariableExpression").as_null_object
|
67
|
+
@variable_expression_2 = mock("VariableExpression").as_null_object
|
68
|
+
@object_qualification_1 = mock("ObjectQualification").as_null_object
|
69
|
+
@object_qualification_2 = mock("ObjectQualification").as_null_object
|
70
|
+
@object_type_1 = mock("ObjectType").as_null_object
|
71
|
+
@object_type_2 = mock("ObjectType").as_null_object
|
72
|
+
@formula_expression_1 = mock("FormulaExpression").as_null_object
|
73
|
+
@formula_expression_2 = mock("FormulaExpression").as_null_object
|
74
|
+
|
75
|
+
@document_instance.should_receive(:getDictionary).once.with.and_return(@report_dictionary)
|
76
|
+
@report_dictionary.should_receive(:getVariables).once.with.and_return([@variable_expression_1, @variable_expression_2])
|
77
|
+
|
78
|
+
@variable_expression_1.should_receive(:getName).once.with.and_return("Variable1")
|
79
|
+
@variable_expression_1.should_receive(:getQualification).once.with.and_return(@object_qualification_1)
|
80
|
+
@variable_expression_1.should_receive(:getType).once.with.and_return(@object_type_1)
|
81
|
+
@variable_expression_1.should_receive(:getFormula).once.with.and_return(@formula_expression_1)
|
82
|
+
|
83
|
+
@variable_expression_2.should_receive(:getName).once.with.and_return("Variable2")
|
84
|
+
@variable_expression_2.should_receive(:getQualification).once.with.and_return(@object_qualification_2)
|
85
|
+
@variable_expression_2.should_receive(:getType).once.with.and_return(@object_type_2)
|
86
|
+
@variable_expression_2.should_receive(:getFormula).once.with.and_return(@formula_expression_2)
|
87
|
+
|
88
|
+
@object_qualification_1.should_receive(:toString).once.with.and_return("DIMENSION")
|
89
|
+
@object_qualification_2.should_receive(:toString).once.with.and_return("MEASURE")
|
90
|
+
|
91
|
+
@object_type_1.should_receive(:toString).once.with.and_return("TEXT")
|
92
|
+
@object_type_2.should_receive(:toString).once.with.and_return("NUMERIC")
|
93
|
+
|
94
|
+
@formula_expression_1.should_receive(:getValue).once.with.and_return('If([Object1]="Object1";"Yes";"False")')
|
95
|
+
@formula_expression_2.should_receive(:getValue).once.with.and_return('Sum([Object2])')
|
96
|
+
|
97
|
+
@variables = [
|
98
|
+
{:name => 'Variable1', :qual => :dimension, :type => :text, :formula => 'If([Object1]="Object1";"Yes";"False")', :variable => @variable_expression_1},
|
99
|
+
{:name => 'Variable2', :qual => :measure, :type => :numeric, :formula => 'Sum([Object2])', :variable => @variable_expression_2},
|
100
|
+
]
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should return an array of variables" do
|
104
|
+
@webi.variables.should == @variables
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should cache results" do
|
108
|
+
2.times{@webi.variables}
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
3
2
|
require 'bosdk/webi_report_engine'
|
4
3
|
|
@@ -13,21 +12,28 @@ module BOSDK
|
|
13
12
|
module ReportEngines; module ReportEngineType; module WI_REPORT_ENGINE; end; end; end
|
14
13
|
@report_engines.should_receive(:getService).at_least(1).with(ReportEngines::ReportEngineType::WI_REPORT_ENGINE).and_return(@webi_report_engine)
|
15
14
|
@webi_report_engine.should_receive(:setLocale).at_least(1).with("en_US")
|
16
|
-
#@enterprise_session.should_receive(:setAttribute).at_least(1).with("widReportEngine", @webi_report_engine)
|
17
15
|
|
18
16
|
@wre = WebiReportEngine.new(@enterprise_session)
|
19
17
|
end
|
20
18
|
|
21
|
-
|
22
|
-
|
19
|
+
describe "#new" do
|
20
|
+
before(:each) do
|
21
|
+
@webi_report_engine.should_receive(:setLocale).once.with("en_CA")
|
22
|
+
end
|
23
23
|
|
24
|
-
|
24
|
+
it "should allow you to set the locale" do
|
25
|
+
WebiReportEngine.new(@enterprise_session, "en_CA")
|
26
|
+
end
|
25
27
|
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
+
describe "#open" do
|
30
|
+
before(:each) do
|
31
|
+
@webi_report_engine.should_receive(:openDocument).once.with("1234")
|
32
|
+
end
|
29
33
|
|
30
|
-
|
34
|
+
it "should call the underlying #openDocument with the supplied docid" do
|
35
|
+
@wre.open("1234")
|
36
|
+
end
|
31
37
|
end
|
32
38
|
end
|
33
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: universal-java-1.6
|
6
6
|
authors:
|
7
7
|
- Shane Emmons
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-09 00:00:00 -05:00
|
13
13
|
default_executable: boirb
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -39,28 +39,34 @@ executables:
|
|
39
39
|
extensions: []
|
40
40
|
|
41
41
|
extra_rdoc_files:
|
42
|
+
- LICENSE
|
42
43
|
- README.rdoc
|
43
|
-
- MIT-LICENSE
|
44
44
|
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
45
48
|
- README.rdoc
|
46
|
-
- MIT-LICENSE
|
47
|
-
- bosdk.gemspec
|
48
49
|
- Rakefile
|
50
|
+
- VERSION
|
49
51
|
- bin/boirb
|
52
|
+
- bosdk.gemspec
|
50
53
|
- lib/bosdk.rb
|
51
54
|
- lib/bosdk/enterprise_session.rb
|
52
55
|
- lib/bosdk/info_object.rb
|
56
|
+
- lib/bosdk/webi_instance.rb
|
53
57
|
- lib/bosdk/webi_report_engine.rb
|
58
|
+
- spec/bosdk_spec.rb
|
54
59
|
- spec/enterprise_session_spec.rb
|
55
60
|
- spec/info_object_spec.rb
|
61
|
+
- spec/webi_instance_spec.rb
|
56
62
|
- spec/webi_report_engine_spec.rb
|
57
63
|
has_rdoc: true
|
58
64
|
homepage: http://semmons99.github.com/bosdk
|
59
65
|
licenses: []
|
60
66
|
|
61
67
|
post_install_message:
|
62
|
-
rdoc_options:
|
63
|
-
|
68
|
+
rdoc_options:
|
69
|
+
- --charset=UTF-8
|
64
70
|
require_paths:
|
65
71
|
- lib
|
66
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -82,5 +88,9 @@ rubygems_version: 1.3.5
|
|
82
88
|
signing_key:
|
83
89
|
specification_version: 3
|
84
90
|
summary: JRuby Business Object Java SDK wrapper
|
85
|
-
test_files:
|
86
|
-
|
91
|
+
test_files:
|
92
|
+
- spec/bosdk_spec.rb
|
93
|
+
- spec/enterprise_session_spec.rb
|
94
|
+
- spec/info_object_spec.rb
|
95
|
+
- spec/webi_instance_spec.rb
|
96
|
+
- spec/webi_report_engine_spec.rb
|