user3165438
user3165438

Reputation: 2661

Where are package relations stored?

I would like to measure the amount of dependencies of my EA package in other packages in the model.

I therefore loop on t_connector to identify the records in which elements from my package are the source, and the destinations are elements from other packages.

All works fine with relations between elements, but relations between packages are different:
The sub packages in my package sometimes depend on external packages in the model. Unfortunately, t_connector does not store this data!
Where, then, the package relations are stored?

Upvotes: 2

Views: 93

Answers (2)

Uffe
Uffe

Reputation: 10504

All connectors are stored in the t_connector table. However, the references in t_connector.Start_Object_ID and t_connector.End_Object_ID refer to t_object.Object_ID -- not to t_package.Package_ID.

In the EA data model, a UML package has a dual representation: one row in t_package and one in t_object, with t_object.Object_Type = 'Package' and t_object.PDATA1 = t_package.Package_ID. (Note that the t_object.PDATA columns are strings.)

So strictly speaking, only elements have connectors in EA. But the Package class in the API hides this and allows you to loop over the connectors of the package element as if they belonged to the package itself using the Package.Connectors collection -- but if you look at Connector.ClientID and Connector.SupplierID you'll see that neither one matches the Package.PackageID of the package whose connectors you're looping over.

If a connector runs from the current package to some other package, what you need to do in order to retrieve the other end of the connector is to query the repository for the element -- not the package -- with the connector's client ID, as in

connectedPackageElement = Repository.GetElementByID(connector.ClientID)

The good news is that the package proper and its package element both have the same name. But if you need to pull more information from the package, you'll need to issue another call like

connectedPackage = Repository.GetPackageByID(connectedPackageElement.MiscData(0)

Since you said that you were "looping over" the connectors, I've assumed you're using the API rather than issuing SQL queries. But the structures are the same; t_object corresponds to the Element class, t_package to the Package class and t_connector to the Connector class.

Upvotes: 2

qwerty_so
qwerty_so

Reputation: 36313

They are stored in the hierarchy. t_package.parent_id links child packages to their parent. A connector is only created if you explicitly create one. If so, the connector source/target link the id of the package's element.

Upvotes: 2

Related Questions