cancel
Showing results for 
Search instead for 
Did you mean: 

Context Node Comparision - Need Idea

Former Member
0 Kudos

Hi Experts

I have a context node with some data, I do have another context node with different name and same attributes of 1st context node. The first context node holds data from UI, the second context node holds data from DB. I need to check these 2 and find out the new, changed and deleted records. I do have a unique identifier in both tables. I need to populate the new, changed and deleted in 3 different tables. New records or Changed records or Deleted records refers to Database.

New: If an entry from UI is new to Database

Changed: If an entry from UI and the same entry from Database has different attribute values.

Deleted: If an entry from Database is not found in UI. I mean the new set of Data in UI misses a few records from Database.

Please advice with your valuable thoughts

Thanks

Ramamoorthy D

Accepted Solutions (0)

Answers (2)

Answers (2)

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Ramamoorthy D

For New entries: New entry is the entry with unique key = NULL. Only after the entry will be inserted into DB it shall get the key.

For Changed entries:

if (IWDNodeElement.isChangedByClient() || IWDNodeElement.isChanged()) {
   // changed entry is here
}

Note: You have to do wdContext.getContext().resetChangesByClient() periodically, after Save changes, for example.

For Deleted entries: see the post above.

BR, Siarhei

Edited by: Siarhei Pisarenka on Nov 13, 2009 9:42 AM

Former Member
0 Kudos

Hi Ramamoorthy,

You have to write a logic to implement this.

For Changed and Deleted Items.

You have to use nested for loop for the records in DB node and records in UI

for(records in DB)
	{
		boolean flagRecFound = false;
		
	   for(records in UI)
	   {
	   	  if(Unique Identifier of rec in DB = Unique Identifier of rec in UI)
	   	  {
	   	  	flagRecFound = true;
	   	  	
	   	  	 1. check all parameters that rec they are changed
	   	  	 2. if yes, add it in the node/table to changed items 
	   	  }
	   }
	   
	   if(!flagRecFound)
	   {
	   	 1. add the rec in the table/node of deleted items
	   }
	}

For New Items

You must be using a table to enter the records. Create another context attribute called "Status" in the table node. While Inserting an Item(OnAction event of Inserting the item), set this context to "N".

wdContext.currentTableNode().setStatus("N");

Now when you are checking for the deleted/changed and New items, write the below code.

for(rec in UI)
	{
		1.check the itemFlag of the context element.
		2. add to the node/table of New Items if flag is N 
	}

Hope this helps you.

Former Member
0 Kudos

Hi Sruthi

Thanks for your quick turnaround.

I will try it out and let you know

Regards

Ramamoorthy D