Beispiel #1
0
def DispCrons(dom, grph, configNode, configName):

    attr_name = GetDefaultApp(dom)

    for elt_crontable in dom.getElementsByTagName('crontable'):
        for elt_cronrules in elt_crontable.getElementsByTagName('cronrules'):
            attr_cronrules_cronid = elt_cronrules.getAttributeNode(
                'cronid').value
            nodeCronrules = AC2_cronrules.MakeUri(configName,
                                                  attr_cronrules_cronid)
            grph.add((configNode, AC2.propCronRules, nodeCronrules))

            for elt_trigger in elt_cronrules.getElementsByTagName('trigger'):
                attr_trigger_name = elt_trigger.getAttributeNode('name').value
                attr_trigger_name_no_sharp = attr_trigger_name.replace(
                    "CRON#", "Cron ")
                nodeTrigger = AC2_trigger.MakeUri(configName,
                                                  attr_cronrules_cronid,
                                                  attr_trigger_name_no_sharp)

                # Many optional attributes.
                attr_trigger_action = elt_trigger.getAttributeNode('action')
                if attr_trigger_action:
                    grph.add(
                        (nodeTrigger, lib_common.MakeProp("action"),
                         lib_common.NodeLiteral(attr_trigger_action.value)))

                attr_trigger_force = elt_trigger.getAttributeNode('force')
                if attr_trigger_force:
                    grph.add(
                        (nodeTrigger, lib_common.MakeProp("force"),
                         lib_common.NodeLiteral(attr_trigger_force.value)))

                attr_trigger_components = elt_trigger.getAttributeNode(
                    'components')
                if attr_trigger_components:
                    componentList = attr_trigger_components.value.split(",")
                    for compNam in componentList:
                        nodeComponent = AC2_component.MakeUri(
                            configName, attr_name, compNam)
                        grph.add(
                            (nodeTrigger, AC2.propComponents, nodeComponent))

                attr_trigger_propagate = elt_trigger.getAttributeNode(
                    'propagate')
                if attr_trigger_propagate:
                    grph.add(
                        (nodeTrigger, lib_common.MakeProp("propagate"),
                         lib_common.NodeLiteral(attr_trigger_propagate.value)))

                attr_trigger_expression = elt_trigger.getAttributeNode(
                    'expression')
                if attr_trigger_expression:
                    grph.add((nodeTrigger, lib_common.MakeProp("expression"),
                              lib_common.NodeLiteral(
                                  attr_trigger_expression.value)))

                grph.add((nodeCronrules, AC2.propTrigger, nodeTrigger))

    return
Beispiel #2
0
def ComponentNameToNode(configName, appName, componentName):
    try:
        return ComponentNameToNode.NodeMap[componentName]
    except KeyError:
        nodeComponent = AC2_component.MakeUri(configName, appName,
                                              componentName)
        ComponentNameToNode.NodeMap[componentName] = nodeComponent
        return nodeComponent
Beispiel #3
0
def DisplayComponentDependencies(grph, ac2File, ac2App, ac2Comp):
    configNode = AC2_configuration.MakeUri(ac2File)
    appNode = AC2_application.MakeUri(ac2File, ac2App)
    compNode = AC2_component.MakeUri(ac2File, ac2App, ac2Comp)

    dom = AC2_configuration.GetDom(ac2File)

    # TODO: PROBLEME, ON DEVRAIT ALLER CHERCHER LES SOUS-NODES AU LIEU DE TOUT REPARCOURIR !!!!!!!!!!!
    for elt_apps in dom.getElementsByTagName('apps'):
        sys.stderr.write("Founds apps\n")

        # TODO: ERROR: SHOULD FOCUS ON ONE APP ONLY.

        for elt_app in elt_apps.getElementsByTagName('app'):
            attr_app_name = elt_app.getAttributeNode('name').value
            sys.stderr.write("attr_app_name=%s\n" % attr_app_name)

            if attr_app_name != ac2App:
                continue

            AC2_application.DecorateAppWithXml(grph, appNode, elt_app)

            for elt_component in elt_app.getElementsByTagName('component'):
                attr_component_name = elt_component.getAttributeNode(
                    'name').value

                sys.stderr.write("attr_component_name=%s\n" %
                                 attr_component_name)

                if attr_component_name == ac2Comp:
                    AC2_component.DecorateComponentWithXml(
                        grph, compNode, elt_component)

                    fatherFound = False
                    for elt_father in elt_component.getElementsByTagName(
                            'father'):
                        # There should be one parent only.
                        attr_father_name = elt_father.firstChild.nodeValue
                        sys.stderr.write("attr_father_name=%s\n" %
                                         attr_father_name)
                        nodeFather = ComponentNameToNode(
                            ac2File, attr_app_name, attr_father_name)

                        grph.add((nodeFather, AC2.propParent, compNode))
                        fatherFound = True

                    if fatherFound:
                        # grph.add( ( appNode, AC2.propComp2App, nodeFather ) )
                        grph.add((nodeFather, AC2.propComp2App, appNode))
                        grph.add((nodeFather, AC2.propParent, compNode))
                    else:
                        # grph.add( ( appNode, AC2.propComp2App, compNode ) )
                        grph.add((compNode, AC2.propComp2App, appNode))

                    break

    return
def DisplayComponentDependencies(grph, ac2File, ac2App, ac2Comp):
    configNode = AC2_configuration.MakeUri(ac2File)
    appNode = AC2_application.MakeUri(ac2File, ac2App)
    compNode = AC2_component.MakeUri(ac2File, ac2App, ac2Comp)

    dom = AC2_configuration.GetDom(ac2File)

    # TODO: PROBLEME, ON DEVRAIT ALLER CHERCHER LES SOUS-NODES AU LIEU DE TOUT REPARCOURIR !!!!!!!!!!!
    for elt_apps in dom.getElementsByTagName('apps'):
        sys.stderr.write("Founds apps\n")

        # TODO: ERROR: SHOULD FOCUS ON ONE APP ONLY.

        for elt_app in elt_apps.getElementsByTagName('app'):
            attr_app_name = elt_app.getAttributeNode('name').value
            sys.stderr.write("attr_app_name=%s\n" % attr_app_name)

            if attr_app_name != ac2App:
                continue

            AC2_application.DecorateAppWithXml(grph, appNode, elt_app)

            #attr_version = elt_app.getAttributeNode('version').value
            #grph.add( ( appNode, lib_common.MakeProp("Version"), lib_common.NodeLiteral( attr_version ) ) )

            #attr_notifref = elt_app.getAttributeNode('notifref').value
            #grph.add( ( appNode, lib_common.MakeProp("Notifref"), lib_common.NodeLiteral( attr_notifref ) ) )

            #attr_cronref = elt_app.getAttributeNode('cronref').value
            #grph.add( ( appNode, lib_common.MakeProp("Cronref"), lib_common.NodeLiteral( attr_cronref ) ) )

            #appParent = None
            #appChildren = []

            for elt_component in elt_app.getElementsByTagName('component'):
                attr_component_name = elt_component.getAttributeNode(
                    'name').value

                sys.stderr.write("attr_component_name=%s\n" %
                                 attr_component_name)

                if attr_component_name == ac2Comp:
                    attr_component_description = elt_component.getAttributeNode(
                        'description')
                    if attr_component_description:
                        grph.add((compNode, pc.property_information,
                                  lib_common.NodeLiteral(
                                      attr_component_description.value)))

                    attr_component_group = elt_component.getAttributeNode(
                        'group')
                    if attr_component_group:
                        grph.add((compNode, lib_common.MakeProp("Group"),
                                  lib_common.NodeLiteral(
                                      attr_component_group.value)))

                    attr_component_type = elt_component.getAttributeNode(
                        'type')
                    if attr_component_type:
                        grph.add((compNode, lib_common.MakeProp("Type"),
                                  lib_common.NodeLiteral(
                                      attr_component_type.value)))

                    nodeFather = None
                    for elt_father in elt_component.getElementsByTagName(
                            'father'):
                        # There should be one parent only.
                        attr_father_name = elt_father.firstChild.nodeValue
                        sys.stderr.write("attr_father_name=%s\n" %
                                         attr_father_name)
                        nodeFather = ComponentNameToNode(
                            ac2File, attr_app_name, attr_father_name)

                        grph.add((nodeFather, AC2.propParent, compNode))
                        grph.add((appNode, AC2.propComp2App, nodeFather))

                    if not nodeFather:
                        grph.add((appNode, AC2.propComp2App, compNode))
                else:
                    currCompNode = ComponentNameToNode(ac2File, attr_app_name,
                                                       attr_component_name)
                    for elt_father in elt_component.getElementsByTagName(
                            'father'):
                        # There should be one parent only.
                        attr_father_name = elt_father.firstChild.nodeValue

                        if attr_father_name == ac2Comp:
                            sys.stderr.write("ac2Comp attr_father_name=%s\n" %
                                             attr_father_name)
                            nodeChild = ComponentNameToNode(
                                ac2File, attr_app_name, attr_father_name)

                            grph.add((compNode, AC2.propParent, currCompNode))
    return