All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.chutneytesting.design.api.dataset.DataSetMapper Maven / Gradle / Ivy

package com.chutneytesting.design.api.dataset;

import static com.chutneytesting.tools.ui.ComposableIdUtils.toFrontId;

import com.chutneytesting.tools.ui.KeyValue;
import com.chutneytesting.design.domain.dataset.DataSet;
import com.chutneytesting.tools.ui.ComposableIdUtils;
import java.util.stream.Collectors;

public class DataSetMapper {

    public static DataSetDto toDto(DataSet dataSet, Integer version) {
        return ImmutableDataSetDto.builder()
            .id(toFrontId(dataSet.id))
            .name(dataSet.name)
            .version(version)
            .description(dataSet.description)
            .lastUpdated(dataSet.creationDate)
            .tags(dataSet.tags)
            .constants(KeyValue.fromMap(dataSet.constants))
            .datatable(dataSet.datatable.stream().map(KeyValue::fromMap).collect(Collectors.toList()))
            .build();
    }

    public static DataSet fromDto(DataSetDto dto) {
        return DataSet.builder()
            .withId(dto.id().map(ComposableIdUtils::fromFrontId).orElse(null))
            .withName(dto.name())
            .withDescription(dto.description())
            .withCreationDate(dto.lastUpdated())
            .withTags(dto.tags())
            .withConstants(KeyValue.toMap(dto.constants()))
            .withDatatable(dto.datatable().stream().map(KeyValue::toMap).collect(Collectors.toList()))
            .build();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy