Search in sources :

Example 11 with Thesaurus

use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.

the class SelectedThesaurus method ajouterTraduction.

/**
 * Création d'une traduction d'un thésaurus
 */
public void ajouterTraduction() {
    if (nomTrad.trim().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error1")));
    } else {
        vue.setTrad(false);
        String id = editTheso.getId_thesaurus();
        Thesaurus thesoTemp = new Thesaurus();
        thesoTemp.setId_thesaurus(id);
        thesoTemp.setLanguage(langueTrad);
        thesoTemp.setTitle(nomTrad);
        new ThesaurusHelper().addThesaurusTraduction(connect.getPoolConnexion(), thesoTemp);
        remplirArrayTrad(editTheso.getId_thesaurus());
    }
    nomTrad = "";
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) FacesMessage(javax.faces.application.FacesMessage)

Example 12 with Thesaurus

use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.

the class WriteSkosBDD method addLangsToThesaurus.

public void addLangsToThesaurus(HikariDataSource ds, String idThesaurus) {
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    ArrayList<String> tabListLang = thesaurusHelper.getAllUsedLanguagesOfThesaurus(ds, idThesaurus);
    for (int i = 0; i < tabListLang.size(); i++) {
        if (!thesaurusHelper.isLanguageExistOfThesaurus(ds, idThesaurus, tabListLang.get(i).trim())) {
            Thesaurus thesaurus = new Thesaurus();
            thesaurus.setId_thesaurus(idThesaurus);
            thesaurus.setContributor("");
            thesaurus.setCoverage("");
            thesaurus.setCreator("");
            thesaurus.setDescription("");
            thesaurus.setFormat("");
            thesaurus.setLanguage(tabListLang.get(i));
            thesaurus.setPublisher("");
            thesaurus.setRelation("");
            thesaurus.setRights("");
            thesaurus.setSource("");
            thesaurus.setSubject("");
            thesaurus.setTitle("theso_" + idThesaurus);
            thesaurus.setType("");
            thesaurusHelper.addThesaurusTraduction(ds, thesaurus);
        }
    }
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper)

Example 13 with Thesaurus

use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.

the class WriteSkosBDD method writeThesaurus.

public void writeThesaurus(SKOSXmlDocument skosDocument, String dateFormat, boolean useArk, String adressSite, int idUser, String langueSource) {
    SKOSConceptScheme conceptScheme = skosDocument.getConceptScheme();
    ArrayList<SKOSTopConcept> topConceptsList = conceptScheme.getTopConceptsList();
    ArrayList<SKOSResource> resourcesList = skosDocument.getResourcesList();
    /*
         * Création du Thésaurus
         */
    String descriptionThesaurus = getThesaurusName(conceptScheme.getUri());
    // if(!query.thesaurusExistLangue(descriptionThesaurus, id_langueSource)) {
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    Thesaurus thesaurus = new Thesaurus();
    thesaurus.setTitle(descriptionThesaurus);
    thesaurus.setLanguage(langueSource);
    String idThesaurus = thesaurusHelper.addThesaurus(ds, thesaurus, adressSite, useArk);
    if (idThesaurus == null)
        return;
    thesaurus.setId_thesaurus(idThesaurus);
    try {
        Connection conn = ds.getConnection();
        conn.setAutoCommit(false);
        UserHelper userHelper = new UserHelper();
        int idRole = userHelper.getRoleOfUser(ds, idUser);
        if (!userHelper.addRole(conn, idUser, idRole, idThesaurus, "")) {
            conn.rollback();
            conn.close();
            return;
        }
        conn.commit();
        conn.close();
    } catch (SQLException ex) {
        Logger.getLogger(WriteSkosBDD.class.getName()).log(Level.SEVERE, null, ex);
    }
    // Si le Titre du thésaurus n'est pas detecter, on donne un nom par defaut
    if (conceptScheme.getSkosLabels().isEmpty()) {
        if (thesaurus.getTitle().isEmpty()) {
            thesaurus.setTitle("Theso_" + idThesaurus);
            thesaurusHelper.addThesaurusTraduction(ds, thesaurus);
        }
    }
    for (SKOSLabel skosLabel : conceptScheme.getSkosLabels()) {
        thesaurus.setTitle(skosLabel.getLabel());
        thesaurus.setLanguage(skosLabel.getLanguage());
        thesaurusHelper.addThesaurusTraduction(ds, thesaurus);
    }
    idsTopConcept = new ArrayList<>();
    for (SKOSResource resource : resourcesList) {
        if (resource != null) {
            if (!isDescriptor(resource, topConceptsList)) {
                // on insère un domaine
                writeDomaine(resource, idThesaurus, "fr", adressSite, useArk, idUser);
            } else {
                // on insère un concept
                writeConcept(resource, idThesaurus, "fr", dateFormat, adressSite, useArk, idUser);
            }
        }
    }
    // ici la fin du fichier on controle si le thésaurus a toutes les langues des concepts
    // Vérifier l'existence de la langue et l'ajouter si elle n'existe pas déjà
    addLangsToThesaurus(ds, idThesaurus);
}
Also used : UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) SQLException(java.sql.SQLException) Connection(java.sql.Connection) SKOSLabel(skos.SKOSLabel) SKOSResource(skos.SKOSResource) Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) SKOSConceptScheme(skos.SKOSConceptScheme) SKOSTopConcept(skos.SKOSTopConcept)

Example 14 with Thesaurus

use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.

the class ImportRdf4jHelper method addThesaurus.

/**
 * Cette fonction permet de créer un thésaurus avec ses traductions (Import)
 * elle retourne l'identifiant du thésaurus, sinon Null
 *
 * @return
 * @throws java.sql.SQLException
 */
public String addThesaurus() throws SQLException {
    thesaurus = new Thesaurus();
    SKOSResource conceptScheme = skosXmlDocument.getConceptScheme();
    String creator = null;
    String contributor = null;
    for (SKOSCreator c : conceptScheme.getCreatorList()) {
        if (c.getProperty() == SKOSProperty.creator) {
            creator = c.getCreator();
        } else if (c.getProperty() == SKOSProperty.contributor) {
            contributor = c.getCreator();
        }
    }
    thesaurus.setCreator(creator);
    thesaurus.setContributor(contributor);
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    thesaurusHelper.setIdentifierType("2");
    Connection conn = ds.getConnection();
    conn.setAutoCommit(false);
    String idTheso1;
    if (thesaurus.getLanguage() == null) {
        thesaurus.setLanguage(langueSource);
    }
    if ((idTheso1 = thesaurusHelper.addThesaurusRollBack(conn, adressSite, useArk)) == null) {
        conn.rollback();
        conn.close();
        return null;
    }
    // Si le Titre du thésaurus n'est pas detecter, on donne un nom par defaut
    if (skosXmlDocument.getConceptScheme().getLabelsList().isEmpty()) {
        if (thesaurus.getTitle().isEmpty()) {
            thesaurus.setTitle("theso_" + idTheso1);
        // thesaurusHelper.addThesaurusTraduction(ds, thesaurus);
        }
    }
    thesaurus.setId_thesaurus(idTheso1);
    this.idTheso = idTheso1;
    // boucler pour les traductions
    for (SKOSLabel label : skosXmlDocument.getConceptScheme().getLabelsList()) {
        if (thesaurus.getLanguage() == null) {
            // test
            String workLanguage = "fr";
            thesaurus.setLanguage(workLanguage);
        }
        thesaurus.setTitle(label.getLabel());
        thesaurus.setLanguage(label.getLanguage());
        if (!thesaurusHelper.addThesaurusTraductionRollBack(conn, thesaurus)) {
            conn.rollback();
            conn.close();
            return null;
        }
    }
    UserHelper userHelper = new UserHelper();
    if (!userHelper.addRole(conn, idUser, idRole, idTheso1, "")) {
        conn.rollback();
        conn.close();
        return null;
    }
    conn.commit();
    conn.close();
    idGroupDefault = getNewGroupId();
    for (SKOSRelation relation : skosXmlDocument.getConceptScheme().getRelationsList()) {
        hasTopConcceptList.add(relation.getTargetUri());
    }
    return null;
}
Also used : SKOSCreator(mom.trd.opentheso.skosapi.SKOSCreator) SKOSResource(mom.trd.opentheso.skosapi.SKOSResource) Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) Connection(java.sql.Connection) SKOSRelation(mom.trd.opentheso.skosapi.SKOSRelation) SKOSLabel(mom.trd.opentheso.skosapi.SKOSLabel)

Example 15 with Thesaurus

use of mom.trd.opentheso.bdd.datas.Thesaurus in project opentheso by miledrousset.

the class ImportRdf4jHelper method addLangsToThesaurus.

public void addLangsToThesaurus(HikariDataSource ds, String idThesaurus) {
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    ArrayList<String> tabListLang = thesaurusHelper.getAllUsedLanguagesOfThesaurus(ds, idThesaurus);
    for (int i = 0; i < tabListLang.size(); i++) {
        if (!thesaurusHelper.isLanguageExistOfThesaurus(ds, idThesaurus, tabListLang.get(i).trim())) {
            Thesaurus thesaurus1 = new Thesaurus();
            thesaurus1.setId_thesaurus(idThesaurus);
            thesaurus1.setContributor("");
            thesaurus1.setCoverage("");
            thesaurus1.setCreator("");
            thesaurus1.setDescription("");
            thesaurus1.setFormat("");
            thesaurus1.setLanguage(tabListLang.get(i));
            thesaurus1.setPublisher("");
            thesaurus1.setRelation("");
            thesaurus1.setRights("");
            thesaurus1.setSource("");
            thesaurus1.setSubject("");
            thesaurus1.setTitle("theso_" + idThesaurus);
            thesaurus1.setType("");
            thesaurusHelper.addThesaurusTraduction(ds, thesaurus1);
        }
    }
}
Also used : Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper)

Aggregations

Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)19 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)10 NodeThesaurus (mom.trd.opentheso.bdd.helper.nodes.thesaurus.NodeThesaurus)6 Connection (java.sql.Connection)4 SQLException (java.sql.SQLException)3 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)2 SKOSResource (mom.trd.opentheso.skosapi.SKOSResource)2 Document (com.itextpdf.text.Document)1 Paragraph (com.itextpdf.text.Paragraph)1 PdfWriter (com.itextpdf.text.pdf.PdfWriter)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)1 FacesMessage (javax.faces.application.FacesMessage)1 Languages_iso639 (mom.trd.opentheso.bdd.datas.Languages_iso639)1 AccessThesaurusHelper (mom.trd.opentheso.bdd.helper.AccessThesaurusHelper)1