Package edu.pitt.ontology

Examples of edu.pitt.ontology.IOntology


        Thread.sleep(500);
      }catch(Exception ex){}
    }
    if(importer.isSelected()){
      //IOntology source = POntology.loadOntology(new File("/home/tseytlin/Work/curriculum/owl/skin/UPMC/Alopecia.owl"));
      IOntology source = importer.getSelectedOntology();
      source.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
          if(IOntology.ONTOLOGY_LOADED_EVENT.equals(e.getPropertyName())){
            System.out.println("preload time "+((System.currentTimeMillis()-time2)/1000)+" s");
         
        }
      });
      IClass [] scls = importer.getSelectedClasses();
     
      IOntology ont = POntology.createOntology(URI.create("http://www.ontologies.com/Test.owl"),new File(System.getProperty("user.home")));
      System.out.println("start time "+new Date());
      long time = System.currentTimeMillis();
      time2 = System.currentTimeMillis();
      importer.copyClasses(scls,ont.getRoot());
      importer.copyValues(scls,ont.getRoot());
      System.out.println("total import time "+((System.currentTimeMillis()-time)/1000)+" s");
      System.out.println("end time "+new Date());
      ont.save();
      showOntology(ont);
     
    }else
      System.exit(0);
     
View Full Code Here


 
  /**
   * display ontology explorer in a non-modal window
   */
  public static JDialog showOntology(IOntology o){
    final IOntology ont = o;
    final OntologyExplorer exp = new OntologyExplorer();
   
    // init dialog
    JDialog d = new JDialog();
    d.setTitle("OntologyExplorer - ["+ont.getName()+"]");
    d.setModal(false);
    d.setResizable(true);
    d.getContentPane().setLayout(new BorderLayout());
    d.getContentPane().add(exp,BorderLayout.CENTER);
    d.pack();
   
    // start the loading process
    exp.setBusy(true);
    (new Thread(new Runnable(){
      public void run(){
        exp.setRoot(ont.getRoot());
        exp.setBusy(false);
      }
    })).start();
   
    // display
View Full Code Here

   * @param cls
   * @param target
   */
  private IClass getClass2(BClass src,IClass parent){
    IClass dst = null;
    IOntology target = parent.getOntology();
   
    // if no such resource, then add it
    if(!target.hasResource(src.getName())){
      dst = parent.createSubClass(src.getName());
    }else{
      IResource r = target.getResource(src.getName());
      if(r instanceof IClass){
        dst = (IClass) r;
      }else{
        System.err.println("Error: expecting a class "+src.getName()+" but got a "+r);
      }
View Full Code Here

   * @param cls
   * @param target
   */
  private IClass copyClass2(BClass src,IClass parent){
    long time = System.currentTimeMillis();
    IOntology target = parent.getOntology();
    IClass dst = getClass2(src,parent);
   
    // if no such resource, then we are fucked
    if(dst == null)
      return null;
   
   
    // add superclasses if needed (avoid infinite loops)
    for(IClass cls : src.getDirectSuperClasses()){
      if(cls.getName().equals(parent.getName()) || cls.equals(src))
        continue;
      // add superclass
      IClass p = getClass2((BClass)cls,target.getRoot());
      if(p != null && !p.hasSuperClass(p))
        dst.addSuperClass(p);
    }
   
    // remove root class as parent if it is not in source, but in destination
    if(src.getDirectSuperClasses().length > 0 && dst.hasDirectSuperClass(target.getRoot()) && !src.hasDirectSuperClass(src.getOntology().getRoot())){
      dst.removeSuperClass(target.getRoot());
    }
     
    // copy superficial stuff
    for(String lbl: src.getLabels())
      dst.addLabel(lbl);
   
    for(String com: src.getComments())
      dst.addComment(com);
    if(src.getVersion() != null && dst.getVersion() != src.getVersion())
      dst.addVersion(src.getVersion());
 
    // copy properties values
    for(IProperty sp : src.getProperties()){
      // skip PartOf, and has_PART
      if(HAS_PART.equals(sp.getName()) || PART_OF.equals(sp.getName()))
        continue;
   
      IProperty dp = target.getProperty(sp.getName());
     
      // create unknown property for the first time
      if(dp == null && !target.hasResource(sp.getName())){
        dp = target.createProperty(sp.getName(),IProperty.ANNOTATION_DATATYPE);
        dp.setRange(new String [0]);
      }
     
      // copy string values if not there
      dst.setPropertyValues(dp,src.getPropertyValues(sp));
View Full Code Here

            map.put("location",u);
          }else if((""+map.get("format")).equals(IRepository.FORMAT_DATABASE)){
            map.putAll((Map)repository.get(CONFIGURATION));
          }
          map.put("uri",URI.create(""+map.get("uri")));
          IOntology ont = new POntology(createProperties(map));
          ont.setRepository(this);
          map.put("object",ont);
          ontologies.add(map.get("object"));
          repository.put(""+map.get("uri"),map);
        }else if((""+map.get("type")).equals(IRepository.TYPE_TERMINOLOGY)){
          if((""+map.get("format")).equalsIgnoreCase("EVS")){
View Full Code Here

  */
  /**
   * create new ontology
   */
  public IOntology createOntology(URI paththrows IOntologyException {
    IOntology ont =  POntology.createOntology(path, directory);
    ont.setRepository(this);
    return ont;
  }
View Full Code Here

    if(i > -1){
      uri = uri.substring(0,i);
    }
   
    // get ontology
    IOntology ont = getOntology(URI.create(uri));
   
    // if ontology is all you want, fine Girish
    if(i == -1 && ont != null)
      return ont;
   
    // if ontology is null try again w/ a different convention
    if(ont == null){
      i = uri.lastIndexOf("/");
      if(i > -1){
        uri = uri.substring(0,i);
       
        // get ontology
        ont = getOntology(URI.create(uri));
      }
    }
   
    // now return resource
    if(ont != null)
      return ont.getResource(""+path);
    return null;
  }
View Full Code Here

  private void doRemove(){
    int r = JOptionPane.showConfirmDialog(frame,"Are you sure you want to delete selected ontologies?","Confirm",JOptionPane.YES_NO_OPTION);
    // if not canceled, remove entry
    if(r == JOptionPane.YES_OPTION){
      for(Object o : ontologies.getSelectedValues()){
        IOntology ont = (IOntology) o;
        // remove entry
        repository.removeOntology(ont);
        // remove data
        ont.delete();
       
      }
    }
  }
View Full Code Here

          }
          //selected
          if(importer.isSelected()){
            setBusy(true);
         
            IOntology source = importer.getSelectedOntology();
            IClass [] scls = importer.getSelectedClasses();
           
            // create new ontology
            IOntology ont = repository.createOntology(source.getURI());
           
            //copy content
            importer.copy(scls,ont.getRoot());
           
            // import ontology
            repository.importOntology(ont);
          }
          importer.removePropertyChangeListener(RepositoryManager.this);
View Full Code Here

      if(chooser.showSaveDialog(frame) == JFileChooser.APPROVE_OPTION){
        final File f = chooser.getSelectedFile();
        setBusy(true);
        (new Thread(new Runnable(){
          public void run(){
            IOntology ont = (IOntology) value;
            try{
              ont.load();
              ont.write(new FileOutputStream(f),IOntology.OWL_FORMAT);
              JOptionPane.showMessageDialog(frame,ont.getName()+" saved as "+f.getAbsolutePath());
            }catch(Exception ex){
              ex.printStackTrace();
              JOptionPane.showMessageDialog(frame,ex.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);             
            }
            setBusy(false);
View Full Code Here

TOP

Related Classes of edu.pitt.ontology.IOntology

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.