Skip to main content

ModelLoadingListeners

ModelLoadingListeners are custom logic that hook into the Model Loading logic.

Listeners can be defined in DataResources, they describe a ModelLoadingStep to which to subscribe and an implementation that point to a java class. After the step in the model loading process has been performed, all listeners subscribed to that step will be executed.

You can subscribe to any of these steps:

  • ExtractResourcesStep
  • PrepareModelStep
  • ReadModelStep
  • ConvertModelStep
  • EnrichModelStep
  • ConfigureExpansionStep

Add a DataResource file to your expansion-resource:

modelLoadingListeners.xml
<dataResource type="expansionControl::ModelLoadingListener">
<modelLoadingListener name="MyModelLoaderListener">
<modelLoadingStep name="ExtractResourcesStep"/>
<implementation>org.example.MyModelLoaderListener</implementation>
</modelLoadingListener>
</dataResource>
Traversing the model

The net.democritus.mapping.CompositeElementFinder class has a findAll() method that can be used to find all instances of a composite in a ExpansionCompositeModel object, which can otherwise be hard to traverse.

Set<ValueFieldComposite> valueFields = CompositeElementFinder
.findAll(result.getExpansionCompositeModel(), ValueFieldComposite.class);