cancel
Showing results for 
Search instead for 
Did you mean: 

copy elements from node

Former Member
0 Kudos

Hi experts,

How to copy only some of the elements from one node to another node based on condition ?

Thanks,

kavya.

Accepted Solutions (0)

Answers (5)

Answers (5)

gill367
Active Contributor
0 Kudos

Hello KAVYA

---> if you want to copy all the elements of one node to another node, then the method

WdCopyService() can be used as shown below:-

WDCopyService.copyElements(wdContext.nodeSourceNode(),wdContext.nodeTargetNode() );

It will copy all the elements of source node to the target node.

--> However if you want to copy only some of the elements based on some situation then you should use a for loop to get each element and copy(add) that element to new node based on the condition as shown below:

	
wdContext.nodeTargetNode().invalidate();
int size_SourceNode = wdContext.nodeSourceNode().size();
for(int i = 0 ; i < size_SourceNode ; i++ )
{IPrivateTestMenuAppView.ISourceNodeElement src_el = wdContext.nodeSourceNode().getSourceNodeElementAt(i);
	Condition = src_el.getA().equalsIgnoreCase( "s");      //condition to check the element which needs to be copied.
	if(Condition)
	{
    IPrivateTestMenuAppView.ITargetNodeElement Tgt_el = wdContext.nodeTargetNode().createTargetNodeElement();
	Tgt_el.setA( src_el.getA());
	Tgt_el.setB( src_el.getB());
	wdContext.nodeTargetNode().addElement(Tgt_el);
	}
}

In this way the elements can be added to the other node based on the condition.

Hope it is clear.

Please let me know if you still have any problem in this.

Sarbjeet Singh

Former Member
0 Kudos

HI Kavya,

Try to use teh following code:

Iprivateview sourcee table ;

Iprivateview targettable ;

for(int i =0;i<sourcesize;i++)

{

sourcetable = wdcontext.nodesourcetable.gettableelementat(i);

targettable = wdcontext.nodetarget.currenttable.createlement();

targettable.set();

targettable.set();

.

.

.

wdcontext.nodetargettablename.addelement(targettable);

}

I hope this helps. If you need some thing else, please revert back, I'll be happy to help you.

Cheers!!!

Umang

Former Member
0 Kudos

hi

Former Member
0 Kudos

Hi,

for copying one node to another u can use this also

int size=wdContext.nodeAbc().size();

for(int i=0;i<size;i++){

IPrivateTimerView.IAbcElement eleABC= wdContext.nodeAbc().getAbcElementAt(i);

boolean check=eleABC.getCheck();

if(check)

{

IPrivateTimerView.IAbc_1Element eleABCCopy= wdContext.nodeAbcCopy().createAbcCopyElement();

eleABCCopy.setAmount(eleABC.getAmount());

eleABCCopy.setName(eleABC.getName());

wdContext.nodeAbcCopy().addElement(eleABCCopy);

}

}

here u can copy abc node data to abcCopy node when check(attribute) value is true.

Regards

Trilochan

Former Member
0 Kudos

Hi,

one way to copy the element is by Using the WDCopyService .

to know more about it please go through this thread

Regards,

Ramesh