use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.
the class ImportTabuleIntoBDD method insertConcept.
private boolean insertConcept(HikariDataSource ds, TabulateDocument tabulateDocument, String idThesaurus, boolean istopConcept, int idUser) {
// ajout du concept dans la base
Concept concept = new Concept();
ConceptHelper conceptHelper = new ConceptHelper();
concept.setIdConcept(tabulateDocument.getId());
concept.setIdThesaurus(idThesaurus);
concept.setNotation("");
concept.setStatus("");
concept.setTopConcept(istopConcept);
concept.setCreated(tabulateDocument.getCreated());
concept.setModified(tabulateDocument.getModified());
// cas de plusieurs Domaines (MT)
if (!tabulateDocument.getInScheme().isEmpty()) {
for (String idGroup : tabulateDocument.getInScheme()) {
concept.setIdGroup(idGroup);
conceptHelper.insertConceptInTable(ds, concept, idUser);
}
} else {
return false;
}
// ajout des termes et traductions
NodeTerm nodeTerm = new NodeTerm();
ArrayList<NodeTermTraduction> nodeTermTraductionList = new ArrayList<>();
for (Label prefLabel : tabulateDocument.getPrefLabels()) {
NodeTermTraduction nodeTermTraduction = new NodeTermTraduction();
nodeTermTraduction.setLexicalValue(prefLabel.getLabel());
nodeTermTraduction.setLang(prefLabel.getLang());
nodeTermTraductionList.add(nodeTermTraduction);
}
nodeTerm.setNodeTermTraduction(nodeTermTraductionList);
nodeTerm.setIdTerm(tabulateDocument.getId());
nodeTerm.setIdConcept(tabulateDocument.getId());
nodeTerm.setIdThesaurus(idThesaurus);
nodeTerm.setSource("");
nodeTerm.setStatus("");
nodeTerm.setCreated(tabulateDocument.getCreated());
nodeTerm.setModified(tabulateDocument.getModified());
TermHelper termHelper = new TermHelper();
termHelper.insertTerm(ds, nodeTerm, idUser);
// Enregister les synonymes et traductions (AltLabel)
ArrayList<NodeEM> nodeEMList = new ArrayList<>();
for (Label altLabel : tabulateDocument.getAltLabels()) {
NodeEM nodeEM = new NodeEM();
nodeEM.setLexical_value(altLabel.getLabel());
nodeEM.setLang(altLabel.getLang());
nodeEM.setSource("");
nodeEM.setStatus("USE");
nodeEM.setHiden(false);
nodeEMList.add(nodeEM);
}
Term term = new Term();
for (NodeEM nodeEMList1 : nodeEMList) {
term.setId_concept(tabulateDocument.getId());
term.setId_term(tabulateDocument.getId());
term.setLexical_value(nodeEMList1.getLexical_value());
term.setLang(nodeEMList1.getLang());
term.setId_thesaurus(idThesaurus);
term.setSource(nodeEMList1.getSource());
term.setStatus(nodeEMList1.getStatus());
termHelper.addNonPreferredTerm(ds, term, idUser);
}
// ajouter les notes
NoteHelper noteHelper = new NoteHelper();
for (Note note : tabulateDocument.getDefinition()) {
noteHelper.addTermNote(ds, tabulateDocument.getId(), note.getLang(), idThesaurus, note.getNote(), "definition", idUser);
}
for (Note note : tabulateDocument.getScopeNote()) {
noteHelper.addTermNote(ds, tabulateDocument.getId(), note.getLang(), idThesaurus, note.getNote(), "scopeNote", idUser);
}
for (Note note : tabulateDocument.getHistoryNote()) {
noteHelper.addTermNote(ds, tabulateDocument.getId(), note.getLang(), idThesaurus, note.getNote(), "historyNote", idUser);
}
for (Note note : tabulateDocument.getEditorialNote()) {
noteHelper.addTermNote(ds, tabulateDocument.getId(), note.getLang(), idThesaurus, note.getNote(), "editorialNote", idUser);
}
// Enregistrer les relations
writeRelationsList(ds, tabulateDocument, idThesaurus, idUser);
// Enregistrer les Mappings (alignements)
AlignmentHelper alignmentHelper = new AlignmentHelper();
for (Alignment alignment : tabulateDocument.getAlignments()) {
if (alignment.getType().equalsIgnoreCase("exactMatch")) {
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI
alignment.getUri(), 1, tabulateDocument.getId(), idThesaurus, 0);
}
if (alignment.getType().equalsIgnoreCase("closeMatch")) {
alignmentHelper.addNewAlignment(ds, // user
1, // concept target
"", // thesaurus target
"", // URI
alignment.getUri(), 2, tabulateDocument.getId(), idThesaurus, 0);
}
}
return true;
}
use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.
the class TermHelper method getTraductionsOfConcept.
/**
* Cette fonction permet de retourner les traductions d'un term sauf la
* langue en cours
*
* @param ds
* @param idConcept
* @param idThesaurus
* @param idLang
* @return Objet class NodeConceptTree
*/
public ArrayList<NodeTermTraduction> getTraductionsOfConcept(HikariDataSource ds, String idConcept, String idThesaurus, String idLang) {
Connection conn;
Statement stmt;
ResultSet resultSet;
ArrayList<NodeTermTraduction> nodeTraductionsList = null;
try {
// Get connection from pool
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
String query = "SELECT term.id_term, term.lexical_value, term.lang FROM" + " term, preferred_term WHERE" + " term.id_term = preferred_term.id_term" + " and preferred_term.id_concept = '" + idConcept + "'" + " and term.lang != '" + idLang + "'" + " and term.id_thesaurus = '" + idThesaurus + "'" + " order by term.lexical_value";
stmt.executeQuery(query);
resultSet = stmt.getResultSet();
if (resultSet != null) {
nodeTraductionsList = new ArrayList<>();
while (resultSet.next()) {
NodeTermTraduction nodeTraductions = new NodeTermTraduction();
nodeTraductions.setLang(resultSet.getString("lang"));
nodeTraductions.setLexicalValue(resultSet.getString("lexical_value"));
nodeTraductionsList.add(nodeTraductions);
}
}
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException sqle) {
// Log exception
log.error("Error while getting Traductions of Term : " + idConcept, sqle);
}
return nodeTraductionsList;
}
use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.
the class TermHelper method getAllTraductionsOfConcept.
/**
* Cette fonction permet de retourner toutes les traductions d'un concept
*
* @param ds
* @param idConcept
* @param idThesaurus
* @return Objet class NodeConceptTree
*/
public ArrayList<NodeTermTraduction> getAllTraductionsOfConcept(HikariDataSource ds, String idConcept, String idThesaurus) {
Connection conn;
Statement stmt;
ResultSet resultSet;
ArrayList<NodeTermTraduction> nodeTraductionsList = new ArrayList<>();
try {
// Get connection from pool
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
String query = "SELECT term.id_term, term.lexical_value, term.lang FROM" + " term, preferred_term WHERE" + " term.id_term = preferred_term.id_term" + " and term.id_thesaurus = preferred_term.id_thesaurus" + " and preferred_term.id_concept = '" + idConcept + "'" + " and term.id_thesaurus = '" + idThesaurus + "'" + " order by term.lexical_value";
stmt.executeQuery(query);
resultSet = stmt.getResultSet();
while (resultSet.next()) {
NodeTermTraduction nodeTraductions = new NodeTermTraduction();
nodeTraductions.setLang(resultSet.getString("lang"));
nodeTraductions.setLexicalValue(resultSet.getString("lexical_value"));
nodeTraductionsList.add(nodeTraductions);
}
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException sqle) {
// Log exception
log.error("Error while getting All Traductions of Concept : " + idConcept, sqle);
}
return nodeTraductionsList;
}
use of mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction in project opentheso by miledrousset.
the class ToolsHelper method GenerateArkIds.
/**
* Cette fonction permet de regénerer ou générer tous les identifiants Ark
* du thésaurus
*
* @param ds
* @param idThesaurus
* @return ArrayList de NodePermute
*/
public boolean GenerateArkIds(HikariDataSource ds, String idThesaurus) {
ConceptHelper conceptHelper = new ConceptHelper();
TermHelper termHelper = new TermHelper();
ArrayList<NodeTermTraduction> nodeTermTraductionList;
// Génération des Id Ark pour les concepts
ArrayList<String> tabIdConcept = conceptHelper.getAllIdConceptOfThesaurus(ds, idThesaurus);
String idArk;
ArkClient ark_Client = new ArkClient();
ArrayList<DcElement> dcElementsList = new ArrayList<>();
for (String idConcept : tabIdConcept) {
dcElementsList.clear();
nodeTermTraductionList = termHelper.getAllTraductionsOfConcept(ds, idConcept, idThesaurus);
for (NodeTermTraduction nodeTermTraduction : nodeTermTraductionList) {
DcElement dcElement = new DcElement();
// cette fonction permet de remplir la table Permutée
dcElement.setName("description");
dcElement.setValue(nodeTermTraduction.getLexicalValue());
dcElement.setLanguage(nodeTermTraduction.getLang());
dcElementsList.add(dcElement);
}
// String date, String url, String title, String creator, String description, String type
idArk = ark_Client.getArkId(new FileUtilities().getDate(), "http://pactols.frantiq.fr/" + "?idc=" + idConcept + "&idt=" + idThesaurus, idConcept, "Frantiq", dcElementsList, // pcrt : p= pactols, crt=code DCMI pour collection
"pcrt");
conceptHelper.updateArkIdOfConcept(ds, idConcept, idThesaurus, idArk);
}
return true;
}
Aggregations