Building a Simple IBF solution - For Beginners, Part 4
This
article focuses on the creation of operations that are a part of an Action element
in the Metadata and is a continuation of the STEP4 in the creation of an IBF solution.
In order to know why we are doing
certain things and what to expect, given below is an overview of what is involved
in adding operations to an Action.
1) Define an operation of type OperationQueryMenu.
This operation will query the entity and view for menu item definitions and get the
required data.
2) Add a custom operation type named
“MSIBF.UI.ShowAssociations”. This is an operation type defined in Microsoft.InformationBridge.Framework.UI.dll
and corresponds to an operation that internally calls a routine to display the menu
items.
3) Create an operation of the type
“MSIBF.UI.ShowAssociations” and name it “ShowAssociations”.
4) Add a custom operation type named
“MSIBF.UI.ShowRegion”. This is another operation type defined in Microsoft.InformationBridge.Framework.UI.dll
and corresponds to an operation that internally calls a routine to render the User
Control created by the user.
5) Create an operation of the type
“MSIBF.UI.ShowRegion” and name it “ShowRegion”
6) Double click the Action named
“Display Greeting Message” to open up the Operation Canvas. Drag and drop the operations
QueryMenu, ShowAssociation and ShowRegion in the same order onto the canvas. So now
we are done with the adding operations to the Action element. This finishes the STEP4
that involved creating metadata to be published to the IBF service.
Being aware of these high level
steps will ensure that we do not get lost in the low-level details.
Now, I shall proceed to elaborate
each of the steps outlined above.
1) In the metadata explorer, expand
the artifact tree to the Operations folder.
Double click [Add Operation…] to open
the Add Operation dialog box. Enter QueryMenu as
the Name of the Operation. Leave the Entity field as it is. Select OperationQueryMenu as
the Type.
2) In the OperationQueryMenuProperties,
click the button associated with the Input Schema list box to open up the Add
Schema dialog box. Assign the value AnySchema to
the name and select Schema String as the
type of Schema as shown below.
Click OK to complete the definition
of this schema and assign the value AnySchema to “Input Schema” & “Output Schema”
property of OperationQueryMenu. This is what we have at the end of these inputs.
Click OK to complete creation of
QueryMenu operation.
3) Expand the artifact tree to the Custom
Operation Types folder and double click [Add
Custom Operation Type…] to open Add Custom
Operation Type dialog box. Enter the name “MSIBF.UI.ShowAssociations” as shown
below
Click OK to add this operation to
the custom operation types.
In a similar manner create another
operation of type “MSIBF.UI.ShowRegion” .
4) Double click [Add
Operation…] to create a new operation named “ShowAssociations” and map it to the
type “MSIBF.UI.ShowAssociations” as shown below.
5) Similarly create a new operation
named “ShowRegion” and map it to the type “MSIBF.UI.ShowRegion” as shown below.
NOTE: As mentioned at the start
of this article, ShowRegion is responsible for rendering the user control developed
for an application. Since we have not yet developed the UI for our application, I
have not assigned any value to the Port property. We shall do this after we have coded
our UI and compiled it into a DLL.
6)
Now we are ready to add the operations just created to the Action named “Display Greeting
Message”. Double click this action to open up the Operation Canvas. As you can see
in the figure below, the three actions created above are visible under the toolbox
window.
Now we need to drag and drop these
operations into the operation canvas in the following order: QueryMenu, ShowAssociations
& ShowRegion. This is the order in which we would like to execute our operations.
Given below is what we get when
we are done with adding all the operations. As can be seen in the Metadata Explorer,
these newly added operations appear as child nodes of Action element.
7) Since the above operations will
be executed sequentially, we need to make sure that output of one operation is directed
as input to another. Right click “ShowAssociations” and select Properties. Click the
button labeled “…” associated with TransformationInstances property to bring up the Transformation
Instances dialog box.
Select the values as shown below
and click OK. By doing this, we are indicating that the output of QueryMenu operation
shall provide input to the ShowAssociations operation.
8) The ShowRegion operation takes
the view data as input. However, it requires that the input XML string passed to it
confirm to a specific format. Hence we will need to define an XSLT transformation
on the input View data passed to ShowRegion operation.
Expand the artifact tree to the Transformations folder.
Double click [Add Transformations…] and
enter the details as shown in the dialog box below.
Click the button Adjacent to the Port list
box and add the details as shown below
In the input textbox, enter the
following XSL transformation, which will convert GreetingMessage View data to a format
confirming to the one expected by ShowRegion operation.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:iwb="http://schemas.microsoft.com/InformationBridge/2004"
xmlns:ab="urn-GreetingService-Data">
<xsl:template
match="ab:GreetingMessage">
<iwb:Region
iwb:AssociationName="Region3" iwb:Enabled="true" iwb:EntityName="Friend" iwb:MetadataScopeName="http://InformationBridge/SayHello">
<iwb:RegionProperties
RegionName="Greet Friend" Caption="Greetings to a Friend" Description="Greet Friend
Page" ShowAs="ExpandedRegion" TypeName="SayHello.UserInterface.GreetingMessage">
<xsl:choose>
<xsl:when
test="count(ab:Name) >= 1">
<xsl:copy-of
select="/">
</xsl:copy-of>
</xsl:when>
<xsl:otherwise>
<ab:GreetingMessage>
<EmptyResult
xmlns="">Hello Stranger</EmptyResult>
</ab:GreetingMessage>
</xsl:otherwise>
</xsl:choose>
</iwb:RegionProperties>
</iwb:Region>
</xsl:template>
</xsl:stylesheet>
Click OK to return back to the Add
Transformation dialog box as shown below
Click OK to complete the transform
definition.
Now under the Action, “Display Greeting
Message”, right click on ShowRegion and select Properties. Click the button labeled
“…” associated with the property TransformationInstances and enter the values as shown
below in the dialog box.
So that completes STEP4 for this
article, which was first discussed in Part 2 of this series. As I noted earlier, after
we are done with developing the UI, we shall come back to this step and modify the
metadata to describe the location of our UI assembly.
In the next article of this series,
we shall see how to recognize a smart tag for our application in a Word document and
develop the UI to render the results returned by the Web Service!!!