use of mom.trd.opentheso.bdd.helper.GroupHelper in project opentheso by miledrousset.
the class TreeChange method moveTopTermToConceptOtherDomaine.
public boolean moveTopTermToConceptOtherDomaine(Connexion connect, String idConceptOrigin, String idBT, String idOriginGroup, String targetidConcept, String targetIGroup, String idThesoSelected, int id) {
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
GroupHelper groupHelper = new GroupHelper();
ConceptHelper conceptHelper = new ConceptHelper();
RelationsHelper relationHelper = new RelationsHelper();
// on récupère les Ids des concepts à modifier
ArrayList<String> lisIds = new ArrayList<>();
lisIds = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), idConceptOrigin, idThesoSelected, lisIds);
if (!groupHelper.deleteAllDomainOfBranch(conn, lisIds, idOriginGroup, idThesoSelected)) {
conn.rollback();
conn.close();
return false;
}
if (!groupHelper.addDomainToBranch(conn, lisIds, targetIGroup, idThesoSelected, id)) {
conn.rollback();
conn.close();
return false;
}
if (!relationHelper.addRelationBT(conn, idConceptOrigin, idThesoSelected, targetidConcept, id)) {
conn.rollback();
conn.close();
return false;
}
if (!relationHelper.deleteRelationTT(conn, idConceptOrigin, idThesoSelected, id)) {
conn.rollback();
conn.close();
return false;
}
conn.commit();
conn.close();
return true;
} catch (SQLException ex) {
Logger.getLogger(AutoCompletBean.class.getName()).log(Level.SEVERE, null, ex);
}
return false;
}
use of mom.trd.opentheso.bdd.helper.GroupHelper in project opentheso by miledrousset.
the class TreeChange method moveConceptToGroupOtherDomain.
/**
* moveConceptToGroupOtherDomain
*
* la tête de la branche devient un top term dans un autre groupe
*
* @param connect
* @param originNodeIdConcept
* @param BToriginNode
* @param originDomain
* @param targetNodeIdConcept
* @param TargetNodeDomaine
* @param idThesaurus
* @param idUser
* @return
*/
public boolean moveConceptToGroupOtherDomain(Connexion connect, String originNodeIdConcept, String BToriginNode, String originDomain, String targetNodeIdConcept, String TargetNodeDomaine, String idThesaurus, int idUser) {
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
/* if (selectedAtt == null || selectedAtt.getIdGroup().equals("")) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("autoComp.error1")));
return false;
}*/
ConceptHelper conceptHelper = new ConceptHelper();
GroupHelper groupHelper = new GroupHelper();
// on récupère les identifiants des BT pour un groupe #jm
ArrayList<String> listeIdGroupBT = conceptHelper.getAllBTOfConceptOfThisGroup(connect.getPoolConnexion(), originNodeIdConcept, originDomain, idThesaurus);
// au concept la relation TT
if (!conceptHelper.moveBranchToAnotherMT(conn, originNodeIdConcept, // ancien Group
BToriginNode, // ancien Group
originDomain, // nouveau Group
TargetNodeDomaine, idThesaurus, idUser)) {
conn.rollback();
conn.close();
return false;
}
// on récupère les Ids des concepts à modifier
ArrayList<String> lisIds = new ArrayList<>();
lisIds = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), originNodeIdConcept, idThesaurus, lisIds);
if (listeIdGroupBT.size() == 1) {
// on supprime l'ancien Groupe de la branche
if (!groupHelper.deleteAllDomainOfBranch(conn, lisIds, originDomain, idThesaurus)) {
conn.rollback();
conn.close();
return false;
}
}
// on ajoute le nouveau domaine à la branche
listeIdGroupBT = conceptHelper.getAllBTOfConceptOfThisGroup(connect.getPoolConnexion(), originNodeIdConcept, TargetNodeDomaine, idThesaurus);
if (listeIdGroupBT.isEmpty()) {
if (!groupHelper.addDomainToBranch(conn, lisIds, TargetNodeDomaine, idThesaurus, idUser)) {
conn.rollback();
conn.close();
return false;
}
}
conn.commit();
conn.close();
return true;
} catch (SQLException ex) {
Logger.getLogger(TreeChange.class.getName()).log(Level.SEVERE, null, ex);
}
return false;
}
use of mom.trd.opentheso.bdd.helper.GroupHelper in project opentheso by miledrousset.
the class BackgroundTimeJob method synchroSparql.
private Runnable synchroSparql(int key) {
SynchroSparql run = new SynchroSparql();
run.setSparqlStruct(this.SparqlSyn.get(key));
ArrayList<Languages_iso639> listeLang = new LanguageHelper().getLanguagesOfThesaurus(this.connect.getPoolConnexion(), this.SparqlSyn.get(key).getThesaurus());
ArrayList<NodeLang> nol = new ArrayList<>();
for (Languages_iso639 lang : listeLang) {
NodeLang nd = new NodeLang();
nd.setValue(lang.getId_iso639_1());
nd.setCode(lang.getId_iso639_1());
nol.add(nd);
}
run.setListe_lang(nol);
ArrayList<String> nog = new GroupHelper().getListIdOfGroup(this.connect.getPoolConnexion(), this.SparqlSyn.get(key).getThesaurus());
ArrayList<NodeGroup> groupes = new ArrayList<>();
for (String group : nog) {
NodeGroup ng1 = new NodeGroup();
ng1.setId_group(group);
ConceptGroup cg = new ConceptGroup();
cg.setIdgroup(group);
ng1.setConceptGroup(cg);
groupes.add(ng1);
}
run.setListe_group(groupes);
run.setConn(this.connect);
return run;
}
use of mom.trd.opentheso.bdd.helper.GroupHelper in project opentheso by miledrousset.
the class ExportFromBDD_Frantiq method exportGroup.
/**
* Fonction récursive permettant d'exporter le Groupe de la tête jusqu'au
* dernier descripteur
*
* @param ds
* @param idThesaurus
* @param idGroup
* @return
*/
public StringBuffer exportGroup(HikariDataSource ds, String idThesaurus, String idGroup) {
WriteFileSKOS_Frantiq writeFileSKOS = new WriteFileSKOS_Frantiq();
// inititialisation des URI
writeFileSKOS.setServerArk(serverArk);
writeFileSKOS.setServerAdress(serverAdress);
writeFileSKOS.writeHeader();
// ecriture des TopConcept
GroupHelper conceptGroupHelper = new GroupHelper();
// écriture des Domaines et Descripteurs avec traductions
NodeGroupLabel nodeGroupLabel = conceptGroupHelper.getNodeGroupLabel(ds, idGroup, idThesaurus);
ArrayList<NodeUri> idOfTopConcept = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, idGroup, idThesaurus);
writeFileSKOS.writeGroup(nodeGroupLabel, idOfTopConcept);
// écriture des TopConcepts
for (NodeUri idOfTopConcept1 : idOfTopConcept) {
exportAllConcepts(ds, idOfTopConcept1.getIdConcept(), idThesaurus, writeFileSKOS);
}
writeFileSKOS.endSkos();
return writeFileSKOS.getSkosBuff();
}
Aggregations