Exercise 2 Re-using and editing a Custom Transformer
Data Neighborhoods (Google KML)
Overall Goal Make use of a custom transformer created out of a workspace
Demonstrates Basic custom transformer re-use and editing
Start Workspace C:\FMEData2016\Workspaces\DesktopAdvanced\CustomTransformers-Ex2-Begin.fmw
End Workspace C:\FMEData2016\Workspaces\DesktopAdvanced\CustomTransformers-Ex2-Complete.fmw

A colleague - new to FME - has created a workspace that calculates the population density for neighborhoods in the city of Vancouver, and comments that this technique could be reused for other projects.

We've turned her workspace into a custom transformer as a way of doing this and now need to show how to use it multiple times and apply edits to its definition.


1) Start Workbench
Open the workspace containing the embedded custom transformer: C:\FMEData2016\Workspaces\DesktopAdvanced\CustomTransformers-Ex2-Begin.fmw


2) Duplicate Custom Transformer
Notice that we started with two ExpressionEvaluators and now have one ExpressionEvaluator and one custom transformer. Let's place another instance of the custom transformer in place of the ExpressionEvaluator.

Click on the ExpressionEvaluator and press the delete key to delete it.

Click on the DensityEvaluator custom transformer and press Ctrl+D (or right-click > duplicate) to create a duplicate copy of it. This is the same effect as placing a new instance, but quicker. You could do the same task through Quick Add or the Transformer Gallery if you desired.

Connect the second DensityEvaluator into the workflow, in parallel and not in series:


3) Set Custom Transformer Parameters
By creating a second instance of the custom transformer we've started to re-use our content, which is great. However, the second instance is currently processing the wrong data.

Click the cog wheel icon to open the parameters dialog for the second DensityEvaluator. This time set the population parameter to TotalPopulation2011 (not 2001).


4) Run Workspace
Run the workspace and inspect the output to ensure the data is being processed correctly.

One obvious problem with the output from the transformer is that the result is put into an attribute called PopulationDensity2001, regardless of what data is being processed.

This is not useful; for example the 2011 results also get the same name, as would any other scenario where we used this transformer. We should improve this by making the output name more generic.


5) Edit Custom Transformer
Click on the tab labelled DensityEvaluator to switch the canvas to the custom transformer definition. Open the ExpressionEvaluator parameters and change the name of the New Attribute parameter to DensityResult.

If you run the workspace again you’ll notice that DensityResult is the attribute output by both instances of the custom transformer; i.e. one edit has fixed both of them!


6) Rename Ports
One other edit we ought to make is to the port names of the custom transformer. At the moment they are not very elegant.

Still within the DensityEvaluator tab, click the input port object in the custom transformer definition (currently labeled AreaCalculator_Input) and press F2 to edit the name. Change the name to Input.

Now repeat the process for the output port object, renaming it to Output.

Click the Main tab to check back on the main canvas and confirm the changes have been made:


CONGRATULATIONS
By completing this exercise you have learned how to:
  • Use multiple instances of a custom transformer
  • Make a custom transformer generic for use anywhere
  • Rename output ports in a custom transformer

results matching ""

    No results matching ""