Sorry for my late reply, but I was away for a few weeks.
My problem is related to associations handling when forward and reverse engineering.
Background:
-----------------
The original model was in Rational Rose. All the associations were with unspecified direction, but both ends of each and every association have a name. This means that, in the diagram there are no arrows at any association end, but the associations are in fact bi-directional (as both ends are named). If class A has a member of class B, then B also has a member of A (you can extrapolate this to any cardinality).
Yes, I know that the 'unspecified' direction is inherently wrong if bi-directional is meant, but I cannot change the modellers who are in a standards' committee :-), while I have to deal with the model they produced. Since they've been using Rose for modelling, and in Rose associations are by default with unspecified direction, all the associations are so. The model itself is an ontology, so it is important to have names at both ends of each association. Also, the standard does not want to explicitly state all the directions, in order to allow for implementation flexibility.
From Rose to EA:
---------------------
Now, I've exported Rose model into XMI and imported into EA - so far so good.
In EA - code generation and manual fixes:
-----------------------------------------------------
I started forward engineering from UML to java and stumbled over several problems. Some of them I could solve by manually fixing problems in each and every of about 500 files (now you understand why I was a bit irritated in my first posting):
- imports were missing in .java files
- for each association, EA generated member variables for only one class; e.g., for association between A and B, A had a member of type, but B had not a member of type A.
In EA - reverse engineering/synch and what I couldn't fix:
------------------------------------------------------------------------
After the above issues have been fixed, and the whole code could compile, I've started reverse engineering from the code into the model: In project browser, I select a package, and from its context menu (right mouse click) I select Code Engineering -> Synchronise package contents -> Reverse engineer (source->model). This is now my only mode of operation, since I have my code as master source.
What I would like to preserve in the UML model is the ***single association of unspecified direction*** in the case of each two classes A and B pointing to each other, for every possible cardinality implementation (collection, array, single value). This is what I mean by "normal".
My problem is that EA does synchronisation differently as a function of what I use in my code to implement the cardinalities. Here 3 examples:
1) The case of a java collection at any or both sides produces (or better said: preserves) the single association of unspecified direction in the model. Example:
public class A {
private ArrayList<B> myBs; // card. [1..*] or [0..*]
}
public class B {
private A myA; // card. [1] or [0..1]
}
2) The case of a java array DOES NOT preserve the original association in the model. It creates two uni-directional associations. Example:
public class A {
private B[] myBs; // card. [1..*] or [0..*]
}
public class B {
private A myA; // card. [1] or [0..1]
}
3) The case of a single value at both sides DOES NOT preserve the original association in the model. It creates two uni-directional associations. Example:
public class A {
private B myB; // card. [1] or [0..1]
}
public class B {
private A myA; // card. [1] or [0..1]
}
So, please tell me how I could make the cases 2) and 3) behave as case 1)? In particular, the non-coherent result produced by EA for the 3 cases above is somewhat disturbing, and limits me in the implementation choice if I want to preserve the model.
Hope this one was not "Houston, we have a problem" :-)
Thanx in advance!