on 11-12-2009 7:16 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.