Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Frank Crow on March 27, 2013, 12:02:13 pm

Title: Transformation - Simple String Manipulation
Post by: Frank Crow 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:


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]
Title: Re: Transformation - Simple String Manipulation
Post by: Eve 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
Title: Re: Transformation - Simple String Manipulation
Post by: Frank Crow on March 28, 2013, 09:18:09 am
Excellent, thanks!

-Frank
 :) :) :)