use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class SelectedTerme method creerTermeAsso.
/**
* Ajoute une relation terme associé au concept courant
*
* @param idC2 le concept associé
*/
public void creerTermeAsso(String idC2) {
HierarchicalRelationship hr = new HierarchicalRelationship();
hr.setIdConcept1(idC);
hr.setIdConcept2(idC2);
hr.setIdThesaurus(idTheso);
hr.setRole("RT");
new ConceptHelper().addAssociativeRelation(connect.getPoolConnexion(), hr, user.getUser().getId());
ArrayList<NodeRT> tempRT = new RelationsHelper().getListRT(connect.getPoolConnexion(), idC, idTheso, idlangue);
termesAssocies = new ArrayList<>();
HashMap<String, String> tempMap = new HashMap<>();
for (NodeRT nrt : tempRT) {
tempMap.put(nrt.getIdConcept(), nrt.getTitle() + " (" + nrt.getRole() + ")");
}
termesAssocies.addAll(tempMap.entrySet());
vue.setAddTAsso(0);
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class SelectedTerme method creerTradterme.
/**
* Ajoute une traduction au terme courant et met l'affichage à jour
*/
public void creerTradterme() {
if (valueEdit == null || valueEdit.trim().equals("")) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error3")));
return;
}
boolean tradExist = false;
// c'est le cas ou le concept n'a pas de traduction dans la langue en cours, il faut le mettre a jour dans l'arbre
boolean newTraduction = false;
for (Entry<String, String> e : langues) {
if (e.getKey().equals(langueEdit)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
tradExist = true;
break;
}
}
ConceptHelper ch = new ConceptHelper();
TermHelper termHelper = new TermHelper();
if (idT.isEmpty()) {
newTraduction = true;
String tmp = termHelper.getIdTermOfConcept(connect.getPoolConnexion(), idC, idTheso);
if (tmp != null) {
idT = tmp;
}
}
// traduction du domaine
if (type == 1 && !tradExist) {
ConceptGroupLabel cgl = new ConceptGroupLabel();
cgl.setLexicalvalue(valueEdit);
cgl.setIdgroup(idDomaine);
cgl.setIdthesaurus(idTheso);
cgl.setLang(langueEdit);
GroupHelper cgh = new GroupHelper();
if (cgh.isDomainExist(connect.getPoolConnexion(), cgl.getLexicalvalue(), cgl.getIdthesaurus(), cgl.getLang())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
return;
}
if (!cgh.addGroupTraduction(connect.getPoolConnexion(), cgl, user.getUser().getId())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
return;
}
ArrayList<NodeGroupTraductions> tempNGT = new GroupHelper().getGroupTraduction(connect.getPoolConnexion(), idDomaine, idTheso, idlangue);
langues = new ArrayList<>();
HashMap<String, String> tempMapL = new HashMap<>();
for (NodeGroupTraductions ngt : tempNGT) {
tempMapL.put(ngt.getIdLang(), ngt.getTitle());
}
if (newTraduction) {
nom = cgh.getLexicalValueOfGroup(connect.getPoolConnexion(), idDomaine, idTheso, idlangue);
}
langues.addAll(tempMapL.entrySet());
// traduction du TT
} else if (type == 2 && !tradExist) {
Term terme = new Term();
terme.setId_thesaurus(idTheso);
terme.setLang(langueEdit);
terme.setLexical_value(valueEdit);
terme.setId_term(idT);
terme.setContributor(user.getUser().getId());
terme.setCreator(user.getUser().getId());
terme.setSource("");
terme.setStatus("");
if (termHelper.isTermExist(connect.getPoolConnexion(), terme.getLexical_value(), terme.getId_thesaurus(), terme.getLang())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
return;
}
if (!ch.addTopConceptTraduction(connect.getPoolConnexion(), terme, user.getUser().getId())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
return;
}
ArrayList<NodeTermTraduction> tempNTT = termHelper.getTraductionsOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue);
langues = new ArrayList<>();
HashMap<String, String> tempMapL = new HashMap<>();
for (NodeTermTraduction ntt : tempNTT) {
tempMapL.put(ntt.getLang(), ntt.getLexicalValue());
}
if (newTraduction) {
nom = termHelper.getThisTerm(connect.getPoolConnexion(), idC, idTheso, idlangue).getLexical_value();
}
langues.addAll(tempMapL.entrySet());
// traduction des concepts
} else if (type == 3 && !tradExist) {
Term terme = new Term();
terme.setId_thesaurus(idTheso);
terme.setLang(langueEdit);
terme.setLexical_value(valueEdit);
terme.setId_term(idT);
terme.setContributor(user.getUser().getId());
terme.setCreator(user.getUser().getId());
terme.setSource("");
terme.setStatus("");
if (termHelper.isTermExist(connect.getPoolConnexion(), terme.getLexical_value(), terme.getId_thesaurus(), terme.getLang())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
return;
}
if (!ch.addConceptTraduction(connect.getPoolConnexion(), terme, user.getUser().getId())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
return;
}
ArrayList<NodeTermTraduction> tempNTT = termHelper.getTraductionsOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue);
langues = new ArrayList<>();
HashMap<String, String> tempMapL = new HashMap<>();
for (NodeTermTraduction ntt : tempNTT) {
tempMapL.put(ntt.getLang(), ntt.getLexicalValue());
}
langues.addAll(tempMapL.entrySet());
if (newTraduction) {
nom = termHelper.getThisTerm(connect.getPoolConnexion(), idC, idTheso, idlangue).getLexical_value();
}
}
langueEdit = "";
valueEdit = "";
if (!tradExist) {
vue.setAddTrad(0);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sTerme.info2")));
}
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class SelectedTerme method creerTermeSpe.
/**
* Corrigé par M.R. Ajoute une relation terme spécifique au concept courant
*
* @param idCNT
* @return true or false
*/
public boolean creerTermeSpe(String idCNT) {
ConceptHelper conceptHelper = new ConceptHelper();
if (new OrphanHelper().isOrphan(connect.getPoolConnexion(), idCNT, idTheso)) {
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
ArrayList<String> newGroup = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), idC, idTheso);
for (String s : newGroup) {
Concept c = new Concept();
c.setIdConcept(idCNT);
c.setIdGroup(s);
c.setIdThesaurus(idTheso);
c.setStatus("D");
String idConcept = conceptHelper.addConceptInTable(conn, c, user.getUser().getId());
// si ça se passe mal, on ajoute rien;
if (idConcept == null) {
conn.rollback();
conn.close();
return false;
}
}
if (!new OrphanHelper().deleteOrphan(conn, idCNT, idTheso)) {
conn.rollback();
conn.close();
return false;
}
// On crée les relations
if (!new RelationsHelper().addRelationBT(conn, idCNT, idTheso, idC, user.getUser().getId())) {
conn.rollback();
conn.close();
return false;
}
conn.commit();
conn.close();
} catch (SQLException ex) {
Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
} else if (type == 1) {
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
if (new ConceptHelper().haveThisGroup(connect.getPoolConnexion(), idCNT, idC, idTheso)) {
if (!new RelationsHelper().setRelationTopConcept(conn, idCNT, idTheso, idC, true, user.getUser().getId())) {
conn.rollback();
conn.close();
return false;
}
} else {
ArrayList<String> newGroup = new ArrayList<>();
newGroup.add(idC);
if (!addBranchGroup(newGroup, idCNT)) {
conn.rollback();
conn.close();
return false;
}
if (!new RelationsHelper().setRelationTopConcept(conn, idCNT, idTheso, idC, true, user.getUser().getId())) {
conn.rollback();
conn.close();
return false;
}
}
conn.commit();
conn.close();
} catch (SQLException ex) {
Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
// On ajoute les nouveaux domaines s'il y en a
ArrayList<String> groupNT = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), idCNT, idTheso);
ArrayList<String> groupCurrent = conceptHelper.getListGroupIdOfConcept(connect.getPoolConnexion(), idC, idTheso);
ArrayList<String> newGroup = new ArrayList<>();
for (String s : groupCurrent) {
if (!groupNT.contains(s)) {
newGroup.add(s);
}
}
if (!addBranchGroup(newGroup, idCNT)) {
conn.rollback();
conn.close();
return false;
}
// On crée les relations
if (!new RelationsHelper().addRelationBT(conn, idCNT, idTheso, idC, user.getUser().getId())) {
conn.rollback();
conn.close();
return false;
}
conn.commit();
conn.close();
} catch (SQLException ex) {
Logger.getLogger(SelectedTerme.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
}
ArrayList<NodeNT> tempNT = new RelationsHelper().getListNT(connect.getPoolConnexion(), idC, idTheso, idlangue);
termesSpecifique = new ArrayList<>();
HashMap<String, String> tempMap = new HashMap<>();
for (NodeNT nnt : tempNT) {
tempMap.put(nnt.getIdConcept(), nnt.getTitle() + " (" + nnt.getRole() + ")");
}
termesSpecifique.addAll(tempMap.entrySet());
vue.setAddTSpe(false);
return true;
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class SelectedTerme method getNbNoticesOfBranch.
public String getNbNoticesOfBranch() {
// ResourceBundle bundlePref = getBundlePref();
int total = 0;
if (totalNoticesOfBranch.isEmpty()) {
if (user.getNodePreference().isZ3950actif()) {
ConceptHelper conceptHelper = new ConceptHelper();
ArrayList<String> lisIds = new ArrayList();
lisIds = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), idC, idTheso, lisIds);
Properties p = new Properties();
p.put("CollectionDataSourceClassName", "com.k_int.util.Repository.XMLDataSource");
p.put("RepositoryDataSourceURL", "file:" + user.getNodePreference().getPathNotice1());
p.put("XSLConverterConfiguratorClassName", "com.k_int.IR.Syntaxes.Conversion.XMLConfigurator");
p.put("ConvertorConfigFile", user.getNodePreference().getPathNotice2());
Searchable federated_search_proxy = new HeterogeneousSetOfSearchable();
federated_search_proxy.init(p);
try {
IRQuery e = new IRQuery();
// e.collections = new Vector<String>();
e.collections.add(user.getNodePreference().getCollectionAdresse());
e.hints.put("default_element_set_name", "f");
e.hints.put("small_set_setname", "f");
e.hints.put("record_syntax", "unimarc");
for (String idConcept : lisIds) {
e.query = new PrefixString((new StringBuilder("@attrset bib-1 @attr 1=Koha-Auth-Number \"")).append(AsciiUtils.convertNonAscii("" + idConcept)).append("\"").toString());
SearchTask st = federated_search_proxy.createTask(e, null);
st.evaluate(5000);
total = total + st.getTaskResultSet().getFragmentCount();
st.destroyTask();
}
federated_search_proxy.destroy();
} catch (TimeoutExceededException | SearchException srch_e) {
srch_e.printStackTrace();
}
totalNoticesOfBranch = "" + total;
}
}
return totalNoticesOfBranch;
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class SelectedThesaurus method preRenderView.
/**
* récupère la variable URL et affiche le terme qu'elle désigne
*/
public void preRenderView() {
// if the URL is for Concept
if (idCurl != null && idTurl != null) {
idLurl = Locale.getDefault().toString().substring(0, 2);
ArrayList<Languages_iso639> temp = new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), idTurl);
if (temp.isEmpty()) {
idCurl = null;
idGurl = null;
idTurl = null;
return;
} else {
boolean lExist = false;
for (Languages_iso639 l : temp) {
if (l.getId_iso639_1().trim().equals(idLurl)) {
lExist = true;
}
}
if (!lExist) {
idLurl = temp.get(0).getId_iso639_1().trim();
}
}
if (new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl) == null) {
idCurl = null;
idGurl = null;
idTurl = null;
return;
}
tree.getSelectedTerme().reInitTerme();
// Initialisation du thésaurus et de l'arbre
thesaurus.setId_thesaurus(idTurl);
thesaurus.setLanguage(idLurl);
tree.getSelectedTerme().reInitTerme();
tree.reInit();
tree.initTree(null, null);
ThesaurusHelper th = new ThesaurusHelper();
thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
user.initUserNodePref(idTurl);
// Initialisation du terme séléctionné et de l'arbre
int type;
Concept c = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl);
if (c.isTopConcept()) {
type = 2;
} else {
type = 3;
}
tree.getSelectedTerme().setIdTheso(idTurl);
tree.getSelectedTerme().setIdlangue(idLurl);
MyTreeNode mTN = new MyTreeNode(type, idCurl, idTurl, idLurl, c.getIdGroup(), "", null, null, null, null);
tree.getSelectedTerme().majTerme(mTN);
tree.reExpand();
idCurl = null;
idGurl = null;
idTurl = null;
idLurl = null;
return;
}
// if the URL is for Groups
if (idGurl != null && idTurl != null) {
idLurl = Locale.getDefault().toString().substring(0, 2);
ArrayList<Languages_iso639> temp = new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), idTurl);
if (temp.isEmpty()) {
idCurl = null;
idGurl = null;
idTurl = null;
return;
} else {
boolean lExist = false;
for (Languages_iso639 l : temp) {
if (l.getId_iso639_1().trim().equals(idLurl)) {
lExist = true;
}
}
if (!lExist) {
idLurl = temp.get(0).getId_iso639_1().trim();
}
}
if (new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(), idGurl, idTurl, idLurl) == null) {
idCurl = null;
idGurl = null;
idTurl = null;
return;
}
tree.getSelectedTerme().reInitTerme();
// Initialisation du thésaurus et de l'arbre
thesaurus.setId_thesaurus(idTurl);
thesaurus.setLanguage(idLurl);
tree.getSelectedTerme().reInitTerme();
tree.reInit();
tree.initTree(null, null);
ThesaurusHelper th = new ThesaurusHelper();
thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
user.initUserNodePref(idTurl);
// Initialisation du terme séléctionné et de l'arbre
int type = 1;
// NodeGroup nodeGroup = new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(),idGurl, idTurl, idLurl);
/*
Concept c = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl);
if (c.isTopConcept()) {
type = 2;
} else {
type = 3;
}*/
tree.getSelectedTerme().setIdTheso(idTurl);
tree.getSelectedTerme().setIdlangue(idLurl);
MyTreeNode mTN = new MyTreeNode(type, idGurl, idTurl, idLurl, idGurl, "", null, null, null, null);
tree.getSelectedTerme().majTerme(mTN);
tree.reExpand();
idCurl = null;
idGurl = null;
idTurl = null;
idLurl = null;
return;
}
// if the URL is only for thésaurus
if (idTurl != null) {
idLurl = Locale.getDefault().toString().substring(0, 2);
ArrayList<Languages_iso639> temp = new LanguageHelper().getLanguagesOfThesaurus(connect.getPoolConnexion(), idTurl);
if (temp.isEmpty()) {
idCurl = null;
idGurl = null;
idTurl = null;
return;
} else {
boolean lExist = false;
for (Languages_iso639 l : temp) {
if (l.getId_iso639_1().trim().equals(idLurl)) {
lExist = true;
}
}
if (!lExist) {
idLurl = temp.get(0).getId_iso639_1().trim();
}
}
/* if (new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(), idGurl, idTurl, idLurl) == null) {
idCurl = null;
idGurl = null;
idTurl = null;
return;
}*/
tree.getSelectedTerme().reInitTerme();
// Initialisation du thésaurus et de l'arbre
thesaurus.setId_thesaurus(idTurl);
thesaurus.setLanguage(idLurl);
tree.getSelectedTerme().reInitTerme();
tree.reInit();
tree.initTree(null, null);
ThesaurusHelper th = new ThesaurusHelper();
thesaurus = th.getThisThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
tree.initTree(thesaurus.getId_thesaurus(), thesaurus.getLanguage());
languesTheso = new LanguageHelper().getSelectItemLanguagesOneThesaurus(connect.getPoolConnexion(), thesaurus.getId_thesaurus(), thesaurus.getLanguage());
user.initUserNodePref(idTurl);
// Initialisation du terme séléctionné et de l'arbre
// NodeGroup nodeGroup = new GroupHelper().getThisConceptGroup(connect.getPoolConnexion(),idGurl, idTurl, idLurl);
/*
Concept c = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idCurl, idTurl);
if (c.isTopConcept()) {
type = 2;
} else {
type = 3;
}*/
tree.getSelectedTerme().setIdTheso(idTurl);
tree.getSelectedTerme().setIdlangue(idLurl);
// MyTreeNode mTN = new MyTreeNode(type, idGurl, idTurl, idLurl, idGurl, "", null, null, null);
// tree.getSelectedTerme().majTerme(mTN);
// tree.reExpand();
idCurl = null;
idGurl = null;
idTurl = null;
idLurl = null;
}
}
Aggregations