Package com.hp.hpl.jena.ontology

Examples of com.hp.hpl.jena.ontology.OntProperty


    }
   
    // include no more than cardinality restrictions for referenced elements
    if (!this.equals(def)) return;
   
    OntProperty property = null;
    Resource range = null;
    complexType ct = def.complexType;
    if (ct==null) ct = ctx.getComplexType(type);   
    if (ct!=null) {
      property = getModel().createObjectProperty(uri);     
      range = ct.toOWL(null,true, ctx);     
    }
    else if (def.simpleType!=null || ctx.getSimpleType(type)!=null) {
      simpleType s = def.simpleType;
      if (s==null) s = ctx.getSimpleType(type);
      // add simpleType range restrictions
      property = getModel().createOntProperty(uri);
      s.defineType(property,ctx);
      range = s.toOWL(ctx);
    }
    // schema datatype
    else {
      property = getModel().createOntProperty(uri);
      schema.defineType(property,type);
      range = schema.toOWL(xs.ont,type);
     
      // ecore extension
      if (ecore!=null) ecore.toOWL(getModel(), uri, rest, get_node(), type, ctx);
    }
   
    // add the type to the restrictions and property range
    if (ctx.isGlobalElement(def) && ctx.isClosed() && range!=null && !schema.isID(range)
        && !Restrictions.voidClass(range))
      property.addRange(range);
   
    if (rest!=null) rest.addRange(uri,range);
 
    // a nillable element may refer to rdf:nil (an object)
    if (def.is_nillable()) nullify(getModel(), rest, ctx, uri, def, property);
   
    // add comments
    if (annotation!=null) annotation.toOWL(property,ctx);
   
    // substitution groups map to subProperty relationships
    if (substitutionGroup!=null) {
      String sub = createURI(getModel(),getSubstitutionGroup(),ctx);
      property.addSuperProperty(getModel().createProperty(sub));
    }
   
  }
View Full Code Here


    }
   
    // include no more than cardinality restrictions for referenced attributes
    if (!this.equals(def)) return;

    OntProperty property = xs.ont.createOntProperty(uri);

    Resource range = null;
    simpleType s = def.simpleType;
    if (s==null) s = ctx.getSimpleType(type);
    if (s!=null) {
      s.defineType(property,ctx);
      range = s.toOWL(ctx);
    }
    else {
      // default attribute type
      if (type==null) type = schema.anySimpleType;
      schema.defineType(property,type);
      range = schema.toOWL(xs.ont,type);
     
      // ecore extensions
      if (ecore!=null) ecore.toOWL(getModel(), uri, rest, get_node(), type, ctx);
    }
   
    // remove all evidence of an ID attribute
    if (range!=null && schema.isID(range)) property.remove();
   
    // Don't bother to add a range restriction only for it to be cleaned up afterwards (noRest)
    if (range!=null && rest!=null && !noRest && !schema.isID(range))
      rest.addRange(uri, range);
   
    // global attribute closure
    if (property.getRange()==null && ctx.isGlobalAttribute(def)
        && ctx.isClosed() && range!=null && !schema.ID.equals(range.getURI())) {
      property.setRange(range);
    }
   
    if (noRest) rest.cleanup(xs.ont,uri);
   
    // add comments
View Full Code Here

    rest.adjust(xs.ont);
    List<OntClass> restrictions = new Vector<OntClass>();
    // minCardinality (and cardinality)
    for (String key: rest.getMinCard().keySet()) {
      OntModel ont = rest.getModel(key);
      OntProperty p = ont.createOntProperty(key);
      Integer minCard = rest.getMinCard().get(key);
      // maxCard includes occurrences of any
      Integer maxCard = Restrictions.sum(rest.getMaxCard().get(key), rest.getAny(key,tns));
      if (maxCard!=null && minCard==maxCard)
        restrictions.add(xs.ont.createCardinalityRestriction(null,p,minCard));
      else if (minCard>0)
        restrictions.add(xs.ont.createMinCardinalityRestriction(null,p,minCard));
    }
    // maxCardinality
    for (String key: rest.getMaxCard().keySet()) {
      OntModel ont = rest.getModel(key);
      OntProperty p = ont.createOntProperty(key);
      int m = rest.getMaxCard().get(key);
      if (m==Integer.MAX_VALUE) continue;
      Integer minCard = rest.getMinCard().get(key);
      Integer maxCard = Restrictions.sum(rest.getMaxCard().get(key),  rest.getAny(key,tns));
      if (minCard==null || minCard!=maxCard)
        restrictions.add(xs.ont.createMaxCardinalityRestriction(null,p,maxCard));
    }
   
    // add value restrictions   
    for (String key: rest.getRange().keySet()) {
      OntModel ont = rest.getModel(key);
      OntProperty p = ont.getOntProperty(key);
      Set<Resource> s = rest.getRange().get(key);

      if (s.size()==1) {
        Resource t = s.iterator().next();
       
        if (t!=null && ont!=xs.ont) t = copyResource(t);
        // is the range implied by the global property
        if (t!=null && (p.getRange()==null || !p.getRange().equals(t)))
          restrictions.add(xs.ont.createAllValuesFromRestriction(null,p,t));         
      }
      else if (s.size()>1) {
        // create an OWL union
        UnionClass u = xs.ont.createUnionClass(null,xs.ont.createList(s.iterator()));
View Full Code Here

    entityInfo.setUri(entityUri);
    entityInfo.setLocalName(localName);

    OntResource domain = null;
    if ( prop instanceof OntProperty ) {
      OntProperty ontProp = (OntProperty) prop;
      domain = ontProp.getDomain();
    }
    if ( domain != null &&  domain.isURIResource() ) {
      String domainUri = domain.getURI();
      entityInfo.setDomainUri(domainUri);
    }
View Full Code Here

        return null;
      OntModel local = (OntModel)localOntology.getImplementation();
      if (contains(r))
        return r;
      Restriction restrict = null;
      OntProperty ont = null;
      if (r.isAllDifferent()) {
        debugDisplay("  asAllDifferent              ");// + r.asAllDifferent() );       
        return local.createAllDifferent(r.asAllDifferent().getDistinctMembers());
        }
      else if (r.isAllValuesFromRestriction()) {
View Full Code Here

   * @param ancestorURI
   * @param direct
   * @return
   */
  public static boolean hasSuperProperty(String childURI, String ancestorURI, boolean direct) {
    OntProperty childProperty = asProperty(childURI);
    OntProperty ancestorProperty =  asProperty(ancestorURI);
   
    if(childProperty == null || ancestorProperty == null) {
      return false;
    }
   
View Full Code Here

                Arrays.asList(new Resource[] {orh.createUnionClass(ranges)}));

        }
        // Create super property relations
        for (RelationshipType relType : relationshipTypes) {
            OntProperty prop = orh.getPropertyByReference(relType.getId());
            ObjectType parentType = relType.getParentType();
            if (parentType != null) {
                // TODO Check if parent type is correctly resolved to an ont class
                OntProperty parentProp = orh.getPropertyByReference(parentType.getId());
                prop.addSuperProperty(parentProp);
            }
        }
    }
View Full Code Here

                                 MappingEngine engine,
                                 CMISNodeTypeLifter lifter) {
        OntologyResourceHelper orh = engine.getOntologyResourceHelper();
        RelationshipType type = (RelationshipType) relation.getType();
        lifter.createObjectPropertyDefForRelationshipTypes(Arrays.asList(new RelationshipType[] {type}));
        OntProperty prop = orh.getDatatypePropertyByReference(type.getId());
        Individual ind = orh.getIndividualByReference(node.getUniqueRef());
        Individual target = orh.getIndividualByReference(relation.getTarget().getId());
        ind.addProperty(prop, target);
        log.debug("Added triple by relationship processor, {}, {}, {}",
            new Object[] {ind.getURI(), prop.getURI(), target.getURI()});

    }
View Full Code Here

   
    ExtendedIterator<OntProperty> itrP = ontHandler.getOntModel().listAllOntProperties();
   
    while (itrP.hasNext()) {
     
      OntProperty p = itrP.next();
     
      if (!p.isURIResource())
        continue;
     
//      if (p.isAnnotationProperty())
//        continue;

      if (!properties.containsKey(p.getURI()))
        properties.put(p.getURI(), ontHandler.getResourceLabel(p));
     
      if (p.isDatatypeProperty() || !p.isObjectProperty())
      {
        if (!dataProperties.containsKey(p.getURI()))
          dataProperties.put(p.getURI(), ontHandler.getResourceLabel(p));
      }

      if (p.isObjectProperty() || !p.isDatatypeProperty())
      {
        if (p.getRange() != null && p.getRange().hasURI(Namespaces.RDFS + "Literal")) {
          if (!dataProperties.containsKey(p.getURI())) {
            dataProperties.put(p.getURI(), ontHandler.getResourceLabel(p));
          }
        } else if (!objectProperties.containsKey(p.getURI()))
          objectProperties.put(p.getURI(), ontHandler.getResourceLabel(p));
      }
    }
  }
View Full Code Here

      directRangesUris = new HashSet<String>();
      indirectRangesUris = new HashSet<String>();
      allRanges = new HashSet<OntResource>();
      allRangesUris = new HashSet<String>();
     
      OntProperty property = this.ontHandler.getOntModel().getOntProperty(propertyUri);
      if (property == null || !property.isURIResource())
        continue;
     
      // direct domain
      ExtendedIterator<? extends OntResource> itrDomains = property.listDomain();
      while (itrDomains.hasNext()) {
        d = itrDomains.next();
        ontHandler.getMembers(d, directDomains, false);
      }
      directDomainsUris = ontHandler.getResourcesUris(directDomains);
     
      temp  = propertyDirectDomains.get(property.getURI());
      if (temp == null)
        propertyDirectDomains.put(property.getURI(), directDomainsUris);
      else
        temp.addAll(directDomainsUris);
     
      for (OntResource domain : directDomains) {
        temp = directOutDataProperties.get(domain.getURI());
        if (temp == null) {
          temp = new HashSet<String>();
          directOutDataProperties.put(domain.getURI(), temp);
        }
        temp.add(property.getURI());
      }

      // all domains
      if (directDomainsUris.contains(Uris.THING_URI))
        allDomainsUris = new HashSet<String>(this.classes.keySet());
      else {
        for (OntResource domain : directDomains) {
          allDomains.add(domain);
          ontHandler.getChildren(domain, allDomains, true);
        }
        allDomainsUris = ontHandler.getResourcesUris(allDomains);
      }

      // indirect domains
      for (String domainUri : allDomainsUris) {
        if (!directDomainsUris.contains(domainUri))
          indirectDomainsUris.add(domainUri);
      }

      temp  = propertyIndirectDomains.get(property.getURI());
      if (temp == null)
        propertyIndirectDomains.put(property.getURI(), indirectDomainsUris);
      else
        temp.addAll(indirectDomainsUris);
     
      for (String domainUri : indirectDomainsUris) {
        temp = indirectOutDataProperties.get(domainUri);
        if (temp == null) {
          temp = new HashSet<String>();
          indirectOutDataProperties.put(domainUri, temp);
        }
        temp.add(property.getURI());
      }
     
      // direct ranges
      ExtendedIterator<? extends OntResource> itrRanges = property.listRange();
      while (itrRanges.hasNext()) {
        r = itrRanges.next();
        ontHandler.getMembers(r, directRanges, false);
      }
      directRangesUris = ontHandler.getResourcesUris(directRanges);

      temp  = propertyDirectRanges.get(property.getURI());
      if (temp == null)
        propertyDirectRanges.put(property.getURI(), directRangesUris);
      else
        temp.addAll(directRangesUris);
     
      // all ranges
      for (OntResource range : directRanges) {
        allRanges.add(range);
        ontHandler.getChildren(range, allRanges, true);
      }
      allRangesUris = ontHandler.getResourcesUris(allRanges);
     
      // indirect ranges
      for (String rangeUri : allRangesUris) {
        if (!directRangesUris.contains(rangeUri))
          indirectRangesUris.add(rangeUri);
      }
     
      temp  = propertyIndirectRanges.get(property.getURI());
      if (temp == null)
        propertyIndirectRanges.put(property.getURI(), indirectRangesUris);
      else
        temp.addAll(indirectRangesUris);
     
   
  }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.ontology.OntProperty

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.