You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by fm...@apache.org on 2014/05/06 10:45:00 UTC
[3/4] [OLINGO-261] providing basics for pojo generator and proxy
annotations
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/it/keyAsSegmentService/verify.groovy
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/keyAsSegmentService/verify.groovy b/ext/pojogen-maven-plugin/src/it/keyAsSegmentService/verify.groovy
new file mode 100644
index 0000000..a19cf4d
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/it/keyAsSegmentService/verify.groovy
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/com/msopentech/odatajclient/proxy" );
+assert basepkg.isDirectory() && basepkg.listFiles().length>0;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/it/northwind/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/northwind/pom.xml b/ext/pojogen-maven-plugin/src/it/northwind/pom.xml
new file mode 100644
index 0000000..862493a
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/it/northwind/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.olingo.ext</groupId>
+ <artifactId>odatajclient-maven-plugin</artifactId>
+ <version>@project.version@</version>
+
+ <description>A simple IT verifying the basic use case.</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>@velocity.version@</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.olingo.ext</groupId>
+ <artifactId>odatajclient-proxy</artifactId>
+ <version>@project.version@</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <configuration>
+ <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
+ <serviceRootURL>http://services.odata.org/v3/(S(g00nkir0ssikgdmz3maw5l1x))/Northwind/Northwind.svc</serviceRootURL>
+ <basePackage>org.apache.olingo.ext.proxy.northwind</basePackage>
+ </configuration>
+ <id>pojosV3</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>pojosV3</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/it/northwind/verify.groovy
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/northwind/verify.groovy b/ext/pojogen-maven-plugin/src/it/northwind/verify.groovy
new file mode 100644
index 0000000..a19cf4d
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/it/northwind/verify.groovy
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/com/msopentech/odatajclient/proxy" );
+assert basepkg.isDirectory() && basepkg.listFiles().length>0;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/pom.xml b/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/pom.xml
new file mode 100644
index 0000000..0f133b4
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.olingo.ext</groupId>
+ <artifactId>odatajclient-maven-plugin</artifactId>
+ <version>@project.version@</version>
+
+ <description>A simple IT verifying the basic use case.</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>@velocity.version@</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.olingo.ext</groupId>
+ <artifactId>odatajclient-proxy</artifactId>
+ <version>@project.version@</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <configuration>
+ <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
+ <serviceRootURL>@serviceRootURL@/ODataWriterDefaultService.svc</serviceRootURL>
+ <basePackage>org.apache.olingo.ext.proxy.odatawriterdefaultservice</basePackage>
+ </configuration>
+ <id>pojosV3</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>pojosV3</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/verify.groovy
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/verify.groovy b/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/verify.groovy
new file mode 100644
index 0000000..a19cf4d
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/verify.groovy
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/com/msopentech/odatajclient/proxy" );
+assert basepkg.isDirectory() && basepkg.listFiles().length>0;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/it/openTypeService/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/openTypeService/pom.xml b/ext/pojogen-maven-plugin/src/it/openTypeService/pom.xml
new file mode 100644
index 0000000..408c57a
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/it/openTypeService/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.olingo.ext</groupId>
+ <artifactId>odatajclient-maven-plugin</artifactId>
+ <version>@project.version@</version>
+
+ <description>A simple IT verifying the basic use case.</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>@velocity.version@</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.olingo.ext</groupId>
+ <artifactId>odatajclient-proxy</artifactId>
+ <version>@project.version@</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <configuration>
+ <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
+ <serviceRootURL>@serviceRootURL@/OpenTypeService.svc</serviceRootURL>
+ <basePackage>org.apache.olingo.ext.proxy.opentypeservice</basePackage>
+ </configuration>
+ <id>pojosV3</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>pojosV3</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/it/openTypeService/verify.groovy
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/openTypeService/verify.groovy b/ext/pojogen-maven-plugin/src/it/openTypeService/verify.groovy
new file mode 100644
index 0000000..a19cf4d
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/it/openTypeService/verify.groovy
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/com/msopentech/odatajclient/proxy" );
+assert basepkg.isDirectory() && basepkg.listFiles().length>0;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/it/primitiveKeysService/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/primitiveKeysService/pom.xml b/ext/pojogen-maven-plugin/src/it/primitiveKeysService/pom.xml
new file mode 100644
index 0000000..1596708
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/it/primitiveKeysService/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.olingo.ext</groupId>
+ <artifactId>odatajclient-maven-plugin</artifactId>
+ <version>@project.version@</version>
+
+ <description>A simple IT verifying the basic use case.</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>@velocity.version@</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.olingo.ext</groupId>
+ <artifactId>odatajclient-proxy</artifactId>
+ <version>@project.version@</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <configuration>
+ <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
+ <serviceRootURL>@serviceRootURL@/PrimitiveKeys.svc</serviceRootURL>
+ <basePackage>org.apache.olingo.ext.proxy.primitivekeysservice</basePackage>
+ </configuration>
+ <id>pojosV3</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>pojosV3</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/it/primitiveKeysService/verify.groovy
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/primitiveKeysService/verify.groovy b/ext/pojogen-maven-plugin/src/it/primitiveKeysService/verify.groovy
new file mode 100644
index 0000000..a19cf4d
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/it/primitiveKeysService/verify.groovy
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/com/msopentech/odatajclient/proxy" );
+assert basepkg.isDirectory() && basepkg.listFiles().length>0;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/it/staticServiceV3/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/staticServiceV3/pom.xml b/ext/pojogen-maven-plugin/src/it/staticServiceV3/pom.xml
new file mode 100644
index 0000000..43cb499
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/it/staticServiceV3/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.olingo.ext</groupId>
+ <artifactId>odatajclient-maven-plugin</artifactId>
+ <version>@project.version@</version>
+
+ <description>A simple IT verifying the basic use case.</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>@velocity.version@</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.olingo.ext</groupId>
+ <artifactId>odatajclient-proxy</artifactId>
+ <version>@project.version@</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <configuration>
+ <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
+ <serviceRootURL>http://localhost:9080/StaticService/V3/Static.svc</serviceRootURL>
+ <basePackage>org.apache.olingo.ext.proxy.staticservice</basePackage>
+ </configuration>
+ <id>pojosV3</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>pojosV3</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/it/staticServiceV3/verify.groovy
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/staticServiceV3/verify.groovy b/ext/pojogen-maven-plugin/src/it/staticServiceV3/verify.groovy
new file mode 100644
index 0000000..a19cf4d
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/it/staticServiceV3/verify.groovy
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/com/msopentech/odatajclient/proxy" );
+assert basepkg.isDirectory() && basepkg.listFiles().length>0;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/it/staticServiceV4/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/staticServiceV4/pom.xml b/ext/pojogen-maven-plugin/src/it/staticServiceV4/pom.xml
new file mode 100644
index 0000000..7c1e208
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/it/staticServiceV4/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.olingo.ext</groupId>
+ <artifactId>odatajclient-maven-plugin</artifactId>
+ <version>@project.version@</version>
+
+ <description>A simple IT verifying the basic use case.</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>@velocity.version@</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.olingo.ext</groupId>
+ <artifactId>odatajclient-proxy</artifactId>
+ <version>@project.version@</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <configuration>
+ <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
+ <serviceRootURL>http://localhost:9080/StaticService/V4/Static.svc</serviceRootURL>
+ <basePackage>org.apache.olingo.ext.proxy.staticservice</basePackage>
+ </configuration>
+ <id>pojosV3</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>pojosV4</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/it/staticServiceV4/verify.groovy
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/staticServiceV4/verify.groovy b/ext/pojogen-maven-plugin/src/it/staticServiceV4/verify.groovy
new file mode 100644
index 0000000..a19cf4d
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/it/staticServiceV4/verify.groovy
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/com/msopentech/odatajclient/proxy" );
+assert basepkg.isDirectory() && basepkg.listFiles().length>0;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractMetadataMojo.java
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractMetadataMojo.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractMetadataMojo.java
new file mode 100644
index 0000000..2347761
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractMetadataMojo.java
@@ -0,0 +1,161 @@
+/*
+ * 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 org.apache.olingo.ext.pojogen;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Parameter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+
+public abstract class AbstractMetadataMojo extends AbstractMojo {
+
+ /**
+ * Generated files base root.
+ */
+ @Parameter(property = "outputDirectory", required = true)
+ protected String outputDirectory;
+
+ /**
+ * OData service root URL.
+ */
+ @Parameter(property = "serviceRootURL", required = true)
+ protected String serviceRootURL;
+
+ /**
+ * Base package.
+ */
+ @Parameter(property = "basePackage", required = true)
+ protected String basePackage;
+
+ protected final Set<String> namespaces = new HashSet<String>();
+
+ protected static String TOOL_DIR = "ojc-plugin";
+
+ protected AbstractUtility utility;
+
+ protected abstract AbstractUtility getUtility();
+
+ protected abstract String getVersion();
+
+ 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()) {
+ throw new IllegalArgumentException("Invalid path '" + path + "': it is not a directory");
+ }
+ } else {
+ dir.mkdirs();
+ }
+
+ 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 {
+
+ if (!path.exists()) {
+ throw new IllegalArgumentException("Invalid base path '" + path.getAbsolutePath() + "'");
+ }
+
+ FileWriter writer = null;
+ try {
+ final File toBeWritten = new File(path, name);
+ if (!append && toBeWritten.exists()) {
+ throw new IllegalStateException("File '" + toBeWritten.getAbsolutePath() + "' already exists");
+ }
+ writer = new FileWriter(toBeWritten, append);
+ template.merge(ctx, writer);
+ } catch (IOException e) {
+ throw new MojoExecutionException("Error creating file '" + name + "'", e);
+ } finally {
+ IOUtils.closeQuietly(writer);
+ }
+ }
+
+ protected VelocityContext newContext() {
+
+ final VelocityContext ctx = new VelocityContext();
+
+ ctx.put("utility", getUtility());
+ ctx.put("basePackage", basePackage);
+ ctx.put("schemaName", getUtility().getSchemaName());
+ ctx.put("namespace", getUtility().getNamespace());
+ ctx.put("namespaces", namespaces);
+ ctx.put("odataVersion", getVersion());
+
+ return ctx;
+ }
+
+ protected void parseObj(final File base, final String pkg, final String name, final String out)
+ throws MojoExecutionException {
+
+ parseObj(base, false, pkg, name, out, Collections.<String, Object>emptyMap());
+ }
+
+ protected void parseObj(
+ final File base,
+ final String pkg,
+ final String name,
+ final String out,
+ final Map<String, Object> objs)
+ throws MojoExecutionException {
+
+ parseObj(base, false, pkg, name, out, objs);
+ }
+
+ protected void parseObj(
+ final File base,
+ final boolean append,
+ final String pkg,
+ final String name,
+ final String out,
+ final Map<String, Object> objs)
+ throws MojoExecutionException {
+
+ final VelocityContext ctx = newContext();
+ ctx.put("package", pkg);
+
+ if (objs != null) {
+ for (Map.Entry<String, Object> obj : objs.entrySet()) {
+ if (StringUtils.isNotBlank(obj.getKey()) && obj.getValue() != null) {
+ ctx.put(obj.getKey(), obj.getValue());
+ }
+ }
+ }
+
+ final Template template = Velocity.getTemplate(name + ".vm");
+ writeFile(out, base, ctx, template, append);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java
new file mode 100644
index 0000000..e52d278
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java
@@ -0,0 +1,411 @@
+/*
+ * 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 org.apache.olingo.ext.pojogen;
+
+import java.io.InputStream;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmAction;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmFunction;
+import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
+import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
+import org.apache.olingo.commons.api.edm.EdmParameter;
+import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.edm.EdmSchema;
+import org.apache.olingo.commons.api.edm.EdmSingleton;
+import org.apache.olingo.commons.api.edm.EdmStructuredType;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
+
+public abstract class AbstractUtility {
+
+ protected static final String FC_TARGET_PATH = "fcTargetPath";
+
+ protected static final String FC_SOURCE_PATH = "fcSourcePath";
+
+ protected static final String FC_KEEP_IN_CONTENT = "fcKeepInContent";
+
+ protected static final String FC_CONTENT_KIND = "fcContentKind";
+
+ protected static final String FC_NS_PREFIX = "fcNSPrefix";
+
+ protected static final String FC_NS_URI = "fcNSURI";
+
+ protected static final String TYPE_SUB_PKG = "types";
+
+ protected final String basePackage;
+
+ protected final String schemaName;
+
+ protected final String namespace;
+
+ private final Edm metadata;
+
+ private final EdmSchema schema;
+
+ protected final Map<String, List<EdmEntityType>> allEntityTypes = new HashMap<String, List<EdmEntityType>>();
+
+ public AbstractUtility(final Edm metadata, final EdmSchema schema, final String basePackage) {
+ this.basePackage = basePackage;
+ this.schemaName = schema.getAlias();
+ this.namespace = schema.getNamespace();
+ this.metadata = metadata;
+ this.schema = schema;
+
+ collectEntityTypes();
+ }
+
+ public EdmTypeInfo getEdmTypeInfo(final EdmType type) {
+ return new EdmTypeInfo.Builder().setEdm(metadata).
+ setTypeExpression(type.getFullQualifiedName().toString()).build();
+ }
+
+ public EdmTypeInfo getEdmTypeInfo(final String expression) {
+ return new EdmTypeInfo.Builder().setEdm(metadata).setTypeExpression(expression).build();
+ }
+
+ public EdmTypeInfo getEdmType(final EdmSingleton singleton) {
+ return getEdmTypeInfo(singleton.getEntityType().getFullQualifiedName().toString());
+ }
+
+ public Map<String, String> getEntityKeyType(final EdmSingleton singleton) {
+ return getEntityKeyType(singleton.getEntityType());
+ }
+
+ protected Edm getMetadata() {
+ return metadata;
+ }
+
+ protected EdmSchema getSchema() {
+ return schema;
+ }
+
+ public String getNavigationType(final EdmNavigationProperty property) {
+ return property.getType().getFullQualifiedName().toString();
+ }
+
+ public NavPropertyBindingDetails getNavigationBindingDetails(
+ final EdmStructuredType sourceEntityType, final EdmNavigationProperty property) {
+ if (property.containsTarget()) {
+ return new NavPropertyContainsTarget(metadata, property.getType());
+ }
+
+ try {
+ return getNavigationBindings(sourceEntityType, property);
+ } catch (Exception e) {
+ // maybe source entity type without entity set ...
+ return getNavigationBindings(property.getType());
+ }
+ }
+
+ private NavPropertyBindingDetails getNavigationBindings(final EdmStructuredType type) {
+ if (type == null) {
+ throw new IllegalStateException("Invalid navigation property");
+ }
+
+ try {
+ return new NavPropertyBindingDetails(metadata, type);
+ } catch (IllegalStateException ignore) {
+ return getNavigationBindings(type.getBaseType());
+ }
+ }
+
+ private NavPropertyBindingDetails getNavigationBindings(
+ final EdmStructuredType sourceEntityType, final EdmNavigationProperty property) {
+
+ if (sourceEntityType == null) {
+ throw new IllegalStateException("Invalid navigation property " + property.getName());
+ }
+
+ try {
+ return new NavPropertyBindingDetails(metadata, sourceEntityType, property);
+ } catch (IllegalStateException ignore) {
+ return getNavigationBindingDetails(sourceEntityType.getBaseType(), property);
+ }
+ }
+
+ public EdmFunction getFunctionByName(final FullQualifiedName name) {
+
+ final EdmSchema targetSchema = metadata.getSchema(name.getNamespace());
+
+ if (targetSchema != null) {
+ for (EdmFunction function : targetSchema.getFunctions()) {
+ if (function.getName().equals(name.getName())) {
+ return function;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public EdmAction getActionByName(final FullQualifiedName name) {
+
+ final EdmSchema targetSchema = metadata.getSchema(name.getNamespace());
+
+ if (targetSchema != null) {
+ for (EdmAction action : targetSchema.getActions()) {
+ if (action.getName().equals(name.getName())) {
+ return action;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public List<EdmFunction> getFunctionsBoundTo(final String typeExpression, final boolean collection) {
+
+ final List<EdmFunction> result = new ArrayList<EdmFunction>();
+
+ for (EdmSchema sch : getMetadata().getSchemas()) {
+ for (EdmFunction function : sch.getFunctions()) {
+ if (function.isBound()) {
+ final EdmParameter bound = function.getParameterNames().isEmpty()
+ ? null : function.getParameter(function.getParameterNames().get(0));
+
+ if (bound != null
+ && isSameType(typeExpression, bound.getType().getFullQualifiedName().toString(), false)
+ && ((bound.isCollection() && collection) || (!bound.isCollection() && !collection))) {
+ result.add(function);
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public List<EdmAction> getActionsBoundTo(final String typeExpression, final boolean collection) {
+
+ final List<EdmAction> result = new ArrayList<EdmAction>();
+
+ for (EdmSchema sch : getMetadata().getSchemas()) {
+ for (EdmAction action : sch.getActions()) {
+ if (action.isBound()) {
+ final EdmParameter bound = action.getParameterNames().isEmpty()
+ ? null : action.getParameter(action.getParameterNames().get(0));
+
+ if (bound != null
+ && isSameType(typeExpression, bound.getType().getFullQualifiedName().toString(), false)
+ && ((bound.isCollection() && collection) || (!bound.isCollection() && !collection))) {
+ result.add(action);
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private void collectEntityTypes() {
+ for (EdmSchema _schema : getMetadata().getSchemas()) {
+ allEntityTypes.put(_schema.getNamespace(), new ArrayList<EdmEntityType>(_schema.getEntityTypes()));
+ if (StringUtils.isNotBlank(_schema.getAlias())) {
+ allEntityTypes.put(_schema.getAlias(), new ArrayList<EdmEntityType>(_schema.getEntityTypes()));
+ }
+ }
+ }
+
+ public String getJavaType(final EdmType type, final Boolean forceCollection) {
+ return getJavaType(type.getFullQualifiedName().toString(), forceCollection);
+ }
+
+ public String getJavaType(final EdmType type) {
+ return getJavaType(type, false);
+ }
+
+ public String getJavaType(final EdmEntityType entityType, final Boolean forceCollection) {
+ return getJavaType(entityType.getFullQualifiedName().toString(), forceCollection);
+ }
+
+ public String getJavaType(final EdmEntityType entityType) {
+ return getJavaType(entityType, false);
+ }
+
+ public String getJavaType(final String typeExpression) {
+ return getJavaType(typeExpression, false);
+ }
+
+ public String getJavaType(final String typeExpression, final boolean forceCollection) {
+ final StringBuilder res = new StringBuilder();
+
+ final EdmTypeInfo edmType = getEdmTypeInfo(typeExpression);
+
+ if ((forceCollection || edmType.isCollection()) && !edmType.isEntityType()) {
+ res.append("Collection<");
+ }
+
+ if ("Edm.Stream".equals(typeExpression)) {
+ res.append(InputStream.class.getName());
+ } else if (edmType.isPrimitiveType()) {
+ final Class<?> clazz = EdmPrimitiveTypeFactory.getInstance(edmType.getPrimitiveTypeKind()).getDefaultType();
+ res.append((clazz.isAssignableFrom(Calendar.class) ? Timestamp.class : clazz).getSimpleName());
+ } else if (edmType.isComplexType()) {
+ res.append(basePackage).append('.').
+ append(edmType.getFullQualifiedName().getNamespace().toLowerCase()). // namespace
+ append('.').append(TYPE_SUB_PKG).append('.').
+ append(capitalize(edmType.getComplexType().getName())); // ComplexType capitalized name
+ } else if (edmType.isEntityType()) {
+ res.append(basePackage).append('.').
+ append(edmType.getFullQualifiedName().getNamespace().toLowerCase()). // namespace
+ append('.').append(TYPE_SUB_PKG).append('.').
+ append(capitalize(edmType.getEntityType().getName())); // EntityType capitalized name
+ } else if (edmType.isEnumType()) {
+ res.append(basePackage).append('.').
+ append(edmType.getFullQualifiedName().getNamespace().toLowerCase()). // namespace
+ append('.').append(TYPE_SUB_PKG).append('.').
+ append(capitalize(edmType.getEnumType().getName()));
+ } else {
+ throw new IllegalArgumentException("Invalid type expression '" + typeExpression + "'");
+ }
+
+ if (forceCollection || edmType.isCollection()) {
+ if (edmType.isEntityType()) {
+ res.append("Collection");
+ } else {
+ res.append(">");
+ }
+ }
+
+ return res.toString();
+ }
+
+ public EdmTypeInfo getEdmType(final EdmEntitySet entitySet) {
+ return getEdmTypeInfo(entitySet.getEntityType().getFullQualifiedName().toString());
+ }
+
+ public Map<String, String> getEntityKeyType(final EdmEntitySet entitySet) {
+ return getEntityKeyType(getEdmType(entitySet).getEntityType());
+ }
+
+ public Map<String, String> getEntityKeyType(final EdmEntityType entityType) {
+ EdmEntityType baseType = entityType;
+ while (CollectionUtils.isEmpty(baseType.getKeyPredicateNames()) && baseType.getBaseType() != null) {
+ baseType = getEdmTypeInfo(baseType.getBaseType().getFullQualifiedName().toString()).getEntityType();
+ }
+
+ final Map<String, String> res = new HashMap<String, String>();
+ for (EdmKeyPropertyRef pref : baseType.getKeyPropertyRefs()) {
+ res.put(pref.getKeyPropertyName(),
+ getJavaType(pref.getProperty().getType().getFullQualifiedName().toString()));
+ }
+
+ return res;
+ }
+
+ public final String getNameInNamespace(final String name) {
+ return getSchema().getNamespace() + "." + name;
+ }
+
+ public boolean isSameType(
+ final String entityTypeExpression, final String fullTypeExpression, final boolean collection) {
+
+ final Set<String> types = new HashSet<String>(2);
+
+ types.add((collection ? "Collection(" : StringUtils.EMPTY)
+ + getNameInNamespace(entityTypeExpression)
+ + (collection ? ")" : StringUtils.EMPTY));
+ if (StringUtils.isNotBlank(getSchema().getAlias())) {
+ types.add((collection ? "Collection(" : StringUtils.EMPTY)
+ + getSchema().getAlias() + "." + entityTypeExpression
+ + (collection ? ")" : StringUtils.EMPTY));
+ }
+
+ return types.contains(fullTypeExpression);
+ }
+
+ private void populateDescendants(final EdmTypeInfo base, final List<String> descendants) {
+ for (Map.Entry<String, List<EdmEntityType>> entry : allEntityTypes.entrySet()) {
+ for (EdmEntityType type : entry.getValue()) {
+ if (type.getBaseType() != null
+ && base.getFullQualifiedName().equals(type.getBaseType().getFullQualifiedName())) {
+
+ final EdmTypeInfo entityTypeInfo = getEdmTypeInfo(type.getFullQualifiedName().toString());
+
+ descendants.add(entityTypeInfo.getFullQualifiedName().toString());
+ populateDescendants(entityTypeInfo, descendants);
+ }
+ }
+ }
+ }
+
+ public List<String> getDescendantsOrSelf(final EdmTypeInfo entityType) {
+ final List<String> descendants = new ArrayList<String>();
+
+ descendants.add(entityType.getFullQualifiedName().toString());
+ populateDescendants(entityType, descendants);
+
+ return descendants;
+ }
+
+ public String getBasePackage() {
+ return basePackage;
+ }
+
+ public String getSchemaName() {
+ return schemaName;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public String capitalize(final String str) {
+ return StringUtils.capitalize(str);
+ }
+
+ public String uncapitalize(final String str) {
+ return StringUtils.uncapitalize(str);
+ }
+
+ public Map<String, String> getFcProperties(final EdmProperty property) {
+ return Collections.<String, String>emptyMap();
+ }
+
+ public final String getNameFromNS(final String ns) {
+ return getNameFromNS(ns, false);
+ }
+
+ public final String getNameFromNS(final String ns, final boolean toLowerCase) {
+ String res = null;
+
+ if (StringUtils.isNotBlank(ns)) {
+ final int lastpt = ns.lastIndexOf('.');
+ res = ns.substring(lastpt < 0 ? 0 : lastpt + 1);
+ res = toLowerCase ? res.toLowerCase() : res;
+ }
+
+ return res;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/NavPropertyBindingDetails.java
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/NavPropertyBindingDetails.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/NavPropertyBindingDetails.java
new file mode 100644
index 0000000..27555bc
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/NavPropertyBindingDetails.java
@@ -0,0 +1,141 @@
+/*
+ * 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 org.apache.olingo.ext.pojogen;
+
+import org.apache.olingo.client.api.v3.UnsupportedInV3Exception;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmBindingTarget;
+import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
+import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding;
+import org.apache.olingo.commons.api.edm.EdmSchema;
+import org.apache.olingo.commons.api.edm.EdmSingleton;
+import org.apache.olingo.commons.api.edm.EdmStructuredType;
+
+public class NavPropertyBindingDetails {
+
+ protected Edm edm;
+
+ protected EdmSchema schema;
+
+ protected EdmEntityContainer container;
+
+ protected EdmBindingTarget entitySet;
+
+ protected EdmStructuredType type;
+
+ protected NavPropertyBindingDetails() {
+ }
+
+ public NavPropertyBindingDetails(final Edm edm, final EdmStructuredType type) {
+ this.edm = edm;
+ this.type = type;
+ this.entitySet = getNavigationBindingDetails(type);
+ this.container = this.entitySet.getEntityContainer();
+ this.schema = edm.getSchema(container.getNamespace());
+ }
+
+ public NavPropertyBindingDetails(
+ final Edm edm, final EdmStructuredType sourceType, final EdmNavigationProperty property) {
+ this.edm = edm;
+ this.entitySet = getNavigationBindingDetails(sourceType, property);
+ this.container = this.entitySet.getEntityContainer();
+ this.schema = edm.getSchema(container.getNamespace());
+ this.type = entitySet.getEntityType();
+ }
+
+ private EdmBindingTarget getNavigationBindingDetails(final EdmStructuredType type) {
+ for (EdmSchema sc : edm.getSchemas()) {
+ for (EdmEntityContainer c : sc.getEntityContainers()) {
+ for (EdmEntitySet es : c.getEntitySets()) {
+ if (es.getEntityType().getFullQualifiedName().equals(type.getFullQualifiedName())) {
+ return es;
+ }
+ }
+
+ try {
+ for (EdmSingleton s : c.getSingletons()) {
+ if (s.getEntityType().getFullQualifiedName().equals(type.getFullQualifiedName())) {
+ return s;
+ }
+ }
+ } catch (UnsupportedInV3Exception ignore) {
+ // ignore
+ }
+ }
+
+ }
+
+ throw new IllegalStateException("EntitySet for '" + type.getName() + "' not found");
+ }
+
+ private EdmBindingTarget getNavigationBindingDetails(
+ final EdmStructuredType sourceType, final EdmNavigationProperty property) {
+
+ for (EdmSchema sc : edm.getSchemas()) {
+ for (EdmEntityContainer c : sc.getEntityContainers()) {
+ for (EdmEntitySet es : c.getEntitySets()) {
+ if (es.getEntityType().getFullQualifiedName().equals(sourceType.getFullQualifiedName())) {
+ for (EdmNavigationPropertyBinding binding : es.getNavigationPropertyBindings()) {
+ if (binding.getPath().equals(property.getName())
+ || binding.getPath().endsWith("/" + property.getName())) {
+ return es.getRelatedBindingTarget(binding.getPath());
+ }
+ }
+ }
+ }
+
+ try {
+ for (EdmSingleton s : c.getSingletons()) {
+ if (s.getEntityType().getFullQualifiedName().equals(sourceType.getFullQualifiedName())) {
+ for (EdmNavigationPropertyBinding binding : s.getNavigationPropertyBindings()) {
+ if (binding.getPath().equals(property.getName())
+ || binding.getPath().endsWith("/" + property.getName())) {
+ return s.getRelatedBindingTarget(binding.getPath());
+ }
+ }
+ }
+ }
+ } catch (UnsupportedInV3Exception ignore) {
+ // ignore
+ }
+ }
+ }
+
+ throw new IllegalStateException(
+ "Navigation property '" + sourceType.getName() + "." + property.getName() + "' not valid");
+ }
+
+ public EdmSchema getSchema() {
+ return schema;
+ }
+
+ public EdmEntityContainer getContainer() {
+ return container;
+ }
+
+ public EdmBindingTarget getEntitySet() {
+ return entitySet;
+ }
+
+ public EdmStructuredType getType() {
+ return type;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/NavPropertyContainsTarget.java
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/NavPropertyContainsTarget.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/NavPropertyContainsTarget.java
new file mode 100644
index 0000000..54ce6fe
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/NavPropertyContainsTarget.java
@@ -0,0 +1,34 @@
+/*
+ * 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 org.apache.olingo.ext.pojogen;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+
+public class NavPropertyContainsTarget extends NavPropertyBindingDetails {
+
+ public NavPropertyContainsTarget(final Edm edm, final EdmEntityType type) {
+ super();
+ this.edm = edm;
+ this.entitySet = null;
+ this.container = null;
+ this.type = type;
+ schema = edm.getSchema(type.getNamespace());
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V3MetadataMojo.java
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V3MetadataMojo.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V3MetadataMojo.java
new file mode 100644
index 0000000..acd9f75
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V3MetadataMojo.java
@@ -0,0 +1,184 @@
+/*
+ * 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 org.apache.olingo.ext.pojogen;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmComplexType;
+import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.EdmSchema;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+/**
+ * POJOs generator.
+ */
+@Mojo(name = "pojosV3", defaultPhase = LifecyclePhase.PROCESS_SOURCES)
+public class V3MetadataMojo extends AbstractMetadataMojo {
+
+ @Override
+ protected V3Utility getUtility() {
+ return (V3Utility) utility;
+ }
+
+ @Override
+ protected String getVersion() {
+ return ODataServiceVersion.V30.name().toLowerCase();
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException {
+ if (new File(outputDirectory + File.separator + TOOL_DIR).exists()) {
+ getLog().info("Nothing to do because " + TOOL_DIR + " directory already exists. Clean to update.");
+ return;
+ }
+
+ try {
+ Velocity.addProperty(Velocity.RESOURCE_LOADER, "class");
+ Velocity.addProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName());
+
+ final Edm metadata =
+ ODataClientFactory.getV3().getRetrieveRequestFactory().getMetadataRequest(serviceRootURL).execute().
+ getBody();
+
+ if (metadata == null) {
+ throw new IllegalStateException("Metadata not found");
+ }
+
+ for (EdmSchema schema : metadata.getSchemas()) {
+ namespaces.add(schema.getNamespace().toLowerCase());
+ }
+
+ final Set<String> complexTypeNames = new HashSet<String>();
+ final File services = mkdir("META-INF/services");
+
+ for (EdmSchema schema : metadata.getSchemas()) {
+ utility = new V3Utility(metadata, schema, basePackage);
+
+ // write package-info for the base package
+ final String schemaPath = utility.getNamespace().toLowerCase().replace('.', File.separatorChar);
+ final File base = mkPkgDir(schemaPath);
+ final String pkg = basePackage + "." + utility.getNamespace().toLowerCase();
+ parseObj(base, pkg, "package-info", "package-info.java");
+
+ // write package-info for types package
+ final File typesBaseDir = mkPkgDir(schemaPath + "/types");
+ final String typesPkg = pkg + ".types";
+ parseObj(typesBaseDir, typesPkg, "package-info", "package-info.java");
+
+ final Map<String, Object> objs = new HashMap<String, Object>();
+
+ // write types into types package
+ for (EdmEnumType enumType : schema.getEnumTypes()) {
+ final String className = utility.capitalize(enumType.getName());
+ objs.clear();
+ objs.put("enumType", enumType);
+ parseObj(typesBaseDir, typesPkg, "enumType", className + ".java", objs);
+ }
+
+ for (EdmComplexType complex : schema.getComplexTypes()) {
+ final String className = utility.capitalize(complex.getName());
+ complexTypeNames.add(typesPkg + "." + className);
+ objs.clear();
+ objs.put("complexType", complex);
+ parseObj(typesBaseDir, typesPkg, "complexType", className + ".java", objs);
+ }
+
+ for (EdmEntityType entity : schema.getEntityTypes()) {
+ objs.clear();
+ objs.put("entityType", entity);
+
+ final Map<String, String> keys;
+
+ EdmEntityType baseType = null;
+ if (entity.getBaseType() == null) {
+ keys = getUtility().getEntityKeyType(entity);
+ } else {
+ baseType = entity.getBaseType();
+ objs.put("baseType", getUtility().getJavaType(baseType.getFullQualifiedName().toString()));
+ while (baseType.getBaseType() != null) {
+ baseType = baseType.getBaseType();
+ }
+ keys = getUtility().getEntityKeyType(baseType);
+ }
+
+ if (keys.size() > 1) {
+ // create compound key class
+ final String keyClassName = utility.capitalize(baseType == null
+ ? entity.getName()
+ : baseType.getName()) + "Key";
+ objs.put("keyRef", keyClassName);
+
+ if (entity.getBaseType() == null) {
+ objs.put("keys", keys);
+ parseObj(typesBaseDir, typesPkg, "entityTypeKey", keyClassName + ".java", objs);
+ }
+ }
+
+ parseObj(typesBaseDir, typesPkg, "entityType",
+ utility.capitalize(entity.getName()) + ".java", objs);
+ parseObj(typesBaseDir, typesPkg, "entityCollection",
+ utility.capitalize(entity.getName()) + "Collection.java", objs);
+ }
+
+ // write container and top entity sets into the base package
+ for (EdmEntityContainer container : schema.getEntityContainers()) {
+ objs.clear();
+ objs.put("container", container);
+ parseObj(base, pkg, "container",
+ utility.capitalize(container.getName()) + ".java", objs);
+
+ for (EdmEntitySet entitySet : container.getEntitySets()) {
+ objs.clear();
+ objs.put("entitySet", entitySet);
+ parseObj(base, pkg, "entitySet",
+ utility.capitalize(entitySet.getName()) + ".java", objs);
+ }
+ }
+
+ parseObj(services, true, null, "services", "org.apache.olingo.ext.proxy.api.AbstractComplexType",
+ Collections.singletonMap("services", (Object) complexTypeNames));
+ }
+ } catch (Exception t) {
+ final StringWriter stringWriter = new StringWriter();
+ final PrintWriter printWriter = new PrintWriter(stringWriter);
+ t.printStackTrace(printWriter);
+ getLog().error(stringWriter.toString());
+
+ throw (t instanceof MojoExecutionException)
+ ? (MojoExecutionException) t
+ : new MojoExecutionException("While executin mojo", t);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V3Utility.java
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V3Utility.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V3Utility.java
new file mode 100644
index 0000000..47c96e5
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V3Utility.java
@@ -0,0 +1,29 @@
+/*
+ * 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 org.apache.olingo.ext.pojogen;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmSchema;
+
+public class V3Utility extends AbstractUtility {
+
+ public V3Utility(final Edm metadata, final EdmSchema schema, final String basePackage) {
+ super(metadata, schema, basePackage);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V4MetadataMojo.java
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V4MetadataMojo.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V4MetadataMojo.java
new file mode 100644
index 0000000..042a558
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V4MetadataMojo.java
@@ -0,0 +1,192 @@
+/*
+ * 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 org.apache.olingo.ext.pojogen;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmComplexType;
+import org.apache.olingo.commons.api.edm.EdmEntityContainer;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.EdmSchema;
+import org.apache.olingo.commons.api.edm.EdmSingleton;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+/**
+ * POJOs generator.
+ */
+@Mojo(name = "pojosV4", defaultPhase = LifecyclePhase.PROCESS_SOURCES)
+public class V4MetadataMojo extends AbstractMetadataMojo {
+
+ @Override
+ protected V4Utility getUtility() {
+ return (V4Utility) utility;
+ }
+
+ @Override
+ protected String getVersion() {
+ return ODataServiceVersion.V40.name().toLowerCase();
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException {
+ if (new File(outputDirectory + File.separator + TOOL_DIR).exists()) {
+ getLog().info("Nothing to do because " + TOOL_DIR + " directory already exists. Clean to update.");
+ return;
+ }
+
+ try {
+ Velocity.addProperty(Velocity.RESOURCE_LOADER, "class");
+ Velocity.addProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName());
+
+ final Edm metadata =
+ ODataClientFactory.getV4().getRetrieveRequestFactory().getMetadataRequest(serviceRootURL).execute().
+ getBody();
+
+ if (metadata == null) {
+ throw new IllegalStateException("Metadata not found");
+ }
+
+ for (EdmSchema schema : metadata.getSchemas()) {
+ namespaces.add(schema.getNamespace().toLowerCase());
+ }
+
+ final Set<String> complexTypeNames = new HashSet<String>();
+ final File services = mkdir("META-INF/services");
+
+ for (EdmSchema schema : metadata.getSchemas()) {
+ utility = new V4Utility(metadata, schema, basePackage);
+
+ // write package-info for the base package
+ final String schemaPath = utility.getNamespace().toLowerCase().replace('.', File.separatorChar);
+ final File base = mkPkgDir(schemaPath);
+ final String pkg = basePackage + "." + utility.getNamespace().toLowerCase();
+ parseObj(base, pkg, "package-info", "package-info.java");
+
+ // write package-info for types package
+ final File typesBaseDir = mkPkgDir(schemaPath + "/types");
+ final String typesPkg = pkg + ".types";
+ parseObj(typesBaseDir, typesPkg, "package-info", "package-info.java");
+
+ final Map<String, Object> objs = new HashMap<String, Object>();
+
+ // write types into types package
+ for (EdmEnumType enumType : schema.getEnumTypes()) {
+ final String className = utility.capitalize(enumType.getName());
+ objs.clear();
+ objs.put("enumType", enumType);
+ parseObj(typesBaseDir, typesPkg, "enumType", className + ".java", objs);
+ }
+
+ for (EdmComplexType complex : schema.getComplexTypes()) {
+ final String className = utility.capitalize(complex.getName());
+ complexTypeNames.add(typesPkg + "." + className);
+ objs.clear();
+ objs.put("complexType", complex);
+ parseObj(typesBaseDir, typesPkg, "complexType", className + ".java", objs);
+ }
+
+ for (EdmEntityType entity : schema.getEntityTypes()) {
+ objs.clear();
+ objs.put("entityType", entity);
+
+ final Map<String, String> keys;
+
+ EdmEntityType baseType = null;
+ if (entity.getBaseType() == null) {
+ keys = getUtility().getEntityKeyType(entity);
+ } else {
+ baseType = entity.getBaseType();
+ objs.put("baseType", getUtility().getJavaType(baseType.getFullQualifiedName().toString()));
+ while (baseType.getBaseType() != null) {
+ baseType = baseType.getBaseType();
+ }
+ keys = getUtility().getEntityKeyType(baseType);
+ }
+
+ if (keys.size() > 1) {
+ // create compound key class
+ final String keyClassName = utility.capitalize(baseType == null
+ ? entity.getName()
+ : baseType.getName()) + "Key";
+ objs.put("keyRef", keyClassName);
+
+ if (entity.getBaseType() == null) {
+ objs.put("keys", keys);
+ parseObj(typesBaseDir, typesPkg, "entityTypeKey", keyClassName + ".java", objs);
+ }
+ }
+
+ parseObj(typesBaseDir, typesPkg, "entityType",
+ utility.capitalize(entity.getName()) + ".java", objs);
+ parseObj(typesBaseDir, typesPkg, "entityCollection",
+ utility.capitalize(entity.getName()) + "Collection.java", objs);
+ }
+
+ // write container and top entity sets into the base package
+ for (EdmEntityContainer container : schema.getEntityContainers()) {
+ objs.clear();
+ objs.put("container", container);
+ parseObj(base, pkg, "container",
+ utility.capitalize(container.getName()) + ".java", objs);
+
+ for (EdmEntitySet entitySet : container.getEntitySets()) {
+ objs.clear();
+ objs.put("entitySet", entitySet);
+ parseObj(base, pkg, "entitySet",
+ utility.capitalize(entitySet.getName()) + ".java", objs);
+ }
+
+ for (EdmSingleton singleton : container.getSingletons()) {
+ objs.clear();
+ objs.put("singleton", singleton);
+ parseObj(base, pkg, "singleton",
+ utility.capitalize(singleton.getName()) + ".java", objs);
+ }
+ }
+
+ parseObj(services, true, null, "services", "org.apache.olingo.ext.proxy.api.AbstractComplexType",
+ Collections.singletonMap("services", (Object) complexTypeNames));
+ }
+ } catch (Exception t) {
+ final StringWriter stringWriter = new StringWriter();
+ final PrintWriter printWriter = new PrintWriter(stringWriter);
+ t.printStackTrace(printWriter);
+ getLog().error(stringWriter.toString());
+
+ throw (t instanceof MojoExecutionException)
+ ? (MojoExecutionException) t
+ : new MojoExecutionException("While executin mojo", t);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V4Utility.java
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V4Utility.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V4Utility.java
new file mode 100644
index 0000000..874e415
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/V4Utility.java
@@ -0,0 +1,29 @@
+/*
+ * 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 org.apache.olingo.ext.pojogen;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmSchema;
+
+public class V4Utility extends AbstractUtility {
+
+ public V4Utility(final Edm metadata, final EdmSchema schema, final String basePackage) {
+ super(metadata, schema, basePackage);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f02d9a07/ext/pojogen-maven-plugin/src/main/resources/complexType.vm
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/resources/complexType.vm b/ext/pojogen-maven-plugin/src/main/resources/complexType.vm
new file mode 100644
index 0000000..683739c
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/main/resources/complexType.vm
@@ -0,0 +1,48 @@
+#*
+ * 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 ${package};
+
+import org.apache.olingo.ext.proxy.api.annotations.Namespace;
+import org.apache.olingo.ext.proxy.api.annotations.ComplexType;
+import org.apache.olingo.ext.proxy.api.annotations.Property;
+import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty;
+#foreach($ns in $namespaces)
+import ${basePackage}.${ns}.*;
+import ${basePackage}.${ns}.types.*;
+#end
+
+// EdmSimpleType property imports
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
+import org.apache.olingo.commons.api.edm.geo.LineString;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
+import org.apache.olingo.commons.api.edm.geo.MultiPoint;
+import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
+import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.Polygon;
+import java.math.BigDecimal;
+import java.net.URI;
+import java.util.UUID;
+import java.io.Serializable;
+import java.util.Collection;
+import java.sql.Timestamp;
+import javax.xml.datatype.Duration;
+
+#parse( "${odataVersion}/complexType.vm" )
+}