Back to project page SalesOrder.
The source code is released under:
GNU General Public License
If you think the Android project SalesOrder listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.capgemini.SalesOrder.zgwsample_srv.v0; // w ww. j a va 2 s. co m /* Auto-Generated by SAP NetWeaver Gateway Productivity Accelerator, Version 1.1.1 */ import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URLEncoder; import java.util.LinkedList; import java.util.List; import android.content.res.Resources.NotFoundException; import com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.BusinessPartner; import com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.Contact; import com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.Product; import com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.SalesOrder; import com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.SalesOrderLineItem; import com.sap.gwpa.proxy.ODataQuery; import com.sap.mobile.lib.configuration.IPreferences; import com.sap.mobile.lib.configuration.Preferences; import com.sap.mobile.lib.configuration.PreferencesException; import com.sap.mobile.lib.parser.IODataEntry; import com.sap.mobile.lib.parser.IODataSchema; import com.sap.mobile.lib.parser.IODataServiceDocument; import com.sap.mobile.lib.parser.IParser; import com.sap.mobile.lib.parser.Parser; import com.sap.mobile.lib.parser.ParserException; import com.sap.mobile.lib.supportability.ILogger; import com.sap.mobile.lib.supportability.Logger; /** * ZGWSAMPLE_SRVService Proxy Class * <br> * <br>Service Version: v0. */ public class ZGWSAMPLE_SRVService { private String baseUrl; private ILogger logger; private IPreferences preferences; private IParser parser; private IODataServiceDocument serviceDocument; private IODataSchema schema; /** * Constructs a new service (proxy) class, with the given parameters. * @param context - application context. * @param aServiceDocument - service document. * @param aServiceMetadata - service metadata. */ public ZGWSAMPLE_SRVService(android.content.Context context, String aServiceDocument, String aServiceMetadata) { initISDMParameters(context); parseServiceDocumentAndMetadata(context, aServiceDocument, aServiceMetadata); } /** * Constructs a new service (proxy) class, with the given parameter. * @param context - application context. */ public ZGWSAMPLE_SRVService(android.content.Context context) { this(context, null, null); } /* * Parses the service document and metadata. */ private void parseServiceDocumentAndMetadata(android.content.Context context, String aServiceDocument, String aServiceMetadata) { try { if (aServiceDocument == null || aServiceMetadata == null) { serviceDocument = parser.parseODataServiceDocument(context.getResources().openRawResource(com.capgemini.SalesOrder.R.raw.zgwsample_srvv0document)); schema = parser.parseODataSchema(context.getResources().openRawResource(com.capgemini.SalesOrder.R.raw.zgwsample_srvv0metadata),serviceDocument); } else { serviceDocument = parser.parseODataServiceDocument(aServiceDocument); schema = parser.parseODataSchema(aServiceMetadata,serviceDocument); } setUrl(serviceDocument.getBaseUrl()); loadLabels(); } catch (NotFoundException e) { throw new ExceptionInInitializerError(e); } catch (IllegalArgumentException e) { throw new ExceptionInInitializerError(e); } catch (ParserException e) { throw new ExceptionInInitializerError(e); } } private void initISDMParameters(android.content.Context context) { logger = new Logger(); preferences = new Preferences(context, logger); try { preferences.setBooleanPreference(IPreferences.PERSISTENCE_SECUREMODE, false); parser = new Parser(preferences, logger); } catch (PreferencesException e) { throw new ExceptionInInitializerError(e); } catch (ParserException e) { throw new ExceptionInInitializerError(e); } } /** * Returns the parser of this proxy class. * @return IParser. */ public IParser getParser() { return this.parser; } /** * Returns the service document. * @return - IODataServiceDocument. */ public IODataServiceDocument getServiceDocument() { return this.serviceDocument; } /** * Returns the schema of the service. * @return - IODataSchema. */ public IODataSchema getSchema() { return this.schema; } /** * Returns the base URL of the service. * @return - the base URL of the service. */ public String getBaseUrl() { return this.baseUrl; } /** * Sets the base URL of the service. * @param url - the url to set. */ public void setUrl(String url) { if (url.endsWith("/")) { baseUrl = url; } else { baseUrl = url + "/"; } } /** * Loads the labels for each entity type. * This method is called by the class initialisers. */ public void loadLabels() { SalesOrderLineItem.loadLabels(this.serviceDocument); BusinessPartner.loadLabels(this.serviceDocument); Contact.loadLabels(this.serviceDocument); SalesOrder.loadLabels(this.serviceDocument); Product.loadLabels(this.serviceDocument); } // service collections /** * @return - the SalesOrderLineItemCollectionQuery * @throws - MalformedURLException */ public ODataQuery getSalesOrderLineItemCollectionQuery() throws MalformedURLException { return new ODataQuery(getBaseUrl() + "SalesOrderLineItemCollection"); } /** * @return - the BusinessPartnerCollectionQuery * @throws - MalformedURLException */ public ODataQuery getBusinessPartnerCollectionQuery() throws MalformedURLException { return new ODataQuery(getBaseUrl() + "BusinessPartnerCollection"); } /** * @return - the ContactCollectionQuery * @throws - MalformedURLException */ public ODataQuery getContactCollectionQuery() throws MalformedURLException { return new ODataQuery(getBaseUrl() + "ContactCollection"); } /** * @return - the SalesOrderCollectionQuery * @throws - MalformedURLException */ public ODataQuery getSalesOrderCollectionQuery() throws MalformedURLException { return new ODataQuery(getBaseUrl() + "SalesOrderCollection"); } /** * @return - the ProductCollectionQuery * @throws - MalformedURLException */ public ODataQuery getProductCollectionQuery() throws MalformedURLException { return new ODataQuery(getBaseUrl() + "ProductCollection"); } /** * SalesOrderLineItemCollectionQuery with Key * * @throws MalformedURLException */ public ODataQuery getSalesOrderLineItemCollectionEntryQuery( String SoItemPos, String SoId) throws MalformedURLException, UnsupportedEncodingException { SoItemPos = URLEncoder.encode(SoItemPos, "UTF-8"); SoId = URLEncoder.encode(SoId, "UTF-8"); return new ODataQuery(getBaseUrl() + "SalesOrderLineItemCollection("+"SoItemPos='"+SoItemPos+"',SoId='"+SoId+"')"); } /** * BusinessPartnerCollectionQuery with Key * * @throws MalformedURLException */ public ODataQuery getBusinessPartnerCollectionEntryQuery( String BusinessPartnerID) throws MalformedURLException, UnsupportedEncodingException { BusinessPartnerID = URLEncoder.encode(BusinessPartnerID, "UTF-8"); return new ODataQuery(getBaseUrl() + "BusinessPartnerCollection("+"BusinessPartnerID='"+BusinessPartnerID+"')"); } /** * ContactCollectionQuery with Key * * @throws MalformedURLException */ public ODataQuery getContactCollectionEntryQuery( String BusinessPartnerID, String Title, String FirstName, String MiddleName, String LastName, String PostalCode, String City, String Street, String Building, String Country, String AddressType) throws MalformedURLException, UnsupportedEncodingException { BusinessPartnerID = URLEncoder.encode(BusinessPartnerID, "UTF-8"); Title = URLEncoder.encode(Title, "UTF-8"); FirstName = URLEncoder.encode(FirstName, "UTF-8"); MiddleName = URLEncoder.encode(MiddleName, "UTF-8"); LastName = URLEncoder.encode(LastName, "UTF-8"); PostalCode = URLEncoder.encode(PostalCode, "UTF-8"); City = URLEncoder.encode(City, "UTF-8"); Street = URLEncoder.encode(Street, "UTF-8"); Building = URLEncoder.encode(Building, "UTF-8"); Country = URLEncoder.encode(Country, "UTF-8"); AddressType = URLEncoder.encode(AddressType, "UTF-8"); return new ODataQuery(getBaseUrl() + "ContactCollection("+"BusinessPartnerID='"+BusinessPartnerID+"',Title='"+Title+"',FirstName='"+FirstName+"',MiddleName='"+MiddleName+"',LastName='"+LastName+"',PostalCode='"+PostalCode+"',City='"+City+"',Street='"+Street+"',Building='"+Building+"',Country='"+Country+"',AddressType='"+AddressType+"')"); } /** * SalesOrderCollectionQuery with Key * * @throws MalformedURLException */ public ODataQuery getSalesOrderCollectionEntryQuery( String SoId) throws MalformedURLException, UnsupportedEncodingException { SoId = URLEncoder.encode(SoId, "UTF-8"); return new ODataQuery(getBaseUrl() + "SalesOrderCollection("+"SoId='"+SoId+"')"); } /** * ProductCollectionQuery with Key * * @throws MalformedURLException */ public ODataQuery getProductCollectionEntryQuery( String ProductId) throws MalformedURLException, UnsupportedEncodingException { ProductId = URLEncoder.encode(ProductId, "UTF-8"); return new ODataQuery(getBaseUrl() + "ProductCollection("+"ProductId='"+ProductId+"')"); } /** * @return - the SalesOrderLineItemCollection * @throws - ParserException * @throws - MalformedURLException */ public List<SalesOrderLineItem> getSalesOrderLineItemCollection(String data) throws ParserException, MalformedURLException { List<SalesOrderLineItem> returnList = new LinkedList<SalesOrderLineItem>(); List<IODataEntry> list = parser.parseODataEntries(data, "SalesOrderLineItemCollection", schema); for (IODataEntry isdmoDataEntry : list) { returnList.add(new SalesOrderLineItem(isdmoDataEntry, parser, schema)); } return returnList; } /** * @return - the BusinessPartnerCollection * @throws - ParserException * @throws - MalformedURLException */ public List<BusinessPartner> getBusinessPartnerCollection(String data) throws ParserException, MalformedURLException { List<BusinessPartner> returnList = new LinkedList<BusinessPartner>(); List<IODataEntry> list = parser.parseODataEntries(data, "BusinessPartnerCollection", schema); for (IODataEntry isdmoDataEntry : list) { returnList.add(new BusinessPartner(isdmoDataEntry, parser, schema)); } return returnList; } /** * @return - the ContactCollection * @throws - ParserException * @throws - MalformedURLException */ public List<Contact> getContactCollection(String data) throws ParserException, MalformedURLException { List<Contact> returnList = new LinkedList<Contact>(); List<IODataEntry> list = parser.parseODataEntries(data, "ContactCollection", schema); for (IODataEntry isdmoDataEntry : list) { returnList.add(new Contact(isdmoDataEntry, parser, schema)); } return returnList; } /** * @return - the SalesOrderCollection * @throws - ParserException * @throws - MalformedURLException */ public List<SalesOrder> getSalesOrderCollection(String data) throws ParserException, MalformedURLException { List<SalesOrder> returnList = new LinkedList<SalesOrder>(); List<IODataEntry> list = parser.parseODataEntries(data, "SalesOrderCollection", schema); for (IODataEntry isdmoDataEntry : list) { returnList.add(new SalesOrder(isdmoDataEntry, parser, schema)); } return returnList; } /** * @return - the ProductCollection * @throws - ParserException * @throws - MalformedURLException */ public List<Product> getProductCollection(String data) throws ParserException, MalformedURLException { List<Product> returnList = new LinkedList<Product>(); List<IODataEntry> list = parser.parseODataEntries(data, "ProductCollection", schema); for (IODataEntry isdmoDataEntry : list) { returnList.add(new Product(isdmoDataEntry, parser, schema)); } return returnList; } /** * @return - SalesOrderLineItem when sending the key of SalesOrderLineItem * @throws - ParserException * @throws MalformedURLException */ public SalesOrderLineItem getSalesOrderLineItemCollectionEntry(String data) throws ParserException, MalformedURLException { List<IODataEntry> list = parser.parseODataEntries(data, "SalesOrderLineItemCollection", schema); return new SalesOrderLineItem(list.get(0), parser, schema); } /** * @return - BusinessPartner when sending the key of BusinessPartner * @throws - ParserException * @throws MalformedURLException */ public BusinessPartner getBusinessPartnerCollectionEntry(String data) throws ParserException, MalformedURLException { List<IODataEntry> list = parser.parseODataEntries(data, "BusinessPartnerCollection", schema); return new BusinessPartner(list.get(0), parser, schema); } /** * @return - Contact when sending the key of Contact * @throws - ParserException * @throws MalformedURLException */ public Contact getContactCollectionEntry(String data) throws ParserException, MalformedURLException { List<IODataEntry> list = parser.parseODataEntries(data, "ContactCollection", schema); return new Contact(list.get(0), parser, schema); } /** * @return - SalesOrder when sending the key of SalesOrder * @throws - ParserException * @throws MalformedURLException */ public SalesOrder getSalesOrderCollectionEntry(String data) throws ParserException, MalformedURLException { List<IODataEntry> list = parser.parseODataEntries(data, "SalesOrderCollection", schema); return new SalesOrder(list.get(0), parser, schema); } /** * @return - Product when sending the key of Product * @throws - ParserException * @throws MalformedURLException */ public Product getProductCollectionEntry(String data) throws ParserException, MalformedURLException { List<IODataEntry> list = parser.parseODataEntries(data, "ProductCollection", schema); return new Product(list.get(0), parser, schema); } }