on 10-14-2008 1:26 PM
I have a context node that contains 0..n items (AttendanceNode). This node contains daily attendance records for employees. I need to look at this node and add an element for any missing work days for each employee (thus each employee has at least one record for each work day).
I am looping though the attendance node in my context. What my question is - is it possible to create a temporary node that I put each of the elements in the attendance node plus the new ones I add - then copy the node back? Is there a better way to do this? My assumption is that it is not correct to add elements to a node you are looping though while you are in the loop.
Regards,
Diane
Hi Diane,
If my understanding is correct, your requirement is as follows:
You have a node called AttendanceNode. It contains some elements, where each element represents attendance of one employee for one particular day. You want to loop through the node and add new elements for the missing dates.
Solution:
-> Loop through the Attendance node and note down the missing dates in one hash map.
-> Now loop throught the hashmap and create new elements with the missing dates and add it to the AttendanceNode.
(or)
-> Loop through the AttendanceNode and put the existing dates in hashmap.
-> Now loop through 1 to 30 or 31 based on the month, check if the date exists in hashmap or not using "if(!hm.contains(date))" and add the new element if necessary.
Note:This requires a logic to decide how many days you have to loop through. Whether it is 28 or 29 or 30 or 31 based on the month and year.
Regards,
VJR.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am not clear with your requirement , you can use the methods from WDCopyService to copy the contents of a node to other node
Ex: WDCopyService.copyElements(source, target)
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I was just reading about the WDCopyService. Question...this target node - my assumption is I'll have to create another node in the context to be the target - do you have any sample code?
Yes you have to create the target node.
Ex :
Here Data and Table are two nodes where data is the source and table is the target.
WDCopyService.copyElements(wdContext.nodeData(), wdContext.nodeTable());
Regards
Ayyapparaj
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.