Fix line endings in xml for windows machines
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/4966ebed Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/4966ebed Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/4966ebed Branch: refs/heads/Olingo-129_PocJpaDataStore Commit: 4966ebed03eb23fa389ae8be5de9a7d3b86b8607 Parents: fc8c4ff Author: Christian Amend <[email protected]> Authored: Tue Sep 23 14:07:45 2014 +0200 Committer: Christian Amend <[email protected]> Committed: Tue Sep 23 14:07:45 2014 +0200 ---------------------------------------------------------------------- .../extension/SalesOrderHeaderProcessor.java | 272 +++++++++---------- .../webapp/SalesOrderProcessingMappingModel.xml | 84 +++--- 2 files changed, 178 insertions(+), 178 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/4966ebed/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java ---------------------------------------------------------------------- diff --git a/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java index 9a34473..dd72595 100644 --- a/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java +++ b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java @@ -1,136 +1,136 @@ -/******************************************************************************* - * 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.EdmFacets; -import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport; -import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport.HttpMethod; -import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport.ReturnType; -import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport.ReturnType.Type; -import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImportParameter; -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") - @EdmFunctionImport(name = "FindAllSalesOrders", entitySet = "SalesOrders", returnType = @ReturnType( - type = Type.ENTITY, isCollection = true)) - public List<SalesOrderHeader> findAllSalesOrders( - @EdmFunctionImportParameter(name = "DeliveryStatusCode", - facets = @EdmFacets(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; - } - - @EdmFunctionImport(name = "CheckATP", returnType = @ReturnType(type = Type.SIMPLE, isCollection = false), - httpMethod = HttpMethod.GET) - public boolean checkATP( - @EdmFunctionImportParameter(name = "SoID", facets = @EdmFacets(nullable = false)) final Long soID, - @EdmFunctionImportParameter(name = "LiId", facets = @EdmFacets(nullable = false)) final Long lineItemID) { - if (soID == 2L) { - return false; - } else { - return true; - } - } - - @EdmFunctionImport(returnType = @ReturnType(type = Type.ENTITY, isCollection = false), entitySet = "SalesOrders") - public SalesOrderHeader calculateNetAmount( - @EdmFunctionImportParameter(name = "SoID", facets = @EdmFacets(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") - @EdmFunctionImport(returnType = @ReturnType(type = Type.COMPLEX)) - public Address getAddress( - @EdmFunctionImportParameter(name = "SoID", facets = @EdmFacets(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).getCustomer().getAddress(); - } else { - return null; - } - } - - @EdmFunctionImport(returnType = @ReturnType(type = Type.COMPLEX)) - public OrderValue orderValue( - @EdmFunctionImportParameter(name = "SoId", facets = @EdmFacets(nullable = false)) final Long 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()); - } - OrderValue orderValue = new OrderValue(); - orderValue.setAmount(amount); - orderValue.setCurrency(so.getCurrencyCode()); - return orderValue; - } - -} +/******************************************************************************* + * 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.EdmFacets; +import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport; +import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport.HttpMethod; +import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport.ReturnType; +import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport.ReturnType.Type; +import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImportParameter; +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") + @EdmFunctionImport(name = "FindAllSalesOrders", entitySet = "SalesOrders", returnType = @ReturnType( + type = Type.ENTITY, isCollection = true)) + public List<SalesOrderHeader> findAllSalesOrders( + @EdmFunctionImportParameter(name = "DeliveryStatusCode", + facets = @EdmFacets(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; + } + + @EdmFunctionImport(name = "CheckATP", returnType = @ReturnType(type = Type.SIMPLE, isCollection = false), + httpMethod = HttpMethod.GET) + public boolean checkATP( + @EdmFunctionImportParameter(name = "SoID", facets = @EdmFacets(nullable = false)) final Long soID, + @EdmFunctionImportParameter(name = "LiId", facets = @EdmFacets(nullable = false)) final Long lineItemID) { + if (soID == 2L) { + return false; + } else { + return true; + } + } + + @EdmFunctionImport(returnType = @ReturnType(type = Type.ENTITY, isCollection = false), entitySet = "SalesOrders") + public SalesOrderHeader calculateNetAmount( + @EdmFunctionImportParameter(name = "SoID", facets = @EdmFacets(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") + @EdmFunctionImport(returnType = @ReturnType(type = Type.COMPLEX)) + public Address getAddress( + @EdmFunctionImportParameter(name = "SoID", facets = @EdmFacets(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).getCustomer().getAddress(); + } else { + return null; + } + } + + @EdmFunctionImport(returnType = @ReturnType(type = Type.COMPLEX)) + public OrderValue orderValue( + @EdmFunctionImportParameter(name = "SoId", facets = @EdmFacets(nullable = false)) final Long 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()); + } + OrderValue orderValue = new OrderValue(); + orderValue.setAmount(amount); + orderValue.setCurrency(so.getCurrencyCode()); + return orderValue; + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/4966ebed/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml ---------------------------------------------------------------------- diff --git a/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml b/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml index 2d7f7c7..50afd7e 100644 --- a/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml +++ b/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml @@ -8,37 +8,37 @@ 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/jpa/processor/api/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> + language governing permissions and limitations under the License. --> +<JPAEDMMappingModel + xmlns="http://www.apache.org/olingo/odata2/jpa/processor/api/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> - <JPAAttribute name="Material_Id">mID</JPAAttribute> - </JPAAttributes> - <JPARelationships> - <JPARelationship name="salesOrderHeader">SalesOrderHeaderDetails</JPARelationship> - <JPARelationship name="materials">MaterialDetails</JPARelationship> - </JPARelationships> + <JPAAttribute name="Material_Id">mID</JPAAttribute> + </JPAAttributes> + <JPARelationships> + <JPARelationship name="salesOrderHeader">SalesOrderHeaderDetails</JPARelationship> + <JPARelationship name="materials">MaterialDetails</JPARelationship> + </JPARelationships> </JPAEntityType> <JPAEntityType name="EmailActivity"> <EDMEntityType>Email</EDMEntityType> @@ -47,16 +47,16 @@ <JPAEntityType name="AppointmentActivity"> <EDMEntityType>Appointment</EDMEntityType> <EDMEntitySet>Appointments</EDMEntitySet> - </JPAEntityType> - </JPAEntityTypes> - <JPAEmbeddableTypes> - <JPAEmbeddableType name="Address"> - <EDMComplexType>AddressInfo</EDMComplexType> - <JPAAttributes> - <JPAAttribute name="houseNumber">Number</JPAAttribute> - <JPAAttribute name="streetName">Street</JPAAttribute> - </JPAAttributes> - </JPAEmbeddableType> - </JPAEmbeddableTypes> - </PersistenceUnit> + </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
