File and Code Generation in ThinkComposer version 1.3

A new version of ThinkComposer (1.3) is available! It can generate text files, either for code generation or custom information export, based on templates using the Liquid markup language. So, the precise knowledge stored in Composition documents can be consumed from external sources. Lets take a look.

Suppose you want to export the information content of the next Composition diagram…

Sample_for_Templates

…and your desired generated file, for the ‘Compute Result’ Concept, would look like:

[Concept]
Global-Id: 7b104a91-b464-484a-9419-9d37ee578b9c
Name: Compute Result
Summary: Use the entered Code to calculate the proper result.
MARKINGS [2]:
 [1] 'Correct' (Correct state.)
 [2] 'Star Gold' (Star Gold award.)
 Descriptor: 'Approved' -- Full compliance with our test cases!
INPUTS [1]:
 [1] 'Flow (Idea 10)' FROM 'Is Valid?'('Yes'); .
OUTPUTS [1]:
 [1] 'Flow (Idea 11)' TO 'Show Result'; .
[End-Concept]

Then, to achieve that formatted result file, you can use the Output-Template editor (accessed thru ‘Domain’ -> ‘Edit Domain’-> ‘Output-Templates’ -> ‘Concept base templates…’) as shown in the next screenshot:

sample-template-decl

The complete sample output-template is:

%%:FileName={{ TechName }}.txt
[Concept]

Global-Id: {{ GlobalId }}
Name: {{ Name }}
Summary: {{ Summary }}

{%- if Markings.Size > 0 -%}
MARKINGS [{{ Markings.Size }}]:
{%- for Mark in Markings -%}
[{{ forloop.index }}] '{{ Mark.Definitor.Name }}' ({{ Mark.Definitor.Summary }})
{%- if Mark.Descriptor != null -%}
Descriptor: '{{ Mark.Descriptor.Name }}' -- {{ Mark.Descriptor.Summary }}
{%- endif -%}
{%- endfor -%}

{%- endif -%}
{%- if IncomingLinks.Any -%}
INPUTS [{{ IncomingLinks.Size }}]:
{%- for Link in IncomingLinks -%}
[{{ forloop.index }}] '{{ Link.OwnerRelationship.Name }}'{% unless Link.Descriptor == null %}('{{ Link.Descriptor.Name }}'){% endunless -%}
 FROM {% for OriginLink in Link.OwnerRelationship.OriginLinks -%} '{{ OriginLink.AssociatedIdea.Name }}'{% unless OriginLink.Descriptor == null %}('{{ OriginLink.Descriptor.Name }}'){% endunless -%}; {% endfor -%}.
{%- endfor -%}
{%- endif -%}

{%- if OutgoingLinks.Any -%}
OUTPUTS [{{ OutgoingLinks.Size }}]:
{%- for Link in OutgoingLinks -%}
[{{ forloop.index }}] '{{ Link.OwnerRelationship.Name }}'{% unless Link.Descriptor == null %}('{{ Link.Descriptor.Name }}'){% endunless -%}
 TO {% for TargetLink in Link.OwnerRelationship.TargetLinks -%} '{{ TargetLink.AssociatedIdea.Name }}'{% unless TargetLink.Descriptor == null %}('{{ TargetLink.Descriptor.Name }}'){% endunless -%}; {% endfor -%}.
{%- endfor -%}

{%- endif -%}
[End-Concept]

Output-Templates can be defined, at the Domain level, for:

– Composition: To create a file for the root of the Composition.

– Concepts: Use one template to generate files with the same format from all Concepts.

– Relationships: Same as the prior, but for Relationships.

Plus, the Output-Template can be declared individually per each Idea (Concept or Relationship) Definition, in case you have specialized or more complex ones.

These Output-Templates are stored in the Domain, so you can reuse them in other Compositions.

To generate the files, just select the “Tools” tab and click the “Generate Files…” button. The next window will be shown:

sample-file-generation

The description of the Output-Templates language and the ThinkComposer Information model can be found in the manual.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s