Book a Demo

Author Topic: Transformation - Simple String Manipulation  (Read 4610 times)

Frank Crow

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Transformation - Simple String Manipulation
« on: March 27, 2013, 12:02:13 pm »
We are following a SoaML service interface scheme.   That means that, in the PIM, the client provided responses are "conjugate" interfaces and are named as the primary interface with a leading tilde.

I'm creating new classes on transformation that realize these interfaces, but I want to give them more meaningful names.   Transformation like this:

  • WidgetFactory becomes WidgetFactoryService
  • ~WidgetFactory becomes WidgetFactoryClient

I think that I could use some for of %if%, variable assignment and an expression, but I can't seem to figure it out from the documentation.   Any advice greatly appreciated.


Thanks,
Frank

[/list]

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Transformation - Simple String Manipulation
« Reply #1 on: March 28, 2013, 08:47:07 am »
This achieves what I think you are after:
Class Template
Code: [Select]
%elemType%
{
  %TRANSFORM_REFERENCE("Class")%  
$first = %LEFT(className, 1)%
%if $first=="~"%
  name=%qt%%MID(className, 1)%Client%qt%
%else%
  name=%qt%%className%Server%qt%
%endIf%
}

But I question if you don't actually want a server and client generated out of the same class as follows.
Class Template
Code: [Select]
%elemType%
{
  %TRANSFORM_REFERENCE("Client")%  
  name=%qt%%className%Client%qt%
}

%elemType%
{
  %TRANSFORM_REFERENCE("Server")%  
  name=%qt%%className%Server%qt%
}

Potentially linking them as shown at http://www.sparxsystems.com/enterprise_architect_user_guide/9.3/model_transformation/transform_connectors.html

Frank Crow

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Transformation - Simple String Manipulation
« Reply #2 on: March 28, 2013, 09:18:09 am »
Excellent, thanks!

-Frank
 :) :) :)