Copying and Modifying contents to another VO in OAF


The Below is the program

In my case my requirement is to copy and to modify the contents so I have Iterated the VO Rows  and Row’s Attribute to modify and Then i have inserted into my another VO.

/* Logic for inserting the second row for updating the Balance */

OAViewObject voIter=(OAViewObject)am.findViewObject(“xxcactTxnTestVO1”); //First VO where there is data (Source VO)

System.out.println(“voIter.getAttributeIndexOf(\”Acc_no\”);”+voIter.getAttributeIndexOf(“Acc_no”)); //Obtaining Index of Account number

System.out.println(voIter.getAttributeDef(8).getName()); //Obtaining column name from the index account number

int jgr=voIter.getAttributeCount(); //Obtaining the Attribute Count
System.out.println(“The Value of J is “+jgr); //Displaying the Attribute Count
AttributeDef[] attrDefs = voIter.getAttributeDefs(); //Obtaining the Attribute Definitions

int attrCount = (attrDefs == null)? 0 : attrDefs.length; //Obtaining the attribute Count from the attributes

OAViewObject destvo=(OAViewObject)am.findViewObject(“xxcactTxnTestVO2”); //Second VO which is the Destination where data is to be copied

for(int i=0;i<(attrCount-1);i++) //looping Attributes

{

// System.out.println(“VO Iteration And its Value Starts “+voIter.getAttributeDef().getName());

System.out.println(“The Value of I is This Comes to testing :**********”+i); //Obtaining the index numbers for looping

System.out.println(“AttrDefs “+attrDefs[i]);

System.out.println(“AttrDefs Testing Obtaining name”+attrDefs[i].getName());

System.out.println(“AttrDefs Testing Obtaining Property”+attrDefs[i].getProperty(attrDefs[i].getName()));

// System.out.println(“AttrDefs Testing”+attrDefs[i].getProperty(attrDefs[i].));

xxcactTxnTestVO1RowImpl roloe=(xxcactTxnTestVO1RowImpl)voIter.getCurrentRow();//Registering the current row to the View Object here the current row is the create row

// System.out.println(“Getting Row Count of the values”+voIter.getRowCount());

System.out.println(“AttrDefs Testing Otaining value by row wise “+roloe.getAttribute(attrDefs[i].getName()));

System.out.println(“AttrDefs Testing Otaining name by row wise “+attrDefs[i].getName());

// System.out.println(“Attribute Value Obtaining Value row wise “+roloe.getAttribute((roloe.getAttribute(attrDefs[i].getName())).toString()));// Obtaining a value from the retrived Row attributes

if((attrDefs[i].getName()).equals(“TransferAccNo”))    //Making my Own Modifications If You want to just copy without Modyfying just use the Logic in ELSE

{

destvo.getCurrentRow().setAttribute(attrDefs[i-1].getName(), roloe.getAttribute(attrDefs[i].getName())) ;

}

else if((attrDefs[i].getName()).equals(“AccNo”))

{

destvo.getCurrentRow().setAttribute(attrDefs[i+1].getName(), roloe.getAttribute(attrDefs[i].getName())) ;

}

else if((attrDefs[i].getName()).equals(“Debit”))

{

destvo.getCurrentRow().setAttribute(attrDefs[i-1].getName(), roloe.getAttribute(attrDefs[i].getName())) ;

}

else if((attrDefs[i].getName()).equals(“Credit”))

{

System.out.println(“Credit Looped”);

}

else if((attrDefs[i].getName()).equals(“Balance”))

{

OAMessageTextInputBean tip=(OAMessageTextInputBean)webBean.findChildRecursive(“TransferAccNo3”);

String k=(tip.getValue(pageContext)).toString();

OAViewObject iop=(OAViewObject)am.findViewObject(“xxcactbanktxntestBalanceVO”);

System.out.println(“The Value of Iop is “+iop);

iop.setWhereClauseParam(0, k);

iop.setWhereClauseParam(1, k);

//iop.setOrderByClause(“Sno Desc”);

iop.executeQuery();

iop.first();

String iol=(iop.getCurrentRow().getAttribute(“Balance”)).toString();

System.out.println(“The receiving person’s balance is “+iol);

int lre=Integer.parseInt((roloe.getAttribute(“Debit”)).toString());

int lwer=Integer.parseInt((iop.getCurrentRow().getAttribute(“Balance”)).toString());

int klol=0;

klol=lwer+lre;

System.out.println(“The Current Balance Obtained is “+klol);

String cbal1=Integer.toString(klol);

System.out.println(“Somehow we obtain the Debit value and Balance for the receving person “+lre+”The Balance is “+lwer);

destvo.getCurrentRow().setAttribute(attrDefs[i].getName(), cbal1) ;//Setting the name and attributes for a row\

}

else{

destvo.getCurrentRow().setAttribute(attrDefs[i].getName(), roloe.getAttribute(attrDefs[i].getName())) ;//Setting the name and attributes for a row

}

System.out.println(“Getting the setted Attribute from the second VO object”+destvo.getCurrentRow().getAttribute(attrDefs[i].getName()) );

}

//———————————————————————————————————————————————————————————————————–

About pacesettergraam

A good and realistic person

Posted on August 28, 2013, in OAF and tagged , , , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: