Package edu.stanford.smi.protege.model

Examples of edu.stanford.smi.protege.model.Project


   */
  public static POntology loadOntology(URI uri) throws IOntologyException{
    POntology ont = null;
    if(uri.toString().endsWith(".pprj")){
      ArrayList errors = new ArrayList();
      Project project = Project.loadProjectFromURI(uri,errors);
      if(!errors.isEmpty()){
        throw new IOntologyException("Problem loading PPRJ file "+uri,getException(errors));
      }
      ont =  new POntology((OWLModel) project.getKnowledgeBase());
    }else {
      try{
        ont = new POntology(ProtegeOWL.createJenaOWLModelFromURI(""+uri));
      }catch(Exception ex){
        throw new IOntologyException("Problem loading OWL file "+uri,ex);
View Full Code Here


   */
  public static POntology loadOntology(File uri) throws IOntologyException{
    // check if this is an pprj file
    if(uri.getName().endsWith(".pprj")){
      ArrayList errors = new ArrayList();
      Project project = Project.loadProjectFromFile(uri.getAbsolutePath(),errors);
      if(!errors.isEmpty()){
        throw new IOntologyException("Could not open "+uri,getException(errors));
      }
      return new POntology((OWLModel) project.getKnowledgeBase());
    }
    return loadOntology(uri.toURI());
  }
View Full Code Here

    if(info.containsKey("driver") || "database".equals(info.get("format"))){
      URI path = getURI();
     
      // load new KB
      KnowledgeBaseFactory factory = new MyOWLDatabaseKnowledgeBaseFactory();
      Project project = Project.createBuildProject(factory, errors);
      if(!errors.isEmpty())
        throw new IOntologyException(""+errors);
      loadNewSources(project, factory);
     
      // load data
      project.createDomainKnowledgeBase(factory, errors, true);
          if(!errors.isEmpty())
        throw new IOntologyException(""+errors);
             
        model = (OWLModel) project.getKnowledgeBase();      
     
          // make sure it is named correctly
          model.getNamespaceManager().setDefaultNamespace(path+"#");
      OWLUtil.renameOntology(model,model.getDefaultOWLOntology(),""+path);
     }else{
      // load regular ontology
      String u = ""+info.get("location");
      File f = new File(u);
      URI path = (f.exists())?f.toURI():URI.create(u);
     
      // check URI path, if doesn't exist simply use URI as location
      if("file".equals(path.getScheme()) && !(new File(path)).exists())
        path = getURI();
     
      if(path.toString().endsWith(".pprj")){
        Project project = Project.loadProjectFromURI(path,errors);
        if(!errors.isEmpty()){
          throw new IOntologyException("Problem loading PPRJ file "+path+"\n",getException(errors));
        }
        model = (OWLModel) project.getKnowledgeBase();
      }else {
        try{
          model = ProtegeOWL.createJenaOWLModelFromURI(""+path);
        }catch(Exception ex){
          throw new IOntologyException("Problem loading OWL file "+path,ex);
View Full Code Here

    String prefix="";
    if(getRepository() instanceof ProtegeRepository){
      prefix = ((ProtegeRepository)getRepository()).getOntologyPrefix();
    }
 
    Project currentProject = model.getProject();
    KnowledgeBaseFactory factory = new OWLDatabaseKnowledgeBaseFactory();
       
        // load new source information
        loadNewSources(currentProject, factory);
       
        // check completeness
        if (currentProject.hasCompleteSources()) {
          ArrayList errors = new ArrayList();
            currentProject.setIsReadonly(false);
            currentProject.save(errors);
            if(!errors.isEmpty())
              throw new IOntologyException("problem saving "+getURI(),getException(errors));      
        }
       
        // save included projects
View Full Code Here

   */
  public static POntology loadOntology(URI uri) throws IOntologyException{
    POntology ont = null;
    if(uri.toString().endsWith(".pprj")){
      ArrayList errors = new ArrayList();
      Project project = Project.loadProjectFromURI(uri,errors);
      if(!errors.isEmpty()){
        throw new IOntologyException("Problem loading PPRJ file "+uri,getException(errors));
      }
      ont =  new POntology((OWLModel) project.getKnowledgeBase());
    }else {
      try{
        ont = new POntology(ProtegeOWL.createJenaOWLModelFromURI(""+uri));
      }catch(Exception ex){
        throw new IOntologyException("Problem loading OWL file "+uri,ex);
View Full Code Here

   */
  public static POntology loadOntology(File uri) throws IOntologyException{
    // check if this is an pprj file
    if(uri.getName().endsWith(".pprj")){
      ArrayList errors = new ArrayList();
      Project project = Project.loadProjectFromFile(uri.getAbsolutePath(),errors);
      if(!errors.isEmpty()){
        throw new IOntologyException("Could not open "+uri,getException(errors));
      }
      return new POntology((OWLModel) project.getKnowledgeBase());
    }
    return loadOntology(uri.toURI());
  }
View Full Code Here

    if(info.containsKey("driver") || "database".equals(info.get("format"))){
      URI path = getURI();
     
      // load new KB
      KnowledgeBaseFactory factory = new MyOWLDatabaseKnowledgeBaseFactory();
      Project project = Project.createBuildProject(factory, errors);
      if(!errors.isEmpty())
        throw new IOntologyException(""+errors);
      loadNewSources(project, factory);
     
      // load data
      project.createDomainKnowledgeBase(factory, errors, true);
          if(!errors.isEmpty())
        throw new IOntologyException(""+errors);
             
        model = (OWLModel) project.getKnowledgeBase();      
     
          // make sure it is named correctly
          model.getNamespaceManager().setDefaultNamespace(path+"#");
      OWLUtil.renameOntology(model,model.getDefaultOWLOntology(),""+path);
     }else{
      // load regular ontology
      String u = ""+info.get("location");
      File f = new File(u);
      URI path = (f.exists())?f.toURI():URI.create(u);
     
      // check URI path, if doesn't exist simply use URI as location
      if("file".equals(path.getScheme()) && !(new File(path)).exists())
        path = getURI();
     
      if(path.toString().endsWith(".pprj")){
        Project project = Project.loadProjectFromURI(path,errors);
        if(!errors.isEmpty()){
          throw new IOntologyException("Problem loading PPRJ file "+path+"\n",getException(errors));
        }
        model = (OWLModel) project.getKnowledgeBase();
      }else {
        try{
          model = ProtegeOWL.createJenaOWLModelFromURI(""+path);
        }catch(Exception ex){
          throw new IOntologyException("Problem loading OWL file "+path,ex);
View Full Code Here

    String prefix="";
    if(getRepository() instanceof ProtegeRepository){
      prefix = ((ProtegeRepository)getRepository()).getOntologyPrefix();
    }
 
    Project currentProject = model.getProject();
    KnowledgeBaseFactory factory = new OWLDatabaseKnowledgeBaseFactory();
       
        // load new source information
        loadNewSources(currentProject, factory);
       
        // check completeness
        if (currentProject.hasCompleteSources()) {
          ArrayList errors = new ArrayList();
            currentProject.setIsReadonly(false);
            currentProject.save(errors);
            if(!errors.isEmpty())
              throw new IOntologyException("problem saving "+getURI(),getException(errors));      
        }
       
        // save included projects
View Full Code Here

        clamlFile = file;
    }

    @Override
    protected Project buildNewProject(KnowledgeBaseFactory factory) {
        Project project = createNewProject(factory);
        if (project != null) {
            try {
                importClamlCM((OWLModel) project.getKnowledgeBase());
                ClamlImport clamlImport = new ClamlImport((OWLModel) project.getKnowledgeBase());
                clamlImport.doImport(clamlFile);
            } catch (Exception ex) {
                Log.getLogger().log(Level.SEVERE, "Exception caught", ex);
                JOptionPane.showMessageDialog(Application.getMainWindow(), "Could not load " + clamlFile.getAbsolutePath() + "\n" + ex, "Error", JOptionPane.ERROR_MESSAGE);
            }
View Full Code Here

    return null;
  }
 
  private KnowledgeBase loadProject(URI uri) {
    ArrayList errors = new ArrayList();
    Project project = null;
    try {
      project = Project.loadProjectFromURI(uri, errors)
    } catch (Exception e) {
      Log.getLogger().log(Level.SEVERE, "Errors at loading " + uri, e);
    }
   
    if (errors.size() > 0) {
      ProjectManager.getProjectManager().displayErrors("Errors at loading project " + uri, errors);
    }
   
    return project == null ? null : project.getKnowledgeBase();
  }
View Full Code Here

TOP

Related Classes of edu.stanford.smi.protege.model.Project

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.