kwatable 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/ChangeLog.txt +28 -2
  2. data/README.txt +1 -1
  3. data/bin/kwatable +2 -2
  4. data/examples/ex1/Makefile +1 -1
  5. data/examples/ex1/example1.yaml +18 -7
  6. data/examples/ex2/Makefile +1 -1
  7. data/kwatable.gemspec +2 -2
  8. data/lib/kwatable/error-msg.rb +15 -14
  9. data/lib/kwatable/kwatable.schema.yaml +34 -81
  10. data/lib/kwatable/main-program.rb +49 -41
  11. data/lib/kwatable/manipulator.rb +222 -0
  12. data/lib/kwatable/templates/ddl-mysql.eruby +15 -12
  13. data/lib/kwatable/templates/ddl-postgresql.eruby +14 -10
  14. data/lib/kwatable/templates/defaults.yaml +4 -4
  15. data/lib/kwatable/templates/dto-java.eruby +49 -59
  16. data/lib/kwatable/templates/dto-ruby.eruby +47 -54
  17. data/lib/kwatable.rb +3 -4
  18. data/test/assert-diff.rb +1 -1
  19. data/test/test.rb +24 -17
  20. data/test/test1/test1.ddl-mysql.expected +3 -2
  21. data/test/test1/test1.ddl-postgresql.expected +2 -1
  22. data/test/test1/test1.dto-java.Group.expected +12 -9
  23. data/test/test1/test1.dto-java.User.expected +12 -14
  24. data/test/test1/test1.dto-ruby.Group.expected +9 -10
  25. data/test/test1/test1.dto-ruby.User.expected +12 -15
  26. data/test/test1/test1.yaml +18 -7
  27. data/test/test2/test2.ddl-mysql.expected +4 -4
  28. data/test/test2/test2.dto-java.Address.expected +6 -8
  29. data/test/test2/test2.dto-java.Customer.expected +6 -8
  30. data/test/test2/test2.dto-java.Item.expected +5 -7
  31. data/test/test2/test2.dto-java.SalesOrder.expected +6 -8
  32. data/test/test2/test2.dto-java.SalesOrderLine.expected +6 -8
  33. data/test/test2/test2.dto-ruby.Address.expected +6 -9
  34. data/test/test2/test2.dto-ruby.Customer.expected +6 -9
  35. data/test/test2/test2.dto-ruby.Item.expected +5 -8
  36. data/test/test2/test2.dto-ruby.SalesOrder.expected +6 -9
  37. data/test/test2/test2.dto-ruby.SalesOrderLine.expected +6 -9
  38. data/test/test2/test2.yaml +3 -3
  39. metadata +65 -64
  40. data/lib/kwatable/manufactory.rb +0 -213
@@ -1,16 +1,17 @@
1
1
  <%
2
2
 
3
3
  ##
4
- ## kwatable template file for Java DTO class
4
+ ## kwatable template file for Ruby DTO class
5
5
  ##
6
6
  ## copyright(c) 2005 kuwata-lab.com all rights reserved.
7
- ## $Release: 0.0.1 $
8
- ## $Rev: 12 $
7
+ ## $Release: 0.1.0 $
8
+ ## $Rev: 15 $
9
9
  ##
10
10
  ## template properties:
11
11
  ## module - module name
12
12
  ## parent - parent class
13
13
  ## reqpath - require path
14
+ ##
14
15
 
15
16
 
16
17
  #
@@ -18,46 +19,43 @@
18
19
  #
19
20
  table = context['table']
20
21
  properties = context['properties']
21
- raise "option '-m' is required when using 'dto-java.eruby'." unless table
22
-
23
-
24
- unless defined?(KEYWORDS)
25
- #
26
- # java keywords
27
- #
28
- keywords = <<-END
29
- BEGIN END alias and begin break case
30
- class def defined do else elsif end
31
- ensure false for if in module next
32
- nil not or redo rescue retry return
33
- self super then true undef unless
34
- until when while yield
35
- END
36
- KEYWORDS = {}
37
- keywords.split(/\s+/).each { |word| KEYWORDS[word] = true }
38
-
39
-
40
- #
41
- # escape java keywords
42
- #
43
- def _(word)
44
- return KEYWORDS[word] ? "_#{word}" : word
45
- end
22
+ raise "option '-m' is required when using 'dto-ruby.eruby'." unless table
46
23
 
47
24
 
48
- #
49
- # convert 'aaa_bbb_ccc' into 'AaaBbbCcc'
50
- #
51
- def camel_case(name, flag_all=true)
52
- s = ''
53
- name.split('_').each_with_index do |word, i|
54
- s << (!flag_all && i == 0 ? word.downcase : word.capitalize)
55
- end
56
- return s
57
- #s = name.split('_').collect { |w| w.capitalize }.join()
58
- #s[0] = s[0].to_s.upcase.chr unless flag_all
59
- end
25
+ #
26
+ # ruby keywords
27
+ #
28
+ keywords = <<-END
29
+ BEGIN END alias and begin break case
30
+ class def defined do else elsif end
31
+ ensure false for if in module next
32
+ nil not or redo rescue retry return
33
+ self super then true undef unless
34
+ until when while yield
35
+ END
36
+ @keywords = {}
37
+ keywords.split(/\s+/).each { |word| @keywords[word] = true }
38
+
39
+
40
+ #
41
+ # escape java keywords
42
+ #
43
+ def self._(word)
44
+ return @keywords[word] ? "_#{word}" : word
45
+ end
46
+
60
47
 
48
+ #
49
+ # convert 'aaa_bbb_ccc' into 'AaaBbbCcc'
50
+ #
51
+ def self.camel_case(name, flag_all=true)
52
+ s = ''
53
+ name.split('_').each_with_index do |word, i|
54
+ s << (!flag_all && i == 0 ? word.downcase : word.capitalize)
55
+ end
56
+ return s
57
+ #s = name.split('_').collect { |w| w.capitalize }.join()
58
+ #s[0] = s[0].to_s.upcase.chr unless flag_all
61
59
  end
62
60
 
63
61
 
@@ -103,9 +101,9 @@
103
101
  # require other dto file
104
102
  #
105
103
  for column in table['columns']
106
- if column['ref-table']
107
- refclass = column['ref-table']['class']
108
- refclass ||= camel_case(column['ref-table']['name'])
104
+ if column['ref']
105
+ refclass = column['ref']['table']['class']
106
+ refclass ||= camel_case(column['ref']['table']['name'])
109
107
  reqpath = properties[:reqpath]
110
108
  %>
111
109
  require '<%= reqpath %><%= reqpath ? '/' : '' %><%= refclass %>'
@@ -127,15 +125,12 @@ class <%= mod %><%= klass[:name] %><% extends %>
127
125
 
128
126
  <%
129
127
  #
130
- # initializer
128
+ # populator with hash
131
129
  #
132
- argstr = variables.collect { |var| _(var[:name]) }.join(", ")
133
- %>
134
-
135
- def initialize(<%= argstr %>)
130
+ %>
131
+ def populate(values={})
136
132
  <% for var in variables %>
137
- @<%= var[:name] %> = <%=_ var[:name] %>
138
-
133
+ self.<%= "%-14s" % var[:name] %> = values['<%= var[:name] %>']
139
134
  <% end %>
140
135
  end
141
136
 
@@ -149,15 +144,13 @@ class <%= mod %><%= klass[:name] %><% extends %>
149
144
 
150
145
  <% end %>
151
146
 
152
- // -----------
153
-
154
147
  <%
155
148
  #
156
149
  # foreign keys
157
150
  #
158
151
  table['columns'].each do |column|
159
- if column['ref-table']
160
- refcol = column['ref-column']['name']
152
+ if column['ref']
153
+ refcol = column['ref']['name']
161
154
  refname = column['ref-name']
162
155
  varname = column['name']
163
156
  if refname == varname
data/lib/kwatable.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  ###
2
2
  ### copyright(c) 2005 kuwata-lab.com all rights reserved.
3
- ### $Release: 0.0.1 $
4
- ### $Rev: 11 $
3
+ ### $Release: 0.1.0 $
4
+ ### $Rev: 15 $
5
5
  ###
6
6
 
7
7
  module Kwatable
@@ -27,5 +27,4 @@ module Kwatable
27
27
  end
28
28
 
29
29
  require 'kwatable/error-msg'
30
-
31
- require 'kwatable/manufactory'
30
+ require 'kwatable/manipulator'
data/test/assert-diff.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ###
2
2
  ### copyright(c) 2005 kuwata-lab.com all rights reserved.
3
- ### $Release: 0.0.1 $
3
+ ### $Release: 0.1.0 $
4
4
  ### $Rev: 10 $
5
5
  ###
6
6
 
data/test/test.rb CHANGED
@@ -1,28 +1,31 @@
1
1
  ###
2
2
  ### copyright(c) 2005 kuwata-lab.com all rights reserved.
3
- ### $Release: 0.0.1 $
4
- ### $Rev: 11 $
3
+ ### $Release: 0.1.0 $
4
+ ### $Rev: 15 $
5
5
  ###
6
6
 
7
- dir = Dir.pwd
8
- dir = File.dirname(dir) if File.basename(dir) == 'test'
9
-
10
- BASE_DIR = dir
11
- TEST_DIR = "#{BASE_DIR}/test"
12
- LIB_DIR = "#{BASE_DIR}/lib"
13
- EXAMPLES_DIR = "#{BASE_DIR}/examples"
14
-
15
- Dir.chdir(TEST_DIR)
16
-
17
- $: << LIB_DIR
18
- $: << TEST_DIR
7
+ unless defined?(BASE_DIR)
8
+ TEST_DIR = File.expand_path(File.dirname(__FILE__))
9
+ BASE_DIR = File.dirname(TEST_DIR)
10
+ LIB_DIR = BASE_DIR + "/lib"
11
+ BIN_DIR = BASE_DIR + "/bin"
12
+ EXAMPLES_DIR = BASE_DIR + "/examples"
13
+ $LOAD_PATH << LIB_DIR << TEST_DIR
14
+
15
+ ENV['RUBYLIB'] = LIB_DIR
16
+ ENV['PATH'] = "#{BIN_DIR}:#{ENV['PATH']}"
17
+ #puts ENV['PATH']
18
+ #puts `kwatable -h`
19
+ #exit 0
20
+ end
21
+ Dir.chdir TEST_DIR
19
22
 
20
- ENV['RUBYLIB'] = LIB_DIR
21
23
 
22
24
  require 'test/unit'
23
25
  require 'test/unit/ui/console/testrunner'
24
26
 
25
27
  require 'kwatable.rb'
28
+ require 'kwatable/main-program'
26
29
  require 'assert-diff'
27
30
 
28
31
 
@@ -37,8 +40,12 @@ class KwatableExampleTest < Test::Unit::TestCase
37
40
  cmd = "kwatable -f #{@template} #{optstr} #{@datafile}"
38
41
  #cmd = "kwatable -I #{BASE_DIR}/templates -f #{@template} #{optstr} #{@datafile}"
39
42
  $logger.write("- command: #{cmd}\n thread: #{Thread.current.__id__}\n timestamp: #{Time.new.to_s}\n")
40
- #$stderr.puts "*** debug: cmd=#{cmd.inspect}"
41
- actual = `#{cmd}`
43
+ #actual = `#{cmd}`
44
+ argv = cmd.split(/\s+/)
45
+ argv.shift
46
+ main = Kwatable::MainProgram.new(argv)
47
+ actual = main.execute()
48
+
42
49
  if @classnames
43
50
  actuals = {}
44
51
  @classnames.each do |classname|
@@ -7,7 +7,8 @@
7
7
  create table groups (
8
8
  id integer auto_increment primary key,
9
9
  name varchar(63) not null,
10
- `desc` varchar(255)
10
+ `desc` varchar(255) ,
11
+ class enum('ADMIN', 'SYSTEM', 'USER', 'UNUSED')
11
12
  );
12
13
 
13
14
  -- User master table
@@ -16,7 +17,7 @@ create table users (
16
17
  name varchar(63) not null,
17
18
  `desc` varchar(255) ,
18
19
  email varchar(63) ,
19
- group_id integer , -- references groups.id
20
+ group_id integer , -- references groups(id)
20
21
  account varchar(31) not null,
21
22
  password varchar(31) not null
22
23
  );
@@ -7,7 +7,8 @@
7
7
  create table groups (
8
8
  id serial primary key,
9
9
  name varchar(63) not null,
10
- "desc" varchar(255)
10
+ "desc" varchar(255) ,
11
+ class varchar(6) -- ADMIN,SYSTEM,USER,UNUSED
11
12
  );
12
13
 
13
14
  -- User master table
@@ -8,14 +8,16 @@
8
8
  */
9
9
  public class Group implements java.io.Serializable {
10
10
 
11
- private int id; /* */
12
- private String name; /* */
13
- private String desc; /* */
14
-
15
- public Group(int id, String name, String desc) {
16
- this.id = id;
17
- this.name = name;
18
- this.desc = desc;
11
+ private int id; /* group id */
12
+ private String name; /* group name */
13
+ private String desc; /* group description */
14
+ private String _class; /* group class */
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
+ setClass(resultset.getString("class"));
19
21
  }
20
22
 
21
23
  public int getId() { return id }
@@ -27,6 +29,7 @@ public class Group implements java.io.Serializable {
27
29
  public String getDesc() { return desc }
28
30
  public void setDesc(String desc) { this.desc = desc; }
29
31
 
30
- // -----------
32
+ public String getClass() { return _class }
33
+ public void setClass(String _class) { this._class = _class; }
31
34
 
32
35
  }
@@ -8,22 +8,22 @@
8
8
  */
9
9
  public class User implements java.io.Serializable {
10
10
 
11
- private int id; /* */
12
- private String name; /* */
13
- private String desc; /* */
11
+ private int id; /* user id */
12
+ private String name; /* user name */
13
+ private String desc; /* description about user */
14
14
  private String email; /* */
15
- private int group_id; /* */
15
+ private int group_id; /* group id to which user belongs */
16
16
  private String account; /* */
17
17
  private String password; /* */
18
18
 
19
- public User(int id, String name, String desc, String email, int group_id, String account, String password) {
20
- this.id = id;
21
- this.name = name;
22
- this.desc = desc;
23
- this.email = email;
24
- this.group_id = group_id;
25
- this.account = account;
26
- this.password = password;
19
+ public void populate(java.sql.ResultSet resultset) {
20
+ setId(resultset.getInt("id"));
21
+ setName(resultset.getString("name"));
22
+ setDesc(resultset.getString("desc"));
23
+ setEmail(resultset.getString("email"));
24
+ setGroupId(resultset.getInt("group_id"));
25
+ setAccount(resultset.getString("account"));
26
+ setPassword(resultset.getString("password"));
27
27
  }
28
28
 
29
29
  public int getId() { return id }
@@ -47,8 +47,6 @@ public class User implements java.io.Serializable {
47
47
  public String getPassword() { return password }
48
48
  public void setPassword(String password) { this.password = password; }
49
49
 
50
- // -----------
51
-
52
50
  private Group group;
53
51
  public Group getGroup() { return group; }
54
52
  public void setGroup(Group group) {
@@ -5,17 +5,16 @@
5
5
 
6
6
  ## Group master table
7
7
  class Group
8
-
9
- def initialize(id, name, desc)
10
- @id = id
11
- @name = name
12
- @desc = desc
8
+ def populate(values={})
9
+ self.id = values['id']
10
+ self.name = values['name']
11
+ self.desc = values['desc']
12
+ self.class = values['class']
13
13
  end
14
14
 
15
- attr_accessor :id #
16
- attr_accessor :name #
17
- attr_accessor :desc #
18
-
19
- // -----------
15
+ attr_accessor :id # group id
16
+ attr_accessor :name # group name
17
+ attr_accessor :desc # group description
18
+ attr_accessor :class # group class
20
19
 
21
20
  end
@@ -6,27 +6,24 @@ require 'Group'
6
6
 
7
7
  ## User master table
8
8
  class User
9
-
10
- def initialize(id, name, desc, email, group_id, account, password)
11
- @id = id
12
- @name = name
13
- @desc = desc
14
- @email = email
15
- @group_id = group_id
16
- @account = account
17
- @password = password
9
+ def populate(values={})
10
+ self.id = values['id']
11
+ self.name = values['name']
12
+ self.desc = values['desc']
13
+ self.email = values['email']
14
+ self.group_id = values['group_id']
15
+ self.account = values['account']
16
+ self.password = values['password']
18
17
  end
19
18
 
20
- attr_accessor :id #
21
- attr_accessor :name #
22
- attr_accessor :desc #
19
+ attr_accessor :id # user id
20
+ attr_accessor :name # user name
21
+ attr_accessor :desc # description about user
23
22
  attr_accessor :email #
24
- attr_accessor :group_id #
23
+ attr_accessor :group_id # group id to which user belongs
25
24
  attr_accessor :account #
26
25
  attr_accessor :password #
27
26
 
28
- // -----------
29
-
30
27
  attr_reader :group
31
28
  def group=(group)
32
29
  @group = group
@@ -2,19 +2,19 @@
2
2
  ## example data file for kwatable
3
3
  ##
4
4
  ## copyright(c) 2005 kuwata-lab.com all rights reserved.
5
- ## $Release: 0.0.1 $
6
- ## $Rev$
5
+ ## $Release: 0.1.0 $
6
+ ## $Rev: 13 $
7
7
  ##
8
8
 
9
9
  columns:
10
10
  - name: id
11
11
  type: integer
12
- primary-key: yes
12
+ ident: yes
13
13
  serial: yes
14
14
 
15
15
  - name: name
16
16
  type: string
17
- not-null: yes
17
+ required: yes
18
18
  width: 63
19
19
 
20
20
  - name: desc
@@ -53,7 +53,7 @@ columns:
53
53
 
54
54
  - name: gender
55
55
  type: string
56
- values:
56
+ enum:
57
57
  - M
58
58
  - F
59
59
 
@@ -63,23 +63,34 @@ tables:
63
63
  desc: Group master table
64
64
  columns:
65
65
  - name: id
66
+ desc: group id
66
67
  - name: name
68
+ desc: group name
67
69
  - name: desc
70
+ desc: group description
71
+ - name: class
72
+ desc: group class
73
+ type: string
74
+ enum: [ ADMIN, SYSTEM, USER, UNUSED ]
68
75
 
69
76
  - name: users
70
77
  class: User
71
78
  desc: User master table
72
79
  columns:
73
80
  - name: id
81
+ desc: user id
74
82
  - name: name
83
+ desc: user name
75
84
  - name: desc
85
+ desc: description about user
76
86
  - name: email
77
87
  - name: group_id
78
88
  ref: groups.id
89
+ desc: group id to which user belongs
79
90
  - name: account
80
91
  type: string
81
92
  width: 31
82
- not-null: yes
93
+ required: yes
83
94
  - name: password
84
- not-null: yes
95
+ required: yes
85
96
 
@@ -18,7 +18,7 @@ create table customers (
18
18
  name varchar(255) not null,
19
19
  tel varchar(255) ,
20
20
  email varchar(255) ,
21
- address_id integer not null -- references addresses.id
21
+ address_id integer not null -- references addresses(id)
22
22
  );
23
23
 
24
24
  -- Item master table
@@ -32,7 +32,7 @@ create table items (
32
32
  -- Sales order master table
33
33
  create table sales_orders (
34
34
  id integer auto_increment primary key,
35
- customer_id integer not null, -- references customers.id
35
+ customer_id integer not null, -- references customers(id)
36
36
  ordered_date date not null,
37
37
  delivery_date date ,
38
38
  amount decimal
@@ -41,8 +41,8 @@ create table sales_orders (
41
41
  -- Sales Order detail lines
42
42
  create table sales_order_lines (
43
43
  num integer not null,
44
- order_id integer not null, -- references sales_orders.id
45
- item_id integer not null, -- references items.id
44
+ order_id integer not null, -- references sales_orders(id)
45
+ item_id integer not null, -- references items(id)
46
46
  price decimal not null,
47
47
  quantity integer not null
48
48
  , primary key (order_id, item_id)
@@ -14,12 +14,12 @@ public class Address implements java.io.Serializable {
14
14
  private String addr2; /* */
15
15
  private String addr3; /* */
16
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;
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
23
  }
24
24
 
25
25
  public int getId() { return id }
@@ -37,6 +37,4 @@ public class Address implements java.io.Serializable {
37
37
  public String getAddr3() { return addr3 }
38
38
  public void setAddr3(String addr3) { this.addr3 = addr3; }
39
39
 
40
- // -----------
41
-
42
40
  }
@@ -14,12 +14,12 @@ public class Customer implements java.io.Serializable {
14
14
  private String email; /* */
15
15
  private int address_id; /* */
16
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;
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
23
  }
24
24
 
25
25
  public int getId() { return id }
@@ -37,8 +37,6 @@ public class Customer implements java.io.Serializable {
37
37
  public int getAddressId() { return address_id }
38
38
  public void setAddressId(int address_id) { this.address_id = address_id; }
39
39
 
40
- // -----------
41
-
42
40
  private Address address;
43
41
  public Address getAddress() { return address; }
44
42
  public void setAddress(Address address) {
@@ -13,11 +13,11 @@ public class Item implements java.io.Serializable {
13
13
  private String desc; /* */
14
14
  private double price; /* */
15
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;
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
21
  }
22
22
 
23
23
  public int getId() { return id }
@@ -32,6 +32,4 @@ public class Item implements java.io.Serializable {
32
32
  public double getPrice() { return price }
33
33
  public void setPrice(double price) { this.price = price; }
34
34
 
35
- // -----------
36
-
37
35
  }
@@ -15,12 +15,12 @@ public class SalesOrder implements java.io.Serializable {
15
15
  private Date delivery_date; /* */
16
16
  private double amount; /* */
17
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;
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
24
  }
25
25
 
26
26
  public int getId() { return id }
@@ -38,8 +38,6 @@ public class SalesOrder implements java.io.Serializable {
38
38
  public double getAmount() { return amount }
39
39
  public void setAmount(double amount) { this.amount = amount; }
40
40
 
41
- // -----------
42
-
43
41
  private Customer customer;
44
42
  public Customer getCustomer() { return customer; }
45
43
  public void setCustomer(Customer customer) {
@@ -14,12 +14,12 @@ public class SalesOrderLine implements java.io.Serializable {
14
14
  private double price; /* */
15
15
  private int quantity; /* */
16
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;
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
23
  }
24
24
 
25
25
  public int getNum() { return num }
@@ -37,8 +37,6 @@ public class SalesOrderLine implements java.io.Serializable {
37
37
  public int getQuantity() { return quantity }
38
38
  public void setQuantity(int quantity) { this.quantity = quantity; }
39
39
 
40
- // -----------
41
-
42
40
  private SalesOrder order;
43
41
  public SalesOrder getOrder() { return order; }
44
42
  public void setOrder(SalesOrder order) {