Class: MiniSheet
- Inherits:
-
Mustache
- Object
- Mustache
- MiniSheet
- Defined in:
- lib/sawa/MiniSheet.rb
Instance Method Summary collapse
- #api_imports ⇒ Object
- #api_name ⇒ Object
- #dao_name ⇒ Object
-
#initialize(sheet, config) ⇒ MiniSheet
constructor
A new instance of MiniSheet.
- #model_imports ⇒ Object
- #model_name ⇒ Object
- #model_property_metas ⇒ Object
- #model_title ⇒ Object
- #name ⇒ Object
- #package_api ⇒ Object
- #package_dao ⇒ Object
- #package_model ⇒ Object
- #package_resource ⇒ Object
- #page_name ⇒ Object
- #resource_imports ⇒ Object
- #resource_name ⇒ Object
- #resource_path ⇒ Object
- #rows_model ⇒ Object
- #rows_path ⇒ Object
- #table_name ⇒ Object
Constructor Details
#initialize(sheet, config) ⇒ MiniSheet
Returns a new instance of MiniSheet.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sawa/MiniSheet.rb', line 7 def initialize(sheet, config) @sheet = sheet @config = config @idx_path = 2 @idx_title = 3 @idx_method = 1 @idx_process = 2 @idx_role = 3 @idx_type = 1 @idx_name = 2 @idx_unique = 3 @idx_nullable = 4 @idx_jsonignore = 5 @idx_mtitle = 6 @idx_mappedBy = 7 @idx_refColumn = 8 @idx_isList = 5 @idx_param = 6 end |
Instance Method Details
#api_imports ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/sawa/MiniSheet.rb', line 150 def api_imports arr = [] @sheet.each do |row| if row[0] != "p" next end if row[@idx_isList] == "1" and !arr.include?("import java.util.List;") arr.push "import java.util.List;" end if row[@idx_param].include?("@role") and !arr.include?("import io.dropwizard.auth.Auth;") arr.push "import io.dropwizard.auth.Auth;" end end arr end |
#api_name ⇒ Object
83 84 85 |
# File 'lib/sawa/MiniSheet.rb', line 83 def api_name getName("if", @sheet.name) end |
#dao_name ⇒ Object
71 72 73 |
# File 'lib/sawa/MiniSheet.rb', line 71 def dao_name getName("dao", @sheet.name) end |
#model_imports ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/sawa/MiniSheet.rb', line 97 def model_imports arr = [] @sheet.each do |row| if row[0] != "m" next end if row[@idx_jsonignore] == "1" and !arr.include?("import com.fasterxml.jackson.annotation.JsonIgnore;") arr.push "import com.fasterxml.jackson.annotation.JsonIgnore;" end if row[@idx_mappedBy] == "1:n" and !arr.include?("import javax.persistence.OneToMany;") arr.push "import javax.persistence.OneToMany;" end if row[@idx_mappedBy] == "1:n" and !arr.include?("import com.fasterxml.jackson.annotation.JsonManagedReference;") arr.push "import com.fasterxml.jackson.annotation.JsonManagedReference;" end if row[@idx_mappedBy] == "1:n" and !arr.include?("import org.hibernate.annotations.Where;") arr.push "import org.hibernate.annotations.Where;" end if row[@idx_mappedBy] == "n:1" and !arr.include?("import javax.persistence.ManyToOne;") arr.push "import javax.persistence.ManyToOne;" end if row[@idx_mappedBy] == "n:1" and !arr.include?("import com.fasterxml.jackson.annotation.JsonBackReference;") arr.push "import com.fasterxml.jackson.annotation.JsonBackReference;" end if row[@idx_mappedBy] == "n:1" and !arr.include?("import javax.persistence.JoinColumn;") arr.push "import javax.persistence.JoinColumn;" end if row[@idx_mappedBy] == "1:1" and !arr.include?("import javax.persistence.OneToOne;") arr.push "import javax.persistence.OneToOne;" end if row[@idx_mappedBy] == "1:1" and !arr.include?("import javax.persistence.JoinColumn;") arr.push "import javax.persistence.JoinColumn;" end end arr end |
#model_name ⇒ Object
59 60 61 |
# File 'lib/sawa/MiniSheet.rb', line 59 def model_name getName("model", @sheet.name) end |
#model_property_metas ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/sawa/MiniSheet.rb', line 87 def arr = [] @sheet.each do |row| if row[0] == "m" and row[@idx_jsonignore] == "1" arr.push "#{@sheet.row(0)[@idx_path]}.#{row[@idx_name]}=#{row[@idx_type]},#{row[@idx_nullable]},#{row[@idx_mtitle]}" end end arr end |
#model_title ⇒ Object
67 68 69 |
# File 'lib/sawa/MiniSheet.rb', line 67 def model_title @sheet.row(0)[@idx_title] end |
#name ⇒ Object
27 28 29 |
# File 'lib/sawa/MiniSheet.rb', line 27 def name @sheet.name end |
#package_api ⇒ Object
39 40 41 |
# File 'lib/sawa/MiniSheet.rb', line 39 def package_api @config['packageApi'] end |
#package_dao ⇒ Object
43 44 45 |
# File 'lib/sawa/MiniSheet.rb', line 43 def package_dao @config['packageDao'] end |
#package_model ⇒ Object
47 48 49 |
# File 'lib/sawa/MiniSheet.rb', line 47 def package_model @config['packageModel'] end |
#package_resource ⇒ Object
51 52 53 |
# File 'lib/sawa/MiniSheet.rb', line 51 def package_resource @config['packageResource'] end |
#page_name ⇒ Object
79 80 81 |
# File 'lib/sawa/MiniSheet.rb', line 79 def page_name getName("page", @sheet.name) end |
#resource_imports ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/sawa/MiniSheet.rb', line 137 def resource_imports arr = [] @sheet.each do |row| if row[0] != "p" next end if row[@idx_jsonignore] == "1" and !arr.include?("import java.util.List;") arr.push "import java.util.List;" end end arr end |
#resource_name ⇒ Object
75 76 77 |
# File 'lib/sawa/MiniSheet.rb', line 75 def resource_name getName("resource", @sheet.name) end |
#resource_path ⇒ Object
63 64 65 |
# File 'lib/sawa/MiniSheet.rb', line 63 def resource_path @sheet.row(0)[@idx_path] end |
#rows_model ⇒ Object
31 32 33 |
# File 'lib/sawa/MiniSheet.rb', line 31 def rows_model get_model_rows(@sheet) end |
#rows_path ⇒ Object
35 36 37 |
# File 'lib/sawa/MiniSheet.rb', line 35 def rows_path get_path_rows(@sheet) end |
#table_name ⇒ Object
55 56 57 |
# File 'lib/sawa/MiniSheet.rb', line 55 def table_name @sheet.name end |