/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Metier; import Physique.ArmoireServiceJDBC; import Physique.EtagereServiceJDBC; import Physique.StructureBibliothequeServiceJDBC; import java.util.ArrayList; public class StructureBibliothequeServiceImpl implements StructureBibliothequeService { StructureBibliothequeServiceJDBC sbs = Physique.PhysiqueFactory.getStructureService(); ArmoireServiceJDBC as = Physique.PhysiqueFactory.getArmoireService(); EtagereServiceJDBC es = Physique.PhysiqueFactory.getEtagereService(); protected StructureBibliothequeServiceImpl() { } @Override public void add(StructureBibliotheque structure) { if (structure != null) { sbs.add(structure); } } @Override public void update(StructureBibliotheque structure) { if (structure != null) { sbs.update(structure); } } @Override public void remove(StructureBibliotheque structure) { if (structure != null) { ArrayList<Armoire> armoires = structure.getArmoires(); if (armoires != null) { for (int i = 0; i < armoires.size(); i++) { Armoire armoire = armoires.get(i); ArrayList<Etagere> etageres = armoire.getEtageres(); for (int y = 0; y < etageres.size(); y++) { es.remove(etageres.get(y)); } as.remove(armoire); } } sbs.remove(structure); } } @Override public ArrayList<StructureBibliotheque> getAll() { return sbs.getAll(); } @Override public StructureBibliotheque getById(int id) { StructureBibliotheque sb = null; if (id != 0) { sb = sbs.getById(id); } return sb; } @Override public StructureBibliotheque getByNom(String nom) { if (!nom.equals("") && nom != null) { return sbs.getByNom(nom); } return null; } }