spring-gen 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +2 -0
  4. data/lib/commands/resource.rb +74 -91
  5. data/lib/commands/service.rb +9 -9
  6. data/lib/configurations/mongodb_configuration.rb +6 -0
  7. data/lib/configurations/neo4j_configuration.rb +6 -0
  8. data/lib/generators/generator.rb +43 -0
  9. data/lib/templates/{layout/.gitignore → .gitignore} +0 -0
  10. data/lib/templates/{layout/config → config}/checkstyle/checkstyle.xml +0 -0
  11. data/lib/templates/{layout/build.gradle.erb → gradle/jpa_build.gradle.erb} +3 -11
  12. data/lib/templates/gradle/mongodb_build.gradle.erb +85 -0
  13. data/lib/templates/gradle/neo4j_build.gradle.erb +80 -0
  14. data/lib/templates/{licence.erb → project/licence.erb} +0 -0
  15. data/lib/templates/{service.yml.erb → project/service.yml.erb} +0 -0
  16. data/lib/templates/{resource → src/main/java}/assembler/Assembler.java.erb +0 -0
  17. data/lib/templates/{resource → src/main/java}/assembler/BaseAssembler.java.erb +0 -0
  18. data/lib/templates/{layout/src → src/main}/java/config/AppConfig.java.erb +0 -0
  19. data/lib/templates/{resource → src/main/java}/controller/BaseController.java.erb +0 -0
  20. data/lib/templates/{resource → src/main/java}/controller/Controller.java.erb +0 -0
  21. data/lib/templates/{layout/src → src/main}/java/main/App.java.erb +0 -0
  22. data/lib/templates/{resource/model → src/main/java/model/jpa}/JpaBaseEntity.java.erb +0 -0
  23. data/lib/templates/src/main/java/model/jpa/JpaModel.java.erb +38 -0
  24. data/lib/templates/src/main/java/model/jpa/JpaUser.java.erb +92 -0
  25. data/lib/templates/{resource/model → src/main/java/model/mongodb}/MongodbBaseEntity.java.erb +0 -0
  26. data/lib/templates/src/main/java/model/mongodb/MongodbModel.java.erb +38 -0
  27. data/lib/templates/src/main/java/model/mongodb/MongodbUser.java.erb +90 -0
  28. data/lib/templates/{resource/model → src/main/java/model/neo4j}/Neo4jBaseEntity.java.erb +0 -0
  29. data/lib/templates/{resource/model/Model.java.erb → src/main/java/model/neo4j/Neo4jModel.java.erb} +0 -0
  30. data/lib/templates/src/main/java/repository/jpa/JpaRepository.java.erb +16 -0
  31. data/lib/templates/src/main/java/repository/mongodb/MongodbRepository.java.erb +16 -0
  32. data/lib/templates/{resource/repository/Repository.java.erb → src/main/java/repository/neo4j/Neo4jRepository.java.erb} +0 -1
  33. data/lib/templates/{resource → src/main/java}/resource/Resource.java.erb +0 -0
  34. data/lib/templates/src/main/java/service/UserService.java.erb +25 -0
  35. data/lib/templates/{layout/src → src/main}/resources/application.yml.erb +0 -0
  36. data/lib/templates/{layout/src → src/main}/resources/bootstrap.yml.erb +0 -0
  37. data/lib/templates/{resource/test → src/test/java}/TestUtil.java.erb +0 -0
  38. data/lib/templates/{resource/test/integration/neo4j → src/test/java/integration/jpa}/IntegrationTest.java.erb +0 -0
  39. data/lib/templates/{resource/test → src/test/java}/integration/jpa/IntegrationTestConfig.java.erb +0 -0
  40. data/lib/templates/{resource/test → src/test/java}/integration/jpa/sampleData.xml.erb +0 -0
  41. data/lib/templates/{resource/test → src/test/java}/integration/mongodb/IntegrationTest.java.erb +0 -0
  42. data/lib/templates/{resource/test → src/test/java}/integration/mongodb/IntegrationTestConfig.java.erb +0 -0
  43. data/lib/templates/{resource/test → src/test/java}/integration/mongodb/SampleData.java.erb +0 -0
  44. data/lib/templates/{resource/test/integration/jpa → src/test/java/integration/neo4j}/IntegrationTest.java.erb +1 -1
  45. data/lib/templates/{resource/test → src/test/java}/integration/neo4j/IntegrationTestConfig.java.erb +0 -0
  46. data/lib/templates/{resource/test → src/test/java}/integration/neo4j/SampleData.java.erb +0 -0
  47. data/lib/templates/{resource/test → src/test/java}/unit/assembler/AssemblerUnitTest.java.erb +0 -0
  48. data/lib/templates/{resource/test → src/test/java}/unit/assembler/AssemblerUnitTestConfig.java.erb +0 -0
  49. data/lib/templates/{resource/test → src/test/java}/unit/controller/ControllerUnitTest.java.erb +0 -0
  50. data/lib/templates/{resource/test → src/test/java}/unit/controller/ControllerUnitTestConfig.java.erb +0 -0
  51. data/lib/version.rb +1 -1
  52. data/spring-gen.gemspec +1 -0
  53. metadata +61 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2aa721f79a259cc82e704a84b38ab7b0d0aa2dfd
4
- data.tar.gz: 7b287bf95c59fba0a9403b47a8d23a22a248153e
3
+ metadata.gz: 09f568bcce438f10eadb24b9f744caa7ce7ea192
4
+ data.tar.gz: d896cec36aded99c24308a588ac1cae35cb44b09
5
5
  SHA512:
6
- metadata.gz: 6b910e283146d2614f918eb7543fbb3b361076fb3b58fd2014623e5889a5a660c3c882d225f13b17b3ce9967885c5593cdcd51203e4602b78b46f4910b92a2d8
7
- data.tar.gz: aed13e5b334e63719ddbf3d7bb526da79d84ee1212fab7434bcc620da095c00835672d0bc50b426591032d81298ccdfa643a33fc89e78f4538036c369ba0b574
6
+ metadata.gz: d5da0583538330ea77db8864df58a2017ca252595fce7ce30f96360222ff08dee2d4c34c5cb0440e10e61e3f0dfee27079ee361cf6e52c25821da5db8c8bd097
7
+ data.tar.gz: d37f257a8efc153ee39a5448ca2e8d4286dfb6d6aab80eba5b156e86ee6ea8bd718e969bbc6f6a5d38edd3c23e6e9de0daa361a3bb693fe4ffa279c3d1c041ef
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  /test/livetest/*
11
11
  .idea/
12
+ test.rb
data/Gemfile CHANGED
@@ -6,4 +6,6 @@ gem "thor"
6
6
 
7
7
  gem 'git'
8
8
 
9
+ gem 'activesupport', '~> 4.2.1'
10
+
9
11
  gemspec
@@ -1,6 +1,9 @@
1
- require 'thor'
2
1
  require 'thor/group'
3
2
  require 'util'
3
+ #require_relative '../../lib/generators/generator'
4
+ require 'active_support/core_ext/string/inflections'
5
+
6
+
4
7
 
5
8
  Attribute = Struct.new(:name,:data_type)
6
9
  class Resource < Thor::Group
@@ -19,112 +22,92 @@ class Resource < Thor::Group
19
22
  :aliases => 'f',
20
23
  :default => false
21
24
 
25
+ def prepare_attributes
26
+ @attributes = @attributes.map{|k,v| Attribute.new k,v}
27
+ end
28
+
22
29
  def self.source_root
23
30
  File.expand_path('../',__dir__)
24
31
  end
25
32
 
26
- def prepare_attributes
27
- @attributes = @attributes.map{|k,v| Attribute.new k,v}
28
- end
33
+
29
34
 
30
35
  def create_model
36
+ @licence = licence
31
37
  @user_name = user_name
32
- @user_email = user_email
33
38
  @package = config.group_id.split('.').each {|part| part.gsub!(/\W/,'')}.join('.')
34
39
  fs_path = @package.gsub('.','/')
35
- @artifact_id = config.artifact_id
36
- @full = options['full']
37
- @licence = licence
38
-
39
-
40
- case config.repository_technique
41
- when 'jpa'
42
- @repository_import = 'jpa.repository.JpaRepository'
43
- @repository_type = "JpaRepository<#{@model_name},Long>"
44
- @entity_annotation = "@Entity"
45
- @annotation_import = "import javax.persistence.Entity;"
46
- template "templates/resource/test/integration/#{config.repository_technique}/sampleData.xml.erb",
47
- "#{content_root}/src/test/resources/sampledata/#{@model_name.downcase}SampleData.xml"
48
- when "mongodb"
49
- @repository_import = "mongodb.repository.MongoRepository"
50
- @repository_type = "MongoRepository<#{@model_name},String>"
51
- @annotation_import = 'import org.springframework.data.mongodb.core.mapping.Document;'
52
- @entity_annotation = "@Document"
53
- template "templates/resource/test/integration/#{config.repository_technique}/SampleData.java.erb",
54
- "#{content_root}/src/test/java/#{fs_path}/integration/#{@model_name.downcase}/#{@model_name}SampleData.java"
55
- when "neo4j"
56
- @repository_import = "neo4j.repository.GraphRepository"
57
- @repository_type = "GraphRepository<#{@model_name}>"
58
- @entity_annotation = "@NodeEntity"
59
- template "templates/resource/test/integration/#{config.repository_technique}/SampleData.java.erb",
60
- "#{content_root}/src/test/java/#{fs_path}/integration/#{@model_name.downcase}/#{@model_name}SampleData.java"
61
- else
62
- raise ("not a suitable repository-technique.")
63
- end
64
-
65
-
66
- template "templates/resource/model/#{config.repository_technique.capitalize}BaseEntity.java.erb",
67
- "#{content_root}/src/main/java/#{fs_path}/model/BaseEntity.java" unless File.exist?("#{content_root}/src/main/java/#{fs_path}/model/BaseEntity.java")
68
- template(
69
- 'templates/resource/model/Model.java.erb',
70
- "#{content_root}/src/main/java/#{fs_path}/model/#{@model_name}.java")
71
-
72
- template(
73
- 'templates/resource/repository/Repository.java.erb',
74
- "#{content_root}/src/main/java/#{fs_path}/repository/#{@model_name}Repository.java")
75
-
76
- template(
77
- "templates/resource/test/integration/#{config.repository_technique}/IntegrationTestConfig.java.erb",
78
- "#{content_root}/src/test/java/#{fs_path}/integration/#{@model_name.downcase}/#{@model_name}IntegrationTestConfig.java")
79
40
 
41
+ @full = options['full']
42
+ template("templates/src/main/java/model/#{config.repository_technique}/#{config.repository_technique.capitalize}BaseEntity.java.erb",
43
+ "#{content_root}/src/main/java/#{fs_path}/model/BaseEntity.java") unless File.exist?("#{content_root}/src/main/java/#{fs_path}/model/BaseEntity.java")
80
44
  template(
81
- "templates/resource/test/integration/#{config.repository_technique}/IntegrationTest.java.erb",
82
- "#{content_root}/src/test/java/#{fs_path}/integration/#{@model_name.downcase}/#{@model_name}IntegrationTest.java")
45
+ "templates/src/main/java/model/#{config.repository_technique}/#{config.repository_technique.capitalize}Model.java.erb",
46
+ "#{content_root}/src/main/java/#{fs_path}/model/#{@model_name}.java")
83
47
 
48
+ template("templates/src/main/java/repository/#{config.repository_technique}/#{config.repository_technique.capitalize}Repository.java.erb",
49
+ "#{content_root}/src/main/java/#{fs_path}/repository/#{@model_name}Repository.java")
84
50
 
85
51
  template(
86
- 'templates/resource/test/TestUtil.java.erb',
87
- "#{content_root}/src/test/java/util/TestUtil.java") unless File.exist?("#{content_root}/src/test/java/util/TestUtil.java")
88
-
89
- if @full
90
-
91
- template(
92
- 'templates/resource/test/unit/controller/ControllerUnitTestConfig.java.erb',
93
- "#{content_root}/src/test/java/#{fs_path}/unit/#{@model_name.downcase}/controller/#{@model_name}ControllerUnitTestConfig.java")
94
-
95
- template(
96
- 'templates/resource/test/unit/controller/ControllerUnitTest.java.erb',
97
- "#{content_root}/src/test/java/#{fs_path}/unit/#{@model_name.downcase}/controller/#{@model_name}ControllerUnitTest.java")
98
-
99
- template(
100
- 'templates/resource/test/unit/assembler/AssemblerUnitTestConfig.java.erb',
101
- "#{content_root}/src/test/java/#{fs_path}/unit/#{@model_name.downcase}/assembler/#{@model_name}AssemblerUnitTestConfig.java")
102
-
103
- template(
104
- 'templates/resource/test/unit/assembler/AssemblerUnitTest.java.erb',
105
- "#{content_root}/src/test/java/#{fs_path}/unit/#{@model_name.downcase}/assembler/#{@model_name}AssemblerUnitTest.java")
106
-
107
-
108
- template 'templates/resource/controller/BaseController.java.erb',
109
- "#{content_root}/src/main/java/#{fs_path}/controller/BaseController.java" unless File.exist?("#{content_root}/src/main/java/#{fs_path}/controller/BaseController.java")
110
-
52
+ "templates/src/test/java/integration/#{config.repository_technique}/IntegrationTestConfig.java.erb",
53
+ "#{content_root}/src/test/java/#{fs_path}/integration/#{@model_name.downcase}/#{@model_name}IntegrationTestConfig.java")
111
54
  template(
112
- 'templates/resource/controller/Controller.java.erb',
113
- "#{content_root}/src/main/java/#{fs_path}/controller/#{@model_name}Controller.java")
114
-
115
- template 'templates/resource/assembler/BaseAssembler.java.erb',
116
- "#{content_root}/src/main/java/#{fs_path}/assembler/BaseAssembler.java" unless File.exist?("#{content_root}/src/main/java/#{fs_path}/assembler/BaseAssembler.java")
117
- template(
118
- 'templates/resource/assembler/Assembler.java.erb',
119
- "#{content_root}/src/main/java/#{fs_path}/assembler/#{@model_name}Assembler.java")
120
-
55
+ "templates/src/test/java/integration/#{config.repository_technique}/IntegrationTest.java.erb",
56
+ "#{content_root}/src/test/java/#{fs_path}/integration/#{@model_name.downcase}/#{@model_name}IntegrationTest.java")
121
57
  template(
122
- 'templates/resource/resource/Resource.java.erb',
123
- "#{content_root}/src/main/java/#{fs_path}/resource/#{@model_name}Resource.java")
124
-
125
- template 'templates/resource/exception/NotCreatedException.java.erb',
126
- "#{content_root}/src/main/java/#{fs_path}/exception/NotCreatedException.java" unless File.exist? "#{content_root}/src/main/java/#{fs_path}/exception/NotCreatedException.java"
127
-
58
+ 'templates/src/test/java/TestUtil.java.erb',
59
+ "#{content_root}/src/test/java/util/TestUtil.java") unless File.exist?("#{content_root}/src/test/java/util/TestUtil.java")
60
+
61
+ case config.repository_technique
62
+ when 'jpa'
63
+ #TODO unify sample data. This check should not need to exist.
64
+ template "templates/src/test/java/integration/#{config.repository_technique}/sampleData.xml.erb",
65
+ "#{content_root}/src/test/resources/sampledata/#{@model_name.downcase}SampleData.xml"
66
+ when "mongodb"
67
+ template "templates/src/test/java/integration/#{config.repository_technique}/SampleData.java.erb",
68
+ "#{content_root}/src/test/java/#{fs_path}/integration/#{@model_name.downcase}/#{@model_name}SampleData.java"
69
+ when "neo4j"
70
+ template "templates/src/test/java/integration/#{config.repository_technique}/SampleData.java.erb",
71
+ "#{content_root}/src/test/java/#{fs_path}/integration/#{@model_name.downcase}/#{@model_name}SampleData.java"
72
+ else
73
+ raise ("not a suitable repository-technique.")
74
+ end
75
+
76
+ if @full
77
+
78
+ template(
79
+ 'templates/src/test/java/unit/controller/ControllerUnitTestConfig.java.erb',
80
+ "#{content_root}/src/test/java/#{fs_path}/unit/#{@model_name.downcase}/controller/#{@model_name}ControllerUnitTestConfig.java")
81
+
82
+ template(
83
+ 'templates/src/test/java/unit/controller/ControllerUnitTest.java.erb',
84
+ "#{content_root}/src/test/java/#{fs_path}/unit/#{@model_name.downcase}/controller/#{@model_name}ControllerUnitTest.java")
85
+
86
+ template(
87
+ 'templates/src/test/java/unit/assembler/AssemblerUnitTestConfig.java.erb',
88
+ "#{content_root}/src/test/java/#{fs_path}/unit/#{@model_name.downcase}/assembler/#{@model_name}AssemblerUnitTestConfig.java")
89
+
90
+ template(
91
+ 'templates/src/test/java/unit/assembler/AssemblerUnitTest.java.erb',
92
+ "#{content_root}/src/test/java/#{fs_path}/unit/#{@model_name.downcase}/assembler/#{@model_name}AssemblerUnitTest.java")
93
+
94
+
95
+ template 'templates/src/main/java/controller/BaseController.java.erb',
96
+ "#{content_root}/src/main/java/#{fs_path}/controller/BaseController.java" unless File.exist?("#{content_root}/src/main/java/#{fs_path}/controller/BaseController.java")
97
+
98
+ template(
99
+ 'templates/src/main/java/controller/Controller.java.erb',
100
+ "#{content_root}/src/main/java/#{fs_path}/controller/#{@model_name}Controller.java")
101
+
102
+ template 'templates/src/main/java/assembler/BaseAssembler.java.erb',
103
+ "#{content_root}/src/main/java/#{fs_path}/assembler/BaseAssembler.java" unless File.exist?("#{content_root}/src/main/java/#{fs_path}/assembler/BaseAssembler.java")
104
+ template(
105
+ 'templates/src/main/java/assembler/Assembler.java.erb',
106
+ "#{content_root}/src/main/java/#{fs_path}/assembler/#{@model_name}Assembler.java")
107
+
108
+ template(
109
+ 'templates/src/main/java/resource/Resource.java.erb',
110
+ "#{content_root}/src/main/java/#{fs_path}/resource/#{@model_name}Resource.java")
128
111
  end
129
112
  end
130
113
 
@@ -30,10 +30,10 @@ class Service < Thor::Group
30
30
 
31
31
  def prepare_project
32
32
  @repository_technique = options['repository_technique'] || 'jpa'
33
- copy_file 'templates/licence.erb',"#{@name}/.spring-gen/licence.erb"
34
- template 'templates/service.yml.erb',"#{@name}/.spring-gen/service.yml"
35
- directory 'templates/layout/config',"#{@name}/config"
36
- copy_file 'templates/layout/.gitignore',"#{@name}/.gitignore"
33
+ copy_file 'templates/project/licence.erb',"#{@name}/.spring-gen/licence.erb"
34
+ template 'templates/project/service.yml.erb',"#{@name}/.spring-gen/service.yml"
35
+ directory 'templates/config',"#{@name}/config"
36
+ copy_file 'templates/.gitignore',"#{@name}/.gitignore"
37
37
  end
38
38
 
39
39
  def init_git
@@ -44,11 +44,11 @@ class Service < Thor::Group
44
44
 
45
45
  def add_sources
46
46
  Dir.chdir(@name) {@licence = licence}
47
- template 'templates/layout/src/java/main/App.java.erb',"#{@name}/src/main/java/#{@group_id.gsub(".","/")}/main/App.java"
48
- template 'templates/layout/src/java/config/AppConfig.java.erb',"#{@name}/src/main/java/#{@group_id.gsub(".","/")}/config/AppConfig.java"
49
- template 'templates/layout/src/resources/application.yml.erb',"#{@name}/src/main/resources/application.yml"
50
- template 'templates/layout/src/resources/bootstrap.yml.erb',"#{@name}/src/main/resources/bootstrap.yml"
51
- template 'templates/layout/build.gradle.erb',"#{@name}/build.gradle"
47
+ template 'templates/src/main/java/main/App.java.erb',"#{@name}/src/main/java/#{@group_id.gsub(".","/")}/main/App.java"
48
+ template 'templates/src/main/java/config/AppConfig.java.erb',"#{@name}/src/main/java/#{@group_id.gsub(".","/")}/config/AppConfig.java"
49
+ template 'templates/src/main/resources/application.yml.erb',"#{@name}/src/main/resources/application.yml"
50
+ template 'templates/src/main/resources/bootstrap.yml.erb',"#{@name}/src/main/resources/bootstrap.yml"
51
+ template "templates/gradle/#{@repository_technique}_build.gradle.erb","#{@name}/build.gradle"
52
52
 
53
53
  end
54
54
 
@@ -0,0 +1,6 @@
1
+ module MongodbConfiguration
2
+ REPOSITORY_IMPORT = "mongodb.repository.MongoRepository"
3
+ REPOSITORY_TYPE = "MongoRepository<#{@model_name},String>"
4
+ ANNOTATION_IMPORT = 'import org.springframework.data.mongodb.core.mapping.Document;'
5
+ ENTITY_ANNOTATION = "@Document"
6
+ end
@@ -0,0 +1,6 @@
1
+ module Neo4jConfiguration
2
+ #TODO complete...
3
+ REPOSITORY_IMPORT = "neo4j.repository.GraphRepository"
4
+ REPOSITORY_TYPE = "GraphRepository<#{@model_name}>"
5
+ ENTITY_ANNOTATION = "@NodeEntity"
6
+ end
@@ -0,0 +1,43 @@
1
+ require 'util'
2
+ require 'thor'
3
+ require 'thor/group'
4
+ require 'active_support/core_ext/string/inflections'
5
+
6
+ class Generator
7
+ include Util
8
+ include Thor::Actions
9
+
10
+
11
+
12
+
13
+
14
+ attr_accessor :licence,:user_name,:package,:fs_path,:model_name,:repository_import,:repository_type,:full
15
+
16
+
17
+ def initialize
18
+ @licence = licence
19
+ @user_name = user_name
20
+ @package = config.group_id.split('.').each {|part| part.gsub!(/\W/,'')}.join('.')
21
+ @fs_path = @package.gsub('.','/')
22
+ @repository_import = Generator.repository_configuration(config.repository_technique).const_get :REPOSITORY_IMPORT
23
+ @repository_type = Generator.repository_configuration(config.repository_technique).const_get :REPOSITORY_TYPE
24
+ @destination_stack = [self.class.source_root]
25
+ end
26
+
27
+ def self.source_root
28
+ File.expand_path('../',__dir__)
29
+ end
30
+
31
+ def generate(template,target)
32
+ puts "take the template #{template}"
33
+ puts "and put it here: #{target}"
34
+ template(template,target)
35
+ end
36
+
37
+ def self.for_model(model_name,options,&block)
38
+ instance = Generator.new
39
+ instance.model_name = model_name
40
+ instance.full = options['full']
41
+ block.call instance
42
+ end
43
+ end
File without changes
@@ -66,17 +66,9 @@ dependencies {
66
66
 
67
67
  compile 'org.apache.commons:commons-lang3:3.4'
68
68
 
69
- <%if @repository_technique == "jpa"%>
70
- compile 'com.h2database:h2:1.4.187'
71
- testCompile "org.dbunit:dbunit:2.5.0"
72
- testCompile "com.github.springtestdbunit:spring-test-dbunit:1.2.1"
73
- <%elsif @repository_technique == "mongodb"%>
74
- testCompile 'com.github.fakemongo:fongo:1.6.2'
75
- <%elsif @repository_technique == "neo4j"%>
76
-
77
- <%end%>
78
-
79
-
69
+ testCompile 'com.h2database:h2:1.4.187'
70
+ testCompile "org.dbunit:dbunit:2.5.0"
71
+ testCompile "com.github.springtestdbunit:spring-test-dbunit:1.2.1"
80
72
  testCompile "org.springframework:spring-test:4.1.6.RELEASE"
81
73
  testCompile "org.mockito:mockito-core:1.9.5"
82
74
  testCompile "org.hamcrest:hamcrest-all:1.3"
@@ -0,0 +1,85 @@
1
+ <%=@licence%>
2
+
3
+ buildscript {
4
+ repositories {
5
+ mavenCentral()
6
+ }
7
+ dependencies {
8
+ classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.3.RELEASE")
9
+ }
10
+ }
11
+
12
+ repositories {
13
+ mavenCentral()
14
+
15
+ maven {
16
+ url 'http://repo.spring.io/libs-snapshot-continuous-local'
17
+ }
18
+ maven {
19
+ url 'http://maven.springframework.org/milestone/'
20
+ }
21
+
22
+ maven {
23
+ url 'http://repo.spring.io/libs-snapshot'
24
+ }
25
+
26
+
27
+
28
+ }
29
+
30
+
31
+ apply plugin: 'java'
32
+ apply plugin: 'idea'
33
+ apply plugin: 'spring-boot'
34
+ apply plugin: "checkstyle"
35
+
36
+ checkstyle{
37
+ checkstyle {
38
+ toolVersion = "6.6"
39
+ }
40
+ }
41
+
42
+ task checkstyle(type: Checkstyle) {
43
+ configFile file("config/checkstyle/checkstyle.xml")
44
+ source './'
45
+ include '**/*.java'
46
+ classpath = files()
47
+ }
48
+
49
+
50
+
51
+ sourceCompatibility = 1.8
52
+ targetCompatibility = 1.8
53
+
54
+ dependencies {
55
+ compile("org.springframework.boot:spring-boot-starter-web")
56
+ compile("org.springframework.boot:spring-boot-starter-tomcat")
57
+ compile("org.springframework.boot:spring-boot-starter-data-rest")
58
+ compile("org.springframework.boot:spring-boot-starter-data-mongodb")
59
+
60
+
61
+ compile("org.springframework.amqp:spring-rabbit")
62
+
63
+ compile 'org.springframework.cloud:spring-cloud-starter-eureka:1.0.1.RELEASE'
64
+
65
+ compile 'org.springframework.hateoas:spring-hateoas'
66
+
67
+ compile 'org.apache.commons:commons-lang3:3.4'
68
+
69
+ testCompile 'com.github.fakemongo:fongo:1.6.2'
70
+
71
+
72
+
73
+ testCompile "org.springframework:spring-test:4.1.6.RELEASE"
74
+ testCompile "org.mockito:mockito-core:1.9.5"
75
+ testCompile "org.hamcrest:hamcrest-all:1.3"
76
+ testCompile "com.jayway.jsonpath:json-path-assert:2.0.0"
77
+ testCompile("junit:junit")
78
+
79
+
80
+
81
+ }
82
+
83
+ task wrapper(type: Wrapper) {
84
+ gradleVersion = '2.3'
85
+ }
@@ -0,0 +1,80 @@
1
+ <%=@licence%>
2
+
3
+ buildscript {
4
+ repositories {
5
+ mavenCentral()
6
+ }
7
+ dependencies {
8
+ classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.3.RELEASE")
9
+ }
10
+ }
11
+
12
+ repositories {
13
+ mavenCentral()
14
+
15
+ maven {
16
+ url 'http://repo.spring.io/libs-snapshot-continuous-local'
17
+ }
18
+ maven {
19
+ url 'http://maven.springframework.org/milestone/'
20
+ }
21
+
22
+ maven {
23
+ url 'http://repo.spring.io/libs-snapshot'
24
+ }
25
+
26
+
27
+
28
+ }
29
+
30
+
31
+ apply plugin: 'java'
32
+ apply plugin: 'idea'
33
+ apply plugin: 'spring-boot'
34
+ apply plugin: "checkstyle"
35
+
36
+ checkstyle{
37
+ checkstyle {
38
+ toolVersion = "6.6"
39
+ }
40
+ }
41
+
42
+ task checkstyle(type: Checkstyle) {
43
+ configFile file("config/checkstyle/checkstyle.xml")
44
+ source './'
45
+ include '**/*.java'
46
+ classpath = files()
47
+ }
48
+
49
+
50
+
51
+ sourceCompatibility = 1.8
52
+ targetCompatibility = 1.8
53
+
54
+ dependencies {
55
+ compile("org.springframework.boot:spring-boot-starter-web")
56
+ compile("org.springframework.boot:spring-boot-starter-tomcat")
57
+ compile("org.springframework.boot:spring-boot-starter-data-rest")
58
+ compile("org.springframework.boot:spring-boot-starter-data-jpa")
59
+
60
+
61
+ compile("org.springframework.amqp:spring-rabbit")
62
+
63
+ compile 'org.springframework.cloud:spring-cloud-starter-eureka:1.0.1.RELEASE'
64
+
65
+ compile 'org.springframework.hateoas:spring-hateoas'
66
+
67
+ compile 'org.apache.commons:commons-lang3:3.4'
68
+ testCcompile 'com.h2database:h2:1.4.187'
69
+ testCompile "org.dbunit:dbunit:2.5.0"
70
+ testCompile "com.github.springtestdbunit:spring-test-dbunit:1.2.1"
71
+ testCompile "org.springframework:spring-test:4.1.6.RELEASE"
72
+ testCompile "org.mockito:mockito-core:1.9.5"
73
+ testCompile "org.hamcrest:hamcrest-all:1.3"
74
+ testCompile "com.jayway.jsonpath:json-path-assert:2.0.0"
75
+ testCompile("junit:junit")
76
+ }
77
+
78
+ task wrapper(type: Wrapper) {
79
+ gradleVersion = '2.3'
80
+ }
File without changes
@@ -0,0 +1,38 @@
1
+ package <%=@package%>.model;
2
+
3
+ <%=@licence%>
4
+
5
+ import javax.persistence.Entity;
6
+
7
+ /**
8
+ * Entity that represents <%=@model_name%>s.
9
+ * @author <%=@user_name%>
10
+ */
11
+ @Entity
12
+ public class <%=@model_name%> extends BaseEntity {
13
+
14
+ <%@attributes.each do |attribute| %>private <%="#{attribute.data_type} #{attribute.name}"%>;
15
+ <%end%>
16
+
17
+ public <%=@model_name%>(){}
18
+
19
+
20
+ /**
21
+ * a convenience constructor.
22
+ */
23
+ public <%=@model_name%>(<%=@attributes.map {|attribute| "#{attribute.data_type} #{attribute.name}"}.join(',')%>) {
24
+
25
+ <%@attributes.each do |attribute|%>this.<%=attribute.name%> = <%=attribute.name%>;
26
+ <%end%>
27
+ }
28
+
29
+ <%@attributes.each do |attribute| %>
30
+ public void <%="set#{attribute.name.capitalize}(#{attribute.data_type} #{attribute.name})"%> {
31
+ this.<%=attribute.name%> = <%=attribute.name%>;
32
+ }
33
+
34
+ public <%="#{attribute.data_type} get#{attribute.name.capitalize}"%>() {
35
+ return this.<%=attribute.name%>;
36
+ }
37
+ <%end%>
38
+ }
@@ -0,0 +1,92 @@
1
+ package <%=@package%>.model;
2
+
3
+ import org.springframework.security.core.GrantedAuthority;
4
+ import org.springframework.security.core.userdetails.UserDetails;
5
+
6
+ import javax.persistence.Column;
7
+ import javax.persistence.Entity;
8
+ import java.util.Collection;
9
+
10
+ /**
11
+ * Entity that represents a single User in the application.
12
+ * @author <%@user_name%>
13
+ */
14
+ @Entity(name = "users")
15
+ public class User extends BaseEntity implements UserDetails {
16
+
17
+ @Column(nullable = false, unique = true)
18
+ private String email;
19
+
20
+ @Column(nullable = false)
21
+ private String password;
22
+
23
+ private boolean isAccountNonExpired;
24
+ private boolean isAccountNonLocked;
25
+ private boolean isCredentialsNonExpired;
26
+ private boolean isEnabled;
27
+
28
+ public User(String email, String password) {
29
+ this.email = email;
30
+ this.password = password;
31
+ this.isEnabled = true;
32
+ }
33
+
34
+ public User(){}
35
+
36
+ public Collection<? extends GrantedAuthority> getAuthorities() {
37
+ return null;
38
+ }
39
+
40
+ public String getEmail() {
41
+ return email;
42
+ }
43
+
44
+ public void setEmail(String email) {
45
+ this.email = email;
46
+ }
47
+
48
+ public String getPassword() {
49
+ return password;
50
+ }
51
+
52
+ public void setPassword(String password) {
53
+ this.password = password;
54
+ }
55
+
56
+ public boolean isAccountNonExpired() {
57
+ return isAccountNonExpired;
58
+ }
59
+
60
+ public void setIsAccountNonExpired(boolean isAccountNonExpired) {
61
+ this.isAccountNonExpired = isAccountNonExpired;
62
+ }
63
+
64
+ public boolean isAccountNonLocked() {
65
+ return isAccountNonLocked;
66
+ }
67
+
68
+ public void setIsAccountNonLocked(boolean isAccountNonLocked) {
69
+ this.isAccountNonLocked = isAccountNonLocked;
70
+ }
71
+
72
+ public boolean isEnabled() {
73
+ return isEnabled;
74
+ }
75
+
76
+ public void setIsEnabled(boolean isEnabled) {
77
+ this.isEnabled = isEnabled;
78
+ }
79
+
80
+
81
+ public String getUsername() {
82
+ return this.email;
83
+ }
84
+
85
+ public boolean isCredentialsNonExpired() {
86
+ return isCredentialsNonExpired;
87
+ }
88
+
89
+ public void setIsCredentialsNonExpired(boolean isCredentialsNonExpired) {
90
+ this.isCredentialsNonExpired = isCredentialsNonExpired;
91
+ }
92
+ }
@@ -0,0 +1,38 @@
1
+ package <%=@package%>.model;
2
+
3
+ <%=@licence%>
4
+
5
+ import org.springframework.data.mongodb.core.mapping.Document;
6
+
7
+ /**
8
+ * Entity that represents <%=@model_name%>s.
9
+ * @author <%=@user_name%>
10
+ */
11
+ @Document
12
+ public class <%=@model_name%> extends BaseEntity {
13
+
14
+ <%@attributes.each do |attribute| %>private <%="#{attribute.data_type} #{attribute.name}"%>;
15
+ <%end%>
16
+
17
+ public <%=@model_name%>(){}
18
+
19
+
20
+ /**
21
+ * a convenience constructor.
22
+ */
23
+ public <%=@model_name%>(<%=@attributes.map {|attribute| "#{attribute.data_type} #{attribute.name}"}.join(',')%>) {
24
+
25
+ <%@attributes.each do |attribute|%>this.<%=attribute.name%> = <%=attribute.name%>;
26
+ <%end%>
27
+ }
28
+
29
+ <%@attributes.each do |attribute| %>
30
+ public void <%="set#{attribute.name.capitalize}(#{attribute.data_type} #{attribute.name})"%> {
31
+ this.<%=attribute.name%> = <%=attribute.name%>;
32
+ }
33
+
34
+ public <%="#{attribute.data_type} get#{attribute.name.capitalize}"%>() {
35
+ return this.<%=attribute.name%>;
36
+ }
37
+ <%end%>
38
+ }
@@ -0,0 +1,90 @@
1
+ package <%=@package%>.model;
2
+
3
+ import org.springframework.security.core.GrantedAuthority;
4
+ import org.springframework.security.core.userdetails.UserDetails;
5
+ import org.springframework.data.mongodb.core.mapping.Document;
6
+
7
+ import java.util.Collection;
8
+
9
+ /**
10
+ * Entity that represents a single User in the application.
11
+ * @author <%@user_name%>
12
+ */
13
+ @Document
14
+ public class User extends BaseEntity implements UserDetails {
15
+
16
+ @Indexed(unique=true)
17
+ private String email;
18
+
19
+ private String password;
20
+
21
+ private boolean isAccountNonExpired;
22
+ private boolean isAccountNonLocked;
23
+ private boolean isCredentialsNonExpired;
24
+ private boolean isEnabled;
25
+
26
+ public User(String email, String password) {
27
+ this.email = email;
28
+ this.password = password;
29
+ this.isEnabled = true;
30
+ }
31
+
32
+ public User(){}
33
+
34
+ public Collection<? extends GrantedAuthority> getAuthorities() {
35
+ return null;
36
+ }
37
+
38
+ public String getEmail() {
39
+ return email;
40
+ }
41
+
42
+ public void setEmail(String email) {
43
+ this.email = email;
44
+ }
45
+
46
+ public String getPassword() {
47
+ return password;
48
+ }
49
+
50
+ public void setPassword(String password) {
51
+ this.password = password;
52
+ }
53
+
54
+ public boolean isAccountNonExpired() {
55
+ return isAccountNonExpired;
56
+ }
57
+
58
+ public void setIsAccountNonExpired(boolean isAccountNonExpired) {
59
+ this.isAccountNonExpired = isAccountNonExpired;
60
+ }
61
+
62
+ public boolean isAccountNonLocked() {
63
+ return isAccountNonLocked;
64
+ }
65
+
66
+ public void setIsAccountNonLocked(boolean isAccountNonLocked) {
67
+ this.isAccountNonLocked = isAccountNonLocked;
68
+ }
69
+
70
+ public boolean isEnabled() {
71
+ return isEnabled;
72
+ }
73
+
74
+ public void setIsEnabled(boolean isEnabled) {
75
+ this.isEnabled = isEnabled;
76
+ }
77
+
78
+
79
+ public String getUsername() {
80
+ return this.email;
81
+ }
82
+
83
+ public boolean isCredentialsNonExpired() {
84
+ return isCredentialsNonExpired;
85
+ }
86
+
87
+ public void setIsCredentialsNonExpired(boolean isCredentialsNonExpired) {
88
+ this.isCredentialsNonExpired = isCredentialsNonExpired;
89
+ }
90
+ }
@@ -0,0 +1,16 @@
1
+ package <%=@package%>.repository;
2
+
3
+ <%=@licence%>
4
+
5
+ import <%=@package%>.model.<%=@model_name%>;
6
+ import org.springframework.stereotype.Repository;
7
+ import org.springframework.data.jpa.repository.JpaRepository;
8
+
9
+
10
+ /**
11
+ * A repository for <%=@model_name.downcase%>s
12
+ * @author <%=@user_name%>
13
+ */
14
+ public interface <%=@model_name%>Repository extends JpaRepository<<%=@model_name%>,Long> {
15
+
16
+ }
@@ -0,0 +1,16 @@
1
+ package <%=@package%>.repository;
2
+
3
+ <%=@licence%>
4
+
5
+ import <%=@package%>.model.<%=@model_name%>;
6
+ import org.springframework.stereotype.Repository;
7
+ import org.springframework.data.mongodb.repository.MongoRepository;
8
+
9
+
10
+ /**
11
+ * A repository for <%=@model_name.downcase%>s
12
+ * @author <%=@user_name%>
13
+ */
14
+ public interface <%=@model_name%>Repository extends MongoRepository<<%=@model_name%>,String> {
15
+
16
+ }
@@ -7,7 +7,6 @@ import org.springframework.stereotype.Repository;
7
7
  import org.springframework.data.<%=@repository_import%>;
8
8
 
9
9
 
10
-
11
10
  /**
12
11
  * A repository for <%=@model_name%>s
13
12
  * @author <%=@user_name%>
@@ -0,0 +1,25 @@
1
+ package <%=@package%>.service;
2
+
3
+ <%=@licence%>
4
+
5
+ import <%=@package%>.repository.UserRepository;
6
+ import org.springframework.beans.factory.annotation.Autowired;
7
+ import org.springframework.security.core.userdetails.UserDetails;
8
+ import org.springframework.security.core.userdetails.UserDetailsService;
9
+ import org.springframework.security.core.userdetails.UsernameNotFoundException;
10
+ import org.springframework.stereotype.Service;
11
+
12
+ /**
13
+ * Service to load a user by username.
14
+ * @author <%=@user_name%>
15
+ */
16
+ @Service
17
+ public class UserService implements UserDetailsService {
18
+
19
+ @Autowired
20
+ private UserRepository userRepository;
21
+
22
+ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
23
+ return userRepository.findByEmail(username);
24
+ }
25
+ }
@@ -1,4 +1,4 @@
1
- package <%=@package%>.integration.<%=@model_name.downcase%>.routes;
1
+ package <%=@package%>.integration.<%=@model_name.downcase%>;
2
2
 
3
3
  <%=@licence%>
4
4
 
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SpringGen
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/spring-gen.gemspec CHANGED
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_runtime_dependency 'thor', '~> 0.19.1'
24
24
  spec.add_runtime_dependency 'git', '~> 1.2.9.1'
25
+ spec.add_runtime_dependency 'activesupport', '~> 4.2.1'
25
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spring-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rene Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-17 00:00:00.000000000 Z
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.2.9.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 4.2.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 4.2.1
69
83
  description: Generator for spring microservices
70
84
  email:
71
85
  - Richterrettich@gmail.com
@@ -86,39 +100,51 @@ files:
86
100
  - lib/command_router.rb
87
101
  - lib/commands/resource.rb
88
102
  - lib/commands/service.rb
89
- - lib/templates/layout/.gitignore
90
- - lib/templates/layout/build.gradle.erb
91
- - lib/templates/layout/config/checkstyle/checkstyle.xml
92
- - lib/templates/layout/src/java/config/AppConfig.java.erb
93
- - lib/templates/layout/src/java/main/App.java.erb
94
- - lib/templates/layout/src/resources/application.yml.erb
95
- - lib/templates/layout/src/resources/bootstrap.yml.erb
96
- - lib/templates/licence.erb
97
- - lib/templates/resource/assembler/Assembler.java.erb
98
- - lib/templates/resource/assembler/BaseAssembler.java.erb
99
- - lib/templates/resource/controller/BaseController.java.erb
100
- - lib/templates/resource/controller/Controller.java.erb
101
- - lib/templates/resource/model/JpaBaseEntity.java.erb
102
- - lib/templates/resource/model/Model.java.erb
103
- - lib/templates/resource/model/MongodbBaseEntity.java.erb
104
- - lib/templates/resource/model/Neo4jBaseEntity.java.erb
105
- - lib/templates/resource/repository/Repository.java.erb
106
- - lib/templates/resource/resource/Resource.java.erb
107
- - lib/templates/resource/test/TestUtil.java.erb
108
- - lib/templates/resource/test/integration/jpa/IntegrationTest.java.erb
109
- - lib/templates/resource/test/integration/jpa/IntegrationTestConfig.java.erb
110
- - lib/templates/resource/test/integration/jpa/sampleData.xml.erb
111
- - lib/templates/resource/test/integration/mongodb/IntegrationTest.java.erb
112
- - lib/templates/resource/test/integration/mongodb/IntegrationTestConfig.java.erb
113
- - lib/templates/resource/test/integration/mongodb/SampleData.java.erb
114
- - lib/templates/resource/test/integration/neo4j/IntegrationTest.java.erb
115
- - lib/templates/resource/test/integration/neo4j/IntegrationTestConfig.java.erb
116
- - lib/templates/resource/test/integration/neo4j/SampleData.java.erb
117
- - lib/templates/resource/test/unit/assembler/AssemblerUnitTest.java.erb
118
- - lib/templates/resource/test/unit/assembler/AssemblerUnitTestConfig.java.erb
119
- - lib/templates/resource/test/unit/controller/ControllerUnitTest.java.erb
120
- - lib/templates/resource/test/unit/controller/ControllerUnitTestConfig.java.erb
121
- - lib/templates/service.yml.erb
103
+ - lib/configurations/mongodb_configuration.rb
104
+ - lib/configurations/neo4j_configuration.rb
105
+ - lib/generators/generator.rb
106
+ - lib/templates/.gitignore
107
+ - lib/templates/config/checkstyle/checkstyle.xml
108
+ - lib/templates/gradle/jpa_build.gradle.erb
109
+ - lib/templates/gradle/mongodb_build.gradle.erb
110
+ - lib/templates/gradle/neo4j_build.gradle.erb
111
+ - lib/templates/project/licence.erb
112
+ - lib/templates/project/service.yml.erb
113
+ - lib/templates/src/main/java/assembler/Assembler.java.erb
114
+ - lib/templates/src/main/java/assembler/BaseAssembler.java.erb
115
+ - lib/templates/src/main/java/config/AppConfig.java.erb
116
+ - lib/templates/src/main/java/controller/BaseController.java.erb
117
+ - lib/templates/src/main/java/controller/Controller.java.erb
118
+ - lib/templates/src/main/java/main/App.java.erb
119
+ - lib/templates/src/main/java/model/jpa/JpaBaseEntity.java.erb
120
+ - lib/templates/src/main/java/model/jpa/JpaModel.java.erb
121
+ - lib/templates/src/main/java/model/jpa/JpaUser.java.erb
122
+ - lib/templates/src/main/java/model/mongodb/MongodbBaseEntity.java.erb
123
+ - lib/templates/src/main/java/model/mongodb/MongodbModel.java.erb
124
+ - lib/templates/src/main/java/model/mongodb/MongodbUser.java.erb
125
+ - lib/templates/src/main/java/model/neo4j/Neo4jBaseEntity.java.erb
126
+ - lib/templates/src/main/java/model/neo4j/Neo4jModel.java.erb
127
+ - lib/templates/src/main/java/repository/jpa/JpaRepository.java.erb
128
+ - lib/templates/src/main/java/repository/mongodb/MongodbRepository.java.erb
129
+ - lib/templates/src/main/java/repository/neo4j/Neo4jRepository.java.erb
130
+ - lib/templates/src/main/java/resource/Resource.java.erb
131
+ - lib/templates/src/main/java/service/UserService.java.erb
132
+ - lib/templates/src/main/resources/application.yml.erb
133
+ - lib/templates/src/main/resources/bootstrap.yml.erb
134
+ - lib/templates/src/test/java/TestUtil.java.erb
135
+ - lib/templates/src/test/java/integration/jpa/IntegrationTest.java.erb
136
+ - lib/templates/src/test/java/integration/jpa/IntegrationTestConfig.java.erb
137
+ - lib/templates/src/test/java/integration/jpa/sampleData.xml.erb
138
+ - lib/templates/src/test/java/integration/mongodb/IntegrationTest.java.erb
139
+ - lib/templates/src/test/java/integration/mongodb/IntegrationTestConfig.java.erb
140
+ - lib/templates/src/test/java/integration/mongodb/SampleData.java.erb
141
+ - lib/templates/src/test/java/integration/neo4j/IntegrationTest.java.erb
142
+ - lib/templates/src/test/java/integration/neo4j/IntegrationTestConfig.java.erb
143
+ - lib/templates/src/test/java/integration/neo4j/SampleData.java.erb
144
+ - lib/templates/src/test/java/unit/assembler/AssemblerUnitTest.java.erb
145
+ - lib/templates/src/test/java/unit/assembler/AssemblerUnitTestConfig.java.erb
146
+ - lib/templates/src/test/java/unit/controller/ControllerUnitTest.java.erb
147
+ - lib/templates/src/test/java/unit/controller/ControllerUnitTestConfig.java.erb
122
148
  - lib/util.rb
123
149
  - lib/version.rb
124
150
  - spring-gen.gemspec