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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package com.megatim.fdxcommons.core.impl.helper.referentiel;
 
import com.megatim.fdxcommons.core.ifaces.helper.referentiel.ReferentielXmlDataReader;
import com.megatim.fdxcommons.model.jaxb.ApplicationSourcesToExport;
import com.megatim.fdxcommons.model.jaxb.ExtensionFichiersToExport;
import com.megatim.fdxcommons.model.jaxb.GroupeNoeudsToExport;
import com.megatim.fdxcommons.model.jaxb.GroupeParticipantsToExport;
import com.megatim.fdxcommons.model.jaxb.NatureProductionFichiersToExport;
import com.megatim.fdxcommons.model.jaxb.NoeudsToExport;
import com.megatim.fdxcommons.model.jaxb.ParticipantsToExport;
import com.megatim.fdxcommons.model.jaxb.PaysToExport;
import com.megatim.fdxcommons.model.jaxb.ReferentielsToExport;
import com.megatim.fdxcommons.model.jaxb.RoutagesToExport;
import com.megatim.fdxcommons.model.jaxb.StructureLigneToExport;
import com.megatim.fdxcommons.model.jaxb.TypeFichiersToExport;
import com.megatim.fdxcommons.model.jaxb.ValidateurFichierConfigurationToExport;
import com.megatim.fdxcommons.model.jaxb.ValidateurFichierToExport;
import com.megatim.fdxcommons.model.pojo.ReferentielToImportData;
import com.megatim.fdxcommons.model.referentiel.ValidateurFichierConfiguration;
import com.megatim.fdxcommons.core.impl.tools.XmlUtils;
import java.io.File;
import java.util.List;
import javax.enterprise.context.Dependent;
 
/**
 *
 * @author lenovo
 */
@Dependent
public class ReferentielXmlDataReaderImpl implements ReferentielXmlDataReader {
 
    @Override
    public void readData(File referentielXmlFileDirectory, ReferentielToImportData referentielToImportData) throws Exception {
 
        if (referentielXmlFileDirectory.isDirectory()) {
 
            File[] xmlFiles = referentielXmlFileDirectory.listFiles();
 
            for (File xmlFile : xmlFiles) {
 
                switch (xmlFile.getName()) {
 
                    case "applicationSources.xml":
                        readApplicationSources(xmlFile, referentielToImportData);
                        break;
 
                    case "extensionFichiers.xml":
                        readExtensionFichiers(xmlFile, referentielToImportData);
                        break;
 
                    case "groupeNoeuds.xml":
                        readGroupeNoeuds(xmlFile, referentielToImportData);
                        break;
 
                    case "structureLignes.xml":
                        readStructureLignes(xmlFile, referentielToImportData);
                        break;
 
                    case "validateurFichiers.xml":
                        readValidateurFichiers(xmlFile, referentielToImportData);
                        break;
 
                    case "groupeParticipants.xml":
                        readGroupeParticipants(xmlFile, referentielToImportData);
                        break;
 
                    case "noeuds.xml":
                        readNoeuds(xmlFile, referentielToImportData);
                        break;
 
                    case "participants.xml":
                        readParticipants(xmlFile, referentielToImportData);
                        break;
 
                    case "pays.xml":
                        readPays(xmlFile, referentielToImportData);
                        break;
 
                    case "referentiels.xml":
                        readReferentiels(xmlFile, referentielToImportData);
                        break;
 
                    case "routages.xml":
                        readRoutages(xmlFile, referentielToImportData);
                        break;
 
                    case "typeFichiers.xml":
                        readTypeFichiers(xmlFile, referentielToImportData);
                        break;
 
                    case "validateurFichierConfigurations.xml":
                        readValidateurFichierConfiguration(xmlFile, referentielToImportData);
                        break;
 
                    case "natureProductionFichiers.xml":
                        readNatureProductionFichiers(xmlFile, referentielToImportData);
                        break;
                }
            }
 
        }
 
    }
 
    private void readValidateurFichierConfiguration(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        ValidateurFichierConfigurationToExport validateurFichierConfigurationToExport = (ValidateurFichierConfigurationToExport) XmlUtils.unMarshal(xmlFile, ValidateurFichierConfigurationToExport.class);
        List<ValidateurFichierConfiguration> validateurFichierConfigurations = validateurFichierConfigurationToExport.getValidateurFichierConfigurationList().getValidateurFichierConfigurationList();
        referentielToImportData.setValidateurFichierConfigurations(validateurFichierConfigurations);
    }
 
    private void readTypeFichiers(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        TypeFichiersToExport typeFichiersToExport = (TypeFichiersToExport) XmlUtils.unMarshal(xmlFile, TypeFichiersToExport.class);
        referentielToImportData.setTypeFichiers(typeFichiersToExport.getTypeFichiersList());
    }
 
    private void readRoutages(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        RoutagesToExport routagesToExport = (RoutagesToExport) XmlUtils.unMarshal(xmlFile, RoutagesToExport.class);
        referentielToImportData.setRoutages(routagesToExport.getRoutageList());
    }
 
    private void readReferentiels(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        ReferentielsToExport referentielsToExport = (ReferentielsToExport) XmlUtils.unMarshal(xmlFile, ReferentielsToExport.class);
        referentielToImportData.setReferentiels(referentielsToExport.getReferentielList());
    }
 
    private void readPays(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        PaysToExport paysToExport = (PaysToExport) XmlUtils.unMarshal(xmlFile, PaysToExport.class);
        referentielToImportData.setPays(paysToExport.getPaysList());
    }
 
    private void readParticipants(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        ParticipantsToExport participantsToExport = (ParticipantsToExport) XmlUtils.unMarshal(xmlFile, ParticipantsToExport.class);
        referentielToImportData.setParticipants(participantsToExport.getParticipants());
    }
 
    private void readNoeuds(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        NoeudsToExport noeudsToExport = (NoeudsToExport) XmlUtils.unMarshal(xmlFile, NoeudsToExport.class);
        referentielToImportData.setNoeuds(noeudsToExport.getNoeuds());
    }
 
    private void readGroupeParticipants(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        GroupeParticipantsToExport groupeParticipantsToExport = (GroupeParticipantsToExport) XmlUtils.unMarshal(xmlFile, GroupeParticipantsToExport.class);
        referentielToImportData.setGroupeParticipants(groupeParticipantsToExport.getGroupeParticipants());
    }
 
    private void readValidateurFichiers(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        ValidateurFichierToExport validateurFichierToExport = (ValidateurFichierToExport) XmlUtils.unMarshal(xmlFile, ValidateurFichierToExport.class);
        referentielToImportData.setValidateurFichiers(validateurFichierToExport.getValidateurFichierList());
    }
 
    private void readStructureLignes(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        StructureLigneToExport structureLigneToExport = (StructureLigneToExport) XmlUtils.unMarshal(xmlFile, StructureLigneToExport.class);
        referentielToImportData.setStructureLignes(structureLigneToExport.getStructureLigneList());
    }
 
    private void readGroupeNoeuds(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        GroupeNoeudsToExport groupeNoeudsToExport = (GroupeNoeudsToExport) XmlUtils.unMarshal(xmlFile, GroupeNoeudsToExport.class);
        referentielToImportData.setGroupeNoeuds(groupeNoeudsToExport.getGroupeNoeuds());
    }
 
    private void readExtensionFichiers(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        ExtensionFichiersToExport extensionFichiersToExport = (ExtensionFichiersToExport) XmlUtils.unMarshal(xmlFile, ExtensionFichiersToExport.class);
        referentielToImportData.setExtensionFichiers(extensionFichiersToExport.getExtensionFichiers());
    }
 
    private void readApplicationSources(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        ApplicationSourcesToExport applicationSourcesToExport = (ApplicationSourcesToExport) XmlUtils.unMarshal(xmlFile, ApplicationSourcesToExport.class);
        referentielToImportData.setApplicationSources(applicationSourcesToExport.getApplicationSourceList());
    }
 
    private void readNatureProductionFichiers(File xmlFile, ReferentielToImportData referentielToImportData) throws Exception {
        NatureProductionFichiersToExport natureProductionFichiersToExport = (NatureProductionFichiersToExport) XmlUtils.unMarshal(xmlFile, NatureProductionFichiersToExport.class);
        referentielToImportData.setNatureProductionFichiers(natureProductionFichiersToExport.getNatureProductionFichierList());
    }
}