Book a Demo

Author Topic: Merging & Splitting of Elements by Transformation  (Read 2729 times)

ASamol

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Merging & Splitting of Elements by Transformation
« on: April 08, 2008, 08:03:49 pm »
Hi all,

I'd like to merge or split elements like classes by transformation or code generation

Frist case
Splitting of classes by tagged values. Does someone know a way to manage it?

Result should be:


Second case
Merging two or more classes.

Result should be:


Thx in advance for any help and with best regards

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Merging & Splitting of Elements by Transformat
« Reply #1 on: April 09, 2008, 08:10:40 am »
Splitting elements is quite easy.  See the EJB transformations for an example.

Merging isn't so simple as you can't list over the attributes/operations/connectors of a class at the other end of a connector.  To do any of these things you'll need to use an add-in call.  You can search for examples on this forum.  But I'll include another one here.

Example C#
Code: [Select]
public String AddedAttributes(EA.Repository r, object args)
{
   Array p = (Array)args;
   String classGUID = (String)p.GetValue(0);
   EA.Element e = r.GetElementByGuid(attGUID);
   for(short i = 0; i < e.Connectors.Count; i ++) {
     EA.Connector con = (EA.Connector)e.Connectors.GetAt(i);
     ...
   }
   return result;
}

Example template
Code: [Select]
%EXEC_ADD_IN("MyAddinName", "AddedAttributes", classGUID)%