Adding extension activities

Extension activities are a means to encapsulate reusable functionality for IBM® WebSphere® sMash Assemble flow. Custom extension activities can also be added to the flow editor palette.

To add an extension activity to the flow editor, use the following steps:

  1. Create an extension activity. See the information about Writing extensions in the Assemble flow language and Writing extensions in Groovy for details.
  2. Add the metadata for your extension activity. Such metadata is not only used by the flow engine for validation, but it also directs the tooling to display the extension activity and validate during build-time. See the information about Defining the validation rule for a extension activity for details.

The extension activity has been added to the flow editor, and you can find it in the All activities category.

Customizing your extension activity

You can specify an icon for the extension activity to display in one of the following ways:

  • On the palette: to do this, create a 16x16 size ActivityName.png as icon file in the following directory of your application: public/tooling/icon-activity/.
  • On the figure: to do this, create a 48x48 size ActivityName.png as icon file in the following directory of your application: public/tooling/figure-activity/.

You can add a help document for your extension activity. To do this, put the ActivityName.html file in the following path: public/tooling/assemble/resources/help/activity/ActivityName.html.

You can create a custom category to be listed in the palette and you can use it to classify your extension activities. To do this, put the CustomCategoryName.json file under the following directory: public/tooling/categories/. The following example creates a category file for the feed category:

{
	"name" : "Feed Activities",
	"description" : "Activities for feed manipulation",
	"icon":"/tooling/assemble/resources/images/group.gif", 
	"item" : [
		{
			"name" : "feed",			
			"type": "feed"
		},
		{
			"name" : "aggregateFeeds",		
			"type": "aggregateFeeds"
		}
	]
}
Custom category file format:
Name Description Required
name The name of category in palette. Yes
description The description of category. The tooltip message when mouse hover on the category. No
icon The icon of category in palette.The path of icon is under public directory. No
item The items in this category. Yes

The property view of activity can also be customized.To do the customization, put the tooling metdata to the extension activity.

advanced
Whether to open the "Advanced" part by default.
showContentType
Whether to display the 'content-type' combobox in activity input section. For some activities (e.g. feed kind of activites), 'content-type' is not necessary for these activities. Setting this customization parameter can reduce the 'content-type' noise when editing inputs of these activities
/config/activity/metadata/<activityName> += {
    "tooling":{
    	"advanced":<boolean value>?
    	# true :Open the "Advanced" part
    	# false: Close the "Advanced" part
    	# By default, the value is false
    	
    	"showContentType":<boolean value>?
    	# true :Show the "content-type" in input
    	# false: Not show the "content-type" in input
    	# By default, the value is true
    }
}

Example

Complete the following steps to create an extension activity named myActivity .

  1. Add the myActivity activity, then add the metadata of the activity in the zero.config file as shown in the following example:
    /config/activity/metadata/myActivity = {
        # Two attributes,one is required and other is optional.
        "attributes" : [
            {"name":"message"},
            {"name":"url", "required":false}
        ],
        # One input
        "inputs" : [        
            {"name": "body", "occurrence": "0..1"}
        ],
        # Open the "Advanced" by default
        "tooling":{
        	"advanced":true
        } 
    }
    

    As default, the attribute whose "required" value is set to false can be hidden when the "advanced" checkbox on property dialog is unchecked. You can keep one attribute be displayed all the time by setting up one "advanced" value as false.

    The inputs will always be displayed as default, but when you set its "advanced" value to true, it can be hidden when the "advanced" checkbox is checked. Like the following metadata configuration:

    /config/activity/metadata/myActivity = {
        # Two attributes,one is required and other is optional.
        "attributes" : [
            {"name":"message"},
            # attribute "url" can't be hidden when "advanced" value is false
            {"name":"url", "required":false, "advanced": false}
        ],
        "inputs" : [
            # inputs whose "advanced" value is true can be hidden when the "advanced" checkbox is checked
            {"name": "body", "occurrence": "0..1", "advanced": true}
        ],
        # ...
    }
    
  2. Add the icon for the myActivity activity. To do this:
    1. Put the 16x16 size icon file (small myActivity icon) in the following path: public/tooling/icon-activity/myActivity.png
    2. Put the 48x48 size icon file (larger myActivity icon) into the following path:public/tooling/figure-activity/myActivity.png
  3. Run the tooling. When you myActivity it to the canvas, the required attribute message is displayed, as shown in the following screen capture.

    The message attribute is displayed.

    All attributes of the myActivity activity are shown in the properties view, as the following screen capture shows.

    The attributes of the activity you added are shown in the property view.

  4. Add the help document for myActivity by putting the html file in the following path: public/tooling/assemble/resources/help/activity/myActivity.html.
  5. Create a custom category as shown in the following example:
    {
    	"name" : "My activities",
    	"description" : "My activities",
    	"item" : [
    		{
    			"name" : "myActivity",			
    			"type": "myActivity"
    		}
    	]
    }
    
  6. Save the content in the previous example to a file as My activities.json and put it under the following directory: public/tooling/categories/.
  7. Refresh the tooling and the My activities category is shown as in the following screen capture:

    The My activities category is shown.

Version 2.0.30111