Class MappingProcessor<T>
- java.lang.Object
-
- org.incenp.obofoundry.sssom.transform.MappingProcessor<T>
-
- Type Parameters:
T- The type of object that should be generated when applying a rule to a mapping.
- Direct Known Subclasses:
OWLGenerator
public class MappingProcessor<T> extends Object
An engine for applyingMappingProcessingRules to mappings. This engine is programmed with a list of rules that, applies them to a list of mappings, and collects the objects generated by the rules.
-
-
Constructor Summary
Constructors Constructor Description MappingProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddGeneratedListener(IMappingProcessorListener<T> listener)Adds a listener to react to "generated" events, when an object is generated by the application of a rule to a mapping.voidaddRule(MappingProcessingRule<T> rule)Adds a rule to be applied to mappings.voidaddRules(List<MappingProcessingRule<T>> rules)Adds a list of rules to be applied.voidaddStopingRule(IMappingFilter filter)Adds a rule that stops any further processing for selected mappings.voidexcludeRules(Set<String> tags)Sets the processor to exclude the rules that have at least one tag in the specified tag set.booleanhasRules()Indicates whether this processor has some rules to work with.voidincludeRules(Set<String> tags)Sets the processor to run only the rules that have at least one tag in the specified tag set.protected voidonGeneratedProduct(MappingProcessingRule<T> rule, Mapping mapping, T product)Called when a rule generates an object from a mapping.List<T>process(List<Mapping> mappings)Applies all the rules to the given mappings.
-
-
-
Method Detail
-
addRule
public void addRule(MappingProcessingRule<T> rule)
Adds a rule to be applied to mappings. The order in which rules are added is significant. Rules are applied in the order in which they are added, and an earlier rule may impact the behaviour of a later rule.- Parameters:
rule- The new rule to add.
-
addRules
public void addRules(List<MappingProcessingRule<T>> rules)
Adds a list of rules to be applied. This has the same effect as callingaddRule(MappingProcessingRule)repeatedly.- Parameters:
rules- The new rules to add.
-
addStopingRule
public void addStopingRule(IMappingFilter filter)
Adds a rule that stops any further processing for selected mappings.- Parameters:
filter- The filter to determine whether the rule applies to a given mapping.
-
addGeneratedListener
public void addGeneratedListener(IMappingProcessorListener<T> listener)
Adds a listener to react to "generated" events, when an object is generated by the application of a rule to a mapping.- Parameters:
listener- The listener to add.
-
includeRules
public void includeRules(Set<String> tags)
Sets the processor to run only the rules that have at least one tag in the specified tag set.- Parameters:
tags- The tags to select the rules to run. Any rules with no matching tag will be excluded.
-
excludeRules
public void excludeRules(Set<String> tags)
Sets the processor to exclude the rules that have at least one tag in the specified tag set.- Parameters:
tags- The tags to select the rules to exclude. Only the rules with no matching tag will be run.
-
hasRules
public boolean hasRules()
Indicates whether this processor has some rules to work with.- Returns:
trueif the processor has a least one rule,falseotherwise.
-
process
public List<T> process(List<Mapping> mappings)
Applies all the rules to the given mappings.- Parameters:
mappings- The mappings the rules should be applied to.- Returns:
- A list of all the objects that were produced by the application of the rules.
-
onGeneratedProduct
protected void onGeneratedProduct(MappingProcessingRule<T> rule, Mapping mapping, T product)
Called when a rule generates an object from a mapping.- Parameters:
rule- The rule producing the object.mapping- The mapping the rule has been applied to.product- The object produced by the rule.
-
-