Esempio n. 1
0
  def get_mapping_definitions(cls, object_class):
    """Get column definitions for allowed (un)mappings for object_class.

    For an Audit-scope object, generates snapshot mappings for all allowed
    mappings with snapshottable objects and direct mappings with all allowed
    mappings with non-snapshottable objects.

    For a normal object, generates direct mappings with all allowed mappings.

    For every direct mapping column generated it also generates an unmapping
    column.
    """

    definitions = {}

    definitions.update(cls._generate_mapping_definition(
        rules.get_mapping_rules().get(object_class.__name__, set()),
        cls.MAPPING_PREFIX, "map:{}",
    ))
    definitions.update(cls._generate_mapping_definition(
        rules.get_snapshot_mapping_rules().get(object_class.__name__, set()),
        cls.SNAPSHOT_MAPPING_PREFIX, "map:{} versions",
    ))
    definitions.update(cls._generate_mapping_definition(
        rules.get_unmapping_rules().get(object_class.__name__, set()),
        cls.UNMAPPING_PREFIX, "unmap:{}",
    ))
    return definitions
Esempio n. 2
0
  def get_mapping_definitions(cls, object_class):
    """Get column definitions for allowed (un)mappings for object_class.

    For an Audit-scope object, generates snapshot mappings for all allowed
    mappings with snapshottable objects and direct mappings with all allowed
    mappings with non-snapshottable objects.

    For a normal object, generates direct mappings with all allowed mappings.

    For every direct mapping column generated it also generates an unmapping
    column.
    """

    definitions = {}

    definitions.update(cls._generate_mapping_definition(
        rules.get_mapping_rules().get(object_class.__name__, set()),
        cls.MAPPING_PREFIX, "map:{}",
    ))
    definitions.update(cls._generate_mapping_definition(
        rules.get_snapshot_mapping_rules().get(object_class.__name__, set()),
        cls.SNAPSHOT_MAPPING_PREFIX, "map:{} versions",
    ))
    definitions.update(cls._generate_mapping_definition(
        rules.get_unmapping_rules().get(object_class.__name__, set()),
        cls.UNMAPPING_PREFIX, "unmap:{}",
    ))
    return definitions
def get_mapping_names(class_name):
  mapping_rules = get_mapping_rules().get(class_name)
  if mapping_rules is not None:
    pretty_mapping_rules = (title_from_camelcase(r) for r in mapping_rules)
    mapping_names = {"map:{}".format(n) for n in pretty_mapping_rules}
  else:
    mapping_names = None
  return mapping_names
def get_mapping_names(class_name):
    mapping_rules = get_mapping_rules().get(class_name)
    if mapping_rules is not None:
        pretty_mapping_rules = (title_from_camelcase(r) for r in mapping_rules)
        mapping_names = {"map:{}".format(n) for n in pretty_mapping_rules}
    else:
        mapping_names = None
    return mapping_names
def get_mapping_names(class_name):
    """Get mapping, unmapping and snapshot mapping column names."""
    map_rules = rules.get_mapping_rules().get(class_name) or set()
    unmap_rules = rules.get_unmapping_rules().get(class_name) or set()
    unmap_sn_rules = rules.get_snapshot_mapping_rules().get(
        class_name) or set()

    format_rules = [("map:{}", map_rules), ("unmap:{}", unmap_rules),
                    ("map:{} versions", unmap_sn_rules)]

    column_names = set()
    for format_, rule_set in format_rules:
        pretty_rules = (title_from_camelcase(r) for r in rule_set)
        column_names.update(format_.format(r) for r in pretty_rules)

    return column_names
Esempio n. 6
0
def get_mapping_names(class_name):
  """Get mapping, unmapping and snapshot mapping column names."""
  map_rules = rules.get_mapping_rules().get(class_name) or set()
  unmap_rules = rules.get_unmapping_rules().get(class_name) or set()
  unmap_sn_rules = rules.get_snapshot_mapping_rules().get(class_name) or set()

  format_rules = [("map:{}", map_rules),
                  ("unmap:{}", unmap_rules),
                  ("map:{} versions", unmap_sn_rules)]

  column_names = set()
  for format_, rule_set in format_rules:
    pretty_rules = (title_from_camelcase(r) for r in rule_set)
    column_names.update(format_.format(r) for r in pretty_rules)

  return column_names
Esempio n. 7
0
    def get_mapping_definitions(cls, object_class):
        """Get column definitions for allowed (un)mappings for object_class.

    For an Audit-scope object, generates snapshot mappings for all allowed
    mappings with snapshottable objects and direct mappings with all allowed
    mappings with non-snapshottable objects.

    For a normal object, generates direct mappings with all allowed mappings.

    For every direct mapping column generated it also generates an unmapping
    column.
    """
        from ggrc.snapshotter import rules
        mapping_rules = get_mapping_rules()
        all_mappings = mapping_rules.get(object_class.__name__, set())
        unmapping_rules = get_unmapping_rules()
        all_unmappings = unmapping_rules.get(object_class.__name__, set())

        definitions = {}
        if object_class.__name__ in rules.Types.scoped | rules.Types.parents:
            snapshot_mappings = all_mappings & rules.Types.all
            direct_mappings = all_mappings - rules.Types.all
            definitions.update(
                cls._generate_mapping_definition(
                    snapshot_mappings,
                    cls.SNAPSHOT_MAPPING_PREFIX,
                    "map:{}",
                ))
        else:
            direct_mappings = all_mappings

        direct_unmappings = direct_mappings & all_unmappings

        definitions.update(
            cls._generate_mapping_definition(
                direct_mappings,
                cls.MAPPING_PREFIX,
                "map:{}",
            ))
        definitions.update(
            cls._generate_mapping_definition(
                direct_unmappings,
                cls.UNMAPPING_PREFIX,
                "unmap:{}",
            ))
        return definitions
Esempio n. 8
0
  def get_mapping_definitions(cls, object_class):
    """Get column definitions for allowed (un)mappings for object_class.

    For an Audit-scope object, generates snapshot mappings for all allowed
    mappings with snapshottable objects and direct mappings with all allowed
    mappings with non-snapshottable objects.

    For a normal object, generates direct mappings with all allowed mappings.

    For every direct mapping column generated it also generates an unmapping
    column.
    """
    from ggrc.snapshotter import rules
    mapping_rules = get_mapping_rules()
    all_mappings = mapping_rules.get(object_class.__name__, set())
    unmapping_rules = get_unmapping_rules()
    all_unmappings = unmapping_rules.get(object_class.__name__, set())

    definitions = {}
    if object_class.__name__ in rules.Types.scoped | rules.Types.parents:
      snapshot_mappings = all_mappings & rules.Types.all
      direct_mappings = all_mappings - rules.Types.all
      definitions.update(cls._generate_mapping_definition(
          snapshot_mappings, cls.SNAPSHOT_MAPPING_PREFIX, "map:{}",
      ))
    else:
      direct_mappings = all_mappings

    direct_unmappings = direct_mappings & all_unmappings

    definitions.update(cls._generate_mapping_definition(
        direct_mappings, cls.MAPPING_PREFIX, "map:{}",
    ))
    definitions.update(cls._generate_mapping_definition(
        direct_unmappings, cls.UNMAPPING_PREFIX, "unmap:{}",
    ))
    return definitions