Class SlotPropagator
Some of the SSSOM metadata slots exist both on the MappingSet class and on
the Mapping class. Among them, some represent a different metadata depending
on whether they are on the mapping set or on a mapping. For example, the
creator_id
slot on a mapping set represents the creators of the
entire set, while that same slot on an individual mapping represents the
creator of that particular mapping (which may be different from the creators
of the set).
But there are also metadata slots that are actually intended to represent a
common value for all mappings in the set, rather than a value for the set
itself. For example, the mapping_tool
slot, when used on a set,
indicates the mapping tool used by all mappings in the set. A mapping set
that has a mapping_tool
value should be considered as a mapping set
in which all mappings have that same value in their mapping_tool
slots.
To implement this behaviour, this class defines two operations on a mapping set:
- propagation, in which the value of any “propagatable” slot on the mapping set is explicitly assigned to the corresponding slot in all the mappings of that set;
- condensation, which does the opposite: if all the mappings in a set have the same value for a given ”propagatable” slot, that value is assigned to the corresponding slot on the mapping set.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance using the default propagation policy (always replace).SlotPropagator
(PropagationPolicy policy) Creates a new instance with the specified propagation policy. -
Method Summary
Modifier and TypeMethodDescriptioncondense
(MappingSet mappingSet, boolean preserve) Condenses a mapping set, i.e. move slot values from the level of individual mappings up to the mapping set level wherever possible.propagate
(MappingSet mappingSet) Propagates the values of slots from the mapping set level to the individual mappings.propagate
(MappingSet mappingSet, boolean preserve) Propagates the values of slots the mapping set level to the individual mappings.void
setStrategy
(PropagationPolicy policy) Sets the propagation policy to use.
-
Constructor Details
-
SlotPropagator
public SlotPropagator()Creates a new instance using the default propagation policy (always replace). -
SlotPropagator
Creates a new instance with the specified propagation policy.- Parameters:
policy
- The default propagation policy to use.
-
-
Method Details
-
setStrategy
Sets the propagation policy to use. The new policy will be used in all subsequent calls topropagate(MappingSet)
andcondense(MappingSet, boolean)
.- Parameters:
policy
- The new policy to use.
-
propagate
Propagates the values of slots from the mapping set level to the individual mappings.- Parameters:
mappingSet
- The mapping set whose slot values should be propagated.- Returns:
- A set containing the names of slots that were effectively propagated.
-
propagate
Propagates the values of slots the mapping set level to the individual mappings.- Parameters:
mappingSet
- The mapping set whose slot values should be propagated.preserve
- Iftrue
, set-level values will not be removed after propagation.- Returns:
- A set containing the names of slots that were effectively propagated.
-
condense
Condenses a mapping set, i.e. move slot values from the level of individual mappings up to the mapping set level wherever possible.Note that for this operation, the
PropagationPolicy.ReplaceIfUnset
andPropagationPolicy.NeverReplace
policies are equivalent. They both lead to a slot not being condensed if the set already has a value for that slot.- Parameters:
mappingSet
- The mapping set to condense.preserve
- Iftrue
, mapping-level values will only be copied to the set, and not removed from the mappings.- Returns:
- A set containing the names of slots whose values were effectively moved (or copied) to the set level.
-