From ee9fec32ec68db2e85776e1408df8c2e80289bd5 Mon Sep 17 00:00:00 2001 From: Kaveh Shahedi Date: Wed, 9 Apr 2025 14:08:51 -0400 Subject: [PATCH] tmf.core: Add data fetching capabilities to data providers Introduce a new interface ITmfDataProviderConfigurationDataFetcher and model class TmfDataProviderConfigurationDataModel to allow data providers to fetch and return custom data based on provider configuration. [Added] Infrastructure of fetching a data provider configuration's data Signed-off-by: Kaveh Shahedi --- .../META-INF/MANIFEST.MF | 3 +- .../ITmfDataProviderDataFetcher.java | 39 ++++++++++ .../TmfDataProviderDataModel.java | 73 +++++++++++++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/provisional/tmf/core/dataprovider/ITmfDataProviderDataFetcher.java create mode 100644 tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/provisional/tmf/core/dataprovider/TmfDataProviderDataModel.java diff --git a/tmf/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF b/tmf/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF index 71ce1ca536..9ff59656b4 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF +++ b/tmf/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF @@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.tracecompass.tmf.filter.parser, org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional, org.apache.commons.lang3 -Export-Package: org.eclipse.tracecompass.internal.provisional.tmf.core.model, +Export-Package: org.eclipse.tracecompass.internal.provisional.tmf.core.dataprovider;x-internal:=true, + org.eclipse.tracecompass.internal.provisional.tmf.core.model, org.eclipse.tracecompass.internal.provisional.tmf.core.model.events;x-friends:="org.eclipse.tracecompass.tmf.core.tests,org.eclipse.tracecompass.analysis.timing.core.tests", org.eclipse.tracecompass.internal.provisional.tmf.core.model.filter.parser;x-friends:="org.eclipse.tracecompass.tmf.ui,org.eclipse.tracecompass.tmf.core.tests", org.eclipse.tracecompass.internal.provisional.tmf.core.model.filters; diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/provisional/tmf/core/dataprovider/ITmfDataProviderDataFetcher.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/provisional/tmf/core/dataprovider/ITmfDataProviderDataFetcher.java new file mode 100644 index 0000000000..b5e64038ba --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/provisional/tmf/core/dataprovider/ITmfDataProviderDataFetcher.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2025 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License 2.0 which + * accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.tracecompass.internal.provisional.tmf.core.dataprovider; + +import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderDescriptor; +import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse; +import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; + +/** + * Interface for data providers that can fetch custom data based on the provider. + * Data providers that need to return specialized data types (images, reports, etc.) + * can implement this interface and define the data fetching logic. + * + * @author Kaveh Shahedi + * @since 10.3 + */ +public interface ITmfDataProviderDataFetcher { + + /** + * Get the data for a specific trace and data provider. + * + * @param trace + * The trace to get the data for + * @param descriptor + * The descriptor of the data provider + * @return The report data + * @throws Exception + * If the data cannot be retrieved + */ + TmfModelResponse> getData(ITmfTrace trace, IDataProviderDescriptor descriptor) throws Exception; +} diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/provisional/tmf/core/dataprovider/TmfDataProviderDataModel.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/provisional/tmf/core/dataprovider/TmfDataProviderDataModel.java new file mode 100644 index 0000000000..52e98fd6a3 --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/provisional/tmf/core/dataprovider/TmfDataProviderDataModel.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2025 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License 2.0 which + * accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.tracecompass.internal.provisional.tmf.core.dataprovider; + +/** + * Data model for the data provider configuration data. This class is used to + * hold the data that is returned by the data provider configuration. + * + * @author Kaveh Shahedi + * + * @param Type of the content + */ +public class TmfDataProviderDataModel { + + private T fContent; + private String fContentType; + private String fContentName; + + /** + * Constructor + * + * @param content + * The content of the data model + * @param contentType + * The type of the content + * @param contentName + * The name of the content + */ + public TmfDataProviderDataModel(T content, String contentType, String contentName) { + fContent = content; + fContentType = contentType; + fContentName = contentName; + } + + /** + * Get the content of the data model. + * + * @return The content of the data model + */ + public T getContent() { + return fContent; + } + + /** + * Get the type of the content. + * This is used to identify the type of content that is returned by, + * for instance, MIME type (e.g., application/octet-stream for binary data). + * + * @return The type of the content + */ + public String getContentType() { + return fContentType; + } + + /** + * Get the name of the content. + * This is used to identify the name the content if required, + * as it could be saved to a file. + * + * @return The name of the content + */ + public String getContentName() { + return fContentName; + } +}