Configure the Service Factory

Assemblies can only be written in Workspaces. This enables greater flexibility, extraction, and packaging, and it provides the ability to create dynamic dashboards, dynamic cubes, dynamic Cube Views, and dynamic grids.

You can implement a service factory to use capabilities in Workspaces.

Runtime Logic

The service factory is a dispatcher object that routes requests to run rules to specific objects called services that can satisfy these requests.

In a basic setup, a service factory can have a single service for each type of rule.

Example: One rule is for data management calls, and one rule is for XFBR calls.

However, a service factory can also invoke multiple services of a specific type, depending on context variables.

Example: Route calls for data management jobs to one service from Monday to Friday and then to a different service from Saturday to Sunday.

It is not required to provide a service for each supported type.

Example: If the service factory is not used for requests of that type, it may use the traditional approach, and everything will function correctly.

The following image is an example of the service factory process.

Flow diagram showing how a Cube View XFBR is sent to the Service Factory, which identifies the rule type and routes it to the appropriate service, ending with an XFBR rule that returns text to the Cube View.

Create a Maintenance Unit for All Assemblies within a Workspace

This first step is organizational and designed to keep all rules within a single location. Create a maintenance unit within the Workspace to hold all necessary assemblies. The following image displays multiple maintenance units in the Workspace, but only the DynamicCode maintenance unit contains assemblies. This will be the central location for all rules.

Blue highlight box over Dynamic Code under Assemblies.

Create an Assembly File for the Service Factory

The second step is to create an assembly file with the Source Code Type of Service Factory.

See Create an Assembly File.

Add File dialog box shows fields for File Name set to WsAssemblyFactory, Source Code Type set to Service Factory, and Compiler Action set to Use Default.

The service factory assembly file is needed to leverage all items used within assemblies. It should look similar to the following image. This example uses C#.

Code editor displaying the WsAssemblyFactory.cs file with a class that creates service instances based on the assembly service type. The left pane shows project dependencies and files, and the main pane shows the C# switch statement used to return service implementations.

The code enables you to create the following objects:

  • Components

  • Dashboards

  • DataManagementStep

  • DataSet

  • Dynamic dashboard

  • Dynamic Cube View

  • Finance business rules

  • SqlTableEditor

  • TableViews

  • XFBRString

If you are not using any of the objects listed, keep them commented out in the code. Otherwise, you will receive a syntax error when compiling.

Example: If you only need the DynamicDashboard call, the service factory would look similar to the following image.

Sample Service Factory with a DynamicDashboard call that has a yellow highlight line on lines 31-32.

Configure the Workspace Assembly Service Property

This last step enables the entire Workspace to use the new service factory file so that your rules run correctly.

IMPORTANT: Assembly files will not run correctly if you skip this step.

Go to the Workspace, and update the Workspace Assembly Service to follow this format: {WsAssemblyName}.{ServiceFactoryName}

Example: DynamicCode.WsAssemblyFactory

Workspace properties showing the Dynamic Dashboard Examples Workspace, including general details, security settings, shared options, assemblies, and the Workspace Assembly Service set to DynamicCode.WsAssemblyFactory. The left navigation tree displays Workspace folders and configuration groups.

You can also do this on any maintenance unit. As a best practice, keep all assembly files in a single maintenance unit. You can designate the Workspace and maintenance unit level in all actions.

Maintenance Unit properties showing the Bound Param Member Tree selected on the left and the Assemblies section on the right, with the Workspace Assembly Service field set to DynamicCode.WsAssemblyFactory.

Reference the Service Factory in Properties

Service factories can be referenced from configuration properties in different ways, depending on their location.

  • assemblyName.factoryName: This will look for a service factory file called factoryName in the assembly called assemblyName. This can be used on the maintenance unit and Workspace properties.

  • WSMU: This will look for the service factory specified on the maintenance unit containing the object. If it cannot find it, it will search for the service factory specified on the Workspace containing the object. It will fail if it is empty. This can be used on the Dashboard Components properties.

  • WS: This will look for the service factory specified on the Workspace containing the object. It will fail if it is empty. This can be used on the Dashboard Components properties.

  • Workspace.workspaceName.maintenanceUnitName.WSMU: This will look for the service factory specified on the maintenance unit called maintenanceUnitName in Workspace called workspaceName. It will fail if it is empty.

    NOTE: You can specify a Namespace Prefix as workspaceName.

    If the specified maintenance unit is not in the Workspace containing the object that originates the call or if this syntax is used in Cube Views, the specified Workspace must be set to Is Shareable Workspaces. This can be used on the Cube View, Dashboard Components, and Data Management Steps properties.

  • Workspace.workspaceName.WS: This will look for the service factory specified on Workspace workspaceName. It will fail if it is empty.

    NOTE: You can specify a Namespace Prefix as workspaceName.

    If the specified Workspace is not the one containing the object that originates the call or if this syntax is used in Cube Views or Cube Properties, the specified Workspace must be set to Is Shareable. This can be used on the Cube Properties, Cube Views, Dashboard Components, and Data Management Steps properties.

  • Workspace.Current.maintenanceUnitName.WSMU, Workspace.Current.Current.WSMU, and Workspace.Current.WS: The Current keyword can be used to reference the Workspace or maintenance unit without having to fully spell out their names when they contain the object originating the call. This makes the configuration more robust because references will not break if these containers are renamed or copied. This syntax will still follow the same Workspace Is Shareable and application restrictions and behave the same as the explicit syntax. These can be used on the Cube Views, Dashboard Components, and Data Management Steps properties.

Dashboard Components Example

In this example, a component service was implemented with the function name SaveRecord. This service is enabled by the MyFactory Service Factory - Assembly File specified on the same MyMU maintenance unit within the MyWorkspace Workspace, which contains the Button component that will invoke the function when selected on a dashboard.

MyWorkspace navigation tree on the left with Maintenance Units and Assemblies, a middle pane listing assembly dependencies and VB files, and a code editor on the right displaying a VB class for a Workspace component.

The MyMU Maintenance Unit propertes display and the Workspace Assemvly Service property value is MyAssembly.MyFactory

In the MyButton component, the Selection Changed Server Task Arguments field displays the following format: {WSMU}{SaveRecord}{}

Server Task settings display the Selection Changed Server Task set to execute a Dashboard Extender business rule. The Selection Changed Server Task Arguments are set for the SaveRecord action.

To invoke the same rule from a Button component in another maintenance unit named MyMU in the same Workspace, use the following format: {Workspace.Current.MyMU.WSMU}{SaveRecord}{}

To invoke the same action from a Button component in another Workspace named MyWorkspace, you must set the property of MyWorkspace, and change the Is Shareable Workspace field in the Workspace to True, and then use the following format: {Workspace.MyWorkspace.MyMU.WSMU}{SaveRecord}{}

Data Management Steps Example

Data management steps require the expanded syntax.

Example: Workspace.MyWorkspace.MyMU.WSMU

However, to make the configuration more robust, if the factory is specified on the same maintenance unit that contains the step, use the Current keyword.

Example: Workspace.Current.Current.WSMU

Sequences pane displays a selected step named TestStep with the Business Rule panel on the right displaying the configured Workspace business rule, which is Workspace.Current.Current.WSMU.

Member Lists Example

Cube Views require all referenced factories to be in a shareable Workspaces even if service factories are in the same Workspace as the Cube View. The syntax must be explicit.

Workspace selected in the navigation tree on the left with the Sharing panel on the right displaying properties for Is Shareable Workspace set to True and Shared Workspace Names set to MyAssembly.MyFactory.

In this example, a Member List parameter called MyMemberList was created, provided by a service factory specified in the properties of maintenance unit MyMU in Workspace MyWorkspace.

From the MyWorkspace navigation tree on the left, the assembly named MyAssembly is selected. The Files pane displays VB assembly files with a code editor on the right displaying a Finance member list named MyMemberList.

To invoke it from a Cube View, use the following syntax: [Workspace.MyWorkspace.MyMU.WSMU,MyMemberList]

Row Members settings panel displays Member Expansion 1 options, with the primary dimension type set to Account and a member filter referencing a Workspace member list: E#Root.[Workspace.MyWorkspace.MyMU.WSMU,MyMemberList]

GetDataCell Example

The same considerations apply for GetDataCell as for Member Lists.

Example: GetDataCell(“BR#[Workspace.MyWorkspace.MyMU.WSMU,MyDataCellFunction]”):Name(My Check)

Row Members settings panel displays Member Expansion 1 options, with the primary dimension type set to Account and a member filter that uses a GetDataCell function to return members dynamically: GetDataCell(“BR#[Workspace.MyWorkspace.MyMU.WSMU,MyDataCellFunction]”):Name(My Check)

Organize Service Factory Assembly Files

With the service factory set up, you can build any necessary assembly files to bring the Workspace to life. The following image provides an example of the organizational structure of assembly files.

Assembly Files tab displays the Dependencies and Files navigation tree, with C# source files and a folder with Factory Controllers for the selected Workspace assembly.

Notice that the service factory assembly file is separate, and a folder contains all the necessary factory controller files. The Workspaces use one of each of the calls from the service factory assembly file.

You can refer to business rules created as assemblies in other Workspaces, but you cannot refer to service types from other Workspaces. So, a lighter syntax is required when calling business rules throughout the Workspace.

See the following sections:

See the following sections for additional service types: