'Transform local mappings, to an easier to understand format.
Transform the incoming array to generate the return value for
the process function. Generating content for Keystone tokens will
be easier if some pre-processing is done at this level.
:param identity_values: local mapping from valid evaluations
:type identity_values: array of dict
Example identity_values::
\'group\': {\'id\': \'0cd5e9\'},
\'user\': {
\'email\': \'bob@example.com\'
\'groups\': [\'member\', \'admin\', tester\'],
\'domain\': {
\'name\': \'default_domain\'
\'group_ids\': [\'abc123\', \'def456\', \'0cd5e9\']
:returns: dictionary with user name, group_ids and group_names.
:rtype: dict'

def _transform(self, identity_values):

    def extract_groups(groups_by_domain):
        for groups in list(groups_by_domain.values()):
            for group in list({g['name']: g for g in groups}.values()):
                (yield group)
    def normalize_user(user):
        'Parse    and    validate    user    mapping.'
        user_type = user.get('type')
        if (user_type and (user_type not in (UserType.EPHEMERAL, UserType.LOCAL))):
            msg = (_('User    type    %s    not    supported') % user_type)
            raise exception.ValidationError(msg)
        if (user_type is None):
            user_type = user['type'] = UserType.EPHEMERAL
        if (user_type == UserType.EPHEMERAL):
            user['domain'] = {'id': CONF.federation.federated_domain_name}
    user = {}
    group_ids = set()
    group_names = list()
    groups_by_domain = dict()
    projects = []
    if (not identity_values):
        msg = _('Could    not    map    any    federated    user    properties    to    identity    values.    Check    debug    logs    or    the    mapping    used    for    additional    details.')
        LOG.warning(msg)
        raise exception.ValidationError(msg)
    for identity_value in identity_values:
        if ('user' in identity_value):
            if user:
                LOG.warning('Ignoring    user    name')
            else:
                user = identity_value.get('user')
        if ('group' in identity_value):
            group = identity_value['group']
            if ('id' in group):
                group_ids.add(group['id'])
            elif ('name' in group):
                domain = (group['domain'].get('name') or group['domain'].get('id'))
                groups_by_domain.setdefault(domain, list()).append(group)
            group_names.extend(extract_groups(groups_by_domain))
        if ('groups' in identity_value):
            if ('domain' not in identity_value):
                msg = _("Invalid    rule:    %(identity_value)s.    Both    'groups'    and    'domain'    keywords    must    be    specified.")
                msg = (msg % {'identity_value': identity_value})
                raise exception.ValidationError(msg)
            try:
                group_names_list = ast.literal_eval(identity_value['groups'])
            except (ValueError, SyntaxError):
                group_names_list = [identity_value['groups']]
            domain = identity_value['domain']
            group_dicts = [{'name': name, 'domain': domain} for name in group_names_list]
            group_names.extend(group_dicts)
        if ('group_ids' in identity_value):
            try:
                group_ids.update(ast.literal_eval(identity_value['group_ids']))
            except (ValueError, SyntaxError):
                group_ids.update([identity_value['group_ids']])
        if ('projects' in identity_value):
            projects = identity_value['projects']
    normalize_user(user)
    return {'user': user, 'group_ids': list(group_ids), 'group_names': group_names, 'projects': projects}
