xmlconv 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/History.txt +6 -0
- data/LICENSE +339 -0
- data/README.txt +29 -0
- data/Rakefile +37 -0
- data/bin/admin +68 -0
- data/bin/xmlconvd +38 -0
- data/data/grammar/i2.grammar +73 -0
- data/lib/xmlconv/config.rb +61 -0
- data/lib/xmlconv/custom/lookandfeel.rb +50 -0
- data/lib/xmlconv/i2/address.rb +35 -0
- data/lib/xmlconv/i2/date.rb +41 -0
- data/lib/xmlconv/i2/document.rb +27 -0
- data/lib/xmlconv/i2/header.rb +32 -0
- data/lib/xmlconv/i2/order.rb +61 -0
- data/lib/xmlconv/i2/parser.rb +23 -0
- data/lib/xmlconv/i2/position.rb +45 -0
- data/lib/xmlconv/i2/record.rb +11 -0
- data/lib/xmlconv/model/address.rb +20 -0
- data/lib/xmlconv/model/agreement.rb +10 -0
- data/lib/xmlconv/model/bdd.rb +37 -0
- data/lib/xmlconv/model/bsr.rb +16 -0
- data/lib/xmlconv/model/delivery.rb +15 -0
- data/lib/xmlconv/model/delivery_item.rb +24 -0
- data/lib/xmlconv/model/document.rb +25 -0
- data/lib/xmlconv/model/freetext_container.rb +26 -0
- data/lib/xmlconv/model/id_container.rb +22 -0
- data/lib/xmlconv/model/invoice.rb +18 -0
- data/lib/xmlconv/model/invoice_item.rb +11 -0
- data/lib/xmlconv/model/item.rb +19 -0
- data/lib/xmlconv/model/item_container.rb +15 -0
- data/lib/xmlconv/model/name.rb +27 -0
- data/lib/xmlconv/model/part_info.rb +10 -0
- data/lib/xmlconv/model/part_info_container.rb +15 -0
- data/lib/xmlconv/model/party.rb +20 -0
- data/lib/xmlconv/model/party_container.rb +20 -0
- data/lib/xmlconv/model/price.rb +10 -0
- data/lib/xmlconv/model/price_container.rb +18 -0
- data/lib/xmlconv/model/transaction.rb +28 -0
- data/lib/xmlconv/state/global.rb +28 -0
- data/lib/xmlconv/state/global_predefine.rb +11 -0
- data/lib/xmlconv/state/login.rb +39 -0
- data/lib/xmlconv/state/transaction.rb +13 -0
- data/lib/xmlconv/state/transactions.rb +130 -0
- data/lib/xmlconv/util/application.rb +142 -0
- data/lib/xmlconv/util/autoload.rb +35 -0
- data/lib/xmlconv/util/destination.rb +249 -0
- data/lib/xmlconv/util/invoicer.rb +71 -0
- data/lib/xmlconv/util/known_user.rb +16 -0
- data/lib/xmlconv/util/mail.rb +31 -0
- data/lib/xmlconv/util/polling_manager.rb +198 -0
- data/lib/xmlconv/util/session.rb +23 -0
- data/lib/xmlconv/util/transaction.rb +133 -0
- data/lib/xmlconv/util/validator.rb +20 -0
- data/lib/xmlconv/view/foot.rb +27 -0
- data/lib/xmlconv/view/head.rb +13 -0
- data/lib/xmlconv/view/login.rb +36 -0
- data/lib/xmlconv/view/navigation.rb +30 -0
- data/lib/xmlconv/view/navigationlink.rb +21 -0
- data/lib/xmlconv/view/pager.rb +73 -0
- data/lib/xmlconv/view/preformatted.rb +54 -0
- data/lib/xmlconv/view/template.rb +17 -0
- data/lib/xmlconv/view/transaction.rb +42 -0
- data/lib/xmlconv/view/transactions.rb +90 -0
- data/lib/xmlconv.rb +3 -0
- data/test/config.rb +12 -0
- data/test/mock.rb +149 -0
- data/test/suite.rb +16 -0
- data/test/test_i2/address.rb +88 -0
- data/test/test_i2/date.rb +50 -0
- data/test/test_i2/document.rb +62 -0
- data/test/test_i2/header.rb +39 -0
- data/test/test_i2/order.rb +94 -0
- data/test/test_i2/parser.rb +312 -0
- data/test/test_i2/position.rb +65 -0
- data/test/test_model/address.rb +35 -0
- data/test/test_model/agreement.rb +22 -0
- data/test/test_model/bdd.rb +55 -0
- data/test/test_model/bsr.rb +38 -0
- data/test/test_model/delivery.rb +79 -0
- data/test/test_model/delivery_item.rb +52 -0
- data/test/test_model/freetext_container.rb +45 -0
- data/test/test_model/invoice.rb +65 -0
- data/test/test_model/invoice_item.rb +41 -0
- data/test/test_model/name.rb +57 -0
- data/test/test_model/part_info.rb +24 -0
- data/test/test_model/party.rb +96 -0
- data/test/test_model/price.rb +24 -0
- data/test/test_util/application.rb +168 -0
- data/test/test_util/destination.rb +415 -0
- data/test/test_util/invoicer.rb +42 -0
- data/test/test_util/polling_manager.rb +299 -0
- data/test/test_util/transaction.rb +130 -0
- metadata +178 -0
@@ -0,0 +1,133 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Util::Transaction -- xmlconv2 -- 04.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'odba'
|
5
|
+
require 'xmlconv/util/destination'
|
6
|
+
require 'xmlconv/util/mail'
|
7
|
+
|
8
|
+
module XmlConv
|
9
|
+
module Util
|
10
|
+
class Transaction
|
11
|
+
include ODBA::Persistable
|
12
|
+
ODBA_SERIALIZABLE = ['@postprocs', '@responses', '@arguments']
|
13
|
+
odba_index :invoice_ids
|
14
|
+
attr_accessor :input, :reader, :writer, :destination, :origin,
|
15
|
+
:transaction_id, :partner, :error, :postprocs,
|
16
|
+
:error_recipients, :debug_recipients, :domain,
|
17
|
+
:response, :arguments
|
18
|
+
attr_reader :output, :model, :start_time, :commit_time,
|
19
|
+
:input_model, :output_model
|
20
|
+
def initialize
|
21
|
+
@postprocs = []
|
22
|
+
end
|
23
|
+
def execute
|
24
|
+
reader_instance = Conversion.const_get(@reader)
|
25
|
+
writer_instance = Conversion.const_get(@writer)
|
26
|
+
@start_time = Time.now
|
27
|
+
input_model = reader_instance.parse(@input)
|
28
|
+
@arguments ||= []
|
29
|
+
@model = reader_instance.convert(input_model, *@arguments)
|
30
|
+
output_model = writer_instance.convert(@model, *@arguments)
|
31
|
+
@output = output_model.to_s
|
32
|
+
@destination.deliver(output_model)
|
33
|
+
@commit_time = Time.now
|
34
|
+
@output
|
35
|
+
ensure
|
36
|
+
@destination.forget_credentials!
|
37
|
+
end
|
38
|
+
def invoice_ids
|
39
|
+
@model.invoices.collect do |inv|
|
40
|
+
inv.invoice_id.last.to_s.gsub /^0+/, ''
|
41
|
+
end
|
42
|
+
end
|
43
|
+
def notify
|
44
|
+
recipients = [@debug_recipients]
|
45
|
+
subject = 'XmlConv2 - Debug-Notification'
|
46
|
+
if(@error)
|
47
|
+
recipients.push(@error_recipients)
|
48
|
+
subject = 'XmlConv2 - Error-Notification'
|
49
|
+
end
|
50
|
+
recipients.flatten!
|
51
|
+
recipients.compact!
|
52
|
+
recipients.uniq!
|
53
|
+
return if(recipients.empty?)
|
54
|
+
body = <<-EOS
|
55
|
+
Date: #{@start_time.strftime("%d.%m.%Y")}
|
56
|
+
Time: #{@start_time.strftime("%H:%M:%S")}
|
57
|
+
Status: #{status}
|
58
|
+
Error: #{@error}
|
59
|
+
Link: http://#{@domain}/de/transaction/transaction_id/#{@transaction_id}
|
60
|
+
|
61
|
+
Input:
|
62
|
+
# input start
|
63
|
+
#{@input}
|
64
|
+
# input end
|
65
|
+
|
66
|
+
Output:
|
67
|
+
# output start
|
68
|
+
#{@output}
|
69
|
+
# output end
|
70
|
+
EOS
|
71
|
+
Util::Mail.notify recipients, subject, body
|
72
|
+
end
|
73
|
+
def odba_store
|
74
|
+
@input.extend(ODBA::Persistable) if(@input)
|
75
|
+
@output.extend(ODBA::Persistable) if(@output)
|
76
|
+
super
|
77
|
+
end
|
78
|
+
def postprocess
|
79
|
+
if(@postprocs.respond_to?(:each))
|
80
|
+
@postprocs.each { |klass, *args|
|
81
|
+
next if args.empty?
|
82
|
+
args.push(self)
|
83
|
+
PostProcess.const_get(klass).send(*args)
|
84
|
+
}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
def respond delivery, response
|
88
|
+
responses[delivery] = response
|
89
|
+
end
|
90
|
+
def response
|
91
|
+
reader_instance = Conversion.const_get(@reader)
|
92
|
+
if reader_instance.respond_to?(:respond)
|
93
|
+
reader_instance.respond(self, responses)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
def responses
|
97
|
+
@responses ||= []
|
98
|
+
end
|
99
|
+
def status
|
100
|
+
if(@error)
|
101
|
+
:error
|
102
|
+
elsif(@model.nil? || @model.empty?)
|
103
|
+
:empty
|
104
|
+
elsif(@destination.respond_to?(:status))
|
105
|
+
@destination.status
|
106
|
+
end
|
107
|
+
end
|
108
|
+
def status=(status)
|
109
|
+
if @destination.respond_to?(:status=)
|
110
|
+
@destination.status = status
|
111
|
+
@destination.odba_store
|
112
|
+
@destination.status
|
113
|
+
end
|
114
|
+
end
|
115
|
+
def status_comparable
|
116
|
+
if(@destination.respond_to?(:status_comparable))
|
117
|
+
@destination.status_comparable
|
118
|
+
end
|
119
|
+
end
|
120
|
+
def update_status
|
121
|
+
if(@destination.respond_to?(:update_status))
|
122
|
+
@destination.update_status
|
123
|
+
end
|
124
|
+
end
|
125
|
+
def uri
|
126
|
+
@destination.uri if(@destination.respond_to?(:uri))
|
127
|
+
end
|
128
|
+
def uri_comparable
|
129
|
+
self.uri.to_s
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Util::Validator -- xmlconv2 -- 09.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'sbsm/validator'
|
5
|
+
|
6
|
+
module XmlConv
|
7
|
+
module Util
|
8
|
+
class Validator < SBSM::Validator
|
9
|
+
EVENTS = [
|
10
|
+
:login, :logout, :sort, :transaction, :self, :home
|
11
|
+
]
|
12
|
+
STRINGS = [
|
13
|
+
:sortvalue,
|
14
|
+
]
|
15
|
+
NUMERIC = [
|
16
|
+
:transaction_id, :page
|
17
|
+
]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# View::Foot -- xmlconv2 -- 09.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'htmlgrid/composite'
|
5
|
+
require 'xmlconv/view/navigation'
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
module XmlConv
|
9
|
+
module View
|
10
|
+
class Foot < HtmlGrid::Composite
|
11
|
+
COMPONENTS = {
|
12
|
+
[0,0] => :copyright,
|
13
|
+
[1,0] => Navigation,
|
14
|
+
}
|
15
|
+
CSS_CLASS = 'foot composite'
|
16
|
+
LEGACY_INTERFACE = false
|
17
|
+
def copyright(model)
|
18
|
+
link = HtmlGrid::Link.new(:copyright, model, @session, self)
|
19
|
+
link.href = 'http://www.ywesee.com'
|
20
|
+
link.value = @lookandfeel.lookup(:copyright, Date.today.strftime('%Y'))
|
21
|
+
link.css_class = 'foot'
|
22
|
+
link.target = '_blank'
|
23
|
+
link
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# View::Login -- xmlconv2 -- 09.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'xmlconv/view/template'
|
5
|
+
require 'htmlgrid/form'
|
6
|
+
require 'htmlgrid/pass'
|
7
|
+
|
8
|
+
module XmlConv
|
9
|
+
module View
|
10
|
+
class LoginForm < HtmlGrid::Form
|
11
|
+
COMPONENTS = {
|
12
|
+
[0,0] => :pass,
|
13
|
+
[1,1] => :submit,
|
14
|
+
}
|
15
|
+
CSS_CLASS = 'component'
|
16
|
+
EVENT = :login
|
17
|
+
LABELS = true
|
18
|
+
SYMBOL_MAP = {
|
19
|
+
:pass => HtmlGrid::Pass,
|
20
|
+
}
|
21
|
+
end
|
22
|
+
class LoginComposite < HtmlGrid::Composite
|
23
|
+
COMPONENTS = {
|
24
|
+
[0,0] => "login_welcome",
|
25
|
+
[0,1] => LoginForm,
|
26
|
+
}
|
27
|
+
CSS_CLASS = 'composite'
|
28
|
+
CSS_MAP = {
|
29
|
+
[0,0] => 'th',
|
30
|
+
}
|
31
|
+
end
|
32
|
+
class Login < Template
|
33
|
+
CONTENT = LoginComposite
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# View::Navigation -- xmlconv2 -- 09.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'htmlgrid/composite'
|
5
|
+
require 'xmlconv/view/navigationlink'
|
6
|
+
|
7
|
+
module XmlConv
|
8
|
+
module View
|
9
|
+
class Navigation < HtmlGrid::Composite
|
10
|
+
COMPONENTS = {}
|
11
|
+
CSS_CLASS = "navigation"
|
12
|
+
#HTML_ATTRIBUTES = {"align"=>"right"}
|
13
|
+
SYMBOL_MAP = {
|
14
|
+
:navigation_divider => HtmlGrid::Text,
|
15
|
+
}
|
16
|
+
def init
|
17
|
+
build_navigation()
|
18
|
+
super
|
19
|
+
end
|
20
|
+
def build_navigation
|
21
|
+
@lookandfeel.navigation.each_with_index { |state, idx|
|
22
|
+
evt = state.is_a?(Symbol) ? state : state.direct_event
|
23
|
+
symbol_map.store(evt, NavigationLink)
|
24
|
+
components.store([idx*2,0], evt)
|
25
|
+
components.store([idx*2-1,0], :navigation_divider) if(idx > 0)
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# View::NavigationLink -- xmlconv2 -- 09.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'htmlgrid/link'
|
5
|
+
|
6
|
+
module XmlConv
|
7
|
+
module View
|
8
|
+
class NavigationLink < HtmlGrid::Link
|
9
|
+
#CSS_CLASS = "navigation"
|
10
|
+
def init
|
11
|
+
super
|
12
|
+
unless(@lookandfeel.direct_event == @name)
|
13
|
+
@attributes.store("href", @lookandfeel.event_url(@name))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# View::Pager -- xmlconv2 -- 01.07.2004 -- ywesee@ywesee.com
|
3
|
+
|
4
|
+
require 'htmlgrid/link'
|
5
|
+
require 'htmlgrid/list'
|
6
|
+
|
7
|
+
module XmlConv
|
8
|
+
module View
|
9
|
+
class Pager < HtmlGrid::List
|
10
|
+
BACKGROUND_SUFFIX = ''
|
11
|
+
COMPONENTS = {
|
12
|
+
[0,0] => :number_link,
|
13
|
+
}
|
14
|
+
CSS_CLASS = 'pager'
|
15
|
+
CSS_HEAD_MAP = {
|
16
|
+
#[0,0] => 'pager-head',
|
17
|
+
}
|
18
|
+
CSS_MAP = {
|
19
|
+
#[0,0] => 'pager',
|
20
|
+
}
|
21
|
+
LEGACY_INTERFACE = false
|
22
|
+
OFFSET_STEP = [1,0]
|
23
|
+
SORT_DEFAULT = :to_i
|
24
|
+
SORT_HEADER = false
|
25
|
+
def init
|
26
|
+
@page = @container.model
|
27
|
+
super
|
28
|
+
end
|
29
|
+
def compose_header(offset)
|
30
|
+
@grid.add(page_number(@model), *offset)
|
31
|
+
@grid.add_style('head', *offset)
|
32
|
+
offset = resolve_offset(offset, self::class::OFFSET_STEP)
|
33
|
+
if(@page != @model.first)
|
34
|
+
link = page_link(@page.previous)
|
35
|
+
link.value = @lookandfeel.lookup(:page_back)
|
36
|
+
@grid.add(link, *offset)
|
37
|
+
end
|
38
|
+
#@grid.add_attribute('class', 'pager', *offset)
|
39
|
+
resolve_offset(offset, self::class::OFFSET_STEP)
|
40
|
+
end
|
41
|
+
def compose_footer(offset)
|
42
|
+
if(@page != @model.last)
|
43
|
+
link = page_link(@page.next)
|
44
|
+
link.value = @lookandfeel.lookup(:page_fwd)
|
45
|
+
@grid.add(link, *offset)
|
46
|
+
else
|
47
|
+
@grid.add(nil, *offset)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
private
|
51
|
+
def number_link(model)
|
52
|
+
page_link(model)
|
53
|
+
end
|
54
|
+
def page_link(page)
|
55
|
+
if(page != @page)
|
56
|
+
link = HtmlGrid::Link.new(:self, page, @session, self)
|
57
|
+
link.value = page.to_s
|
58
|
+
#link.set_attribute("class", "pager")
|
59
|
+
values = {
|
60
|
+
:page => page.to_i.to_s,
|
61
|
+
}
|
62
|
+
link.href = @lookandfeel.event_url(:self, values)
|
63
|
+
link
|
64
|
+
else
|
65
|
+
page.to_s
|
66
|
+
end
|
67
|
+
end
|
68
|
+
def page_number(model)
|
69
|
+
@lookandfeel.lookup(:page_number, @page, @page.total)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# View::Preformatted -- xmlconv2 -- 09.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'htmlgrid/value'
|
5
|
+
|
6
|
+
module XmlConv
|
7
|
+
module View
|
8
|
+
BREAK_WIDTH = 65
|
9
|
+
class Preformatted < HtmlGrid::Value
|
10
|
+
def init
|
11
|
+
super
|
12
|
+
pretty = ''
|
13
|
+
if(@value)
|
14
|
+
raw = @value.gsub(/>\s+</, "><").gsub(/\r\n?/, "\n")
|
15
|
+
begin
|
16
|
+
pretty = CGI.pretty(raw)
|
17
|
+
rescue
|
18
|
+
pretty = raw
|
19
|
+
end
|
20
|
+
wrap = ''
|
21
|
+
pretty.each_line { |line|
|
22
|
+
if(line.length < BREAK_WIDTH)
|
23
|
+
wrap << line
|
24
|
+
else
|
25
|
+
indent = line[/^ +/].to_s
|
26
|
+
indent = indent[0,indent.length % (BREAK_WIDTH / 3)]
|
27
|
+
tmpparts = line.split(/(?<=") +(?=")/)
|
28
|
+
parts = []
|
29
|
+
tmpparts.each { |part|
|
30
|
+
if(part.length > BREAK_WIDTH)
|
31
|
+
parts.concat(part.split(/ /))
|
32
|
+
else
|
33
|
+
parts.push(part)
|
34
|
+
end
|
35
|
+
}
|
36
|
+
wrapline = parts.shift
|
37
|
+
while(part = parts.shift)
|
38
|
+
if((wrapline.length + part.length) >= BREAK_WIDTH)
|
39
|
+
wrap << wrapline
|
40
|
+
wrap << "\n"
|
41
|
+
wrapline = indent.dup << (' ' * 5) << part
|
42
|
+
else
|
43
|
+
wrapline << ' ' << part
|
44
|
+
end
|
45
|
+
end
|
46
|
+
wrap << wrapline
|
47
|
+
end
|
48
|
+
}
|
49
|
+
@value = CGI.escapeHTML(wrap)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# View::Template -- xmlconv2 -- 09.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'htmlgrid/divtemplate'
|
5
|
+
require 'xmlconv/view/foot'
|
6
|
+
|
7
|
+
module XmlConv
|
8
|
+
module View
|
9
|
+
class Template < HtmlGrid::DivTemplate
|
10
|
+
COMPONENTS = {
|
11
|
+
[0,0] => :content,
|
12
|
+
[0,1] => :foot,
|
13
|
+
}
|
14
|
+
FOOT = Foot
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# View::Transaction -- xmlconv2 -- 09.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'htmlgrid/value'
|
5
|
+
require 'xmlconv/view/template'
|
6
|
+
require 'xmlconv/view/preformatted'
|
7
|
+
|
8
|
+
module XmlConv
|
9
|
+
module View
|
10
|
+
class TransactionComposite < HtmlGrid::Composite
|
11
|
+
COMPONENTS = {
|
12
|
+
[0,0] => 'th_input',
|
13
|
+
[1,0] => 'th_output',
|
14
|
+
[0,1] => :input,
|
15
|
+
[1,1] => :output,
|
16
|
+
[0,2] => 'th_error',
|
17
|
+
[0,3] => :error_string,
|
18
|
+
}
|
19
|
+
CSS_CLASS = 'composite'
|
20
|
+
CSS_MAP = {
|
21
|
+
[0,0,2] => 'th',
|
22
|
+
[0,1,2] => 'helfti preformatted',
|
23
|
+
[0,2] => 'th',
|
24
|
+
[0,3] => 'list preformatted bg',
|
25
|
+
}
|
26
|
+
COLSPAN_MAP = {
|
27
|
+
[0,2] => 2,
|
28
|
+
[0,3] => 2,
|
29
|
+
}
|
30
|
+
DEFAULT_CLASS = View::Preformatted
|
31
|
+
LEGACY_INTERFACE = false
|
32
|
+
def error_string(model)
|
33
|
+
if(err = model.error)
|
34
|
+
[err.class, err.message, err.backtrace].join("\n")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
class Transaction < Template
|
39
|
+
CONTENT = TransactionComposite
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# View::Transactions -- xmlconv2 -- 09.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'htmlgrid/list'
|
5
|
+
require 'htmlgrid/value'
|
6
|
+
require 'xmlconv/view/template'
|
7
|
+
require 'xmlconv/view/pager'
|
8
|
+
|
9
|
+
module XmlConv
|
10
|
+
module View
|
11
|
+
class TransactionsList < HtmlGrid::List
|
12
|
+
BACKGROUND_SUFFIX = ' bg'
|
13
|
+
COMPONENTS = {
|
14
|
+
[0,0] => :transaction_id,
|
15
|
+
[1,0] => :origin,
|
16
|
+
[2,0] => :commit_time,
|
17
|
+
[3,0] => :uri_comparable,
|
18
|
+
[4,0] => :status_comparable,
|
19
|
+
}
|
20
|
+
CSS_CLASS = 'composite'
|
21
|
+
CSS_HEAD_MAP = {
|
22
|
+
[0,0] => 'right',
|
23
|
+
}
|
24
|
+
CSS_MAP = {
|
25
|
+
[0,0] => 'list right',
|
26
|
+
[1,0,4] => 'list',
|
27
|
+
}
|
28
|
+
DEFAULT_CLASS = HtmlGrid::Value
|
29
|
+
LEGACY_INTERFACE = false
|
30
|
+
SORT_DEFAULT = nil #:commit_time
|
31
|
+
SORT_REVERSE = false
|
32
|
+
def commit_time(model)
|
33
|
+
time_format(model.commit_time || model.start_time)
|
34
|
+
end
|
35
|
+
def origin(model)
|
36
|
+
uri_fmt(model.origin)
|
37
|
+
end
|
38
|
+
def uri_comparable(model)
|
39
|
+
uri_fmt(model.uri)
|
40
|
+
end
|
41
|
+
def uri_fmt(uri)
|
42
|
+
uri = uri.to_s
|
43
|
+
if((i1 = uri.index(/([^\/])\/[^\/]/, 1)) \
|
44
|
+
&& (i2 = uri.rindex(/(\/[^\/]+){3}/)) \
|
45
|
+
&& (i2 > i1))
|
46
|
+
uri[0..(i1.next)] << '...' << uri[i2..-1]
|
47
|
+
else
|
48
|
+
uri
|
49
|
+
end
|
50
|
+
end
|
51
|
+
def status_comparable(model)
|
52
|
+
model.update_status
|
53
|
+
status = model.status
|
54
|
+
@lookandfeel.lookup("status_#{status}") or status.to_s
|
55
|
+
end
|
56
|
+
def time_format(a_time)
|
57
|
+
if(a_time.respond_to?(:strftime))
|
58
|
+
a_time.strftime("%d.%m.%Y %H:%M:%S")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
def transaction_id(model)
|
62
|
+
link = HtmlGrid::Link.new(:transaction_id, model, @session, self)
|
63
|
+
args = {
|
64
|
+
'transaction_id' => model.transaction_id,
|
65
|
+
}
|
66
|
+
link.href = @lookandfeel.event_url(:transaction, args)
|
67
|
+
link.value = model.transaction_id
|
68
|
+
link
|
69
|
+
end
|
70
|
+
end
|
71
|
+
class TransactionsComposite < HtmlGrid::Composite
|
72
|
+
COMPONENTS = {
|
73
|
+
[0,0] => :pager,
|
74
|
+
[0,1] => :transactions,
|
75
|
+
}
|
76
|
+
CSS_CLASS = 'composite'
|
77
|
+
LEGACY_INTERFACE = false
|
78
|
+
def pager(model)
|
79
|
+
Pager.new(model.pages, @session, self)
|
80
|
+
end
|
81
|
+
def transactions(page)
|
82
|
+
TransactionsList.new(page.model, @session, self)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
class Transactions < Template
|
86
|
+
CONTENT = TransactionsComposite
|
87
|
+
#CONTENT = TransactionsList
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/lib/xmlconv.rb
ADDED
data/test/config.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Config -- xmlconv2 -- 21.08.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
module XmlConv
|
7
|
+
CONFIG = OpenStruct.new
|
8
|
+
CONFIG.grammar_dir = File.expand_path('../data/grammar',
|
9
|
+
File.dirname(__FILE__))
|
10
|
+
CONFIG.polling_file = File.expand_path('data/polling.yaml',
|
11
|
+
File.dirname(__FILE__))
|
12
|
+
end
|