kwatable 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/ChangeLog.txt +15 -3
  2. data/README.txt +1 -1
  3. data/bin/kwatable +3 -9
  4. data/examples/ex1/Makefile +18 -26
  5. data/examples/ex1/example1.yaml +9 -6
  6. data/examples/ex2/Makefile +15 -24
  7. data/kwatable.gemspec +2 -2
  8. data/lib/kwatable.rb +1 -1
  9. data/lib/kwatable/error-msg.rb +1 -1
  10. data/lib/kwatable/kwatable.schema.yaml +12 -2
  11. data/lib/kwatable/main-program.rb +18 -7
  12. data/lib/kwatable/manipulator.rb +3 -3
  13. data/lib/kwatable/templates/ddl-mysql.eruby +1 -1
  14. data/lib/kwatable/templates/ddl-postgresql.eruby +3 -3
  15. data/lib/kwatable/templates/defaults.yaml +1 -1
  16. data/lib/kwatable/templates/dto-java.eruby +75 -9
  17. data/lib/kwatable/templates/dto-ruby.eruby +27 -15
  18. data/lib/kwatable/templates/validator-ruby.eruby +97 -0
  19. data/test/assert-diff.rb +1 -1
  20. data/test/test.rb +80 -151
  21. metadata +4 -25
  22. data/test/test1/test1.ddl-mysql.expected +0 -23
  23. data/test/test1/test1.ddl-postgresql.expected +0 -23
  24. data/test/test1/test1.dto-java.Group.expected +0 -35
  25. data/test/test1/test1.dto-java.User.expected +0 -57
  26. data/test/test1/test1.dto-ruby.Group.expected +0 -20
  27. data/test/test1/test1.dto-ruby.User.expected +0 -33
  28. data/test/test1/test1.yaml +0 -96
  29. data/test/test2/test2.ddl-mysql.expected +0 -49
  30. data/test/test2/test2.ddl-postgresql.expected +0 -49
  31. data/test/test2/test2.dto-java.Address.expected +0 -40
  32. data/test/test2/test2.dto-java.Customer.expected +0 -47
  33. data/test/test2/test2.dto-java.Item.expected +0 -35
  34. data/test/test2/test2.dto-java.SalesOrder.expected +0 -48
  35. data/test/test2/test2.dto-java.SalesOrderLine.expected +0 -54
  36. data/test/test2/test2.dto-ruby.Address.expected +0 -22
  37. data/test/test2/test2.dto-ruby.Customer.expected +0 -29
  38. data/test/test2/test2.dto-ruby.Item.expected +0 -20
  39. data/test/test2/test2.dto-ruby.SalesOrder.expected +0 -29
  40. data/test/test2/test2.dto-ruby.SalesOrderLine.expected +0 -36
  41. data/test/test2/test2.yaml +0 -94
@@ -1,40 +0,0 @@
1
- /*
2
- * DTO for Java
3
- * generated by kwatable with template 'dto-java.eruby'
4
- */
5
-
6
- /**
7
- * Address master table
8
- */
9
- public class Address implements java.io.Serializable {
10
-
11
- private int id; /* */
12
- private String zipcode; /* */
13
- private String addr1; /* */
14
- private String addr2; /* */
15
- private String addr3; /* */
16
-
17
- public void populate(java.sql.ResultSet resultset) {
18
- setId(resultset.getInt("id"));
19
- setZipcode(resultset.getString("zipcode"));
20
- setAddr1(resultset.getString("addr1"));
21
- setAddr2(resultset.getString("addr2"));
22
- setAddr3(resultset.getString("addr3"));
23
- }
24
-
25
- public int getId() { return id }
26
- public void setId(int id) { this.id = id; }
27
-
28
- public String getZipcode() { return zipcode }
29
- public void setZipcode(String zipcode) { this.zipcode = zipcode; }
30
-
31
- public String getAddr1() { return addr1 }
32
- public void setAddr1(String addr1) { this.addr1 = addr1; }
33
-
34
- public String getAddr2() { return addr2 }
35
- public void setAddr2(String addr2) { this.addr2 = addr2; }
36
-
37
- public String getAddr3() { return addr3 }
38
- public void setAddr3(String addr3) { this.addr3 = addr3; }
39
-
40
- }
@@ -1,47 +0,0 @@
1
- /*
2
- * DTO for Java
3
- * generated by kwatable with template 'dto-java.eruby'
4
- */
5
-
6
- /**
7
- * Customer master table
8
- */
9
- public class Customer implements java.io.Serializable {
10
-
11
- private int id; /* */
12
- private String name; /* */
13
- private String tel; /* */
14
- private String email; /* */
15
- private int address_id; /* */
16
-
17
- public void populate(java.sql.ResultSet resultset) {
18
- setId(resultset.getInt("id"));
19
- setName(resultset.getString("name"));
20
- setTel(resultset.getString("tel"));
21
- setEmail(resultset.getString("email"));
22
- setAddressId(resultset.getInt("address_id"));
23
- }
24
-
25
- public int getId() { return id }
26
- public void setId(int id) { this.id = id; }
27
-
28
- public String getName() { return name }
29
- public void setName(String name) { this.name = name; }
30
-
31
- public String getTel() { return tel }
32
- public void setTel(String tel) { this.tel = tel; }
33
-
34
- public String getEmail() { return email }
35
- public void setEmail(String email) { this.email = email; }
36
-
37
- public int getAddressId() { return address_id }
38
- public void setAddressId(int address_id) { this.address_id = address_id; }
39
-
40
- private Address address;
41
- public Address getAddress() { return address; }
42
- public void setAddress(Address address) {
43
- this.address = address;
44
- this.address_id = address.getId();
45
- }
46
-
47
- }
@@ -1,35 +0,0 @@
1
- /*
2
- * DTO for Java
3
- * generated by kwatable with template 'dto-java.eruby'
4
- */
5
-
6
- /**
7
- * Item master table
8
- */
9
- public class Item implements java.io.Serializable {
10
-
11
- private int id; /* */
12
- private String name; /* */
13
- private String desc; /* */
14
- private double price; /* */
15
-
16
- public void populate(java.sql.ResultSet resultset) {
17
- setId(resultset.getInt("id"));
18
- setName(resultset.getString("name"));
19
- setDesc(resultset.getString("desc"));
20
- setPrice(resultset.getDouble("price"));
21
- }
22
-
23
- public int getId() { return id }
24
- public void setId(int id) { this.id = id; }
25
-
26
- public String getName() { return name }
27
- public void setName(String name) { this.name = name; }
28
-
29
- public String getDesc() { return desc }
30
- public void setDesc(String desc) { this.desc = desc; }
31
-
32
- public double getPrice() { return price }
33
- public void setPrice(double price) { this.price = price; }
34
-
35
- }
@@ -1,48 +0,0 @@
1
- /*
2
- * DTO for Java
3
- * generated by kwatable with template 'dto-java.eruby'
4
- */
5
- import java.util.Date;
6
-
7
- /**
8
- * Sales order master table
9
- */
10
- public class SalesOrder implements java.io.Serializable {
11
-
12
- private int id; /* */
13
- private int customer_id; /* */
14
- private Date ordered_date; /* */
15
- private Date delivery_date; /* */
16
- private double amount; /* */
17
-
18
- public void populate(java.sql.ResultSet resultset) {
19
- setId(resultset.getInt("id"));
20
- setCustomerId(resultset.getInt("customer_id"));
21
- setOrderedDate(resultset.getDate("ordered_date"));
22
- setDeliveryDate(resultset.getDate("delivery_date"));
23
- setAmount(resultset.getDouble("amount"));
24
- }
25
-
26
- public int getId() { return id }
27
- public void setId(int id) { this.id = id; }
28
-
29
- public int getCustomerId() { return customer_id }
30
- public void setCustomerId(int customer_id) { this.customer_id = customer_id; }
31
-
32
- public Date getOrderedDate() { return ordered_date }
33
- public void setOrderedDate(Date ordered_date) { this.ordered_date = ordered_date; }
34
-
35
- public Date getDeliveryDate() { return delivery_date }
36
- public void setDeliveryDate(Date delivery_date) { this.delivery_date = delivery_date; }
37
-
38
- public double getAmount() { return amount }
39
- public void setAmount(double amount) { this.amount = amount; }
40
-
41
- private Customer customer;
42
- public Customer getCustomer() { return customer; }
43
- public void setCustomer(Customer customer) {
44
- this.customer = customer;
45
- this.customer_id = customer.getId();
46
- }
47
-
48
- }
@@ -1,54 +0,0 @@
1
- /*
2
- * DTO for Java
3
- * generated by kwatable with template 'dto-java.eruby'
4
- */
5
-
6
- /**
7
- * Sales Order detail lines
8
- */
9
- public class SalesOrderLine implements java.io.Serializable {
10
-
11
- private int num; /* */
12
- private int order_id; /* */
13
- private int item_id; /* */
14
- private double price; /* */
15
- private int quantity; /* */
16
-
17
- public void populate(java.sql.ResultSet resultset) {
18
- setNum(resultset.getInt("num"));
19
- setOrderId(resultset.getInt("order_id"));
20
- setItemId(resultset.getInt("item_id"));
21
- setPrice(resultset.getDouble("price"));
22
- setQuantity(resultset.getInt("quantity"));
23
- }
24
-
25
- public int getNum() { return num }
26
- public void setNum(int num) { this.num = num; }
27
-
28
- public int getOrderId() { return order_id }
29
- public void setOrderId(int order_id) { this.order_id = order_id; }
30
-
31
- public int getItemId() { return item_id }
32
- public void setItemId(int item_id) { this.item_id = item_id; }
33
-
34
- public double getPrice() { return price }
35
- public void setPrice(double price) { this.price = price; }
36
-
37
- public int getQuantity() { return quantity }
38
- public void setQuantity(int quantity) { this.quantity = quantity; }
39
-
40
- private SalesOrder order;
41
- public SalesOrder getOrder() { return order; }
42
- public void setOrder(SalesOrder order) {
43
- this.order = order;
44
- this.order_id = order.getId();
45
- }
46
-
47
- private Item item;
48
- public Item getItem() { return item; }
49
- public void setItem(Item item) {
50
- this.item = item;
51
- this.item_id = item.getId();
52
- }
53
-
54
- }
@@ -1,22 +0,0 @@
1
- ##
2
- ## DTO for Ruby
3
- ## generated by kwatable with template 'dto-ruby.eruby'
4
- ##
5
-
6
- ## Address master table
7
- class Address
8
- def populate(values={})
9
- self.id = values['id']
10
- self.zipcode = values['zipcode']
11
- self.addr1 = values['addr1']
12
- self.addr2 = values['addr2']
13
- self.addr3 = values['addr3']
14
- end
15
-
16
- attr_accessor :id #
17
- attr_accessor :zipcode #
18
- attr_accessor :addr1 #
19
- attr_accessor :addr2 #
20
- attr_accessor :addr3 #
21
-
22
- end
@@ -1,29 +0,0 @@
1
- ##
2
- ## DTO for Ruby
3
- ## generated by kwatable with template 'dto-ruby.eruby'
4
- ##
5
- require 'Address'
6
-
7
- ## Customer master table
8
- class Customer
9
- def populate(values={})
10
- self.id = values['id']
11
- self.name = values['name']
12
- self.tel = values['tel']
13
- self.email = values['email']
14
- self.address_id = values['address_id']
15
- end
16
-
17
- attr_accessor :id #
18
- attr_accessor :name #
19
- attr_accessor :tel #
20
- attr_accessor :email #
21
- attr_accessor :address_id #
22
-
23
- attr_reader :address
24
- def address=(address)
25
- @address = address
26
- @address_id = address.id
27
- end
28
-
29
- end
@@ -1,20 +0,0 @@
1
- ##
2
- ## DTO for Ruby
3
- ## generated by kwatable with template 'dto-ruby.eruby'
4
- ##
5
-
6
- ## Item master table
7
- class Item
8
- def populate(values={})
9
- self.id = values['id']
10
- self.name = values['name']
11
- self.desc = values['desc']
12
- self.price = values['price']
13
- end
14
-
15
- attr_accessor :id #
16
- attr_accessor :name #
17
- attr_accessor :desc #
18
- attr_accessor :price #
19
-
20
- end
@@ -1,29 +0,0 @@
1
- ##
2
- ## DTO for Ruby
3
- ## generated by kwatable with template 'dto-ruby.eruby'
4
- ##
5
- require 'Customer'
6
-
7
- ## Sales order master table
8
- class SalesOrder
9
- def populate(values={})
10
- self.id = values['id']
11
- self.customer_id = values['customer_id']
12
- self.ordered_date = values['ordered_date']
13
- self.delivery_date = values['delivery_date']
14
- self.amount = values['amount']
15
- end
16
-
17
- attr_accessor :id #
18
- attr_accessor :customer_id #
19
- attr_accessor :ordered_date #
20
- attr_accessor :delivery_date #
21
- attr_accessor :amount #
22
-
23
- attr_reader :customer
24
- def customer=(customer)
25
- @customer = customer
26
- @customer_id = customer.id
27
- end
28
-
29
- end
@@ -1,36 +0,0 @@
1
- ##
2
- ## DTO for Ruby
3
- ## generated by kwatable with template 'dto-ruby.eruby'
4
- ##
5
- require 'SalesOrder'
6
- require 'Item'
7
-
8
- ## Sales Order detail lines
9
- class SalesOrderLine
10
- def populate(values={})
11
- self.num = values['num']
12
- self.order_id = values['order_id']
13
- self.item_id = values['item_id']
14
- self.price = values['price']
15
- self.quantity = values['quantity']
16
- end
17
-
18
- attr_accessor :num #
19
- attr_accessor :order_id #
20
- attr_accessor :item_id #
21
- attr_accessor :price #
22
- attr_accessor :quantity #
23
-
24
- attr_reader :order
25
- def order=(order)
26
- @order = order
27
- @order_id = order.id
28
- end
29
-
30
- attr_reader :item
31
- def item=(item)
32
- @item = item
33
- @item_id = item.id
34
- end
35
-
36
- end
@@ -1,94 +0,0 @@
1
- columns:
2
- - name: id
3
- type: int
4
- primary-key: yes
5
- serial: yes
6
-
7
- - name: name
8
- type: str
9
- not-null: yes
10
-
11
- - name: desc
12
- type: str
13
-
14
-
15
- tables:
16
-
17
- - name: addresses
18
- class: Address
19
- desc: Address master table
20
- columns:
21
- - name: id
22
- - name: zipcode
23
- type: str
24
- width: 8
25
- pattern: /^\d+-\d+$/
26
- - name: addr1
27
- type: str
28
- - name: addr2
29
- type: str
30
- - name: addr3
31
- type: str
32
-
33
- - name: customers
34
- class: Customer
35
- desc: Customer master table
36
- columns:
37
- - name: id
38
- - name: name
39
- - name: tel
40
- type: str
41
- - name: email
42
- type: str
43
- - name: address_id
44
- ref: addresses.id
45
- not-null: yes
46
-
47
- - name: items
48
- class: Item
49
- desc: Item master table
50
- columns:
51
- - name: id
52
- - name: name
53
- - name: desc
54
- - name: price
55
- type: money
56
- not-null: yes
57
-
58
- - name: sales_orders
59
- class: SalesOrder
60
- desc: Sales order master table
61
- columns:
62
- - name: id
63
- - name: customer_id
64
- ref: customers.id
65
- not-null: yes
66
- - name: ordered_date
67
- type: date
68
- not-null: yes
69
- - name: delivery_date
70
- type: date
71
- - name: amount
72
- type: money
73
-
74
- - name: sales_order_lines
75
- class: SalesOrderLine
76
- desc: Sales Order detail lines
77
- columns:
78
- - name: num
79
- type: int
80
- not-null: yes
81
- - name: order_id
82
- ref: sales_orders.id
83
- not-null: yes
84
- - name: item_id
85
- ref: items.id
86
- not-null: yes
87
- - name: price
88
- type: money
89
- not-null: yes
90
- - name: quantity
91
- type: int
92
- not-null: yes
93
- primary-keys: [ order_id, item_id ]
94
-