Package edu.pitt.ontology

Examples of edu.pitt.ontology.IClass


      }
      return t;
    }else if(value instanceof IProperty){
      return ont.getProperty(((IProperty) value).getName());
    }else if(value instanceof IClass){
      IClass c = (IClass) value;
      if(c.isAnonymous())
        return convertResource(ont,c.getLogicExpression());
      return ont.getClass(c.getName());
    }else if(value instanceof IInstance){
      return ont.getInstance(((IInstance) value).getName());
    }else if(value instanceof IResource){
      return ont.getResource(((IResource) value).getName());
    }
View Full Code Here


    pcs.firePropertyChange(PROPERTY_PROGRESS_MSG, progressMessage, msg);
    progressMessage = msg;
   
   
    //check if name exits
    IClass cls = ont.getClass(name);
    // if exists, then do the magic
    if(cls != null){
      // copy property values
      for(IProperty sp: source.getProperties()){
        IProperty tp = (IProperty) convertResource(ont,sp);
        if(tp != null){
          // set property values
          if(tp.isFunctional())
            cls.setPropertyValue(tp,convertResource(ont,source.getPropertyValue(sp)));
          else
            cls.setPropertyValues(tp,convertResources(ont,source.getPropertyValues(sp)));
         
       
      }
     
      // copy disjoints
      for(IClass c: source.getDisjointClasses()){
        cls.addDisjointClass((IClass)convertResource(ont,c));
      }
     
      // copy necessary restrictions
      ILogicExpression exp = source.getNecessaryRestrictions();
      if(exp.getExpressionType() == ILogicExpression.OR){
        cls.addSuperClass(ont.createClass((ILogicExpression) convertResource(ont,exp)));
      }else{
        for(Object c: exp){
          if(c instanceof IRestriction)
            cls.addNecessaryRestriction((IRestriction)convertResource(ont,c));
          else if(c instanceof IClass)
            cls.addSuperClass((IClass) convertResource(ont,c));
          else if(c instanceof ILogicExpression)
            cls.addSuperClass(ont.createClass((ILogicExpression) convertResource(ont,exp)));   
        }
      }
     
      // copy equivalent restrictions
      exp = source.getEquivalentRestrictions();
      if(exp.getExpressionType() == ILogicExpression.OR){
        cls.addEquivalentClass(ont.createClass((ILogicExpression) convertResource(ont,exp)));
      }else{
        for(Object c: exp){
          if(c instanceof IRestriction)
            cls.addEquivalentRestriction((IRestriction)convertResource(ont,c));
          else if(c instanceof IClass)
            cls.addEquivalentClass((IClass) convertResource(ont,c));
          else if(c instanceof ILogicExpression)
            cls.addEquivalentClass(ont.createClass((ILogicExpression) convertResource(ont,exp)));
         
        }
      }
           
      // copy instances
      for(IInstance inst: source.getDirectInstances()){
        IInstance i = ont.getInstance(inst.getName());
        if(i == null){
          i = cls.createInstance(inst.getName());
          // copy property values
          for(IProperty sp : inst.getProperties()){
            IProperty tp = (IProperty) convertResource(ont,sp);
            if(tp != null){
              if(tp.isFunctional())
View Full Code Here

   * Lookup concept information if unique identifier is available
   * @param CUI
   * @return Concept object
   */
  public Concept lookupConcept(String cui) throws TerminologyException {
    IClass c = getClass(cui);
    return (c != null)?c.getConcept():null;
  }
View Full Code Here

   * @return Map where relation is a key and list of related concepts is a value
   */
  public Map getRelatedConcepts(Concept c) throws TerminologyException{
    Map<Relation,Concept[]> map = new HashMap<Relation,Concept[]>();
    Relation [] r = getRelations();
    IClass cls = getClass(c.getCode());
    if(cls != null){
      map.put(r[0],getConcepts(cls.getDirectSuperClasses()));
      map.put(r[1],getConcepts(cls.getDirectSubClasses()));
      map.put(r[2],getConcepts(cls.getDisjointClasses()));
    }
    return map;
  }
View Full Code Here

      buffer.append("<b>"+e.getName()+"</b><br>");
      buffer.append("(<i>"+e.getURI()+"</i>)<br>");
      buffer.append("<hr>");
      buffer.append("<b>Definition: </b> "+e.getDescription()+"<br>");
      if(e instanceof IClass){
        IClass cls = (IClass) e;
        buffer.append("<b>Equivalent: </b> "+Arrays.asList(cls.getEquivalentClasses())+"<br>");
        buffer.append("<b>Disjoint: </b> "+Arrays.asList(cls.getDisjointClasses())+"<br>");
      }else if(e instanceof IProperty){
        IProperty cls = (IProperty) e;
        buffer.append("<b>Domain: </b> "+Arrays.asList(cls.getDomain())+"<br>");
        buffer.append("<b>Range: </b> "+Arrays.asList(cls.getRange())+"<br>");
      }else if(e instanceof IInstance){
        IInstance cls = (IInstance) e;
        buffer.append("<b>Types: </b> "+Arrays.asList(cls.getTypes())+"<br>");
      }
      buffer.append("<b>Properties:</b>");
      IProperty[] p = e.getProperties();
      if(p.length > 0){
        buffer.append("<ul>");
View Full Code Here

    // if we got a uri as a code
    int i = name.lastIndexOf("#");
    if(i > -1)
      name = name.substring(i+1);
    // fetch class
    IClass cls = classMap.get(name);
   
    // try some derivative of a name
    if(cls == null){
      cls = classMap.get(deriveName(name));
    }
View Full Code Here

  public IRepository getRepository() {
    return repository;
  }

  public IResource getResource(String name) {
    IClass c = getClass(name);
    // search if not in caseh, can't rely on lookup
    // cause class name and location are not always the same things
    if(c == null){
      try{
        Concept [] result = search(BioPortalHelper.getName(name));
View Full Code Here

    partOf.setInverseProperty(hasPart);
   
    // now that we have all classes, build a tree, since classes only have the superclasses set
    IResourceIterator it = target.getAllClasses();
    while(it.hasNext()){
      IClass cls = (IClass) it.next();
     
      long time = System.currentTimeMillis();
     
      // now copy equivalent classes classes
      IProperty p = target.getProperty(EQUIVALENT_CLASS);
      if(p != null){
        for(IClass sibling: getClassList(target,cls.getPropertyValues(p))){
          cls.addEquivalentClass(sibling);
        }
        // remove temporary property
        cls.removePropertyValues(p);
      }
     
      // setup direct subclasses and superclasses
      p = target.getProperty(SUPER_CLASS);
      if(p != null){
        for(IClass parent: getClassList(target,cls.getPropertyValues(p))){
          if(!cls.hasDirectSuperClass(parent)){ 
            // add string as a true superclass
            cls.addSuperClass(parent);
            // if superclass is not root, then add this class
            // as a child and remove root as parent
            if(!parent.equals(target.getRoot())){
              parent.addSubClass(cls);
             
              // since everything was added as root, cleanup
              cls.removeSuperClass(target.getRoot());
            }
          }     
        }
       
        // remove temporary property
        cls.removePropertyValues(p);
      }
     
      // setup direct subclasses and superclasses
      p = target.getProperty(SUB_CLASS);
      if(p != null){
        for(IClass child: getClassList(target,cls.getPropertyValues(p))){
          if(!cls.hasDirectSubClass(child)){
            // add string as a true superclass
            cls.addSubClass(child);
            child.addSuperClass(cls);
           
            // if superclass is not root, then add this class
            // as a child and remove root as parent
            if(child.hasDirectSuperClass(target.getRoot())){
              // since everything was added as root, cleanup
              child.removeSuperClass(target.getRoot());
            }
          }
        }
       
        // remove temporary property
        cls.removePropertyValues(p);
      }
     
     
      // now copy disjoint classes
      p = target.getProperty(DISJOINT_CLASS);
      if(p != null){
        for(IClass sibling: getClassList(target,cls.getPropertyValues(p))){
          cls.addDisjointClass(sibling);
        }
        // remove temporary property
        cls.removePropertyValues(p);
      }
   
      // now copy other relationships relationships
      for(String relation: new String [] {PART_OF, HAS_PART}){
        p = target.getProperty("annotation_"+relation);
        if(p != null){
          for(IClass sibling: getClassList(target,cls.getPropertyValues(p))){
           
            IRestriction r = target.createRestriction(IRestriction.SOME_VALUES_FROM);
            r.setProperty(target.getProperty(relation));
            r.setParameter(sibling.getLogicExpression());
            cls.addNecessaryRestriction(r);
          }
          // remove temporary property
          cls.removePropertyValues(p);
        }
      }
     
     
     
View Full Code Here

  /**
   * display specific instance (path to root)
   * @param i
   */
  public void setInstance(IInstance i){
    IClass c = i.getDirectTypes()[0];
    // get path
    List<ClassPath> paths = OntologyUtils.getRootPaths(c);
    // set first path
    if(!paths.isEmpty()){
      ExplorerPanel panel = root;
View Full Code Here

    List<IClass> list = new ArrayList<IClass>();
    for(Object s: obj){
      String name = (String) s;
      // check for valid names
      if(name.matches("[\\w-]+")){
        IClass cls = ont.getClass(name);
        if(cls != null)
          list.add(cls);
      }
    }
    return list;
View Full Code Here

TOP

Related Classes of edu.pitt.ontology.IClass

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.