Chauffeur chauffeur2; ChauffeurDAO dao = SandraDAOHelper.getChauffeurDAO(transaction); String code = chauffeur.getCode(); String topiaId = chauffeur.getTopiaId(); Societe societe = getSociete(transaction, chauffeur.getSociete().getTopiaId()); chauffeur.setSociete(societe); if (topiaId == null || "".equals(topiaId)) { log.info("has created usine " + chauffeur2.getTopiaId()); if (!chauffeur2.getCode().equals(code) && dao.findByCode(code) != null) { throw new LogicException("error.service.chauffeur.already.exists"); log.info("update chauffeur " + chauffeur2.getTopiaId()); chauffeur2.setCode(code); chauffeur2.setNom(chauffeur.getNom()); chauffeur2.setPrenom(chauffeur.getPrenom()); chauffeur2.setTrigramme(chauffeur.getTrigramme()); chauffeur2.setSociete(chauffeur.getSociete());
@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 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); }
public void inject(ManagerInjector manager, IbuChauffeur ibuChauffeur) throws TopiaException { ChauffeurDAO chauffeurDAO = SandraDAOHelper.getChauffeurDAO(manager.getTransaction()); // Recherche chauffeur = chauffeurDAO.findByNaturalId(ibuChauffeur.getCode()); // Création if (chauffeur == null) { chauffeur = chauffeurDAO.createByNaturalId(ibuChauffeur.getCode()); } // Mise à jour chauffeur.setNom(ibuChauffeur.getNom()); chauffeur.setPrenom(ibuChauffeur.getPrenom()); chauffeur.setTrigramme(ibuChauffeur.getTrigramme()); // Chauffeur par défaut addDefautChauffeur(manager, ibuChauffeur.getCamion1()); addDefautChauffeur(manager, ibuChauffeur.getCamion2()); addDefautChauffeur(manager, ibuChauffeur.getCamion3()); addDefautChauffeur(manager, ibuChauffeur.getCamion4()); addDefautChauffeur(manager, ibuChauffeur.getCamion5()); addDefautChauffeur(manager, ibuChauffeur.getCamion6()); }
@Override public void removeDefautChauffeurs(Chauffeur defautChauffeurs) { fireOnPreWrite(PROPERTY_DEFAUT_CHAUFFEURS, defautChauffeurs, null); if (this.defautChauffeurs == null || !this.defautChauffeurs.remove(defautChauffeurs)) { throw new IllegalArgumentException("List does not contain given element"); } defautChauffeurs.getCamions().remove(this); fireOnPostWrite(PROPERTY_DEFAUT_CHAUFFEURS, this.defautChauffeurs.size() + 1, defautChauffeurs, null); }
@Override @Transaction public void deleteCamionsToChauffeur(TopiaContext transaction, String topiaIdChauffeur, String... topiaIdCamion) throws TopiaException, LogicException { if (log.isDebugEnabled()) { log.debug("deleteCamionsToChauffeur chauffeur:" + topiaIdChauffeur); } ChauffeurDAO dao = SandraDAOHelper.getChauffeurDAO(transaction); CamionDAO cdao = SandraDAOHelper.getCamionDAO(transaction); Chauffeur chauffeur = dao.findByTopiaId(topiaIdChauffeur); for (String s : topiaIdCamion) { Camion camion = cdao.findByTopiaId(s); if (log.isInfoEnabled()) { log.info("delete camion " + camion.getTopiaId()); } chauffeur.removeCamions(camion); } dao.update(chauffeur); }
"from camion main, camions_defautchauffeurs secondary " + "where main.topiaid=secondary.camions" + " and secondary.defautChauffeurs='" + entity.getTopiaId() + "'") .addEntity("main", com.cybelia.sandra.SandraDAOHelper.getImplementationClass(Camion.class)).list();
Chauffeur chauffeur = chauffeurDAO.findByCode(suiviTour.getReel().getCode()); suiviTour.setReel(chauffeur);
public void inject(ManagerInjector manager, IbuChauffeur ibuChauffeur) throws TopiaException { ChauffeurDAO chauffeurDAO = SandraDAOHelper.getChauffeurDAO(manager.getTransaction()); // Recherche chauffeur = chauffeurDAO.findByNaturalId(ibuChauffeur.getCode()); // Création if (chauffeur == null) { chauffeur = chauffeurDAO.createByNaturalId(ibuChauffeur.getCode()); } // Mise à jour chauffeur.setNom(ibuChauffeur.getNom()); chauffeur.setPrenom(ibuChauffeur.getPrenom()); chauffeur.setTrigramme(ibuChauffeur.getTrigramme()); // Chauffeur par défaut addDefautChauffeur(manager, ibuChauffeur.getCamion1()); addDefautChauffeur(manager, ibuChauffeur.getCamion2()); addDefautChauffeur(manager, ibuChauffeur.getCamion3()); addDefautChauffeur(manager, ibuChauffeur.getCamion4()); addDefautChauffeur(manager, ibuChauffeur.getCamion5()); addDefautChauffeur(manager, ibuChauffeur.getCamion6()); }
@Override @Transaction public Chauffeur getChauffeur(TopiaContext transaction, String topiaId) throws TopiaException, LogicException { if (log.isDebugEnabled()) { log.debug("getChauffeur " + topiaId); } String query = "SELECT chauffeur FROM " + Chauffeur.class.getName() + " chauffeur WHERE chauffeur.topiaId = :topiaId"; Chauffeur chauffeur = ProfilManager.findUnique("error.service.chauffeur.unfound", transaction, Chauffeur.class, query, "topiaId", topiaId); //fixme lazy camions pb... chauffeur.getCamions().size(); return chauffeur; }
@Override @Transaction public void deleteCamionsToChauffeur(TopiaContext transaction, String topiaIdChauffeur, String... topiaIdCamion) throws TopiaException, LogicException { if (log.isDebugEnabled()) { log.debug("deleteCamionsToChauffeur chauffeur:" + topiaIdChauffeur); } ChauffeurDAO dao = SandraDAOHelper.getChauffeurDAO(transaction); CamionDAO cdao = SandraDAOHelper.getCamionDAO(transaction); Chauffeur chauffeur = dao.findByTopiaId(topiaIdChauffeur); for (String s : topiaIdCamion) { Camion camion = cdao.findByTopiaId(s); if (log.isInfoEnabled()) { log.info("delete camion " + camion.getTopiaId()); } chauffeur.removeCamions(camion); } dao.update(chauffeur); }
Chauffeur chauffeur = chauffeurDAO.findByCode(suiviTour.getReel().getCode()); suiviTour.setReel(chauffeur);
Chauffeur chauffeur2; ChauffeurDAO dao = SandraDAOHelper.getChauffeurDAO(transaction); String code = chauffeur.getCode(); String topiaId = chauffeur.getTopiaId(); if (topiaId == null || "".equals(topiaId)) { log.info("has created usine " + chauffeur2.getTopiaId()); if (!chauffeur2.getCode().equals(code) && dao.findByCode(code) != null) { throw new LogicException("error.service.chauffeur.already.exists"); log.info("update chauffeur " + chauffeur2.getTopiaId()); chauffeur2.setCode(code); chauffeur2.setNom(chauffeur.getNom()); chauffeur2.setPrenom(chauffeur.getPrenom()); chauffeur2.setTrigramme(chauffeur.getTrigramme());
@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 Chauffeur getChauffeur(TopiaContext transaction, String topiaId) throws TopiaException, LogicException { if (log.isDebugEnabled()) { log.debug("getChauffeur " + topiaId); } String query = "SELECT chauffeur FROM " + Chauffeur.class.getName() + " chauffeur WHERE chauffeur.topiaId = :topiaId"; Chauffeur chauffeur = ProfilManager.findUnique("error.service.chauffeur.unfound", transaction, Chauffeur.class, query, "topiaId", topiaId); //fixme lazy camions pb... chauffeur.getCamions().size(); return chauffeur; }
@Override public void delete(E entity) throws TopiaException { { List<Tour> list = getContext() .getDAO(Tour.class) .findAllByProperties(Tour.PROPERTY_CAMION, entity); for (Tour item : list) { // sletellier : Set null only if target is concerned by deletion if (entity.equals(item.getCamion())) { item.setCamion(null); } } } { List<Chauffeur> list = getContext().getHibernate().createSQLQuery( "SELECT main.topiaid " + "from chauffeur main, camions_defautchauffeurs secondary " + "where main.topiaid=secondary.defautChauffeurs" + " and secondary.camions='" + entity.getTopiaId() + "'") .addEntity("main", com.cybelia.sandra.SandraDAOHelper.getImplementationClass(Chauffeur.class)).list(); for (Chauffeur item : list) { item.removeCamions(entity); } } super.delete(entity); }
@Override public void clearDefautChauffeurs() { if (this.defautChauffeurs == null) { return; } for (Chauffeur item : this.defautChauffeurs) { item.getCamions().remove(this); } Collection<Chauffeur> oldValue = new ArrayList<Chauffeur>(this.defautChauffeurs); fireOnPreWrite(PROPERTY_DEFAUT_CHAUFFEURS, oldValue, this.defautChauffeurs); this.defautChauffeurs.clear(); fireOnPostWrite(PROPERTY_DEFAUT_CHAUFFEURS, oldValue, this.defautChauffeurs); }