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",
	"item" : [
		{
			"name" : "feed",			
			"type": "feed"
		},
		{
			"name" : "aggregateFeeds",		
			"type": "aggregateFeeds"
		}
	]
}

The property view of activity can also be customized.Currently it can support whether to open the "Advanced" part by default.To do this, put the tooling metdata to the extension activity:

/config/activity/metadata/<activityName> += {
    "tooling":{
    	"advanced":<boolean value>?
    	# true :Open the "Advanced" part
        # false: Close the "Advanced" part
        # By default, the value is false
    }
}

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
        } 
    }
    
  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 1.1.26825