You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2013/09/04 17:08:53 UTC
git commit: JPA reference scenario Phase 1
Updated Branches:
refs/heads/master d343d3f21 -> b7e9f394f
JPA reference scenario Phase 1
Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/commit/b7e9f394
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/b7e9f394
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/b7e9f394
Branch: refs/heads/master
Commit: b7e9f394f900ce06344ef4d4caf8587a391addd3
Parents: d343d3f
Author: Chandan V A <ch...@sap.com>
Authored: Wed Sep 4 20:38:26 2013 +0530
Committer: Chandan V A <ch...@sap.com>
Committed: Wed Sep 4 20:38:26 2013 +0530
----------------------------------------------------------------------
jpa-ref/.gitignore | 8 +
jpa-ref/pom.xml | 69 +++++++
.../ref/factory/JPAEntityManagerFactory.java | 47 +++++
.../odata2/jpa/processor/ref/model/Address.java | 83 ++++++++
.../jpa/processor/ref/model/Material.java | 116 ++++++++++++
.../odata2/jpa/processor/ref/model/Note.java | 116 ++++++++++++
.../processor/ref/model/SalesOrderHeader.java | 188 +++++++++++++++++++
.../jpa/processor/ref/model/SalesOrderItem.java | 133 +++++++++++++
.../processor/ref/model/SalesOrderItemKey.java | 89 +++++++++
.../odata2/jpa/processor/ref/model/Store.java | 92 +++++++++
.../src/main/resources/META-INF/persistence.xml | 46 +++++
jpa-web/.gitignore | 8 +
jpa-web/pom.xml | 134 +++++++++++++
.../extension/SalesOrderHeaderProcessor.java | 124 ++++++++++++
.../SalesOrderProcessingExtension.java | 38 ++++
.../ref/web/JPAReferenceServiceFactory.java | 44 +++++
.../webapp/SalesOrderProcessingMappingModel.xml | 62 ++++++
jpa-web/src/main/webapp/WEB-INF/web.xml | 47 +++++
jpa-web/src/main/webapp/index.jsp | 23 +++
19 files changed, 1467 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-ref/.gitignore
----------------------------------------------------------------------
diff --git a/jpa-ref/.gitignore b/jpa-ref/.gitignore
new file mode 100644
index 0000000..fe5d89b
--- /dev/null
+++ b/jpa-ref/.gitignore
@@ -0,0 +1,8 @@
+.project
+.classpath
+.settings
+target
+bin
+*.bak
+classes
+.DS_Store
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-ref/pom.xml
----------------------------------------------------------------------
diff --git a/jpa-ref/pom.xml b/jpa-ref/pom.xml
new file mode 100644
index 0000000..9148258
--- /dev/null
+++ b/jpa-ref/pom.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<!--
+ 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
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.olingo.odata2</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>jpa.processor.ref</artifactId>
+ <packaging>jar</packaging>
+ <name>${project.groupId}-${project.artifactId}</name>
+
+ <dependencies>
+ <!-- JPA Support -->
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>eclipselink</artifactId>
+ <version>2.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>javax.persistence</artifactId>
+ <version>2.0.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.10</version>
+ </dependency>
+
+ <!-- OData Annotation Support -->
+ <dependency>
+ <groupId>org.apache.olingo.odata2</groupId>
+ <artifactId>api.annotation</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- JUnits -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/factory/JPAEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/factory/JPAEntityManagerFactory.java b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/factory/JPAEntityManagerFactory.java
new file mode 100644
index 0000000..688d125
--- /dev/null
+++ b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/factory/JPAEntityManagerFactory.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.ref.factory;
+
+import java.util.HashMap;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+public class JPAEntityManagerFactory {
+ private static HashMap<String, EntityManagerFactory> emfMap;
+
+ public static EntityManagerFactory getEntityManagerFactory(final String pUnit) {
+ if (pUnit == null) {
+ return null;
+ }
+ if (emfMap == null) {
+ emfMap = new HashMap<String, EntityManagerFactory>();
+ }
+
+ if (emfMap.containsKey(pUnit)) {
+ return emfMap.get(pUnit);
+ } else
+ {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(pUnit);
+ emfMap.put(pUnit, emf);
+ return emf;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Address.java
----------------------------------------------------------------------
diff --git a/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Address.java b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Address.java
new file mode 100644
index 0000000..d7a5ea0
--- /dev/null
+++ b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Address.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.ref.model;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class Address {
+
+ public Address() {
+ super();
+ }
+
+ public Address(final short houseNumber, final String streetName, final String city,
+ final String country) {
+ this();
+ this.houseNumber = houseNumber;
+ this.streetName = streetName;
+ this.city = city;
+ this.country = country;
+ }
+
+ @Column(name = "HOUSE_NUMBER")
+ private short houseNumber;
+
+ @Column(name = "STREET_NAME")
+ private String streetName;
+
+ @Column(name = "CITY")
+ private String city;
+
+ @Column(name = "COUNTRY")
+ private String country;
+
+ public short getHouseNumber() {
+ return houseNumber;
+ }
+
+ public void setHouseNumber(final short houseNumber) {
+ this.houseNumber = houseNumber;
+ }
+
+ public String getStreetName() {
+ return streetName;
+ }
+
+ public void setStreetName(final String streetName) {
+ this.streetName = streetName;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(final String city) {
+ this.city = city;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(final String country) {
+ this.country = country;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Material.java
----------------------------------------------------------------------
diff --git a/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Material.java b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Material.java
new file mode 100644
index 0000000..a34f240
--- /dev/null
+++ b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Material.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.ref.model;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "T_MATERIAL")
+public class Material {
+
+ public Material() {}
+
+ public Material(final String materialName, final String typeCode, final double price,
+ final String measurementUnit) {
+ super();
+ this.materialName = materialName;
+ this.typeCode = typeCode;
+ this.price = price;
+ this.measurementUnit = measurementUnit;
+ }
+
+ @Id
+ @Column(name = "MATERIAL_ID")
+ private long materialId;
+
+ @Column(name = "MATERIAL_NAME")
+ private String materialName;
+
+ @Column(name = "TYPE_CODE")
+ private String typeCode;
+
+ @Column(name = "PRICE")
+ private double price;
+
+ @Column(name = "MEASUREMENT_UNIT")
+ private String measurementUnit;
+
+ @ManyToMany
+ private List<Store> stores = new ArrayList<Store>();
+
+ public long getMaterialId() {
+ return materialId;
+ }
+
+ public void setMaterialId(final long materialId) {
+ this.materialId = materialId;
+ }
+
+ public String getMaterialName() {
+ return materialName;
+ }
+
+ public void setMaterialName(final String materialName) {
+ this.materialName = materialName;
+ }
+
+ public String getTypeCode() {
+ return typeCode;
+ }
+
+ public void setTypeCode(final String typeCode) {
+ this.typeCode = typeCode;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(final double price) {
+ this.price = price;
+ }
+
+ public String getMeasurementUnit() {
+ return measurementUnit;
+ }
+
+ public void setMeasurementUnit(final String measurementUnit) {
+ this.measurementUnit = measurementUnit;
+ }
+
+ public List<Store> getStores() {
+ return stores;
+ }
+
+ public void setStores(final List<Store> stores) {
+ this.stores = stores;
+ Iterator<Store> itr = stores.iterator();
+ while (itr.hasNext()) {
+ itr.next().getMaterials().add(this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Note.java
----------------------------------------------------------------------
diff --git a/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Note.java b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Note.java
new file mode 100644
index 0000000..ea09511
--- /dev/null
+++ b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Note.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.ref.model;
+
+import java.util.Calendar;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+@Table(name = "T_NOTE")
+public class Note {
+
+ public Note() {}
+
+ public Note(final Calendar creationTime, final Calendar creationDate, final String createdBy,
+ final String text) {
+ super();
+ this.creationTime = creationTime;
+ this.creationDate = creationDate;
+ this.createdBy = createdBy;
+ this.text = text;
+ }
+
+ @Id
+ @Temporal(TemporalType.TIME)
+ private Calendar creationTime;
+
+ @Id
+ @Temporal(TemporalType.DATE)
+ private Calendar creationDate;
+
+ @Id
+ private String createdBy;
+
+ @Column
+ private String text;
+
+ @Column(name = "SO_ID")
+ private long soId;
+
+ @JoinColumn(name = "SO_ID", referencedColumnName = "SO_ID", insertable = false, updatable = false)
+ @ManyToOne
+ private SalesOrderHeader salesOrderHeader;
+
+ public Calendar getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(final Calendar creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Calendar getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(final Calendar creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+ public void setCreatedBy(final String createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(final String text) {
+ this.text = text;
+ }
+
+ public long getSoId() {
+ return soId;
+ }
+
+ public void setSoId(final long soId) {
+ this.soId = soId;
+ }
+
+ public SalesOrderHeader getSalesOrderHeader() {
+ return salesOrderHeader;
+ }
+
+ public void setSalesOrderHeader(final SalesOrderHeader salesOrderHeader) {
+ this.salesOrderHeader = salesOrderHeader;
+ this.salesOrderHeader.getNotes().add(this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderHeader.java
----------------------------------------------------------------------
diff --git a/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderHeader.java b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderHeader.java
new file mode 100644
index 0000000..2b034c4
--- /dev/null
+++ b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderHeader.java
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.ref.model;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+@Table(name = "T_SALESORDERHEADER")
+public class SalesOrderHeader {
+
+ public SalesOrderHeader() {}
+
+ public SalesOrderHeader(final Calendar creationDate, final int buyerId, final String buyerName,
+ final Address buyerAddress, final String currencyCode, final double netAmount,
+ final String deliveryStatus) {
+ super();
+ this.creationDate = creationDate;
+ this.buyerId = buyerId;
+ this.buyerName = buyerName;
+ this.buyerAddress = buyerAddress;
+ this.currencyCode = currencyCode;
+ this.deliveryStatus = deliveryStatus;
+ }
+
+ @Id
+ @Column(name = "SO_ID")
+ private long soId;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ private Calendar creationDate;
+
+ @Column(name = "BUYER_ID")
+ private int buyerId;
+
+ @Column(name = "BUYER_NAME", length = 255)
+ private String buyerName;
+
+ @Embedded
+ private Address buyerAddress;
+
+ @Column(name = "CURRENCY_CODE", length = 3)
+ private String currencyCode;
+
+ @Column(name = "DELIVERY_STATUS", length = 2)
+ private String deliveryStatus;
+
+ @Column(precision = 5)
+ private double grossAmount;
+
+ @Column(precision = 8)
+ private double netAmount;
+
+ @OneToMany(mappedBy = "salesOrderHeader", cascade = CascadeType.ALL)
+ private List<SalesOrderItem> salesOrderItem = new ArrayList<SalesOrderItem>();
+
+ @OneToMany(mappedBy = "salesOrderHeader", cascade = CascadeType.ALL)
+ private List<Note> notes = new ArrayList<Note>();
+
+ public long getSoId() {
+ return soId;
+ }
+
+ public void setSoId(final long soId) {
+ this.soId = soId;
+ }
+
+ public Date getCreationDate() {
+ if (creationDate == null) {
+ return null;
+ }
+ long dbTime = creationDate.getTime().getTime();
+ Date originalDate = new Date(dbTime + TimeZone.getDefault().getOffset(dbTime));
+ return originalDate;
+ }
+
+ public void setCreationDate(final Calendar creationDate) {
+ if (creationDate == null) {
+ return;
+ }
+ long originalTime = creationDate.getTime().getTime();
+ Date newDate = new Date(originalTime - TimeZone.getDefault().getOffset(originalTime));
+ Calendar newCalendar = Calendar.getInstance();
+ newCalendar.setTime(newDate);
+ this.creationDate = newCalendar;
+ }
+
+ public int getBuyerId() {
+ return buyerId;
+ }
+
+ public void setBuyerId(final int buyerId) {
+ this.buyerId = buyerId;
+ }
+
+ public String getBuyerName() {
+ return buyerName;
+ }
+
+ public void setBuyerName(final String buyerName) {
+ this.buyerName = buyerName;
+ }
+
+ public Address getBuyerAddress() {
+ return buyerAddress;
+ }
+
+ public void setBuyerAddress(final Address buyerAddress) {
+ this.buyerAddress = buyerAddress;
+ }
+
+ public String getCurrencyCode() {
+ return currencyCode;
+ }
+
+ public void setCurrencyCode(final String currencyCode) {
+ this.currencyCode = currencyCode;
+ }
+
+ public String getDeliveryStatus() {
+ return deliveryStatus;
+ }
+
+ public void setDeliveryStatus(final String deliveryStatus) {
+ this.deliveryStatus = deliveryStatus;
+ }
+
+ public double getGrossAmount() {
+ return grossAmount;
+ }
+
+ public void setGrossAmount(final double grossAmount) {
+ this.grossAmount = grossAmount;
+ }
+
+ public double getNetAmount() {
+ return netAmount;
+ }
+
+ public void setNetAmount(final double netAmount) {
+ this.netAmount = netAmount;
+ }
+
+ public List<SalesOrderItem> getSalesOrderItem() {
+ return salesOrderItem;
+ }
+
+ public void setSalesOrderItem(final List<SalesOrderItem> salesOrderItem) {
+ this.salesOrderItem = salesOrderItem;
+ }
+
+ public List<Note> getNotes() {
+ return notes;
+ }
+
+ public void setNotes(final List<Note> notes) {
+ this.notes = notes;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItem.java
----------------------------------------------------------------------
diff --git a/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItem.java b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItem.java
new file mode 100644
index 0000000..07eb6e6
--- /dev/null
+++ b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItem.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.ref.model;
+
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+@Entity
+@Table(name = "T_SALESORDERITEM")
+public class SalesOrderItem {
+
+ public SalesOrderItem() {}
+
+ public SalesOrderItem(final int quantity, final double amount, final double discount,
+ final Material material) {
+ super();
+ this.quantity = quantity;
+ this.amount = amount;
+ this.discount = discount;
+ this.material = material;
+ }
+
+ @EmbeddedId
+ private SalesOrderItemKey salesOrderItemKey;
+
+ @Column(name = "Material_Id", nullable = false)
+ private long matId;
+
+ @Column
+ private int quantity;
+
+ @Column
+ private double amount;
+
+ @Column
+ private double discount;
+
+ @Transient
+ private double netAmount;
+
+ @JoinColumn(name = "Material_Id", referencedColumnName = "MATERIAL_ID", insertable = false, updatable = false)
+ @ManyToOne
+ private Material material;
+
+ @JoinColumn(name = "Sales_Order_Id", referencedColumnName = "SO_ID", insertable = false, updatable = false)
+ @ManyToOne
+ private SalesOrderHeader salesOrderHeader;
+
+ public SalesOrderItemKey getSalesOrderItemKey() {
+ return salesOrderItemKey;
+ }
+
+ public void setSalesOrderItemKey(final SalesOrderItemKey salesOrderItemKey) {
+ this.salesOrderItemKey = salesOrderItemKey;
+ }
+
+ public long getMatId() {
+ return matId;
+ }
+
+ public void setMatId(final long matId) {
+ this.matId = matId;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(final int quantity) {
+ this.quantity = quantity;
+ }
+
+ public double getAmount() {
+ return amount;
+ }
+
+ public void setAmount(final double amount) {
+ this.amount = amount;
+ }
+
+ public double getDiscount() {
+ return discount;
+ }
+
+ public void setDiscount(final double discount) {
+ this.discount = discount;
+ }
+
+ public double getNetAmount() {
+ return netAmount;
+ }
+
+ public void setNetAmount(final double netAmount) {
+ this.netAmount = netAmount;
+ }
+
+ public Material getMaterial() {
+ return material;
+ }
+
+ public void setMaterial(final Material material) {
+ this.material = material;
+ }
+
+ public SalesOrderHeader getSalesOrderHeader() {
+ return salesOrderHeader;
+ }
+
+ public void setSalesOrderHeader(final SalesOrderHeader salesOrderHeader) {
+ this.salesOrderHeader = salesOrderHeader;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItemKey.java
----------------------------------------------------------------------
diff --git a/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItemKey.java b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItemKey.java
new file mode 100644
index 0000000..f4bc895
--- /dev/null
+++ b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItemKey.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.ref.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class SalesOrderItemKey implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public SalesOrderItemKey() {}
+
+ public SalesOrderItemKey(final long liId) {
+ super();
+ this.liId = liId;
+ }
+
+ @Column(name = "Sales_Order_Id", nullable = false)
+ private long soId;
+
+ @Column(name = "Sales_Order_Item_Id", unique = true)
+ private long liId;
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (liId ^ (liId >>> 32));
+ result = prime * result + (int) (soId ^ (soId >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ SalesOrderItemKey other = (SalesOrderItemKey) obj;
+ if (liId != other.liId) {
+ return false;
+ }
+ if (soId != other.soId) {
+ return false;
+ }
+ return true;
+ }
+
+ public long getSoId() {
+ return soId;
+ }
+
+ public void setSoId(final long soId) {
+ this.soId = soId;
+ }
+
+ public long getLiId() {
+ return liId;
+ }
+
+ public void setLiId(final long liId) {
+ this.liId = liId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Store.java
----------------------------------------------------------------------
diff --git a/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Store.java b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Store.java
new file mode 100644
index 0000000..95c2625
--- /dev/null
+++ b/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Store.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.ref.model;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "T_STORE")
+public class Store {
+
+ public Store() {}
+
+ public Store(final String storeName, final Address storeAddress) {
+ super();
+ this.storeName = storeName;
+ this.storeAddress = storeAddress;
+ }
+
+ @Id
+ @Column(name = "STORE_ID")
+ private long storeId;
+
+ @Column(name = "STORE_NAME", unique = true)
+ private String storeName;
+
+ @Embedded
+ private Address storeAddress;
+
+ @ManyToMany(mappedBy = "stores")
+ private List<Material> materials = new ArrayList<Material>();
+
+ public long getStoreId() {
+ return storeId;
+ }
+
+ public void setStoreId(final long storeId) {
+ this.storeId = storeId;
+ }
+
+ public String getStoreName() {
+ return storeName;
+ }
+
+ public void setStoreName(final String storeName) {
+ this.storeName = storeName;
+ }
+
+ public Address getStoreAddress() {
+ return storeAddress;
+ }
+
+ public void setStoreAddress(final Address storeAddress) {
+ this.storeAddress = storeAddress;
+ }
+
+ public List<Material> getMaterials() {
+ return materials;
+ }
+
+ public void setMaterials(final List<Material> materials) {
+ this.materials = materials;
+ Iterator<Material> itr = materials.iterator();
+ while (itr.hasNext()) {
+ itr.next().getStores().add(this);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-ref/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/jpa-ref/src/main/resources/META-INF/persistence.xml b/jpa-ref/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..f1a102f
--- /dev/null
+++ b/jpa-ref/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,46 @@
+<?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.
+-->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="salesorderprocessing"
+ transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <class>org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderHeader</class>
+ <class>org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderItem</class>
+ <class>org.apache.olingo.odata2.jpa.processor.ref.model.Note</class>
+ <class>org.apache.olingo.odata2.jpa.processor.ref.model.Material</class>
+ <class>org.apache.olingo.odata2.jpa.processor.ref.model.Store</class>
+ <properties>
+ <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" />
+ <property name="javax.persistence.jdbc.url"
+ value="jdbc:hsqldb:mem:org.apache.olingo.jpa.sample" />
+ <property name="javax.persistence.jdbc.user" value="sa" />
+ <property name="javax.persistence.jdbc.password" value="" />
+ <property name="eclipselink.target-database"
+ value="org.eclipse.persistence.platform.database.HSQLPlatform" />
+ <property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.orm.throw.exceptions" value="true" />
+ <property name="eclipselink.ddl-generation" value="create-tables" />
+ <property name="eclipselink.ddl-generation.output-mode"
+ value="database" />
+ </properties>
+ </persistence-unit>
+</persistence>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-web/.gitignore
----------------------------------------------------------------------
diff --git a/jpa-web/.gitignore b/jpa-web/.gitignore
new file mode 100644
index 0000000..fe5d89b
--- /dev/null
+++ b/jpa-web/.gitignore
@@ -0,0 +1,8 @@
+.project
+.classpath
+.settings
+target
+bin
+*.bak
+classes
+.DS_Store
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-web/pom.xml
----------------------------------------------------------------------
diff --git a/jpa-web/pom.xml b/jpa-web/pom.xml
new file mode 100644
index 0000000..9c81ef7
--- /dev/null
+++ b/jpa-web/pom.xml
@@ -0,0 +1,134 @@
+<?xml version="1.0"?>
+<!--
+ 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
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>jpa.processor.ref.web</artifactId>
+ <packaging>war</packaging>
+ <name>${project.groupId}-${project.artifactId}</name>
+
+ <parent>
+ <groupId>org.apache.olingo.odata2</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/version</directory>
+ <filtering>true</filtering>
+ <targetPath>../${project.build.finalName}/gen</targetPath>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <groupId>com.sap.research</groupId>
+ <artifactId>nwcloud-maven-plugin</artifactId>
+ <version>1.0.0.RELEASE</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+
+ <dependencies>
+ <dependency>
+ <!-- required because of auto detection of web facet 2.5 -->
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.olingo.odata2</groupId>
+ <artifactId>ref</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.olingo.odata2</groupId>
+ <artifactId>core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.olingo.odata2</groupId>
+ <artifactId>jpa.processor.api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.olingo.odata2</groupId>
+ <artifactId>jpa.processor.core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.olingo.odata2</groupId>
+ <artifactId>jpa.processor.ref</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>dev</id>
+
+ <build>
+ <defaultGoal>cargo:run</defaultGoal>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>1.4.2</version>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
----------------------------------------------------------------------
diff --git a/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java b/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
new file mode 100644
index 0000000..71e29d8
--- /dev/null
+++ b/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.ref.extension;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+import org.apache.olingo.odata2.api.annotation.edm.Facets;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.Multiplicity;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.ReturnType;
+import org.apache.olingo.odata2.api.annotation.edm.Parameter;
+import org.apache.olingo.odata2.api.annotation.edm.Parameter.Mode;
+import org.apache.olingo.odata2.api.annotation.edmx.HttpMethod;
+import org.apache.olingo.odata2.api.annotation.edmx.HttpMethod.Name;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.jpa.processor.ref.model.Address;
+import org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderHeader;
+import org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderItem;
+
+public class SalesOrderHeaderProcessor {
+
+ private EntityManager em;
+
+ public SalesOrderHeaderProcessor() {
+ em = Persistence.createEntityManagerFactory("salesorderprocessing")
+ .createEntityManager();
+ }
+
+ @SuppressWarnings("unchecked")
+ @FunctionImport(name = "FindAllSalesOrders", entitySet = "SalesOrders", returnType = ReturnType.ENTITY_TYPE, multiplicity = Multiplicity.MANY)
+ public List<SalesOrderHeader> findAllSalesOrders(
+ @Parameter(name = "DeliveryStatusCode", facets = @Facets(maxLength = 2)) final String status) {
+
+ Query q = em
+ .createQuery("SELECT E1 from SalesOrderHeader E1 WHERE E1.deliveryStatus = '"
+ + status + "'");
+ List<SalesOrderHeader> soList = (List<SalesOrderHeader>) q
+ .getResultList();
+ return soList;
+ }
+
+ @FunctionImport(name = "CheckATP", returnType = ReturnType.SCALAR, multiplicity = Multiplicity.ONE, httpMethod = @HttpMethod(name = Name.GET))
+ public boolean checkATP(
+ @Parameter(name = "SoID", facets = @Facets(nullable = false), mode = Mode.IN) final Long soID,
+ @Parameter(name = "LiId", facets = @Facets(nullable = false), mode = Mode.IN) final Long lineItemID) {
+ if (soID == 2L) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ @FunctionImport(returnType = ReturnType.ENTITY_TYPE, entitySet = "SalesOrders")
+ public SalesOrderHeader calculateNetAmount(
+ @Parameter(name = "SoID", facets = @Facets(nullable = false)) final Long soID)
+ throws ODataException {
+
+ if (soID <= 0L) {
+ throw new ODataException("Invalid SoID");
+ }
+
+ Query q = em
+ .createQuery("SELECT E1 from SalesOrderHeader E1 WHERE E1.soId = "
+ + soID + "l");
+ if (q.getResultList().isEmpty()) {
+ return null;
+ }
+ SalesOrderHeader so = (SalesOrderHeader) q.getResultList().get(0);
+ double amount = 0;
+ for (SalesOrderItem soi : so.getSalesOrderItem()) {
+ amount = amount
+ + (soi.getAmount() * soi.getDiscount() * soi.getQuantity());
+ }
+ so.setNetAmount(amount);
+ return so;
+ }
+
+ @SuppressWarnings("unchecked")
+ @FunctionImport(returnType = ReturnType.COMPLEX_TYPE)
+ public Address getAddress(
+ @Parameter(name = "SoID", facets = @Facets(nullable = false)) final Long soID) {
+ Query q = em
+ .createQuery("SELECT E1 from SalesOrderHeader E1 WHERE E1.soId = "
+ + soID + "l");
+ List<SalesOrderHeader> soList = (List<SalesOrderHeader>) q
+ .getResultList();
+ if (!soList.isEmpty()) {
+ return soList.get(0).getBuyerAddress();
+ } else {
+ return null;
+ }
+ }
+
+ /*
+ * This method will not be transformed into Function Import Function Import
+ * with return type as void is not supported yet.
+ */
+ @FunctionImport(returnType = ReturnType.NONE)
+ public void process(
+ @Parameter(name = "SoID", facets = @Facets(nullable = false)) final Long soID) {
+ return;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderProcessingExtension.java
----------------------------------------------------------------------
diff --git a/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderProcessingExtension.java b/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderProcessingExtension.java
new file mode 100644
index 0000000..de73088
--- /dev/null
+++ b/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderProcessingExtension.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.ref.extension;
+
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+
+public class SalesOrderProcessingExtension implements JPAEdmExtension {
+
+ @Override
+ public void extendJPAEdmSchema(final JPAEdmSchemaView arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void extendWithOperation(final JPAEdmSchemaView view) {
+ view.registerOperations(SalesOrderHeaderProcessor.class, null);
+
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
----------------------------------------------------------------------
diff --git a/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java b/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
new file mode 100644
index 0000000..ac4638e
--- /dev/null
+++ b/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.odata2.jpa.processor.ref.web;
+
+import org.apache.olingo.odata2.jpa.processor.ref.extension.SalesOrderProcessingExtension;
+import org.apache.olingo.odata2.jpa.processor.ref.factory.JPAEntityManagerFactory;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAServiceFactory;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
+
+public class JPAReferenceServiceFactory extends ODataJPAServiceFactory {
+ private static final String PUNIT_NAME = "salesorderprocessing";
+ private static final String MAPPING_MODEL = "SalesOrderProcessingMappingModel.xml";
+
+ @Override
+ public ODataJPAContext initializeODataJPAContext()
+ throws ODataJPARuntimeException {
+ ODataJPAContext oDataJPAContext = getODataJPAContext();
+ oDataJPAContext.setEntityManagerFactory(JPAEntityManagerFactory.getEntityManagerFactory(PUNIT_NAME));
+ oDataJPAContext.setPersistenceUnitName(PUNIT_NAME);
+ oDataJPAContext.setJPAEdmMappingModel(MAPPING_MODEL);
+ oDataJPAContext
+ .setJPAEdmExtension((JPAEdmExtension) new SalesOrderProcessingExtension());
+
+ return oDataJPAContext;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml
----------------------------------------------------------------------
diff --git a/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml b/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml
new file mode 100644
index 0000000..5e49189
--- /dev/null
+++ b/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml
@@ -0,0 +1,62 @@
+<?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.
+-->
+<JPAEDMMappingModel
+ xmlns="http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping">
+ <PersistenceUnit name="salesorderprocessing">
+ <EDMSchemaNamespace>SalesOrderProcessing</EDMSchemaNamespace>
+ <JPAEntityTypes>
+ <JPAEntityType name="SalesOrderHeader">
+ <EDMEntityType>SalesOrder</EDMEntityType>
+ <EDMEntitySet>SalesOrders</EDMEntitySet>
+ <JPAAttributes>
+ <JPAAttribute name="soId">ID</JPAAttribute>
+ <JPAAttribute name="netAmount">NetAmount</JPAAttribute>
+ <JPAAttribute name="buyerAddress">BuyerAddressInfo</JPAAttribute>
+ </JPAAttributes>
+ <JPARelationships>
+ <JPARelationship name="salesOrderItem">SalesOrderLineItemDetails</JPARelationship>
+ <JPARelationship name="notes">NotesDetails</JPARelationship>
+ </JPARelationships>
+ </JPAEntityType>
+ <JPAEntityType name="SalesOrderItem">
+ <EDMEntityType>SalesOrderLineItem</EDMEntityType>
+ <EDMEntitySet>SalesOrderLineItems</EDMEntitySet>
+ <JPAAttributes>
+ <JPAAttribute name="liId">ID</JPAAttribute>
+ <JPAAttribute name="soId">SalesOrderID</JPAAttribute>
+ </JPAAttributes>
+ <JPARelationships>
+ <JPARelationship name="salesOrderHeader">SalesOrderHeaderDetails</JPARelationship>
+ <JPARelationship name="materials">MaterialDetails</JPARelationship>
+ </JPARelationships>
+ </JPAEntityType>
+
+ </JPAEntityTypes>
+ <JPAEmbeddableTypes>
+ <JPAEmbeddableType name="Address">
+ <EDMComplexType>AddressInfo</EDMComplexType>
+ <JPAAttributes>
+ <JPAAttribute name="houseNumber">Number</JPAAttribute>
+ <JPAAttribute name="streetName">Street</JPAAttribute>
+ </JPAAttributes>
+ </JPAEmbeddableType>
+ </JPAEmbeddableTypes>
+ </PersistenceUnit>
+</JPAEDMMappingModel>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-web/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/jpa-web/src/main/webapp/WEB-INF/web.xml b/jpa-web/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..df2bba0
--- /dev/null
+++ b/jpa-web/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,47 @@
+<?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.
+-->
+
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ id="WebApp_ID" version="2.5">
+ <display-name>OData - JPA Reference</display-name>
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+
+ <servlet>
+ <servlet-name>JPARefScenarioServlet</servlet-name>
+ <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
+ <init-param>
+ <param-name>javax.ws.rs.Application</param-name>
+ <param-value>org.apache.olingo.odata2.core.rest.app.ODataApplication</param-value>
+ </init-param>
+ <init-param>
+ <param-name>org.apache.olingo.odata2.service.factory</param-name>
+ <param-value>org.apache.olingo.odata2.jpa.processor.ref.web.JPAReferenceServiceFactory</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>JPARefScenarioServlet</servlet-name>
+ <url-pattern>/SalesOrderProcessing.svc/*</url-pattern>
+ </servlet-mapping>
+</web-app>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/b7e9f394/jpa-web/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/jpa-web/src/main/webapp/index.jsp b/jpa-web/src/main/webapp/index.jsp
new file mode 100644
index 0000000..6cf39d8
--- /dev/null
+++ b/jpa-web/src/main/webapp/index.jsp
@@ -0,0 +1,23 @@
+<!--
+ 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.
+-->
+<html>
+<body>
+<h2><a href="/SalesOrderProcessing.svc?$format=xm">Service Document</a></h2>
+</body>
+</html>