Sunday, October 30, 2011

Work Around: Popup forces user to enter required values first

 

In my previous project I came across a typical problem While trying to enter value using pop up. The problem is If other required fields on same page are not entered and button/link for generating popup pressed , then an error message appears like below. It forces us to enter required values first.

image

As a work around I have used the option [immediate=true] for the button/link responsible for the pop up to be generated. Please follow below snap shot. Earlier command link selectText has no option set as [immediate=true] and we get above error.

image

After setting the option [immediate=true] for the command link selectText, above error resolved as we redeploy it.

image

Below screen shows that all required fields are empty but it is not prompting us to enter required fields while trying to open popup as user can enter data successfully in pop up and no restriction comes from required fields.

image

Saturday, October 29, 2011

Field Validation in ADF as user Tab out

In this blog I am trying to show validation as user tab out any field in ADF. User enter data in a form field and as he tab out the field validation happens and If validation criteria does not meet error message appears.

image

An ADF application has model and ViewController project. We can create the form in ViewController project. Please follow my previous blogs for the basics of Form generation in ViewController project. So rather than spending much time on the basics like Form generation , I would like to show special things I have done here to accomplish above goal.

Step1: Create a java class and implement javax.faces.validator.Validator,java.io.Serializable. Implementation of Validator will ask for the validate(FacesContext facesContext, UIComponent uiComponent,Object object) method to be Implemented. Here I have created a java class named EmailValidator. This java file can be downloaded from http://www.box.net/shared/cux283rmjp45cl8mry2x link. Similarly we can create another java file for date validation. Please download the same from http://www.box.net/shared/trtvicb7ihesdmy6hpzx link.

Step2: Declare these java files as validator in faces-config.xml file. Please refer below snapshot

image 

Step3: Modify your form so that it will not obey default validator and follow the custom validator you have created in step2. Please follow below entry in your jsff file.

image

Please download the jsff file from below link http://www.box.net/shared/8eb7hcm4qxq0330n3eme

Please deploy and it will work as expected.

image

Friday, September 2, 2011

BPEL Composites start recovery automatically , Creating Instances after 5 minute: Dealing with Automatic Recovery Settings

 

In our production server we faced this typical issue and initially thought of having problem in our JCA adapter. The issue was few BPEL process faulted instance starts automatically and again faulted for same reason and we had no control over its start time. As shown in below snap shot our BPEL composite first faulted on 29th August 7:33:59 PM and again starts on 30th August 00:00:36 AM. As a result huge number of faulted instance piled up and crashes the server.

image

As a fix we shift our thoughts from JCA adapter Retrying bug to SOA Server Recovery settings. Initially we are searching for bug in JCA adapter, as we thought that JCA adapter retry settings make that happens. But actually SOA server automatic Recovery Settings tried that faulted instances to recover for a certain period of time. Please refer below screen shot for default values of SOA Server Automatic Recovery.

Detail description for those attributes are explained by oracle, please refer http://download.oracle.com/docs/cd/E14571_01/relnotes.1111/e10133/soa.htm#RNLIN1052.

image

Step 1: As a fix we went to our Production server and expand SOA and then right click to soa-infra and select BPEL properties. Please refer below screen shot.

image

Step 2: Select “More BPEL Configuration Properties” (Refer Below Screen shot)

image 

Step 3: Select “RecoveryConfig” (Refer Below Screen shot)

image

Step 4: Change Stop Window Time to 00:00 (same as Start Window time , so Recovery Period becomes negligible).

image

Monday, August 8, 2011

Achieving “While” functionality in XSL using recursive custom template call


Few days before I came across one XSL transformation business requirement where an xml element of Input data is having  two sub elements named “NumberBlockVON” and “NumberBlockBIS” . Name of these two is mentioned by our business user.  “NumberBlockVON” will have a positive Integer value and same happens for “NumberBlockBIS” . Now the requirement was whatever value specified as “NumberBlockBIS” that will be treated in output xml as “the power of” the value specified for “NumberBlockVON” . It means in out put xml “NumberBlockVON” will pass as it is but the value for “NumberBlockBIS” will be replaced by the <NumberBlockVON> to the power of <NumberBlockBIS>.
&lt;PickPackShipCustomElement&gt; &lt;NumberBlockVON&gt;5&lt;/NumberBlockVON&gt; &lt;NumberBlockBIS&gt;6&lt;/NumberBlockBIS&gt; &lt;/PickPackShipCustomElement&gt;
Now if it is a java requirement we can finished it off easily by writing a looping construct with the limit from 0 to <NumberBlockBIS>, and multiply the <NumberBlockVON> that many times. But here the problem is XSL constructs can loop through xml nodes , but it can’t loop through from 0 to any other specific value with in a single xml node. So we cant depend on XSL given constructs.
We use a custom XSL template to achieve this and call the template recursively with tuned parameters.<NumberBlockVON> value and <NumberBlockBIS>value is passed as a parameter to the template.How we achieve this is explained below with code snippet.



&lt;xsl:templatename="whileImplTemplate"&gt;
&lt; !--parameter limit_var is used to hold value of NumberBlockBIS which is used as a power value
--&gt;
&lt;xsl:paramname="limit_var"/&gt;
&lt; !--parameter var is used to hold value of NumberBlockVON which is used as a base value
--&gt;
&lt;xsl:param name="var"/&gt;
&lt; !--parameter Outvar is used to hold output value 
--&gt;
&lt;xsl:param name="Outvar" select="1"/&gt; &lt;xsl:param name="count_index" select="0"/&gt; &lt;xsl:variable name="out_var" select="$Outvar"/&gt;
&lt; !--while logic Implementation
--&gt;
&lt;xsl:choose&gt;
&lt; !--Is limit achieved --&gt;
    &lt;xsl:when test="$count_index &lt; $limit_var"&gt;
&lt; !--recursive template call if limit does not achieved--
&gt;
&lt;xsl:call-template name="whileImplTemplate"&gt; &lt;xsl:with-param name="limit_var" select="$limit_var"/&gt; &lt;xsl:with-param name="var" select="$var"/&gt; &lt;xsl:with-param name="count_index" select="number($count_index)+1"/&gt; &lt;xsl:with-param name="Outvar" select="number($var)*number($out_var)"/&gt; &lt;/xsl:call-template&gt;
&lt; !-- End template --&gt;
&lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="$out_var"/&gt;
&lt; !--If limit achieved then print value --&gt;
    &lt;/xsl:otherwise&gt;
  &lt;xsl:choose&gt;
&lt;/xsl:template&gt; 
As a result the output comes like below
&lt;PickPackElement&gt; &lt;NumberBlockVON&gt;5&lt;/NumberBlockVON&gt; &lt;NumberBlockBIS&gt;15625&lt;/NumberBlockBIS&gt; &lt;/PickPackElement&gt;

Sunday, June 19, 2011

Oracle SOA composite Deployment and Migration using WLST script

Deployment

Step 1: Prepare execution location and codebase in the server where SOA is installed

We need to create a directory in the server location where SOA installed .From that directory we need to execute our deployment scripts.For example, I assume that directory as /app/deployment. Similarly for codebase we need to create another directory. I assume that directory as /app/codebase. We need to put our composite project source here (Not application file[.jws])

Step 2: Generate Configuration Plan:

Configuration plan is created based on composite.xml. This plan is used to modify server references in BPEL process.After developing SOA composites using JDeveloper , we need to generate configuration plan file by right clicking on the composite.xml file.

image

 

We can SFTP that Composite project folder including the configuration file to /app/codebase.

Step 3: Create Deployment Property file

We need to create a property file under /app/deployment directory. Sample Property file will look like below. Named the property file as deploy<BPEL Name>.properties.

  1. filenamewithpath=<SAR file location>
  2. oraclehome=<Oracle Home Location>
  3. apphome=<codebase location>
  4. processName=<Composite Name>
  5. configPlan=<Configuration plan location>
  6. description="BPEL process"
  7. serverurl=<admin server url>
  8. bpelversion=2.0

Note: we need to change the Property file name and its content for other BPEL process.

 

Step 4: Create Python Script

We need to create a python script file [/app/deployment/compileComposite.py] to compile BPEL source code and create SAR file. A sample python script is as below.

  1. import os
  2. if os.environ.has_key('wlsUserID'):
  3. wlsUserID = os.environ['wlsUserID']
  4. if os.environ.has_key('wlsPassword'):
  5. wlsPassword = os.environ['wlsPassword']
  6. sca_package(apphome,processName,bpelversion,oracleHome=oraclehome)
  7. exit()

to know more about sca_package () please find below link http://download.oracle.com/docs/cd/E12839_01/web.1111/e13813/custom_soa.htm

we need to create python script file [/app/deployment/soa_common_deployment.py] to deploy SAR files created from above python script after attaching configuration file created from above step.

A sample python script is as follows.

  1. import os
  2. if os.environ.has_key('wlsUserID'):
  3. wlsUserID = os.environ['wlsUserID']
  4. if os.environ.has_key('wlsPassword'):
  5. wlsPassword = os.environ['wlsPassword']
  6. connect( url='t3://cbicdg-pcp06:6001', adminServerName='soa_server1')
  7. print "server url[",serverurl,"] filename with path [",filenamewithpath,"] bpel version [",bpelversion,"] configPlan [",configPlan,"]"
  8. sca_attachPlan (filenamewithpath, configPlan,true,true)
  9. sca_deployComposite (serverurl,filenamewithpath,true)
  10. exit()

Note: Unlike property file we need not to change the python file for different BPEL processes.

To know more about sca_attachPlan(),sca_deployComposite() please visit below link http://download.oracle.com/docs/cd/E12839_01/web.1111/e13813/custom_soa.htm

Step 5 : Create Build [Shell] script

We need to create a shell script which will execute above python scripts recursively for all interfaces. Below shell script will ask for Interface name and based on given name it will load corresponding property file and execute python Scripts.

  1. while :
  2. do
  3. echo "Enter Process Name to be build and deploy[default none]: "
  4. read processName
  5. echo /app/deployment/deploy$processName.properties
  6. cp /app/oracle/product/wls1032/aia11g/aia_instances/aia11gdev/config/.adf/META-INF/adf-config.xml /app/codebase/$processName/SCA-INF/classes/META-INF
  7. export wlsttoolhome=(Location of wlst.sh script under SOA server installation normally it resides under wls1032/soa11g/common/bin)
  8. export wlsUserID=$1
  9. export wlsPassword=$2
  10. cd $wlsttoolhome
  11. pwd
  12. ./wlst.sh -loadProperties /app/deployment/deploy$processName.properties /app/deployment/compileComposite.py
  13. mv /app/codebase/$processName/deploy/sca\_$processName\_rev2.0.jar /app/codebase/$processName/deploy/sca_$processName.jar
  14. cp /app/codebase/$processName/deploy/sca_$processName.jar /app/deployment
  15. ./wlst.sh -loadProperties /app/deployment/deploy$processName.properties /app/deployment/soa_common_deployment.py
  16. done
  17. exit()

Note:

If your BPEL process refer MDS storage then we need to define that location in adf-config.xml file.So proper adf-config.xml will refer proper mds. So in above shell script we copy standard adf-config.xml which comes with AIA installation to our SOA project [Please refer Line 6]

 

Step 6 : Modify Configuration file:

We need to Modify generic auto generated configuration plan by including searchReplace components and use the targeted instance host name and port name in search and replace component like below.

image

Migration:

Here I assume migration happens from DEV to TEST so below places needs to changed from DEV references to TEST references.

1. In configuration file like above.

2. In property file the admin server references and Oracle home  needs to be changed based on TEST server references

3. In build script below lines needs to be modified based on Test server references.

image

Execute WLST utility

Execute the build script from /app/deployment and pass weblogic admin userid and weblogic admin password as argument. Before execution please give chmod 755 to that build.sh (refer step 5). Sample command for executing python script as follows

./build.sh <weblogic userid > <password>

if prompted please give the SOA composite name.

Note: “Deploying composite success” confirms the successful deployment.

Friday, December 31, 2010

Create a node in Oracle Hyperion Data Relation Ship Management (DRM)

LiveJournal Tags:
In this post I am trying to show how we can create a node in Oracle Data Relation Ship Management using in build API’s for DRM . Before proceeding for actual development we need to make our project ready so that it will able to get all In build API’s. First of all we need to download Oracle DRM SDK using below link http://www.oracle.com/technetwork/middleware/bi-foundation/downloads/hyperion-data-relationship-111120-089726.html.
DRM sdk provides below artifacts
image Figure 1
but we need only jar files belongs to dist/lib and thirdparty to create below libraries for our Jdeveloper Project. Jdeveloper 11.1.1.3 is the IDE I am using for developing the project.
image Figure 2 
where library “Thirdparty” contains below jar files.I prefer those jar files needs to be copied to project folder, I mean from DRM SDK zip file (from figure 1) to project folder.
image
DRMAPI library contains dist/lib/hdrm-proxy-api.jar and xerces library contains thirdparty/xerces/xerces.jar. After doing all setups we can move for development.
please follow below code block for adding a node in DRM.


public class AddDRMNode { //declare variables that needs to be initialized and //used through out the class Identify the DRM server //to which we are trying to make request String aUrl = "&lt;Url of DRM server&gt;"; //Initialize master data management IMasterDataManagement masterDataManagement = null ; //Initialize TRemSessionInfo TRemSessionInfo sessionInfo = null ; //Initialize Current Version String CurrentVersion = null ; //Initialize list of hierarchy Objects ArrayOfStringHolder hierobjects= null ; public AddDRMNode(){} public void addNode( String &lt;DRM UserId&gt;, String &lt;DRM Password&gt;, Sring node) { //get instance of mdm masterDataManagement = MasterDataManagementUtils . getMasterDataManagementFacade ( new URL (aUrl)); //get session try{ sessionInfo = masterDataManagement. getSessionMgr (). createSession (&lt;DRM Server User ID&gt;, &lt;DRM Server Password&gt;, "ProductVersion=11.1.1,CleartextPassword=True"); } catch ( Exception e) { logger. info ("unable to get session");} //get hold of current version currentversion = "Current"; //get list of all hierarchies under Current version. here listHierObjects //is a method which returns list of hierarchies.Defined later in my post try { hierobjects = listHierObjects(this.sessionInfo, currentversion); logger. info ("there are [" + hierobjects.value.length + "] hierarchy objects for version [" + currentversion + "]"); } catch ( Exception e) { logger. info ("Hierarchies are not found"); } //looping through the Current Hierarchy for ( int i = 0; i &lt; hierobjects. value . length ; i++) { logger. info ("[" + i + "] hierarchy value is [" + hierobjects. value [i] + "]"); //Obtain a hierarchy locator using version and current hierarchy value hierlocator = getHierLocator(currentversion, hierobjects. value [i]); //get hold of hierarchy prefix using the hierarchy locator try { prefix = getHierarchyPrefix(hierlocator); //update passed argument node as a concat with prefix node = prefix+ node; logger. info ("Customer to be added :[" + node + "]"); } catch ( Exception e) { logger. info ("Problem retrieving Hierarchy Prefix"); e. printStackTrace (); } //get IHier_PortyType for node addition ihierpt = this .masterDataManagement. getHier (); //get hold of parent node try { parentnode = ihierpt. nodeByAbbrev (hierlocator, &lt;Parrent node name&gt;); logger. info ("ID of Unmapped node is" + parentnode. getID() ); } catch ( Exception e) { logger. info ("parent node does not exist"); e. printStackTrace() ; break ; } //get hold of nodelocator object for parent node TRemLocalNodeLocator nodelocator = getTremLocalNodeLocator(currentversion, hierobjects.value[i], localnode. getDisplayByString ()); try { //check whether passed node is existed, isnodeExist is //defined later. passed argument is //locator of parent node,Local node object,node to be added if (isnodeExist(nodelocator, this.masterDataManagement. getLocalNode (), node)) { logger. info ("Node Exists in UNMAPPED"); } else { logger. info ("Node does not exist, going to add"); //addNode passed arguments are hierarchy locator //node to be added,parent node ID,boolean value to decide //whether added node is leaf or limb ihierpt. addNode (hierlocator, node, parentnode.getID(), true); } } catch ( Exception e) { logger. info ("Exception odue to node handling, It may be mapped earlier in parent Node"); } } } private boolean isNodeExist( TRemLocalNodeLocator nodelocator, ILocalNode localnode, String node ) { //obtain list of descendent nodes for parent node TRemLocalNode [] descendentArray = localnode. fillChildrenSorted (nodelocator); boolean flagExist = false ; for ( int i=0;i&lt;=descendentArray. length ;i++) { //if parent nodes display equals to passed node //then set flag equals to true if (descendentArray[i]. equals (). getDisplayByString (). equals (node)) { flagExist = true ; } } //return flag return flagExist; } //This method take session and version as input and returns list of hierarchies as output //private ArrayOfStringHolder listHierObjects(TRemSessionInfo sessionInfo, String versionId) throws Exception { //Get IVersion object to invoke methods for retriving list of hierarchies IVersion versionOfInterest = this.masterDataManagement. getVersion (); ArrayOfStringHolder hierarchies = new ArrayOfStringHolder() ; //obtain list of hierarchies versionOfInterest.listHiers(sessionInfo. getSession (), versionId, hierarchies); return hierarchies; } //This method takes version and hierarchy name as input and returns //TRemHierarchy locator as output public TRemHierLocator getHierLocator( String versionID, String hierarchyname) { TRemHierLocator tremhierlocator = new TRemHierLocator (); tremhierlocator. setSession ( this .sessionInfo. getSession ()); tremhierlocator. setVersion (versionID); tremhierlocator. setHier (hierarchyname); return tremhierlocator; } //This procedure takes hierarchy locator object as input and //returns valid prefix stringfor that hierarchy as output private String getHierarchyPrefix( TRemHierLocator hierLocator) throws Exception { logger . info ("Hierarchy prefix for " + hierLocator. getHier ()); String prefix = this .masterDataManagement. getHier (). fillStrPropValue (hierLocator, DRM_HIERARCHY_PREFIX_FINDER); return prefix; } }

Monday, November 1, 2010

Customizing standard Input output of BPEL Process

Modifying Input XSD:
BPEL designer by default uses string for input as well as output. while dealing with complex interfaces we need to update input and output structure in such a way that it will meet all requirements. By default the schema looks like below. 
<schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/DatabaseToFileAdapter" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="DatabaseToFileAdapterProcessRequest"> <complexType> <sequence> //Input Element <element name="input" type="string"/> </sequence> </complexType> </element> //Output Element <element name="DatabaseToFileAdapterProcessResponse"> <complexType> <sequence> <element name="result" type="string"/> </sequence></complexType> </element> </schema>
The example I have shown here is to take ProjectName, Status and Role as input and after querying database it will show other project details like hostname,port, location,domain etc. Please refer below Figure 1 and Figure 2 for input and Output.
image  Figure 1
image
Figure 2
Figure 1 is used to describe input and Figure 2 is used to describe Output format.
we can edit “DatabaseToFileAdapterProcessRequest” element like below instead of a simple string.
image
After querying database fetched data structure looks like below.
image
Figure 2
Our next step will be incorporating those structures in BPEL file by Creating variables and using those variables in rest of the files. Please note down below things
  • Make sure that used targetnamespace for xsd also present in BPEL process. Check Process section of the BPEL process for below entry
    <process name="DatabaseToFileAdapter" targetNamespace="http://xmlns.oracle.com/DatabaseToFileAdapter" xmlns:client="http://xmlns.oracle.com/DatabaseToFileAdapter"
  • Make sure Input and Output variable is referring modified input and output element of xsd via default message types of wsdl.
    <variables> <!-- Reference to the message passed as input during initiation --> <!-- Reference to the message that will be returned to the requester--> <variable name="inputVariable" messageType="client:DatabaseToFileAdapterRequestMessage"/> <variablename="outputVariable" messageType="client:DatabaseToFileAdapterResponseMessage"/> </variables>
  • messageType specified above refers message from WSDL file.Please see belowimage
  • Similarly the response message is using “DatabaseToFileAdapterResponse” element of the xsd.

Modifying BPEL standard WSDL:
  • Another way of achieving above objective is to import another xsd in wsdl file.
image
  • Make sure that the targetnamespace for imported xsd is used in WSDL definition as xml namespace prefix.
  • <definitions name="DatabaseToFileAdapter" targetNamespace="http://xmlns.oracle.com/DatabaseToFileAdapter" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:client="http://xmlns.oracle.com/DatabaseToFileAdapter" //below name space prefix needs to be added in order to utilize defined elements in that schema xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/SlectProjDetailsByProjName" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/">
  • We need to modify the Message element for “DatabaseToFileAdapterResponseMessage” in such a way that it will refer element belongs to imported xsd.
image
  • Make sure that InputVariable and OutputVariable referring to newly modified xsd rather than old default xsd.
image   expand the outputVariable node and make sure that you will get modified structure instead of the old structure.
image