Search in sources :

Example 41 with ConceptHelper

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) {
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) SQLException(java.sql.SQLException) FacesMessage(javax.faces.application.FacesMessage) SQLException(java.sql.SQLException)

Example 42 with ConceptHelper

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);
    }
}
Also used : ImagesHelper(mom.trd.opentheso.bdd.helper.ImagesHelper) GpsHelper(mom.trd.opentheso.bdd.helper.GpsHelper) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) AlignmentHelper(mom.trd.opentheso.bdd.helper.AlignmentHelper) SQLException(java.sql.SQLException)

Example 43 with ConceptHelper

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;
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper)

Example 44 with ConceptHelper

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);
                }
            }
        }
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) ArrayList(java.util.ArrayList) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) NodeConceptTree(mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptTree) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) TreeNode(org.primefaces.model.TreeNode) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 45 with ConceptHelper

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);
            }
        }
    }
}
Also used : OrphanHelper(mom.trd.opentheso.bdd.helper.OrphanHelper) Concept(mom.trd.opentheso.bdd.datas.Concept) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) TreeNode(org.primefaces.model.TreeNode) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) DefaultTreeNode(org.primefaces.model.DefaultTreeNode) MyTreeNode(mom.trd.opentheso.bdd.helper.nodes.MyTreeNode) Term(mom.trd.opentheso.bdd.datas.Term) StructIdBroaderTerm(mom.trd.opentheso.dragdrop.StructIdBroaderTerm) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Aggregations

ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)125 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)38 SQLException (java.sql.SQLException)36 Connection (java.sql.Connection)29 ArrayList (java.util.ArrayList)28 FacesMessage (javax.faces.application.FacesMessage)23 Concept (mom.trd.opentheso.bdd.datas.Concept)18 AlignmentHelper (mom.trd.opentheso.bdd.helper.AlignmentHelper)16 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)16 Term (mom.trd.opentheso.bdd.datas.Term)15 PrefixString (com.k_int.IR.QueryModels.PrefixString)14 RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)14 HierarchicalRelationship (mom.trd.opentheso.bdd.datas.HierarchicalRelationship)13 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)12 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)12 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)12 HashMap (java.util.HashMap)9 MyTreeNode (mom.trd.opentheso.bdd.helper.nodes.MyTreeNode)9 NodeConceptExport (mom.trd.opentheso.bdd.helper.nodes.concept.NodeConceptExport)9 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)9