Search in sources :

Example 16 with Thesaurus

use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.

the class ThesaurusHelper method getNodeThesaurus.

/**
 * Permet de retourner un thésaurus par identifiant sous forme de
 * NodeThesaurus avec les traductions
 *
 * @param ds le pool de connexion
 * @param idThesaurus
 * @return Objet Class Thesaurus
 */
public NodeThesaurus getNodeThesaurus(HikariDataSource ds, String idThesaurus) {
    ArrayList<Languages_iso639> listLangTheso = getLanguagesOfThesaurus(ds, idThesaurus);
    NodeThesaurus nodeThesaurus = new NodeThesaurus();
    ArrayList<Thesaurus> thesaurusTraductionsList = new ArrayList<>();
    for (int i = 0; i < listLangTheso.size(); i++) {
        Thesaurus thesaurus = getThisThesaurus(ds, idThesaurus, listLangTheso.get(i).getId_iso639_1());
        if (thesaurus != null) {
            thesaurusTraductionsList.add(thesaurus);
        }
    }
    nodeThesaurus.setIdThesaurus(idThesaurus);
    nodeThesaurus.setListThesaurusTraduction(thesaurusTraductionsList);
    return nodeThesaurus;
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) ArrayList(java.util.ArrayList) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) Languages_iso639(mom.trd.opentheso.bdd.datas.Languages_iso639)

Example 17 with Thesaurus

use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.

the class ThesaurusHelper method getThisThesaurus.

/**
 * Permet de retourner un thésaurus par identifiant et par langue / ou null
 * si rien cette fonction ne retourne pas les détails et les traductions
 *
 * @param ds le pool de connexion
 * @param idThesaurus
 * @param idLang
 * @return Objet Class Thesaurus
 */
public Thesaurus getThisThesaurus(HikariDataSource ds, String idThesaurus, String idLang) {
    idLang = idLang.trim();
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    Thesaurus thesaurus = null;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select * from thesaurus_label where id_thesaurus = '" + idThesaurus + "' and lang = '" + idLang + "'";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                if (resultSet.next()) {
                    if (resultSet.getString("lang") != null) {
                        thesaurus = new Thesaurus();
                        thesaurus.setId_thesaurus(idThesaurus);
                        thesaurus.setContributor(resultSet.getString("contributor"));
                        thesaurus.setCoverage(resultSet.getString("coverage"));
                        thesaurus.setCreator(resultSet.getString("creator"));
                        thesaurus.setCreated(resultSet.getDate("created"));
                        thesaurus.setModified(resultSet.getDate("modified"));
                        thesaurus.setDescription(resultSet.getString("description"));
                        thesaurus.setFormat(resultSet.getString("format"));
                        thesaurus.setLanguage(resultSet.getString("lang"));
                        thesaurus.setPublisher(resultSet.getString("publisher"));
                        thesaurus.setRelation(resultSet.getString("relation"));
                        thesaurus.setRights(resultSet.getString("rights"));
                        thesaurus.setSource(resultSet.getString("source"));
                        thesaurus.setSubject(resultSet.getString("subject"));
                        thesaurus.setTitle(resultSet.getString("title"));
                        thesaurus.setType(resultSet.getString("type"));
                    }
                }
                resultSet.close();
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting This Thesaurus : " + idThesaurus, sqle);
    }
    return thesaurus;
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet)

Example 18 with Thesaurus

use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.

the class WriteFileSKOS method writeThesaurus.

public boolean writeThesaurus(NodeThesaurus nodeThesaurus) {
    // Ecriture de la balise de declaration du thesaurus
    String xml = "    <skos:ConceptScheme rdf:about=\"" + URI + "?idt=" + nodeThesaurus.getIdThesaurus() + "\">\n";
    // balises DublinCore pour le libellé du thésaurus
    for (Thesaurus listThesaurusTraduction : nodeThesaurus.getListThesaurusTraduction()) {
        if (!listThesaurusTraduction.getTitle().trim().isEmpty()) {
            xml += "        <skos:prefLabel xml:lang=";
            xml += "\"" + listThesaurusTraduction.getLanguage() + "\">";
            xml += listThesaurusTraduction.getTitle();
            xml += "</skos:prefLabel>";
            xml += "\n";
        }
    }
    skosBuff.append(xml);
    return true;
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) NodeThesaurus(mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus)

Example 19 with Thesaurus

use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.

the class AccessThesaurusBean method addVisibility.

/**
 * fonction addVisbility
 * #JM
 * fonction pour update ou insert d'une valeur dans visibility dans la table thesaurus via la classe accessThesaurusHelper
 */
public void addVisibility() {
    boolean visible = this.accessThesaurus.isVisibility();
    String id = theso.getEditTheso().getId_thesaurus();
    AccessThesaurusHelper ath = new AccessThesaurusHelper();
    int ret = ath.insertVisibility(this.connect.getPoolConnexion(), visible, id);
    System.out.println("valeur retour insertVibility =" + ret);
    theso.setEditTheso(new Thesaurus());
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) AccessThesaurusHelper(mom.trd.opentheso.bdd.helper.AccessThesaurusHelper)

Aggregations

Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)19 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)10 NodeThesaurus (mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus)6 Connection (java.sql.Connection)4 SQLException (java.sql.SQLException)3 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)2 SKOSResource (mom.trd.opentheso.skosapi.SKOSResource)2 Document (com.itextpdf.text.Document)1 Paragraph (com.itextpdf.text.Paragraph)1 PdfWriter (com.itextpdf.text.pdf.PdfWriter)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)1 FacesMessage (javax.faces.application.FacesMessage)1 Languages_iso639 (mom.trd.opentheso.bdd.datas.Languages_iso639)1 AccessThesaurusHelper (mom.trd.opentheso.bdd.helper.AccessThesaurusHelper)1