Search in sources :

Example 16 with UserHelper

use of mom.trd.opentheso.bdd.helper.UserHelper 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 17 with UserHelper

use of mom.trd.opentheso.bdd.helper.UserHelper 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 18 with UserHelper

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

the class BackgroundTimeJobHelper method selectMessageProposedCdt.

/**
 * selectMessageProposeCdt
 *#JM
 *
 * récupère un corps de message et une liste de destinataire, constuits avec
 * ces valeurs un objet MessageCdt puis le retourne
 *
 * @param idTheso
 * @param d1
 * @param d2
 * @param poolConnexion
 * @return
 */
MessageCdt selectMessageProposedCdt(String idTheso, Date d1, Date d2, HikariDataSource poolConnexion) {
    ArrayList<String> ret = new CandidateHelper().getListOfCdtDuringPeriod(idTheso, d1, d2, poolConnexion);
    ArrayList<String> destinataires = new UserHelper().getMailAdmin(poolConnexion, idTheso);
    ArrayList<String> dest = reduce(destinataires);
    MessageCdt mess = new MessageCdt(ret, dest);
    return mess;
}
Also used : UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Example 19 with UserHelper

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

the class BackgroundTimeJobHelper method selectMessageValidedInsertedCdt.

/**
 * selectMessageValidedInsertedCdt
 * #JM
 * récupère un corps de message correspondant aux candidats validé ou
 * insérés ou refusés et une liste d'adresse mail
 * crée un objet MessageCdt avec ce corps de message et cette liste de
 * destinataires puis le retourne
 *
 * @param idTheso
 * @param d1
 * @param d2
 * @param poolConnexion
 * @return
 */
MessageCdt selectMessageValidedInsertedCdt(String idTheso, Date d1, Date d2, HikariDataSource poolConnexion) {
    ArrayList<String> destinataires = new UserHelper().getMailAdmin(poolConnexion, idTheso);
    destinataires.addAll(new UserHelper().getMailUserForCandidat(poolConnexion, idTheso, d1, d2));
    ArrayList<String> ret = new CandidateHelper().getInsertedValidedRefusedCdtDuringPeriod(poolConnexion, d1, d2, idTheso);
    MessageCdt mess = new MessageCdt(ret, reduce(destinataires));
    return mess;
}
Also used : UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) CandidateHelper(mom.trd.opentheso.bdd.helper.CandidateHelper)

Aggregations

UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)19 FacesMessage (javax.faces.application.FacesMessage)10 Connection (java.sql.Connection)8 SQLException (java.sql.SQLException)8 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)6 Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)2 BaseDeDoneesHelper (mom.trd.opentheso.bdd.helper.BaseDeDoneesHelper)2 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)2 NodeUser (mom.trd.opentheso.bdd.helper.nodes.NodeUser)2 FacesContext (javax.faces.context.FacesContext)1 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)1 PreferencesHelper (mom.trd.opentheso.bdd.helper.PreferencesHelper)1 SKOSCreator (mom.trd.opentheso.skosapi.SKOSCreator)1 SKOSLabel (mom.trd.opentheso.skosapi.SKOSLabel)1 SKOSRelation (mom.trd.opentheso.skosapi.SKOSRelation)1 SKOSResource (mom.trd.opentheso.skosapi.SKOSResource)1 SKOSConceptScheme (skos.SKOSConceptScheme)1 SKOSLabel (skos.SKOSLabel)1 SKOSResource (skos.SKOSResource)1 SKOSTopConcept (skos.SKOSTopConcept)1