Search in sources :

Example 11 with AlignementSource

use of mom.trd.opentheso.core.alignment.AlignementSource in project opentheso by miledrousset.

the class EditAlignementSourceBean method insertIntoAlignementSource.

public void insertIntoAlignementSource(String currentIdTheso, List<String> selectedThesaurus, int id_user) {
    AlignementSource alignementSource = new AlignementSource();
    alignementSource.setAlignement_format(alignement_format);
    alignementSource.setDescription(description);
    alignementSource.setId(id);
    alignementSource.setRequete(requete);
    alignementSource.setSource(source);
    alignementSource.setTypeRequete(type_rqt);
    AlignmentHelper alignementHelper = new AlignmentHelper();
    alignementHelper.injenctdansBDAlignement(connect.getPoolConnexion(), selectedThesaurus, alignementSource, id_user, currentIdTheso);
    setListeAlignementSources(currentIdTheso);
    cancel();
}
Also used : AlignmentHelper(mom.trd.opentheso.bdd.helper.AlignmentHelper) AlignementSource(mom.trd.opentheso.core.alignment.AlignementSource)

Example 12 with AlignementSource

use of mom.trd.opentheso.core.alignment.AlignementSource in project opentheso by miledrousset.

the class GpsBeans method onRowSelect.

public void onRowSelect(SelectEvent event) {
    AlignmentHelper alignmentHelper = new AlignmentHelper();
    GpsHelper gpsHelper = new GpsHelper();
    GpsPreferences gpsPreferences;
    gpsPreferences = gpsHelper.getGpsPreferences(connect.getPoolConnexion(), id_theso, id_user1, ((AlignementSource) event.getObject()).getId());
    integrerTraduction = gpsPreferences.isGps_integrertraduction();
    alignementAutomatique = gpsPreferences.isGps_alignementautomatique();
    remplacerTraduction = gpsPreferences.isGps_reemplacertraduction();
    // alignement_source = "" + gpsPreferences.getId_alignement_source();
    for (AlignementSource alignementSource : alignementSources) {
        if (((AlignementSource) event.getObject()).getId() == alignementSource.getId()) {
            alignement_source = alignementSource;
        }
    }
    selectedAlignement = alignement_source.getRequete();
}
Also used : GpsHelper(mom.trd.opentheso.bdd.helper.GpsHelper) GpsPreferences(mom.trd.opentheso.core.alignment.GpsPreferences) AlignmentHelper(mom.trd.opentheso.bdd.helper.AlignmentHelper) AlignementSource(mom.trd.opentheso.core.alignment.AlignementSource)

Example 13 with AlignementSource

use of mom.trd.opentheso.core.alignment.AlignementSource in project opentheso by miledrousset.

the class AlignmentHelper method update_alignementSource.

/**
 * Permet de faire un update d'un alignement_source
 *
 * @param ds
 * @param alignements
 * @param id
 */
public void update_alignementSource(HikariDataSource ds, List<AlignementSource> alignements, int id) {
    Statement stmt;
    Connection conn;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                for (AlignementSource alignement : alignements) {
                    stmt = conn.createStatement();
                    String query = "update alignement_source set " + "source ='" + alignement.getSource() + "', requete ='" + alignement.getRequete() + "', type_rqt ='" + alignement.getTypeRequete() + "', alignement_format='" + alignement.getAlignement_format() + "', description ='" + alignement.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);
    }
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) AlignementSource(mom.trd.opentheso.core.alignment.AlignementSource)

Example 14 with AlignementSource

use of mom.trd.opentheso.core.alignment.AlignementSource in project opentheso by miledrousset.

the class AlignmentHelper method getAlignementSource.

/**
 * 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 + "'" + " AND gps = false";
                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;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) AlignementSource(mom.trd.opentheso.core.alignment.AlignementSource)

Example 15 with AlignementSource

use of mom.trd.opentheso.core.alignment.AlignementSource in project opentheso by miledrousset.

the class GpsHelper method getAlignementSource.

public ArrayList<AlignementSource> getAlignementSource(HikariDataSource ds) {
    ArrayList<AlignementSource> aligSource = null;
    AlignementSource alig = null;
    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" + " where gps = true";
                resultSet = stmt.executeQuery(query);
                aligSource = new ArrayList<>();
                while (resultSet.next()) {
                    alig = new AlignementSource();
                    alig.setSource(resultSet.getString("source"));
                    alig.setRequete(resultSet.getString("requete"));
                    alig.setTypeRequete(resultSet.getString("type_rqt"));
                    alig.setAlignement_format(resultSet.getString("alignement_format"));
                    alig.setId(resultSet.getInt("id"));
                    alig.setDescription(resultSet.getString("description"));
                    aligSource.add(alig);
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while Add coordonnes : ", sqle);
    }
    return aligSource;
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) AlignementSource(mom.trd.opentheso.core.alignment.AlignementSource)

Aggregations

AlignementSource (mom.trd.opentheso.core.alignment.AlignementSource)15 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)6 Connection (java.sql.Connection)5 SQLException (java.sql.SQLException)5 Statement (java.sql.Statement)5 ResultSet (java.sql.ResultSet)4 GpsHelper (mom.trd.opentheso.bdd.helper.GpsHelper)4 ArrayList (java.util.ArrayList)3 GpsPreferences (mom.trd.opentheso.core.alignment.GpsPreferences)2 FacesMessage (javax.faces.application.FacesMessage)1 AlignmentQuery (mom.trd.opentheso.core.alignment.AlignmentQuery)1 GpsQuery (mom.trd.opentheso.core.alignment.GpsQuery)1