MicroStrategy ONE

Code Samples

The following code samples are provided with MicroStrategy Web, as additional assistance to help you get started with various types of customization tasks. They are located under samples in the SDK installation directory. The specific code samples for each of the customization scenarios described in the Web SDK portion of the MSDL are located under CustomizationPlugins in the SDK installation directory.

Many samples are provided with the SDK, but only the Java, XSL, and sample applications are discussed here.


Java class and source files

The following samples require a Java development environment for modification. The samples discussed here can be found in the SDK installation directory under samples/java/beans:

Name Description Additional reading

SampleCustomBean

Demonstrates how to create a custom bean with only one property, which can be updated through a custom event handler.

 

 

SerializeSampleBean

Demonstrates how to save and restore the state of a bean.

The following samples require a Java development environment for modification. The samples discussed here can be found in the SDK installation directory under samples/java/dialog:

Name Description Additional reading

SimpleEditorBean

 

Demonstrates how to create a custom editor bean.

 

 

SimpleEditorTransform

 

Demonstrates how to create a custom editor transform.

 

 

The following samples require a Java development environment for modification. The samples discussed here can be found in the SDK installation directory under samples/java/events:

Name Description  

CustomDocumentHandler

 

Event handler that determines whether the current document includes an element prompt. If found, it answers the prompt using element ID that was passed in the URL.

 

CustomPromptsHandler

Event handler used to add a new transform to the default collection of transforms in a PromptsBean, and re-open closed prompts.

 

CustomReportHandler

Showcases how to aggregate the ReportEventHandler to add extra logic for the following events:

  • EnumReportBeanEvents.REPORT_EVENT_GRAPH_DRILL
  • EnumReportBeanEvents.REPORT_EVENT_EXECUTE
  • EnumReportBeanEvents.REPORT_EVENT_TABLE_FORMAT

 

CustomReportHandlerForExtendedProps

Event handler used to add extra information to an extended property for a specific report

 

CustomReportHandlerForMaxRowsColsOnly

 

ReportBean event handler used in a customization scenario.

 

CustomReportHandlerForPromptsOnly

 

ReportBean event handler used in a customization scenario.

 

EnumCustomDocumentBeanEvents

Enumeration that extends EnumDocumentBeanEvents by adding custom event and argument IDs used in various custom DocumentBean event handlers.

 

EnumCustomReportBeanEvents

Enumeration that extends EnumReportBeanEvents by adding custom event and argument IDs used in various custom ReportBean event handlers.

 

NewEnumCustomEventHandlerTypes

Defines a new type for a custom event handler. This type is used by NewEventHandlerFactory to decide which handler should be used. (In this case, it creates a new NewTypeCustomHandler handler.)

 

NewEventHandlerFactory

Sample of extended EventHandlerFactory that can be used to instantiate NewTypeCustomHandler (described below).

 

NewTypeCustomHandler

Works with NewEnumCustomEventHandlerTypes (in same location) to show you how to define a new EventHandler of a custom type.

 

SampleCustomEventHandler

Demonstrates how to create a custom event handler.

 

The following samples require a Java development environment for modification. The samples discussed here can be found in the SDK installation directory under samples/java/externalsecurity:

Name Description Additional reading

CustoLoginValidator

 

Performs validation. 'MyCustomExternalSecurityPlugin' calls this class's validation function to perform user validation in the user-mapping sample.

 To perform validation relevant to your system, you must change the code in this function.

 

MyCustomExternalSecurity

 

Demonstrates the following:

  • Returning a valid session without requiring a login.
  • Validating against an external source.

 

Two sample databases, ExternalSecurity.mdb and ExternalSecurityDB.mdb, are included in the same folder along with the samples mentioned in the table above.

The following samples require a Java development environment for modification. The samples discussed here can be found in the SDK installation directory under samples/java/monitoring:

Name Description Additional reading

MonitoringUseCases

 

Demonstrates the use cases for administrative monitoring of Intelligence Server activities, such as jobs, user connection and database connection.

 

Use Cases

The following samples require a Java development environment for modification. The samples discussed here can be found in the SDK installation directory under samples/java/sessionhelper:

Name Description Additional reading

SessionHelper

Abstracts some of the logic of the session object and exposes it in a friendlier way by exposing a series of properties and methods.

 

SessonHelperException

Exception thrown by the SessionHelper when an API error occurs.

 

The following samples require a Java development environment for modification. The samples discussed here can be found in the SDK installation directory under samples/java/sso:

Name Description Additional reading

ErrorInfo

Stores error code and error message when an error occurs in the Single Sign-On sample application.

 

 

 

SSOESM

Implementation of MicroStrategy External Security module that is a part of Single Sign-On sample application. Useful when using MicroStrategy Web with identity management products.

 

The sample application is provided in a single WAR file (sso.war). The properties file used by the sample (ssoesm.properties) is provided in a plug-in called SSOSample, located under theCustomizationPlugins/AdvancedScenariosfolder in the SDK installation directory. Detailed instructions for installing and using the sample application are provided in the Setting Up and Using the SSO Sample topic.

 

The following samples require a Java development environment for modification. The samples discussed here can be found in the SDK installation directory under samples/java/transforms:

Name Description Additional reading

SampleCustomTransform

 

Demonstrates how to create a custom transform.

 

SparklinesTransform

 

Demonstrates how to create an AJAX visualization that displays Sparklines (small line charts) using Google's© Graph API.

 

The following samples require a Java development environment for modification. The samples discussed here can be found in the SDK installation directory under samples/java/transforms/contextmenus:

Name Description Additional reading

CustomEdit

 

Demonstrates how to add a menu element.

 

 

The following samples require a Java development environment for modification. The samples discussed here can be found in the SDK installation directory under samples/java/transforms/excel97:

Name Description Additional reading

ColHeader

Extends ReportGridCellColHeaderImpl by adding necessary HTML tags and attributes to format the cell without using CSS.

 

 

ColTitle

Extends ReportGridCellColTitleImpl by adding necessary HTML tags and attributes to format the cell without using CSS.

 

CssHTMLMappingHelper

Parses CSS string of a report and creates a structure that can be used to apply formatting to a grid using HTML tags instead of CSS standard.

 

Log

 

Logger class that enables logging at package level.

 

MetricValue

Extends ReportGridCellMetricValueImpl by adding necessary HTML tags and attributes to format the cell without using CSS.

 

ReportHTMLFormatTransform

Generates a grid that is formatted by the browser using HTML tags rather than CSS.

 

Includes a readme.txt file with a detailed explanation of  this transform.

 

RowHeader

Extends ReportGridCellRowHeaderImpl by adding necessary HTML tags and attributes to format the cell without using CSS.

 

RowTitle

Extends ReportGridCellRowTitleImpl by adding necessary HTML tags and attributes to format the cell without using CSS.

 

The following samples do not  require a Java development environment for modification. The samples discussed here can be found in the SDK installation directory under samples/java/transforms/layouts:

Name Description Additional reading

SparklinesLayout.xml

Provides template for rendering AJAX Sparkline visualizations.

 

  • AJAX Sparkline Sample

The following samples require a Java development environment for modification. The samples discussed here can be found in the SDK installation directory under samples/java/webobjects:

Name Description Additional reading

AccessControlListSample

Illustrates how to add new Access Control Entries (ACEs) to an object, edit them, and remove them.

 

 

CustomGroupCreationSample

Illustrates how to create custom groups.

 

FolderBrowsingSample

Illustrates how to browse a folder using the Web Objects API.

 

 

FolderCreationSample

Illustrates how to create a new folder under the "Shared Reports" folder for the "MicroStrategy Tutorial" project.

 

FolderMoveSample

Illustrates how to create two folders under the "Shared Reports" folder for the "MicroStrategy Tutorial" project and move one folder into the other.

 

ReportExecutionSample

Illustrates how to execute a report using the Web Objects API.

 

ReportMoveSample

Illustrates how to create a folder under the "Shared Reports" folder for the "MicroStrategy Tutorial" project and move the "Customer Income Analysis" report into it.

 

SessionManagementSample

Illustrates how to create and close the session with MicroStrategy Intelligence Server.

 

 

 


XSL Files

The following XSL samples discussed here  can be found in the SDK installation directory under samples/xsl:

Name Description Additional reading

DumpXML

Sample XSL for ReportXSLTransform code sample and HTML Document drilling.

OnlyDocMessageID

 

Sample XSL for ReportXSLTransform code sample and HTML Document drilling.


Sample Applications

The following samples are provided along with the MicroStrategy SDK installation. Some of them are meant for deploying in a .NET environment while others can be deployed in a J2EE environment.

The samples for deployment in a .NET environment can be found in the SDK installation directory under samples/DotNET:

Name (location) Description Additional reading

BridgeUtils

Allows you to create a MicroStrategy Intelligence Server session in a .NET environment.

 

SessionHelperBridge

Allows you to create a MicroStrategy Intelligence server session on a .NET environment.

 

 

ThickClient

Illustrates how the URL API can be used to embed MicroStrategy content and functionality into other applications.

 

The samples for deployment in a J2EE environment can be found in the SDK installation directory under samples/java/webapps.

Name Description Additional reading

ExternalSecurity

Demonstrates how to access the External Security Sample Application. This sample can be used directly by extracting the plug-in (ZIP file) to the  root folder of the MicroStrategy Web installation directory.