vraptor-scaffold 1.3.0.rc → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/.rvmrc.example +1 -0
  2. data/.travis.yml +2 -1
  3. data/CHANGELOG.rdoc +22 -3
  4. data/Rakefile +2 -2
  5. data/lib/vraptor-scaffold.rb +1 -1
  6. data/lib/vraptor-scaffold/generators/app/app_generator.rb +23 -56
  7. data/lib/vraptor-scaffold/generators/app/dependency/default_dependencies.rb +44 -0
  8. data/lib/vraptor-scaffold/generators/app/{dependency.rb → dependency/dependency.rb} +0 -0
  9. data/lib/vraptor-scaffold/generators/app/dependency/dependency_manager.rb +25 -0
  10. data/lib/vraptor-scaffold/generators/app/dependency/gae_dependencies.rb +49 -0
  11. data/lib/vraptor-scaffold/generators/app/dependency/heroku_dependencies.rb +48 -0
  12. data/lib/vraptor-scaffold/generators/app/freemarker_template_engine.rb +7 -5
  13. data/lib/vraptor-scaffold/generators/app/gae_app_generator.rb +145 -0
  14. data/lib/vraptor-scaffold/generators/app/jsp_template_engine.rb +6 -5
  15. data/lib/vraptor-scaffold/generators/app/templates/build-gae.xml +144 -0
  16. data/lib/vraptor-scaffold/generators/app/templates/build.gradle.erb +4 -4
  17. data/lib/vraptor-scaffold/generators/app/templates/eclipse/classpath-gae.erb +1 -3
  18. data/lib/vraptor-scaffold/generators/app/templates/eclipse/classpath.erb +1 -1
  19. data/lib/vraptor-scaffold/generators/app/templates/eclipse/project-gae.erb +2 -2
  20. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings-gae/com.google.appengine.eclipse.core.prefs +4 -0
  21. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings-gae/com.google.gdt.eclipse.core.prefs +1 -2
  22. data/lib/vraptor-scaffold/generators/app/templates/freemarker/macros/html.ftl +12 -0
  23. data/lib/vraptor-scaffold/generators/app/templates/freemarker/main.ftl.erb +18 -0
  24. data/lib/vraptor-scaffold/generators/app/templates/gae/appengine-web.xml.tt +1 -0
  25. data/lib/vraptor-scaffold/generators/app/templates/gae/ivysettings.xml +1 -1
  26. data/lib/vraptor-scaffold/generators/app/templates/gitignore-gae +4 -0
  27. data/lib/vraptor-scaffold/generators/app/templates/ivy.erb +3 -3
  28. data/lib/vraptor-scaffold/generators/app/templates/jsp/main.jsp.erb +20 -0
  29. data/lib/vraptor-scaffold/generators/app/templates/pom.erb +3 -3
  30. data/lib/vraptor-scaffold/generators/app/templates/vraptor-scaffold-gae.erb +7 -0
  31. data/lib/vraptor-scaffold/generators/base.rb +21 -0
  32. data/lib/vraptor-scaffold/generators/scaffold/attribute.rb +7 -1
  33. data/lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb +18 -0
  34. data/lib/vraptor-scaffold/generators/scaffold/controller_generator/templates/controller.erb +26 -1
  35. data/lib/vraptor-scaffold/generators/scaffold/controller_generator/templates/controller_test.erb +1 -1
  36. data/lib/vraptor-scaffold/generators/scaffold/import_manager.rb +20 -0
  37. data/lib/vraptor-scaffold/generators/scaffold/model_generator/templates/model.erb +7 -4
  38. data/lib/vraptor-scaffold/generators/scaffold/model_generator/templates/objectify_model.erb +3 -3
  39. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/templates/form.erb +8 -0
  40. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/templates/form.erb +13 -3
  41. data/lib/vraptor-scaffold/load_paths.rb +3 -3
  42. data/lib/vraptor-scaffold/runner/generator.rb +11 -1
  43. data/lib/vraptor-scaffold/runner/start.rb +1 -1
  44. data/lib/vraptor-scaffold/version.rb +1 -1
  45. data/maven/repo/br/com/caelum/vraptor3.4-compatible-gae/1.1/vraptor3.4-compatible-gae-1.1.jar +0 -0
  46. data/spec/spec_helper.rb +9 -1
  47. data/spec/vraptor-scaffold/generators/app/app_generator_spec.rb +47 -99
  48. data/spec/vraptor-scaffold/generators/app/dependency/dependency_manager_spec.rb +21 -0
  49. data/spec/vraptor-scaffold/generators/app/{dependency_spec.rb → dependency/dependency_spec.rb} +4 -4
  50. data/spec/vraptor-scaffold/generators/app/dependency/gae_dependencies_spec.rb +20 -0
  51. data/spec/vraptor-scaffold/generators/app/dependency/heroku_dependencies_spec.rb +20 -0
  52. data/spec/vraptor-scaffold/generators/app/freemarker_template_engine_spec.rb +49 -7
  53. data/spec/vraptor-scaffold/generators/app/gae_app_generator_spec.rb +286 -0
  54. data/spec/vraptor-scaffold/generators/app/jsp_template_engine_spec.rb +49 -7
  55. data/spec/vraptor-scaffold/generators/app/templates/build.gradle +6 -6
  56. data/spec/vraptor-scaffold/generators/app/templates/classpath-gae +1 -3
  57. data/spec/vraptor-scaffold/generators/app/templates/gae-jsp-web.xml +1 -1
  58. data/spec/vraptor-scaffold/generators/app/templates/ivy-gae.xml +8 -6
  59. data/spec/vraptor-scaffold/generators/app/templates/ivy.xml +5 -5
  60. data/{lib/vraptor-scaffold/generators/app/templates/freemarker/main.ftl → spec/vraptor-scaffold/generators/app/templates/main-with-jquery.ftl} +0 -0
  61. data/{lib/vraptor-scaffold/generators/app/templates/jsp/main.jsp → spec/vraptor-scaffold/generators/app/templates/main-with-jquery.jsp} +0 -0
  62. data/spec/vraptor-scaffold/generators/app/templates/main-without-jquery.ftl +14 -0
  63. data/spec/vraptor-scaffold/generators/app/templates/main-without-jquery.jsp +16 -0
  64. data/spec/vraptor-scaffold/generators/app/templates/pom-heroku.xml +5 -5
  65. data/spec/vraptor-scaffold/generators/app/templates/pom.xml +5 -5
  66. data/spec/vraptor-scaffold/generators/app/templates/project-gae +2 -2
  67. data/spec/vraptor-scaffold/generators/app/templates/vraptor-scaffold-gae.properties +7 -0
  68. data/spec/vraptor-scaffold/generators/plugin/expected_configs/build.gradle +7 -7
  69. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_build.gradle +6 -6
  70. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_ivy.xml +5 -5
  71. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_pom.xml +5 -5
  72. data/spec/vraptor-scaffold/generators/plugin/expected_configs/ivy.xml +6 -6
  73. data/spec/vraptor-scaffold/generators/plugin/expected_configs/pom.xml +6 -6
  74. data/spec/vraptor-scaffold/generators/plugin/plugin_generator_spec.rb +7 -7
  75. data/spec/vraptor-scaffold/generators/scaffold/attribute_spec.rb +198 -181
  76. data/spec/vraptor-scaffold/generators/scaffold/base_scaffold_spec.rb +7 -1
  77. data/spec/vraptor-scaffold/generators/scaffold/controller_generator/templates/ProductController.java +9 -1
  78. data/spec/vraptor-scaffold/generators/scaffold/freemarker_generator/templates/form.ftl +15 -0
  79. data/spec/vraptor-scaffold/generators/scaffold/import_manager_spec.rb +9 -0
  80. data/spec/vraptor-scaffold/generators/scaffold/jsp_generator/templates/form.jsp +23 -3
  81. data/spec/vraptor-scaffold/generators/scaffold/model_generator/model_generator_spec.rb +2 -2
  82. data/spec/vraptor-scaffold/generators/scaffold/model_generator/objectify_model_generator_spec.rb +6 -6
  83. data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/Objectify_Product.java +23 -5
  84. data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/Product.java +24 -6
  85. data/spec/vraptor-scaffold/http_request_spec.rb +10 -0
  86. data/spec/vraptor-scaffold/runner/generator_spec.rb +18 -2
  87. metadata +86 -30
  88. data/lib/vraptor-scaffold/generators/app/dependency_manager.rb +0 -83
  89. data/spec/vraptor-scaffold/generators/app/dependency_manager_spec.rb +0 -34
@@ -9,5 +9,6 @@
9
9
  </system-properties>
10
10
 
11
11
  <sessions-enabled>true</sessions-enabled>
12
+ <threadsafe>true</threadsafe>
12
13
 
13
14
  </appengine-web-app>
@@ -4,7 +4,7 @@
4
4
  <chain name="chain">
5
5
  <ibiblio name="central" m2compatible="true"/>
6
6
  <ibiblio name="objectify-appengine" m2compatible="true" root="http://objectify-appengine.googlecode.com/svn/maven"/>
7
- <ibiblio name="vraptor-scaffold-repo" m2compatible="true" root="https://raw.github.com/caelum/vraptor-scaffold/master/maven/repo"/>
7
+ <ibiblio name="vraptor-scaffold-repo" m2compatible="true" root="https://raw.github.com/caelum/vraptor-scaffold/desenv/maven/repo"/>
8
8
  </chain>
9
9
  </resolvers>
10
10
  </ivysettings>
@@ -0,0 +1,4 @@
1
+ /lib/
2
+ /src/main/webapp/WEB-INF/lib/
3
+ /src/main/webapp/WEB-INF/classes/
4
+ /src/main/webapp/WEB-INF/appengine-generated/
@@ -9,15 +9,15 @@
9
9
  <conf name="minify" description="dependencies used to minify js and css" visibility="public" />
10
10
  </configurations>
11
11
 
12
- <dependencies><% @dependency_manager.compile_scope.each do |dependency| -%>
12
+ <dependencies><% @dependencies.compile_scope.each do |dependency| -%>
13
13
  <dependency org="<%= dependency.group %>" name="<%= dependency.name %>" rev="<%= dependency.version %>" conf="default"<% if dependency.has_exclusions? %>><% dependency.exclusions.each do |exclusion| %>
14
14
  <exclude org="<%= exclusion.group %>" name="<%= exclusion.name %>" />
15
15
  </dependency><% end %><% else %> /><% end %><% end %>
16
16
 
17
- <!-- Provided dependencies --><% @dependency_manager.provided_scope.each do |dependency| -%>
17
+ <!-- Provided dependencies --><% @dependencies.provided_scope.each do |dependency| -%>
18
18
  <dependency org="<%= dependency.group %>" name="<%= dependency.name %>" rev="<%= dependency.version %>" conf="provided->default" /><% end -%>
19
19
 
20
- <!-- Test dependencies --><% @dependency_manager.test_scope.each do |dependency| -%>
20
+ <!-- Test dependencies --><% @dependencies.test_scope.each do |dependency| -%>
21
21
  <dependency org="<%= dependency.group %>" name="<%= dependency.name %>" rev="<%= dependency.version %>" conf="test->default" /><% end -%>
22
22
 
23
23
  <!-- Jetty dependencies -->
@@ -0,0 +1,20 @@
1
+ <% sitemesh_directive = "<%@ taglib uri=\"http://www.opensymphony.com/sitemesh/decorator\" prefix=\"decorator\" %\>" %><%= sitemesh_directive %>
2
+
3
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
+
5
+ <html>
6
+ <head>
7
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
8
+ <title><decorator:title default="Vraptor Scaffold"/></title>
9
+ <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/stylesheets/application.css"/>
10
+ <decorator:head/>
11
+ </head>
12
+ <body>
13
+ <decorator:body/>
14
+ <%
15
+ jquery_file = File.join(destination_root, Configuration::WEB_APP, "javascripts", "jquery.min.js")
16
+ if (File.exists?(jquery_file))
17
+ %><script type="text/javascript" src="${pageContext.request.contextPath}/javascripts/jquery.min.js"></script>
18
+ <% end %><script type="text/javascript" src="${pageContext.request.contextPath}/javascripts/application.js"></script>
19
+ </body>
20
+ </html>
@@ -76,7 +76,7 @@
76
76
  </plugins>
77
77
  </build>
78
78
 
79
- <dependencies><% @dependency_manager.compile_scope.each do |dependency| %>
79
+ <dependencies><% @dependencies.compile_scope.each do |dependency| %>
80
80
  <dependency>
81
81
  <groupId><%= dependency.group %></groupId>
82
82
  <artifactId><%= dependency.name %></artifactId>
@@ -89,7 +89,7 @@
89
89
  </exclusions><% end %>
90
90
  </dependency><% end %>
91
91
 
92
- <!-- Test dependencies --><% @dependency_manager.test_scope.each do |dependency| %>
92
+ <!-- Test dependencies --><% @dependencies.test_scope.each do |dependency| %>
93
93
  <dependency>
94
94
  <groupId><%= dependency.group %></groupId>
95
95
  <artifactId><%= dependency.name %></artifactId>
@@ -97,7 +97,7 @@
97
97
  <scope>test</scope>
98
98
  </dependency><% end %>
99
99
 
100
- <!-- Provided dependencies --><% @dependency_manager.provided_scope.each do |dependency| %>
100
+ <!-- Provided dependencies --><% @dependencies.provided_scope.each do |dependency| %>
101
101
  <dependency>
102
102
  <groupId><%= dependency.group %></groupId>
103
103
  <artifactId><%= dependency.name %></artifactId>
@@ -0,0 +1,7 @@
1
+ build_tool: ant
2
+ package: <%= options[:package] %>
3
+ template_engine: jsp
4
+ orm: <%= orm %>
5
+ models_package: <%= options[:models_package] %>
6
+ controllers_package: <%= options[:controllers_package] %>
7
+ repositories_package: <%= options[:repositories_package] %>
@@ -3,3 +3,24 @@ module VraptorScaffold
3
3
  include Thor::Actions
4
4
  end
5
5
  end
6
+
7
+ require File.dirname(__FILE__) + '/plugin/plugin_generator'
8
+ require File.dirname(__FILE__) + '/app/app_generator'
9
+ require File.dirname(__FILE__) + '/app/gae_app_generator'
10
+ require File.dirname(__FILE__) + '/app/dependency/dependency'
11
+ require File.dirname(__FILE__) + '/app/dependency/dependency_manager'
12
+ require File.dirname(__FILE__) + '/app/dependency/default_dependencies'
13
+ require File.dirname(__FILE__) + '/app/dependency/heroku_dependencies'
14
+ require File.dirname(__FILE__) + '/app/dependency/gae_dependencies'
15
+ require File.dirname(__FILE__) + '/app/freemarker_template_engine'
16
+ require File.dirname(__FILE__) + '/app/jsp_template_engine'
17
+ require File.dirname(__FILE__) + '/scaffold/attribute'
18
+ require File.dirname(__FILE__) + '/scaffold/scaffold_generator'
19
+ require File.dirname(__FILE__) + '/scaffold/base_scaffold'
20
+ require File.dirname(__FILE__) + '/scaffold/import_manager'
21
+ require File.dirname(__FILE__) + '/scaffold/model_generator/model_generator'
22
+ require File.dirname(__FILE__) + '/scaffold/model_generator/objectify_model_generator'
23
+ require File.dirname(__FILE__) + '/scaffold/repository_generator/repository_generator'
24
+ require File.dirname(__FILE__) + '/scaffold/repository_generator/objectify_repository_generator'
25
+ require File.dirname(__FILE__) + '/scaffold/controller_generator/controller_generator'
26
+ require File.dirname(__FILE__) + '/scaffold/template_engine_generator/template_engine_generator'
@@ -22,11 +22,17 @@ class Attribute
22
22
  java = type.capitalize
23
23
  java = "boolean" if boolean?
24
24
  java = "String" if type.eql?("text")
25
+ java = "Date" if type.eql?("date")
26
+ java = name.camelize if type.eql?("references")
25
27
  java
26
28
  end
27
29
 
30
+ def import
31
+ ImportManager.new(type).package
32
+ end
33
+
28
34
  def self.valid_types
29
- %w(boolean double float short integer long string text)
35
+ %w(boolean double float short integer long string text date references)
30
36
  end
31
37
 
32
38
  def boolean?
@@ -37,10 +37,28 @@ class BaseScaffold < VraptorScaffold::Base
37
37
  def controller_test_class_name
38
38
  "#{controller_class_name}Test"
39
39
  end
40
+
41
+ def controller_test_param
42
+ params = ""
43
+ @attributes.each do |att|
44
+ params += ", null" if att.type.eql?("references")
45
+ end
46
+ params
47
+ end
40
48
 
41
49
  def base_path
42
50
  model_parameter_name.pluralize
43
51
  end
52
+
53
+ def imports
54
+ imports = []
55
+ @attributes.each do |attribute|
56
+ attribute.import.each do |import|
57
+ imports << import unless imports.include?(import)
58
+ end
59
+ end
60
+ imports
61
+ end
44
62
 
45
63
  protected
46
64
  def define_source_paths
@@ -4,6 +4,11 @@ import java.util.List;
4
4
 
5
5
  import <%= Configuration.full_models_package %>.<%= class_name %>;
6
6
  import <%= Configuration.package %>.<%= Configuration.repositories_package %>.<%= repository_interface_name %>;
7
+ <%- @attributes.each do |att| -%>
8
+ <%- if att.type.eql?("references") -%>
9
+ import <%= Configuration.package %>.repositories.<%= att.name.camelize %>Repository;
10
+ <%- end -%>
11
+ <%- end -%>
7
12
  import br.com.caelum.vraptor.Delete;
8
13
  import br.com.caelum.vraptor.Get;
9
14
  import br.com.caelum.vraptor.Post;
@@ -17,11 +22,21 @@ public class <%= controller_class_name %> {
17
22
 
18
23
  private final Result result;
19
24
  private final <%= repository_interface_name %> repository;
25
+ <%- @attributes.each do |att| -%>
26
+ <%- if att.type.eql?("references") -%>
27
+ private final <%= att.name.camelize %>Repository <%= att.name %>Repository;
28
+ <%- end -%>
29
+ <%- end -%>
20
30
  private final Validator validator;
21
31
 
22
- <%= controller_class_name %>(Result result, <%= repository_interface_name %> repository, Validator validator) {
32
+ public <%= controller_class_name %>(Result result, <%= repository_interface_name %> repository,
33
+ <% @attributes.each do |att| -%>
34
+ <%- if att.type.eql?("references") -%><%= att.name.camelize %>Repository <%= att.name %>Repository, <%- end -%><% end -%>Validator validator) {
23
35
  this.result = result;
24
36
  this.repository = repository;
37
+ <%- @attributes.each do |att| -%>
38
+ <%- if att.type.eql?("references") -%>
39
+ this.<%= att.name %>Repository = <%= att.name %>Repository;<%- end -%><%- end -%>
25
40
  this.validator = validator;
26
41
  }
27
42
 
@@ -40,6 +55,11 @@ public class <%= controller_class_name %> {
40
55
 
41
56
  @Get("<%= "#{path}/new" %>")
42
57
  public <%= class_name %> new<%= class_name %>() {
58
+ <%- @attributes.each do |att| -%>
59
+ <%- if att.type.eql?("references") -%>
60
+ result.include("<%=att.name%>List", <%= att.name %>Repository.findAll());
61
+ <%- end -%>
62
+ <%- end -%>
43
63
  return new <%= class_name %>();
44
64
  }
45
65
 
@@ -53,6 +73,11 @@ public class <%= controller_class_name %> {
53
73
 
54
74
  @Get("<%= "#{path}/{#{model_parameter_name}.id}/edit" %>")
55
75
  public <%= class_name %> edit(<%= class_name %> <%= model_parameter_name %>) {
76
+ <%- @attributes.each do |att| -%>
77
+ <%- if att.type.eql?("references") -%>
78
+ result.include("<%=att.name%>List", <%= att.name %>Repository.findAll());
79
+ <%- end -%>
80
+ <%- end -%>
56
81
  return repository.find(<%= model_parameter_name %>.getId());
57
82
  }
58
83
 
@@ -7,6 +7,6 @@ import org.junit.Test;
7
7
  public class <%= controller_test_class_name %> {
8
8
 
9
9
  @Test public void fakeTest() {
10
- assertNotNull("put something real.", new <%= controller_class_name %>(null, null, null));
10
+ assertNotNull("put something real.", new <%= controller_class_name %>(null, null, null<%=controller_test_param%>));
11
11
  }
12
12
  }
@@ -0,0 +1,20 @@
1
+ class ImportManager
2
+
3
+ attr_accessor :type
4
+
5
+ def initialize(type)
6
+ @type = type
7
+ packages
8
+ end
9
+
10
+ def package
11
+ packages[type.to_sym] or []
12
+ end
13
+
14
+ def packages
15
+ {
16
+ :date => ["java.util.Date"],
17
+ }
18
+ end
19
+
20
+ end
@@ -1,20 +1,23 @@
1
1
  package <%= Configuration.full_models_package %>;
2
2
 
3
+ <% imports.each do |import| -%>
4
+ import <%= import %>;
5
+ <% end -%>
3
6
  @javax.persistence.Entity
4
7
  public class <%= class_name %> extends Entity {
5
-
8
+
6
9
  <% @attributes.each do |att| -%>
7
10
  private <%= att.java_type %> <%= att.name %>;
8
11
  <% end -%>
9
-
12
+
10
13
  <% @attributes.each do |att| -%>
11
14
  public void set<%= att.name.camelize %>(<%= att.java_type %> <%= att.name %>) {
12
15
  this.<%= att.name %> = <%= att.name %>;
13
16
  }
14
-
17
+
15
18
  public <%= att.java_type %> <%= att.getter_prefix + att.name.camelize %>() {
16
19
  return <%= att.name %>;
17
20
  }
18
-
21
+
19
22
  <% end -%>
20
23
  }
@@ -11,7 +11,7 @@ public class <%= class_name %> {
11
11
  <% @attributes.each do |att| -%>
12
12
  private <%= att.java_type %> <%= att.name %>;
13
13
  <% end -%>
14
-
14
+
15
15
  public void setId(Long id) {
16
16
  this.id = id;
17
17
  }
@@ -24,10 +24,10 @@ public class <%= class_name %> {
24
24
  public void set<%= att.name.camelize %>(<%= att.java_type %> <%= att.name %>) {
25
25
  this.<%= att.name %> = <%= att.name %>;
26
26
  }
27
-
27
+
28
28
  public <%= att.java_type %> <%= att.getter_prefix + att.name.camelize %>() {
29
29
  return <%= att.name %>;
30
30
  }
31
-
31
+
32
32
  <% end -%>
33
33
  }
@@ -14,7 +14,15 @@
14
14
  <% @attributes.each do |att| -%>
15
15
  <div class="field">
16
16
  <%= att.html_label %>:<br />
17
+ <%- if att.type.eql?("references") -%>
18
+ <select name="<%= model_parameter_name %>.<%=att.name%>.id">
19
+ <#list <%=att.name%>List as <%=att.name%>>
20
+ <option value="${<%=att.name%>.id}" <#if <%= model_parameter_name %>.<%=att.name%>?? && <%= model_parameter_name %>.<%=att.name%>.id <%= "== #{att.name}"%>.id>selected="true"</#if> >${<%=att.name%>.id}</option>
21
+ </#list>
22
+ </select>
23
+ <%- else -%>
17
24
  <%= "<@html.#{att.html_input} \"#{model_parameter_name}.#{att.name}\" #{model_parameter_name}.#{att.name}/>" %>
25
+ <%- end -%>
18
26
  </div>
19
27
  <% end -%>
20
28
  <div class="actions">
@@ -14,12 +14,22 @@
14
14
  <% @attributes.each do |att| -%>
15
15
  <div class="field">
16
16
  <%= att.html_label %>:<br />
17
+ <%- if att.type.eql?("references") -%>
18
+ <select name="<%= model_parameter_name %>.<%=att.name%>.id">
19
+ <c:forEach var="<%=att.name%>" items="${<%=att.name%>List}">
20
+ <option value="${<%=att.name%>.id}" <c:if test = "${<%= model_parameter_name %>.<%=att.name%>.id == <%=att.name%>.id}">selected="true"</c:if>>
21
+ ${<%=att.name%>.id}
22
+ </option>
23
+ </c:forEach>
24
+ </select>
25
+ <%- else -%>
17
26
  <input type="text" name="<%= model_parameter_name %>.<%=att.name%>" value="${<%=model_parameter_name%>.<%=att.name%>}"/>
27
+ <%- end -%>
18
28
  </div>
29
+
19
30
  <% end -%>
20
-
21
- <div class="actions">
22
- <button type="submit">send</button>
31
+ <div class="actions">
32
+ <button type="submit">send</button>
23
33
  </div>
24
34
  </form>
25
35
 
@@ -5,12 +5,12 @@ require File.dirname(__FILE__) + '/generators/app/dependency'
5
5
  require File.dirname(__FILE__) + '/generators/app/dependency_manager'
6
6
  require File.dirname(__FILE__) + '/generators/app/freemarker_template_engine'
7
7
  require File.dirname(__FILE__) + '/generators/app/jsp_template_engine'
8
+ require File.dirname(__FILE__) + '/generators/scaffold/import_manager'
9
+ require File.dirname(__FILE__) + '/generators/scaffold/annotation_manager'
8
10
  require File.dirname(__FILE__) + '/generators/scaffold/attribute'
9
11
  require File.dirname(__FILE__) + '/generators/scaffold/scaffold_generator'
10
12
  require File.dirname(__FILE__) + '/generators/scaffold/base_scaffold'
11
13
  require File.dirname(__FILE__) + '/generators/scaffold/model_generator/model_generator'
12
- require File.dirname(__FILE__) + '/generators/scaffold/model_generator/objectify_model_generator'
13
14
  require File.dirname(__FILE__) + '/generators/scaffold/repository_generator/repository_generator'
14
- require File.dirname(__FILE__) + '/generators/scaffold/repository_generator/objectify_repository_generator'
15
15
  require File.dirname(__FILE__) + '/generators/scaffold/controller_generator/controller_generator'
16
- require File.dirname(__FILE__) + '/generators/scaffold/template_engine_generator/template_engine_generator'
16
+ require File.dirname(__FILE__) + '/generators/scaffold/template_engine_generator/template_engine_generator'
@@ -1,15 +1,25 @@
1
1
  module VraptorScaffold
2
2
  module Runner
3
3
 
4
+
4
5
  class Generator
5
6
  def run(args)
6
7
  project_path = args.shift
7
8
  if VraptorScaffold::Runner::Help.help? project_path
8
9
  AppGenerator.start(["-h"])
9
10
  else
10
- AppGenerator.new(project_path, args).invoke_all
11
+ app_generators_available = {"default" => AppGenerator, "gae" => GaeAppGenerator }
12
+
13
+ app_generator_selected = "default"
14
+ app_generator_selected = "gae" if gae_project? args
15
+ app_generators_available.fetch(app_generator_selected).new(project_path, args).invoke_all
11
16
  end
12
17
  end
18
+
19
+ private
20
+ def gae_project?(args)
21
+ !args.grep(/--gae/).empty?
22
+ end
13
23
  end
14
24
  end
15
25
  end
@@ -4,7 +4,7 @@ module VraptorScaffold
4
4
  class Start
5
5
  def run(args)
6
6
  validate
7
- Kernel.system("ant compile")
7
+ Kernel.system("ant vraptor-scanning")
8
8
  Kernel.system("sh $APPENGINE_SDK_HOME/bin/dev_appserver.sh #{Configuration::WEB_APP}")
9
9
  end
10
10
 
@@ -1,3 +1,3 @@
1
1
  module VraptorScaffold
2
- VERSION = "1.3.0.rc"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -6,7 +6,8 @@ require 'spec/autorun'
6
6
  require File.dirname(__FILE__) + '/../lib/vraptor-scaffold'
7
7
 
8
8
  def build_attributes
9
- [Attribute.new("name", "string"), Attribute.new("myFlag", "boolean")]
9
+ [Attribute.new("name", "string"), Attribute.new("myFlag", "boolean"),
10
+ Attribute.new("price", "double"), Attribute.new("category", "references")]
10
11
  end
11
12
 
12
13
  def mock_config_file
@@ -24,3 +25,10 @@ def exists_and_identical?(source, created)
24
25
  c2 = File.open(source).read.gsub( /\r/m, "" )
25
26
  c.should be == c2
26
27
  end
28
+
29
+ def mock_http_request
30
+ http_request = mock(Net::HTTP)
31
+ http_request.stub!(:get).with(kind_of(String)).and_return(http_request)
32
+ http_request.stub!(:body).and_return("corpo :)")
33
+ VraptorScaffold::HttpRequest.stub!(:open_session).with(kind_of(String)).and_return(http_request)
34
+ end
@@ -5,7 +5,7 @@ describe AppGenerator do
5
5
  context "build new application" do
6
6
  before(:all) do
7
7
  @project_path = "src/vraptor-scaffold"
8
- AppGenerator.new(@project_path, ["-b=mvn", "-r=repository", "-m=domain", "-c=control"]).invoke_all
8
+ AppGenerator.new(@project_path, ["-b=mvn", "-r=repository", "-m=domain", "-c=control", "--skip_jquery"]).invoke_all
9
9
  end
10
10
 
11
11
  after(:all) do
@@ -18,7 +18,7 @@ describe AppGenerator do
18
18
 
19
19
  it "should be invalid when project name already exist" do
20
20
  Kernel.should_receive(:exit)
21
- AppGenerator.new(@project_path)
21
+ AppGenerator.new(@project_path, ["--skip_jquery"])
22
22
  end
23
23
 
24
24
  it "should create pom" do
@@ -91,7 +91,7 @@ describe AppGenerator do
91
91
  @project_path = "src/vraptor-scaffold-hibernate"
92
92
  @main_resources = "#{@project_path}/#{Configuration::MAIN_RESOURCES}"
93
93
  @meta_inf = "#{@main_resources}/META-INF"
94
- AppGenerator.new(@project_path, ["--orm=hibernate"]).invoke_all
94
+ AppGenerator.new(@project_path, ["--orm=hibernate", "--skip_jquery"]).invoke_all
95
95
  end
96
96
 
97
97
  after(:all) do
@@ -182,11 +182,6 @@ describe AppGenerator do
182
182
  exists_and_identical?(source, destination)
183
183
  end
184
184
 
185
- it "should create jquery js" do
186
- destination = "#{@webapp}/javascripts/jquery.min.js"
187
- File.exists?(destination).should be_true
188
- end
189
-
190
185
  it "should create application js" do
191
186
  destination = "#{@webapp}/javascripts/application.js"
192
187
  File.exists?(destination).should be_true
@@ -234,7 +229,7 @@ describe AppGenerator do
234
229
 
235
230
  before(:all) do
236
231
  @project_path = "src/vraptor-scaffold"
237
- AppGenerator.new(@project_path, ["-p=br.com.caelum"]).invoke_all
232
+ AppGenerator.new(@project_path, ["-p=br.com.caelum", "--skip_jquery"]).invoke_all
238
233
  @main_java = "#{@project_path}/#{Configuration::MAIN_SRC}/br/com/caelum"
239
234
  @test_java = "#{@project_path}/#{Configuration::TEST_SRC}/br/com/caelum"
240
235
  end
@@ -265,16 +260,16 @@ describe AppGenerator do
265
260
 
266
261
  it "should configure freemarker template engine" do
267
262
  template = mock(FreemarkerTemplateEngine)
268
- FreemarkerTemplateEngine.stub!(:new).with(@project_path).and_return(template)
263
+ FreemarkerTemplateEngine.stub!(:new).with(@project_path, anything()).and_return(template)
269
264
  template.should_receive(:configure)
270
- AppGenerator.new(@project_path, ["--template-engine=ftl"]).invoke_all
265
+ AppGenerator.new(@project_path, ["--template-engine=ftl", "--skip_jquery"]).invoke_all
271
266
  end
272
267
 
273
268
  it "should configure jsp template engine" do
274
269
  template = mock(JspTemplateEngine)
275
- JspTemplateEngine.stub!(:new).with(@project_path).and_return(template)
270
+ JspTemplateEngine.stub!(:new).with(@project_path, anything()).and_return(template)
276
271
  template.should_receive(:configure)
277
- AppGenerator.new(@project_path).invoke_all
272
+ AppGenerator.new(@project_path, ["--skip_jquery"]).invoke_all
278
273
  end
279
274
  end
280
275
 
@@ -282,7 +277,7 @@ describe AppGenerator do
282
277
 
283
278
  before(:all) do
284
279
  @project_path = "vraptor-scaffold"
285
- AppGenerator.new(@project_path, ["-b=ant"]).invoke_all
280
+ AppGenerator.new(@project_path, ["-b=ant", "--skip_jquery"]).invoke_all
286
281
  end
287
282
 
288
283
  after(:all) do
@@ -341,7 +336,7 @@ describe AppGenerator do
341
336
  context "skip eclipse configuration files" do
342
337
  before(:all) do
343
338
  @project_path = "vraptor-scaffold"
344
- AppGenerator.new(@project_path, ["--skip-eclipse"]).invoke_all
339
+ AppGenerator.new(@project_path, ["--skip-eclipse", "--skip_jquery"]).invoke_all
345
340
  end
346
341
 
347
342
  after(:all) do
@@ -353,11 +348,43 @@ describe AppGenerator do
353
348
  end
354
349
  end
355
350
 
351
+ context "no skip jquery download file" do
352
+ before(:all) do
353
+ @project_path = "vraptor-scaffold"
354
+
355
+ mock_http_request()
356
+
357
+ AppGenerator.new(@project_path).invoke_all
358
+ end
359
+
360
+ after(:all) do
361
+ FileUtils.remove_dir(@project_path)
362
+ end
363
+
364
+ it "should exist jquery.min.js file" do
365
+ javascripts = File.join @project_path, Configuration::WEB_APP, "javascripts", "jquery.min.js"
366
+ File.exist?(javascripts).should be_true
367
+ end
368
+
369
+ it "should show a message for http problems" do
370
+ http_request = mock(Net::HTTP)
371
+ http_request.stub!(:get).with(kind_of(String)).and_throw(Net::HTTPError)
372
+ VraptorScaffold::HttpRequest.stub!(:open_session).with(kind_of(String)).and_return(http_request)
373
+
374
+ Kernel.should_receive(:puts).with("Was not possible to download jQuery.")
375
+
376
+ local_project_path = "project_without_jquery_by_http_error"
377
+ AppGenerator.new(local_project_path).invoke_all
378
+
379
+ FileUtils.remove_dir(local_project_path)
380
+ end
381
+ end
382
+
356
383
  context "configuring gradle application" do
357
384
 
358
385
  before(:all) do
359
386
  @project_path = "vraptor-scaffold"
360
- AppGenerator.new(@project_path, ["-b=gradle"]).invoke_all
387
+ AppGenerator.new(@project_path, ["-b=gradle", "--skip_jquery"]).invoke_all
361
388
  end
362
389
 
363
390
  after(:all) do
@@ -424,34 +451,25 @@ describe AppGenerator do
424
451
 
425
452
  it "should be invalid when build tool is not supported" do
426
453
  Kernel.should_receive(:exit)
427
- AppGenerator.new(@project_path, ["-b=maven"])
454
+ AppGenerator.new(@project_path, ["-b=maven", "--skip_jquery"])
428
455
  end
429
456
 
430
457
  it "should be invalid when template engine is not supported" do
431
458
  Kernel.should_receive(:exit)
432
- AppGenerator.new(@project_path, ["-e=velocity"])
459
+ AppGenerator.new(@project_path, ["-e=velocity", "--skip_jquery"])
433
460
  end
434
461
 
435
462
  it "should be invalid when orm mapping is not supported" do
436
463
  Kernel.should_receive(:exit)
437
- AppGenerator.new(@project_path, ["-o=toplink"])
438
- end
439
-
440
- it "should be invalid when jquery version does not exist" do
441
- Kernel.should_receive(:exit)
442
- AppGenerator.new(@project_path, ["-j=1.x"])
464
+ AppGenerator.new(@project_path, ["-o=toplink", "--skip_jquery"])
443
465
  end
444
466
 
445
- it "should be invalid when gae and heroku are selected" do
446
- Kernel.should_receive(:exit)
447
- AppGenerator.new(@project_path, ["-g", "-h"])
448
- end
449
467
  end
450
468
 
451
469
  context "heroku app" do
452
470
  before(:all) do
453
471
  @project_path = "heroku"
454
- AppGenerator.new(@project_path, ["--heroku"]).invoke_all
472
+ AppGenerator.new(@project_path, ["--heroku", "--skip_jquery"]).invoke_all
455
473
  end
456
474
 
457
475
  after(:all) do
@@ -473,74 +491,4 @@ describe AppGenerator do
473
491
  end
474
492
  end
475
493
 
476
- context "gae app" do
477
- before(:all) do
478
- @project_path = "gae"
479
- AppGenerator.new(@project_path, ["--gae"]).invoke_all
480
- @main_java = "#{@project_path}/#{Configuration::MAIN_SRC}"
481
- @app = "#{@main_java}/app"
482
- end
483
-
484
- after(:all) do
485
- FileUtils.remove_dir(@project_path)
486
- end
487
-
488
- it "should create ivy.xml" do
489
- source = File.join File.dirname(__FILE__), "templates", "ivy-gae.xml"
490
- destination = "#{@project_path}/ivy.xml"
491
- exists_and_identical?(source, destination)
492
- end
493
-
494
- it "should create ivysettings.xml" do
495
- File.exist?("#{@project_path}/ivysettings.xml").should be_true
496
- end
497
-
498
- it "should not create generic entity" do
499
- File.exist?("#{@app}/model/Entity.java").should be_false
500
- end
501
-
502
- it "should create appengine-web xml to run gae apps" do
503
- File.exist?("#{@project_path}/#{Configuration::WEB_INF}/appengine-web.xml").should be_true
504
- end
505
-
506
- it "should create logging properties for gae apps" do
507
- File.exist?("#{@project_path}/#{Configuration::WEB_INF}/logging.properties").should be_true
508
- end
509
-
510
- it "should create web.xml" do
511
- source = File.join File.dirname(__FILE__), "templates", "gae-jsp-web.xml"
512
- destination = "#{@project_path}/#{Configuration::WEB_INF}/web.xml"
513
- exists_and_identical?(source, destination)
514
- end
515
-
516
- it "should generate a objectify repository" do
517
- source = File.join File.dirname(__FILE__), "templates", "RepositoryObjectify.java"
518
- destination = "#{@project_path}/#{Configuration::MAIN_SRC}/app/repositories/Repository.java"
519
- exists_and_identical?(source, destination)
520
- end
521
-
522
- it "should generate a objectify resource factory" do
523
- source = File.join File.dirname(__FILE__), "templates", "ObjectifyFactory.java"
524
- destination = "#{@project_path}/#{Configuration::MAIN_SRC}/app/infra/ObjectifyFactory.java"
525
- exists_and_identical?(source, destination)
526
- end
527
-
528
- it "should create a specific .classpath for gae" do
529
- source = File.join File.dirname(__FILE__), "templates", "classpath-gae"
530
- destination = "#{@project_path}/.classpath"
531
- exists_and_identical?(source, destination)
532
- end
533
-
534
- it "should create a specific .project for gae" do
535
- source = File.join File.dirname(__FILE__), "templates", "project-gae"
536
- destination = "#{@project_path}/.project"
537
- exists_and_identical?(source, destination)
538
- end
539
-
540
- it "should create .settings" do
541
- settings = File.join @project_path, ".settings"
542
- File.exist?(settings).should be_true
543
- end
544
- end
545
-
546
494
  end