Skip to main content

Data Resources

DataResources are data files in expansion-resources. When a developer adds an expansion-resource to their expansionSettings, the data from the DataResources will be available to the model. Uses can vary from parts of the model, like ValueTypes, to technical data for the expansion, like ModelLoadingListeners

The functionality of different data types will be explained below, but first we'll focus on how to add data resource files to the expansion-resource.

Data Resource Files

Data resources are XML files which are packaged in an expansion-resource.

A DataResource file looks like this:

<dataResource type="elements::Technology">
<technology name="HSQLDB">
<subdir>hsql</subdir>
<concernType name="DATABASE"/>
<description>-</description>
</technology>
<technology name="POSTGRESQL">
<subdir>postgresql</subdir>
<concernType name="DATABASE"/>
<description>PostgreSQL Database</description>
</technology>
</dataResource>
  • The root tag should be dataResource and should contain a type attribute. This type refers to the ElementType.
  • The files should be placed in a resources directory so that they are included in the build. Pick a subdirectory data/<your-subdir> that is unique for your expansion-resource to avoid any classpath collisions (can be problematic during tests).
    src/
    main/
    resources/
    data/
    example/
    technologies.xml
    libraries.xml
    layerImplementations.xml
    pom.xml

If everything went correctly, you should see the dataResources appear in the target/classes/expansionResource.xml file after building:

<expansionResource name="org.example:example-expanders">
<version>1.0.0-SNAPSHOT</version>
<expanders/>
<features/>
<additionalExpansionSteps/>
<dataResources>
<dataResource>
<path>data/example/technologies.xml</path>
</dataResource>
<dataResource>
<path>data/example/libraries.xml</path>
</dataResource>
<dataResource>
<path>data/example/layerImplementations.xml</path>
</dataResource>
</dataResources>
<modelResources/>
<expansionResourceDependencys/>
</expansionResource>

Testing

To test if the data has been configured correctly, we can call the validate-data mojo:

  <plugin>
<groupId>net.democritus.maven.plugins</groupId>
<artifactId>expanders-maven-plugin</artifactId>
<version>${expanders-maven-plugin.version}</version>
<executions>
...
<execution>
<id>validate</id>
<goals>
<goal>validate-data</goal>
</goals>
</execution>
</executions>
</plugin>

This will try to load the configuration during the maven verify phase to check if the data can be loaded correctly.

It might be necessary to add a dependency on prime-data if the data references predefined data (such as standard layerTypes):

<dependency>
<artifactId>prime-data</artifactId>
<packaging>jar</packaging>
<version>2024.0.3</version>
</dependency>