Repository: polygene-java Updated Branches: refs/heads/develop eec1660fb -> 718fa57ca
Fixing generator issues, when a model.json is provided. Signed-off-by: niclas <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/7bec0f0d Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/7bec0f0d Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/7bec0f0d Branch: refs/heads/develop Commit: 7bec0f0d090e775f29091e6b19263e166b513cb2 Parents: eec1660 Author: niclas <[email protected]> Authored: Mon Apr 17 20:11:34 2017 +0800 Committer: niclas <[email protected]> Committed: Mon Apr 17 20:11:34 2017 +0800 ---------------------------------------------------------------------- tools/generator-polygene/app/index.js | 25 ++++--- .../DomainLayer/DomainModule/Configuration.tmpl | 1 - .../DomainLayer/DomainModule/Crud.tmpl | 4 +- .../DomainLayer/DomainModule/Entity.tmpl | 8 +-- .../DomainLayer/DomainModule/Service.tmpl | 7 +- .../DomainLayer/DomainModule/Transient.tmpl | 10 +-- .../DomainLayer/DomainModule/Value.tmpl | 8 +-- tools/src/docs/yeoman_polygene.txt | 70 ++++++++++++-------- 8 files changed, 78 insertions(+), 55 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7bec0f0d/tools/generator-polygene/app/index.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/index.js b/tools/generator-polygene/app/index.js index a28f470..3829a8f 100644 --- a/tools/generator-polygene/app/index.js +++ b/tools/generator-polygene/app/index.js @@ -322,36 +322,41 @@ function assignFunctions(polygene) { var imported = {}; var props = current.clazz.properties; if (props) { + imported["org.apache.polygene.api.property.Property"] = true; for (var idx in props) { var prop = props[idx]; - state.push('Property' + '<' + polygene.typeNameOnly(prop.type) + "> " + prop.name + "();") - imported[prop.type] = imported[prop.type]; + state.push('Property' + '<' + polygene.typeNameOnly(prop.type) + "> " + prop.name + "();"); + imported[prop.type] = true; } } else { + imported["org.apache.polygene.api.property.Property"] = true; state.push('Property<String> name(); // TODO: remove sample property') } var assocs = current.clazz.associations; if (assocs) { + imported["org.apache.polygene.api.association.Association"] = true; for (var idx in assocs) { var assoc = assocs[idx]; - state.push("Association" + '<' + polygene.typeNameOnly(assoc.type) + '>' + assoc.name + "();") - imported[assoc.type] = imported[assoc.type]; + state.push("Association" + '<' + polygene.typeNameOnly(assoc.type) + "> " + assoc.name + "();"); + imported[assoc.type] = true; } } assocs = current.clazz.manyassociations; if (assocs) { + imported["org.apache.polygene.api.association.ManyAssociation"] = true; for (var idx in assocs) { var assoc = assocs[idx]; - state.push("ManyAssociation<" + polygene.typeNameOnly(assoc.type) + ">" + assoc.name + "();") - imported[assoc.type] = imported[assoc.type]; + state.push("ManyAssociation<" + polygene.typeNameOnly(assoc.type) + "> " + assoc.name + "();"); + imported[assoc.type] = true; } } assocs = current.clazz.namedassociations; if (assocs) { + imported["org.apache.polygene.api.association.NamedAssociation"] = true; for (var idx in assocs) { var assoc = assocs[idx]; - state.push("NamedAssociation<" + polygene.typeNameOnly(assoc.type) + ">" + assoc.name + "();") - imported[assoc.type] = imported[assoc.type]; + state.push("NamedAssociation<" + polygene.typeNameOnly(assoc.type) + "> " + assoc.name + "();"); + imported[assoc.type] = true; } } current.state = state; @@ -366,7 +371,7 @@ function assignFunctions(polygene) { if (props) { for (var idx in props) { var prop = props[idx]; - state.push('Property' + '<' + polygene.typeNameOnly(prop.type) + "> " + prop.name + "();") + state.push('Property' + '<' + polygene.typeNameOnly(prop.type) + "> " + prop.name + "();"); imported[prop.type] = imported[prop.type]; var yamlDefault; if (prop.type === "java.lang.String") { @@ -393,7 +398,7 @@ function assignFunctions(polygene) { yaml.push(prop.name + " : " + yamlDefault); } } else { - state.push('Property<String> name(); // TODO: remove sample property') + state.push('Property<String> name(); // TODO: remove sample property'); yaml.push('name : "sample config value"'); } current.state = state; http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7bec0f0d/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Configuration.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Configuration.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Configuration.tmpl index b5ab022..6498640 100644 --- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Configuration.tmpl +++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Configuration.tmpl @@ -19,7 +19,6 @@ -%> package <%= polygene.packageName %>.model.<%= polygene.current.name %>; -import org.apache.polygene.api.property.Property; <% for( var prop in polygene.current.imported ) { if( !prop.startsWith( "java.lang" )) { http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7bec0f0d/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Crud.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Crud.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Crud.tmpl index 2abd6b3..cbb7e5d 100644 --- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Crud.tmpl +++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Crud.tmpl @@ -21,11 +21,11 @@ package <%= polygene.packageName %>.model.<%= polygene.current.name %>; import org.apache.polygene.api.injection.scope.This; import org.apache.polygene.api.mixin.Mixins; -import org.apache.polygene.api.property.Property; <% for( var prop in polygene.current.imported ) { if( !prop.startsWith( "java.lang" )) { - %><%- "import " + prop + ";"; %><% + %><%- "import " + prop + ";"; %> +<% } } %> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7bec0f0d/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Entity.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Entity.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Entity.tmpl index 2abd6b3..4c30883 100644 --- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Entity.tmpl +++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Entity.tmpl @@ -21,11 +21,11 @@ package <%= polygene.packageName %>.model.<%= polygene.current.name %>; import org.apache.polygene.api.injection.scope.This; import org.apache.polygene.api.mixin.Mixins; -import org.apache.polygene.api.property.Property; <% -for( var prop in polygene.current.imported ) { - if( !prop.startsWith( "java.lang" )) { - %><%- "import " + prop + ";"; %><% +for( var imp in polygene.current.imported ) { + if( !imp.startsWith( "java.lang" )) { + %><%- "import " + imp + ";"; %> +<% } } %> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7bec0f0d/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Service.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Service.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Service.tmpl index 67c989b..a4028ca 100644 --- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Service.tmpl +++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Service.tmpl @@ -26,9 +26,10 @@ import org.apache.polygene.api.mixin.Mixins; import org.apache.polygene.api.unitofwork.UnitOfWorkFactory; import org.apache.polygene.api.value.ValueBuilderFactory; <% -for( var prop in polygene.current.imported ) { - if( !prop.startsWith( "java.lang" )) { - %><%- "import " + prop + ";"; %><% +for( var imp in polygene.current.imported ) { + if( !imp.startsWith( "java.lang" )) { + %><%- "import " + imp + ";"; %> +<% } } %> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7bec0f0d/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Transient.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Transient.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Transient.tmpl index ffb1660..3b49522 100644 --- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Transient.tmpl +++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Transient.tmpl @@ -21,11 +21,11 @@ package <%= polygene.packageName %>.model.<%= polygene.current.name %>; import org.apache.polygene.api.injection.scope.Uses; import org.apache.polygene.api.mixin.Mixins; -import org.apache.polygene.api.property.Property; <% -for( var prop in polygene.current.imported ) { - if( !prop.startsWith( "java.lang" )) { - %><%- "import " + prop + ";"; %><% +for( var imp in polygene.current.imported ) { + if( !imp.startsWith( "java.lang" )) { + %><%- "import " + imp + ";"; %> +<% } } %> @@ -33,7 +33,7 @@ for( var prop in polygene.current.imported ) { public interface <%= polygene.current.clazz.name %> { <% for( var idx in polygene.current.state ) { %> - <%- polygene.current.state[idx]; %> + <%- polygene.current.state[idx]; %> <% } %> // If Property declarations are public, the Mixin must be abstract, because PropertyMixin will implement those methods. http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7bec0f0d/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Value.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Value.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Value.tmpl index 3d3baea..cf15d92 100644 --- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Value.tmpl +++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Value.tmpl @@ -21,11 +21,11 @@ package <%= polygene.packageName %>.model.<%= polygene.current.name %>; import org.apache.polygene.api.injection.scope.This; import org.apache.polygene.api.mixin.Mixins; -import org.apache.polygene.api.property.Property; <% -for( var prop in polygene.current.imported ) { - if( !prop.startsWith( "java.lang" )) { - %><%- "import " + prop + ";"; %><% +for( var imp in polygene.current.imported ) { + if( !imp.startsWith( "java.lang" )) { + %><%- "import " + imp + ";"; %> +<% } } %> http://git-wip-us.apache.org/repos/asf/polygene-java/blob/7bec0f0d/tools/src/docs/yeoman_polygene.txt ---------------------------------------------------------------------- diff --git a/tools/src/docs/yeoman_polygene.txt b/tools/src/docs/yeoman_polygene.txt index 250ece2..0a9e779 100644 --- a/tools/src/docs/yeoman_polygene.txt +++ b/tools/src/docs/yeoman_polygene.txt @@ -22,11 +22,12 @@ Apache Polygene comes with a Yeoman code generator, to quickly set up a development environment for Polygene applications. ---------------------------- +[source,shell] +---- mkdir projectdirname cd projectdirname yo polygene ---------------------------- +---- It will ask a lot of questions. For choice questions, you operate up and down, and with multi-choice, you select with space bar. @@ -36,15 +37,19 @@ select with space bar. === Project Name === It starts with the Project name. This will be the project name in Gradle and any gradle driven naming of the project such as in IDEs. It defaults to current directory with initial uppercase letter. ---------------------------- + +[source,shell] +---- ? Your project name ---------------------------- +---- === Java Package Name === This is the root of the package names in the multi-module, multi-package project. ---------------------------- + +[source,shell] +---- ? Java package name ---------------------------- +---- === Application Type === @@ -52,17 +57,19 @@ The Application Type that you want to create. NOTE: Command Line is currently not implemented correctly, and the Rest API is still not complete. ---------------------------- +[source,shell] +---- ? what type of application do you want to create? Command Line ⯠Rest API ---------------------------- +---- === Entity Store === Polygene has built-in persistence, and that is backed by entity store plugins. There are currently a fair number of implementations to choose from. Not that "memory" is not persistent, but looses the content on shutdown. ---------------------------- +[source,shell] +---- ? Which entity store do you want to use? Cassandra File @@ -81,7 +88,7 @@ number of implementations to choose from. Not that "memory" is not persistent, b Riak PostgreSQL SQLite ---------------------------- +---- === Indexin/Query system === Select of a pluggable Indexing and Query subsystem. @@ -93,44 +100,50 @@ from the document-oriented approach of most entity stores. NOTE: Not all indexing subsystems support all of the specified Indexing/Query SPI. ---------------------------- +[source,shell] +---- ? Which indexing system do you want to use? > Rdf ElasticSearch Solr SQL ---------------------------- +---- === Caching System === Some of the entity stores rely on a Polygene level caching SPI. This caching subsystem is pluggable and will be used by any of the entity stores that uses the internal MapEntityStore SPI ---------------------------- +[source,shell] +---- ? Which caching system do you want to use? > None Memcache EhCache ---------------------------- +---- === Serialization system === Serialization is a key concept in business applications, and in Polygene that is a pluggable subsystem. ? Which serialization system do you want to use? ---------------------------- + +[source,shell] +---- > JavaxJson JavaxXml MessagePack ---------------------------- +---- === Metrics System === Metrics is the SPI for measuring the performance and health of an Polygene application. Currently only one implementation is available. ? Which metrics capturing system do you want to use? ---------------------------- + +[source,shell] +---- > None Codahale ---------------------------- +---- === Other Features === @@ -140,17 +153,19 @@ Mixin Scripting is allowing Mixin methods to be implemented in other languages p Security installs Apache Shiro and binds Users, Groups and Roles to entity store. ---------------------------- +[source,shell] +---- ? Other features? ⯠jmx ⯠mixin scripting ⯠security ---------------------------- +---- === Example === ---------------------------- +[source,shell] +---- ~/dev/sensetif/sink$ yo polygene ? Your project name Sink ? Java package name com.sensetif.sink @@ -203,23 +218,26 @@ Features: [ 'jmx', 'security' ] create bootstrap/src/main/java/com/sensetif/sink/bootstrap/connectivity/RestApiModule.java create rest/src/main/java/com/sensetif/sink/rest/security/DefaultEnroler.java create rest/src/main/java/com/sensetif/sink/rest/security/DefaultVerifier.java ---------------------------- +---- == Command Line Options == ---------- +[source,shell] +---- --import=<modelfile> Imports the model from a JSON file and creates a project descibed therein. --export=<modelfile> Exports the generated model to a JSON file in the same format as the import model. --noPrompt If this option is not provided for --import-model, the user can still input answers, which will override the values in the imported model ---------- +---- === Example === If we run the following, ------------- + +[source,shell] +---- $ yo polygene --import=../model.json --noPrompt ------------- +---- where the content of the +../model.json+ is as follows,
