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;
}
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() + "&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() + "&idt=" + nodeGroupLabel.getIdThesaurus(), SKOSProperty.narrower);
} else {
concept.addRelation(serverArk + listIdOfTopConcept1.getIdArk(), SKOSProperty.narrower);
}
}
skosBuff.append(" ").append(concept.toString());
return true;
}
Aggregations