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);
}
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;
}
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();
}
}
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;
}
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;
}
Aggregations