Search in sources :

Example 11 with NodeLang

use of mom.trd.opentheso.bdd.helper.nodes.NodeLang in project opentheso by miledrousset.

the class ThesaurusHelper method getAllUsedLanguagesOfThesaurusNode.

/**
 * Cette fonction permet de retourner toutes les langues utilisées par les
 * Concepts d'un thésaurus (sous forme de NodeLang, un objet complet)
 *
 * @param ds
 * @param idThesaurus
 * @return Objet class NodeConceptTree
 */
public ArrayList<NodeLang> getAllUsedLanguagesOfThesaurusNode(HikariDataSource ds, String idThesaurus) {
    Connection conn;
    Statement stmt;
    ResultSet resultSet;
    ArrayList<NodeLang> nodeLangs = new ArrayList<>();
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "SELECT thesaurus_label.lang, languages_iso639.french_name" + " FROM thesaurus_label, languages_iso639" + " WHERE thesaurus_label.lang = languages_iso639.iso639_1" + " and thesaurus_label.id_thesaurus = '" + idThesaurus + "'" + " order by languages_iso639.french_name";
                stmt.executeQuery(query);
                resultSet = stmt.getResultSet();
                int i = 0;
                while (resultSet.next()) {
                    NodeLang nodeLang = new NodeLang();
                    nodeLang.setId("" + i);
                    nodeLang.setCode(resultSet.getString("lang"));
                    nodeLang.setValue(resultSet.getString("french_name"));
                    nodeLangs.add(nodeLang);
                    i++;
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting All Used languages of Concepts of thesaurus  : " + idThesaurus, sqle);
    }
    return nodeLangs;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList)

Example 12 with NodeLang

use of mom.trd.opentheso.bdd.helper.nodes.NodeLang in project opentheso by miledrousset.

the class WriteFileSKOS method writeGroup.

/**
 * @param nodeGroupLabel
 * @param listIdOfTopConcept
 * @param selectedLanguages
 *
 * @return true ou false
 */
public boolean writeGroup(NodeGroupLabel nodeGroupLabel, ArrayList<NodeUri> listIdOfTopConcept, List<NodeLang> selectedLanguages) {
    SKOSResource concept;
    if (nodeGroupLabel.getIdArk() == null || nodeGroupLabel.getIdArk().trim().isEmpty()) {
        /*
            Cette partie est pour l'export des PACTOLS pour Frantiq
             */
        // concept = new SKOSResource(serverAdress + "#" + nodeGroupLabel.getIdGroup());
        concept = new SKOSResource(serverAdress + "?idg=" + nodeGroupLabel.getIdGroup() + "&amp;idt=" + nodeGroupLabel.getIdThesaurus());
    } else {
        concept = new SKOSResource(serverArk + nodeGroupLabel.getIdArk());
    }
    for (int i = 0; i < nodeGroupLabel.getNodeGroupTraductionses().size(); i++) {
        if (selectedLanguages != null) {
            // nodeGroupLabel.getNodeGroupTraductionses().get(i).getIdLang().equalsIgnoreCase("fr"))
            for (NodeLang selectedLanguage : selectedLanguages) {
                if (nodeGroupLabel.getNodeGroupTraductionses().get(i).getIdLang().equalsIgnoreCase(selectedLanguage.getCode())) {
                    concept.addLabel(nodeGroupLabel.getNodeGroupTraductionses().get(i).getTitle(), nodeGroupLabel.getNodeGroupTraductionses().get(i).getIdLang(), SKOSProperty.prefLabel);
                }
            }
        } else {
            concept.addLabel(nodeGroupLabel.getNodeGroupTraductionses().get(i).getTitle(), nodeGroupLabel.getNodeGroupTraductionses().get(i).getIdLang(), SKOSProperty.prefLabel);
        }
    }
    if (!nodeGroupLabel.getNodeGroupTraductionses().isEmpty()) {
        concept.addDate(nodeGroupLabel.getNodeGroupTraductionses().get(0).getCreated().toString(), SKOSProperty.created);
        concept.addDate(nodeGroupLabel.getNodeGroupTraductionses().get(0).getModified().toString(), SKOSProperty.modified);
    }
    if (!nodeGroupLabel.getIdGroup().isEmpty()) {
        concept.addIdentifier(nodeGroupLabel.getIdGroup(), SKOSProperty.identifier);
    }
    for (NodeUri listIdOfTopConcept1 : listIdOfTopConcept) {
        if (listIdOfTopConcept1.getIdArk() == null || listIdOfTopConcept1.getIdArk().trim().isEmpty()) {
            concept.addRelation(serverAdress + "?idc=" + listIdOfTopConcept1.getIdConcept() + "&amp;idt=" + nodeGroupLabel.getIdThesaurus(), SKOSProperty.narrower);
        } else {
            concept.addRelation(serverArk + listIdOfTopConcept1.getIdArk(), SKOSProperty.narrower);
        }
    }
    skosBuff.append("    ").append(concept.toString());
    return true;
}
Also used : SKOSResource(skos.SKOSResource) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri)

Aggregations

NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)12 ArrayList (java.util.ArrayList)5 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)4 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)3 NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)3 NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)3 Languages_iso639 (mom.trd.opentheso.bdd.datas.Languages_iso639)2 LanguageHelper (mom.trd.opentheso.bdd.helper.LanguageHelper)2 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)2 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)2 NodeConceptExport (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport)2 NodeGroup (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroup)2 NodeTermTraduction (mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)2 SKOSResource (skos.SKOSResource)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 StringReader (java.io.StringReader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HttpURLConnection (java.net.HttpURLConnection)1