Book a Demo

Author Topic: Retrieve all requirements in a eap file  (Read 3823 times)

jepessen

  • EA User
  • **
  • Posts: 106
  • Karma: +1/-1
    • View Profile
Retrieve all requirements in a eap file
« on: June 05, 2019, 06:58:47 am »
I'm creating an external C# application for synchronizing EA requirements with an external tool.

I need to retrieve all requirements that are defined in packages. Since project structure is not defined I cannot read specific packages.

How can retrieve all requirements from a EA project?

Code: [Select]
var repository = new EA.Repository();
fileOpened = repository.OpenFile(filePath);
// Project is opened here

// This works
var edition = repository.EAEdition;

// Retrieve list of requirements
var requirements = repository.???;

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Retrieve all requirements in a eap file
« Reply #1 on: June 05, 2019, 01:26:51 pm »
use Repository.GetElementSet(sqlQuery, 2)

Geert

jepessen

  • EA User
  • **
  • Posts: 106
  • Karma: +1/-1
    • View Profile
Re: Retrieve all requirements in a eap file
« Reply #2 on: June 05, 2019, 10:33:53 pm »
I don't know which query should I use, so I've tested a bit and I've used this method that returns everything:

var data = repository.GetElementSet("", 0);

I obtain a bunch of objects, that probably are all objects in the Project Browser.

I've seen that requirements have a Metatype of type "Requirement". I can cycle all of them, control this field and make operation just if a requirement is found, but maybe it's better to retrieve only requirements with the query.

What query should I use in order to retrieve only objects with specific metatype?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Retrieve all requirements in a eap file
« Reply #3 on: June 05, 2019, 10:41:47 pm »
You should really learn the database as a add-in/script developer. That is as important as getting to know the API.

In your case the query is
Code: [Select]
select o.Object_ID from t_object o where o.Object_Type = 'Requirement'
Geert

jepessen

  • EA User
  • **
  • Posts: 106
  • Karma: +1/-1
    • View Profile
Re: Retrieve all requirements in a eap file
« Reply #4 on: June 05, 2019, 11:00:49 pm »
Ok I'll try to learn it. Thanks for the query, it works...