Class SlotPropagator


  • public class SlotPropagator
    extends Object
    A helper class to implement the propagation of slots from the mapping set level to the level of individual mappings and the other way round.

    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 Detail

      • SlotPropagator

        public SlotPropagator()
        Creates a new instance using the default propagation policy (always replace).
      • SlotPropagator

        public SlotPropagator​(PropagationPolicy policy)
        Creates a new instance with the specified propagation policy.
        Parameters:
        policy - The default propagation policy to use.
      • SlotPropagator

        public SlotPropagator​(PropagationPolicy policy,
                              Version maxVersion)
        Creates a new instance with the specified propagation policy and highest version.
        Parameters:
        policy - The default propagation policy to use.
        maxVersion - The default highest version of the SSSOM specification that sets should remain compliant with after propagation or condensation.
    • Method Detail

      • setMaxVersion

        public void setMaxVersion​(Version maxVersion)
        Sets the highest version of the SSSOM specification to use for deciding which slots should be affected by propagation or condensation operations.

        This property allows to deal with the fact that some slots have existed since version 1.0 but have only been added to the MappingSet class (and made propagatable) in version 1.1. If we want to produce a SSSOM 1.0 compliant set, such a slot must not condensed.

        Parameters:
        maxVersion - The target SSSOM version.
      • propagate

        public Set<String> propagate​(MappingSet mappingSet)
        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

        public Set<String> propagate​(MappingSet mappingSet,
                                     boolean preserve)
        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 - If true, set-level values will not be removed after propagation.
        Returns:
        A set containing the names of slots that were effectively propagated.
      • condense

        public Set<String> condense​(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.

        Note that for this operation, the PropagationPolicy.ReplaceIfUnset and PropagationPolicy.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 - If true, 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.