public ArrayList<ListaAlquiler> get_alquiler_byclientefecha(String condicion) { Connection cnn = null; CallableStatement cstmt = null; ArrayList<ListaAlquiler> listAlquiler = new ArrayList<ListaAlquiler>(); try { cnn = BD.getConnection(); String sql = "select * from get_alquiler_byclientefecha where " + condicion; cstmt = cnn.prepareCall(sql); ResultSet rs = cstmt.executeQuery(); while (rs.next()) { ListaAlquiler a = new ListaAlquiler(); a.setIdCliente(rs.getInt("int_id")); a.setVar_nombre_cliente(rs.getString("var_nombre_cliente")); a.setVar_apepaterno(rs.getString("var_apepaterno")); a.setVar_apematerno(rs.getString("var_apematerno")); a.setVar_nombre_material(rs.getString("var_nombre_material")); a.setDat_fechinicio(rs.getTimestamp("dat_fechinicio")); a.setDat_fechfin(rs.getTimestamp("dat_fechfin")); a.setInt_cantidad(rs.getInt("int_cantidad")); a.setDec_monto(rs.getDouble("dec_monto")); a.setDat_fechaRegistro(rs.getTimestamp("dat_fechaRegistro")); a.setVar_numero(rs.getString("var_numero")); listAlquiler.add(a); } cstmt.close(); cnn.close(); } catch (SQLException a) { System.out.println("" + a); } return listAlquiler; }
public static ArrayList<Detalle> getAll(int codigo) throws SinBaseDatosException { ArrayList<Detalle> a = null; BD bd = null; try { bd = new BD(); StringBuilder sb = new StringBuilder(); sb.append("select d.idDetalle, d.codigoComic, c.codigo, c.nombre, c.numero from detalle as d") .append(" join comic as c on d.codigoComic=c.codigo ") .append("where d.id_venta=") .append(codigo); ResultSet r = bd.createStatement().executeQuery(sb.toString()); a = new ArrayList<>(); while (r.next()) { int id = r.getInt("idDetalle"); int codigoComic = r.getInt("codigoComic"); int c_codigoComic = r.getInt("codigo"); String c_nombre = r.getString("nombre"); int c_numero = r.getInt("numero"); a.add(new Detalle(id, new Comic(c_codigoComic, c_nombre, c_numero))); } r.close(); } catch (SQLException ex) { Logger.getLogger(DetalleDAL.class.getName()).log(Level.SEVERE, null, ex); } finally { if (bd != null) { bd.close(); } } return a; }
public Pelicula[] getPeliculas() { BD D = new BD(); Pelicula[] T = new Pelicula[D.getCantidad() + 1]; String L; int I = 0; D.leerLinea(); while ((L = D.leerLinea()) != null) { T[I] = new Pelicula(); T[I].setNombre(L); L = D.leerLinea(); T[I].setGenero(L); L = D.leerLinea(); T[I].setPuntaje(L); L = D.leerLinea(); T[I].setReview(L); L = D.leerLinea(); T[I].setTrailer(L); T[I].setNumero(I); D.leerLinea(); I++; } D.cerrarBuffers(); return T; }
@Override public void visit(VariableTable r) throws MVisitorException { // VariableTable : cas de base /* * si feuille : représente un résultat déjà calculé. Il ne faut pas le * prendre en compte dans le coût */ if (r.getRelation() == null && !BD.isATable(r)) { return; // TODO : vérifier que les res inter ont bien un fils nul } /* * Si ce n'est pas une feuille, c'est un soit une table, soit un * résultat intermédiaire à calculer et à envoyer sur un autre site */ // Cas table : on la rapatrie sur le site courant if (BD.isATable(r)) { Table t = BD.getTable(r); String siteT = BD.isHostedOn(t); this.nbtuples = t.tupleCount(); if (siteT.equals(site)) { // super, on est déjà sur le bon site } else { // on calcule le cout de transfert par tuple float coutTransfert = cost(site, siteT); // on a le cout total grace au nb de tuples this.cout = coutTransfert * this.nbtuples; print(coutTransfert); } } // Cas res interm. Le site dest est indiqué par l'attribut site de la // VariableTable else { // on visite d'abord la descendance r.getRelation().maccept(this); String siteD = r.getSite(); if (siteD == null || siteD == "") // Anomalie, on ne fait rien return; if (siteD.equals(site)) { // à priori ne devrait pas arriver mais pourquoi pas // le cout ne change pas } else { // on calcule le cout de transfert par tuple float coutTransfert = cost(siteD, site); // ici le nb de tuples est celui calculé par les visites des // fils si le visiteur n'est pas tombé sur une VariableTable // représentant une table plutôt, on aura un cout faux this.cout = coutTransfert * this.nbtuples; print(coutTransfert); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_salary); bd = new BD(getApplicationContext()); bd.sqlLiteDB = bd.getWritableDatabase(); salaries = bd.getSalaries(); tvSalaries = (TextView) findViewById(R.id.tvSalaries); btnXML = (Button) findViewById(R.id.btnXML); btnXML.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Thread fio = new Thread() { @Override public void run() { descargarXML(); } }; fio.start(); try { fio.join(); } catch (Exception ex) { ex.printStackTrace(); } procesarXML(); } }); btnShowSalaries = (Button) findViewById(R.id.btnShowSalaries); btnShowSalaries.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { salaries = bd.getSalaries(); showSalaries(); } }); btnXmlToFile = (Button) findViewById(R.id.btnSalariesToFile); btnXmlToFile.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { try { fromDBToFile(); } catch (Exception ex) { ex.printStackTrace(); } } }); }
public static void setPeliculas(Pelicula[] T) { BD D = new BD(); D.vaciar(); D.cerrarBuffers(); for (int I = 0; I < T.length; I++) { if (T[I] != null) { agregarPelicula(T[I]); } } }
public static Detalle get(int id) throws SinBaseDatosException { Detalle d = null; BD bd; bd = new BD(); ArrayList<Object[]> a = bd.select("detalle", "idDetalle=" + id, "idDetalle", "id_venta", "codigoComic"); for (Object[] o : a) { d = new Detalle((int) o[0], Comic.get((int) o[2]), Venta.get((int) o[1])); } return d; }
public boolean borrar(final int idDetalle) throws SinBaseDatosException { boolean s = false; BD bd; try { bd = new BD(); s = bd.update("delete from detalle where idDetalle=?", idDetalle); } catch (CodigoRepetidoException ex) { Logger.getLogger(DetalleDAL.class.getName()).log(Level.SEVERE, null, ex); } return s; }
public boolean insertarAlquiler( int idtrabajador, int idCliente, ArrayList<Detalle_Alquiler> lista_detalle, int identificador) { boolean resultado = false; Connection cnn = null; CallableStatement cstmt = null; CallableStatement cstm1 = null; CallableStatement cstm2 = null; int id_alquiler = 0; try { cnn = BD.getConnection(); cnn.setAutoCommit(false); String sql = "call spI_Alquiler (?,?,?,?);"; cstmt = cnn.prepareCall(sql); cstmt.setInt(1, 2); cstmt.setInt(2, idCliente); cstmt.setInt(3, idtrabajador); cstmt.setInt(4, identificador); ResultSet rs = cstmt.executeQuery(); if (rs.next()) { id_alquiler = rs.getInt("int_id"); } for (int i = 0; i < lista_detalle.size(); i++) { String sql1 = "call spI_DetalleAlquiler(?,?,?,?,?,?,?);"; cstm1 = cnn.prepareCall(sql1); cstm1.setInt(1, id_alquiler); cstm1.setInt(2, lista_detalle.get(i).getMaterial_id()); cstm1.setInt(3, lista_detalle.get(i).getInt_cantidad()); cstm1.setDouble(4, lista_detalle.get(i).getDec_monto()); cstm1.setTimestamp(5, lista_detalle.get(i).getDat_fechfin()); cstm1.setTimestamp(6, lista_detalle.get(i).getDat_fechinicio()); cstm1.setInt(7, lista_detalle.get(i).getInt_horas()); cstm1.execute(); } // Registrar Pagos String sql2 = "call spI_Pagos_ByAlquiler(?,?);"; cstm2 = cnn.prepareCall(sql2); cstm2.setInt(1, 1); // es el codigo del usuario cambiar despues cstm2.setInt(2, id_alquiler); cstm2.execute(); cnn.commit(); resultado = true; } catch (SQLException s) { try { cnn.rollback(); } catch (SQLException b) { } System.out.println("aquí es :/ " + s); } finally { try { cstmt.close(); cnn.close(); } catch (SQLException ex) { } } return resultado; }
public static void main(String[] args) { BD bd = new BD(); String lsTable = "pays"; String lsContenu = ""; lsContenu += "<?xml version='1.0' encoding='utf-8'?>\n"; lsContenu += "<!-- " + lsTable + "Document.xml -->\n"; lsContenu += "<" + lsTable + ">\n"; String lsEnfant = lsTable.substring(0, lsTable.length() - 1); try { bd.seConnecter("cours", "root", "alonso"); Connection lcn = bd.getConnexion(); PreparedStatement lpst = lcn.prepareStatement("SELECT * FROM pays"); // paysSelect() ou villesSelect() ResultSet lrs = lpst.executeQuery(); ResultSetMetaData lrsmd = lrs.getMetaData(); int liCols = lrsmd.getColumnCount(); while (lrs.next()) { lsContenu += "\t<" + lsEnfant + " "; for (int i = 1; i <= liCols; i++) { lsContenu += lrsmd.getColumnName(i) + "='" + lrs.getString(i) + "' "; } lsContenu += "/>\n"; } lsContenu += "</" + lsTable + ">"; System.out.println(lsContenu); FileWriter lfwFichier = new FileWriter(lsTable + ".xml"); // pays.csv ou villes.csv BufferedWriter lbwBuffer = new BufferedWriter(lfwFichier); lbwBuffer.write(lsContenu); lbwBuffer.close(); lfwFichier.close(); bd.seDeconnecter(); } catch (Exception e) { System.out.println("Erreor : "); } }
public boolean actualizar(final Integer idVenta, final Integer codigo, final Integer idDetalle) throws SinBaseDatosException { // boolean s = false; try { BD bd; bd = new BD(); s = bd.update( "update detalle " + "set id_venta=?, codigoComic=? " + "where idDetalle=? ", idVenta, codigo, idDetalle); } catch (CodigoRepetidoException ex) { Logger.getLogger(DetalleDAL.class.getName()).log(Level.SEVERE, null, ex); } return s; }
public void run() { if (infosMotCles == null && infosSociete == null && maBD == null) return; String pageCourante = url.substring(infosSociete.get("url").toString().length(), url.length()); try { // Si on a pas vu la page -> On fouille la page if (maBD.estDejaVu(infosSociete.get("url").toString(), pageCourante).equalsIgnoreCase("0")) { logger.log(Level.INFO, "Parsing - {0}", url); Document doc = Jsoup.connect(url).get(); // Si c'est une page 404 on skip if (doc.title().indexOf("404") != -1) return; parser(doc, pageCourante); if (infosSociete.get("url").toString().equalsIgnoreCase(url)) { // On regarde si il y a des page en plus for (String link : getLinks(doc)) { pageCourante = link.substring(infosSociete.get("url").toString().length(), link.length()); if (maBD.estDejaVu(infosSociete.get("url").toString(), pageCourante) .equalsIgnoreCase("0")) { // On lance un nouveau thread pour cette page // System.out.println("!"+pageCourante+" a plusieurs pages"); new Thread(new Parser(infosSociete, infosMotCles, maBD, link, logger)).start(); try { Thread.sleep(3500); // On wait 3.5 sec } catch (Exception e) { } } } } } } catch (Exception ex) { logger.log(Level.WARNING, "Parsing error - {0}", url + " - " + ex.toString()); } finally { return; } }
public Integer guardar(int idVenta, int codigoComic) throws SinBaseDatosException { Integer s = null; BD bd = null; try { bd = new BD(); boolean b = bd.update( "insert into detalle (id_venta, codigoComic) values (?,?)", idVenta, codigoComic); if (b) { s = bd.lastId(); } } catch (CodigoRepetidoException ex) { Logger.getLogger(DetalleDAL.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(DetalleDAL.class.getName()).log(Level.SEVERE, null, ex); } finally { bd.close(); } return s; }
/** * Instanciation du visiteur destiné à calculer le cout d'un arbre de requêtes sur un site * * @param site Le site depuis lequel on execute la requête * @param racine L'arbre de requêtes */ public CostVisitor(String site, Relation racine) { this.cout = 0; this.nbtuples = 0; this.site = site; // initialisation des couts si besoin if (BD.coutsStockage == null || BD.coutsComm == null) for (Engine site1 : BD.sites.values()) { BD.addDefaultCost(site1.getName()); } }
@Override public void visit(Table r) throws MVisitorException { // ne devrait pas arriver mais pour le fun : if (BD.isHostedOn(r) == null) // la table n'est pas hébergée sur un site return; String siteT = BD.isHostedOn(r); this.nbtuples = r.tupleCount(); if (siteT.equals(site)) { // super, on est déjà sur le bon site } else { // on calcule le cout de transfert par tuple float coutTransfert = cost(site, siteT); // on a le cout total grace au nb de tuples this.cout = coutTransfert * this.nbtuples; print(coutTransfert); } }
public static void main(String[] args) { inicializaUsua(); View view = new View(); BuscaRotaMotorista buscRotMot = new BuscaRotaMotorista(bancod, view); BuscaRotaCarona buscRotCar = new BuscaRotaCarona(bancod, view); view.setB1(buscRotCar); view.setB2(buscRotMot); bancod.registerObserver(view); view.routingR(); }
private void fromDBToFile() throws IOException { salaries = bd.getSalaries(); File fsaida = new File(Environment.getExternalStorageDirectory(), "salaries.txt"); if (fsaida.exists()) fsaida.delete(); FileOutputStream fos = new FileOutputStream(fsaida); OutputStreamWriter osw = new OutputStreamWriter(fos); int tamread; char[] buffer = new char[2048]; String cadena; for (Salary s : salaries) { osw.write(s.toString() + "\n"); } osw.close(); }
public List<StatusRecurso> ListarTodos() { try { List<StatusRecurso> listastatus = new LinkedList<>(); PreparedStatement comando = bd.getConexao().prepareStatement("select * from statusrecurso"); ResultSet resultado = comando.executeQuery(); while (resultado.next()) { StatusRecurso status = new StatusRecurso(); status.setCodstatusrecurso(resultado.getInt("codstatus")); status.setNomestatus(resultado.getString("nomestatus")); listastatus.add(status); } return listastatus; } catch (SQLException ex) { Logger.getLogger(StatusRecursoDAO.class.getName()).log(Level.SEVERE, null, ex); return null; } }
public static boolean agregarPelicula(Pelicula T) { boolean toR = false; BD D = null; try { D = new BD(); D.escribir("" + "\r\n"); D.escribir(T.getNombre() + "\r\n"); D.escribir(T.getGenero() + "\r\n"); D.escribir(T.getPuntaje() + "\r\n"); D.escribir(T.getReview() + "\r\n"); D.escribir(T.getTrailer() + "\r\n"); D.cerrarBuffers(); toR = true; } catch (Exception e) { D.cerrarBuffers(); } return toR; }
public String cantproducto(int codigo) { String total = ""; try { Connection con = BD.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery( "select SUM(nTraCantidad) total from transaccion where nVenCodigo=" + codigo); while (rs.next()) { total = rs.getString("total"); } rs.close(); stmt.close(); con.close(); } catch (SQLException error) { System.out.println(); } return total; }
public ArrayList<ListaMovimiento> get_reporte_movimiento(String condicion) { Connection cnn = null; CallableStatement cstmt = null; ArrayList<ListaMovimiento> lista_material = new ArrayList<ListaMovimiento>(); try { cnn = BD.getConnection(); String sql = "select * from get_reporte_movimiento " + condicion; cstmt = cnn.prepareCall(sql); ResultSet rs = cstmt.executeQuery(); int cont = 0; double ingreso = 0.0, egreso = 0.0, total = 0.0; while (rs.next()) { ListaMovimiento lm = new ListaMovimiento(); ingreso = rs.getDouble("dec_ingreso"); egreso = rs.getDouble("dec_egreso"); lm.setDat_fecregistro(rs.getDate("dat_fecregistro")); lm.setTipoComprobante(rs.getString("TipoComprobante")); lm.setInt_tipoOperacion(rs.getInt("int_tipoOperacion")); lm.setVar_numeroComprobante(rs.getString("var_numeroComprobante")); lm.setInt_proveedor(rs.getInt("int_proveedor")); lm.setDec_cantidad(rs.getDouble("dec_cantidad")); lm.setVar_concepto(rs.getString("var_concepto")); lm.setUsuario_id(rs.getInt("usuario_id")); lm.setTipo(rs.getInt("tipo")); lm.setDec_ingreso(new BigDecimal(String.valueOf(ingreso))); lm.setDec_egreso(new BigDecimal(String.valueOf(egreso))); if (cont == 0) { total = ingreso + egreso; } else { total = ingreso == 0.0 ? (egreso + total) : (ingreso + total); } lm.setDec_saldo(new BigDecimal(String.valueOf(total))); lista_material.add(lm); cont++; } cstmt.close(); cnn.close(); } catch (SQLException a) { System.out.println("" + a); } return lista_material; }
public double obtenerMonto() { double monto = 0.0; try { Connection con = BD.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery( "select SUM(nCPagoRecibido) MontoEsperado from cronogramapago where nVenCodigo=" + getCodigoVenta()); while (rs.next()) { monto = rs.getDouble(1); } rs.close(); stmt.close(); con.close(); } catch (SQLException error) { System.out.println(error); } return monto; }
public boolean insertarMovimiento(Movimiento m) { boolean resultado = true; Connection cnn = null; CallableStatement cstmt = null; try { cnn = BD.getConnection(); cnn.setAutoCommit(false); String sql = "call spI_Movimiento(?,?,?,?,?,?,?,?,?);"; cstmt = cnn.prepareCall(sql); cstmt.setInt(1, m.getUsuario_id()); cstmt.setString(2, m.getVar_concepto()); cstmt.setDouble(3, m.getDec_monto()); cstmt.setInt(4, m.getInt_tipoOperacion()); cstmt.setTimestamp(5, m.getDat_fecregistro()); cstmt.setInt(6, m.getInt_tipoComprobante()); cstmt.setString(7, m.getVar_numeroComprobante()); cstmt.setDouble(8, m.getDec_cantidad()); cstmt.setInt(9, m.getInt_proveedor()); cstmt.execute(); cnn.commit(); } catch (SQLException a) { try { cnn.rollback(); } catch (SQLException b) { System.out.println("" + b.toString()); } finally { resultado = false; } System.out.println("error al registrar movimiento " + a.toString()); } finally { try { cstmt.close(); cnn.close(); } catch (SQLException ex) { System.out.println("" + ex.getMessage()); } } return resultado; }
private void procesarXML() { try { Boolean xaIncluido = false; Salary salary = null; InputStream is = new FileInputStream(arquivo); XmlPullParser parser = Xml.newPullParser(); parser.setInput(is, "UTF-8"); while (parser.nextTag() != XmlPullParser.END_DOCUMENT) { if (parser.nextTag() == XmlPullParser.START_TAG) { if (parser.getName().equals("salary")) { salary = new Salary(); parser.nextTag(); salary.setMonth(parser.nextText()); parser.nextTag(); salary.setTotalSalary(Float.parseFloat(parser.nextText())); parser.nextTag(); salary.setTotalSalary(salary.getTotalSalary() + Float.parseFloat(parser.nextText())); parser.nextTag(); salary.setTotalSalary(salary.getTotalSalary() + Float.parseFloat(parser.nextText())); } } if (parser.nextTag() == XmlPullParser.END_TAG) { if (parser.getName().equals("salary")) { for (Salary s : salaries) { if (salary.getMonth().equals(s.getMonth())) { xaIncluido = true; } } if (!xaIncluido) bd.insertSalary(salary); } } parser.next(); } is.close(); } catch (Exception e) { e.printStackTrace(); } }
private void parser(Document doc, String pageCourante) throws Exception { String pos = ""; // maBD.insertPage(infosSociete.get("url").toString(), pageCourante); //On insère la page // courante for (Map unMot : infosMotCles) { pos = "autre"; // Inspection de l'entete String keywords = doc.getElementsByAttributeValue("name", "keywords").attr("content"); String description = doc.getElementsByAttributeValue("name", "description").attr("content"); if (keywords.indexOf(unMot.get("libelleMotCle").toString().toLowerCase().trim()) != -1) { pos = "keywords"; maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, keywords); // ************* TROUVE KEYWORD *************** // System.out.println("keyword "+description); } if (description.indexOf(unMot.get("libelleMotCle").toString().toLowerCase().trim()) != -1) { pos = "description"; maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, description); // ************* TROUVE DESCRIPTION *************** // System.out.println("description "+description); } Elements all = doc.getElementsContainingOwnText( unMot.get("libelleMotCle").toString().toLowerCase().trim()); if (!all.isEmpty()) { for (Element elt : all) { if (elt.tagName().equalsIgnoreCase("h1")) { pos = "h1"; // pos here indicates where the element appears. e.g., here the idMot appears // between tag <h1></h1> String ownText = elt.ownText(); // The text where the motcle appears // maBD.insert(infosSociete.get("url").toString(), pageCourante, // unMot.get("idMotCle").toString(),pos); maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, ownText); // ************* TROUVE H1 *************** // System.out.println("<h1> "+elt.ownText()); } else if (elt.tagName().equalsIgnoreCase("h2")) { pos = "h2"; String ownText = elt.ownText(); // The text where the motcle appears maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, ownText); // ************* TROUVE H2 *************** // System.out.println("<h2> "+elt.ownText()); } else if (elt.tagName().equalsIgnoreCase("h3")) { pos = "h3"; String ownText = elt.ownText(); // The text where the motcle appears maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, ownText); // ************* TROUVE H3 *************** // System.out.println("<h3> "+elt.ownText()); } else if (elt.tagName().equalsIgnoreCase("h4")) { pos = "h4"; String ownText = elt.ownText(); // The text where the motcle appears maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, ownText); // ************* TROUVE H4 *************** // System.out.println("<h4> "+elt.ownText()); } else if (elt.tagName().equalsIgnoreCase("li")) { pos = "li"; String ownText = elt.ownText(); // The text where the motcle appears maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, ownText); // ************* TROUVE MENU *************** // System.out.println("<li> "+elt.ownText()); } else if (elt.tagName().equalsIgnoreCase("div")) { pos = "div"; String ownText = elt.ownText(); // The text where the motcle appears maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, ownText); // ************* TROUVE DIV *************** // System.out.println("<div> "+elt.ownText()); } else if (elt.tagName().equalsIgnoreCase("span")) { pos = "span"; String ownText = elt.ownText(); // The text where the motcle appears maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, ownText); // ************* TROUVE SPAN *************** // System.out.println("<span> "+elt.ownText()); } else if (elt.tagName().equalsIgnoreCase("p")) { pos = "p"; String ownText = elt.ownText(); // The text where the motcle appears maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, ownText); // ************* TROUVE PARAGRAPHE *************** // System.out.println("<p> "+elt.ownText()); } else if (elt.tagName().equalsIgnoreCase("a")) { pos = "a"; String ownText = elt.ownText(); // The text where the motcle appears maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, ownText); // ************* TROUVE LIEN *************** // System.out.println("<a> "+elt.ownText()); } else { pos = "autre"; String ownText = elt.ownText(); // The text where the motcle appears maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, ownText); // ************* TROUVE AUTRE *************** // System.out.println("autre "+elt.tagName()+" - "+elt.ownText()); } } } // On check les images Elements img = doc.getElementsByTag("img"); for (Element elt : img) { if (elt.attr("alt").indexOf(unMot.get("libelleMotCle").toString().toLowerCase().trim()) != -1) { pos = "img"; String ownText = elt.ownText(); // The text where the motcle appears maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, ownText); // ************* TROUVE IMAGE *************** // System.out.println("image "+elt.attr("alt").toString()); } } // On check les titles liens Elements links = doc.getElementsByTag("a"); for (Element elt : links) { if (elt.attr("title").indexOf(unMot.get("libelleMotCle").toString().toLowerCase().trim()) != -1) { pos = "a"; String ownText = elt.ownText(); // The text where the motcle appears maBD.insert( infosSociete.get("url").toString(), pageCourante, unMot.get("idMotCle").toString(), pos, ownText); // ************* TROUVE LIEN TITLE *************** // System.out.println("a "+elt.attr("title").toString()); } } } // Fin boucle mot clés }
public static void inicializaUsua() { bancod.addRota(new Motorista("bosque_eucaliptos", "olivo_gomes", 1)); bancod.addRota(new Motorista("eugenio_melo", "bosque_eucaliptos", 4)); bancod.addRota(new Carona("ademar_de_barros", "olivo_gomes")); }