Search in sources :

Example 1 with TmfXmlStateProviderCu

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu 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 TmfXmlStateProviderCu

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

the class XmlUtilsTest method initializeModule.

/**
 * Initialize a new module using the xml file
 *
 * @param xmlAnalysisFile
 *            The xml file used to initialize the module
 * @return The module
 */
@NonNull
public static DataDrivenAnalysisModule initializeModule(TmfXmlTestFiles xmlAnalysisFile) {
    /* Initialize the state provider module */
    Document doc = xmlAnalysisFile.getXmlDocument();
    assertNotNull(doc);
    List<@NonNull Element> childElements = TmfXmlUtils.getChildElements(doc.getDocumentElement(), TmfXmlStrings.STATE_PROVIDER);
    assertFalse(childElements.isEmpty());
    Element element = childElements.get(0);
    String moduleId = element.getAttribute(TmfXmlStrings.ID);
    TmfXmlStateProviderCu compile = TmfXmlStateProviderCu.compile(xmlAnalysisFile.getFile().toPath(), moduleId);
    assertNotNull(compile);
    DataDrivenAnalysisModule module = new DataDrivenAnalysisModule(moduleId, compile);
    return module;
}
Also used : TmfXmlStateProviderCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 3 with TmfXmlStateProviderCu

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

the class StateProviderTest method testInvalidInput.

/**
 * Test an invalid instantiation
 */
@Test
public void testInvalidInput() {
    TmfXmlStateProviderCu compile = TmfXmlStateProviderCu.compile(Paths.get(""), "test");
    assertNull(compile);
}
Also used : TmfXmlStateProviderCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu) Test(org.junit.Test)

Example 4 with TmfXmlStateProviderCu

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu 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 5 with TmfXmlStateProviderCu

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu 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)

Aggregations

TmfXmlStateProviderCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu)6 DataDrivenAnalysisModule (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule)5 TmfXmlPatternCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu)4 XmlPatternAnalysis (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis)4 Element (org.w3c.dom.Element)3 Document (org.w3c.dom.Document)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 Test (org.junit.Test)1 NodeList (org.w3c.dom.NodeList)1