Tigerstripe Plugin Miscellany

From Eclipsepedia

Jump to: navigation, search

< To: Tigerstripe_Tutorials

This section includes some handy reference documents that are useful when putting together plugins.

Default Velocity context contents

Collections

There are a number of Collections in the context that allows access to sets of artifacts. These Collections are described in the following table and would typically be accessed as follows: #foreach ($artifact in $artifacts)

Collection Name Type Contents
$artifactsCollection<IArtifact> All artifacts within this project.
$entitiesCollection<IManagedEntityArtifact> All Managed Entity artifacts within this project.
$datatypesCollection<IDatatypeArtifact> All Datatype artifacts within this project.
$eventsCollection<IEventArtifact> All Event artifacts within this project.
$enumsCollection<IEnumArtifact> All Enumeration artifacts within this project.
$exceptionsCollection<IExceptionArtifact> All Exception artifacts within this project.
$queriesCollection<IQueryArtifact> All Query artifacts within this project.
$updateProceduresCollection<IUpdateProcedureArtifact> All Update Procedure artifacts within this project.
$associationsCollection<IAssociationArtifact> All Association artifacts within this project.
$associationClassesCollection<IAssociationClassArtifact> All Association Class artifacts within this project.
$sessionsCollection<ISessionArtifact> All Session Facade artifacts within this project.
$allArtifactsCollection<IAbstractArtifact> All artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allEntitiesCollection<IManagedEntityArtifact> All Managed Entity artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allDatatypesCollection<IDatatypeArtifact> All Datatype artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allEventsCollection<IEventArtifact> All Event artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allEnumsCollection<IEnumArtifact> All Enumeration artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allExceptionsCollection<IExceptionArtifact> All Exception artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allQueriesCollection<IQueryArtifact> All Query artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allUpdateProceduresCollection<IUpdateProcedureArtifact> All Update Procedure artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allAssociationsCollection<IAssociationArtifact> All Association artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allAssociationClassesCollection<IAssociationClassArtifact> All Association Class artifacts within this project, plus those in Referenced Projects and Dependent Modules.
$allSessionsCollection<ISessionArtifact> All Session Facade artifacts within this project, plus those in Referenced Projects and Dependent Modules.

Note : The contents of the collections above may be reduced by the application of Contract facets.

Other contents

$artifact (IAbstractArtifact)

In an Artifact Rule, this is set to the current artifact. That is on each iteration of the rule over a different artifact in the Tigerstripe project, this will have a different value. If a specific artifact type was selected in the rule (the AnyArtifact option has not been selected), the actual artifact will be of that type ( eg IManagedEntityArtifact) and the object can be cast to the precise type for access to the specifics of that artifact type.


$pluginConfig (IPluginConfig)

The plug-in reference gives access to the values of the plug-in Global Properties. For example, $pluginRef.Properties.getProperty(“propname”)

$tsProjectHandle (ITigerstripeModelProject)


Contains information about the Tigerstripe project such as the version, name, and Copyright notice of your project. This information is held in ProjectDetails object, for example $tsProjectHandle.getIextProjectDetails().getProperty("copyrightNotice","")

$runtime (TigerstripeRuntime)

The runtime object contains information about the Tigerstripe installation so you can check the version of Workbench. For example, $runtime.getProperty("tigerstripe.feature.version")

$sessionManager (IArtifactManagerSession)

The artifact manager session is used to gain access to artifacts in the project, or in project dependencies. For example, if you have a String that should be an FQN of another artifact, you can access that artifact using $sessionManager.getIArtifactByFullyQualifiedName($fqnString)

$util (VelocityContextUtil)

A utility class that contains a few simple String handling utilities.

stripExternalQuotes(String arg0)removes leading and trailing quotation (”) characters.
unCapitalize(String arg0)Turns the first character to lower-case.
capitalize(String arg0)Turns the first character to upper-case.
getLastSegment(String arg0)Returns the part of the String after the last “.” character.
toLowerCase(String arg0)Returns entire Strings in lower-case.
toUpperCase(String arg0)Returns entire Strings in upper-case.

Example use : $util.capitalize($attribute.Name)

$exp (IExpander)

A utility that can be used to simplify access to some model, plug-in, or project variables. The currentArtifact or currentModel must be set prior to use for artifact or model attributes, but the pluginRef is pre-set.

Example use : $exp.expandVar($model.TargetNamespace)

$templateName (String)

The local pathname of the template that is currently being used. For example, templates/wsdm/type.vm.

$pluginDir (String)

The path to the root of the plugin when it is deployed. This is useful for gaining access to files that have been included with the deployed plugin.


Using an Expander