use of mom.trd.opentheso.bdd.helper.nodes.NodeFacet in project opentheso by miledrousset.
the class SelectedTerme method onNodeExpand.
/**
* Expension de l'abre sur un seul noeud (ouvert manuellement)
*
* @param event Le noeud ouvert
*/
public void onNodeExpand(NodeExpandEvent event) {
String theso = ((MyTreeNode) event.getTreeNode()).getIdTheso();
String lang = ((MyTreeNode) event.getTreeNode()).getLangue();
// Récupération des facettes
ArrayList<Integer> listIdFacet = new FacetHelper().getIdFacetUnderConcept(connect.getPoolConnexion(), ((MyTreeNode) event.getTreeNode()).getIdConcept(), theso);
ArrayList<NodeFacet> listFacet = new ArrayList<>();
for (Integer id : listIdFacet) {
NodeFacet nf = new FacetHelper().getThisFacet(connect.getPoolConnexion(), id, theso, lang);
listFacet.add(nf);
}
// <Retirer noeuds fictifs>
if (event.getTreeNode().getChildCount() == 1) {
event.getTreeNode().getChildren().remove(0);
}
// Récupération et insertion des facettes avec leurs concepts
for (NodeFacet nf : listFacet) {
String valeur = nf.getLexicalValue() + "(" + String.valueOf(nf.getIdFacet()) + ")";
new MyTreeNode(1, String.valueOf(nf.getIdFacet()), theso, lang, "", "", "", "facette", valeur, event.getTreeNode());
ArrayList<String> listIdC = new FacetHelper().getIdConceptsOfFacet(connect.getPoolConnexion(), nf.getIdFacet(), theso);
ArrayList<NodeConceptTree> liste = new ArrayList<>();
for (String id : listIdC) {
String value = new TermHelper().getThisTerm(connect.getPoolConnexion(), id, theso, lang).getLexical_value();
NodeConceptTree nct = new NodeConceptTree();
nct.setHaveChildren(false);
nct.setIdConcept(id);
nct.setIdLang(lang);
nct.setIdThesaurus(theso);
nct.setTitle(value);
liste.add(nct);
}
// Ajout dans l'arbre
for (NodeConceptTree nct : liste) {
new MyTreeNode(3, nct.getIdConcept(), theso, lang, "", "", "", "fichier", nct.getTitle() + "(" + nct.getIdConcept() + ")", event.getTreeNode());
}
}
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeFacet in project opentheso by miledrousset.
the class UnderTree method onNodeExpand.
/**
************************** ACTIONS TREE ***************************
*/
/**
* Expension de l'abre sur un seul noeud (ouvert manuellement)
* @param event Le noeud ouvert
*/
public void onNodeExpand(NodeExpandEvent event) {
String theso = ((MyTreeNode) event.getTreeNode()).getIdTheso();
String lang = ((MyTreeNode) event.getTreeNode()).getLangue();
// Récupération des facettes
ArrayList<Integer> listIdFacet = new FacetHelper().getIdFacetUnderConcept(connect.getPoolConnexion(), ((MyTreeNode) event.getTreeNode()).getIdConcept(), theso);
ArrayList<NodeFacet> listFacet = new ArrayList<>();
for (Integer id : listIdFacet) {
NodeFacet nf = new FacetHelper().getThisFacet(connect.getPoolConnexion(), id, theso, lang);
listFacet.add(nf);
}
// <Retirer noeuds fictifs>
if (event.getTreeNode().getChildCount() == 1) {
event.getTreeNode().getChildren().remove(0);
}
// Récupération et insertion des facettes avec leurs concepts
for (NodeFacet nf : listFacet) {
new MyTreeNode(1, String.valueOf(nf.getIdFacet()), theso, lang, "", "", "", "facette", nf.getLexicalValue() + "(" + String.valueOf(nf.getIdFacet()) + ")", event.getTreeNode());
ArrayList<String> listIdC = new FacetHelper().getIdConceptsOfFacet(connect.getPoolConnexion(), nf.getIdFacet(), theso);
ArrayList<NodeConceptTree> liste = new ArrayList<>();
for (String id : listIdC) {
String value = new TermHelper().getThisTerm(connect.getPoolConnexion(), id, theso, lang).getLexical_value();
NodeConceptTree nct = new NodeConceptTree();
nct.setHaveChildren(false);
nct.setIdConcept(id);
nct.setIdLang(lang);
nct.setIdThesaurus(theso);
nct.setTitle(value);
liste.add(nct);
}
// Ajout dans l'arbre
for (NodeConceptTree nct : liste) {
new MyTreeNode(3, nct.getIdConcept(), theso, lang, "", "", "", "fichier", nct.getTitle() + "(" + nct.getIdConcept() + ")", event.getTreeNode());
}
}
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeFacet in project opentheso by miledrousset.
the class FacetHelper method getAllFacetsOfThesaurus.
/**
* Cette fonction permet de retourner toutes les Facettes d'un thésaurus
* sous forme de NodeFacet
*
* @param ds
* @param idThesaurus
* @param idLang
* @return ArrayList de NodeFacet
*/
public ArrayList<NodeFacet> getAllFacetsOfThesaurus(HikariDataSource ds, String idThesaurus, String idLang) {
Connection conn;
Statement stmt;
ResultSet resultSet;
ArrayList<NodeFacet> nodeFacetlist = new ArrayList();
try {
// Get connection from pool
conn = ds.getConnection();
try {
stmt = conn.createStatement();
try {
String query = "SELECT node_label.lexical_value," + " node_label.facet_id, thesaurus_array.id_concept_parent FROM " + " thesaurus_array, node_label WHERE" + " thesaurus_array.facet_id = node_label.facet_id AND" + " thesaurus_array.id_thesaurus = node_label.id_thesaurus" + " and node_label.lang = '" + idLang + "'" + " and node_label.id_thesaurus = '" + idThesaurus + "'";
stmt.executeQuery(query);
resultSet = stmt.getResultSet();
while (resultSet.next()) {
NodeFacet nodeFacet = new NodeFacet();
nodeFacet.setIdFacet(resultSet.getInt("facet_id"));
nodeFacet.setLexicalValue(resultSet.getString("lexical_value"));
nodeFacet.setIdConceptParent(resultSet.getString("id_concept_parent"));
nodeFacetlist.add(nodeFacet);
}
} finally {
stmt.close();
}
} finally {
conn.close();
}
} catch (SQLException sqle) {
// Log exception
log.error("Error while getting All Facet of Thesaurus : " + idThesaurus, sqle);
}
return nodeFacetlist;
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeFacet in project opentheso by miledrousset.
the class SelectedTerme method getArrayFacetteInclure.
public ArrayList<Entry<String, String>> getArrayFacetteInclure() {
if (connect.getPoolConnexion() == null) {
return null;
}
ArrayList<NodeFacet> temp = new FacetHelper().getAllFacetsOfThesaurus(connect.getPoolConnexion(), idTheso, idlangue);
ArrayList<Integer> temp2 = new FacetHelper().getIdFacetOfConcept(connect.getPoolConnexion(), idC, idTheso);
Map<String, String> mapTemp = new HashMap<>();
/* for (NodeFacet nf : temp) {
if (!temp2.contains(nf.getIdFacet())) {
String value = new TermHelper().getThisTerm(connect.getPoolConnexion(), nf.getIdConceptParent(), idTheso, idlangue).getLexical_value();
mapTemp.put(String.valueOf(nf.getIdFacet()), nf.getLexicalValue() + " (" + value + ")");
}
}*/
arrayFacette = new ArrayList<>(mapTemp.entrySet());
return arrayFacette;
}
use of mom.trd.opentheso.bdd.helper.nodes.NodeFacet in project opentheso by miledrousset.
the class SelectedThesaurus method getArrayFacette.
public ArrayList<Entry<String, String>> getArrayFacette() {
if (connect.getPoolConnexion() != null) {
if (thesaurus == null) {
return arrayFacette;
}
ArrayList<NodeFacet> temp = new FacetHelper().getAllFacetsOfThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
Map<String, String> mapTemp = new HashMap<>();
Term value;
for (NodeFacet nf : temp) {
value = new TermHelper().getThisTerm(connect.getPoolConnexion(), nf.getIdConceptParent(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
if (value == null) {
mapTemp.put(String.valueOf(nf.getIdFacet()), nf.getLexicalValue() + " (" + nf.getIdConceptParent() + ")");
} else {
mapTemp.put(String.valueOf(nf.getIdFacet()), nf.getLexicalValue() + " (" + value.getLexical_value() + ")");
}
}
arrayFacette = new ArrayList<>(mapTemp.entrySet());
}
return arrayFacette;
}
Aggregations