kwatable 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/COPYING +340 -0
  2. data/ChangeLog.txt +27 -0
  3. data/README.txt +81 -0
  4. data/bin/kwatable +20 -0
  5. data/examples/ex1/Makefile +34 -0
  6. data/examples/ex1/example1.yaml +85 -0
  7. data/examples/ex2/Makefile +34 -0
  8. data/examples/ex2/example2.yaml +94 -0
  9. data/kwatable.gemspec +48 -0
  10. data/lib/kwatable.rb +31 -0
  11. data/lib/kwatable/error-msg.rb +37 -0
  12. data/lib/kwatable/kwatable.schema.yaml +133 -0
  13. data/lib/kwatable/main-program.rb +197 -0
  14. data/lib/kwatable/manufactory.rb +213 -0
  15. data/lib/kwatable/templates/ddl-mysql.eruby +169 -0
  16. data/lib/kwatable/templates/ddl-postgresql.eruby +153 -0
  17. data/lib/kwatable/templates/defaults.yaml +87 -0
  18. data/lib/kwatable/templates/dto-java.eruby +204 -0
  19. data/lib/kwatable/templates/dto-ruby.eruby +180 -0
  20. data/setup.rb +1331 -0
  21. data/test/assert-diff.rb +44 -0
  22. data/test/test.rb +202 -0
  23. data/test/test1/test1.ddl-mysql.expected +22 -0
  24. data/test/test1/test1.ddl-postgresql.expected +22 -0
  25. data/test/test1/test1.dto-java.Group.expected +32 -0
  26. data/test/test1/test1.dto-java.User.expected +59 -0
  27. data/test/test1/test1.dto-ruby.Group.expected +21 -0
  28. data/test/test1/test1.dto-ruby.User.expected +36 -0
  29. data/test/test1/test1.yaml +85 -0
  30. data/test/test2/test2.ddl-mysql.expected +49 -0
  31. data/test/test2/test2.ddl-postgresql.expected +49 -0
  32. data/test/test2/test2.dto-java.Address.expected +42 -0
  33. data/test/test2/test2.dto-java.Customer.expected +49 -0
  34. data/test/test2/test2.dto-java.Item.expected +37 -0
  35. data/test/test2/test2.dto-java.SalesOrder.expected +50 -0
  36. data/test/test2/test2.dto-java.SalesOrderLine.expected +56 -0
  37. data/test/test2/test2.dto-ruby.Address.expected +25 -0
  38. data/test/test2/test2.dto-ruby.Customer.expected +32 -0
  39. data/test/test2/test2.dto-ruby.Item.expected +23 -0
  40. data/test/test2/test2.dto-ruby.SalesOrder.expected +32 -0
  41. data/test/test2/test2.dto-ruby.SalesOrderLine.expected +39 -0
  42. data/test/test2/test2.yaml +94 -0
  43. metadata +91 -0
@@ -0,0 +1,85 @@
1
+ ##
2
+ ## example data file for kwatable
3
+ ##
4
+ ## copyright(c) 2005 kuwata-lab.com all rights reserved.
5
+ ## $Release: 0.0.1 $
6
+ ## $Rev$
7
+ ##
8
+
9
+ columns:
10
+ - name: id
11
+ type: integer
12
+ primary-key: yes
13
+ serial: yes
14
+
15
+ - name: name
16
+ type: string
17
+ not-null: yes
18
+ width: 63
19
+
20
+ - name: desc
21
+ type: string
22
+
23
+ - name: email
24
+ type: string
25
+ width: 63
26
+
27
+ - name: status
28
+ type: string
29
+ width: 15
30
+
31
+ - name: username
32
+ type: string
33
+ width: 31
34
+
35
+ - name: password
36
+ type: string
37
+ width: 31
38
+
39
+ - name: memo
40
+ type: text
41
+
42
+ - name: text
43
+ type: text
44
+
45
+ - name: birth
46
+ type: date
47
+
48
+ - name: age
49
+ type: integer
50
+
51
+ - name: last_update
52
+ type: timestamp
53
+
54
+ - name: gender
55
+ type: string
56
+ values:
57
+ - M
58
+ - F
59
+
60
+ tables:
61
+ - name: groups
62
+ class: Group
63
+ desc: Group master table
64
+ columns:
65
+ - name: id
66
+ - name: name
67
+ - name: desc
68
+
69
+ - name: users
70
+ class: User
71
+ desc: User master table
72
+ columns:
73
+ - name: id
74
+ - name: name
75
+ - name: desc
76
+ - name: email
77
+ - name: group_id
78
+ ref: groups.id
79
+ - name: account
80
+ type: string
81
+ width: 31
82
+ not-null: yes
83
+ - name: password
84
+ not-null: yes
85
+
@@ -0,0 +1,49 @@
1
+ ----------------------------------------------------------------------
2
+ -- DDL for MySQL
3
+ -- generated by kwatable with template 'ddl-mysql.eruby'
4
+ ----------------------------------------------------------------------
5
+
6
+ -- Address master table
7
+ create table addresses (
8
+ id integer auto_increment primary key,
9
+ zipcode varchar(8) ,
10
+ addr1 varchar(255) ,
11
+ addr2 varchar(255) ,
12
+ addr3 varchar(255)
13
+ );
14
+
15
+ -- Customer master table
16
+ create table customers (
17
+ id integer auto_increment primary key,
18
+ name varchar(255) not null,
19
+ tel varchar(255) ,
20
+ email varchar(255) ,
21
+ address_id integer not null -- references addresses.id
22
+ );
23
+
24
+ -- Item master table
25
+ create table items (
26
+ id integer auto_increment primary key,
27
+ name varchar(255) not null,
28
+ `desc` varchar(255) ,
29
+ price decimal not null
30
+ );
31
+
32
+ -- Sales order master table
33
+ create table sales_orders (
34
+ id integer auto_increment primary key,
35
+ customer_id integer not null, -- references customers.id
36
+ ordered_date date not null,
37
+ delivery_date date ,
38
+ amount decimal
39
+ );
40
+
41
+ -- Sales Order detail lines
42
+ create table sales_order_lines (
43
+ num integer not null,
44
+ order_id integer not null, -- references sales_orders.id
45
+ item_id integer not null, -- references items.id
46
+ price decimal not null,
47
+ quantity integer not null
48
+ , primary key (order_id, item_id)
49
+ );
@@ -0,0 +1,49 @@
1
+ ----------------------------------------------------------------------
2
+ -- DDL for PostgreSQL
3
+ -- generated by kwatable with template 'ddl-postgresql.eruby'
4
+ ----------------------------------------------------------------------
5
+
6
+ -- Address master table
7
+ create table addresses (
8
+ id serial primary key,
9
+ zipcode varchar(8) ,
10
+ addr1 varchar(255) ,
11
+ addr2 varchar(255) ,
12
+ addr3 varchar(255)
13
+ );
14
+
15
+ -- Customer master table
16
+ create table customers (
17
+ id serial primary key,
18
+ name varchar(255) not null,
19
+ tel varchar(255) ,
20
+ email varchar(255) ,
21
+ address_id integer not null references addresses(id)
22
+ );
23
+
24
+ -- Item master table
25
+ create table items (
26
+ id serial primary key,
27
+ name varchar(255) not null,
28
+ "desc" varchar(255) ,
29
+ price decimal not null
30
+ );
31
+
32
+ -- Sales order master table
33
+ create table sales_orders (
34
+ id serial primary key,
35
+ customer_id integer not null references customers(id),
36
+ ordered_date date not null,
37
+ delivery_date date ,
38
+ amount decimal
39
+ );
40
+
41
+ -- Sales Order detail lines
42
+ create table sales_order_lines (
43
+ num integer not null,
44
+ order_id integer not null references sales_orders(id),
45
+ item_id integer not null references items(id),
46
+ price decimal not null,
47
+ quantity integer not null
48
+ , primary key (order_id, item_id)
49
+ );
@@ -0,0 +1,42 @@
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 Address(int id, String zipcode, String addr1, String addr2, String addr3) {
18
+ this.id = id;
19
+ this.zipcode = zipcode;
20
+ this.addr1 = addr1;
21
+ this.addr2 = addr2;
22
+ this.addr3 = 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
+ // -----------
41
+
42
+ }
@@ -0,0 +1,49 @@
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 Customer(int id, String name, String tel, String email, int address_id) {
18
+ this.id = id;
19
+ this.name = name;
20
+ this.tel = tel;
21
+ this.email = email;
22
+ this.address_id = 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
+ // -----------
41
+
42
+ private Address address;
43
+ public Address getAddress() { return address; }
44
+ public void setAddress(Address address) {
45
+ this.address = address;
46
+ this.address_id = address.getId();
47
+ }
48
+
49
+ }
@@ -0,0 +1,37 @@
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 Item(int id, String name, String desc, double price) {
17
+ this.id = id;
18
+ this.name = name;
19
+ this.desc = desc;
20
+ this.price = 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
+ // -----------
36
+
37
+ }
@@ -0,0 +1,50 @@
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 SalesOrder(int id, int customer_id, Date ordered_date, Date delivery_date, double amount) {
19
+ this.id = id;
20
+ this.customer_id = customer_id;
21
+ this.ordered_date = ordered_date;
22
+ this.delivery_date = delivery_date;
23
+ this.amount = 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
+ // -----------
42
+
43
+ private Customer customer;
44
+ public Customer getCustomer() { return customer; }
45
+ public void setCustomer(Customer customer) {
46
+ this.customer = customer;
47
+ this.customer_id = customer.getId();
48
+ }
49
+
50
+ }
@@ -0,0 +1,56 @@
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 SalesOrderLine(int num, int order_id, int item_id, double price, int quantity) {
18
+ this.num = num;
19
+ this.order_id = order_id;
20
+ this.item_id = item_id;
21
+ this.price = price;
22
+ this.quantity = 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
+ // -----------
41
+
42
+ private SalesOrder order;
43
+ public SalesOrder getOrder() { return order; }
44
+ public void setOrder(SalesOrder order) {
45
+ this.order = order;
46
+ this.order_id = order.getId();
47
+ }
48
+
49
+ private Item item;
50
+ public Item getItem() { return item; }
51
+ public void setItem(Item item) {
52
+ this.item = item;
53
+ this.item_id = item.getId();
54
+ }
55
+
56
+ }
@@ -0,0 +1,25 @@
1
+ ##
2
+ ## DTO for Ruby
3
+ ## generated by kwatable with template 'dto-ruby.eruby'
4
+ ##
5
+
6
+ ## Address master table
7
+ class Address
8
+
9
+ def initialize(id, zipcode, addr1, addr2, addr3)
10
+ @id = id
11
+ @zipcode = zipcode
12
+ @addr1 = addr1
13
+ @addr2 = addr2
14
+ @addr3 = addr3
15
+ end
16
+
17
+ attr_accessor :id #
18
+ attr_accessor :zipcode #
19
+ attr_accessor :addr1 #
20
+ attr_accessor :addr2 #
21
+ attr_accessor :addr3 #
22
+
23
+ // -----------
24
+
25
+ end