Book a Demo

Author Topic: Using a script to assign requirements  (Read 4397 times)

skranenburg

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Using a script to assign requirements
« on: February 18, 2021, 03:53:38 am »
Hi,

In our project, we are trying to streamline report generation based on customized input. To clarify, we are assigning different requirements to a block based on a user's input and outputting those requirements. We have successfully written scripts to take in a csv file and create new "satisfies" connectors to all the necessary requirements, but have now run into the problem that those requirements are not included in the requirement section of the element's properties and thus, aren't outputted along with the rest of the report.

This is the connector script:

function SetGen(target /* ea element*/)
{
   var source as EA.Element;

   source = Repository.GetElementByGuid("{GUID}");
      
   //Instantiate new Connector
   var genConn as EA.Connector;
   var Connectors as EA.Collection;
   tarConn = target.Connectors;
   genConn = tarConn.AddNew("","Generalization");
   
   genConn.SupplierID = target.ElementID;
   genConn.ClientID = source.ElementID;
   
   var soConn as EA.Collection;
   var tarConn as EA.Collection;
   soConn = source.Connectors;

   
   for(i=0;i < tarConn.Count; i++)
   {
      if(tarConn.GetAt(i).Stereotype == "satisfy"){
            var localReq as EA.Element;
            localReq = Repository.GetElementByID(tarConn.GetAt(i).SupplierID);
            Session.Output(localReq.Name + " Applied from " + target.Name);
         
            var newReq as EA.Connector;
            newReq = soConn.AddNew("","Satisfy");
            newReq.SupplierID = source.ElementID;
            newReq.ClientID = localReq.ElementID;
            
            newReq.Update();
            soConn.Refresh();
            tarConn.Refresh();
            

      }
   }
   
   genConn.Update();
   source.Connectors.Refresh();
   target.Connectors.Refresh();

Any input on how to fix this would be greatly appreciated.

Thank you.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Using a script to assign requirements
« Reply #1 on: February 18, 2021, 04:14:23 am »
The element's requirements are no elements. They are special properties of an element. So you can not link them anyhow. Either you have requirement elements externally or you use those element requirements (Paolo had another name for them since they are no requirements; can't recall it...).

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Using a script to assign requirements
« Reply #2 on: February 18, 2021, 08:32:32 am »
The element's requirements are no elements. They are special properties of an element. So you can not link them anyhow. Either you have requirement elements externally or you use those element requirements (Paolo had another name for them since they are no requirements; can't recall it...).

q.

Responsibilities?
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Using a script to assign requirements
« Reply #3 on: February 18, 2021, 06:01:03 pm »
Exactly that was the word. Unfortunately it never made it into EA's UI.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Using a script to assign requirements
« Reply #4 on: February 18, 2021, 07:33:19 pm »
Have you tried to use a Realization relation between the element and the requirement?

Geert