use of org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel in project tracecompass by tracecompass.
the class XmlXYDataProvider method fetchTree.
/**
* @since 2.4
*/
@Override
public TmfModelResponse<TmfTreeModel<ITmfTreeDataModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
fLock.readLock().lock();
try {
if (fCached != null) {
return fCached;
}
} finally {
fLock.readLock().unlock();
}
ITmfStateSystem ss = fXmlEntry.getStateSystem();
DataDrivenStateSystemPath seriesNameAttrib = fSeriesNameAttrib;
boolean isComplete = ss.waitUntilBuilt(0);
// Get the quarks before the full states to ensure that the attributes will be present in the full state
List<Integer> quarks = fXmlEntry.getQuarks();
fLock.writeLock().lock();
try {
List<ITmfStateInterval> fullState = ss.queryFullState(ss.getCurrentEndTime());
ImmutableList.Builder<ITmfTreeDataModel> builder = ImmutableList.builder();
builder.add(new TmfTreeDataModel(fTraceId, -1, Collections.singletonList(getTrace().getName())));
for (int quark : quarks) {
String seriesName = ss.getAttributeName(quark);
if (seriesNameAttrib != null) {
// Use the value of the series name attribute
int seriesNameQuark = seriesNameAttrib.getQuark(quark, fXmlEntry);
Object value = fullState.get(seriesNameQuark).getValue();
if (value != null) {
seriesName = String.valueOf(value);
}
}
if (!seriesName.isEmpty()) {
String tempSeriesName = seriesName;
String uniqueName = fQuarkToString.computeIfAbsent(quark, q -> getUniqueNameFor(tempSeriesName));
// Check if an ID has already been created for this quark.
Long id = fIdToQuark.inverse().computeIfAbsent(quark, q -> ENTRY_IDS.getAndIncrement());
builder.add(new TmfTreeDataModel(id, fTraceId, Collections.singletonList(uniqueName)));
}
}
ImmutableList<ITmfTreeDataModel> list = builder.build();
if (isComplete) {
TmfModelResponse<TmfTreeModel<ITmfTreeDataModel>> tmfModelResponse = new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), list), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
fCached = tmfModelResponse;
return tmfModelResponse;
}
return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), list), ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
} catch (StateSystemDisposedException e) {
return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.STATE_SYSTEM_FAILED);
} finally {
fLock.writeLock().unlock();
}
}
Aggregations