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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
 */
package com.megatim.fdxconsultation.core.ifaces.helper;
 
import com.megatim.fdxcommons.model.pojo.BetweenOperatorValues;
import com.megatim.fdxcommons.model.pojo.CriteriaEntityFromView;
import com.megatim.fdxcommons.model.referentiel.Referentiel;
import com.megatim.fdxconsultation.model.dto.stats.TableConfigurationDto;
import com.megatim.fdxconsultation.model.dto.stats.TableauBordDto;
import com.megatim.fdxconsultation.model.stats.CriteriaEntityPersisted;
import com.megatim.fdxconsultation.model.stats.TableConfiguration;
import com.megatim.fdxconsultation.model.stats.TableauBord;
import java.util.Set;
 
/**
 *
 * @author ASUS
 */
public interface TableauBordHandler {
 
    TableauBordDto tableauBordToTableauBordDto(TableauBord tableauBord);
 
    TableauBord tableauBordDtoToTableauBord(TableauBordDto dto, Referentiel referentiel);
 
    TableConfigurationDto tableConfigurationToTableConfigurationDto(TableConfiguration tableConf);
 
    void reconduireTableauBordValides(Referentiel previousRef, Referentiel newRef, Set<String> typeFichiersToMigrate);
 
    void stopIfUserSpecificTableauBordExists(String codeTypeFichier, String referentielVersion, String userName) throws Exception;
 
    void stopIfGlobaleTableauBordExists(String codeTypeFichier, String referentielVersion) throws Exception;
 
    public default CriteriaEntityFromView criteriaEntityPersistedToCriteriaEntityFromView(CriteriaEntityPersisted persisted) {
        if (persisted != null) {
            CriteriaEntityFromView mainCriterion = new CriteriaEntityFromView();
 
            if (persisted.getSubCriterias() != null && !persisted.getSubCriterias().isEmpty()) {
                mainCriterion.setCriteriaLogicConnector(persisted.getCriteriaLogicConnector());
                persisted.getSubCriterias().stream().forEach(c -> {
                    CriteriaEntityFromView criterionfromView = criteriaEntityPersistedToCriteriaEntityFromView(c);
 
                    if (criterionfromView != null) {
                        mainCriterion.getSubCriterias().add(criterionfromView);
                    }
 
                });
                return mainCriterion;
            } else {
                mainCriterion.setNomColonne(persisted.getNomColonne());
                mainCriterion.setOperateur(persisted.getOperateur());
                mainCriterion.setCriteriaValue(getCriteriaValue(persisted));
                return mainCriterion;
            }
        } else {
            return null;
        }
    }
 
    public default Object getCriteriaValue(CriteriaEntityPersisted persisted) {
 
        if (persisted.getCriteriaDateListValue() != null && !persisted.getCriteriaDateListValue().isEmpty()) {
            return persisted.getCriteriaDateListValue();
 
        } else if (persisted.getCriteriaDateLowerBound() != null && persisted.getCriteriaDateUpperBound() != null) {
            return new BetweenOperatorValues(persisted.getCriteriaDateLowerBound(), persisted.getCriteriaDateUpperBound());
 
        } else if (persisted.getCriteriaDateValue() != null) {
            return persisted.getCriteriaDateValue();
 
        } else if (persisted.getCriteriaNumericListValue() != null && !persisted.getCriteriaNumericListValue().isEmpty()) {
            return persisted.getCriteriaNumericListValue();
 
        } else if (persisted.getCriteriaNumericLowerBound() != null && persisted.getCriteriaNumericUpperBound() != null) {
            return new BetweenOperatorValues(persisted.getCriteriaNumericLowerBound(), persisted.getCriteriaNumericUpperBound());
 
        } else if (persisted.getCriteriaNumericValue() != null) {
            return persisted.getCriteriaNumericValue();
 
        } else if (persisted.getCriteriaStringListValue() != null && !persisted.getCriteriaStringListValue().isEmpty()) {
            return persisted.getCriteriaStringListValue();
 
        } else if (persisted.getCriteriaStringLowerBound() != null && persisted.getCriteriaStringUpperBound() != null) {
            return new BetweenOperatorValues(persisted.getCriteriaStringLowerBound(), persisted.getCriteriaStringUpperBound());
 
        } else if (persisted.getCriteriaStringValue() != null) {
            return persisted.getCriteriaStringValue();
 
        } else {
            return null;
        }
    }
}