Snippets

From CaseTalk Wiki
Jump to: navigation, search


A snippet is a reusable model fragment stored in an .igt file. Snippets let you capture fact type patterns, object type clusters, or complete sub-models once and insert them into any model. Depending on how a snippet is structured, it behaves either as a plain snippet (merged interactively) or as a template snippet (pattern-driven and idempotent), linked to OTFT[template].

Snippet File (.igt)

Snippets are stored as .igt files (IG Template). The filename without extension becomes the snippet's display name in menus. A file named Auditable.igt appears as Auditable in the Insert menu.

All .igt files in the configured snippets folder (and its sub-folders) are loaded automatically at startup. You set this folder via Tools > Environment > Snippets.

Two Kinds of Snippets

Plain Snippet

A plain snippet is an .igt file containing a set of OFTypes and fact types with no specially named anchor OFType. When inserted, CaseTalk opens a merge wizard where you map the snippet's OFTypes onto existing ones. Use plain snippets for structural patterns you want to place into a model interactively.

Template Snippet

A template snippet is an .igt file that contains an OTFT[template] whose name matches the filename exactly. That OTFT is called the anchor. The fact types in the snippet that have a role played by the anchor define the pattern.

Template snippets behave differently from plain snippets in two ways:

  • Idempotent - applying the same template snippet twice has no effect. CaseTalk detects that the anchor is already present in the model and skips re-importing.
  • Pattern-driven - the anchor acts as a placeholder; it is the roles played by that anchor in the snippet's fact types that define what gets reused.

Using Snippets

Inserting a Snippet into a Model

  1. Open an IG file in the diagram.
  2. Choose Insert > Snippets > <snippet name>.
  3. For a plain snippet, the merge wizard opens. Map OFTypes and confirm.
  4. For a template snippet, the pattern OFTypes are imported immediately with no wizard.

Applying a Template to an OFType

Applying a template marks a specific OFType with a template-driven indicator and imports the pattern into the model. This is the primary way to use the built-in named templates.

  1. Right-click the target OFType in the diagram.
  2. Choose Apply Template > <template name>.
  3. CaseTalk imports the template OFTypes and sets the indicator property on the target OFType.

Only template snippets (those with an OTFT[template] anchor) appear in this submenu. Plain snippets are not listed here.

Built-in Named Templates

CaseTalk ships three named templates, each stored as a specially named .igt file in the snippets folder. Applying one of these sets an indicator on the target OFType and activates a virtual folder in the Source Mapping panel.

Annotatable

File: Annotatable.igt  |  Indicator: Annotatable

Marks an OFType as supporting external annotations. After applying this template:

  • The OFType receives the Annotatable indicator.
  • A ~Annotations virtual folder appears under the OFType in the Source Mapping panel.
  • The virtual folder lists every fact type in the template whose role is played by the Annotatable anchor, making those fact types available as mapping columns.

Typical use: object types that carry supplementary data from external systems (ratings, tags, audit remarks, quality scores).

Transitional

File: Transitional.igt  |  Indicator: Transitional

Marks an OFType as having states or statuses. After applying this template:

  • The OFType receives the Transitional indicator.
  • A ~Transitional virtual folder appears in the Source Mapping panel.
  • Fact types with roles played by the Transitional anchor are exposed as mapping columns for state data.

Typical use: object types with a lifecycle - orders, cases, tickets, documents requiring approval.

Localization

File: Localization.igt  |  Indicator: Localization

Marks an OFType as carrying locale-specific tuple values. After applying this template:

  • The OFType receives the Localization indicator.
  • A ~Localization virtual folder appears in the Source Mapping panel.
  • Fact types with roles played by the Localization anchor are exposed as mapping columns for translated values.

Typical use: object types whose labels or descriptions differ per language or region.

Source Mapping Integration

The indicators set by applying a named template are stored in the model. Each time the Source Mapping panel loads, it reads these indicators and builds virtual folders automatically:

Indicator Virtual folder Populated from
Annotatable ~Annotations Fact types with a role played by the Annotatable anchor
Transitional ~Transitional Fact types with a role played by the Transitional anchor
Localization ~Localization Fact types with a role played by the Localization anchor

To create a mapping connection, drag a source column from the left tree onto a node in one of these virtual folders.

Creating a Custom Template Snippet

To build your own reusable template:

  1. Create a new IG file (or work in an existing scratch IG).
  2. Add an OFType and set its type to Template (OTFT[template]).
  3. Give it the name you want to appear in menus - for example, Auditable.
  4. Add the fact types that form the pattern. For each fact type, ensure at least one role is played by your anchor OFType (Auditable).
  5. Add any supporting OFTypes (value types, label types) required by the pattern.
  6. Save the file as Auditable.igt in your snippets folder.
  7. Restart CaseTalk (or reload templates) - the new snippet appears in Insert > Snippets and Apply Template.

When a user chooses Apply Template > Auditable, CaseTalk imports the pattern OFTypes and the template can be reused safely across any number of models.

See Also