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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
|
package com.cl.zqen.services.impl;
import java.util.HashMap;
import java.util.Map;
import com.cl.fwk.services.cics.CICSService;
import com.cl.fwk.services.cics.CommareaInput;
import com.cl.fwk.services.cics.CommareaOutput;
import com.cl.fwk.services.cics.Transaction;
import com.cl.fwk.services.log.LogService;
import com.cl.zqen.services.ListesParametrablesTPService;
/**
* récupération de liste de couple "code,libellé". utilisée pour alimenter des combo box, mais aussi le libellé d'une donnée dont on ne connait que le code.
*
* @author TAHIR_A
*/
public class ListesParametrablesTPServiceImpl implements ListesParametrablesTPService {
/** etat du lancement de la tache. */
private boolean isRunnedOneTime = false;
/** map des devises. */
private static Map<String, String> mapDevises = new HashMap<String, String>();
/** map decimale monde. */
private static Map<String, String> mapDecimaleMonde = new HashMap<String, String>();
/** map devises europe. */
private static Map<String, String> mapDevisesEurope = new HashMap<String, String>();
/** map pays. */
private static Map<String, String> mapPays = new HashMap<String, String>();
/** map pays code interne. */
private static Map<String, String> mapPaysCodeInterne = new HashMap<String, String>();
/** map pays europe. */
private static Map<String, String> mapPaysEurope = new HashMap<String, String>();
/** map pays restrints. */
private static Map<String, String> mapPaysRestreints = new HashMap<String, String>();
/** Handler du service de log. */
private LogService log;
/** Handler sur le service CICS. */
private CICSService cics;
/**
* @return the mapPays
*/
public static Map<String, String> getMapPays() {
return mapPays;
}
/**
* @param mapPays the mapPays to set
*/
public static void setMapPays(Map<String, String> mapPays) {
ListesParametrablesTPServiceImpl.mapPays = mapPays;
}
/**
* @return the mapPaysCodeInterne
*/
public static Map<String, String> getMapPaysCodeInterne() {
return mapPaysCodeInterne;
}
/**
* @param mapPaysCodeInterne the mapPaysCodeInterne to set
*/
public static void setMapPaysCodeInterne(Map<String, String> mapPaysCodeInterne) {
ListesParametrablesTPServiceImpl.mapPaysCodeInterne = mapPaysCodeInterne;
}
/**
* @return the mapPaysEurope
*/
public static Map<String, String> getMapPaysEurope() {
return mapPaysEurope;
}
/**
* @param mapPaysEurope the mapPaysEurope to set
*/
public static void setMapPaysEurope(Map<String, String> mapPaysEurope) {
ListesParametrablesTPServiceImpl.mapPaysEurope = mapPaysEurope;
}
/**
* @return the mapPays
*/
public static Map<String, String> getMapPaysRestreints() {
return mapPaysRestreints;
}
/**
* @param mapPaysRestreints the mapPaysRestreints to set
*/
public static void setMapPaysRestreints(Map<String, String> mapPaysRestreints) {
ListesParametrablesTPServiceImpl.mapPaysRestreints = mapPaysRestreints;
}
/**
* @return the mapDevises
*/
public static Map<String, String> getMapDevises() {
return mapDevises;
}
/**
* @param mapDevises the mapDevises to set
*/
public static void setMapDevises(Map<String, String> mapDevises) {
ListesParametrablesTPServiceImpl.mapDevises = mapDevises;
}
/**
* @return the mapDevisesEurope
*/
public static Map<String, String> getMapDevisesEurope() {
return mapDevisesEurope;
}
/**
* @param mapDevisesEurope the mapDevisesEurope to set
*/
public static void setMapDevisesEurope(Map<String, String> mapDevisesEurope) {
ListesParametrablesTPServiceImpl.mapDevisesEurope = mapDevisesEurope;
}
/**
* @return the mapDecimaleMonde
*/
public static Map<String, String> getMapDecimaleMonde() {
return mapDecimaleMonde;
}
/**
* @param mapDecimaleMonde the mapDecimaleMonde to set
*/
public static void setMapDecimaleMonde(Map<String, String> mapDecimaleMonde) {
ListesParametrablesTPServiceImpl.mapDecimaleMonde = mapDecimaleMonde;
}
/**
* {@inheritDoc}
*/
public boolean runned() {
return mapDevises != null && mapDevises.size() > 0;
}
/**
* @param cics the cics to set .
*/
public void setCics(final CICSService cics) {
this.cics = cics;
}
/**
* Setter du service LOG.
*
* @param log : le service LOG a setter.
*/
public void setLog(final LogService log) {
this.log = log;
}
/**
* mise à jour de la liste des codes bloopés ainsi que l'état bloqué du site.
*
*/
public void run() {
manageCodesPays();
manageCodesDevises();
}
/**
*
*/
private void manageCodesPays() {
try {
mapDevises.clear();
mapDecimaleMonde.clear();
mapDevisesEurope.clear();
// obtention de la transaction
final Transaction transaction = cics.getTransaction("H3DV");
// creation de la commarea d'entrée
final CommareaInput input = transaction.createInput();
// appel métier
final CommareaOutput output = transaction.execute(input);
final String numErr = output.getString("COM-ENTETE-APPLI-CODE-RET", true);
if (!numErr.equals("")) {
log.debug(this.getClass().getName() + " -> ERREUR BLOQUANTE CICS service " + output.getProgramme() + ". Numero : [" + numErr + "].");
} else {
final int nbElements = output.getShort("COM-OUT-NB-DEV");
// for (final CommareaOutput element : output.getArray("COM-OUT-LISTE-DEV", nbElements)) {
// // final String codeDevise = element.getString("COM-OUT-CODE-INT", true);
// final String codeIso = element.getString("COM-OUT-CODE-ISO", true);
// final String nbrDecimale = element.getString("COM-OUT-NB-DECI", true);
// final String libDevise = element.getString("COM-OUT-LIB-DEV", true);
// mapDevises.put(codeIso, libDevise);
// mapDecimaleMonde.put(codeIso, nbrDecimale);
alimenterMAp(nbElements, output);
// }
// parcours de la liste devises europe
final int nbElementsEurope = output.getShort("COM-OUT-NB-DEV-EUR");
// récupération de la liste des elements
for (final CommareaOutput element : output.getArray("COM-OUT-LISTE-DEV-EUR", nbElementsEurope)) {
final String codeIso = element.getString("COM-OUT-CODE-ISO-EUR", true);
final String libDevise = element.getString("COM-OUT-LIB-DEV-EUR", true);
mapDevisesEurope.put(codeIso, libDevise);
}
// changement d'état du service : il a été lancé
if (!isRunnedOneTime) {
isRunnedOneTime = true;
}
}
} catch (Exception e) {
log.critical(9003, e, "H3H3DVP : Erreur de récupération de la liste des codes devises");
}
}
/**
*
*/
private void manageCodesDevises() {
try {
mapPays.clear();
mapPaysCodeInterne.clear();
mapPaysEurope.clear();
mapPaysRestreints.clear();
// obtention de la transaction
final Transaction transaction = cics.getTransaction("H3PY");
// creation de la commarea d'entrée
final CommareaInput input = transaction.createInput();
// appel métier
final CommareaOutput output = transaction.execute(input);
final String numErr = output.getString("COM-ENTETE-APPLI-CODE-RET", true);
// final String msgErr = output.getString("COM-ENTETE-APPLI-CODE-MSG");
if (!numErr.equals("")) {
log.debug(this.getClass().getName() + " -> ERREUR BLOQUANTE CICS service " + output.getProgramme() + ". Numero : [" + numErr + "].");
} else {
// parcours de la liste
final int nbElements = output.getShort("COM-OUT-NB-PAYS");
// récupération de la liste des elements
output.getArray("COM-OUT-LISTE-PAYS");
for (final CommareaOutput element : output.getArray("COM-OUT-LISTE-PAYS", nbElements)) {
final String codePays = element.getString("COM-OUT-CODE-INT", true);
final String codeIso = element.getString("COM-OUT-CODE-ISO2", true);
final String libPays = element.getString("COM-OUT-LIB-PAYS", true);
mapPays.put(codeIso, libPays);
mapPaysCodeInterne.put(codePays, libPays);
}
final int nbElementsEurope = output.getShort("COM-OUT-NB-PAYS-EUR");
// récupération de la liste des elements
for (final CommareaOutput element : output.getArray("COM-OUT-LISTE-PAYS-EUR", nbElementsEurope)) {
final String codePays = element.getString("COM-OUT-CODE-ISO2-EUR", true);
final String libPays = element.getString("COM-OUT-LIB-PAYS-EUR", true);
mapPaysEurope.put(codePays, libPays);
}
final int nbElementsRestreints = output.getShort("COM-OUT-NB-PAYS-RES");
// récupération de la liste des elements
for (final CommareaOutput element : output.getArray("COM-OUT-LISTE-RES", nbElementsRestreints)) {
final String codePays = element.getString("COM-OUT-CODE-ISO2-RES", true);
final String libPays = element.getString("COM-OUT-LIB-PAYS-RES", true);
mapPaysRestreints.put(codePays, libPays);
}
// changement d'état du service : il a été lancé
if (!isRunnedOneTime) {
isRunnedOneTime = true;
}
}
} catch (Exception e) {
log.critical(9003, e, "H3H3PYP : Erreur de récupération de la liste des codes pays");
}
}
synchronized public static void alimenterMAp(int nbElements, CommareaOutput output) {
mapDevises = new HashMap<String, String>();
mapDecimaleMonde = new HashMap<String, String>();
for (final CommareaOutput element : output.getArray("COM-OUT-LISTE-DEV", nbElements)) {
// final String codeDevise = element.getString("COM-OUT-CODE-INT", true);
final String codeIso = element.getString("COM-OUT-CODE-ISO", true);
final String nbrDecimale = element.getString("COM-OUT-NB-DECI", true);
final String libDevise = element.getString("COM-OUT-LIB-DEV", true);
mapDevises.put(codeIso, libDevise);
mapDecimaleMonde.put(codeIso, nbrDecimale);
}
}
} |
Partager