I am trying to remove a CComplexObjects from a list of CComplexObjects
by using remove(myCComplexObject).
This call always removes the first element of the list, not the
appropriate one (where defining_code etc. is the same).
In my case, I have all the ISM_TRANSITIONs of
openEHR-EHR-ACTION.follow_up.v1draft.adl in this list.
I believe this has something to do with the EqualsBuilder used in
CComplexObject and related Classes.
For example:
In CComplexObject, equality is mainly checked by checking for the
equality of the attributes of the two CComplexObjects.
A CAttribute then is equal to another CAttribute if (apart from
rmAttributeName and existence), its children are equals.
The Children of CAttribute are CObjects (generally speaking), but in my
case they are more specifically CComplexObjects.
Now, the problem I think could be that the EqualBuilder doesn't care
that I my children of CAttribute are actually CComplexObjects in my case
and only compares the CObjects for equality (and as rmTypeName,
occurrences, and nodeId are always the same in my case, it always finds
the first element in my list.)
If it compared on CComplexObject-basis, each element in the list would
be different, as its attributes are different.
I am trying to remove a CComplexObjects from a list of CComplexObjects
by using remove(myCComplexObject).
This call always removes the first element of the list, not the
appropriate one (where defining_code etc. is the same).
In my case, I have all the ISM_TRANSITIONs of
openEHR-EHR-ACTION.follow_up.v1draft.adl in this list.
I believe this has something to do with the EqualsBuilder used in
CComplexObject and related Classes.
For example:
In CComplexObject, equality is mainly checked by checking for the
equality of the attributes of the two CComplexObjects.
A CAttribute then is equal to another CAttribute if (apart from
rmAttributeName and existence), its children are equals.
The Children of CAttribute are CObjects (generally speaking), but in my
case they are more specifically CComplexObjects.
Now, the problem I think could be that the EqualBuilder doesn’t care
that I my children of CAttribute are actually CComplexObjects in my case
Hi Sebastian,
The euqals() from CComplexObject should be used instead of the one in CObject in this case. It does seem strange to me.
Can you develop a small unit test to demonstrate this?
EqualsBuilderTest is a small test case.
Just copy the two attached archetypes in your d:\ drive (or edit the paths in the main method)
I commented the source code with some info and when you run it, it shows which element should be removed, and which one actually is removed.
Look for the codeList of current_state and careflow_step in the output, which is different
At first glance, it looks like a problem from CAttribute or CComplexObject but as I dug deeper, I found the the root problem is the missing equals() in the CCodePhrase. Because the only difference between these Transitions is the defining_code leaf constraint which is a CCodePhrase.
I have now checked in the changes on the trunk. We will need to do the same with other CDomainType as well.