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 12:34:30 UTC
[32/45] 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/8976f179
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/8976f179
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/8976f179
Branch: refs/heads/olingo-266-ref
Commit: 8976f1797f0c4309a3ddec5154971a442f1ab707
Parents: 4a0bb2c
Author: Francesco Chicchiriccò <--global>
Authored: Thu May 15 11:16:26 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Mon May 19 12:33:30 2014 +0200
----------------------------------------------------------------------
.../olingo/ext/pojogen/AbstractPOJOGenMojo.java | 23 ++++++++++++++++----
.../org.apache.olingo.ext.proxy.complex | 21 ++++++++++++++++++
.../META-INF/org.apache.olingo.ext.proxy.enum | 4 ++++
.../apache/olingo/commons/api/Constants.java | 4 ++++
4 files changed, 48 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8976f179/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/8976f179/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
new file mode 100644
index 0000000..c6d788f
--- /dev/null
+++ b/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.complex
@@ -0,0 +1,21 @@
+org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.ContactDetails
+org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.AuditInfo
+org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.ConcurrencyInfo
+org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Dimensions
+org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.ComplexToCategory
+org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Phone
+org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Aliases
+org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.ComplexWithAllPrimitiveTypes
+org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.ContactDetails
+org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Aliases
+org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Phone
+org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AuditInfo
+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.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.opentypesservice.types.ContactDetails
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8976f179/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
new file mode 100644
index 0000000..b8c585f
--- /dev/null
+++ b/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.enum
@@ -0,0 +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.opentypesservice.types.Color
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8976f179/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java
index 2edab5e..acd0fb9 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java
@@ -35,6 +35,10 @@ public interface Constants {
public final static Integer DEFAULT_SCALE = 25;
+ public final static String PROXY_ENUM_CLASS_LIST = "org.apache.olingo.ext.proxy.enum";
+
+ public final static String PROXY_COMPLEX_CLASS_LIST = "org.apache.olingo.ext.proxy.complex";
+
// XML namespaces and prefixes
public final static String NS_ATOM = "http://www.w3.org/2005/Atom";