Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel;
import org.eclipse.tracecompass.tmf.core.model.xy.ISeriesModel;
import org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel;
import org.eclipse.tracecompass.tmf.core.model.xy.TmfXYAxisDescription;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
Expand Down Expand Up @@ -80,6 +81,7 @@ public ObjectMapper getContext(Class<?> type) {
module.addSerializer(ITmfConfigurationSourceType.class, new TmfConfigurationSourceTypeSerializer());
module.addSerializer(ITmfConfigParamDescriptor.class, new TmfConfigParamDescriptorSerializer());
module.addSerializer(IAxisDomain.class, new AxisDomainSerializer());
module.addSerializer(TmfXYAxisDescription.class, new TmfXYAxisDescriptionSerializer());

// create JsonProvider to provide custom ObjectMapper
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**********************************************************************
* 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.incubator.internal.trace.server.jersey.rest.core.webapp;

import java.io.IOException;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.model.xy.TmfXYAxisDescription;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;

/**
* Serializer for XY axis description series model {@link TmfXYAxisDescription}
*
* @author Bernd Hufmann
*/
public class TmfXYAxisDescriptionSerializer extends StdSerializer<@NonNull TmfXYAxisDescription> {

/**
* Generated serialVersionUID
*/
private static final long serialVersionUID = 250364996978808548L;

/**
* Constructor.
*/
public TmfXYAxisDescriptionSerializer() {
super(TmfXYAxisDescription.class);
}

@Override
public void serialize(TmfXYAxisDescription value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeStartObject();
gen.writeStringField("label", value.getLabel()); //$NON-NLS-1$
gen.writeStringField("unit", value.getUnit()); //$NON-NLS-1$
gen.writeObjectField("dataType", value.getDataType()); //$NON-NLS-1$
if (value.getAxisDomain() != null) {
gen.writeObjectField("axisDomain", value.getAxisDomain()); //$NON-NLS-1$
}
gen.writeEndObject();
}
}
Loading