Kenmegne
7 days ago 23a46b4be35277e06ec89f48730eeb694e686be8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.megatim.fdxconsultation.core.impl.stats;
 
import com.megatim.fdxcommons.model.pojo.BetweenOperatorValues;
import com.megatim.fdxcommons.model.pojo.CriteriaEntityFromView;
import com.megatim.fdxconsultation.model.stats.CriteriaEntityPersisted;
import com.megatim.fdxconsultation.model.stats.TableConfiguration;
import com.megatim.fdxconsultation.model.stats.dto.TableConfigurationResponse;
import com.megatim.fdxconsultation.model.stats.dto.TableauBordColumnResponse;
import java.io.Serializable;
import java.util.Set;
import java.util.stream.Collectors;
 
/**
 *
 * @author Gabuntu
 */
public class ConvertedTableConfigurationResponse implements Serializable {
 
    private final TableConfiguration tableConfiguration;
 
    public ConvertedTableConfigurationResponse(TableConfiguration tableConfiguration) {
        this.tableConfiguration = tableConfiguration;
    }
 
    public TableConfigurationResponse tableConfigurationResponse() {
        return new TableConfigurationResponse(
                tableConfiguration.getLibelle(),
                tableConfiguration.getFonctionAggregation(),
                tableConfiguration.getTypeResultatConfiguration(),
                targetedColumn(),
                groupingColumns(),
                new ConvertedCriteriaEntityFromView(tableConfiguration.getCriterion()).criteriaEntityFromView(),
                tableConfiguration.getColor()
        );
    }
 
    private Set<TableauBordColumnResponse> groupingColumns() {
        return tableConfiguration.getGroupingColumns() != null
                ? tableConfiguration
                        .getGroupingColumns()
                        .stream()
                        .map(c -> new TableauBordColumnResponse(c.getName(), c.getTypeDonnee()))
                        .collect(Collectors.toSet())
                : null;
    }
 
    private TableauBordColumnResponse targetedColumn() {
        return tableConfiguration.getTargetedColumn() != null
                ? new TableauBordColumnResponse(
                        tableConfiguration.getTargetedColumn().getName(),
                        tableConfiguration.getTargetedColumn().getTypeDonnee())
                : null;
    }
 
}