bosdk 1.0.0-universal-java-1.6 → 1.0.1-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.
@@ -1,4 +1,4 @@
1
- = BOSDK.gem v1.0.0
1
+ = BOSDK.gem v1.0.1
2
2
 
3
3
  == Description
4
4
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "bosdk"
3
- s.version = "1.0.0"
3
+ s.version = "1.0.1"
4
4
 
5
5
  s.author = "Shane Emmons"
6
6
  s.description = "A JRuby wrapper for the Business Objects Java SDK"
@@ -23,6 +23,7 @@
23
23
  include Java
24
24
  Dir.glob(ENV["BOE_JAVA_LIB"] + "/*.jar").each{|jar| require jar}
25
25
  include_class "com.crystaldecisions.sdk.framework.CrystalEnterprise"
26
+ include_class "com.crystaldecisions.sdk.uri.PagingQueryOptions"
26
27
 
27
28
  require 'bosdk/enterprise_session'
28
29
  require 'bosdk/info_object'
@@ -34,10 +34,16 @@ module BOSDK
34
34
  nil
35
35
  end
36
36
 
37
+ # Converts 'path://', 'query://' and 'cuid://' special forms to a SDK query
38
+ def path_to_sql(path_stmt)
39
+ @infostore.getStatelessPageInfo(path_stmt, PagingQueryOptions.new).getPageSQL
40
+ end
41
+
37
42
  # Queries the InfoStore with the provided statement, returning an Array of
38
43
  # InfoObject(s).
39
44
  def query(stmt)
40
- @infostore.query(stmt).map{|o| InfoObject.new(o)}
45
+ sql = stmt.match(/^(path|query|cuid):\/\//i) ? path_to_sql(stmt) : stmt
46
+ @infostore.query(sql).map{|o| InfoObject.new(o)}
41
47
  end
42
48
  end
43
49
  end
@@ -2,6 +2,7 @@
2
2
  include Java
3
3
  Dir.glob(ENV["BOE_JAVA_LIB"] + "/*.jar").each {|jar| require jar}
4
4
  include_class "com.crystaldecisions.sdk.framework.CrystalEnterprise"
5
+ include_class "com.crystaldecisions.sdk.uri.PagingQueryOptions"
5
6
 
6
7
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
7
8
  require 'bosdk/enterprise_session'
@@ -47,11 +48,54 @@ module BOSDK
47
48
  lambda{2.times{ @es.disconnect }}.should_not raise_exception
48
49
  end
49
50
 
51
+ specify "#path_to_sql should convert a path query to an sql query" do
52
+ path_query = 'path://SystemObjects/Users/Administrator@SI_ID'
53
+ stmt = "SELECT SI_ID FROM CI_SYSTEMOBJECTS WHERE SI_KIND='User' AND SI_NAME='Administrator'"
54
+
55
+ @stateless_page_info = mock("IStatelessPageInfo").as_null_object
56
+
57
+ PagingQueryOptions.should_receive(:new).once.with
58
+ @infostore.should_receive(:getStatelessPageInfo).once.with(path_query, nil).and_return(@stateless_page_info)
59
+ @stateless_page_info.should_receive(:getPageSQL).once.with.and_return(stmt)
60
+
61
+ @es.path_to_sql(path_query).should == stmt
62
+ end
63
+
50
64
  specify "#query should send the statement to the underlying InfoStore" do
51
- stmt = 'SELECT * FROM CI_infoobjectS'
65
+ stmt = 'SELECT * FROM CI_INFOOBJECTS'
52
66
  @infostore.should_receive(:query).once.with(stmt).and_return([])
53
67
 
54
68
  @es.query(stmt)
55
69
  end
70
+
71
+ specify "#query should convert a path:// query to sql before execution" do
72
+ path_query = 'path://SystemObjects/Users/Administrator@SI_ID'
73
+ stmt = "SELECT * FROM CI_SYSTEMOBJECTS WHERE SI_KIND='User' AND SI_NAME='Administator'"
74
+
75
+ @es.should_receive(:path_to_sql).once.with(path_query).and_return(stmt)
76
+ @infostore.should_receive(:query).once.with(stmt).and_return([])
77
+
78
+ @es.query(path_query)
79
+ end
80
+
81
+ specify "#query should convert a query:// query to sql before execution" do
82
+ path_query = 'query://{SELECT * FROM CI_INFOOBJECTS}'
83
+ stmt = 'SELECT * FROM CI_INFOOBJECTS'
84
+
85
+ @es.should_receive(:path_to_sql).once.with(path_query).and_return(stmt)
86
+ @infostore.should_receive(:query).once.with(stmt).and_return([])
87
+
88
+ @es.query(path_query)
89
+ end
90
+
91
+ specify "#query should convert a cuid:// query to sql before execution" do
92
+ path_query = 'cuid://ABC'
93
+ stmt = "SELECT * FROM CI_INFOOBJECTS WHERE SI_CUID='ABC'"
94
+
95
+ @es.should_receive(:path_to_sql).once.with(path_query).and_return(stmt)
96
+ @infostore.should_receive(:query).once.with(stmt).and_return([])
97
+
98
+ @es.query(path_query)
99
+ end
56
100
  end
57
101
  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.0
4
+ version: 1.0.1
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-01-21 00:00:00 -05:00
12
+ date: 2010-01-28 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15