You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2017/04/18 01:58:26 UTC
[2/2] polygene-java git commit: Plaintypes needed as well. Also only
generate imports if it is in a package. That allows us to drop "java.lang."
for common property types such as String and Integer,
as well as shortform types in the same package.
Plaintypes needed as well. Also only generate imports if it is in a package. That allows us to drop "java.lang." for common property types such as String and Integer, as well as shortform types in the same package.
Signed-off-by: niclas <ni...@hedhman.org>
Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/718fa57c
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/718fa57c
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/718fa57c
Branch: refs/heads/develop
Commit: 718fa57ca9485b0d34c484682c08ae46f38a7cb0
Parents: 7bec0f0
Author: niclas <ni...@hedhman.org>
Authored: Tue Apr 18 09:58:12 2017 +0800
Committer: niclas <ni...@hedhman.org>
Committed: Tue Apr 18 09:58:12 2017 +0800
----------------------------------------------------------------------
tools/generator-polygene/app/index.js | 4 ++-
.../DomainLayer/DomainModule/Configuration.tmpl | 8 ++---
.../DomainLayer/DomainModule/Crud.tmpl | 7 ++--
.../DomainLayer/DomainModule/Entity.tmpl | 3 +-
.../DomainLayer/DomainModule/Object.tmpl | 8 +++++
.../DomainLayer/DomainModule/Plain.tmpl | 37 ++++++++++++++++++++
.../DomainLayer/DomainModule/Service.tmpl | 3 +-
.../DomainLayer/DomainModule/Transient.tmpl | 3 +-
.../DomainLayer/DomainModule/Value.tmpl | 3 +-
.../DomainLayer/DomainModule/module.js | 1 +
10 files changed, 65 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/718fa57c/tools/generator-polygene/app/index.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/index.js b/tools/generator-polygene/app/index.js
index 3829a8f..a4a4702 100644
--- a/tools/generator-polygene/app/index.js
+++ b/tools/generator-polygene/app/index.js
@@ -369,10 +369,11 @@ function assignFunctions(polygene) {
var imported = {};
var props = current.clazz.configuration;
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];
+ imported[prop.type] = true;
var yamlDefault;
if (prop.type === "java.lang.String") {
yamlDefault = '""';
@@ -398,6 +399,7 @@ function assignFunctions(polygene) {
yaml.push(prop.name + " : " + yamlDefault);
}
} else {
+ imported["org.apache.polygene.api.property.Property"] = true;
state.push('Property<String> name(); // TODO: remove sample property');
yaml.push('name : "sample config value"');
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/718fa57c/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 6498640..b7acd94 100644
--- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Configuration.tmpl
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Configuration.tmpl
@@ -18,11 +18,11 @@
*
-%>
package <%= polygene.packageName %>.model.<%= polygene.current.name %>;
-
<%
-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" )
+ && imp.includes(".") ) {
+ %><%- "import " + imp + ";"; %>
<%
}
} %>
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/718fa57c/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 cbb7e5d..60d7528 100644
--- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Crud.tmpl
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Crud.tmpl
@@ -22,9 +22,10 @@ package <%= polygene.packageName %>.model.<%= polygene.current.name %>;
import org.apache.polygene.api.injection.scope.This;
import org.apache.polygene.api.mixin.Mixins;
<%
-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" )
+ && imp.includes(".") ) {
+ %><%- "import " + imp + ";"; %>
<%
}
} %>
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/718fa57c/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 4c30883..60d7528 100644
--- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Entity.tmpl
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Entity.tmpl
@@ -23,7 +23,8 @@ import org.apache.polygene.api.injection.scope.This;
import org.apache.polygene.api.mixin.Mixins;
<%
for( var imp in polygene.current.imported ) {
- if( !imp.startsWith( "java.lang" )) {
+ if( !imp.startsWith( "java.lang" )
+ && imp.includes(".") ) {
%><%- "import " + imp + ";"; %>
<%
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/718fa57c/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Object.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Object.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Object.tmpl
index d51cdf5..fb8908b 100644
--- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Object.tmpl
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Object.tmpl
@@ -23,6 +23,14 @@ import org.apache.polygene.api.injection.scope.Structure;
import org.apache.polygene.api.injection.scope.Uses;
import org.apache.polygene.api.mixin.Mixins;
import org.apache.polygene.api.value.ValueBuilderFactory;
+<%
+for( var imp in polygene.current.imported ) {
+ if( !imp.startsWith( "java.lang" )
+ && imp.includes(".") ) {
+ %><%- "import " + imp + ";"; %>
+<%
+ }
+} %>
public class <%= polygene.current.clazz.name %>
{
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/718fa57c/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Plain.tmpl
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Plain.tmpl b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Plain.tmpl
new file mode 100644
index 0000000..c7a1c04
--- /dev/null
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Plain.tmpl
@@ -0,0 +1,37 @@
+<%#
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+-%>
+package <%= polygene.packageName %>.model.<%= polygene.current.name %>;
+<%
+for( var imp in polygene.current.imported ) {
+ if( !imp.startsWith( "java.lang" )
+ && imp.includes(".") ) {
+ %><%- "import " + imp + ";"; %>
+<%
+ }
+} %>
+
+public <%- polygene.current.clazz.type %> <%= polygene.current.clazz.name %>
+{<%
+if( polygene.current.clazz.type === 'enum' ) {
+%>
+ <%- polygene.current.clazz.values %>
+<%
+}
+%>}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/718fa57c/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 a4028ca..b5fafdb 100644
--- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Service.tmpl
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Service.tmpl
@@ -27,7 +27,8 @@ import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
import org.apache.polygene.api.value.ValueBuilderFactory;
<%
for( var imp in polygene.current.imported ) {
- if( !imp.startsWith( "java.lang" )) {
+ if( !imp.startsWith( "java.lang" )
+ && imp.includes(".") ) {
%><%- "import " + imp + ";"; %>
<%
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/718fa57c/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 3b49522..c8012ba 100644
--- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Transient.tmpl
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Transient.tmpl
@@ -23,7 +23,8 @@ import org.apache.polygene.api.injection.scope.Uses;
import org.apache.polygene.api.mixin.Mixins;
<%
for( var imp in polygene.current.imported ) {
- if( !imp.startsWith( "java.lang" )) {
+ if( !imp.startsWith( "java.lang" )
+ && imp.includes(".") ) {
%><%- "import " + imp + ";"; %>
<%
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/718fa57c/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 cf15d92..beae662 100644
--- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Value.tmpl
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/Value.tmpl
@@ -23,7 +23,8 @@ import org.apache.polygene.api.injection.scope.This;
import org.apache.polygene.api.mixin.Mixins;
<%
for( var imp in polygene.current.imported ) {
- if( !imp.startsWith( "java.lang" )) {
+ if( !imp.startsWith( "java.lang" )
+ && imp.includes(".") ) {
%><%- "import " + imp + ";"; %>
<%
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/718fa57c/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js
----------------------------------------------------------------------
diff --git a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js
index 27b0a4f..03e2040 100644
--- a/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js
+++ b/tools/generator-polygene/app/templates/DomainLayer/DomainModule/module.js
@@ -28,6 +28,7 @@ function copyPolygeneDomainModule(p, moduleName, moduleDef) {
copyComposites(p, moduleDef.transients, "Transient");
copyComposites(p, moduleDef.objects, "Object");
copyComposites(p, moduleDef.services, "Service");
+ copyComposites(p, moduleDef.plainTypes, "Plain");
copyComposites(p, moduleDef.services, "Configuration");
copyConfigurationYaml(p, moduleDef.services )