@Override public void addDefautChauffeurs(Chauffeur defautChauffeurs) { fireOnPreWrite(PROPERTY_DEFAUT_CHAUFFEURS, null, defautChauffeurs); if (this.defautChauffeurs == null) { this.defautChauffeurs = new ArrayList<Chauffeur>(); } if (defautChauffeurs.getCamions() == null) { defautChauffeurs.setCamions(new ArrayList<Camion>()); } defautChauffeurs.getCamions().add(this); this.defautChauffeurs.add(defautChauffeurs); fireOnPostWrite(PROPERTY_DEFAUT_CHAUFFEURS, this.defautChauffeurs.size(), null, defautChauffeurs); }
@Override @Transaction public void addCamionsToChauffeur(TopiaContext transaction, String topiaIdChauffeur, String... topiaIdCamion) throws TopiaException, LogicException { if (log.isDebugEnabled()) { log.debug("addCamionsToChauffeur chauffeur:" + topiaIdChauffeur); } ChauffeurDAO dao = SandraDAOHelper.getChauffeurDAO(transaction); CamionDAO cdao = SandraDAOHelper.getCamionDAO(transaction); Chauffeur chauffeur = dao.findByTopiaId(topiaIdChauffeur); Collection<Camion> camions = new java.util.ArrayList<Camion>(chauffeur.getCamions()); for (String s : topiaIdCamion) { Camion camion = cdao.findByTopiaId(s); if (log.isDebugEnabled()) { log.debug("add camion " + camion.getTopiaId()); } camions.add(camion); } //TODO why we have to do this, otherwise added are duplicated ? chauffeur.clearCamions(); chauffeur.setCamions(camions); dao.update(chauffeur); }
@Override @Transaction public void addCamionsToChauffeur(TopiaContext transaction, String topiaIdChauffeur, String... topiaIdCamion) throws TopiaException, LogicException { if (log.isDebugEnabled()) { log.debug("addCamionsToChauffeur chauffeur:" + topiaIdChauffeur); } ChauffeurDAO dao = SandraDAOHelper.getChauffeurDAO(transaction); CamionDAO cdao = SandraDAOHelper.getCamionDAO(transaction); Chauffeur chauffeur = dao.findByTopiaId(topiaIdChauffeur); Collection<Camion> camions = new java.util.ArrayList<Camion>(chauffeur.getCamions()); for (String s : topiaIdCamion) { Camion camion = cdao.findByTopiaId(s); if (log.isDebugEnabled()) { log.debug("add camion " + camion.getTopiaId()); } camions.add(camion); } //TODO why we have to do this, otherwise added are duplicated ? chauffeur.clearCamions(); chauffeur.setCamions(camions); dao.update(chauffeur); }