Search in sources :

Example 1 with RelationsHelper

use of mom.trd.opentheso.bdd.helper.RelationsHelper in project opentheso by miledrousset.

the class AutoCompletBean method newRelationNT.

/**
 * Permet d'ajouter une relation terme spécifique NT pour un concept
 * #MR
 */
public void newRelationNT() {
    createValid = false;
    if ((terme.getSelectedTermComp() == null) || (terme.getSelectedTermComp().getIdConcept() == null) || (terme.getSelectedTermComp().getIdConcept().isEmpty())) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("tree.error1")));
        return;
    }
    // vérification si la relation est cohérente (NT et RT à la fois ?)
    if (!isAddRelationNTValid(terme.getIdC(), terme.getSelectedTermComp().getIdConcept())) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("relation.errorNTRT")));
        return;
    }
    RelationsHelper relationsHelper = new RelationsHelper();
    if (!relationsHelper.addRelationNT(connect.getPoolConnexion(), terme.getIdC(), terme.getIdTheso(), terme.getSelectedTermComp().getIdConcept(), terme.getUser().getUser().getId())) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error")));
        return;
    }
    tree.reInit();
    tree.reExpand();
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", terme.getSelectedTermComp().getIdConcept() + " " + langueBean.getMsg("tree.info1")));
    terme.setSelectedTermComp(new NodeAutoCompletion());
    createValid = true;
}
Also used : FacesMessage(javax.faces.application.FacesMessage) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper) NodeAutoCompletion(mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)

Example 2 with RelationsHelper

use of mom.trd.opentheso.bdd.helper.RelationsHelper in project opentheso by miledrousset.

the class ExportRdf4jHelper method addMember.

private void addMember(String id, String idThesaurus, SKOSResource resource) {
    RelationsHelper relationsHelper = new RelationsHelper();
    ArrayList<NodeHieraRelation> listChildren = relationsHelper.getListNT(ds, id, idThesaurus);
    for (NodeHieraRelation idChildren : listChildren) {
        // System.out.println(idChildren.getUri().getIdConcept());
        resource.addRelation(getUriFromNodeUri(idChildren.getUri(), idThesaurus), SKOSProperty.member);
        addMember(idChildren.getUri().getIdConcept(), idThesaurus, resource);
    }
}
Also used : NodeHieraRelation(mom.trd.opentheso.bdd.helper.nodes.NodeHieraRelation) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper)

Example 3 with RelationsHelper

use of mom.trd.opentheso.bdd.helper.RelationsHelper in project opentheso by miledrousset.

the class WriteBranchSkosBDD method writeFirstConcept.

public boolean writeFirstConcept(SKOSResource resource, String idConcept, String idGroup, String idThesaurus, String id_langueSource, String dateFormat, String adressSite, boolean useArk, int idUser) {
    RelationsHelper relationsHelper = new RelationsHelper();
    try {
        relationsHelper.addRelationBT(ds.getConnection(), getId(getId(resource.getUri())), idThesaurus, idConcept, idUser);
    } catch (SQLException ex) {
        Logger.getLogger(WriteBranchSkosBDD.class.getName()).log(Level.SEVERE, null, ex);
        return false;
    }
    // ajout du concept dans la base
    Concept concept = new Concept();
    ConceptHelper conceptHelper = new ConceptHelper();
    if (idConcept.trim().isEmpty())
        return false;
    if (idGroup.trim().isEmpty())
        return false;
    String idC = getId(resource.getUri());
    concept.setIdConcept(idC);
    // concept.setCreated(null);
    concept.setIdThesaurus(idThesaurus);
    concept.setNotation("");
    concept.setStatus("");
    concept.setTopConcept(false);
    concept.setIdGroup(idGroup);
    concept = addDates(resource.getDateList(), concept, dateFormat);
    conceptHelper.insertConceptInTable(ds, concept, idUser);
    // ajout des termes et traductions
    NodeTerm nodeTerm = new NodeTerm();
    nodeTerm.setNodeTermTraduction(getTraductionConcept(resource.getLabelsList()));
    nodeTerm.setIdTerm(idC);
    nodeTerm.setIdConcept(idC);
    nodeTerm.setIdThesaurus(idThesaurus);
    nodeTerm.setSource("");
    nodeTerm.setStatus("");
    nodeTerm = addDatesTerm(resource.getDateList(), nodeTerm, dateFormat);
    TermHelper termHelper = new TermHelper();
    termHelper.insertTerm(ds, nodeTerm, idUser);
    // ajouter les notes
    ArrayList<NodeNote> nodeNoteList = addNotes(resource.getDocumentationsList());
    NoteHelper noteHelper = new NoteHelper();
    for (NodeNote nodeNoteList1 : nodeNoteList) {
        if (nodeNoteList1.getNotetypecode().contains("scopeNote")) {
            noteHelper.addConceptNote(ds, concept.getIdConcept(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
        }
        if (nodeNoteList1.getNotetypecode().contains("historyNote")) {
            noteHelper.addConceptNote(ds, concept.getIdConcept(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
        }
        if (nodeNoteList1.getNotetypecode().contains("definition")) {
            noteHelper.addTermNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
        }
        if (nodeNoteList1.getNotetypecode().contains("editorialNote")) {
            noteHelper.addTermNote(ds, nodeTerm.getIdTerm(), nodeNoteList1.getLang(), idThesaurus, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
        }
    }
    // Enregistrer les relations sans les BT
    writeFirstRelationsList(resource.getRelationsList(), concept.getIdConcept(), idThesaurus, idUser);
    ArrayList<SKOSMapping> sKOSMappings = resource.getMappings();
    // Enregistrer les Mappings (alignements)
    AlignmentHelper alignmentHelper = new AlignmentHelper();
    for (SKOSMapping sKOSMapping : sKOSMappings) {
        if (sKOSMapping.getProperty() == SKOSProperty.exactMatch) {
            alignmentHelper.addNewAlignment(ds, // user
            1, // concept target
            "", // thesaurus target
            "", // URI
            sKOSMapping.getTargetUri(), 1, concept.getIdConcept(), idThesaurus, 0);
        }
        if (sKOSMapping.getProperty() == SKOSProperty.closeMatch) {
            alignmentHelper.addNewAlignment(ds, // user
            1, // concept target
            "", // thesaurus target
            "", // URI
            sKOSMapping.getTargetUri(), 2, concept.getIdConcept(), idThesaurus, 0);
        }
    }
    // Ajouter l'id du concept importé pour l'aligner avec le thésaurus source
    alignmentHelper.addNewAlignment(ds, // user
    1, // concept target
    "", // thesaurus target
    "", // URI de la source
    resource.getUri(), // sKOSMapping.getTargetUri(), // URI
    1, concept.getIdConcept(), idThesaurus, 0);
    // Enregister les synonymes et traductions
    ArrayList<NodeEM> nodeEMs = writeLabelsList(ds, resource.getLabelsList());
    Term term = new Term();
    for (int i = 0; i < nodeEMs.size(); i++) {
        term.setId_concept(concept.getIdConcept());
        term.setId_term(nodeTerm.getIdTerm());
        term.setLexical_value(nodeEMs.get(i).getLexical_value());
        term.setLang(nodeEMs.get(i).getLang());
        term.setId_thesaurus(idThesaurus);
        term.setSource(nodeEMs.get(i).getSource());
        term.setStatus(nodeEMs.get(i).getStatus());
        termHelper.addNonPreferredTerm(ds, term, idUser);
    }
    return true;
}
Also used : SKOSTopConcept(skos.SKOSTopConcept) Concept(mom.trd.opentheso.bdd.datas.Concept) ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeTerm(mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm) SQLException(java.sql.SQLException) NoteHelper(mom.trd.opentheso.bdd.helper.NoteHelper) AlignmentHelper(mom.trd.opentheso.bdd.helper.AlignmentHelper) Term(mom.trd.opentheso.bdd.datas.Term) NodeTerm(mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote) SKOSMapping(skos.SKOSMapping) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 4 with RelationsHelper

use of mom.trd.opentheso.bdd.helper.RelationsHelper in project opentheso by miledrousset.

the class ImportRdf4jHelper method finalizeAddConceptStruct.

private void finalizeAddConceptStruct(AddConceptsStruct acs) throws SQLException {
    acs.termHelper.insertTerm(ds, acs.nodeTerm, idUser);
    RelationsHelper relationsHelper = new RelationsHelper();
    for (HierarchicalRelationship hierarchicalRelationship : acs.hierarchicalRelationships) {
        if (!relationsHelper.insertHierarchicalRelation(ds, hierarchicalRelationship.getIdConcept1(), hierarchicalRelationship.getIdThesaurus(), hierarchicalRelationship.getRole(), hierarchicalRelationship.getIdConcept2())) {
            // System.out.println("Erreur sur la relation = " + acs.concept.getIdConcept() + " ## " + hierarchicalRelationship.getRole());
            message.append(System.getProperty("line.separator"));
            message.append("Erreur sur la relation = ");
            message.append(acs.concept.getIdConcept());
            message.append(" ## ");
            message.append(hierarchicalRelationship.getRole());
        }
    }
    // For Term : definition; editorialNote; historyNote;
    for (NodeNote nodeNoteList1 : acs.nodeNotes) {
        if (nodeNoteList1.getNotetypecode().equals("customnote") || nodeNoteList1.getNotetypecode().equals("scopeNote") || nodeNoteList1.getNotetypecode().equals("historyNote") || nodeNoteList1.getNotetypecode().equals("note")) {
            acs.noteHelper.addConceptNote(ds, acs.concept.getIdConcept(), nodeNoteList1.getLang(), idTheso, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
        }
        if (nodeNoteList1.getNotetypecode().equals("definition") || nodeNoteList1.getNotetypecode().equals("editorialNote")) {
            acs.noteHelper.addTermNote(ds, acs.nodeTerm.getIdTerm(), nodeNoteList1.getLang(), idTheso, nodeNoteList1.getLexicalvalue(), nodeNoteList1.getNotetypecode(), idUser);
        }
    }
    for (NodeAlignment nodeAlignment : acs.nodeAlignments) {
        acs.alignmentHelper.addNewAlignment(ds, nodeAlignment);
    }
    for (NodeEM nodeEMList1 : acs.nodeEMList) {
        acs.term.setId_concept(acs.concept.getIdConcept());
        acs.term.setId_term(acs.nodeTerm.getIdTerm());
        acs.term.setLexical_value(nodeEMList1.getLexical_value());
        acs.term.setLang(nodeEMList1.getLang());
        acs.term.setId_thesaurus(thesaurus.getId_thesaurus());
        acs.term.setSource(nodeEMList1.getSource());
        acs.term.setStatus(nodeEMList1.getStatus());
        acs.termHelper.addNonPreferredTerm(ds, acs.term, idUser);
    }
    if (acs.nodeGps.getLatitude() != null && acs.nodeGps.getLongitude() != null) {
        // insertion des données GPS
        acs.gpsHelper.insertCoordonees(ds, acs.concept.getIdConcept(), thesaurus.getId_thesaurus(), acs.nodeGps.getLatitude(), acs.nodeGps.getLongitude());
    }
    for (String idTopConcept1 : idTopConcept) {
        if (!acs.conceptHelper.setTopConcept(ds, idTopConcept1, thesaurus.getId_thesaurus())) {
        // erreur;
        }
    }
    // initialisation des variables
    acs.concept = new Concept();
    acs.nodeTerm = new NodeTerm();
    acs.nodeTermTraductionList = new ArrayList<>();
    acs.nodeEMList = new ArrayList<>();
    acs.nodeNotes = new ArrayList<>();
    acs.nodeAlignments = new ArrayList<>();
    acs.hierarchicalRelationships = new ArrayList<>();
    acs.idGrps = new ArrayList<>();
    acs.isTopConcept = false;
    acs.nodeGps = new NodeGps();
}
Also used : Concept(mom.trd.opentheso.bdd.datas.Concept) NodeAlignment(mom.trd.opentheso.bdd.helper.nodes.NodeAlignment) NodeTerm(mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm) HierarchicalRelationship(mom.trd.opentheso.bdd.datas.HierarchicalRelationship) NodeGps(mom.trd.opentheso.bdd.helper.nodes.NodeGps) NodeNote(mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote) RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper) NodeEM(mom.trd.opentheso.bdd.helper.nodes.NodeEM)

Example 5 with RelationsHelper

use of mom.trd.opentheso.bdd.helper.RelationsHelper in project opentheso by miledrousset.

the class SelectedTerme method delAsso.

/**
 * Supprime la relation d'association qui lie le terme courant au terme dont
 * l'id est passé en paramètre.
 *
 * @param id
 */
public void delAsso(String id) {
    if (!new RelationsHelper().deleteRelationRT(connect.getPoolConnexion(), idC, idTheso, id, user.getUser().getId())) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.info7")));
        return;
    }
    majTAsso();
    vue.setAddTAsso(0);
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sTerme.info7")));
}
Also used : RelationsHelper(mom.trd.opentheso.bdd.helper.RelationsHelper) FacesMessage(javax.faces.application.FacesMessage)

Aggregations

RelationsHelper (mom.trd.opentheso.bdd.helper.RelationsHelper)26 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)14 PrefixString (com.k_int.IR.QueryModels.PrefixString)11 NodeNT (mom.trd.opentheso.bdd.helper.nodes.NodeNT)10 SQLException (java.sql.SQLException)8 HashMap (java.util.HashMap)8 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)8 Connection (java.sql.Connection)7 Concept (mom.trd.opentheso.bdd.datas.Concept)7 ArrayList (java.util.ArrayList)5 FacesMessage (javax.faces.application.FacesMessage)5 OrphanHelper (mom.trd.opentheso.bdd.helper.OrphanHelper)5 Term (mom.trd.opentheso.bdd.datas.Term)4 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)4 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)4 NodeBT (mom.trd.opentheso.bdd.helper.nodes.NodeBT)4 NodeEM (mom.trd.opentheso.bdd.helper.nodes.NodeEM)3 NodeNote (mom.trd.opentheso.bdd.helper.nodes.notes.NodeNote)3 NodeTerm (mom.trd.opentheso.bdd.helper.nodes.term.NodeTerm)3 HierarchicalRelationship (mom.trd.opentheso.bdd.datas.HierarchicalRelationship)2