Author Topic: Transform issues  (Read 14276 times)

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8054
  • Karma: +118/-20
    • View Profile
Re: Transform issues
« Reply #15 on: September 19, 2019, 09:34:56 am »
Sure. If you don't select to include elements in child packages they won't be included.

1. Namespace root isn't something you set via a transform. https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/model_domains/namespaces.html

2. That's what the check for an empty packagePath is for in the templates.

3. There's an example of creating a connector from the source element to the target in the help. https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/model_domains/transform_connectors.html

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1077
  • Karma: +28/-8
    • View Profile
Re: Transform issues
« Reply #16 on: September 25, 2019, 02:04:15 am »
The namespace was just an inconvenient distraction.
[SNIP]
3. There's an example of creating a connector from the source element to the target in the help. https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/model_domains/transform_connectors.html
Just to clarify what we are trying to do. We have class A and class B connected by an association. I want to
  • Transform class A into class A1, class B into class B1, and the association (this works fine)
  • Create a trace, which I understand is an Abstraction, between class A and class A1, and another between class B and class B1. None of the examples above work, the problem appears to be that although we have the right source GUID (not transformed) we cannot get the GUID of the transform class to create the connector.

This code works
Quote
$Comment="Copy existing connectors (only interested in Associations and Generalisations"
%if connectorType=="Generalization"%
   Generalization
   {
      %TRANSFORM_CURRENT("name","note","alias", "direction", "stereotype")%
      %TRANSFORM_REFERENCE(connectorType,connectorGUID)%
    Target
    {
       %TRANSFORM_REFERENCE(connectorDestElemName,connectorDestElemGUID)%
       %TRANSFORM_CURRENT("name", "stereotype", "direction")%

     }
    Source
    {
       %TRANSFORM_REFERENCE(connectorSourceElemName,connectorSourceElemGUID)%
       %TRANSFORM_CURRENT("name", "stereotype", "direction")%

    }
   }
%endIf%

%if connectorType=="Association"%
   Association
   {
   %TRANSFORM_CURRENT("name","note","alias", "direction", "stereotype")%
   %TRANSFORM_REFERENCE(connectorType,connectorGUID)%
    Source
    {
       %TRANSFORM_REFERENCE(connectorDestElemName,connectorDestElemGUID)%
       %TRANSFORM_CURRENT("name", "stereotype", "direction")%
       multiplicity=%qt%%connectorDestMultiplicity%%qt%
    }
    Target
    {
       %TRANSFORM_REFERENCE(connectorSourceElemName,connectorSourceElemGUID)%
       %TRANSFORM_CURRENT("name", "stereotype", "direction")%
       multiplicity=%qt%%connectorSourceMultiplicity%%qt%
    }
   }
%endIf%


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8054
  • Karma: +118/-20
    • View Profile
Re: Transform issues
« Reply #17 on: September 25, 2019, 09:00:41 am »
Quote
Connecting to a Class for which you know the GUID
The second type of Class that you can use as a connector end is an existing element for which you know the current GUID. To create this connection, specify the GUID of the target Class in either the source or target end; this script creates a Dependency from a Class created in a transformation, to the Class it was transformed from:
Code: [Select]
Dependency
{
    %TRANSFORM_REFERENCE("SourceDependency",classGUID)%
    stereotype="transformedFrom"
    Source
    {
        %TRANSFORM_REFERENCE("Class",classGUID)%
    }
    Target
    {
        GUID=%qt%%classGUID%%qt%
    }
}

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1077
  • Karma: +28/-8
    • View Profile
Re: Transform issues
« Reply #18 on: September 25, 2019, 04:47:55 pm »
Quote
Connecting to a Class for which you know the GUID
The second type of Class that you can use as a connector end is an existing element for which you know the current GUID. To create this connection, specify the GUID of the target Class in either the source or target end; this script creates a Dependency from a Class created in a transformation, to the Class it was transformed from:
Code: [Select]
Dependency
{
    %TRANSFORM_REFERENCE("SourceDependency",classGUID)%
    stereotype="transformedFrom"
    Source
    {
        %TRANSFORM_REFERENCE("Class",classGUID)%
    }
    Target
    {
        GUID=%qt%%classGUID%%qt%
    }
}
Unless I had a senior moment yesterday, not impossible considering the day I had, that in the Connector macro didn’t work and I don’t understand why. A debug reveals that the transform tries to create a relationship to itself.
The only thing we haven’t try is putting that in the Class macro.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1077
  • Karma: +28/-8
    • View Profile
Re: Transform issues
« Reply #19 on: September 25, 2019, 11:07:30 pm »
The meaning of the word, Help, is very important. Unhelpful Help is no help.

The following code in the official Help is wrong:
Quote
Connecting to a Class for which you know the GUID
The second type of Class that you can use as a connector end is an existing element for which you know the current GUID. To create this connection, specify the GUID of the target Class in either the source or target end; this script creates a Dependency from a Class created in a transformation, to the Class it was transformed from:
Code: [Select]
Dependency
{
    %TRANSFORM_REFERENCE("SourceDependency",classGUID)%
    stereotype="transformedFrom"
    Source
    {
        %TRANSFORM_REFERENCE("Class",classGUID)%
    }
    Target
    {
        GUID=%qt%%classGUID%%qt%
    }
}


The following code works (the subtle but maddening difference is connectorSourceElemGUID instead of classGUID in the TRANSFORM_REFERENCE command)

Code: [Select]
Abstraction
{
%TRANSFORM_REFERENCE("SourceDependency",connectorSourceElemGUID)%
stereotype="trace"
Source
{
%TRANSFORM_REFERENCE(className,connectorSourceElemGUID)%
}
Target
{
GUID=%qt%%classGUID%%qt%
}
}

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8054
  • Karma: +118/-20
    • View Profile
Re: Transform issues
« Reply #20 on: September 26, 2019, 08:58:03 am »
It says classGUID because it can be added to the Class template.

If you add it to a connector template and use connectorSourceElemGUID instead you'll probably generate the connector multiple times (although EA won't create multiple connectors if you have the transform reference for the connector) but you'll also not generate the trace for elements with no outgoing connectors.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1077
  • Karma: +28/-8
    • View Profile
Re: Transform issues
« Reply #21 on: September 26, 2019, 04:58:37 pm »
[SNIP]
It says classGUID because it can be added to the Class template.
Please provide a working example of that code in the Class template. We cannot get that code, the code in the help working anywhere.

[SNIP]
If you add it to a connector template and use connectorSourceElemGUID instead you'll probably generate the connector multiple times (although EA won't create multiple connectors if you have the transform reference for the connector) but you'll also not generate the trace for elements with no outgoing connectors.
v13 does not generate multiple connectors, it only generates 1 connector.
« Last Edit: September 26, 2019, 08:07:02 pm by Modesto Vega »

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1077
  • Karma: +28/-8
    • View Profile
Re: Transform issues
« Reply #22 on: September 27, 2019, 12:22:33 am »
[SNIP]
It says classGUID because it can be added to the Class template.
Please provide a working example of that code in the Class template. We cannot get that code, the code in the help working anywhere.
A working example of the code in the Class template is:
Code: [Select]
Class
{

%TRANSFORM_REFERENCE(className, classGUID)%
%TRANSFORM_CURRENT("stereotype")%
stereotype="A Stereotype"


Abstraction
{
%TRANSFORM_REFERENCE("SourceDependency",classGUID)%
stereotype="trace"

Source
{
%TRANSFORM_REFERENCE(className,classGUID)%
}
Target
{
GUID=%qt%%classGUID%%qt%
}
}

%list="Attribute"%

}
%list="Connector" @separator="\n"%

Anywhere else in the template, the code would give an error. Could somebody please update the help?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8054
  • Karma: +118/-20
    • View Profile
Re: Transform issues
« Reply #23 on: September 30, 2019, 09:49:40 am »
Code: [Select]
%elemType%
{
  %TRANSFORM_REFERENCE("Class")%
  %TRANSFORM_CURRENT()%
}
Dependency
{
    %TRANSFORM_REFERENCE("SourceDependency",classGUID)%
    stereotype="transformedFrom"
    Source
    {
        %TRANSFORM_REFERENCE("Class",classGUID)%
    }
    Target
    {
        GUID=%qt%%classGUID%%qt%
    }
}

Drop the transformed element and the original onto the same diagram and you will see a stereotyped dependency between them.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1077
  • Karma: +28/-8
    • View Profile
Re: Transform issues
« Reply #24 on: October 01, 2019, 02:20:15 am »
Thanks Eve, the code in you last post also works fine as long as we add %list="Connector" @separator="\n"% at the end to trigger a transformation of connectors.

Just for clarity what is the difference between these 2 syntax:
Code: [Select]
Class {}
and
Code: [Select]
%elemType% {
%TRANSFORM_REFERENCE("Class")%
%TRANSFORM_CURRENT()%
}

Something I have also notice is that it appears there is a 1-to-1 relationship between a transformation template and a target folder. Once a target folder has been specified we do not seem to be able to execute the same transform against a different target folder.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8054
  • Karma: +118/-20
    • View Profile
Re: Transform issues
« Reply #25 on: October 01, 2019, 08:45:51 am »
%elemType% will evaluate to Class if you are transforming a class.
%TRANSFORM_REFERENCE("Class")% creates a reference that allows synchronization of transforms, linking etc. See the help for more details.
%TRANSFORM_CURRENT()% copies fields from the original element into the new one.

Yes, I removed all the extra lists from my class template for brevity.

EA remembers the target packages for particular elements. If you generate the same transform for the same elements a second time it will then synchronize with the previous elements instead of creating new ones.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1077
  • Karma: +28/-8
    • View Profile
Re: Transform issues
« Reply #26 on: October 02, 2019, 12:33:14 am »
[SNIP]
EA remembers the target packages for particular elements. If you generate the same transform for the same elements a second time it will then synchronize with the previous elements instead of creating new ones.
Have I understood you correctly?

Let's say I have package A and element E1 and we transform E1 into package B (with the resulting element being E1(b), once element E1 has been transformed into E1(b)) in Package B the source element cannot be transformed into Package C, to create. element E1(c)?

What would happen if we psychically duplicated the transformation template and gave it a different name but use the same code?

 

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8054
  • Karma: +118/-20
    • View Profile
Re: Transform issues
« Reply #27 on: October 02, 2019, 08:55:09 am »
Yes, you understand.

The key though is the TRANSFORM_REFERENCE macro. (See https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/model_domains/crossreferences2.html)

Its purpose is to create a unique id for referencing a transformed class based on the source class. I can create an arbitrary number of elements from a single source element in the one transform. Usually I'll do that by changing the name. I can also create connectors in any combination between those elements by specifying the same 3 values in the transform reference to each end of a connector. When processing a connector you can again create 0..* connectors linking different combinations of the transform results for the source and target relationships. I can even link to the result of a completely different transform.

But all that does rely on creating a unique identifier for each transformed elements.

If you copy your entire transform, the default third parameter will change and you will get a new set of elements.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1077
  • Karma: +28/-8
    • View Profile
Re: Transform issues
« Reply #28 on: October 03, 2019, 03:39:17 am »
Thanks Eve, I think I get the gist of it. Hopefully, one final question. Where in the repository at the transform references stored? In the xref tables?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8054
  • Karma: +118/-20
    • View Profile
Re: Transform issues
« Reply #29 on: October 03, 2019, 08:42:28 am »
I'm afraid I can't remember that detail.

Turn auditing on to its highest setting, run a transform of a single item then look at the raw log.
« Last Edit: October 03, 2019, 08:47:25 am by Eve »