use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData in project tracecompass by tracecompass.
the class XmlXYDataProvider method create.
/**
* Create an instance of {@link XmlXYDataProvider}. Returns null if statesystem
* is null.
*
* @param trace
* A trace on which we are interested to fetch a model
* @param analysisIds
* A list of analysis ids used for retrieving Analysis objects
* @param entryElement
* An XML entry element
* @return A XmlDataProvider
*/
@Nullable
public static XmlXYDataProvider create(ITmfTrace trace, Set<String> analysisIds, Element entryElement) {
ITmfAnalysisModuleWithStateSystems ss = getStateSystemFromAnalyses(analysisIds, trace);
if (ss == null) {
return null;
}
AnalysisCompilationData compilationData = new AnalysisCompilationData();
/*
* Initialize state attributes. There should be only one entry element for XY
* charts.
*/
String path = entryElement.hasAttribute(TmfXmlStrings.PATH) ? entryElement.getAttribute(TmfXmlStrings.PATH) : TmfXmlStrings.WILDCARD;
XmlXYEntry entry = new XmlXYEntry(ss, path, entryElement, compilationData);
/* Get the display element to use */
List<@NonNull Element> displayElements = TmfXmlUtils.getChildElements(entryElement, TmfXmlStrings.DISPLAY_ELEMENT);
if (displayElements.isEmpty()) {
return null;
}
Element displayElement = displayElements.get(0);
TmfXmlStateSystemPathCu display = TmfXmlStateSystemPathCu.compile(entry.getAnalysisCompilationData(), Collections.singletonList(displayElement));
if (display == null) {
return null;
}
/* Get the series name element to use */
List<Element> seriesNameElements = TmfXmlUtils.getChildElements(entryElement, TmfXmlStrings.NAME_ELEMENT);
DataDrivenStateSystemPath seriesName = null;
if (!seriesNameElements.isEmpty()) {
Element seriesNameElement = seriesNameElements.get(0);
TmfXmlStateSystemPathCu seriesNameCu = TmfXmlStateSystemPathCu.compile(entry.getAnalysisCompilationData(), Collections.singletonList(seriesNameElement));
if (seriesNameCu != null) {
seriesName = seriesNameCu.generate();
}
}
return new XmlXYDataProvider(trace, entry, display.generate(), seriesName);
}
use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData in project tracecompass by tracecompass.
the class XmlDataProviderManager method getTimeGraphProviderFactory.
/**
* Create (if necessary) and get the
* {@link DataDrivenTimeGraphProviderFactory} from the viewElement.
*
* @param viewElement
* the XML time graph view element for which we are querying a
* provider
* @return the unique instance of a time graph provider for the queried
* parameters
*/
@Nullable
public synchronized DataDrivenTimeGraphProviderFactory getTimeGraphProviderFactory(Element viewElement) {
if (!viewElement.hasAttribute(ID_ATTRIBUTE)) {
return null;
}
String viewId = viewElement.getAttribute(ID_ATTRIBUTE);
// factory that can be null
if (fTimeGraphFactories.containsKey(viewId)) {
return fTimeGraphFactories.get(viewId);
}
// Create with the trace or experiment first
DataDrivenTimeGraphProviderFactory factory = null;
TmfXmlTimeGraphViewCu tgViewCu = TmfXmlTimeGraphViewCu.compile(new AnalysisCompilationData(), viewElement);
if (tgViewCu != null) {
factory = tgViewCu.generate();
}
fTimeGraphFactories.put(viewId, factory);
return factory;
}
use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData in project tracecompass by tracecompass.
the class XmlDataProviderManager method getXyProviderFactory.
/**
* Create (if necessary) and get the {@link DataDrivenXYProviderFactory} for
* the specified trace and viewElement.
*
* @param viewElement
* the XML XY view element for which we are querying a provider
* @return the unique instance of an XY provider for the queried parameters
*/
@Nullable
public synchronized DataDrivenXYProviderFactory getXyProviderFactory(Element viewElement) {
if (!viewElement.hasAttribute(ID_ATTRIBUTE)) {
return null;
}
String viewId = viewElement.getAttribute(ID_ATTRIBUTE);
// factory that can be null
if (fXYFactories.containsKey(viewId)) {
return fXYFactories.get(viewId);
}
// Create with the trace or experiment first
DataDrivenXYProviderFactory factory = null;
TmfXmlXYViewCu tgViewCu = TmfXmlXYViewCu.compile(new AnalysisCompilationData(), viewElement);
if (tgViewCu != null) {
factory = tgViewCu.generate();
}
fXYFactories.put(viewId, factory);
return factory;
}
use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData in project tracecompass by tracecompass.
the class TmfXmlStateAttributeAndLocationCuTest method testValidLocationCompilation.
/**
* Test the compilation of a valid state location strings, and states
* attributes that use it
*
* @throws SAXException
* Exception thrown by parser
* @throws IOException
* Exception thrown by parser
* @throws ParserConfigurationException
* Exception thrown by parser
*/
@Test
public void testValidLocationCompilation() throws SAXException, IOException, ParserConfigurationException {
String locName = "loc";
String location = "<location id=\"" + locName + "\">" + "<stateAttribute type=\"constant\" value=\"abc\" />" + "<stateAttribute type=\"eventField\" value=\"myField\" />" + "</location>";
AnalysisCompilationData data = new AnalysisCompilationData();
Element xmlElement = TmfXmlTestUtils.getXmlElement(TmfXmlStrings.LOCATION, location);
assertNotNull(xmlElement);
TmfXmlLocationCu locationCu = TmfXmlLocationCu.compile(data, xmlElement);
assertNotNull("location", locationCu);
// Add the location to the compilation data
data.addLocation(locName, locationCu);
// Compile a location state attribute
String attributeXml = "<stateAttribute type=\"location\" value=\"" + locName + "\" />";
xmlElement = TmfXmlTestUtils.getXmlElement(TmfXmlStrings.STATE_ATTRIBUTE, attributeXml);
assertNotNull(xmlElement);
List<@NonNull TmfXmlStateValueCu> attribute = TmfXmlStateValueCu.compileAttribute(data, xmlElement);
assertNotNull("Location attribute compilation", attribute);
assertEquals("Attribute count", 2, attribute.size());
List<DataDrivenValue> expected = ImmutableList.of(new DataDrivenValueConstant(null, ITmfStateValue.Type.NULL, "abc"), new DataDrivenValueEventField(null, ITmfStateValue.Type.NULL, "myField"));
List<DataDrivenValue> actual = attribute.stream().map(a -> a.generate()).collect(Collectors.toList());
assertEquals("Location generated", expected, actual);
}
use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData in project tracecompass by tracecompass.
the class TmfXmlActionCuTest method testAction.
/**
* Test the compilation of a valid action strings
*
* @throws SAXException
* Exception thrown by parser
* @throws IOException
* Exception thrown by parser
* @throws ParserConfigurationException
* Exception thrown by parser
*/
@Test
public void testAction() throws SAXException, IOException, ParserConfigurationException {
AnalysisCompilationData data = new AnalysisCompilationData();
Element xmlElement = TmfXmlTestUtils.getXmlElement(TmfXmlStrings.ACTION, fExpected.getXmlString());
assertNotNull(xmlElement);
TmfXmlActionCu compiledAction = TmfXmlActionCu.compileNamedAction(data, xmlElement);
if (fExpected.getResult() == null) {
assertNull("Expected null action" + fExpected.getName(), compiledAction);
} else {
assertNotNull("Expected non null " + fExpected.getName(), compiledAction);
assertEquals(fExpected.getName() + " generated", fExpected.getResult(), compiledAction.generate());
}
}
Aggregations