Search in sources :

Example 1 with NodeGroupTraductions

use of mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions in project opentheso by miledrousset.

the class GroupHelper method getAllGroupTraduction.

/**
 * Cette fonction permet de retourner les traductions d'un domaine
 *
 * @param ds
 * @param idGroup
 * @param idThesaurus
 * @return
 */
public ArrayList<NodeGroupTraductions> getAllGroupTraduction(HikariDataSource ds, String idGroup, String idThesaurus) {
    Connection conn;
    Statement stmt;
    ArrayList<NodeGroupTraductions> nodeGroupTraductionsList = null;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select lang, lexicalvalue, created, modified from concept_group_label " + "where idgroup = '" + idGroup + "'" + " and idthesaurus = '" + idThesaurus + "'";
                ResultSet resultSet = stmt.executeQuery(query);
                if (resultSet != null) {
                    nodeGroupTraductionsList = new ArrayList<>();
                    while (resultSet.next()) {
                        NodeGroupTraductions nodeGroupTraductions = new NodeGroupTraductions();
                        // cas du Group non traduit
                        nodeGroupTraductions.setIdLang(resultSet.getString("lang"));
                        nodeGroupTraductions.setTitle(resultSet.getString("lexicalvalue"));
                        nodeGroupTraductions.setCreated(resultSet.getDate("created"));
                        nodeGroupTraductions.setModified(resultSet.getDate("modified"));
                        nodeGroupTraductionsList.add(nodeGroupTraductions);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting All traduction of Group : " + idGroup, sqle);
    }
    return nodeGroupTraductionsList;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NodeGroupTraductions(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions)

Example 2 with NodeGroupTraductions

use of mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions in project opentheso by miledrousset.

the class SelectedTerme method majLangueGroup.

private void majLangueGroup() {
    langues = new ArrayList<>();
    ArrayList<NodeGroupTraductions> tempNGT = new GroupHelper().getGroupTraduction(connect.getPoolConnexion(), idC, idTheso, idlangue);
    HashMap<String, String> tempMapL = new HashMap<>();
    for (NodeGroupTraductions ngt : tempNGT) {
        tempMapL.put(ngt.getIdLang(), ngt.getTitle());
    }
    langues.addAll(tempMapL.entrySet());
}
Also used : HashMap(java.util.HashMap) PrefixString(com.k_int.IR.QueryModels.PrefixString) NodeGroupTraductions(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper)

Example 3 with NodeGroupTraductions

use of mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions in project opentheso by miledrousset.

the class GroupHelper method getGroupTraduction.

/**
 * Cette fonction permet de retourner les traductions d'un domaine sans
 * celle qui est en cours
 *
 * @param ds
 * @param idGroup
 * @param idThesaurus
 * @param idLang
 * @return
 */
public ArrayList<NodeGroupTraductions> getGroupTraduction(HikariDataSource ds, String idGroup, String idThesaurus, String idLang) {
    Connection conn;
    Statement stmt;
    ArrayList<NodeGroupTraductions> nodeGroupTraductionsList = null;
    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {
                String query = "select lang, lexicalvalue from concept_group_label " + "where idgroup = '" + idGroup + "'" + " and idthesaurus = '" + idThesaurus + "'" + " and lang != '" + idLang + "'";
                ResultSet resultSet = stmt.executeQuery(query);
                if (resultSet != null) {
                    nodeGroupTraductionsList = new ArrayList<>();
                    while (resultSet.next()) {
                        NodeGroupTraductions nodeGroupTraductions = new NodeGroupTraductions();
                        // cas du Group non traduit
                        nodeGroupTraductions.setIdLang(resultSet.getString("lang"));
                        nodeGroupTraductions.setTitle(resultSet.getString("lexicalvalue"));
                        nodeGroupTraductionsList.add(nodeGroupTraductions);
                    }
                }
            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting traduction of Group : " + idGroup, sqle);
    }
    return nodeGroupTraductionsList;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) NodeGroupTraductions(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions)

Example 4 with NodeGroupTraductions

use of mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions in project opentheso by miledrousset.

the class SelectedTerme method creerTradterme.

/**
 * Ajoute une traduction au terme courant et met l'affichage à jour
 */
public void creerTradterme() {
    if (valueEdit == null || valueEdit.trim().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error3")));
        return;
    }
    boolean tradExist = false;
    // c'est le cas ou le concept n'a pas de traduction dans la langue en cours, il faut le mettre a jour dans l'arbre
    boolean newTraduction = false;
    for (Entry<String, String> e : langues) {
        if (e.getKey().equals(langueEdit)) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
            tradExist = true;
            break;
        }
    }
    ConceptHelper ch = new ConceptHelper();
    TermHelper termHelper = new TermHelper();
    if (idT.isEmpty()) {
        newTraduction = true;
        String tmp = termHelper.getIdTermOfConcept(connect.getPoolConnexion(), idC, idTheso);
        if (tmp != null) {
            idT = tmp;
        }
    }
    // traduction du domaine
    if (type == 1 && !tradExist) {
        ConceptGroupLabel cgl = new ConceptGroupLabel();
        cgl.setLexicalvalue(valueEdit);
        cgl.setIdgroup(idDomaine);
        cgl.setIdthesaurus(idTheso);
        cgl.setLang(langueEdit);
        GroupHelper cgh = new GroupHelper();
        if (cgh.isDomainExist(connect.getPoolConnexion(), cgl.getLexicalvalue(), cgl.getIdthesaurus(), cgl.getLang())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
            return;
        }
        if (!cgh.addGroupTraduction(connect.getPoolConnexion(), cgl, user.getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
            return;
        }
        ArrayList<NodeGroupTraductions> tempNGT = new GroupHelper().getGroupTraduction(connect.getPoolConnexion(), idDomaine, idTheso, idlangue);
        langues = new ArrayList<>();
        HashMap<String, String> tempMapL = new HashMap<>();
        for (NodeGroupTraductions ngt : tempNGT) {
            tempMapL.put(ngt.getIdLang(), ngt.getTitle());
        }
        if (newTraduction) {
            nom = cgh.getLexicalValueOfGroup(connect.getPoolConnexion(), idDomaine, idTheso, idlangue);
        }
        langues.addAll(tempMapL.entrySet());
    // traduction du TT
    } else if (type == 2 && !tradExist) {
        Term terme = new Term();
        terme.setId_thesaurus(idTheso);
        terme.setLang(langueEdit);
        terme.setLexical_value(valueEdit);
        terme.setId_term(idT);
        terme.setContributor(user.getUser().getId());
        terme.setCreator(user.getUser().getId());
        terme.setSource("");
        terme.setStatus("");
        if (termHelper.isTermExist(connect.getPoolConnexion(), terme.getLexical_value(), terme.getId_thesaurus(), terme.getLang())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
            return;
        }
        if (!ch.addTopConceptTraduction(connect.getPoolConnexion(), terme, user.getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
            return;
        }
        ArrayList<NodeTermTraduction> tempNTT = termHelper.getTraductionsOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue);
        langues = new ArrayList<>();
        HashMap<String, String> tempMapL = new HashMap<>();
        for (NodeTermTraduction ntt : tempNTT) {
            tempMapL.put(ntt.getLang(), ntt.getLexicalValue());
        }
        if (newTraduction) {
            nom = termHelper.getThisTerm(connect.getPoolConnexion(), idC, idTheso, idlangue).getLexical_value();
        }
        langues.addAll(tempMapL.entrySet());
    // traduction des concepts
    } else if (type == 3 && !tradExist) {
        Term terme = new Term();
        terme.setId_thesaurus(idTheso);
        terme.setLang(langueEdit);
        terme.setLexical_value(valueEdit);
        terme.setId_term(idT);
        terme.setContributor(user.getUser().getId());
        terme.setCreator(user.getUser().getId());
        terme.setSource("");
        terme.setStatus("");
        if (termHelper.isTermExist(connect.getPoolConnexion(), terme.getLexical_value(), terme.getId_thesaurus(), terme.getLang())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error4")));
            return;
        }
        if (!ch.addConceptTraduction(connect.getPoolConnexion(), terme, user.getUser().getId())) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error")));
            return;
        }
        ArrayList<NodeTermTraduction> tempNTT = termHelper.getTraductionsOfConcept(connect.getPoolConnexion(), idC, idTheso, idlangue);
        langues = new ArrayList<>();
        HashMap<String, String> tempMapL = new HashMap<>();
        for (NodeTermTraduction ntt : tempNTT) {
            tempMapL.put(ntt.getLang(), ntt.getLexicalValue());
        }
        langues.addAll(tempMapL.entrySet());
        if (newTraduction) {
            nom = termHelper.getThisTerm(connect.getPoolConnexion(), idC, idTheso, idlangue).getLexical_value();
        }
    }
    langueEdit = "";
    valueEdit = "";
    if (!tradExist) {
        vue.setAddTrad(0);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("sTerme.info2")));
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) HashMap(java.util.HashMap) ConceptGroupLabel(mom.trd.opentheso.bdd.datas.ConceptGroupLabel) ArrayList(java.util.ArrayList) PrefixString(com.k_int.IR.QueryModels.PrefixString) Term(mom.trd.opentheso.bdd.datas.Term) NodeTermTraduction(mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction) NodeGroupTraductions(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions) FacesMessage(javax.faces.application.FacesMessage) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) TermHelper(mom.trd.opentheso.bdd.helper.TermHelper)

Example 5 with NodeGroupTraductions

use of mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions in project opentheso by miledrousset.

the class ExportRdf4jHelper method writeGroupInfo.

private void writeGroupInfo(SKOSResource sKOSResource, String idThesaurus, String idOfGroupChildren, List<NodeLang> selectedLanguages) {
    NodeGroupLabel nodeGroupLabel;
    nodeGroupLabel = new GroupHelper().getNodeGroupLabel(ds, idOfGroupChildren, idThesaurus);
    sKOSResource.setUri(getUriFromId(idOfGroupChildren));
    sKOSResource.setProperty(SKOSProperty.ConceptGroup);
    for (NodeGroupTraductions traduction : nodeGroupLabel.getNodeGroupTraductionses()) {
        boolean isInSelectedLanguages = false;
        for (NodeLang nodeLang : selectedLanguages) {
            if (nodeLang.getCode().equals(traduction.getIdLang())) {
                isInSelectedLanguages = true;
                break;
            }
        }
        if (!isInSelectedLanguages) {
            continue;
        }
        sKOSResource.addLabel(traduction.getTitle(), traduction.getIdLang(), SKOSProperty.prefLabel);
        // dates
        String created;
        String modified;
        created = traduction.getCreated().toString();
        modified = traduction.getModified().toString();
        if (created != null) {
            sKOSResource.addDate(created, SKOSProperty.created);
        }
        if (modified != null) {
            sKOSResource.addDate(modified, SKOSProperty.modified);
        }
    }
    ArrayList<String> childURI = new GroupHelper().getListGroupChildIdOfGroup(ds, idOfGroupChildren, idThesaurus);
    ArrayList<NodeUri> nodeUris = new ConceptHelper().getListIdsOfTopConceptsForExport(ds, idOfGroupChildren, idThesaurus);
    for (NodeUri nodeUri : nodeUris) {
        sKOSResource.addRelation(getUriFromNodeUri(nodeUri, idThesaurus), SKOSProperty.member);
        addMember(nodeUri.getIdConcept(), idThesaurus, sKOSResource);
    }
    for (String id : childURI) {
        sKOSResource.addRelation(getUriFromId(id), SKOSProperty.subGroup);
        superGroupHashMap.put(id, idOfGroupChildren);
    }
    // addNotes(idOfGroupChildren, group, selectedLanguages);
    // addGPS(idOfGroupChildren, group);
    // addAlignement(idOfGroupChildren, group);
    // addRelation(idOfGroupChildren, group);
    String idSuperGroup = superGroupHashMap.get(idOfGroupChildren);
    if (idSuperGroup != null) {
        sKOSResource.addRelation(getUriFromId(idSuperGroup), SKOSProperty.superGroup);
        superGroupHashMap.remove(idOfGroupChildren);
    }
    skosXmlDocument.addGroup(sKOSResource);
    // liste top concept
    nodeTTs.addAll(nodeUris);
    for (NodeUri topConcept : nodeTTs) {
        skosXmlDocument.getConceptScheme().addRelation(getUriFromNodeUri(topConcept, idThesaurus), SKOSProperty.hasTopConcept);
    }
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) NodeGroupLabel(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel) NodeLang(mom.trd.opentheso.bdd.helper.nodes.NodeLang) NodeUri(mom.trd.opentheso.bdd.helper.nodes.NodeUri) GroupHelper(mom.trd.opentheso.bdd.helper.GroupHelper) NodeGroupTraductions(mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions)

Aggregations

NodeGroupTraductions (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupTraductions)6 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)3 PrefixString (com.k_int.IR.QueryModels.PrefixString)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 HashMap (java.util.HashMap)2 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)2 NodeGroupLabel (mom.trd.opentheso.bdd.helper.nodes.group.NodeGroupLabel)2 ArrayList (java.util.ArrayList)1 FacesMessage (javax.faces.application.FacesMessage)1 ConceptGroupLabel (mom.trd.opentheso.bdd.datas.ConceptGroupLabel)1 Term (mom.trd.opentheso.bdd.datas.Term)1 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)1 NodeLang (mom.trd.opentheso.bdd.helper.nodes.NodeLang)1 NodeUri (mom.trd.opentheso.bdd.helper.nodes.NodeUri)1 NodeTermTraduction (mom.trd.opentheso.bdd.helper.nodes.term.NodeTermTraduction)1