use of org.semanticweb.skos.SKOSCreationException in project opentheso by miledrousset.
the class FileBean_progress method readSkos2.
/**
* Cette fonction permet de lire un fichier Skos en utilsant le skosapi et owlapi (officiel)
*
* @param event
*/
public void readSkos2(FileUploadEvent event) {
importSkosHelper = null;
if (!PhaseId.INVOKE_APPLICATION.equals(event.getPhaseId())) {
event.setPhaseId(PhaseId.INVOKE_APPLICATION);
event.queue();
} else {
UploadedFile file = event.getFile();
if (formatDate == null || formatDate.equals("")) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("file.error2")));
} else {
try {
boolean useArk = false;
ResourceBundle bundlePref = getBundlePref();
if (bundlePref.getString("useArk").equalsIgnoreCase("true")) {
useArk = true;
}
String adressSite = bundlePref.getString("cheminSite");
int idUser = selectedTerme.getUser().getUser().getId();
// lecture du fichier SKOS
importSkosHelper = new ImportSkosHelper();
importSkosHelper.setInfos(connect.getPoolConnexion(), formatDate, useArk, adressSite, idUser, langueSource);
if (!importSkosHelper.readFile(file.getInputstream(), file.getFileName())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", importSkosHelper.getMessage()));
return;
}
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, langueBean.getMsg("info") + " :", importSkosHelper.getMessage()));
desabled = false;
}// }
catch (IOException | OWLOntologyCreationException | SKOSCreationException ex) {
Logger.getLogger(FileBean.class.getName()).log(Level.SEVERE, null, ex);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", ex.getMessage()));
}
}
}
}
use of org.semanticweb.skos.SKOSCreationException in project opentheso by miledrousset.
the class ImportSkosHelper method readFile.
/**
* Cette fonction a été modifié pour pouvoir lire un fichier SKOS en passant par un
* InputStream, l'API standard SKOSAPI n'a pas de constructeur adapté
* cette fonction permet de lire tout type de fichier SKOS-OWL en s'appuyant
* sur l'api (OWLAPI-SKOSAPI)
*
* @param streamFilename
* @param fileName
* @return
* @throws OWLOntologyCreationException
* @throws SKOSCreationException
*/
public boolean readFile(InputStream streamFilename, String fileName) throws OWLOntologyCreationException, SKOSCreationException {
try {
sKOSManager = new SKOSManager();
onto = ontologieManager.loadOntologyFromOntologyDocument(streamFilename);
SKOSDatasetImpl voc = new SKOSDatasetImpl(sKOSManager, onto);
if (voc.getURI() != null) {
String theso = "";
for (SKOSConceptScheme scheme : voc.getSKOSConceptSchemes()) {
theso = theso + " " + scheme.getURI();
}
message = "new ontology loaded: " + theso;
// voc.getAsOWLOntology().getOntologyID();
// System.out.println("new ontology loaded: " + voc.getAsOWLOntology().getOntologyID());
skosVocabularies.put(voc.getURI(), voc);
dataSet = voc;
return true;
}
} catch (SKOSCreationException ex) {
Logger.getLogger(ImportSkosHelper.class.getName()).log(Level.SEVERE, null, ex);
message = ex.getMessage();
}
return false;
}
use of org.semanticweb.skos.SKOSCreationException in project opentheso by miledrousset.
the class FileBean_progress method chargeSkos2.
/**
* Cette fonction permet d'insérer un thésaurus en base de données à partir
* d'un fichier Skos en utilsant leskosapi et owlapi (officiel)
*
* @param event
*/
public void chargeSkos2(FileUploadEvent event) {
if (!PhaseId.INVOKE_APPLICATION.equals(event.getPhaseId())) {
event.setPhaseId(PhaseId.INVOKE_APPLICATION);
event.queue();
} else {
UploadedFile file = event.getFile();
if (formatDate == null || formatDate.equals("")) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("file.error2")));
} else {
try {
boolean useArk = false;
ResourceBundle bundlePref = getBundlePref();
if (bundlePref.getString("useArk").equalsIgnoreCase("true")) {
useArk = true;
}
String adressSite = bundlePref.getString("cheminSite");
int idUser = selectedTerme.getUser().getUser().getId();
// lecture du fichier SKOS
ImportSkosHelper importSkosHelper = new ImportSkosHelper();
importSkosHelper.setInfos(connect.getPoolConnexion(), formatDate, useArk, adressSite, idUser, langueSource);
if (!importSkosHelper.readFile(file.getInputstream(), file.getFileName())) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", importSkosHelper.getMessage()));
return;
} else {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, langueBean.getMsg("info") + " :", importSkosHelper.getMessage()));
}
// chargement du nom du thesaurus
if (!importSkosHelper.addThesaurus()) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Aucune information sur le thésaurus et ses domaines, un thésaurus par defaut sera créer.. " + /*langueBean.getMsg("info")*/
" :", importSkosHelper.getMessage()));
if (!importSkosHelper.addDefaultThesaurus()) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", importSkosHelper.getMessage()));
}
// echec de l'ajout du nom de thésaurus
}
// chargement des concepts
if (!importSkosHelper.addConcepts()) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Aucun Concept n'a été détecté dans le fichier ... " + /*langueBean.getMsg("info")*/
" :", importSkosHelper.getMessage()));
// echec de l'ajout des concepts
}
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, langueBean.getMsg("info") + " :", importSkosHelper.getMessage()));
vue.setAddSkos2(false);
}// }
catch (IOException | OWLOntologyCreationException | SKOSCreationException ex) {
Logger.getLogger(FileBean.class.getName()).log(Level.SEVERE, null, ex);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", ex.getMessage()));
}
}
}
}
use of org.semanticweb.skos.SKOSCreationException in project opentheso by miledrousset.
the class SKOSManager method loadDatasetFromInputStream.
public SKOSDataset loadDatasetFromInputStream(InputStream uri) throws SKOSCreationException {
OWLOntology onto = null;
try {
onto = man.loadOntologyFromOntologyDocument(uri);
} catch (OWLOntologyCreationException e) {
throw new SKOSCreationException(e);
}
SKOSDatasetImpl voc;
// voc;
return null;
}
Aggregations