Tree and Composite Projections, IO Projectors

Projections and projectors responsible for model storage and expansion.

Tree projection is a partially-hierarchical projection closely matching the XML representation of the (meta)model.

Composite projection is a single interlinked graph that closely matches the underlying (meta)model.

Projectors Overview

Projectors around Tree projections.

Tree and Composite projections, together with IO projectors are expanded only when componentOption("enableComposites") is configured.

Each available conversion is handled by an expanded projector class.

Tree and Composite projections are part of [...]-shared modules. PrimeToTree/TreeToPrime projectors are part of [...]-logic modules.

TreeToComposite, and all XML-related projectors are expanded separately as part of elements-ioxml project.

Additionally, elements-ioxml contains [...]ExportRunner.java and [...]ImportRunner.java CLI classes responsible for importing/exporting from database via agent RMIs.

Metamodel

Details Projection

Standard projection where all references are defined using DataRefs or Vectors of DataRefs. For some fields the target Details can be looked up and stored as well (deep details), however this is not done in any systematic fashion.

XML Projection

Notice that dataElements and taskElements directories are created due to the composite aggregation with respect to the exported element.

If instead of exporting Component we export a single DataElement as directory, there would be a fields subdirectory, and the root DataElement XML would not contain the <fields> tag.

<!-- model/[component name].xml -->
<component name="[component name]">
  ...
</component>

<!-- model/dataElements/[DataElement name].xml -->
<dataElement name="[DataElement name]">
  <dataElementType name="[dataElementType dataRef name]"/>
  <fields>
    <field name="[field name]">
      ...
    </field>
    ...
  </fields>
  ...
</dataElement>

<!-- model/taskElements/[TaskElement name].xml -->
<taskElement name="[TaskElement name]">
  <targetElement component="[component name]" name="[DataElement name]"/>
  ...
</taskElement>

Tree Projection

Tree projection is a stepping stone between various storage/usage projections: (primeRadiant) database, XML files, and Composite projection (see Projections).

Tree projection closely matches the XML with regards to aggregation option, however remains a tree structure – there are no cycles. Backlinks and crosslinks are represented via DataRefs.

Composite Projection

Composite projections form a single interconnected graph. All indirect references, lookups, options conversions, etc. are performed during the graph construction. This projection is almost identical with the model itself.

Navigation possiblities follow the original model, e.g.

// assuming there is at least one DataElement with at least one Field
@Test
public void testNavigation(ComponentComposite component) {
  assertThat(
    component
      .getDataElements().get(0) // DataElementComposite
      .getFields().get(0) // FieldComposite
        .getDataElement() // DataElementComposite
        .getComponent(), // ComponentComposite
    is(component));
}

See TreeToComposite Projector for in-depth information about the conversion process.

References