Class: XMLService::I_CALL

Inherits:
I_Meta
  • Object
show all
Defined in:
lib/xmlservice.rb

Direct Known Subclasses

I_CMD, I_DB2, I_PGM, I_SH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from I_Meta

#add_user_accessor, #instance_variable_forward_get, #instance_variable_forward_set, #parse_diag_attr, #remove_user_accessor, #shortCut

Constructor Details

#initialize(options) ⇒ I_CALL

Returns a new instance of I_CALL.



1226
1227
1228
1229
1230
1231
1232
# File 'lib/xmlservice.rb', line 1226

def initialize(options)
  @xml_options = ActiveXMLService::Base.symbolize_keys(options)
 @xml_is_error = true
  @input = I_Data.new
  @response = I_Data.new
  @returndata = I_Data.new
end

Instance Attribute Details

#inputObject

Returns the value of attribute input.



1225
1226
1227
# File 'lib/xmlservice.rb', line 1225

def input
  @input
end

#reponseObject

Returns the value of attribute reponse.



1225
1226
1227
# File 'lib/xmlservice.rb', line 1225

def reponse
  @reponse
end

#returnObject

Returns the value of attribute return.



1225
1226
1227
# File 'lib/xmlservice.rb', line 1225

def return
  @return
end

Instance Method Details

#call(p0 = nil, p1 = nil, p2 = nil, p3 = nil, p4 = nil, p5 = nil, p6 = nil, p7 = nil, p8 = nil, p9 = nil, p10 = nil, p11 = nil, p12 = nil, p13 = nil, p14 = nil, p15 = nil, p16 = nil, p17 = nil, p18 = nil, p19 = nil, p20 = nil, p21 = nil, p22 = nil, p23 = nil, p24 = nil, p25 = nil, p26 = nil, p27 = nil, p28 = nil, p29 = nil, p30 = nil, p31 = nil, p32 = nil, p33 = nil, p34 = nil, p35 = nil, p36 = nil, p37 = nil, p38 = nil, p39 = nil, p40 = nil, p41 = nil, p42 = nil, p43 = nil, p44 = nil, p45 = nil, p46 = nil, p47 = nil, p48 = nil, p49 = nil, p50 = nil, p51 = nil, p52 = nil, p53 = nil, p54 = nil, p55 = nil, p56 = nil, p57 = nil, p58 = nil, p59 = nil, p60 = nil, p61 = nil, p62 = nil, p63 = nil, p64 = nil) ⇒ Object



1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
# File 'lib/xmlservice.rb', line 1290

def call(p0=nil,p1=nil,p2=nil,p3=nil,p4=nil,p5=nil,p6=nil,p7=nil,p8=nil,p9=nil,
         p10=nil,p11=nil,p12=nil,p13=nil,p14=nil,p15=nil,p16=nil,p17=nil,p18=nil,p19=nil,
         p20=nil,p21=nil,p22=nil,p23=nil,p24=nil,p25=nil,p26=nil,p27=nil,p28=nil,p29=nil,
         p30=nil,p31=nil,p32=nil,p33=nil,p34=nil,p35=nil,p36=nil,p37=nil,p38=nil,p39=nil,
         p40=nil,p41=nil,p42=nil,p43=nil,p44=nil,p45=nil,p46=nil,p47=nil,p48=nil,p49=nil,
         p50=nil,p51=nil,p52=nil,p53=nil,p54=nil,p55=nil,p56=nil,p57=nil,p58=nil,p59=nil,
         p60=nil,p61=nil,p62=nil,p63=nil,p64=nil)
  self.call_recursive(nil,p0)
  self.call_recursive(nil,p1)
  self.call_recursive(nil,p2)
  self.call_recursive(nil,p3)
  self.call_recursive(nil,p4)
  self.call_recursive(nil,p5)
  self.call_recursive(nil,p6)
  self.call_recursive(nil,p7)
  self.call_recursive(nil,p8)
  self.call_recursive(nil,p9)

  self.call_recursive(nil,p10)
  self.call_recursive(nil,p11)
  self.call_recursive(nil,p12)
  self.call_recursive(nil,p13)
  self.call_recursive(nil,p14)
  self.call_recursive(nil,p15)
  self.call_recursive(nil,p16)
  self.call_recursive(nil,p17)
  self.call_recursive(nil,p18)
  self.call_recursive(nil,p19)

  self.call_recursive(nil,p20)
  self.call_recursive(nil,p21)
  self.call_recursive(nil,p22)
  self.call_recursive(nil,p23)
  self.call_recursive(nil,p24)
  self.call_recursive(nil,p25)
  self.call_recursive(nil,p26)
  self.call_recursive(nil,p27)
  self.call_recursive(nil,p28)
  self.call_recursive(nil,p29)

  self.call_recursive(nil,p30)
  self.call_recursive(nil,p31)
  self.call_recursive(nil,p32)
  self.call_recursive(nil,p33)
  self.call_recursive(nil,p34)
  self.call_recursive(nil,p35)
  self.call_recursive(nil,p36)
  self.call_recursive(nil,p37)
  self.call_recursive(nil,p38)
  self.call_recursive(nil,p39)

  self.call_recursive(nil,p40)
  self.call_recursive(nil,p41)
  self.call_recursive(nil,p42)
  self.call_recursive(nil,p43)
  self.call_recursive(nil,p44)
  self.call_recursive(nil,p45)
  self.call_recursive(nil,p46)
  self.call_recursive(nil,p47)
  self.call_recursive(nil,p48)
  self.call_recursive(nil,p49)

  self.call_recursive(nil,p50)
  self.call_recursive(nil,p51)
  self.call_recursive(nil,p52)
  self.call_recursive(nil,p53)
  self.call_recursive(nil,p54)
  self.call_recursive(nil,p55)
  self.call_recursive(nil,p56)
  self.call_recursive(nil,p57)
  self.call_recursive(nil,p58)
  self.call_recursive(nil,p59)

  self.call_recursive(nil,p60)
  self.call_recursive(nil,p61)
  self.call_recursive(nil,p62)
  self.call_recursive(nil,p63)
  self.call_recursive(nil,p64)

  self.xmlservice
end

#call_recursive(k, v) ⇒ Object



1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
# File 'lib/xmlservice.rb', line 1256

def call_recursive(k,v)
  if k.nil?
    k = "input"
  end
  if !v.nil?
    if v.instance_of? Hash
      v.each do | k1, v1 |
        if k.eql? "input"
#puts "Hash #{k}.#{k1}, #{v1}"
          call_recursive(k + "." + k1,v1)
        elsif v1.instance_of? Hash or v.instance_of? Array
#puts "Hash #{k}['#{k1}'], #{v1}"
          call_recursive(k + "['#{k1}']",v1)
        else
#puts "Hash #{k}.#{k1}, #{v1}"
          call_recursive(k + "." + k1,v1)
        end
      end
    elsif v.instance_of? Array
      for i in 0..v.count-1
        if k.eql? "input"
#puts "Array #{k}, #{v[1]}"
          call_recursive(k,v[i])
        else
#puts "Array #{k}[#{i}], #{v[1]}"
          call_recursive(k + "[#{i}]",v[i])
        end
      end
    elsif !k.eql? "input"
#puts "self.#{k} = #{v}"
      eval "self.#{k} = v"
    end
  end
end

#dumpObject



1429
1430
1431
1432
# File 'lib/xmlservice.rb', line 1429

def dump()
  msg = self.dump_error(true,true,true,true,true)
  msg
end

#dump_allObject



1433
1434
1435
1436
# File 'lib/xmlservice.rb', line 1433

def dump_all()
  msg = self.dump_error(true,true,true,true,true)
  msg
end

#dump_error(xmlversion = true, xmlerror = true, jobinfo = true, jobscan = true, joblog = true) ⇒ Object



1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
# File 'lib/xmlservice.rb', line 1437

def dump_error(xmlversion=true,xmlerror=true,jobinfo=true,jobscan=true,joblog=true)
  msg = "\n"
  # xmlservice error occurred?
  if self.xmlservice_error and defined? self.PARM
    msg << "=== Dump ===\n"
    # xmlservice version (all error modes)
    if xmlversion and defined? self.PARM.version
	    msg << "Version\n"
      msg << "  version: #{self.PARM.version}\n"
    end
    # xmlservice job information (all error modes)
    if jobinfo and defined? self.PARM.jobinfo
      info = self.PARM.jobinfo
      msg << "Job\n"
      msg << " jobipc:      #{info.jobipc}\n"
      msg << " jobipcskey:  #{info.jobipcskey}\n"
      msg << " jobname:     #{info.jobname}\n"
      msg << " jobuser:     #{info.jobuser}\n"
      msg << " jobnbr:      #{info.jobnbr}\n"
      msg << " jobsts:      #{info.jobsts}\n"
      msg << " curuser:     #{info.curuser}\n"
      msg << " ccsid:       #{info.ccsid}\n"
      msg << " dftccsid:    #{info.dftccsid}\n"
      msg << " paseccsid:   #{info.paseccsid}\n"
      msg << " langid:      #{info.langid}\n"
      msg << " cntryid:     #{info.cntryid}\n"
      msg << " sbsname:     #{info.sbsname}\n"
      msg << " sbslib:      #{info.sbslib}\n"
      msg << " curlib:      #{info.curlib}\n"
      msg << " syslibl:     #{info.syslibl}\n"
      msg << " usrlibl:     #{info.usrlibl}\n"
    end
    # xmlservice fast internal error log (all error modes)
    if xmlerror and defined? self.PARM.error
	    msg << "XMLError\n"
      for j in 0..self.PARM.error.count-1
        err = self.PARM.error[j]
     msg << " #{err.errnoxml}"
     msg << " : #{err.xmlerrmsg}"
     msg << " : #{err.xmlhint}\n"
      end
    end
    # xmlservice joblog scan (error='on' or error='off')
    if jobscan and defined? self.PARM.joblogscan
      msg << "JoblogScan\n"
      for j in 0..self.PARM.joblogscan.joblogrec.count-1
        log = self.PARM.joblogscan.joblogrec[j]
     msg << " #{log.jobcpf}"
     msg << " : #{log.jobtime}\n"
     msg << "         : #{log.jobtext}\n"
      end
    end
    # xmlservice joblog scan (error='on' or error='off')
    if joblog and defined? self.PARM.joblog
	    msg << "Joblog\n"
      msg << "#{self.PARM.joblog.joblogdata}\n"
    end
  end
  msg
end

#dump_inspectObject



1509
1510
1511
1512
1513
1514
1515
# File 'lib/xmlservice.rb', line 1509

def dump_inspect
  out = ""
  out << "\n" << self.dump_inspect_input
  out << "\n" << self.dump_inspect_response
  out << "\n" << self.dump_inspect_returndata
  out
end

#dump_inspect_inputObject



1516
1517
1518
1519
# File 'lib/xmlservice.rb', line 1516

def dump_inspect_input
  out = "Input:\n" << self.format_inspect(@input,"input")
  out
end

#dump_inspect_responseObject



1520
1521
1522
1523
# File 'lib/xmlservice.rb', line 1520

def dump_inspect_response
  out = "Response:\n" << self.format_inspect(@response,"response")
  out
end

#dump_inspect_returndataObject



1524
1525
1526
1527
# File 'lib/xmlservice.rb', line 1524

def dump_inspect_returndata
  out = "ReturnData:\n" << self.format_inspect(@returndata,"returndata")
  out
end

#execute(p0 = nil, p1 = nil, p2 = nil, p3 = nil, p4 = nil, p5 = nil, p6 = nil, p7 = nil, p8 = nil, p9 = nil, p10 = nil, p11 = nil, p12 = nil, p13 = nil, p14 = nil, p15 = nil, p16 = nil, p17 = nil, p18 = nil, p19 = nil, p20 = nil, p21 = nil, p22 = nil, p23 = nil, p24 = nil, p25 = nil, p26 = nil, p27 = nil, p28 = nil, p29 = nil, p30 = nil, p31 = nil, p32 = nil, p33 = nil, p34 = nil, p35 = nil, p36 = nil, p37 = nil, p38 = nil, p39 = nil, p40 = nil, p41 = nil, p42 = nil, p43 = nil, p44 = nil, p45 = nil, p46 = nil, p47 = nil, p48 = nil, p49 = nil, p50 = nil, p51 = nil, p52 = nil, p53 = nil, p54 = nil, p55 = nil, p56 = nil, p57 = nil, p58 = nil, p59 = nil, p60 = nil, p61 = nil, p62 = nil, p63 = nil, p64 = nil) ⇒ Object



1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
# File 'lib/xmlservice.rb', line 1371

def execute(p0=nil,p1=nil,p2=nil,p3=nil,p4=nil,p5=nil,p6=nil,p7=nil,p8=nil,p9=nil,
         p10=nil,p11=nil,p12=nil,p13=nil,p14=nil,p15=nil,p16=nil,p17=nil,p18=nil,p19=nil,
         p20=nil,p21=nil,p22=nil,p23=nil,p24=nil,p25=nil,p26=nil,p27=nil,p28=nil,p29=nil,
         p30=nil,p31=nil,p32=nil,p33=nil,p34=nil,p35=nil,p36=nil,p37=nil,p38=nil,p39=nil,
         p40=nil,p41=nil,p42=nil,p43=nil,p44=nil,p45=nil,p46=nil,p47=nil,p48=nil,p49=nil,
         p50=nil,p51=nil,p52=nil,p53=nil,p54=nil,p55=nil,p56=nil,p57=nil,p58=nil,p59=nil,
         p60=nil,p61=nil,p62=nil,p63=nil,p64=nil)
  self.call(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,
            p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,
            p20,p21,p22,p23,p24,p25,p26,p27,p28,p29,
            p30,p31,p32,p33,p34,p35,p36,p37,p38,p39,
            p40,p41,p42,p43,p44,p45,p46,p47,p48,p49,
            p50,p51,p52,p53,p54,p55,p56,p57,p58,p59,
            p60,p61,p62,p63,p64)
end

#format_inspect(cat, top) ⇒ Object



1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
# File 'lib/xmlservice.rb', line 1613

def format_inspect(cat,top)
  if top.eql? "input"
    isInput = true
  else
    isInput = false
  end
  whatami = cat.class.name
  out = ""
  out2 = "@#{top} -> #{whatami}\n"
  out1 = ""
  if !cat.nil?
    alreadyseen = Array.new
    out2 << self.format_inspect_recursive(cat,".",alreadyseen,isInput)
    # shortcut methods
    shortcutmethods = cat.class.instance_methods
    alreadyseen.each do |name|
      shortcutmethods.each do |shortcut|
        if "#{name}".eql? "..@#{shortcut}"
          out1 << "obj." << top << ".#{shortcut}\n"
        end
      end
    end
  end
  out = out1 + out2
  out
end

#format_inspect_include(name) ⇒ Object



1501
1502
1503
1504
1505
1506
1507
1508
# File 'lib/xmlservice.rb', line 1501

def format_inspect_include(name)
  self.reserved_words.each do |no|
    if name.include? no
      return false
    end
  end
  true
end

#format_inspect_recursive(lastvar, dot, alreadyseen, isInput) ⇒ Object



1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
# File 'lib/xmlservice.rb', line 1528

def format_inspect_recursive(lastvar,dot,alreadyseen,isInput)
# puts "top #{dot}#{lastvar.class.name}"
  out = ""
  if isInput
    if lastvar.kind_of? Hash
      outvar = Array.new
      lastvar.each do |k, v|
        out << dot + "[#{k}]\n"
        out << self.format_inspect_recursive(v,dot + ".",alreadyseen,isInput)
      end
    elsif lastvar.kind_of? Array
      outvar = Array.new
      for i in 0..lastvar.count-1
        out << dot + "[#{i}]\n"
        out << self.format_inspect_recursive(lastvar[i],dot + ".",alreadyseen,isInput)
      end
    else
      outvar = lastvar.instance_variables
    end
  else
    outvar = lastvar.instance_variables
  end
  outvar.each do |v|
    name = v.to_s
# puts "child #{dot}#{name}"
    if !self.format_inspect_include(name)
      next
    end
    go = true
    alreadyseen.each do |seen|
      if (dot + "#{name}").eql? "#{seen}"
        go = false
        break;
      end
    end
    if !go
      next
    end
    nextvar = lastvar.instance_variable_get(name)
# puts "next #{dot}#{name} #{nextvar.class.name}"
     if isInput
      if dot.eql? "." and !name.include? "PARM"
        next
      end
     else 
      if dot.eql? "."
        if (self.kind_of? I_PGM or self.kind_of? I_SRVPGM) and !(nextvar.kind_of? I_Return or nextvar.kind_of? I_Parameter)
          next
        end
      end
    end
    whatami = nextvar.class.name
    cln = ""
    if nextvar.instance_of? I_DS
      cln = "[i]"
    elsif nextvar.instance_of? Array
      cln = "[i]"
    elsif nextvar.instance_of? Hash
      cln = "[k,v]"
    end
    out << dot + "#{name}#{cln} -> #{whatami}\n"
    alreadyseen << dot + "#{name}"
    if !isInput and nextvar.kind_of? I_Base
      next
    end
    if !nextvar.nil?
      if nextvar.instance_of? Array
        i = 0
        nextvar.each do | value |
          out << dot + "[#{i}]\n"
          out << self.format_inspect_recursive(value,dot + ".",alreadyseen,isInput)
          i += 1
        end
      elsif nextvar.instance_of? Hash
        nextvar.each do | key, value |
          out << dot + "[#{key}]\n"
          out << self.format_inspect_recursive(value,dot + ".",alreadyseen,isInput)
        end
      else
        out << self.format_inspect_recursive(nextvar,dot + ".",alreadyseen,isInput)
      end
    end
  end
  out
end

#out_xmlObject



1425
1426
1427
1428
# File 'lib/xmlservice.rb', line 1425

def out_xml
  s = @xml_doc.to_s
  s
end

#parse_output_attrObject



1395
1396
1397
# File 'lib/xmlservice.rb', line 1395

def parse_output_attr()
  @response = I_Data.new
end

#parse_return_attrObject



1401
1402
1403
# File 'lib/xmlservice.rb', line 1401

def parse_return_attr()
  @returndata = I_Data.new
end

#reserved_wordsObject



1497
1498
1499
1500
# File 'lib/xmlservice.rb', line 1497

def reserved_words
  no = ["@xml_"]
  no
end

#responseObject



1392
1393
1394
# File 'lib/xmlservice.rb', line 1392

def response()
  @response
end

#returndataObject



1398
1399
1400
# File 'lib/xmlservice.rb', line 1398

def returndata()
  @returndata
end

#xmlserviceObject



1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
# File 'lib/xmlservice.rb', line 1233

def xmlservice()
 @xml_is_error = true
  # one thread at a time please
  ActiveXMLService::Base.semaphore.synchronize {
    # user supplied connection
    if @xml_options && @xml_options.has_key?(:connection)
      adapter = ActiveXMLService::Base.adapter_factory(@xml_options)
    # standard rails connection (singleton)
    else
      adapter = ActiveXMLService::Base.connection
      # I believe "the Rails way" would be to lead them down a best-practice path,
      # xmlservice over db2 stored procedures is most common connection (best)
      if adapter.nil?
        adapter = ActiveXMLService::Base.adapter_factory('connection'=>'ActiveRecord')
      end
    end
    adapter.xmlservice(self)
    @xml_doc = adapter.out_doc
  }
  @xml_is_error = self.parse_diag_attr
  self.parse_output_attr
  self.parse_return_attr
end

#xmlservice_diag_parse(mypath = "/report") ⇒ Object



1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
# File 'lib/xmlservice.rb', line 1404

def xmlservice_diag_parse(mypath="/report")
  diag = nil
  @xml_doc.elements.each("/report") do |report|
    diag = I_Diag.new(report)
    break
  end
  if diag == nil
    @xml_doc.elements.each("#{mypath}/error") do |element|
      @xml_doc.elements.each("#{mypath}") do |report|
        diag = I_Diag.new(report)
        break
      end
      break
    end
  end
  if diag == nil
    return false
  end
  add_user_accessor('PARM', diag)
 return true
end

#xmlservice_errorObject



1386
1387
1388
# File 'lib/xmlservice.rb', line 1386

def xmlservice_error
 @xml_is_error
end