Author Topic: Reverse Engineer  (Read 1834 times)

gritsoft

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love Enterprise Architect 5.0
    • View Profile
Reverse Engineer
« on: October 18, 2005, 04:25:22 am »
hi,

i am new to ea and my main focus is on reverse engineer.

setting up some source folders for reversing i noticed that ea does not show any associations between packages

???is this true?

to get more info i tried this case

creating two packages in logical view with classes

A (package)
A1 (class)
A2 (class)
A1 has an association to A2
B (package)
B1 (class)
B2 (class)
B2 has an association to B1 and A1

when draging both packages (A, B) on a new model ea does not show the association derived from the association of B1 to A1

???is this true or im going wrong?

:othere seems to be also a bug

using this example

A (package)
Class1 (class)
Class2 (class)
A.Class1 has an association to A.Class2
B (package)
Class1 (class)
Class2 (class)
B.Class2 has an association to B.Class1 and A.Class1

the association B.Class1 to A.Class1 in the properties folder link of B.Class1 is not listet. ea does not recognize that A.Class1 is not B.Class1

thanks for any help















Oliver Michalski

  • EA User
  • **
  • Posts: 116
  • Karma: +0/-0
    • View Profile
Re: Reverse Engineer
« Reply #1 on: October 18, 2005, 09:49:01 am »
Hi,

I am something confused. In your model you have associations between classes not packages. I have tried your model and i can see all association at each time. I can't reconstruct your error.

Oliver  ???

gritsoft

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love Enterprise Architect 5.0
    • View Profile
Re: Reverse Engineer
« Reply #2 on: October 19, 2005, 12:52:52 am »
hi,

yes its true the associations are defined between the classes in packages.

but my first example also defines an association between class B2 of package B and class A1 of package A. this results indirectly to an association of package B and package A because the implementation of class B2 in package B wont work without the implementation of class A1 in package A.

???my question is if ea can resolve this association automaticly or if have to set this association on packages manually after reverse engineering.

this means alot of work if there are some packages an classes have to be imported.

???the second example shows that ea gets confused with associations between classes with the same name in different packages

thanks for info
fhr
« Last Edit: October 19, 2005, 12:54:27 am by gritsoft »

Simon M

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6497
  • Karma: +57/-6
    • View Profile
Re: Reverse Engineer
« Reply #3 on: October 19, 2005, 03:20:32 pm »
Reverse engineering does not create associations or dependencies between packages.  It should however create the association between the classes in different packages.  If you want these to show up you will need to create an addin to generate them for you.

EA does attempt to resolve the difference between classes of the same name in different packages.  If you can send in some example source code that EA links incorrectly then we will look at it and see what can be done.
Simon

support@sparxsystems.com

ErnestoC

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
  • I love the smell of napalm in the morning
    • View Profile
Re: Reverse Engineer
« Reply #4 on: November 07, 2005, 07:29:06 am »
Hi

As a matter of interest I tried to do the same in two other different UML tools and none of them resolved the package dependency either.


bigmac

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Reverse Engineer
« Reply #5 on: November 16, 2005, 12:19:34 pm »
Is there anything special and or peculiar about creating dependencies between packages through the automation interface?

I tried to write a simple VB program to create the appropriate dependencies between packages and they never show up in the model (either on the diagram or in the properties of the package). When I change to code to create a dependency between two classes it works fine.

The code snipet that I am using (based on one of the code samples in the online help) is as follows:
Note: the sourceID and targetID are the IDs of the two packages that I am trying to create the dependency between.

Sub AddDependency(sourceID As Long, targetID As Long)

  Dim con As Object
  Dim o As Object

  Dim source As Object
  Dim target As Object
  Dim client As Object
  Dim supplier As Object

  Set source = m_Repository.GetPackageByID(sourceID)
  Set target = m_Repository.GetPackageByID(targetID)
 
  Set con = source.Connectors.AddNew("test link", "Dependency")

  con.supplierID = targetID

  If Not con.Update Then
        Debug.Print (con.GetLastError)
  End If
  source.Connectors.Refresh
 
  Debug.Print ("Client and Supplier set")
             
End Sub


Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 6325
  • Karma: +109/-91
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Reverse Engineer
« Reply #6 on: November 16, 2005, 02:16:02 pm »
Only thing I can think of is that Packages are schizophrenic - they're both Elements and Packages.  Try supplying the package IDs to the entity routine.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

bigmac

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Reverse Engineer
« Reply #7 on: November 17, 2005, 07:12:15 am »
I am not 100% sure what you mean. The code that I posted was passing in the package IDs and using the GetPackageByID() function.

I tried using the package IDs with the GetElementByID() funciton and that didn't work (gave a unknown ID error of some kind).

I also tried using the Element object that is embedded in the package to create the connection but that didn't work either.

The online help says that the Connections collection is read only for packages, but it also says this for Elements and creating the dependecy works for Elements. Maybe it really is readonly for Packages.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 6325
  • Karma: +109/-91
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Reverse Engineer
« Reply #8 on: November 17, 2005, 01:30:40 pm »
Quote
I am not 100% sure what you mean. The code that I posted was passing in the package IDs and using the GetPackageByID() function.

I tried using the package IDs with the GetElementByID() function and that didn't work (gave a unknown ID error of some kind).

I also tried using the Element object that is embedded in the package to create the connection but that didn't work either.

The online help says that the Connections collection is read only for packages, but it also says this for Elements and creating the dependency works for Elements. Maybe it really is readonly for Packages.
Hi bigmac,

I was talking about the embedded Element you mentioned.  Sounds like it may be a bug, since you can do it via the UI.  Report it.

I've read the relations, but not created them.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

bigmac

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Reverse Engineer
« Reply #9 on: November 17, 2005, 01:43:00 pm »
Great thanks for the help. I will report it as a defect.

bigmac

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Reverse Engineer
« Reply #10 on: November 18, 2005, 11:20:02 am »
Thanks to the folks in support (and to Paolo) I have my answer. It did end up being what Paolo suggested. The trick was to set the supplier ID to the package element ID of the supplier package instead of adding the connection to the element of the client  package (which is how I tried to do it in the first place). Now that I have confused everyone here is the code that makes it work.

Sub AddDependency(sourceID As Long, targetID As Long)

  Dim con As Object
  Dim o As Object

   Dim source As Object
   Dim target As Object
  Dim client As Object
  Dim supplier As Object
  Dim targetPackageElementID As Long


  Set source = m_Repository.GetPackageByID(sourceID)
  Set target = m_Repository.GetPackageByID(targetID)
  Set con = source.Connectors.AddNew("test link", "Dependency")

  con.supplierID = target.element.elementID 'instead of targetID

  If Not con.Update Then
      Debug.Print (con.GetLastError)
  End If
  source.Connectors.Refresh

  Debug.Print ("Client and Supplier set")            
End Sub