Search in sources :

Example 1 with SKOSCreator

use of mom.trd.opentheso.skosapi.SKOSCreator 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)

Aggregations

Connection (java.sql.Connection)1 Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)1 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)1 UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)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