Search in sources :

Example 56 with OWLOntologyCreationException

use of org.semanticweb.owlapi.model.OWLOntologyCreationException 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()));
            }
        }
    }
}
Also used : UploadedFile(org.primefaces.model.UploadedFile) OWLOntologyCreationException(org.semanticweb.owlapi.model.OWLOntologyCreationException) ResourceBundle(java.util.ResourceBundle) IOException(java.io.IOException) FacesMessage(javax.faces.application.FacesMessage) ImportSkosHelper(mom.trd.opentheso.core.imports.helper.ImportSkosHelper) SKOSCreationException(org.semanticweb.skos.SKOSCreationException)

Example 57 with OWLOntologyCreationException

use of org.semanticweb.owlapi.model.OWLOntologyCreationException 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;
}
Also used : OWLOntologyCreationException(org.semanticweb.owlapi.model.OWLOntologyCreationException) SKOSDatasetImpl(uk.ac.manchester.cs.skos.SKOSDatasetImpl) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) SKOSCreationException(org.semanticweb.skos.SKOSCreationException)

Aggregations

OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)57 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)46 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)33 OWLAxiom (org.semanticweb.owlapi.model.OWLAxiom)18 OWLDataFactory (org.semanticweb.owlapi.model.OWLDataFactory)15 HashSet (java.util.HashSet)13 OWLOntologyID (org.semanticweb.owlapi.model.OWLOntologyID)13 AddImport (org.semanticweb.owlapi.model.AddImport)12 ReasoningServiceException (org.apache.stanbol.reasoners.servicesapi.ReasoningServiceException)11 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 OntModel (com.hp.hpl.jena.ontology.OntModel)9 WebApplicationException (javax.ws.rs.WebApplicationException)9 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)9 IRI (org.semanticweb.owlapi.model.IRI)9 OWLClass (org.semanticweb.owlapi.model.OWLClass)9 Consumes (javax.ws.rs.Consumes)8 InconsistentInputException (org.apache.stanbol.reasoners.servicesapi.InconsistentInputException)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 POST (javax.ws.rs.POST)7