2022

Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Understanding AppCode and its Usage

Introduction


This document explains the concept of AppCode and how it can be used to build DBSync Adapters
The following step by step story board explains the following:
1: What is AppCode ?
2: How to write an AppCode project and create an AppCode Service ?
3. How to write a test case for an AppCode Service?
4: How to build and deploy an AppCode project on dbsync2 ?
5: How to use it in dbsync profiles and execute a process flow?

Pre-Requisites


  1. JDK 7
  2. Eclipse IDE (Enterprise developers)
  3. Local DBSync setup

StoryBoard


  1. Create a new Java Project in Eclipse IDE




  1. Now add the dbysnc-sdk.jar in the dependencies lib folder and other necessary jar files







  1. Now add the jars to the project dependencies class path and configure the build path in eclipse by using "Add Jars" button and then adding the jars present in the lib folder






  1. Now create your main AppCode Implementation class.


Note : Each AppCode implementation must implement com.appmashups.appcode.AppCode interface




  1. Now implement the default methods exposed by the AppCode interface


5.1 Open – Method called , from the JavaAdapter to initialize the adaper resources if any so that the latter can be used during the sync operation
5.2 Close – Method called by JavaAdapter to close the AppCode service and release its resources if it is holding up any

5.3 setContext – Utility method exposed to allow Java Adapter to set the context with the necessary properties






  1. Now see an example of how we have implemented app-code for MSNav.




  1. Please note that before we start writing any reader or writer methods in the app code service we need to import the SOAP WSDL classes into the project for being able to access the necessary entities and their fields and mappings


For this we can make use of the build script "appcode-deploy,xml" which is checked in under msnav2013 module under dbsync2_1 project in the CVS repository. The same needs to be copied into the "appcode-build" folder under the project




  1. Now change the relevant values in the appcode-deploy.xml file to point to the relevant locations and set the necessary properties



<!-- set global properties for this build -->
<!-- Setup Deployment specific properties -->
<property name="appcode.name" value="MyTestMsNavSvc" />
– The name of the appcode project —
<property name="appcode" location="/AvankiaWS2/MyAppCodeSvc"/>
— The location of the appcode project in your machine —
<property name="environment" value="sandbox" />
— The environment under which the jars will be deployed in dbsync2 ( folder under the profile folder) —
<property name="profile" value="profile_test" />
---- Name of the profile ----
<property name="dbsync.server.url" value="http://localhost:8080/dbsync2"/>
— DBSync2 server URL -----
<property name="dbsync.server.username" value="localhost@avankia.com"/>
— DBSync2 UID ----
<property name="dbsync.server.password" value="avankia"/>
---- DBsync2 Password —
Note: The DBSync2 Properties are actually required to deploy the zip file in DBSync2 server location which the DBSync2 server is running

  1. Assuming we are trying to do a a SOAP call in our AppCode Service implementation, we need to run a wsimport task to download the binding classes into our project and for future use for reading, writing and getmetadata operations















<span style="color: #800000"><!-- Additional properties to pass the wsdl filenames --></span>
<span style="color: #000080"><property</span> <span style="color: #000080">name=</span><span style="color: #008000">"customer_wsdl"</span> <span style="color: #000080">value=</span><span style="color: #008000">"Customer.wsdl"</span><span style="color: #000080">></span> <span style="color: #000080"></property></span>
<span style="color: #000080"><property</span> <span style="color: #000080">name=</span><span style="color: #008000">"salesinv_wsdl"</span> <span style="color: #000080">value=</span><span style="color: #008000">"SalesInvoice.wsdl"</span><span style="color: #000080">></span> </property>
<span style="color: #800000"><!-- added for running wsimport --></span>
<span style="color: #000080"><property</span> <span style="color: #000080">name=</span><span style="color: #008000">"java_home"</span> <span style="color: #000080">value=</span><span style="color: #008000">"/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home"</span><span style="color: #000080">/></span>

<span style="color: #000080"><target</span> <span style="color: #000080">name=</span><span style="color: #008000">"wsimport"</span> <span style="color: #000080">depends=</span><span style="color: #008000">"init"</span><span style="color: #000080">></span>
<span style="color: #000080"><exec</span> <span style="color: #000080">executable=</span><span style="color: #008000">"$

Unknown macro: {java_home}

/bin/wsimport"</span><span style="color: #000080">></span>
<span style="color: #000080"><arg</span> <span style="color: #000080">line=</span><span style="color: #008000">"-keep -s $

Unknown macro: {appcode}

/generated-src -d $

/generated-classes $

Unknown macro: {appcode}

/$

Unknown macro: {customer_wsdl}

"</span><span style="color: #000080">/></span>
<span style="color: #000080"></exec></span>
<span style="color: #000080"><exec</span> <span style="color: #000080">executable=</span><span style="color: #008000">"$

/bin/wsimport"</span><span style="color: #000080">></span>
<span style="color: #000080"><arg</span> <span style="color: #000080">line=</span><span style="color: #008000">"-keep -s $

Unknown macro: {appcode}

/generated-src -d $

/generated-classes $

Unknown macro: {appcode}

/$

Unknown macro: {salesinv_wsdl}

"</span><span style="color: #000080">/></span>
<span style="color: #000080"></exec></span>
<span style="color: #000080"><jar</span> <span style="color: #000080">destfile=</span><span style="color: #008000">"$

Unknown macro: {appcode.lib}

/generatedwsdlclasses.jar"</span> <span style="color: #000080">basedir=</span><span style="color: #008000">"$

/generated-classes"</span><span style="color: #000080">/></span>
<span style="color: #000080"></target></span>

<span style="color: #000080"><target</span> <span style="color: #000080">name=</span><span style="color: #008000">"init"</span><span style="color: #000080">></span>
<span style="color: #800000"><!-- Create the time stamp --></span>
<span style="color: #000080"><tstamp/></span>
<span style="color: #000080"><mkdir</span> <span style="color: #000080">dir=</span><span style="color: #008000">"$

Unknown macro: {deploy.dir}

"</span><span style="color: #000080">/></span>
<span style="color: #000080"><mkdir</span> <span style="color: #000080">dir=</span><span style="color: #008000">"$

Unknown macro: {compile.dir}

"</span><span style="color: #000080">/></span>
<span style="color: #000080"><mkdir</span> <span style="color: #000080">dir=</span><span style="color: #008000">"$

/zip"</span><span style="color: #000080">/></span>
<span style="color: #800000"><!-- add src and target files --></span>
<span style="color: #000080"><delete</span> <span style="color: #000080">dir=</span><span style="color: #008000">"$

Unknown macro: {appcode}

/generated-src"</span><span style="color: #000080">/></span>
<span style="color: #000080"><delete</span> <span style="color: #000080">dir=</span><span style="color: #008000">"$

/generated-classes"</span><span style="color: #000080">/></span>
<span style="color: #000080"><mkdir</span> <span style="color: #000080">dir=</span><span style="color: #008000">"$

Unknown macro: {appcode}

/generated-src"</span><span style="color: #000080">/></span>
<span style="color: #000080"><mkdir</span> <span style="color: #000080">dir=</span><span style="color: #008000">"$

/generated-classes"</span><span style="color: #000080">/></span>

<span style="color: #000080"><delete</span> <span style="color: #000080">file=</span><span style="color: #008000">"$

Unknown macro: {deploy.dir}

/$

Unknown macro: {appcode.name}

.jar"</span><span style="color: #000080">></delete></span>
<span style="color: #000080"><delete</span> <span style="color: #000080">file=</span><span style="color: #008000">"$

/zip/$

Unknown macro: {appcode.name}

.zip"</span><span style="color: #000080">></delete></span>
<span style="color: #000080"><delete</span> <span style="color: #000080">file=</span><span style="color: #008000">"$

Unknown macro: {appcode.lib}

/generatedwsdlclasses.jar"</span><span style="color: #000080">></delete></span>
<span style="color: #000080"></target></span>

Run the ant task with target as wsimport to generate the SOAP binding classes along with the classes and source code


You can see the sample output below:

10. Now you can start using the generated classes in your AppCode project



Note: Due to limitations in the existing DbSync mapping algorithm which cannot allow certain nested hierarchies, we need to create DBSync Compatible Wrapper classes to allow the metadata binding with the conversion processor
Please refer to msnav2013 project where we have created necessary wrapper classes to do the metadata binding

The main functions of the wrapper classes are to convert from the DBSync compatible type to the underlying SOAP type and Vice Versa
E.g.
<span style="color: #7f0055"><strong>public</strong></span> <span style="color: #7f0055"><strong>class</strong></span> Customer {
<properties and methods>

<span style="color: #7f0055"><strong>public</strong></span> <span style="color: #7f0055"><strong>static</strong></span> Customer createCustomer(CustomerCard <span style="color: #6a3e3e">card</span>) {
Customer <span style="color: #6a3e3e">newObject</span> = <span style="color: #7f0055"><strong>new</strong></span> Customer();
<span style="color: #6a3e3e">newObject</span>.setKey(<span style="color: #6a3e3e">card</span>.getKey());
<span style="color: #6a3e3e">newObject</span>.setNo(<span style="color: #6a3e3e">card</span>.getNo());
////Set other attributes
<span style="color: #7f0055"><strong>return</strong></span> <span style="color: #6a3e3e">newObject</span>;
}
<span style="color: #7f0055"><strong>public</strong></span> <span style="color: #7f0055"><strong>static</strong></span> CustomerCard createCustomerCard(Customer <span style="color: #6a3e3e">customer</span>) <span style="color: #7f0055"><strong>throws</strong></span> DatatypeConfigurationException {
CustomerCard <span style="color: #6a3e3e">card</span> = <span style="color: #7f0055"><strong>new</strong></span> CustomerCard();
<span style="color: #6a3e3e">card</span>.setKey(<span style="color: #6a3e3e">customer</span>.getKey());
<span style="color: #6a3e3e">card</span>.setNo(<span style="color: #6a3e3e">customer</span>.getNo());
//set other attributes
<span style="color: #7f0055"><strong>return</strong></span> <span style="color: #6a3e3e">card</span>;
}
}
11. Build the filter classes to be used in the reader classes
They will be responsible for filtering the data in the read queries. Please refer to CustomerFilter and SalesInvoiceFilter in MsNav

<span style="color: #7f0055"><strong>public</strong></span> <span style="color: #7f0055"><strong>class</strong></span> CustomerFilter{


<span style="color: #7f0055"><strong>public</strong></span> CustomerFilter(){
}
<span style="color: #7f0055"><strong>public</strong></span> String <span style="color: #0000c0">key</span>;
<span style="color: #7f0055"><strong>public</strong></span> String <span style="color: #0000c0">No</span>;
<span style="color: #7f0055"><strong>public</strong></span> String <span style="color: #0000c0">Name</span>;

}



12. Open Method
This method is the place where all the authentication happens. Each AppCode can by default take the following three parameters as Adapter Properties
<span style="color: #0000c0">userName</span> = <span style="color: #0000c0">ctx</span>.getPropertyAsString(<span style="color: #2a00ff">"username"</span>); //User name for accessing service
<span style="color: #0000c0">password</span> = <span style="color: #0000c0">ctx</span>.getPropertyAsString(<span style="color: #2a00ff">"password"</span>); //Password for accessing the service
<span style="color: #0000c0">baseURL</span> = <span style="color: #0000c0">ctx</span>.getPropertyAsString(<span style="color: #2a00ff">"baseURL"</span>); //BaseUrl for making the soap call
In this method the actual authentication happens which is more of a one time in the reader and writer call



Authenticator.setDefault(<span style="color: #7f0055"><strong>new</strong></span> MyAuthenticator());
<span style="color: #7f0055"><strong>try</strong></span> {
<span style="color: #0000c0"><strong><em>log</em></strong></span>.finer(<span style="color: #2a00ff">"Customer Service: INIT"</span>);
URL <span style="color: #6a3e3e">customerURL</span> = <span style="color: #7f0055"><strong>new</strong></span> URL(<span style="color: #0000c0">baseURL</span> + <span style="color: #2a00ff">"/CustomerCard"</span>);
QName <span style="color: #6a3e3e">customerQName</span> = <span style="color: #7f0055"><strong>new</strong></span> QName(
<span style="color: #2a00ff">"urn:microsoft-dynamics-schemas/page/customercard"</span>,
<span style="color: #2a00ff">"CustomerCard_Service"</span>);
CustomerCardService <span style="color: #6a3e3e">customerCardService</span> = <span style="color: #7f0055"><strong>new</strong></span> CustomerCardService(
<span style="color: #6a3e3e">customerURL</span>, <span style="color: #6a3e3e">customerQName</span>);
<span style="color: #0000c0">customerCardPort</span> = <span style="color: #6a3e3e">customerCardService</span>.getCustomerCardPort();
<span style="color: #0000c0"><strong><em>log</em></strong></span>.finer(<span style="color: #2a00ff">"SalesInvoice Service: INIT"</span>);
URL <span style="color: #6a3e3e">salesInvoiceURL</span> = <span style="color: #7f0055"><strong>new</strong></span> URL(<span style="color: #0000c0">baseURL</span> + <span style="color: #2a00ff">"/SalesInvoice"</span>);
QName <span style="color: #6a3e3e">salesInvoiceQName</span> = <span style="color: #7f0055"><strong>new</strong></span> QName(
<span style="color: #2a00ff">"urn:microsoft-dynamics-schemas/page/salesinvoice"</span>,
<span style="color: #2a00ff">"SalesInvoice_Service"</span>);
SalesInvoiceService <span style="color: #6a3e3e">sis</span> = <span style="color: #7f0055"><strong>new</strong></span> SalesInvoiceService(<span style="color: #6a3e3e">salesInvoiceURL</span>,
<span style="color: #6a3e3e">salesInvoiceQName</span>);
<span style="color: #0000c0">sip</span> = <span style="color: #6a3e3e">sis</span>.getSalesInvoicePort();
<span style="color: #0000c0">batchSize</span> = Integer.parseInt(<span style="color: #0000c0">ctx</span>.getPropertyAsString(<span style="color: #2a00ff">"batchSize"</span>));
} <span style="color: #7f0055"><strong>catch</strong></span> (Exception <span style="color: #6a3e3e">e</span>) {
<span style="color: #0000c0"><strong><em>log</em></strong></span>.log(Level.<span style="color: #0000c0"><strong><em>SEVERE</em></strong></span>,
<span style="color: #2a00ff">"Customer/SalesInvoice Service Initialization Failed"</span>, <span style="color: #6a3e3e">e</span>);
<span style="color: #6a3e3e">e</span>.printStackTrace();
<span style="color: #7f0055"><strong>throw</strong></span> <span style="color: #7f0055"><strong>new</strong></span> RemoteException(
<span style="color: #2a00ff">"Customer/SalesInvoice Service Initialization Failed"</span>, <span style="color: #6a3e3e">e</span>);
}

13. Read and Write Methods
An AppCode implementation service can either have a read or write method exposed for reader and writer
The Reader Syntax is as follows:
<span style="color: #3f7f5f">/*</span>
<span style="color: #3f7f5f">* Method to read a list of customers in MsNav Takes in a variable arguments</span>
<span style="color: #3f7f5f">* of</span> <span style="color: #3f7f5f">CustomerFilter as input and returns a list of Customer objects</span>
<span style="color: #3f7f5f">*/</span>
<span style="color: #7f0055"><strong>public</strong></span> List<Customer> readCustomer(CustomerFilter <span style="color: #6a3e3e">filter</span>) <span style="color: #7f0055"><strong>throws</strong></span> Exception {

//Read operation
}
Inside a reader method, data is fetched using a relevant SOAP call with the necessary filter applied and the data fetched from the SOAP call is wrapped into the dbsync compatible output wrapper class


<span style="color: #7f0055"><strong>try</strong></span> {
<span style="color: #3f7f5f">// Modified by <span style="text-decoration: underline; ">Sambit</span> to check for null for the filter object</span>
<span style="color: #7f0055"><strong>if</strong></span> (<span style="color: #7f0055"><strong>null</strong></span> != <span style="color: #6a3e3e">filter</span>) {
<span style="color: #7f0055"><strong>for</strong></span> (Field <span style="color: #6a3e3e">field</span> : CustomerFilter.<span style="color: #7f0055"><strong>class</strong></span>.getFields()) {
CustomerCardFilter <span style="color: #6a3e3e">cusCardFilter</span> = <span style="color: #7f0055"><strong>null</strong></span>;
Object <span style="color: #6a3e3e">value</span> = getFieldValue(<span style="color: #6a3e3e">field</span>, <span style="color: #6a3e3e">filter</span>);
<span style="color: #7f0055"><strong>if</strong></span> (<span style="color: #6a3e3e">value</span> != <span style="color: #7f0055"><strong>null</strong></span>
&& !((String) <span style="color: #6a3e3e">value</span>).trim().equalsIgnoreCase(<span style="color: #2a00ff">""</span>)) {
<span style="color: #6a3e3e">cusCardFilter</span> = <span style="color: #7f0055"><strong>new</strong></span> CustomerCardFilter();
String <span style="color: #6a3e3e">fldName</span> = <span style="color: #6a3e3e">field</span>.getName().substring(
<span style="color: #6a3e3e">field</span>.getName().lastIndexOf(<span style="color: #2a00ff">"."</span>) + 1);
<span style="color: #3f7f5f">// CustomerCardFields.valueOf(CustomerCardFields.NO.toString());</span>
<span style="color: #3f7f5f">//System.out.println(CustomerCardFields.NO.toString());</span>
<span style="color: #6a3e3e">cusCardFilter</span>.setField(CustomerCardFields
.valueOf(<span style="color: #6a3e3e">fldName</span>.toUpperCase()));
<span style="color: #6a3e3e">cusCardFilter</span>.setCriteria((String) <span style="color: #6a3e3e">value</span>);
<span style="color: #6a3e3e">custCardFilterList</span>.add(<span style="color: #6a3e3e">cusCardFilter</span>);
}
}<span style="color: #3f7f5f">//for</span>
}<span style="color: #3f7f5f">//if(null != filter)</span>
<span style="color: #3f7f5f">// if there are more elements to read or it is the first read</span>
<span style="color: #7f0055"><strong>if</strong></span> (<span style="color: #0000c0">repositionKey</span> == <span style="color: #7f0055"><strong>null</strong></span> || hasMoreElements()) {
CustomerCardList <span style="color: #6a3e3e">cList</span> = <span style="color: #7f0055"><strong>null</strong></span>;
<span style="color: #7f0055"><strong>if</strong></span> (<span style="color: #0000c0">repositionKey</span> == <span style="color: #7f0055"><strong>null</strong></span>) {
<span style="color: #6a3e3e">cList</span> = <span style="color: #0000c0">customerCardPort</span>.readMultiple(<span style="color: #6a3e3e">custCardFilterList</span>,
<span style="color: #2a00ff">""</span>, <span style="color: #0000c0">batchSize</span>);
} <span style="color: #7f0055"><strong>else</strong></span> {
<span style="color: #6a3e3e">cList</span> = <span style="color: #0000c0">customerCardPort</span>.readMultiple(<span style="color: #6a3e3e">custCardFilterList</span>,
<span style="color: #0000c0">repositionKey</span>, <span style="color: #0000c0">batchSize</span>);
}
<span style="color: #7f0055"><strong>int</strong></span> <span style="color: #6a3e3e">cCount</span> = <span style="color: #6a3e3e">cList</span>.getCustomerCard().size();
<span style="color: #7f0055"><strong>for</strong></span> (<span style="color: #7f0055"><strong>int</strong></span> <span style="color: #6a3e3e">i</span> = 0; <span style="color: #6a3e3e">i</span> < <span style="color: #6a3e3e">cCount</span>; <span style="color: #6a3e3e">i</span>++) {
CustomerCard <span style="color: #6a3e3e">cusCard</span> = (CustomerCard) <span style="color: #6a3e3e">cList</span>
.getCustomerCard().get(<span style="color: #6a3e3e">i</span>);
<span style="color: #3f7f5f">/*</span>
<span style="color: #3f7f5f">* Customer <span style="text-decoration: underline; ">cusw</span> = new Customer();</span>
<span style="color: #3f7f5f">* cusw.setCustomerCard(cusCard);</span>
<span style="color: #3f7f5f">*/</span>
<span style="color: #3f7f5f">// Customer <span style="text-decoration: underline; ">cusw</span> =</span>
<span style="color: #3f7f5f">// (Customer)ClassConverter.convertToClass(cusCard,</span>
<span style="color: #3f7f5f">// Customer.class);</span>
Customer <span style="color: #6a3e3e">cusw</span> = Customer.createCustomer(<span style="color: #6a3e3e">cusCard</span>);
<span style="color: #6a3e3e">customers</span>.add(<span style="color: #6a3e3e">cusw</span>);
}
<span style="color: #7f0055"><strong>if</strong></span> (<span style="color: #6a3e3e">customers</span>.size() == <span style="color: #0000c0">batchSize</span>) {
<span style="color: #3f7f5f">// Get the last element in the list of customers to get the</span>
<span style="color: #3f7f5f">// <span style="text-decoration: underline; ">repositionkey</span></span>
Customer <span style="color: #6a3e3e">cusw</span> = <span style="color: #6a3e3e">customers</span>.get(<span style="color: #0000c0">batchSize</span> - 1);
<span style="color: #0000c0">repositionKey</span> = <span style="color: #6a3e3e">cusw</span>.getKey();
} <span style="color: #7f0055"><strong>else</strong></span> {
<span style="color: #0000c0">repositionKey</span> = <span style="color: #2a00ff">"-1"</span>;
}
}
} <span style="color: #7f0055"><strong>catch</strong></span> (Exception <span style="color: #6a3e3e">e</span>) {
<span style="color: #6a3e3e">e</span>.printStackTrace();
<span style="color: #0000c0"><strong><em>log</em></strong></span>.log(Level.<span style="color: #0000c0"><strong><em>SEVERE</em></strong></span>, <span style="color: #2a00ff">"Error while reading customers from MSNAV"</span>, <span style="color: #6a3e3e">e</span>);
<span style="color: #7f0055"><strong>throw</strong></span> <span style="color: #6a3e3e">e</span>;
}

<span style="color: #7f0055"><strong>return</strong></span> <span style="color: #6a3e3e">customers</span>;
Note: Please note that it is important for the service to implement its own batching mechanism as otherwise the calls can go to an infinite loop as the JavaAdapter keeps on calling the service class till it gets a null or an empty list assuming the batching is handled by the latter

The Writer Syntax is as follows:

<span style="color: #7f0055"><strong>public</strong></span> SaveResult[] createCustomer(List<Customer> <span style="color: #6a3e3e">custList</span>) {
}
It takes a list of entities as the input and returns back an array of saveresults.
In the process, the input entities are converted into the relevant SOAP types and then are sent as a part of the SOAP request to perform a create or an update operation
Batching is not mandatory in this case as already the conversion processor performs necessary batching




List<SaveResult> <span style="color: #6a3e3e">saveResultList</span> = <span style="color: #7f0055"><strong>new</strong></span> ArrayList<SaveResult>();
<span style="color: #7f0055"><strong>try</strong></span> {
CustomerCardList <span style="color: #6a3e3e">customerCardList</span> = <span style="color: #7f0055"><strong>new</strong></span> CustomerCardList();
<span style="color: #3f7f5f">// <span style="text-decoration: underline; ">int</span></span> <span style="color: #3f7f5f">batchVal = 0;</span>
<span style="color: #3f7f5f">// Keep a list of batches to flush at the end of the</span>
<span style="color: #3f7f5f">// for loop</span>
<span style="color: #3f7f5f">// List<Holder> batchHolders = new ArrayList<Holder>();</span>
<span style="color: #3f7f5f">// This the counter for each batch</span>
<span style="color: #7f0055"><strong>int</strong></span> <span style="color: #6a3e3e">eachBatchCounter</span> = 0;
Holder<CustomerCardList> <span style="color: #6a3e3e">holder</span> = <span style="color: #7f0055"><strong>new</strong></span> Holder<CustomerCardList>();
<span style="color: #7f0055"><strong>for</strong></span> (Customer <span style="color: #6a3e3e">ccw</span> : <span style="color: #6a3e3e">custList</span>) {
<span style="color: #3f7f5f">// Customer <span style="text-decoration: underline; ">ccw</span> = custList.get<ac:emoticon ac:name="information" />;</span>
++<span style="color: #6a3e3e">eachBatchCounter</span>; <span style="color: #3f7f5f">// Increment the counter</span>
<span style="color: #3f7f5f">// Added by <span style="text-decoration: underline; ">sambit</span> for key</span>
<span style="color: #7f0055"><strong>if</strong></span> (<span style="color: #6a3e3e">ccw</span>.getNo() != <span style="color: #7f0055"><strong>null</strong></span>) {
<span style="color: #7f0055"><strong>if</strong></span> (<span style="color: #6a3e3e">ccw</span>.getNo().trim().equals(<span style="color: #2a00ff">""</span>)) {
<span style="color: #6a3e3e">ccw</span>.setNo(<span style="color: #7f0055"><strong>null</strong></span>);
}
}
<span style="color: #3f7f5f">/*</span>
<span style="color: #3f7f5f">* CustomerCard cc0 = ccw.getCustomerCard();</span>
<span style="color: #3f7f5f">*</span>
<span style="color: #3f7f5f">* ccl.getCustomerCard().add(cc0);</span>
<span style="color: #3f7f5f">*/</span>
<span style="color: #3f7f5f">// CustomerCard cc0 =</span>
<span style="color: #3f7f5f">// (CustomerCard)ClassConverter.convertToClass(<span style="text-decoration: underline; ">ccw</span>,</span>
<span style="color: #3f7f5f">// CustomerCard.class);</span>
CustomerCard <span style="color: #6a3e3e">cc0</span> = Customer.createCustomerCard(<span style="color: #6a3e3e">ccw</span>);
<span style="color: #6a3e3e">customerCardList</span>.getCustomerCard().add(<span style="color: #6a3e3e">cc0</span>);
<span style="color: #3f7f5f">// If the batch limit is reached or the last element is being</span>
<span style="color: #3f7f5f">// read</span>
<span style="color: #7f0055"><strong>if</strong></span> (hasBatchLimitReached(<span style="color: #6a3e3e">eachBatchCounter</span>)

isEndOfList(custList.size(), eachBatchCounter)) {
// Set the holder value
holder.value = customerCardList;
// flush the batch
flushCustomerBatch(holder, saveResultList, true);
// now clear the list
customerCardList.getCustomerCard().clear();
// and reset the counter and holder object
holder.value = null;
eachBatchCounter = 0;
}
/*
* if (customer.getCustomerCard().size() == batchSize) {
* customerCardPort.createMultiple(hccl);
*
* List<CustomerCard> ccs = hccl.value.getCustomerCard();
*
* // Resetting local Variables ccl = new CustomerCardList();
* hccl = new Holder<CustomerCardList>(); SaveResult sr = null;
* for (int j = 0; j < ccs.size(); j++) { // SaveResults sr =
* new SaveResult(); sr.success = true; String id =

  • ccs.get(j).getNo(); sr.newid = id; srArray[batchVal] = sr;

* batchVal++; } }
*/
}
/*
* if (customerCardList.getCustomerCard().size() > 0) {
*
* // Do batching now Holder<CustomerCardList> batchholder = new
* Holder<CustomerCardList>();
*
* customerCardPort.createMultiple(hccl); List<CustomerCard> ccs =
* hccl.value.getCustomerCard(); SaveResult sr = null; for (int j =
* 0; j < ccs.size(); j+) { +sr = new SaveResult(); sr.success =
* true; String id = ccs.get(j).getNo(); sr.newid = id;
  • srArray[batchVal] = sr; batchVal++; } }

*/
} catch (Exception e) {
e.printStackTrace();
log.severe("Error while creating customers in MSNav:"
+ e.getMessage());
}
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0d60f311-9c53-42f7-8eb2-d7c67f4a448d"><ac:plain-text-body><![CDATA[ return saveResultList.toArray(new SaveResult[] {});]]></ac:plain-text-body></ac:structured-macro>
}

14. Deployment Process
The AppCode is bundled into a zip file and is deployed as a zip file into the environment specified in the appcode-deploy.xml file.
The environment name is specified in the "environment" attribute
<property name = "environment" value = "sandbox" />
The details about the appcode-deployx.xml parameters has been mentioned previously
By default the target is deploy which does the following:

  1. init
  2. wsimport
  3. build
  4. zip
  5. deploy


For the deploy target to work, your dbsync location which you have specified in the appcode-deploy.xml file must be running






15. Viewing the Profile List
Select the profile which you have used to deploy the AppCode. In this case it is profile_test









16. Java Adapter Properties
Set the adapter properties for the Java Adapter
Classpath – same as environment
Username – SOAP Service username
Password – SOAP Service Password
BaseURL – SOAP Service BaseURL




17. View the Metadata
View the metadata of the service to select and map




  • No labels