Template Reference


element-templates

Elements and their structure.

<element-templates>
  <template element='project' use-case='create' selector='new-project'>
    <project>
      <module name="Module">
        <entity name="Enity">
          <field name="id"/>
          <index name="index" type="string" size="255"/>
        </entity>
        <comment caption="comment"/>
      </module>
    </project>
  </template>
</element-template>

element-template

Attribute Values
element project, module, region, comment, entity, index, field, association, many-to-many, inheritance, many-to-many-entity, inheritance-parent, inheritance-child
use-case create, update, template
selector primary-field, new-project, association-field, many-to-many-field, discriminator-field, many-to-many-entity

Selectors

selector allowed element used when
project_new project new project is created
primary_field field project is imported
association-field field association is created
discriminator-field field inheritance is created
many-to-many-field field many-to-many is created
many-to-many entity many-to-many is created

Selector use

primary-field

<template element='field' use-case='create' selector='primary-field'>
  <field name="id" required="true" unique="true" primary="true" auto-increment="true"/>
</template>

Note: Only used for entities without primary key upon project import.

new-project

<template element='project' use-case='create' selector='new-project'>
  <project>
  ...
  </project>
<template/>

association-field

<template element='field' use-case='create' selector='association-field'>
  <field name="{entity-inverse#UL}_id"/>
</template>

discriminator-field

<template element='field' use-case='create' selector='discriminator-field'>
  <field name="{entity-parent#UL}_id"/>
</template>

many-to-many-field

<template element='field' use-case='create' selector='many-to-many-field'>
  <field name="{entity-inverse#UL}_id"/>
</template>

many-to-many

<template element='entity' use-case='create' selector='many-to-many'>
  <orm-attributes>
    <attribute name="isVersionable">true</attribute>
  </orm-attributes>
</template>

Definining many-to-many asociation

<template element='many-to-many' use-case='create'>
  <many-to-many caption="{entity-inverse} to {entity-owner}" mn-entity="{entity-inverse}2{entity-owner}">
    <many-to-many-entity owning-side="true" alias="owner-alias{entity-owner#CFU}"/>
    <many-to-many-entity owning-side="false" alias="inverse-alias{entity-inverse#CFU}"/>
  </many-to-many>
</template>	  

Dynamic templates

There is one more use case for templates and selectors. It’s possibe to define custom templates for dynamic fields. These fields are used as templates in GUI in Entity editor.

As use-case select template, as element enter field and as selector use any custom value, which will be displayed in GUI. 

For example to define uuid field template, enter following fragment to your configuration:

<template element="field" use-case="template" selector="uuid">
   <field name="uuid" type="uuid" required="true" unique="true"/>
</template>

Substitution marks

List of all substitution marks available for each element.

Element Selector Create Update
project   none project
module   project module, project
region   module module, region
comment   module module, comment
entity   project, module project, module, entity
field   entity entity, field
field association entity-inverse,field-inverse none
field many-to-many entity-inverse,field-inverse none
field inheritance entity-parent none
index   entity entity, index
inheritance-parent   entity-parent entity-parrent
inheritance-child   entity-parent, entity-child entity-parent, entity-child
association   entity-owner, entity-inverse, collection-inverse entity-owner, entity-inverse, collection-inverse
association-field   entity-owner, field-inverse none
many-to-many   entity-owner, entity-inverse, entity-mn entity-owner, entity-inverse, entity-mn

Local name vs Full name

Because Skipper now handles object names with full namespace, each object capable to hold namespace has two substitution marks. One for local name and one for name including namespace. Currently namespace can be configured for entity, collection and universal-object.  

Short (local) object name is stored in entity substitution mark as before. If you want to use full object name, use entity-full mark. The same is true for all other substitution marks which use any of namespaced objects.

For example entity-inverse is “User” and entity-inverse-full is “\Model\Users\User”.

Naming styles

Keyword Description
#CFU CamelCaseFirstUpper
#CFL camelCaseFirstLower
#UL under_line
#CFUs CamelCaseFirstUpper in plural form
#CFLs camelCaseFirstLower in plural form
#ULs under_line in plural form