protected static List<String[]> sortDataByCodeCamion(TopiaContext transaction, List<String[]> datas) throws TopiaException { List<String[]> datasTrie = new ArrayList<String[]>(); // Recuperation des camions List<Camion> camions = new ArrayList<Camion>(); for (String[] data : datas) { String camionTopiaId = data[3]; camions.add(SandraDAOHelper.getCamionDAO(transaction).findByTopiaId(camionTopiaId)); } // Trie par code camion Collections.sort(camions, CAMION_CODE_COMPARATOR); // Trie des donnee par camions for (Camion camion : camions) { List<String[]> datasCopy = new ArrayList<String[]>(datas); for (String[] data : datasCopy) { String camionTopiaId = data[3]; if (camionTopiaId.equals(camion.getTopiaId())) { datasTrie.add(data); datas.remove(data); } } } return datasTrie; }
protected static List<String[]> sortDataByCodeCamion(TopiaContext transaction, List<String[]> datas) throws TopiaException { List<String[]> datasTrie = new ArrayList<String[]>(); // Recuperation des camions List<Camion> camions = new ArrayList<Camion>(); for (String[] data : datas) { String camionTopiaId = data[3]; camions.add(SandraDAOHelper.getCamionDAO(transaction).findByTopiaId(camionTopiaId)); } // Trie par code camion Collections.sort(camions, CAMION_CODE_COMPARATOR); // Trie des donnee par camions for (Camion camion : camions) { List<String[]> datasCopy = new ArrayList<String[]>(datas); for (String[] data : datasCopy) { String camionTopiaId = data[3]; if (camionTopiaId.equals(camion.getTopiaId())) { datasTrie.add(data); datas.remove(data); } } } return datasTrie; }
camion = camionDAO.findByTopiaId(topiaIdCamion);
@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); }
@Override @Transaction public Camion setActifCamion(TopiaContext transaction, String topiaId, boolean actif) throws TopiaException { CamionDAO camionDAO = SandraDAOHelper.getCamionDAO(transaction); Camion camion = camionDAO.findByTopiaId(topiaId); camion.setActif(actif); camion = camionDAO.update(camion); return camion; }
camion = camionDAO.findByTopiaId(topiaIdCamion);
@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); }
@Override @Transaction public Camion setActifCamion(TopiaContext transaction, String topiaId, boolean actif) throws TopiaException { CamionDAO camionDAO = SandraDAOHelper.getCamionDAO(transaction); Camion camion = camionDAO.findByTopiaId(topiaId); camion.setActif(actif); camion = camionDAO.update(camion); return camion; }
@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); }
camion2 = dao.findByTopiaId(topiaId);
camion2 = dao.findByTopiaId(topiaId);