You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2014/05/19 15:28:29 UTC

[40/50] [abbrv] git commit: [OLINGO-261] Saving enum and complex generated classes for usage with open types

[OLINGO-261] Saving enum and complex generated classes for usage with open types


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/99e14ea1
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/99e14ea1
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/99e14ea1

Branch: refs/heads/master
Commit: 99e14ea190b4e8f5c711cf483f7b3e14c2be627a
Parents: c8ede38
Author: Francesco Chicchiriccò <--global>
Authored: Thu May 15 11:16:26 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Mon May 19 14:35:16 2014 +0200

----------------------------------------------------------------------
 .../olingo/ext/pojogen/AbstractPOJOGenMojo.java | 23 ++++++++++++++++----
 .../org.apache.olingo.ext.proxy.complex         |  4 ++--
 .../META-INF/org.apache.olingo.ext.proxy.enum   |  2 +-
 3 files changed, 22 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/99e14ea1/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java
index 2b718ca..420d4c2 100644
--- a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java
+++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java
@@ -37,6 +37,7 @@ import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmComplexType;
 import org.apache.olingo.commons.api.edm.EdmEntityContainer;
@@ -86,9 +87,8 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo {
 
   protected abstract String getVersion();
 
-  protected File mkPkgDir(final String path) {
-    final File dir = new File(outputDirectory + File.separator + TOOL_DIR + File.separator
-            + basePackage.replace('.', File.separatorChar) + File.separator + path);
+  protected File mkdir(final String path) {
+    final File dir = new File(outputDirectory + File.separator + TOOL_DIR + File.separator + path);
 
     if (dir.exists()) {
       if (!dir.isDirectory()) {
@@ -101,6 +101,10 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo {
     return dir;
   }
 
+  protected File mkPkgDir(final String path) {
+    return mkdir(basePackage.replace('.', File.separatorChar) + File.separator + path);
+  }
+
   protected void writeFile(final String name, final File path, final VelocityContext ctx, final Template template,
           final boolean append) throws MojoExecutionException {
 
@@ -226,6 +230,9 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo {
         namespaces.add(schema.getNamespace().toLowerCase());
       }
 
+      final StringBuilder complexTypeNames = new StringBuilder();
+      final StringBuilder enumTypeNames = new StringBuilder();
+
       for (EdmSchema schema : edm.getSchemas()) {
         createUtility(edm, schema, basePackage);
 
@@ -245,16 +252,18 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo {
         // write types into types package
         for (EdmEnumType enumType : schema.getEnumTypes()) {
           final String className = utility.capitalize(enumType.getName());
+          enumTypeNames.append(typesPkg).append('.').append(className).append('\n');
           objs.clear();
           objs.put("enumType", enumType);
           parseObj(typesBaseDir, typesPkg, "enumType", className + ".java", objs);
         }
 
         final List<EdmComplexType> complexes = new ArrayList<EdmComplexType>();
-        
+
         for (EdmComplexType complex : schema.getComplexTypes()) {
           complexes.add(complex);
           final String className = utility.capitalize(complex.getName());
+          complexTypeNames.append(typesPkg).append('.').append(className).append('\n');
           objs.clear();
           objs.put("complexType", complex);
           parseObj(typesBaseDir, typesPkg, "complexType", className + ".java", objs);
@@ -324,6 +333,12 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo {
           }
         }
       }
+
+      final File metaInf = mkdir("META-INF");
+      FileUtils.fileWrite(
+              metaInf.getPath() + File.separator + Constants.PROXY_ENUM_CLASS_LIST, enumTypeNames.toString());
+      FileUtils.fileWrite(
+              metaInf.getPath() + File.separator + Constants.PROXY_COMPLEX_CLASS_LIST, complexTypeNames.toString());
     } catch (Exception t) {
       getLog().error(t);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/99e14ea1/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.complex
----------------------------------------------------------------------
diff --git a/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.complex b/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.complex
index 3c43cdf..c6d788f 100644
--- a/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.complex
+++ b/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.complex
@@ -13,9 +13,9 @@ org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.a
 org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.ConcurrencyInfo
 org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Dimensions
 org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.ComplexToCategory
-org.apache.olingo.fit.proxy.v3.opentype.microsoft.test.odata.services.opentypesservicev3.types.ContactDetails
+org.apache.olingo.fit.proxy.v3.opentype.microsoft.test.odata.services.opentypesservice.types.ContactDetails
 org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address
 org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.HomeAddress
 org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyAddress
 org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccountInfo
-org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.ContactDetails
+org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservice.types.ContactDetails

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/99e14ea1/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.enum
----------------------------------------------------------------------
diff --git a/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.enum b/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.enum
index 16dbe68..b8c585f 100644
--- a/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.enum
+++ b/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.enum
@@ -1,4 +1,4 @@
 org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccessLevel
 org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Color
 org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyCategory
-org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Color
+org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservice.types.Color