Ejemplo n.º 1
0
def _extractStateNodes(root, encoding=None):

    result = []

    for s_node in root.getElementsByTagName('state'):

        info = {
            'state_id': _getNodeAttribute(s_node, 'state_id', encoding),
            'title': _getNodeAttribute(s_node, 'title', encoding),
            'description': _extractDescriptionNode(s_node, encoding)
        }

        info['transitions'] = [
            _getNodeAttribute(x, 'transition_id', encoding)
            for x in s_node.getElementsByTagName('exit-transition')
        ]

        info['permissions'] = permission_map = {}

        for p_map in s_node.getElementsByTagName('permission-map'):

            name = _getNodeAttribute(p_map, 'name', encoding)
            acquired = _getNodeAttributeBoolean(p_map, 'acquired')

            roles = [
                _coalesceTextNodeChildren(x, encoding)
                for x in p_map.getElementsByTagName('permission-role')
            ]

            if not acquired:
                roles = tuple(roles)

            permission_map[name] = roles

        info['groups'] = group_map = []

        for g_map in s_node.getElementsByTagName('group-map'):

            name = _getNodeAttribute(g_map, 'name', encoding)

            roles = [
                _coalesceTextNodeChildren(x, encoding)
                for x in g_map.getElementsByTagName('group-role')
            ]

            group_map.append((name, tuple(roles)))

        info['variables'] = var_map = {}

        for assignment in s_node.getElementsByTagName('assignment'):

            name = _getNodeAttribute(assignment, 'name', encoding)
            type_id = _getNodeAttribute(assignment, 'type', encoding)
            value = _coalesceTextNodeChildren(assignment, encoding)

            var_map[name] = {'name': name, 'type': type_id, 'value': value}

        result.append(info)

    return result
Ejemplo n.º 2
0
def _extractTransitionNodes(root, encoding=None):

    result = []

    for t_node in root.getElementsByTagName('transition'):

        info = {
            'transition_id': _getNodeAttribute(t_node, 'transition_id',
                                               encoding),
            'title': _getNodeAttribute(t_node, 'title', encoding),
            'description': _extractDescriptionNode(t_node, encoding),
            'new_state': _getNodeAttribute(t_node, 'new_state', encoding),
            'trigger': _getNodeAttribute(t_node, 'trigger', encoding),
            'before_script': _getNodeAttribute(t_node, 'before_script',
                                               encoding),
            'after_script': _getNodeAttribute(t_node, 'after_script',
                                              encoding),
            'action': _extractActionNode(t_node, encoding),
            'guard': _extractGuardNode(t_node, encoding)
        }

        info['variables'] = var_map = {}

        for assignment in t_node.getElementsByTagName('assignment'):

            name = _getNodeAttribute(assignment, 'name', encoding)
            expr = _coalesceTextNodeChildren(assignment, encoding)
            var_map[name] = expr

        result.append(info)

    return result
Ejemplo n.º 3
0
def _extractVariableNodes( root, encoding=None ):

    result = []

    for v_node in root.getElementsByTagName( 'variable' ):

        info = { 'variable_id' : _getNodeAttribute( v_node, 'variable_id'
                                                    , encoding )
               , 'description' : _extractDescriptionNode( v_node, encoding )
               , 'for_catalog' : _getNodeAttributeBoolean( v_node
                                                         , 'for_catalog'
                                                         )
               , 'for_status' : _getNodeAttributeBoolean( v_node
                                                        , 'for_status'
                                                        )
               , 'update_always' : _getNodeAttributeBoolean( v_node
                                                           , 'update_always'
                                                           )
               , 'default' : _extractDefaultNode( v_node, encoding )
               , 'guard' : _extractGuardNode( v_node, encoding )
               }

        result.append( info )

    return result
Ejemplo n.º 4
0
def _extractTransitionNodes( root, encoding=None ):

    result = []

    for t_node in root.getElementsByTagName( 'transition' ):

        info = { 'transition_id' : _getNodeAttribute( t_node, 'transition_id'
                                                    , encoding )
               , 'title' : _getNodeAttribute( t_node, 'title', encoding )
               , 'description' : _extractDescriptionNode( t_node, encoding )
               , 'new_state' : _getNodeAttribute( t_node, 'new_state'
                                                , encoding )
               , 'trigger' : _getNodeAttribute( t_node, 'trigger', encoding )
               , 'before_script' : _getNodeAttribute( t_node, 'before_script'
                                                  , encoding )
               , 'after_script' : _getNodeAttribute( t_node, 'after_script'
                                                   , encoding )
               , 'action' : _extractActionNode( t_node, encoding )
               , 'guard' : _extractGuardNode( t_node, encoding )
               }

        info[ 'variables' ] = var_map = {}

        for assignment in t_node.getElementsByTagName( 'assignment' ):

            name = _getNodeAttribute( assignment, 'name', encoding )
            expr = _coalesceTextNodeChildren( assignment, encoding )
            var_map[ name ] = expr

        result.append( info )

    return result
Ejemplo n.º 5
0
def _extractStateNodes( root, encoding=None ):

    result = []

    for s_node in root.getElementsByTagName( 'state' ):

        info = { 'state_id' : _getNodeAttribute( s_node, 'state_id', encoding )
               , 'title' : _getNodeAttribute( s_node, 'title', encoding )
               , 'description' : _extractDescriptionNode( s_node, encoding )
               }

        info[ 'transitions' ] = [ _getNodeAttribute( x, 'transition_id'
                                                   , encoding )
                                  for x in s_node.getElementsByTagName(
                                                        'exit-transition' ) ]

        info[ 'permissions' ] = permission_map = {}

        for p_map in s_node.getElementsByTagName( 'permission-map' ):

            name = _getNodeAttribute( p_map, 'name', encoding )
            acquired = _getNodeAttributeBoolean( p_map, 'acquired' )

            roles = [ _coalesceTextNodeChildren( x, encoding )
                        for x in p_map.getElementsByTagName(
                                            'permission-role' ) ]

            if not acquired:
                roles = tuple( roles )

            permission_map[ name ] = roles

        info[ 'groups' ] = group_map = []

        for g_map in s_node.getElementsByTagName( 'group-map' ):

            name = _getNodeAttribute( g_map, 'name', encoding )

            roles = [ _coalesceTextNodeChildren( x, encoding )
                        for x in g_map.getElementsByTagName(
                                            'group-role' ) ]

            group_map.append( ( name, tuple( roles ) ) )

        info[ 'variables' ] = var_map = {}

        for assignment in s_node.getElementsByTagName( 'assignment' ):

            name = _getNodeAttribute( assignment, 'name', encoding )
            type_id = _getNodeAttribute( assignment, 'type', encoding )
            value = _coalesceTextNodeChildren( assignment, encoding )

            var_map[ name ] = { 'name'  : name
                              , 'type'  : type_id
                              , 'value' : value
                              }

        result.append( info )

    return result
Ejemplo n.º 6
0
def _extractVariableNodes( root, encoding=None ):

    result = []

    for v_node in root.getElementsByTagName( 'variable' ):

        info = { 'variable_id' : _getNodeAttribute( v_node, 'variable_id'
                                                    , encoding )
               , 'description' : _extractDescriptionNode( v_node, encoding )
               , 'for_catalog' : _getNodeAttributeBoolean( v_node
                                                         , 'for_catalog'
                                                         )
               , 'for_status' : _getNodeAttributeBoolean( v_node
                                                        , 'for_status'
                                                        )
               , 'update_always' : _getNodeAttributeBoolean( v_node
                                                           , 'update_always'
                                                           )
               , 'default' : _extractDefaultNode( v_node, encoding )
               , 'guard' : _extractGuardNode( v_node, encoding )
               }

        result.append( info )

    return result
Ejemplo n.º 7
0
def _extractTypeInfoNode(parent, encoding=None):

    result = []

    ti_node = parent.getElementsByTagName('type-info')[0]

    def _es(key):
        return _getNodeAttribute(ti_node, key, encoding)

    def _qs(key, default=None):
        return _queryNodeAttribute(ti_node, key, default, encoding)

    def _qb(key, default=None):
        return _queryNodeAttributeBoolean(ti_node, key, default)

    type_id = _es('id')
    kind = _es('kind')
    title = _qs('title', type_id)
    description = _extractDescriptionNode(ti_node, encoding)
    meta_type = _qs('meta_type', type_id)
    icon = _qs('icon', '%s.png' % type_id)
    immediate_view = _qs('immediate_view', '%s_edit' % type_id)
    global_allow = _qb('global_allow', True)
    filter_content_types = _qb('filter_content_types', False)
    allowed_content_types = _extractAllowedContentTypeNodes(ti_node, encoding)
    allow_discussion = _qb('allow_discussion', False)
    aliases = _extractAliasesNode(ti_node, encoding)
    actions = _extractActionNodes(ti_node, encoding)

    info = {
        'id': type_id,
        'kind': kind,
        'title': title,
        'description': description,
        'meta_type': meta_type,
        'icon': icon,
        'immediate_view': immediate_view,
        'global_allow': global_allow,
        'filter_content_types': filter_content_types,
        'allowed_content_types': allowed_content_types,
        'allow_discussion': allow_discussion,
        'aliases': aliases,
        'actions': actions
    }

    if kind == FactoryTypeInformation.meta_type:
        info['product'] = _es('product')
        info['factory'] = _es('factory')
    elif kind == ScriptableTypeInformation.meta_type:
        info['constructor_path'] = _es('constructor_path')
        info['permission'] = _es('permission')

    result.append(info)

    return result
Ejemplo n.º 8
0
def _extractTypeInfoNode(parent, encoding=None):

    result = []

    ti_node = parent.getElementsByTagName('type-info')[0]

    def _es(key):
        return _getNodeAttribute(ti_node, key, encoding)

    def _qs(key, default=None):
        return _queryNodeAttribute(ti_node, key, default, encoding)

    def _qb(key, default=None):
        return _queryNodeAttributeBoolean(ti_node, key, default)

    type_id               = _es('id')
    kind                  = _es('kind')
    title                 = _qs('title', type_id)
    description           = _extractDescriptionNode(ti_node, encoding)
    meta_type             = _qs('meta_type', type_id)
    icon                  = _qs('icon', '%s.png' % type_id)
    immediate_view        = _qs('immediate_view', '%s_edit' % type_id)
    global_allow          = _qb('global_allow', True)
    filter_content_types  = _qb('filter_content_types', False)
    allowed_content_types = _extractAllowedContentTypeNodes(ti_node, encoding)
    allow_discussion      = _qb('allow_discussion', False)
    aliases               = _extractAliasesNode(ti_node, encoding)
    actions               = _extractActionNodes(ti_node, encoding)

    info = { 'id': type_id,
             'kind': kind,
             'title': title,
             'description': description,
             'meta_type': meta_type,
             'icon': icon,
             'immediate_view': immediate_view,
             'global_allow': global_allow,
             'filter_content_types': filter_content_types,
             'allowed_content_types': allowed_content_types,
             'allow_discussion': allow_discussion,
             'aliases': aliases,
             'actions': actions }

    if kind == FactoryTypeInformation.meta_type:
        info['product'] = _es('product')
        info['factory'] = _es('factory')
    elif kind == ScriptableTypeInformation.meta_type:
        info['constructor_path'] = _es('constructor_path')
        info['permission'] = _es('permission')

    result.append(info)

    return result
Ejemplo n.º 9
0
def _extractWorklistNodes(root, encoding=None):

    result = []

    for w_node in root.getElementsByTagName('worklist'):

        info = {
            'worklist_id': _getNodeAttribute(w_node, 'worklist_id', encoding),
            'title': _getNodeAttribute(w_node, 'title', encoding),
            'description': _extractDescriptionNode(w_node, encoding),
            'match': _extractMatchNode(w_node, encoding),
            'action': _extractActionNode(w_node, encoding),
            'guard': _extractGuardNode(w_node, encoding)
        }

        result.append(info)

    return result
Ejemplo n.º 10
0
def _extractWorklistNodes( root, encoding=None ):

    result = []

    for w_node in root.getElementsByTagName( 'worklist' ):

        info = { 'worklist_id' : _getNodeAttribute( w_node, 'worklist_id'
                                                    , encoding )
               , 'title' : _getNodeAttribute( w_node, 'title' , encoding )
               , 'description' : _extractDescriptionNode( w_node, encoding )
               , 'match' : _extractMatchNode( w_node, encoding )
               , 'action' : _extractActionNode( w_node, encoding )
               , 'guard' : _extractGuardNode( w_node, encoding )
               }

        result.append( info )

    return result