use of org.semanticweb.skos.SKOSTypedLiteral 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;
}
use of org.semanticweb.skos.SKOSTypedLiteral in project opentheso by miledrousset.
the class ImportSkosHelper method getValue.
private Value getValue(SKOSAnnotation anno) {
Value value = new Value();
// Annotation: http://www.w3.org/2004/02/skos/core#prefLabel-> arte@e
if (anno.getAnnotationValueAsConstant().isTyped()) {
SKOSTypedLiteral con = anno.getAnnotationValueAsConstant().getAsSKOSTypedLiteral();
value.setValue(con.getLiteral());
// System.err.print(con.getLiteral() + " Type: " + con.getDataType().getURI());
} else {
SKOSUntypedLiteral con = anno.getAnnotationValueAsConstant().getAsSKOSUntypedLiteral();
value.setValue(con.getLiteral());
if (con.hasLang()) {
if (!con.getLang().isEmpty())
value.setLang(con.getLang());
else
// la langue par defaut
value.setLang(langueSource);
}
}
return value;
}
Aggregations