Search in sources :

Example 1 with DcElement

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

the class ImportSkosHelper method addThesaurus.

/**
 * Fonction qui permet d'importer les informations d'un thésaurus
 * @return
 */
public boolean addThesaurus() {
    ThesaurusHelper thesaurusHelper = new ThesaurusHelper();
    idGroupDefault = getNewId();
    for (SKOSConceptScheme scheme : dataSet.getSKOSConceptSchemes()) {
        // récupération du nom de thésaurus
        thesaurus.setTitle(getIdFromUri(scheme.getURI().toString()));
        conceptsCount = dataSet.getSKOSConcepts().size();
        for (SKOSAnnotation anno : scheme.getSKOSAnnotations(dataSet)) {
            if (anno.isAnnotationByConstant()) {
                if (anno.getAnnotationValueAsConstant().isTyped()) {
                    SKOSTypedLiteral con = anno.getAnnotationValueAsConstant().getAsSKOSTypedLiteral();
                // System.err.print(con.getLiteral() + " Type: " + con.getDataType().getURI());
                } else {
                    SKOSUntypedLiteral con = anno.getAnnotationValueAsConstant().getAsSKOSUntypedLiteral();
                    if (anno.getURI().toString().contains("title")) {
                        DcElement dcElement = new DcElement();
                        dcElement.setName("title");
                        dcElement.setValue(con.getLiteral());
                        if (con.hasLang()) {
                            dcElement.setLanguage(con.getLang());
                        } else
                            dcElement.setLanguage(langueSource);
                        thesaurus.addDcElement(dcElement);
                    } else {
                        DcElement dcElement = new DcElement();
                        dcElement.setName("title");
                        dcElement.setValue(con.getLiteral());
                        if (con.hasLang()) {
                            dcElement.setLanguage(con.getLang());
                        } else
                            dcElement.setLanguage(langueSource);
                        thesaurus.addDcElement(dcElement);
                    }
                }
            // * created or date;
            // if(anno.getURI().getPath().contains("date") ){
            // getThesaurusAnnotation(anno);
            // }
            // //              * modified;
            // if(anno.getURI().getPath().contains("modified") ){
            // getThesaurusAnnotation(anno);
            // }
            // * @param coverage
            // * @param creator
            // * @param description
            // * @param format
            // * @param id_langue
            // * @param publisher
            // * @param relation
            // * @param rights
            // * @param source
            // * @param subject
            // * @param title
            // * @param type
            } else // la liste des TopConcept
            {
                idTopConcept.add(getIdFromUri(anno.getAnnotationValue().getURI().toString()));
            // System.err.println(anno.getAnnotationValue().getURI().toString());
            }
        }
        if (!addThesaurusToBdd(thesaurusHelper)) {
            return false;
        }
        if (thesaurus.getDcElement().isEmpty()) {
            if (thesaurus.getTitle().isEmpty()) {
                thesaurus.setTitle("theso_" + thesaurus.getId_thesaurus());
            } else {
                thesaurus.setTitle(thesaurus.getTitle());
            }
            thesaurus.setLanguage(langueSource);
            thesaurusHelper.addThesaurusTraduction(ds, thesaurus);
        } else {
            for (DcElement dcElement : thesaurus.getDcElement()) {
                thesaurus.setTitle(dcElement.getValue());
                thesaurus.setLanguage(dcElement.getLanguage());
                thesaurusHelper.addThesaurusTraduction(ds, thesaurus);
            }
        }
        return true;
    }
    return false;
}
Also used : SKOSTypedLiteral(org.semanticweb.skos.SKOSTypedLiteral) DcElement(mom.trd.opentheso.bdd.datas.DcElement) SKOSUntypedLiteral(org.semanticweb.skos.SKOSUntypedLiteral) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) SKOSConceptScheme(org.semanticweb.skos.SKOSConceptScheme) SKOSAnnotation(org.semanticweb.skos.SKOSAnnotation)

Aggregations

DcElement (mom.trd.opentheso.bdd.datas.DcElement)1 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)1 SKOSAnnotation (org.semanticweb.skos.SKOSAnnotation)1 SKOSConceptScheme (org.semanticweb.skos.SKOSConceptScheme)1 SKOSTypedLiteral (org.semanticweb.skos.SKOSTypedLiteral)1 SKOSUntypedLiteral (org.semanticweb.skos.SKOSUntypedLiteral)1