use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class SelectedThesaurus method generateAllInexistantArkId.
/**
* Permet de générere les identifiants Ark manquants
*
* @param idTheso #MR
*/
public void generateAllInexistantArkId(String idTheso) {
ConceptHelper conceptHelper = new ConceptHelper();
try {
ArrayList<String> idGroup = null;
// concept
try {
ArrayList<String> idConcepts = conceptHelper.getAllIdConceptOfThesaurusWithoutArk(connect.getPoolConnexion(), idTheso);
if (idConcepts == null || idConcepts.isEmpty()) {
throw new Exception("No concept in this thesaurus");
}
regenArkIdConcept(idTheso, idConcepts);
} catch (Exception ex) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error while regen id concept:", ex.getMessage()));
throw new Exception("Error while regen id concept ");
}
maj();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Info :", "Regen id finished"));
} catch (SQLException ex) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "SQL Error :", ex.getMessage()));
} catch (Exception ex) {
}
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class SelectedThesaurus method regenIdConcept.
/**
* Cette fonction remplace tout les id des concepts du théso
*/
private void regenIdConcept(Connection conn, String idTheso, ArrayList<String> idGroup) throws Exception {
/*récup les concepts*/
ConceptHelper conceptHelper = new ConceptHelper();
ArrayList<String> idConcepts = conceptHelper.getAllIdConceptOfThesaurus(conn, idTheso);
if (idConcepts == null || idConcepts.isEmpty()) {
throw new Exception("No concept in this thesaurus");
}
/*génération des nouveaux id*/
ArrayList<String> reservedId = idConcepts;
reservedId.addAll(idGroup);
ArrayList<String> newIdConcepts = createNewId(reservedId, idConcepts.size());
/*maj des tables*/
NoteHelper noteHelper = new NoteHelper();
GpsHelper gpsHelper = new GpsHelper();
ImagesHelper imagesHelper = new ImagesHelper();
AlignmentHelper alignmentHelper = new AlignmentHelper();
for (int i = 0; i < idConcepts.size(); i++) {
String id = idConcepts.get(i);
String newId = newIdConcepts.get(i);
// table concept
conceptHelper.setIdConcept(conn, idTheso, id, newId);
// table concept_group_concept
conceptHelper.setIdConceptGroupConcept(conn, idTheso, id, newId);
// table concept_historique
conceptHelper.setIdConceptHistorique(conn, idTheso, id, newId);
// table concept_orphan
conceptHelper.setIdConceptOrphan(conn, idTheso, id, newId);
// table gps
gpsHelper.setIdConceptGPS(conn, idTheso, id, newId);
// table hierarchical_relationship
conceptHelper.setIdConceptHieraRelation(conn, idTheso, id, newId);
// table hierarchical_relationship_historique
conceptHelper.setIdConceptHieraRelationHisto(conn, idTheso, id, newId);
// table note
noteHelper.setIdConceptNote(conn, idTheso, id, newId);
// table note_historique
noteHelper.setIdConceptNoteHisto(conn, idTheso, id, newId);
// table images
imagesHelper.setIdConceptImage(conn, idTheso, id, newId);
// table concept_fusion
conceptHelper.setIdConceptFusion(conn, idTheso, id, newId);
// table preferred_term
conceptHelper.setIdConceptPreferedTerm(conn, idTheso, id, newId);
// table alignement
alignmentHelper.setIdConceptAlignement(conn, idTheso, id, newId);
}
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class NewTreeBean method deleteOrphanBranch.
/**
* Fonction recursive qui permet de supprimer une branche d'orphelins un
* concept de tête et thesaurus. La suppression est descendante qui ne
* supprime pas les autres branches remontantes.
*
* @param conn
* @param idConcept
* @param idTheso
* @return
*/
private boolean deleteOrphanBranch(HikariDataSource ds, String idConcept, String idTheso, int idUser) {
ConceptHelper conceptHelper = new ConceptHelper();
ArrayList<String> listIdsOfConceptChildren = conceptHelper.getListChildrenOfConcept(ds, idConcept, idTheso);
if (!conceptHelper.deleteConceptForced(ds, idConcept, idTheso, idUser)) {
return false;
}
for (String listIdsOfConceptChildren1 : listIdsOfConceptChildren) {
// if(!conceptHelper.deleteConceptForced(ds, listIdsOfConceptChildren1, idTheso, idUser))
// return false;
deleteOrphanBranch(ds, listIdsOfConceptChildren1, idTheso, idUser);
}
return true;
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class NewTreeBean method reExpandChild.
private void reExpandChild(ArrayList<String> listeId, TreeNode node, int cpt) {
if (!node.isExpanded()) {
ArrayList<NodeConceptTree> listeConcept;
ArrayList<NodeConceptTree> listeSubGroup = new ArrayList<>();
ArrayList<String> idGroupList;
ConceptHelper conceptHelper = new ConceptHelper();
GroupHelper groupHelper = new GroupHelper();
int type = 3;
if (node.getChildCount() == 1) {
node.getChildren().remove(0);
}
MyTreeNode myTreeNode = (MyTreeNode) node;
String idConcept = myTreeNode.getIdConcept();
if (groupHelper.isIdOfGroup(connect.getPoolConnexion(), idConcept, myTreeNode.getIdTheso())) {
// pour group ?
myTreeNode.setTypeConcept(1);
myTreeNode.setIsGroup(true);
listeSubGroup = groupHelper.getRelationGroupOf(connect.getPoolConnexion(), idConcept, myTreeNode.getIdTheso(), myTreeNode.getLangue());
if (listeSubGroup == null) {
listeSubGroup = new ArrayList<>();
}
// pour récupérer les concepts mélangés avec les Sous_Groupes
listeConcept = conceptHelper.getListTopConcepts(connect.getPoolConnexion(), idConcept, myTreeNode.getIdTheso(), myTreeNode.getLangue());
} else {
listeConcept = conceptHelper.getListConcepts(connect.getPoolConnexion(), idConcept, myTreeNode.getIdTheso(), myTreeNode.getLangue());
// myTreeNode.setIsTopConcept(true);
}
TreeNode treeNode = null;
String value = "";
String idTC = "";
String icon;
boolean isTopTerm;
/**
* Ajout des Groupes (MT, C, G, T ..)
*/
for (NodeConceptTree nodeConceptTreeGroup : listeSubGroup) {
value = nodeConceptTreeGroup.getTitle();
if (groupHelper.haveSubGroup(connect.getPoolConnexion(), nodeConceptTreeGroup.getIdThesaurus(), nodeConceptTreeGroup.getIdConcept()) || nodeConceptTreeGroup.isHaveChildren()) {
icon = getTypeOfSubGroup(myTreeNode.getTypeDomaine());
treeNode = new MyTreeNode(1, nodeConceptTreeGroup.getIdConcept(), myTreeNode.getIdTheso(), myTreeNode.getLangue(), myTreeNode.getIdCurrentGroup(), myTreeNode.getTypeDomaine(), idTC, icon, value, myTreeNode);
((MyTreeNode) treeNode).setIsSubGroup(true);
((MyTreeNode) treeNode).setIdCurrentGroup(nodeConceptTreeGroup.getIdConcept());
new DefaultTreeNode("fake", treeNode);
/**
*code poour la numérotation des sous groupes ***
*/
((MyTreeNode) treeNode).setPrefix(((MyTreeNode) node).getNumerotation());
String suffix = groupHelper.getSuffixFromNode(connect.getPoolConnexion(), nodeConceptTreeGroup.getIdThesaurus(), nodeConceptTreeGroup.getIdConcept());
if (suffix.length() < 2)
suffix = "0" + suffix;
((MyTreeNode) treeNode).setSuffix(suffix);
((MyTreeNode) treeNode).setData(((MyTreeNode) treeNode).getNumerotation() + " " + treeNode.getData());
/**
*fin code numérotation des sous groupes****
*/
if (listeId.contains(((MyTreeNode) treeNode).getIdConcept()))
((MyTreeNode) treeNode).setExpanded(true);
if (listeId.get(cpt).equals(((MyTreeNode) treeNode).getIdConcept())) {
if (cpt + 1 < listeId.size()) {
treeNode.setSelected(false);
reExpandChild(listeId, treeNode, cpt + 1);
} else {
treeNode.setSelected(true);
selectedNode = treeNode;
selectedNodes.add(treeNode);
}
}
}
}
// Ajout dans l'arbre
for (NodeConceptTree nodeConceptTree : listeConcept) {
isTopTerm = false;
if (conceptHelper.haveChildren(connect.getPoolConnexion(), nodeConceptTree.getIdThesaurus(), nodeConceptTree.getIdConcept()) || nodeConceptTree.isHaveChildren()) {
icon = "dossier";
if (nodeConceptTree.isIsGroup()) {
icon = "domaine";
// String type = getTypeOfGroup(typeCode);
} else if (nodeConceptTree.isIsSubGroup()) {
icon = getTypeOfSubGroup(myTreeNode.getTypeDomaine());
}
if (nodeConceptTree.isIsTopTerm()) {
// Création de topConcepts
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
value = nodeConceptTree.getTitle();
}
idTC = value;
isTopTerm = true;
} else {
// Création de concepts
idTC = ((MyTreeNode) node).getIdTopConcept();
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
value = nodeConceptTree.getTitle();
}
}
if (nodeConceptTree.getStatusConcept() != null) {
if (nodeConceptTree.getStatusConcept().equals("hidden")) {
icon = "hidden";
}
}
treeNode = new MyTreeNode(type, nodeConceptTree.getIdConcept(), ((MyTreeNode) node).getIdTheso(), ((MyTreeNode) node).getLangue(), ((MyTreeNode) node).getIdCurrentGroup(), ((MyTreeNode) node).getTypeDomaine(), idTC, icon, value, node);
if (isTopTerm) {
((MyTreeNode) treeNode).setIsTopConcept(true);
}
idGroupList = groupHelper.getListIdGroupOfConcept(connect.getPoolConnexion(), nodeConceptTree.getIdThesaurus(), nodeConceptTree.getIdConcept());
((MyTreeNode) treeNode).setOtherGroup(idGroupList);
new DefaultTreeNode("fake", treeNode);
if (listeId.get(cpt).equals(((MyTreeNode) treeNode).getIdConcept())) {
if (cpt + 1 < listeId.size()) {
treeNode.setSelected(false);
reExpandChild(listeId, treeNode, cpt + 1);
} else {
treeNode.setSelected(true);
selectedNode = treeNode;
selectedNodes.add(treeNode);
}
}
} else {
icon = "fichier";
if (nodeConceptTree.isIsTopTerm()) {
// Création de topConcepts
idTC = nodeConceptTree.getIdConcept();
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
value = nodeConceptTree.getTitle();
}
isTopTerm = true;
} else {
// Création de concepts
idTC = ((MyTreeNode) node).getIdTopConcept();
if (nodeConceptTree.getTitle().trim().isEmpty()) {
value = nodeConceptTree.getIdConcept();
} else {
value = nodeConceptTree.getTitle();
}
}
if (nodeConceptTree.getStatusConcept().equals("hidden")) {
icon = "hidden";
}
treeNode = new MyTreeNode(type, nodeConceptTree.getIdConcept(), ((MyTreeNode) node).getIdTheso(), ((MyTreeNode) node).getLangue(), ((MyTreeNode) node).getIdCurrentGroup(), ((MyTreeNode) node).getTypeDomaine(), idTC, icon, value, node);
if (isTopTerm) {
((MyTreeNode) treeNode).setIsTopConcept(true);
}
idGroupList = groupHelper.getListIdGroupOfConcept(connect.getPoolConnexion(), nodeConceptTree.getIdThesaurus(), nodeConceptTree.getIdConcept());
((MyTreeNode) treeNode).setOtherGroup(idGroupList);
if (listeId.get(cpt).equals(((MyTreeNode) treeNode).getIdConcept())) {
treeNode.setSelected(true);
selectedNode = treeNode;
selectedNodes.add(treeNode);
} else {
treeNode.setSelected(false);
}
}
}
node.setExpanded(true);
} else {
List<TreeNode> children = node.getChildren();
for (TreeNode mtn : children) {
if (listeId.get(cpt).equals(((MyTreeNode) mtn).getIdConcept())) {
if (cpt + 1 < listeId.size()) {
mtn.setSelected(false);
reExpandChild(listeId, mtn, cpt + 1);
} else {
mtn.setSelected(true);
selectedNode = mtn;
selectedNodes.add(mtn);
}
}
}
}
}
use of mom.trd.opentheso.bdd.helper.ConceptHelper in project opentheso by miledrousset.
the class NewTreeBean method loadOrphan.
public void loadOrphan(String idTheso, String langue) {
String typeNode, value = "";
/*
this.typeMot = type;
this.idMot = id;
this.idTheso = idT;
this.langue = l;
this.idDomaine = idD;
this.typeDomaine = typeDomaine;
this.idTopConcept = idTC;
*/
TreeNode dynamicTreeNode = (TreeNode) new MyTreeNode(1, null, idTheso, langue, null, null, null, "orphan", langueBean.getMsg("index.orphans"), root);
orphans = new OrphanHelper().getListOrphanId(connect.getPoolConnexion(), idTheso);
for (String idC : orphans) {
if (new ConceptHelper().haveChildren(connect.getPoolConnexion(), idTheso, idC)) {
typeNode = "dossier";
} else {
typeNode = "fichier";
}
Term term = new TermHelper().getThisTerm(connect.getPoolConnexion(), idC, idTheso, langue);
if (term != null) {
value = term.getLexical_value() + " (id_" + idC + ")";
Concept temp = new ConceptHelper().getThisConcept(connect.getPoolConnexion(), idC, idTheso);
MyTreeNode mtn = new MyTreeNode(3, idC, idTheso, langue, "Orphan", null, null, typeNode, value, dynamicTreeNode);
if (typeNode.equals("dossier")) {
new DefaultTreeNode("fake", mtn);
}
}
}
}
Aggregations