-------------------------------------------------------------------
relocating associations:
-------------------------------------------------------------------

Associations are "first class citizens" in Rose. Part of what this 
means is that they are not owned by either of the classes that they
connect. They are actually owned by the package in which they were 
first created.  This can cause some unexpected behaviors if you do
not realize that the package owns the association.  For instance, 
if the user controls all packages and moves two classes that are 
related with an association into a different package, the 
association will not move with them. If he later loads only the 
package that contains the classes, the association will show up as 
not loaded (an M with a slash through it will be attached to the 
association).

Starting with Rose 98i, Rose will show associations in the
browser. This should help make it more clear that associations
are owned by a package, not a class.  You can drag these 
associations in the Browser from one package to another to
relocate them.   

-------------------------------------------------------------------

QUESTION:
During development, we typically use "working" class categories so 
that different designers can work in what will eventually be one 
class category.  The problem is this - when we relocate a class 
from one class cat to another the relationships do not always move.
Inheritance seems to move with the classes but aggregation does 
not. Is there a way to relocate the relationships without deleting 
them in the old class category and then re-creating them (and their
associated code generation properties) ?


ANSWER:
Yes. Packages (formally class categories) own classes. You can move
classes from one package to another and some of the relationships 
move with them, such as inheritance (AKA generalization or "has" 
and "use" in Booch). On the other hand, Associations and 
Aggregations are bidirectional, so they do not belong to any class.
They are owned by the package. You can copy a class from one 
package to another and then do Edit:Relocate and the new package 
will own the class with its relationships, except the associations 
(and aggregates).  Associations must also be copied and relocated, 
separately.

----------------------------------------------------------------------

QUESTION: 

How can I move about 100 associations from one package to another
in short way?

ANSWER:

Try the following:

- Create a new diagram in the destination package.
- menu 'Query->Add Classes' and select the related classes
- menu 'Edit->Select all'
- menu 'Query->Expand Selected elements' and select 1 level
- Select in the diagram the associations to be moved.
  (Holding down the control key while selecting associations
   will allow you to do multiple selects).
- menu 'Edit->Relocate'
- delete the diagram.

-------------------------------------------------------------------

'Script to relocate associations
'If both classes on either side of the association are moved to a
'new package, running this scrit will then also move the related 
'assocation between these two classes, to the new location where 
'these classes reside.
'BACKUP MODEL BEFORE running any script that modifiys it!!!

Sub Main
 Dim allClasses As ClassCollection
 Dim aClass As Class
 Dim assocs As AssociationCollection
 Dim assoc As Association
 Dim otherClass As Class
 Dim aRole As Role

 Viewport.Open
 Print "begin relocate"
 Set allClasses = RoseApp.CurrentModel.GetAllClasses()

 For i% = 1 To allClasses.Count
  Set aClass = allClasses.GetAt(i%)
  Set assocs = aClass.GetAssociations()

  For j% = 1 To assocs.Count
   Set assoc = assocs.GetAt(j%)
   Set aRole = assoc.GetOtherRole(aClass)
   If aRole Is Nothing Then
    MsgBox "oops"
    Exit Sub
   End If
   Set otherClass = assoc.GetOtherRole(aClass).Class
   If aClass.ParentCategory Is Not otherClass.ParentCategory Then
    Print "different cats: " & aClass.GetQualifiedName() & ", " &
otherClass.GetQualifiedName()
   Else                                                 
    aClass.ParentCategory.RelocateAssociation assoc
   End If
  Next j%
 Next i%
Print "Done"
End Sub

-------------------------------------------------------------------

Patrick Kennedy
 Rational Support

                -----Original Message-----
                From:   "M�nnig, Olaf" [mailto:[EMAIL PROTECTED]]
                Sent:   Tuesday, September 11, 2001 5:40 AM
                To:     '[EMAIL PROTECTED]'
                Subject:        (ROSE) Where to put the associations?


                Hi, all!

                When I have an association between two classes organized in
two different
                packages, in which package should I put the association?

                I cannot understand the system Rose uses to put associations
in packages. Is
                anyone out there who can explain that? Should I re-organize
the
                associations?

                Background of the question is: when we use controlled units,
every once in a
                while there is a situation that an association in a package
is to be edited,
                but cannot, because its spec is in another package. Then
it's quite
                disgusting that the other package must be checked-out
despite nothing shall
                be changed there.

                Who helps?

                Thanks in advance,
                Olaf M�nnig

                --------------------
                Diplom-Informatiker Olaf M�nnig
                T-Systems
                debis Systemhaus GEI GmbH
                Martin-Schmei�er-Weg 18, D-44227 Dortmund 
                Telefon: +49 (231) 9744 664 
                Telefax: +49 (231) 9744 600
                E-Mail: [EMAIL PROTECTED] 
                Internet: http://www.t-systems.de 
        
************************************************************************
                * Rose Forum is a public venue for ideas and discussions.
                * For technical support, visit
http://www.rational.com/support
                *
                * Admin.Subscription Requests: [EMAIL PROTECTED]
                * Archive of messages:
http://www.rational.com/support/usergroups/rose/rose_forum.jsp
                * Other Requests: [EMAIL PROTECTED]
                *
                * To unsubscribe from the list, please send email
                *
                * To: [EMAIL PROTECTED]
                * Subject:<BLANK>
                * Body: unsubscribe rose_forum
                *
        
*************************************************************************
************************************************************************
* Rose Forum is a public venue for ideas and discussions.
* For technical support, visit http://www.rational.com/support
*
* Admin.Subscription Requests: [EMAIL PROTECTED]
* Archive of messages: http://www.rational.com/support/usergroups/rose/rose_forum.jsp
* Other Requests: [EMAIL PROTECTED]
*
* To unsubscribe from the list, please send email
*
* To: [EMAIL PROTECTED]
* Subject:<BLANK>
* Body: unsubscribe rose_forum
*
*************************************************************************

Reply via email to