Ejemplo n.º 1
0
def loadWorkspace_0_1(workspacePath, workspaceFile):

    # Parse the XML Document as 0.1 version
    tree = ElementTree()

    tree.parse(workspaceFile)
    xmlWorkspace = tree.getroot()
    wsName = xmlWorkspace.get('name', 'none')
    wsCreationDate = TypeConvertor.xsdDatetime2PythonDatetime(xmlWorkspace.get('creation_date'))

    # Parse the configuration to retrieve the main paths
    xmlWorkspaceConfig = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}configuration")
    pathOfTraces = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}traces").text

    pathOfLogging = None
    if xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}logging") is not None and xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}logging").text is not None and len(xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}logging").text) > 0:
        pathOfLogging = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}logging").text

    pathOfPrototypes = None
    if xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}prototypes") is not None and xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}prototypes").text is not None and len(xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}prototypes").text) > 0:
        pathOfPrototypes = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}prototypes").text

    lastProject = None
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}projects") is not None:
        xmlProjects = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}projects")
        if xmlProjects.get("last", "none") != "none":
            lastProject = xmlProjects.get("last", "none")

    # Instantiation of the workspace
    workspace = Workspace(wsName, wsCreationDate, workspacePath, pathOfTraces, pathOfLogging, pathOfPrototypes)

    # Load the already imported traces
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}traces") is not None:
        xmlTraces = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}traces")
        for xmlTrace in xmlTraces.findall("{" + WORKSPACE_NAMESPACE + "}trace"):
            trace = ImportedTrace.loadTrace(xmlTrace, WORKSPACE_NAMESPACE, COMMON_NAMESPACE, "0.1", workspace.getPathOfTraces())
            if trace is not None:
                workspace.addImportedTrace(trace)

    # Reference the projects
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}projects") is not None:
        for xmlProject in xmlWorkspace.findall("{" + WORKSPACE_NAMESPACE + "}projects/{" + WORKSPACE_NAMESPACE + "}project"):
            project_path = xmlProject.get("path")
            workspace.referenceProject(project_path)
            if project_path == lastProject and lastProject is not None:
                workspace.referenceLastProject(lastProject)

    # Reference the functions
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}functions") is not None:
        for xmlFunction in xmlWorkspace.findall("{" + WORKSPACE_NAMESPACE + "}functions/{" + WORKSPACE_NAMESPACE + "}function"):
            function = RenderingFunction.loadFromXML(xmlFunction, WORKSPACE_NAMESPACE, "0.1")
            if function is not None:
                workspace.addCustomTransformationFunction(function)

    enableBugReporting = False
    if xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}enable_bug_reporting") is not None and xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}enable_bug_reporting").text is not None and len(xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}enable_bug_reporting").text) > 0:
        val = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}enable_bug_reporting").text
        if val == "true":
            enableBugReporting = True
    workspace.setEnableBugReporting(enableBugReporting)

    return workspace
Ejemplo n.º 2
0
 def __init__(self, type, name):
     RenderingFunction.__init__(self, VisualizationFunction.TYPE)
     self.type = type
     self.name = name
Ejemplo n.º 3
0
 def __init__(self, type, name):
     RenderingFunction.__init__(self, EncodingFunction.TYPE)
     self.type = type
     self.name = name
Ejemplo n.º 4
0
 def __init__(self, type, name):
     RenderingFunction.__init__(self, VisualizationFunction.TYPE)
     self.type = type
     self.name = name
Ejemplo n.º 5
0
 def __init__(self, type, name):
     RenderingFunction.__init__(self, TransformationFunction.TYPE)
     self.type = type
     self.name = name
Ejemplo n.º 6
0
def loadWorkspace_0_1(workspacePath, workspaceFile):

    # Parse the XML Document as 0.1 version
    tree = ElementTree()

    tree.parse(workspaceFile)
    xmlWorkspace = tree.getroot()
    wsName = xmlWorkspace.get('name', 'none')
    wsCreationDate = TypeConvertor.xsdDatetime2PythonDatetime(
        xmlWorkspace.get('creation_date'))

    # Parse the configuration to retrieve the main paths
    xmlWorkspaceConfig = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE +
                                           "}configuration")
    pathOfTraces = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                           "}traces").text

    pathOfLogging = None
    if xmlWorkspaceConfig.find(
            "{" + WORKSPACE_NAMESPACE +
            "}logging") is not None and xmlWorkspaceConfig.find(
                "{" + WORKSPACE_NAMESPACE +
                "}logging").text is not None and len(
                    xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                            "}logging").text) > 0:
        pathOfLogging = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                                "}logging").text

    pathOfPrototypes = None
    if xmlWorkspaceConfig.find(
            "{" + WORKSPACE_NAMESPACE +
            "}prototypes") is not None and xmlWorkspaceConfig.find(
                "{" + WORKSPACE_NAMESPACE +
                "}prototypes").text is not None and len(
                    xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                            "}prototypes").text) > 0:
        pathOfPrototypes = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                                   "}prototypes").text

    lastProject = None
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}projects") is not None:
        xmlProjects = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE +
                                        "}projects")
        if xmlProjects.get("last", "none") != "none":
            lastProject = xmlProjects.get("last", "none")

    # Instantiation of the workspace
    workspace = Workspace(wsName, wsCreationDate, workspacePath, pathOfTraces,
                          pathOfLogging, pathOfPrototypes)

    # Load the already imported traces
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}traces") is not None:
        xmlTraces = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}traces")
        for xmlTrace in xmlTraces.findall("{" + WORKSPACE_NAMESPACE +
                                          "}trace"):
            trace = ImportedTrace.loadTrace(xmlTrace, WORKSPACE_NAMESPACE,
                                            COMMON_NAMESPACE, "0.1",
                                            workspace.getPathOfTraces())
            if trace is not None:
                workspace.addImportedTrace(trace)

    # Reference the projects
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}projects") is not None:
        for xmlProject in xmlWorkspace.findall("{" + WORKSPACE_NAMESPACE +
                                               "}projects/{" +
                                               WORKSPACE_NAMESPACE +
                                               "}project"):
            project_path = xmlProject.get("path")
            workspace.referenceProject(project_path)
            if project_path == lastProject and lastProject is not None:
                workspace.referenceLastProject(lastProject)

    # Reference the functions
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}functions") is not None:
        for xmlFunction in xmlWorkspace.findall("{" + WORKSPACE_NAMESPACE +
                                                "}functions/{" +
                                                WORKSPACE_NAMESPACE +
                                                "}function"):
            function = RenderingFunction.loadFromXML(xmlFunction,
                                                     WORKSPACE_NAMESPACE,
                                                     "0.1")
            if function is not None:
                workspace.addCustomTransformationFunction(function)

    enableBugReporting = False
    if xmlWorkspaceConfig.find(
            "{" + WORKSPACE_NAMESPACE +
            "}enable_bug_reporting") is not None and xmlWorkspaceConfig.find(
                "{" + WORKSPACE_NAMESPACE +
                "}enable_bug_reporting").text is not None and len(
                    xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                            "}enable_bug_reporting").text) > 0:
        val = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                      "}enable_bug_reporting").text
        if val == "true":
            enableBugReporting = True
    workspace.setEnableBugReporting(enableBugReporting)

    return workspace
Ejemplo n.º 7
0
 def __init__(self, type, name):
     RenderingFunction.__init__(self, TransformationFunction.TYPE)
     self.type = type
     self.name = name