Esempio n. 1
0
  private boolean insertAlignementSource(Connection conn, AlignementSource alig, int id_user) {
    Statement stmt;
    boolean status = false;
    try {
      // Get connection from pool
      try {
        stmt = conn.createStatement();
        try {
          stmt = conn.createStatement();

          String query =
              "Insert into alignement_source"
                  + "(source,requete,type_rqt,"
                  + "alignement_format, id_user, description) values('"
                  + alig.getSource()
                  + "','"
                  + alig.getRequete()
                  + "','"
                  + alig.getTypeRequete()
                  + "','"
                  + alig.getAlignement_format()
                  + "','"
                  + id_user
                  + "','"
                  + alig.getDescription()
                  + "');";
          stmt.execute(query);
          status = true;

        } finally {
          stmt.close();
        }
      } finally {
        // conn.close();
      }
    } catch (SQLException sqle) {
      // Log exception
      log.error("Error while insert new Alignement : ", sqle);
    }
    return status;
  }
Esempio n. 2
0
  public void update_alignementSource(HikariDataSource ds, AlignementSource alig, int id) {
    Statement stmt;
    Connection conn;

    try {
      // Get connection from pool
      conn = ds.getConnection();
      try {
        stmt = conn.createStatement();
        try {
          stmt = conn.createStatement();

          String query =
              "update alignement_source set "
                  + "source ='"
                  + alig.getSource()
                  + "', requete ='"
                  + alig.getRequete()
                  + "', type_rqt ='"
                  + alig.getTypeRequete()
                  + "', alignement_format='"
                  + alig.getAlignement_format()
                  + "', description ='"
                  + alig.getDescription()
                  + "' where id ="
                  + id;
          stmt.execute(query);

        } finally {
          stmt.close();
        }
      } finally {
        conn.close();
      }
    } catch (SQLException sqle) {
      // Log exception
      log.error("Error while insert new Alignement : ", sqle);
    }
  }
Esempio n. 3
0
  /**
   * cette fonction permet de récupérer les informations de la table des sources d'alignement
   *
   * @param ds
   * @param id_theso
   * @return
   */
  public ArrayList<AlignementSource> getAlignementSource(HikariDataSource ds, String id_theso) {
    ArrayList<AlignementSource> alignementSources = new ArrayList<>();

    Connection conn;
    Statement stmt;
    ResultSet resultSet;

    try {
      // Get connection from pool
      conn = ds.getConnection();
      try {
        stmt = conn.createStatement();
        try {
          String query =
              "select "
                  + " alignement_source.source, alignement_source.requete,"
                  + " alignement_source.type_rqt, alignement_source.alignement_format,"
                  + " alignement_source.id from alignement_source, thesaurus_alignement_source"
                  + " WHERE thesaurus_alignement_source.id_alignement_source = alignement_source.id"
                  + " AND thesaurus_alignement_source.id_thesaurus = '"
                  + id_theso
                  + "'";
          resultSet = stmt.executeQuery(query);
          while (resultSet.next()) {
            AlignementSource alignementSource = new AlignementSource();
            alignementSource.setSource(resultSet.getString("source"));
            alignementSource.setRequete(resultSet.getString("requete"));
            alignementSource.setTypeRequete(resultSet.getString("type_rqt"));
            alignementSource.setAlignement_format(resultSet.getString("alignement_format"));
            alignementSource.setId(resultSet.getInt("id"));
            alignementSources.add(alignementSource);
          }
          resultSet.close();
        } finally {
          stmt.close();
        }
      } finally {
        conn.close();
      }
    } catch (SQLException sqle) {
      // Log exception
      log.error("Error while getting colection of Type of Alignment : ", sqle);
    }
    return alignementSources;
  }
Esempio n. 4
0
  public boolean injenctdansBDAlignement(
      HikariDataSource ds,
      List<String> listThesos,
      AlignementSource alig,
      int id_user,
      String currentIdTheso) {
    int id_alignement;
    boolean status = false;

    try {
      Connection conn = ds.getConnection();
      conn.setAutoCommit(false);

      if (!insertAlignementSource(conn, alig, id_user)) {
        conn.rollback();
        conn.close();
        return false;
      }
      for (String listTheso : listThesos) {
        id_alignement = getId_Alignement(conn, alig.getSource());
        if (!insertSourceAlignementToTheso(conn, listTheso, id_alignement)) {
          conn.rollback();
          conn.close();
          return false;
        }
      }
      status = true;
      conn.commit();
      if (!conn.isClosed()) {
        conn.close();
      }
    } catch (SQLException ex) {
      Logger.getLogger(AlignmentHelper.class.getName()).log(Level.SEVERE, null, ex);
    }
    return status;
  }
Esempio n. 5
0
  public ArrayList<AlignementSource> getAlignementSourceSAdmin(HikariDataSource ds) {
    ArrayList<AlignementSource> alignementSources = new ArrayList<>();

    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    try {
      // Get connection from pool
      conn = ds.getConnection();
      try {
        stmt = conn.createStatement();
        try {
          String query = "select  * from alignement_source";
          resultSet = stmt.executeQuery(query);
          while (resultSet.next()) {
            AlignementSource alignementSource = new AlignementSource();
            alignementSource.setSource(resultSet.getString("source"));
            alignementSource.setRequete(resultSet.getString("requete"));
            alignementSource.setTypeRequete(resultSet.getString("type_rqt"));
            alignementSource.setAlignement_format(resultSet.getString("alignement_format"));
            alignementSource.setId(resultSet.getInt("id"));
            alignementSource.setDescription((resultSet.getString("description")));
            alignementSources.add(alignementSource);
          }
          resultSet.close();
        } finally {
          stmt.close();
        }
      } finally {
        conn.close();
      }
    } catch (SQLException sqle) {
      // Log exception
      log.error("Error while getting colection of Type of Alignment : ", sqle);
    }
    return alignementSources;
  }