Search in sources :

Example 1 with SKOSTopConcept

use of skos.SKOSTopConcept in project opentheso by miledrousset.

the class SkosToJsonldSchemaOrg method addElementInScheme.

private void addElementInScheme(ArrayList<SKOSTopConcept> sKOSTopConcepts, String nameSpace) {
    String element;
    if (sKOSTopConcepts.size() > 1) {
        endElement();
        element = "      \"" + nameSpaceSkosCore + nameSpace + "\": [\n";
        boolean first = true;
        for (SKOSTopConcept sKOSTopConcept : sKOSTopConcepts) {
            if (!first)
                element += "        },\n";
            element += "        {\n";
            element += "          \"@id\": \"" + sKOSTopConcept.getTopConcept() + "\"\n";
            first = false;
        }
        element += "        }\n";
        element += "      ]";
    } else {
        endElement();
        element = "      \"" + nameSpaceSkosCore + nameSpace + "\": {\n";
        for (SKOSTopConcept sKOSTopConcept : sKOSTopConcepts) {
            element += "        \"@id\": \"" + sKOSTopConcept.getTopConcept() + "\"\n";
            element += "      }";
        }
    }
    jsonLd.append(element);
}
Also used : SKOSTopConcept(skos.SKOSTopConcept)

Example 2 with SKOSTopConcept

use of skos.SKOSTopConcept in project opentheso by miledrousset.

the class WriteFileSKOS_Frantiq method writeTopConcepts.

boolean writeTopConcepts(String idGroup) {
    SKOSTopConcept topConcept = new SKOSTopConcept(URI + "concept#" + idGroup);
    // skos = skos + topConcept.toString();
    skosBuff.append(topConcept.toString());
    return true;
}
Also used : SKOSTopConcept(skos.SKOSTopConcept)

Example 3 with SKOSTopConcept

use of skos.SKOSTopConcept 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 4 with SKOSTopConcept

use of skos.SKOSTopConcept in project opentheso by miledrousset.

the class SkosToJsonld method addElementInScheme.

private void addElementInScheme(ArrayList<SKOSTopConcept> sKOSTopConcepts, String nameSpace) {
    String element;
    String uri;
    StringPlus stringPlus = new StringPlus();
    if (sKOSTopConcepts.size() > 1) {
        endElement();
        element = "      \"" + nameSpaceSkosCore + nameSpace + "\": [\n";
        boolean first = true;
        for (SKOSTopConcept sKOSTopConcept : sKOSTopConcepts) {
            if (!first)
                element += "        },\n";
            element += "        {\n";
            uri = stringPlus.normalizeStringForXml(sKOSTopConcept.getTopConcept());
            element += "          \"@id\": \"" + uri + "\"\n";
            first = false;
        }
        element += "        }\n";
        element += "      ]";
    } else {
        endElement();
        element = "      \"" + nameSpaceSkosCore + nameSpace + "\": {\n";
        for (SKOSTopConcept sKOSTopConcept : sKOSTopConcepts) {
            uri = stringPlus.normalizeStringForXml(sKOSTopConcept.getTopConcept());
            element += "        \"@id\": \"" + uri + "\"\n";
            element += "      }";
        }
    }
    jsonLd.append(element);
}
Also used : StringPlus(mom.trd.opentheso.bdd.tools.StringPlus) SKOSTopConcept(skos.SKOSTopConcept)

Example 5 with SKOSTopConcept

use of skos.SKOSTopConcept in project opentheso by miledrousset.

the class WriteFileSKOS method writeTopConcepts.

boolean writeTopConcepts(String idGroup, String idThesaurus) {
    SKOSTopConcept topConcept = new SKOSTopConcept(URI + "?idg=" + idGroup + "&amp;idt=" + idThesaurus);
    // skos = skos + topConcept.toString();
    skosBuff.append(topConcept.toString());
    // System.out.println("écriture du TopConcept : " + idGroup);
    return true;
}
Also used : SKOSTopConcept(skos.SKOSTopConcept)

Aggregations

SKOSTopConcept (skos.SKOSTopConcept)5 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)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 StringPlus (mom.trd.opentheso.bdd.tools.StringPlus)1 SKOSConceptScheme (skos.SKOSConceptScheme)1 SKOSLabel (skos.SKOSLabel)1 SKOSResource (skos.SKOSResource)1