Extending Business-Process-to-Service-Model transformations

You can extend the Business-Process-to-Service-Model transformation to customize how business processes in a specification model are transformed. The conditions that you specify in a transformation extension enable the transformation to generate domain-specific output.

Before you begin

The following procedure assumes that you know how to create, test, and distribute plug-ins, and that you are familiar with the Eclipse Plug-in Development Environment (PDE).

You must have a transformation plug-in project in your workspace. This plug-in project contains the implementation of the transformation extension. The ID that you specify for the transformation must be unique.

About this task

To extend the Business-Process-to-Service-Model transformation, complete the following steps:

Procedure

  1. In the src folder of the transformation plug-in, in the package that has the same name as the transformation plug-in, create a Java class that extends com.ibm.xtools.transform.core.Transform:
    package com.ibm.xtools.transform.cfm.example.transform;  
    
    import com.ibm.xtools.transform.cfm.example.rules.MyPopulateComponentRule; 
    import com.ibm.xtools.transform.core.Transform;   
    
    /**  
     * com.ibm.xtools.transform.cfm.example.transform.MyTransform  
     */ 
    public class MyTransform     
    	extends Transform {      
    
    	public static final String TRANSFORM_ID = "com.ibm.xtools.transform.cfm.example.transform.MyTransformId"; //$NON-NLS-1$      
    
    	public MyTransform() {         
    		super(TRANSFORM_ID);         
    		add(new MyPopulateComponentRule());         
    	} 
    }

    In this example, com.ibm.xtools.transform.cfm.example.transform is the name of the transformation extension that you create, and com.ibm.xtools.transform.cfm.example.transform.MyTransformId is the unique transformation ID. The MyPopulateComponentRule class contains the implementation details about how to transform a business process in a specification model.

  2. In the src folder of the transformation extension, create a Java package to contain the class or classes that specify whether this transformation extension should transform a specific business process. These classes are called condition classes. In this example, the package is called com.ibm.xtools.transform.cfm.example.condition.
  3. In the package that you create in step 2, create a Java class, called a condition class, which contains the following code:
    package com.ibm.xtools.transform.cfm.example.condition;  
    
    import org.eclipse.uml2.uml.Collaboration;  
    import com.ibm.xtools.transform.cfm.common.util.CommonConfigUtil; 
    import com.ibm.xtools.transform.cfm.example.transform.MyTransform; 
    import com.ibm.xtools.transform.core.ITransformContext; 
    import com.ibm.xtools.transform.core.TransformCondition;  
    
    /**  
     * com.ibm.xtools.transform.cfm.example.condition.MyExtensionCondition  
     */ 
    public class MyExtensionCondition     
    	extends TransformCondition {      
    		public MyExtensionCondition() {         
    			super();     
    		}      
    
    		protected boolean isContextSatisfied(ITransformContext context) {          
    			return (context.getSource() instanceof Collaboration)             
    			&& CommonConfigUtil.getExtensionIdFor(                 
    				(Collaboration) context.getSource(), context).equals(                 
    				MyTransform.TRANSFORM_ID);     
    		}  
    }
    When you run the Business-Process-to-Service-Model transformation, the transformation service uses the information in this condition class to determine if this transformation extension should be invoked to transform a business process in the specification model.
  4. In the plugin.xml file of the transformation extension, add an extension point to register the transformation extension. You must use the same values as the example below for the extension point and targetTransformation attributes. For the other attributes, specify the appropriate values based on the naming conventions that you use to create the transformation extension.
    <extension point="com.ibm.xtools.transform.core.transformationExtensions">
          
          <TransformationExtension author="you" description="my custom extension" document="optional" enabled="true" id="com.ibm.xtools.transform.cfm.example.transform.MyTransformId" name="My custom extension" targetTransformation="com.ibm.xtools.transform.cfm.wbm.transforms.MainTransform" version="1.0.0">
                
     					<TransformDefinition acceptCondition="com.ibm.xtools.transform.cfm.example.condition.MyExtensionCondition" class="com.ibm.xtools.transform.cfm.example.transform.MyTransform" id="myTransformId"/>
                   
    							<ExtendTransform targetTransform="com.ibm.xtools.transform.cfm.wbm.transforms.OwnedBehaviorTransform">
          
    									<AddTransform id="com.ibm.xtools.transform.cfm.example.transform.MyTransform"/>
    							</ExtendTransform>
             
    			</TransformationExtension>
    </extension>

Results

The next time that you create or edit a Business-Process-to-Service-Model transformation configuration, on the Business Process to Service Model Transformation page of the New Transformation Configuration wizard, you can select the new extension to transform business processes.

Feedback