sandozxmlconv 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,94 @@
1
+ body
2
+ {
3
+ border: 1px solid green;
4
+ padding: 1px;
5
+ font-family: Arial, Helvetica, sans-serif;
6
+ font-size: 12px;
7
+ }
8
+ table.composite, table.template
9
+ {
10
+ width: 100%;
11
+ }
12
+ th, td.th
13
+ {
14
+ padding: 4px;
15
+ font-weight: bold;
16
+ text-align: left;
17
+ }
18
+ th, th a, td.th, table.foot,
19
+ /*table.navigation a, table.navigation a:hover,*/
20
+ table.foot a, table.foot.a:hover
21
+ {
22
+ background-color: #abcdef;
23
+ color: black;
24
+ text-decoration: none;
25
+ }
26
+ /*table.navigation a:link, table.navigation a:visited,*/
27
+ td.list a:link, td.list a:visited,
28
+ table.foot a:link, table.foot a:visited
29
+ {
30
+ /*background-color: #abcdef;*/
31
+ color: #3b5c7f;
32
+ text-decoration: none;
33
+ }
34
+ td.list a:hover
35
+ {
36
+ color: green;
37
+ text-decoration: none;
38
+ }
39
+ table.component td, td.list, table.navigation td, a.foot
40
+ {
41
+ padding: 4px;
42
+ }
43
+ .bg
44
+ {
45
+ background-color: #cfdfff;
46
+ }
47
+ .right
48
+ {
49
+ text-align: right;
50
+ }
51
+ label
52
+ {
53
+ font-weight: bold;
54
+ }
55
+ form
56
+ {
57
+ margin: 0px;
58
+ padding: 0px;
59
+ }
60
+ table.navigation
61
+ {
62
+ float: right;
63
+ }
64
+ td.helfti
65
+ {
66
+ width: 50%;
67
+ }
68
+ td.preformatted
69
+ {
70
+ font-family: monospace, fixed;
71
+ vertical-align: top;
72
+ white-space: pre;
73
+ }
74
+ table.pager
75
+ {
76
+ float: right;
77
+ }
78
+ table.pager td
79
+ {
80
+ font-weight: bold;
81
+ color: black;
82
+ padding: 1px;
83
+ width: 16px;
84
+ }
85
+ table.pager td.head
86
+ {
87
+ width: auto;
88
+ padding-right: 6px;
89
+ }
90
+ table.pager a
91
+ {
92
+ text-decoration: none;
93
+ color: #3b5c7f;
94
+ }
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+ # wbmb.rbx -- xmlconv2 -- 07.06.2004 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
5
+
6
+ require 'drb/drb'
7
+ require 'xmlconv/util/destination'
8
+ require 'xmlconv/util/transaction'
9
+
10
+ begin
11
+ request = Apache.request
12
+ connection = request.connection
13
+
14
+ request.server.log_notice("Received Request #{request.request_method}")
15
+ if(request.request_method != 'POST')
16
+ request.status = 405 # Method not allowed
17
+ exit
18
+ end
19
+ request.server.log_notice("from #{connection.remote_ip}")
20
+
21
+ content_length = request.headers_in['Content-Length'].to_i
22
+ request.server.log_notice("content-length: #{content_length}")
23
+ if(content_length <= 0)
24
+ request.status = 500 # Server Error
25
+ request.server.log_error("zero length input")
26
+ exit
27
+ end
28
+
29
+ xml_src = $stdin.read(content_length)
30
+
31
+ DRb.start_service
32
+ xmlconv = DRbObject.new(nil, ENV['DRB_SERVER'])
33
+ destination = XmlConv::Util::Destination.book(ENV['ACCESS_DESTINATION'])
34
+
35
+ transaction = XmlConv::Util::Transaction.new
36
+ transaction.domain = ENV['HTTP_HOST']
37
+ transaction.input = xml_src
38
+ transaction.reader = 'WbmbBdd'
39
+ transaction.writer = ENV['WRITER']
40
+ transaction.destination = destination
41
+ transaction.origin = "http://#{connection.remote_ip}:#{connection.remote_port}"
42
+ transaction.partner = 'SOAP'
43
+ transaction.postprocs.push(['Soap', 'update_partner'])
44
+ transaction.postprocs.push(['Bbmb2', 'inject', ENV['ACCESS_BBMB']])
45
+
46
+ xmlconv.dispatch(transaction)
47
+
48
+ rescue StandardError => err
49
+ request.server.log_error(err.class.to_s)
50
+ request.server.log_error(err.message)
51
+ request.server.log_error(err.backtrace.join("\n"))
52
+ request.status = 500
53
+ ensure
54
+ request.send_http_header
55
+ end
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ # sunstore.rbx -- xmlconv2 -- 07.06.2004 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
5
+
6
+ require 'drb/drb'
7
+ require 'xmlconv/util/destination'
8
+ require 'xmlconv/util/transaction'
9
+
10
+ begin
11
+ request = Apache.request
12
+ connection = request.connection
13
+
14
+ request.server.log_notice("Received Request #{request.request_method}")
15
+ if(request.request_method != 'POST')
16
+ request.status = 405 # Method not allowed
17
+ exit
18
+ end
19
+ request.server.log_notice("from #{connection.remote_ip}")
20
+
21
+ content_length = request.headers_in['Content-Length'].to_i
22
+ request.server.log_notice("content-length: #{content_length}")
23
+ if(content_length <= 0)
24
+ request.status = 500 # Server Error
25
+ request.server.log_error("zero length input")
26
+ exit
27
+ end
28
+
29
+ xml_src = $stdin.read(content_length)
30
+
31
+ DRb.start_service
32
+ xmlconv = DRbObject.new(nil, ENV['DRB_SERVER'])
33
+ destination = XmlConv::Util::Destination.book(ENV['ACCESS_DESTINATION'])
34
+
35
+ transaction = XmlConv::Util::Transaction.new
36
+ transaction.domain = ENV['HTTP_HOST']
37
+ transaction.input = xml_src
38
+ transaction.reader = 'SunStoreBdd'
39
+ transaction.writer = ENV['WRITER']
40
+ transaction.destination = destination
41
+ transaction.origin = "http://#{connection.remote_ip}:#{connection.remote_port}"
42
+ transaction.partner = 'SunStore'
43
+ transaction.postprocs.push(['Soap', 'update_partner'])
44
+ transaction.postprocs.push(['Bbmb2', 'inject',
45
+ ENV['ACCESS_BBMB'], 'customer_id'])
46
+
47
+ request.content_type = 'text/xml'
48
+ puts xmlconv.execute_with_response(transaction)
49
+
50
+ rescue StandardError => err
51
+ request.server.log_error(err.class.to_s)
52
+ request.server.log_error(err.message)
53
+ request.server.log_error(err.backtrace.join("\n"))
54
+ request.status = 500
55
+ ensure
56
+ request.send_http_header
57
+ end
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ # sunstore.rbx -- xmlconv2 -- 07.06.2004 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
5
+
6
+ require 'drb/drb'
7
+ require 'xmlconv/util/destination'
8
+ require 'xmlconv/util/transaction'
9
+
10
+ begin
11
+ request = Apache.request
12
+ connection = request.connection
13
+
14
+ request.server.log_notice("Received Request #{request.request_method}")
15
+ if(request.request_method != 'POST')
16
+ request.status = 405 # Method not allowed
17
+ exit
18
+ end
19
+ request.server.log_notice("from #{connection.remote_ip}")
20
+
21
+ content_length = request.headers_in['Content-Length'].to_i
22
+ request.server.log_notice("content-length: #{content_length}")
23
+ if(content_length <= 0)
24
+ request.status = 500 # Server Error
25
+ request.server.log_error("zero length input")
26
+ exit
27
+ end
28
+
29
+ xml_src = $stdin.read(content_length)
30
+
31
+ DRb.start_service
32
+ xmlconv = DRbObject.new(nil, ENV['DRB_SERVER'])
33
+ destination = XmlConv::Util::Destination.book(ENV['ACCESS_DESTINATION'])
34
+
35
+ transaction = XmlConv::Util::Transaction.new
36
+ transaction.domain = ENV['HTTP_HOST']
37
+ transaction.input = xml_src
38
+ transaction.reader = 'SunStoreBdd'
39
+ transaction.writer = ENV['WRITER']
40
+ transaction.destination = destination
41
+ transaction.origin = "http://#{connection.remote_ip}:#{connection.remote_port}"
42
+ transaction.partner = 'Unilog'
43
+ transaction.postprocs.push(['Soap', 'update_partner'])
44
+ transaction.postprocs.push(['Bbmb2', 'inject',
45
+ ENV['ACCESS_BBMB'], 'customer_id'])
46
+
47
+ request.content_type = 'text/xml'
48
+ puts xmlconv.execute_with_response(transaction)
49
+
50
+ rescue StandardError => err
51
+ request.server.log_error(err.class.to_s)
52
+ request.server.log_error(err.message)
53
+ request.server.log_error(err.backtrace.join("\n"))
54
+ request.status = 500
55
+ ensure
56
+ request.send_http_header
57
+ end
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ # sunstore.rbx -- xmlconv2 -- 07.06.2004 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
5
+
6
+ require 'drb/drb'
7
+ require 'xmlconv/util/destination'
8
+ require 'xmlconv/util/transaction'
9
+
10
+ begin
11
+ request = Apache.request
12
+ connection = request.connection
13
+
14
+ request.server.log_notice("Received Request #{request.request_method}")
15
+ if(request.request_method != 'POST')
16
+ request.status = 405 # Method not allowed
17
+ exit
18
+ end
19
+ request.server.log_notice("from #{connection.remote_ip}")
20
+
21
+ content_length = request.headers_in['Content-Length'].to_i
22
+ request.server.log_notice("content-length: #{content_length}")
23
+ if(content_length <= 0)
24
+ request.status = 500 # Server Error
25
+ request.server.log_error("zero length input")
26
+ exit
27
+ end
28
+
29
+ xml_src = $stdin.read(content_length)
30
+
31
+ DRb.start_service
32
+ xmlconv = DRbObject.new(nil, ENV['DRB_SERVER'])
33
+ destination = XmlConv::Util::Destination.book(ENV['ACCESS_DESTINATION'])
34
+
35
+ transaction = XmlConv::Util::Transaction.new
36
+ transaction.domain = ENV['HTTP_HOST']
37
+ transaction.input = xml_src
38
+ transaction.reader = 'SunStoreBdd'
39
+ transaction.writer = ENV['WRITER']
40
+ transaction.destination = destination
41
+ transaction.origin = "http://#{connection.remote_ip}:#{connection.remote_port}"
42
+ transaction.partner = 'Volksapotheke'
43
+ transaction.postprocs.push(['Soap', 'update_partner'])
44
+ transaction.postprocs.push(['Bbmb2', 'inject',
45
+ ENV['ACCESS_BBMB'], 'customer_id'])
46
+
47
+ request.content_type = 'text/xml'
48
+ puts xmlconv.execute_with_response(transaction)
49
+
50
+ rescue StandardError => err
51
+ request.server.log_error(err.class.to_s)
52
+ request.server.log_error(err.message)
53
+ request.server.log_error(err.backtrace.join("\n"))
54
+ request.status = 500
55
+ ensure
56
+ request.send_http_header
57
+ end
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby
2
+ # wbmb.rbx -- xmlconv2 -- 07.06.2004 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
5
+
6
+ require 'drb/drb'
7
+ require 'xmlconv/util/destination'
8
+ require 'xmlconv/util/transaction'
9
+
10
+ begin
11
+ request = Apache.request
12
+ connection = request.connection
13
+
14
+ request.server.log_notice("Received Request #{request.request_method}")
15
+ if(request.request_method != 'POST')
16
+ request.status = 405 # Method not allowed
17
+ exit
18
+ end
19
+ request.server.log_notice("from #{connection.remote_ip}")
20
+
21
+ content_length = request.headers_in['Content-Length'].to_i
22
+ request.server.log_notice("content-length: #{content_length}")
23
+ if(content_length <= 0)
24
+ request.status = 500 # Server Error
25
+ request.server.log_error("zero length input")
26
+ exit
27
+ end
28
+
29
+ xml_src = $stdin.read(content_length)
30
+
31
+ DRb.start_service
32
+ xmlconv = DRbObject.new(nil, ENV['DRB_SERVER'])
33
+ destination = XmlConv::Util::Destination.book(ENV['ACCESS_GLOBOPHARM'])
34
+
35
+ transaction = XmlConv::Util::Transaction.new
36
+ transaction.domain = ENV['HTTP_HOST']
37
+ transaction.input = xml_src
38
+ transaction.reader = 'WbmbBdd'
39
+ transaction.writer = 'BddI2'
40
+ transaction.destination = destination
41
+ transaction.origin = "http://#{connection.remote_ip}:#{connection.remote_port}"
42
+ transaction.partner = 'SOAP'
43
+ transaction.postprocs.push(['Soap', 'update_partner'])
44
+ transaction.postprocs.push(['Bbmb', 'inject', ENV['ACCESS_BBMB'],
45
+ 'gag', '221200'])
46
+
47
+ xmlconv.dispatch(transaction)
48
+
49
+ rescue StandardError => err
50
+ request.server.log_error(err.class.to_s)
51
+ request.server.log_error(err.message)
52
+ request.server.log_error(err.backtrace.join("\n"))
53
+ request.status = 500
54
+ ensure
55
+ request.send_http_header
56
+ end
File without changes
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+ # BddCsv -- xmlconv2 -- 03.12.2007 -- hwyss@ywesee.com
3
+
4
+ require 'csv'
5
+ require 'xmlconv/config'
6
+ require 'xmlconv/model/document'
7
+
8
+ module XmlConv
9
+ module Conversion
10
+ class BddCsv
11
+ class << self
12
+ def convert(bdd)
13
+ bdd.deliveries.collect { |delivery|
14
+ _to_csv(delivery)
15
+ }
16
+ end
17
+ def _formatted_comment(str, replacement=' ')
18
+ str = str.to_s
19
+ u(str.gsub(/[\r\n]+/, replacement))[0,60] unless(str.empty?)
20
+ end
21
+ def _to_csv(delivery)
22
+ result = Model::Document.new
23
+ customer_id, customer_ean13, commit_id, price = nil
24
+ if(customer = delivery.customer)
25
+ result.prefix = customer_id = customer.ids['supplier']
26
+ customer_ean13 = customer.acc_id
27
+ end
28
+ if(customer = delivery.bsr.customer)
29
+ customer_ean13 ||= customer.acc_id
30
+ result.prefix = customer_id ||= customer.ids['supplier']
31
+ end
32
+ result.prefix ||= customer_ean13
33
+ CSV::Writer.generate(result,
34
+ XmlConv::CONFIG.target_format_fs,
35
+ XmlConv::CONFIG.target_format_rs) { |writer|
36
+ delivery.items.each { |item|
37
+ if(nprice = item.get_price('NettoPreis'))
38
+ price = nprice.amount
39
+ end
40
+ writer << [
41
+ customer_id,
42
+ customer_ean13,
43
+ Date.today.strftime('%d%m%Y'),
44
+ commit_id,
45
+ item.pharmacode_id,
46
+ item.et_nummer_id,
47
+ item.customer_id,
48
+ item.qty,
49
+ price,
50
+ delivery.customer_id,
51
+ _formatted_comment(delivery.free_text),
52
+ ]
53
+ }
54
+ }
55
+ result
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env ruby
2
+ # Conversion::PharmaciePlusBdd -- xmlconv2 -- 18.08.2006 -- hwyss@ywesee.com
3
+
4
+ require 'rexml/document'
5
+ require 'xmlconv/model/address'
6
+ require 'xmlconv/model/bdd'
7
+ require 'xmlconv/model/bsr'
8
+ require 'xmlconv/model/delivery'
9
+ require 'xmlconv/model/delivery_item'
10
+ require 'xmlconv/model/name'
11
+ require 'xmlconv/model/party'
12
+
13
+ module XmlConv
14
+ module Conversion
15
+ class PharmaciePlusBdd
16
+ class << self
17
+ def convert(xml_document)
18
+ bdd = Model::Bdd.new
19
+ bsr = Model::Bsr.new
20
+ _bsr_add_customer_id(bsr, 'YWESEEPP')
21
+ bdd.bsr = bsr
22
+ REXML::XPath.each(xml_document, '//com-pharma') { |xml_delivery|
23
+ _bdd_add_xml_delivery(bdd, xml_delivery)
24
+ }
25
+ bdd
26
+ end
27
+ def parse(xml_src)
28
+ REXML::Document.new(xml_src)
29
+ end
30
+ def _bdd_add_xml_delivery(bdd, xml_delivery)
31
+ delivery = Model::Delivery.new
32
+ bsr = Model::Bsr.new
33
+ _bsr_add_customer_id(bsr, xml_delivery.attributes['ean'])
34
+ delivery.bsr = bsr
35
+ _delivery_add_xml_header(delivery, xml_delivery)
36
+ REXML::XPath.each(xml_delivery, 'article') { |xml_item|
37
+ _delivery_add_xml_item(delivery, xml_item)
38
+ }
39
+ bdd.add_delivery(delivery)
40
+ delivery
41
+ end
42
+ def _bsr_add_customer_id(bsr, id)
43
+ customer = Model::Party.new
44
+ customer.role = 'Customer'
45
+ customer.add_id('ACC', id)
46
+ bsr.add_party(customer)
47
+ end
48
+ def _customer_add_party(customer, id, role)
49
+ party = Model::Party.new
50
+ party.role = role
51
+ party.add_id('ACC', id)
52
+ customer.add_party(party)
53
+ party
54
+ end
55
+ def _delivery_add_xml_header(delivery, xml_delivery)
56
+ xml_order = REXML::XPath.first(xml_delivery, '/commande')
57
+ delivery.add_id('Customer', _latin1(xml_order.attributes['id']))
58
+ if(xml_party = REXML::XPath.first(xml_order, 'fournisseur'))
59
+ _delivery_add_xml_seller(delivery, xml_party)
60
+ end
61
+ _delivery_add_xml_customer(delivery, xml_delivery)
62
+ end
63
+ def _delivery_add_xml_customer(delivery, xml_delivery)
64
+ customer = Model::Party.new
65
+ customer.role = 'Customer'
66
+ _customer_add_party(customer, '1075', 'BillTo')
67
+ ship_to = _customer_add_party(customer,
68
+ _latin1(xml_delivery.attributes['ean']),
69
+ 'ShipTo')
70
+ if(xml_header = REXML::XPath.first(xml_delivery, 'livraison'))
71
+ name = Model::Name.new
72
+ # Pharmacieplus delivers the Pharmacy-Name in 'last-name', and the name
73
+ # of the contact person in 'other-name' - we need to juggle the pieces
74
+ # around a bit. (see also _party_add_xml_address)
75
+ =begin
76
+ if(xml_name = REXML::XPath.first(xml_header, 'last-name'))
77
+ name.last = _latin1(xml_name.text)
78
+ end
79
+ if(xml_name = REXML::XPath.first(xml_header, 'first-name'))
80
+ name.first = _latin1(xml_name.text)
81
+ end
82
+ =end
83
+ if(xml_name = REXML::XPath.first(xml_header, 'other-name'))
84
+ name.text = _latin1(xml_name.text)
85
+ end
86
+ customer.name = name
87
+ ship_to.name = name
88
+ _party_add_xml_address(ship_to, xml_header)
89
+ end
90
+ if(xml_email = REXML::XPath.first(xml_delivery, '//groupe/online/email'))
91
+ customer.add_id('email', _latin1(xml_email.text))
92
+ end
93
+ delivery.add_party(customer)
94
+ end
95
+ def _delivery_add_xml_seller(delivery, xml_party)
96
+ party = Model::Party.new
97
+ party.role = 'Seller'
98
+ party.add_id('ACC', _latin1(xml_party.attributes['ean']))
99
+ if(party.acc_id.to_s.empty?)
100
+ party.add_id("ACC", "7601001000681")
101
+ end
102
+ delivery.add_party(party)
103
+ end
104
+ def _delivery_add_xml_item(delivery, xml_item)
105
+ item = Model::DeliveryItem.new
106
+ item.line_no = _latin1(delivery.items.size.next.to_s)
107
+ item.add_id('ET-Nummer', _latin1(xml_item.attributes['ean']))
108
+ item.add_id('Pharmacode', _latin1(xml_item.attributes['pharmacode']))
109
+ item.qty = _latin1(xml_item.attributes['qte-facture'])
110
+ item.unit = 'PCE'
111
+ delivery.add_item(item)
112
+ end
113
+ def _latin1(str)
114
+ Iconv.iconv('ISO-8859-1//TRANSLIT//IGNORE', 'UTF8', str).first.strip
115
+ rescue
116
+ str
117
+ end
118
+ def _party_add_xml_address(party, xml_header)
119
+ if(xml_address = REXML::XPath.first(xml_header, 'address'))
120
+ address = Model::Address.new
121
+ address.zip_code = _text(xml_address, 'zip')
122
+ address.city = _text(xml_address, 'city')
123
+ if(xml_name = REXML::XPath.first(xml_header, 'last-name'))
124
+ address.add_line(_latin1(xml_name.text))
125
+ end
126
+ if(line = _text(xml_address, 'street'))
127
+ address.add_line(line)
128
+ end
129
+ party.address = address
130
+ end
131
+ end
132
+ def _text(xml_parent, xpath)
133
+ if(xml_element = REXML::XPath.first(xml_parent, xpath))
134
+ _latin1(xml_element.text)
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end