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 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.baccarat.gestionpolluant.controller.cumulpolluant;
import com.baccarat.gestionpolluant.controller.polluant.PolluantController;
import com.baccarat.gestionpolluant.entity.CumulPolluant;
import com.baccarat.gestionpolluant.entity.Polluant;
import com.baccarat.gestionpolluant.entity.Unite;
import com.baccarat.gestionpolluant.entity.Utilisateur;
import java.util.*;
import java.util.ArrayList;
import java.util.logging.*;
import javax.faces.model.SelectItem;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.baccarat.gestionpolluant.stateless.cumulpolluant.CumulPolluantRemote;
import com.baccarat.gestionpolluant.stateless.polluant.PolluantRemote;
import com.baccarat.gestionpolluant.stateless.utilisateur.UtilisateurRemote;
/**
*
* @author stginfo1
*/
public class CumulPolluantController {
private int id;
private String nom;
private String libelleModif;
private Set<Polluant> listePolluant;
private Utilisateur createur;
private Utilisateur createurModif;
private int idcreateur;
private int idcreateurModif;
private boolean enable;
private boolean enableModif;
private CumulPolluant c;
private int[] manyListboxValues;
private SelectItem[] manyListBoxItemsRech = new SelectItem[]{
new SelectItem(0, " ")
};
private int[] manyListBoxValuesRech;
private int idSelectionMenuCumul;
private SelectItem[] manyCheckBoxItemsRech = new SelectItem[]{
new SelectItem(0, " ")
};
private int[] manyCheckBoxValuesRech = new int[3];
/* Test de recupération de ajout cumul */
private List<SelectItem> listeCumulTest;
private List<SelectItem> listeCumulDajout;
private int affListeTaille;
/* Partie Cumul */
private Unite uniteCumulSelection;
private int nbPassage = 0;
public String createCumulPolluant() throws Exception {
CumulPolluantRemote cumul = null;
UtilisateurRemote utilisateur = null;
PolluantRemote polluant = null;
try {
Context initialContext = new InitialContext();
utilisateur = (UtilisateurRemote) initialContext.lookup("ejb/stateless/Utilisateur");
cumul = (CumulPolluantRemote) initialContext.lookup("ejb/stateless/CumulPolluant");
polluant = (PolluantRemote) initialContext.lookup("ejb/stateless/Polluant");
} catch (NamingException ex) {
Logger.getLogger(CumulPolluantController.class.getName()).log(Level.SEVERE, null, ex);
}
setListePolluant(new HashSet<Polluant>());
for (int tmp : getManyListboxValues()) {
getListePolluant().add(polluant.getPolluantBeanByValue(tmp));
}
setC(cumul.createCumulPolluantBeanByValue(new CumulPolluant(), getNom(), getListePolluant(), utilisateur.findUtilisateurByValue(getIdcreateur()), isEnable()));
return "itemCumul.create";
}
public List<SelectItem> getAllPolluant() {
PolluantRemote polluant = null;
try {
Context initialContext = new InitialContext();
polluant = (PolluantRemote) initialContext.lookup("ejb/stateless/Polluant");
} catch (NamingException ex) {
Logger.getLogger(CumulPolluantController.class.getName()).log(Level.SEVERE, null, ex);
}
List<Polluant> retour = polluant.selectAllByValue();
List<SelectItem> res = new ArrayList<SelectItem>(retour.size());
for (Polluant tmp : retour) {
res.add(new SelectItem(tmp.getIdPolluant(), tmp.getNom()));
}
return res;
}
public String getCumulPolluant() {
CumulPolluantRemote cumul = null;
try {
Context initialContext = new InitialContext();
cumul = (CumulPolluantRemote) initialContext.lookup("ejb/stateless/CumulPolluant");
} catch (NamingException ex) {
Logger.getLogger(CumulPolluantController.class.getName()).log(Level.SEVERE, null, ex);
}
c = cumul.findCumulByValue(getId());
SelectItem[] res = new SelectItem[c.getListePolluant().size()];
int i = 0;
for (Polluant tmp : c.getListePolluant()) {
res[i] = new SelectItem(tmp.getIdPolluant(), tmp.getNom());
i++;
}
setManyListBoxItemsRech(res);
return "itemCumul.found";
}
public String delCumulBean() {
CumulPolluantRemote cumul = null;
try {
Context initialContext = new InitialContext();
cumul = (CumulPolluantRemote) initialContext.lookup("ejb/stateless/CumulPolluant");
} catch (NamingException ex) {
Logger.getLogger(CumulPolluantController.class.getName()).log(Level.SEVERE, null, ex);
}
cumul.delCumulByValue(id);
return "itemCumul.del";
}
public List<SelectItem> getListeCumul() {
CumulPolluantRemote cumul = null;
try {
Context initialContext = new InitialContext();
cumul = (CumulPolluantRemote) initialContext.lookup("ejb/stateless/CumulPolluant");
} catch (NamingException ex) {
Logger.getLogger(CumulPolluantController.class.getName()).log(Level.SEVERE, null, ex);
}
List<CumulPolluant> retour = cumul.selectAllByValue();
List<SelectItem> res = new ArrayList<SelectItem>(retour.size());
res.add(new SelectItem(0, " "));
for (CumulPolluant tmp : retour) {
res.add(new SelectItem(tmp.getIdCumul(), tmp.getNom()));
}
return res;
}
public String boomLa() throws Exception {
CumulPolluantRemote cumul = null;
PolluantRemote polluant = null;
try {
Context initialContext = new InitialContext();
cumul = (CumulPolluantRemote) initialContext.lookup("ejb/stateless/CumulPolluant");
polluant = (PolluantRemote) initialContext.lookup("ejb/stateless/Polluant");
} catch (NamingException ex) {
Logger.getLogger(CumulPolluantController.class.getName()).log(Level.SEVERE, null, ex);
}
CumulPolluant tp = cumul.findCumulByValue(getIdSelectionMenuCumul());
setCreateurModif(tp.getCreateur());
setIdcreateurModif(createurModif.getIdUtil());
setLibelleModif(tp.getNom());
setEnableModif(tp.isEnable());
SelectItem[] rez = new SelectItem[polluant.selectAllByValue().size()];
int j = 0;
for (Polluant tmp : polluant.selectAllByValue()) {
rez[j] = new SelectItem(tmp.getIdPolluant(), tmp.getNom());
j++;
}
int[] res = new int[tp.getListePolluant().size()];
int i = 0;
for (Polluant tmp : tp.getListePolluant()) {
res[i] = tmp.getIdPolluant();
i++;
}
setManyCheckBoxItemsRech(rez);
setManyCheckBoxValuesRech(res);
return "maj.varCumul";
}
public void majCumul() {
CumulPolluantRemote cumul = null;
PolluantRemote polluant = null;
UtilisateurRemote utilisateur = null;
try {
Context initialContext = new InitialContext();
cumul = (CumulPolluantRemote) initialContext.lookup("ejb/stateless/CumulPolluant");
polluant = (PolluantRemote) initialContext.lookup("ejb/stateless/Polluant");
utilisateur = (UtilisateurRemote) initialContext.lookup("ejb/stateless/Utilisateur");
} catch (NamingException ex) {
Logger.getLogger(CumulPolluantController.class.getName()).log(Level.SEVERE, null, ex);
}
HashSet<Polluant> liste = new HashSet<Polluant>();
for (int tmp : getManyCheckBoxValuesRech()) {
liste.add(polluant.getPolluantBeanByValue(tmp));
}
cumul.majCumulByValue(idSelectionMenuCumul, libelleModif, liste, utilisateur.findUtilisateurByValue(idcreateurModif), enableModif);
}
public SelectItem getTrueItem() {
return new SelectItem("True");
}
public SelectItem getFalseItem() {
return new SelectItem("False");
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the nom
*/
public String getNom() {
return nom;
}
/**
* @param nom the nom to set
*/
public void setNom(String nom) {
this.nom = nom;
}
/**
* @return the listePolluant
*/
public Set<Polluant> getListePolluant() {
return listePolluant;
}
/**
* @param listePolluant the listePolluant to set
*/
public void setListePolluant(Set<Polluant> listePolluant) {
this.listePolluant = listePolluant;
}
/**
* @return the createur
*/
public Utilisateur getCreateur() {
return createur;
}
/**
* @param createur the createur to set
*/
public void setCreateur(Utilisateur createur) {
this.createur = createur;
}
/**
* @return the idcreateur
*/
public int getIdcreateur() {
return idcreateur;
}
/**
* @param idcreateur the idcreateur to set
*/
public void setIdcreateur(int idcreateur) {
this.idcreateur = idcreateur;
}
/**
* @return the enable
*/
public boolean isEnable() {
return enable;
}
/**
* @param enable the enable to set
*/
public void setEnable(boolean enable) {
this.enable = enable;
}
/**
* @return the c
*/
public CumulPolluant getC() {
return c;
}
/**
* @param c the c to set
*/
public void setC(CumulPolluant c) {
this.c = c;
}
/**
* @return the manyListboxValues
*/
public int[] getManyListboxValues() {
return manyListboxValues;
}
/**
* @param manyListboxValues the manyListboxValues to set
*/
public void setManyListboxValues(int[] manyListboxValues) {
this.manyListboxValues = manyListboxValues;
}
/**
* @return the manyListBoxItemsRech
*/
public SelectItem[] getManyListBoxItemsRech() {
return manyListBoxItemsRech;
}
/**
* @param manyListBoxItemsRech the manyListBoxItemsRech to set
*/
public void setManyListBoxItemsRech(SelectItem[] manyListBoxItemsRech) {
this.manyListBoxItemsRech = manyListBoxItemsRech;
}
/**
* @return the manyListBoxValuesRech
*/
public int[] getManyListBoxValuesRech() {
return manyListBoxValuesRech;
}
/**
* @param manyListBoxValuesRech the manyListBoxValuesRech to set
*/
public void setManyListBoxValuesRech(int[] manyListBoxValuesRech) {
this.manyListBoxValuesRech = manyListBoxValuesRech;
}
/**
* @return the enableModif
*/
public boolean isEnableModif() {
return enableModif;
}
/**
* @param enableModif the enableModif to set
*/
public void setEnableModif(boolean enableModif) {
this.enableModif = enableModif;
}
/**
* @return the idSelectionMenuCumul
*/
public int getIdSelectionMenuCumul() {
return idSelectionMenuCumul;
}
/**
* @param idSelectionMenuCumul the idSelectionMenuCumul to set
*/
public void setIdSelectionMenuCumul(int idSelectionMenuCumul) {
this.idSelectionMenuCumul = idSelectionMenuCumul;
}
/**
* @return the manyCheckBoxItemsRech
*/
public SelectItem[] getManyCheckBoxItemsRech() {
return manyCheckBoxItemsRech;
}
/**
* @param manyCheckBoxItemsRech the manyCheckBoxItemsRech to set
*/
public void setManyCheckBoxItemsRech(SelectItem[] manyCheckBoxItemsRech) {
this.manyCheckBoxItemsRech = manyCheckBoxItemsRech;
}
/**
* @return the manyCheckBoxValuesRech
*/
public int[] getManyCheckBoxValuesRech() {
return manyCheckBoxValuesRech;
}
/**
* @param manyCheckBoxValuesRech the manyCheckBoxValuesRech to set
*/
public void setManyCheckBoxValuesRech(int[] manyCheckBoxValuesRech) {
this.manyCheckBoxValuesRech = manyCheckBoxValuesRech;
}
/**
* @return the createurModif
*/
public Utilisateur getCreateurModif() {
return createurModif;
}
/**
* @param createurModif the createurModif to set
*/
public void setCreateurModif(Utilisateur createurModif) {
this.createurModif = createurModif;
}
/**
* @return the libelleModif
*/
public String getLibelleModif() {
return libelleModif;
}
/**
* @param libelleModif the libelleModif to set
*/
public void setLibelleModif(String libelleModif) {
this.libelleModif = libelleModif;
}
/**
* @return the idcreateurModif
*/
public int getIdcreateurModif() {
return idcreateurModif;
}
/**
* @param idcreateurModif the idcreateurModif to set
*/
public void setIdcreateurModif(int idcreateurModif) {
this.idcreateurModif = idcreateurModif;
}
/**
* @return the listeCumulTest
*/
public List<SelectItem> getListeCumulTest() {
return listeCumulTest;
}
/**
* @param listeCumulTest the listeCumulTest to set
*/
public void setListeCumulTest(List<SelectItem> listeCumulTest) {
this.listeCumulTest = listeCumulTest;
setAffListeTaille(this.listeCumulTest.size());
}
/**
* @return the affListeTaille
*/
public int getAffListeTaille() {
return affListeTaille;
}
/**
* @param affListeTaille the affListeTaille to set
*/
public void setAffListeTaille(int affListeTaille) {
this.affListeTaille = affListeTaille;
}
public List<SelectItem> getListePolluantAjout() {
PolluantRemote polluant = null;
try {
Context initialContext = new InitialContext();
polluant = (PolluantRemote) initialContext.lookup("ejb/stateless/Polluant");
} catch (NamingException ex) {
Logger.getLogger(PolluantController.class.getName()).log(Level.SEVERE, null, ex);
}
List<Polluant> retour = polluant.selectAllByValue();
listeCumulDajout = new ArrayList<SelectItem>(retour.size());
for (Polluant tmp : retour) {
listeCumulDajout.add(new SelectItem(tmp.getIdPolluant(), tmp.getNom()));
}
System.out.println("test de passage");
return listeCumulDajout;
}
/**
* @return the uniteCumulSelection
*/
public Unite getUniteCumulSelection() {
return uniteCumulSelection;
}
/**
* @param uniteCumulSelection the uniteCumulSelection to set
*/
public void setUniteCumulSelection(Unite uniteCumulSelection) {
this.uniteCumulSelection = uniteCumulSelection;
}
/**
* @return the listeCumulDajout
*/
public List<SelectItem> getListeCumulDajout() {
if (nbPassage == 0) {
listeCumulDajout = this.getListePolluantAjout();
nbPassage = 1;
}
return listeCumulDajout;
}
/**
* @param listeCumulDajout the listeCumulDajout to set
*/
public void setListeCumulDajout(List<SelectItem> listeCumulDajout) {
this.listeCumulDajout = listeCumulDajout;
}
} |
Partager