sneaql 0.0.19-java → 0.0.20-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c36b484ebefc8fb9d9d8a27138bb331ac84990c7ca3a22abe10c6a2fd54e92bc
4
- data.tar.gz: 497baa4c078fea035b1a76cd74d86891ab6fbdad310af55639695e63a9c9e7d7
3
+ metadata.gz: 8e5f3a3178b52ab661d45c5987378fef1c50a5bf1c4b21b23909b4ea14d73a0d
4
+ data.tar.gz: 0c139bb80dc24cdbfe816ae4e7cd3f4d64eff2151c88e0c785e904dc9a69b55c
5
5
  SHA512:
6
- metadata.gz: 175b6fc7cacefe1eaa25ceb0b5a58055f2574774f2968efba4c6974ff4416a6b70702ee4c770dc1ec297ed33aed9bdbb0a4da750262decae80d31e044bf11e02
7
- data.tar.gz: 3f99053a1b7fc6dbf102b12ad217d7a88b10440808faafd6f3173424e5b66e4f8f4182684781b38d7bfe60e97395adf3d01627fed0aad5913c49261f14cbd407
6
+ metadata.gz: a0085e97d956acb92bc56c64ecfeb45f18b62d451f959e219cb1e5ec0c1c49f2ea27bccca7189516d6b5ec4e4afa6886b8543438561494e33d2a1614880f25bf
7
+ data.tar.gz: d946b6a4e64583bb1aad32fb504deac107c829d8478c104b8e85e16c2809fdb38c7cdd5b77575180eebb895fe80e18547a7d3d353084cbb09abf2e6f600266d8
data/lib/sneaql.rb CHANGED
@@ -244,9 +244,19 @@ module Sneaql
244
244
  end
245
245
 
246
246
  begin
247
+ # find the class assciated with this command
248
+ k = Sneaql::Core.find_class(:command, this_cmd[:command])
249
+
250
+ # if there is an error... check to see if this is the error handler
251
+ if @exception_manager.pending_error != nil
252
+ unless k == Sneaql::Core::Commands::SneaqlOnError
253
+ raise @exception_manager.pending_error
254
+ end
255
+ end
256
+
247
257
  # instantiate a new instance of the command class
248
258
  # and call it's action method with arguments
249
- c = Sneaql::Core.find_class(:command, this_cmd[:command]).new(
259
+ c = k.new(
250
260
  @jdbc_connection,
251
261
  @expression_handler,
252
262
  @exception_manager,
@@ -255,12 +265,7 @@ module Sneaql
255
265
  @logger
256
266
  )
257
267
 
258
- if @exception_manager.pending_error != nil
259
- unless c.class == Sneaql::Core::Commands::SneaqlOnError
260
- raise @exception_manager.pending_error
261
- end
262
- end
263
-
268
+ # performs the work of the current command
264
269
  c.action(*this_cmd[:arguments])
265
270
 
266
271
  # check if there was an error from the action
@@ -231,7 +231,7 @@ module Sneaql
231
231
  # @param [String] recordset_name name of the recordset in which to store the results
232
232
  def action(recordset_name)
233
233
  r = query_results
234
- @logger.debug "adding #{r.length} recs as #{recordset_name}"
234
+ @logger.info "adding #{r.length} recs as #{recordset_name}"
235
235
  @recordset_manager.store_recordset(recordset_name, r)
236
236
  rescue => e
237
237
  @exception_manager.pending_error = e
@@ -252,6 +252,28 @@ module Sneaql
252
252
  end
253
253
  end
254
254
 
255
+ # runs the query then stores the array of hashes into the recordset hash
256
+ class SneaqlRemoveRecordset < Sneaql::Core::SneaqlCommand
257
+ Sneaql::Core::RegisterMappedClass.new(
258
+ :command,
259
+ 'remove_recordset',
260
+ Sneaql::Core::Commands::SneaqlRemoveRecordset
261
+ )
262
+
263
+ # @param [String] recordset_name name of the recordset in which to store the results
264
+ def action(recordset_name)
265
+ @logger.info "removing recordset #{recordset_name}"
266
+ @recordset_manager.remove_recordset(recordset_name)
267
+ rescue => e
268
+ @exception_manager.pending_error = e
269
+ end
270
+
271
+ # argument types
272
+ def arg_definition
273
+ [:recordset]
274
+ end
275
+ end
276
+
255
277
  # iterates a recordset and runs the sql statement for each record
256
278
  class SneaqlIterateRecordset < Sneaql::Core::SneaqlCommand
257
279
  Sneaql::Core::RegisterMappedClass.new(
@@ -299,6 +321,7 @@ module Sneaql
299
321
 
300
322
  # @param [String] recordset recordset to iterate
301
323
  def iterate_all_records(recordset)
324
+ raise Sneaql::Exceptions::RecordsetDoesNotExistError unless @recordset_manager.recordset.has_key?(recordset)
302
325
  @logger.info "iterating recordset #{recordset}..."
303
326
  @recordset_manager.recordset[recordset].each_with_index do |i, n|
304
327
  @logger.debug("#{n + 1} of #{recordset}: #{i}")
@@ -60,6 +60,13 @@ module Sneaql
60
60
  end
61
61
  end
62
62
 
63
+ # Recordset check failure indicator
64
+ class RecordsetDoesNotExistError < BaseError
65
+ def initialize(msg = 'Specified ecordset does not exist')
66
+ super
67
+ end
68
+ end
69
+
63
70
  # General error evaluating expression.
64
71
  class ExpressionEvaluationError < BaseError
65
72
  def initialize(msg = 'Error evaluating expression')
@@ -21,10 +21,20 @@ module Sneaql
21
21
  recordset[name] = rs
22
22
  end
23
23
 
24
+ # Deletes a recordset if it exists
25
+ # @param [String] name name for recordset to delete
26
+ def remove_recordset(name)
27
+ if @recordset.has_key?(name)
28
+ @recordset.delete(name)
29
+ end
30
+ end
31
+
24
32
  # Validates recordset. Must be an array of hashes with identical keys.
25
33
  # @param [Array<Hash>] rs recordset to validate
26
34
  def recordset_valid?(rs)
27
35
  return false unless rs.class == Array
36
+ # empty recordset is valid
37
+ return true if rs == []
28
38
  r1 = rs[0].keys
29
39
 
30
40
  rs.each do |record|
@@ -68,7 +78,7 @@ module Sneaql
68
78
  # takes in argument array as an argument
69
79
  # returns array of expressions to be checked at run time
70
80
  args.delete_at(0) # get rid of the first element, recordset ref
71
- args.each_slice(4).to_a.map{ |x| { condition: x[0].downcase, field: x[1], operator: x[2], expression: x[3]}}
81
+ args.each_slice(4).to_a.map{ |x| { condition: x[0].downcase, field: x[1], operator: x[2], expression: x[3]} }
72
82
  end
73
83
 
74
84
  # applies a conditional expression set against a record.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sneaql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  platform: java
6
6
  authors:
7
7
  - jeremy winters
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-21 00:00:00.000000000 Z
11
+ date: 2017-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement