Search in sources :

Example 1 with TmfXmlPatternCu

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu in project tracecompass by tracecompass.

the class TmfXmlTestUtils method getModuleInFile.

/**
 * Get the XML analysis module in the file. It will return either a pattern
 * or state provider, if there is one in the file
 *
 * @param xmlFilePath
 *            The absolute file path to the XML file
 * @param analysisId
 *            The ID of the analysis to get
 * @return The analysis module
 */
public static TmfAbstractAnalysisModule getModuleInFile(String xmlFilePath, @NonNull String analysisId) {
    // Look for a pattern element
    Element element = TmfXmlUtils.getElementInFile(xmlFilePath, TmfXmlStrings.PATTERN, analysisId);
    if (element != null) {
        TmfXmlPatternCu patternCu = TmfXmlPatternCu.compile(element);
        if (patternCu == null) {
            return null;
        }
        XmlPatternAnalysis module = new XmlPatternAnalysis(analysisId, patternCu);
        module.setName(analysisId);
        return module;
    }
    // Look for a state provider
    element = TmfXmlUtils.getElementInFile(xmlFilePath, TmfXmlStrings.STATE_PROVIDER, analysisId);
    if (element != null) {
        TmfXmlStateProviderCu compile = TmfXmlStateProviderCu.compile(Paths.get(xmlFilePath), analysisId);
        assertNotNull(compile);
        DataDrivenAnalysisModule module = new DataDrivenAnalysisModule(analysisId, compile);
        module.setName(analysisId);
        return module;
    }
    throw new NullPointerException("No module named " + analysisId + " in file " + xmlFilePath);
}
Also used : TmfXmlPatternCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu) TmfXmlStateProviderCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu) Element(org.w3c.dom.Element) XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis) DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule)

Example 2 with TmfXmlPatternCu

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu in project tracecompass by tracecompass.

the class XmlUtilsTest method initializePatternModule.

/**
 * Initialize a new pattern analysis using the xml file
 *
 * @param xmlAnalysisFile
 *            The xml file used to initialize the pattern analysis
 * @return The pattern analysis
 */
@NonNull
public static XmlPatternAnalysis initializePatternModule(TmfXmlTestFiles xmlAnalysisFile) {
    /* Initialize the state provider module */
    Document doc = xmlAnalysisFile.getXmlDocument();
    assertNotNull(doc);
    /* get State Providers modules */
    NodeList patternNodes = doc.getElementsByTagName(TmfXmlStrings.PATTERN);
    assertFalse(patternNodes.getLength() == 0);
    Element node = (Element) patternNodes.item(0);
    String id = node.getAttribute(TmfXmlStrings.ID);
    TmfXmlPatternCu patternCu = TmfXmlPatternCu.compile(node);
    assertNotNull(patternCu);
    XmlPatternAnalysis analysis = new XmlPatternAnalysis(id, patternCu);
    String moduleId = node.getAttribute(TmfXmlStrings.ID);
    assertNotNull(moduleId);
    analysis.setId(moduleId);
    return analysis;
}
Also used : TmfXmlPatternCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis) Document(org.w3c.dom.Document) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 3 with TmfXmlPatternCu

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu in project tracecompass by tracecompass.

the class XmlModuleTestBase method createModule.

private void createModule(@NonNull Element element) {
    String analysisId = element.getAttribute(TmfXmlStrings.ID);
    switch(getAnalysisNodeName()) {
        case TmfXmlStrings.PATTERN:
            TmfXmlPatternCu patternCu = TmfXmlPatternCu.compile(element);
            assertNotNull(patternCu);
            fModule = new XmlPatternAnalysis(analysisId, patternCu);
            fModule.setName(getName(element));
            break;
        case TmfXmlStrings.STATE_PROVIDER:
            TmfXmlStateProviderCu compile = TmfXmlStateProviderCu.compile(getXmlFile().getFile().toPath(), analysisId);
            assertNotNull(compile);
            fModule = new DataDrivenAnalysisModule(analysisId, compile);
            fModule.setName(getName(element));
            break;
        default:
            fail();
    }
}
Also used : TmfXmlPatternCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu) TmfXmlStateProviderCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu) XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis) DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule)

Example 4 with TmfXmlPatternCu

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu in project tracecompass by tracecompass.

the class TmfAnalysisModuleHelperXml method newModule.

@Override
@Nullable
public final IAnalysisModule newModule(ITmfTrace trace) throws TmfAnalysisException {
    String analysisid = getId();
    IAnalysisModule module = null;
    switch(fType) {
        case STATE_SYSTEM:
            TmfXmlStateProviderCu compile = TmfXmlStateProviderCu.compile(fSourceFile.toPath(), analysisid);
            if (compile == null) {
                return null;
            }
            module = new DataDrivenAnalysisModule(analysisid, compile);
            module.setName(getName());
            break;
        case PATTERN:
            TmfXmlPatternCu patternCu = TmfXmlPatternCu.compile(fSourceFile.toPath(), analysisid);
            if (patternCu == null) {
                return null;
            }
            module = new XmlPatternAnalysis(analysisid, patternCu);
            module.setName(getName());
            XmlPatternAnalysis paModule = (XmlPatternAnalysis) module;
            paModule.setViewLabelPrefix(getViewLabelPrefix());
            break;
        case OTHER:
            String name = getName();
            module = createOtherModule(analysisid, name);
            break;
        default:
            break;
    }
    if (module != null) {
        if (module.setTrace(trace)) {
            TmfAnalysisManager.analysisModuleCreated(module);
        } else {
            /*
                 * The analysis does not apply to the trace, dispose of the
                 * module
                 */
            module.dispose();
            module = null;
        }
    }
    return module;
}
Also used : TmfXmlPatternCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu) TmfXmlStateProviderCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis) DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 5 with TmfXmlPatternCu

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu in project tracecompass by tracecompass.

the class PatternAnalysisTestUtils method createModule.

private static XmlPatternAnalysis createModule(@NonNull Element element, TmfXmlTestFiles file) {
    String id = element.getAttribute(TmfXmlStrings.ID);
    TmfXmlPatternCu patternCu = TmfXmlPatternCu.compile(element);
    assertNotNull(patternCu);
    XmlPatternAnalysis module = new XmlPatternAnalysis(id, patternCu);
    module.setName(XmlModuleTestBase.getName(element));
    return module;
}
Also used : TmfXmlPatternCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu) XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis)

Aggregations

TmfXmlPatternCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu)6 XmlPatternAnalysis (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis)6 TmfXmlStateProviderCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu)4 DataDrivenAnalysisModule (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule)4 Element (org.w3c.dom.Element)3 Document (org.w3c.dom.Document)2 NodeList (org.w3c.dom.NodeList)2 NonNull (org.eclipse.jdt.annotation.NonNull)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)1 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1 Before (org.junit.Before)1