use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class TreeChange method moveConceptTermToConceptTermOtherDomain.
/**
* moveConceptTermToConceptTermOtherDomain
*
* déplacement d'un concept vers un autre domaine
*
* @param connect
* @param originNodeIdConcept
* @param originNodeIdGroup
* @param BToriginNode
* @param targetNodeIdConcept
* @param targetNodeIdGroupe
* @param idTheasurus
* @param idUser
* @return
*/
public boolean moveConceptTermToConceptTermOtherDomain(Connexion connect, String originNodeIdConcept, String originNodeIdGroup, String BToriginNode, String targetNodeIdConcept, String targetNodeIdGroupe, String idTheasurus, int idUser) {
ConceptHelper conceptHelper = new ConceptHelper();
GroupHelper groupHelper = new GroupHelper();
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
// on récupère les identifiants des BT pour un groupe #jm
ArrayList<String> listeIdGroupBT = conceptHelper.getAllBTOfConceptOfThisGroup(connect.getPoolConnexion(), originNodeIdConcept, originNodeIdGroup, idTheasurus);
// permet de déplacer une branche simplement, en cas d'erreur, rien n'est écrit
if (!conceptHelper.moveBranchToConceptOtherGroup(conn, originNodeIdConcept, BToriginNode, targetNodeIdConcept, idTheasurus, idUser)) {
return false;
}
// on récupère les Ids des concepts à modifier
ArrayList<String> lisIds = new ArrayList<>();
lisIds = conceptHelper.getIdsOfBranch(connect.getPoolConnexion(), originNodeIdConcept, idTheasurus, lisIds);
if (listeIdGroupBT.size() == 1) {
if (!groupHelper.deleteAllDomainOfBranch(conn, lisIds, originNodeIdGroup, idTheasurus)) {
conn.rollback();
conn.close();
return false;
}
}
listeIdGroupBT = conceptHelper.getAllBTOfConceptOfThisGroup(connect.getPoolConnexion(), originNodeIdConcept, targetNodeIdGroupe, idTheasurus);
if (listeIdGroupBT.isEmpty()) {
if (!groupHelper.addDomainToBranch(conn, lisIds, targetNodeIdGroupe, idTheasurus, idUser)) {
conn.rollback();
conn.close();
return false;
}
}
conn.commit();
conn.close();
} catch (SQLException e) {
Logger.getLogger(TreeChange.class.getName()).log(Level.SEVERE, "erreur dans le déplacement de la branche à un domaine différent de l'origine", e);
}
return true;
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class TreeChange method getPathFromSelectedConcept.
public ArrayList<String> getPathFromSelectedConcept(Connexion conn, MyTreeNode selectedNode) {
String id = selectedNode.getIdConcept();
String theso = selectedNode.getIdTheso();
GroupHelper gh = new GroupHelper();
ArrayList<NodeGroup> groups = gh.getListGroupOfConcept(conn.getPoolConnexion(), theso, id, selectedNode.getLangue());
ConceptHelper ch = new ConceptHelper();
ArrayList<String> result = new ArrayList<>();
ArrayList<String> bt = new ArrayList<>();
ArrayList<String> groupIds = new ArrayList<>();
for (NodeGroup ng : groups) {
groupIds.add(ng.getConceptGroup().getIdgroup());
bt.addAll(ch.getAllBTOfConceptOfThisGroup(conn.getPoolConnexion(), id, ng.getConceptGroup().getIdgroup(), theso));
}
result.addAll(bt);
while (!bt.isEmpty()) {
ArrayList<String> tmp = new ArrayList<>();
for (String idBt : bt) {
for (String idGroup : groupIds) {
tmp.addAll(ch.getAllBTOfConceptOfThisGroup(conn.getPoolConnexion(), idBt, idGroup, theso));
}
}
bt = new ArrayList<>(tmp);
result.addAll(bt);
}
for (String idGroup : groupIds) {
String fat = gh.getIdFather(conn.getPoolConnexion(), idGroup, theso);
result.add(fat);
while (fat != null && !fat.isEmpty()) {
fat = gh.getIdFather(conn.getPoolConnexion(), fat, theso);
result.add(fat);
}
}
result.addAll(groupIds);
return result;
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class TreeChange method moveTopTermToConceptSameDomaine.
/**
* moveTopTermToConceptSameDomain
*
* le top term se déplace dans une hierarchie
* note : cette fonction est utilisé aussi pour déplacer un top
* terme en dehors du groupe
*
* @param connect
* @param originNodeIdConcept
* @param BToriginNode
* @param originIdDomain
* @param targetNodeIdConcept
* @param idThesaurus
* @param idUser
* @return
*/
public boolean moveTopTermToConceptSameDomaine(Connexion connect, String originNodeIdConcept, String BToriginNode, String originIdDomain, String targetNodeIdConcept, String idThesaurus, int idUser) {
try {
Connection conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
ConceptHelper conceptHelper = new ConceptHelper();
// au concept la relation TT
if (!conceptHelper.moveBranchFromMT(conn, originNodeIdConcept, targetNodeIdConcept, originIdDomain, idThesaurus, idUser)) {
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.ConceptHelper in project opentheso by miledrousset.
the class Rest method brancheOfConceptsToSkosFromDate.
/**
* Fonction qui permet de récupérer les concepts à partir d'une date donnée
* (modifiés ou crées)
*
* @param idConcept
* @param idThesaurus
* @return skos
*/
private StringBuffer brancheOfConceptsToSkosFromDate(String idTheso, String date) {
if (ds == null) {
return null;
}
nodePreference = new PreferencesHelper().getThesaurusPreference(ds, idTheso);
if (nodePreference == null) {
return null;
}
ArrayList<String> tabId;
ArrayList<ArrayList<String>> multiTabId = new ArrayList<>();
ConceptHelper conceptHelper = new ConceptHelper();
tabId = conceptHelper.getConceptsDelta(ds, idTheso, date);
if (tabId == null) {
ds.close();
return null;
}
if (tabId.isEmpty()) {
ds.close();
return new StringBuffer("");
}
multiTabId.add(tabId);
ExportFromBDD exportFromBDD = new ExportFromBDD();
exportFromBDD.setServerArk(nodePreference.getServeurArk());
exportFromBDD.setServerAdress(nodePreference.getCheminSite());
exportFromBDD.setNodePreference(nodePreference);
StringBuffer skos = exportFromBDD.exportConceptByLot(ds, idTheso, multiTabId);
return skos;
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class ExportFromBDD method exportConcept.
/**
* Fonction permettant d'exporter Un concept
*
* @param ds
* @param idThesaurus
* @param idConcept
* @return Le Skos en String
*/
public StringBuffer exportConcept(HikariDataSource ds, String idThesaurus, String idConcept) {
WriteFileSKOS writeFileSKOS = new WriteFileSKOS();
// inititialisation des URI
writeFileSKOS.setServerArk(serverArk);
writeFileSKOS.setServerAdress(serverAdress);
writeFileSKOS.setNodePreference(nodePreference);
writeFileSKOS.writeHeader();
ConceptHelper conceptHelper = new ConceptHelper();
NodeConceptExport nodeConcept = conceptHelper.getConceptForExport(ds, idConcept, idThesaurus, isArkActive);
if (nodeConcept == null)
return null;
writeFileSKOS.writeDescriptor(nodeConcept, null);
writeFileSKOS.endSkos();
return writeFileSKOS.getSkosBuff();
}
Aggregations