cancel
Showing results for 
Search instead for 
Did you mean: 

Check if two IWDNodes have the same content

Former Member
0 Kudos

Hi,

I have a model node that is populated with a set of node elements when the associated RFC is executed. The node has only one attribute of type String.

I'd like to:

1. Store in a temporary variable the content of the node

2. Execute the RFC

3. Compare the previous content of the node with the current content of the node to see if it is exactly the same

I want to define equality between two nodes as:

1. The nodes have the same number of node elements

2. The attribute value of the i-th node element of first node is the same of the i-th node element of the second node

So what I'd like to know is:

1) How can I make a temporary copy of the contents of one model IWDNode without creating an ad-hoc structure in the context?

2) For the comparison, does the equal() method called on IWDNode works or instead do I have to check the single node elements one-by-one?

Thank you,

Pietro

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I've come up with this code but it does not work (the results of the RFC are the same and the equals() call returns false)::

boolean eeFirstTime = 
  (wdContext.nodeOutput_Enti_Searc_Enti().getModelCollection() == null);

List<Zmctbpm_Rfc_Output_Enti_A> previousEEList = null, currentEEList = null;

if (!eeFirstTime) {
  previousEEList = new Vector<Zmctbpm_Rfc_Output_Enti_A>(
		  wdContext.nodeOutput_Enti_Searc_Enti().getModelCollection());
}

**** EXECUTE RFC ****

if (!eeFirstTime) {
  currentEEList = new Vector<Zmctbpm_Rfc_Output_Enti_A>(
		  wdContext.nodeOutput_Enti_Searc_Enti().getModelCollection());

  // Check if the two collections are equal
  if (previousEEList.equals(currentEEList))
	  msgManager.reportSuccess("LISTS ARE EQUAL");
  else
	  msgManager.reportSuccess("LISTS ARE DIFFERENTS");
}

with Zmctbpm_Rfc_Output_Enti_A as the type of the output structure of the RFC and nodeOutput_Enti_Searc_Enti() the model IWDNode bound to the RFC output node.

Edited by: pietro.m on Mar 23, 2011 9:15 AM

Edited by: pietro.m on Mar 23, 2011 9:49 AM

Former Member
0 Kudos

Hi Pietro

You can't just "equalize" two lists, then the reference of both will be compared. (check

[http://www.docjar.com/html/api/java/util/List.java.html]

If you've got two lists, you should compare them by a little loop like this:


boolean found = true;
for (Object o : previousEEList ) {   
  if (! currentEEList.contains(o)) {   
     found = false;
  }
}  

Attention: This code is for java > 1.6, when you've got a WD 2004/7.0 you've to loop like this:



boolean found = true;
for (int i = 0; i < previousEEList.size(); i ++ ) {   
  Object o = previousEEList.get(i);
  if (! currentEEList.contains(o)) {   
     found = false;
  }
}  

Best regards

Marco

Former Member
0 Kudos

Hi,

First get the size of each node and compare them if ther are equal then then do a loop for size times and compare one by one with other node .

use equalsingnorecase() instead of equals () because if the content is characters it may fails the comparation because of the the spaces and all.

Regards,

Govindu