Package com.hp.hpl.jena.ontology

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


      entities = new ArrayList<PropertyInfo>();
    }
   
    ExtendedIterator<ObjectProperty> props = ontModel.listObjectProperties();
    while ( props.hasNext() ) {
      ObjectProperty prop = props.next();
      PropertyInfo entityInfo = _createPropertyInfo(prop, ontologyUri, ontModel);
      if ( entityInfo != null ) {
        entities.add(entityInfo);
      }
    }
View Full Code Here


         //Criar um iterador com os objectRelations da ontologia
         ExtendedIterator<ObjectProperty> objProperties = ontologia.listObjectProperties();
       
         //adiciona ao conjunto todos os OntProperty encontrados
         while (objProperties.hasNext()) {
             ObjectProperty objProperty = (ObjectProperty) objProperties.next();
             conjunto.add(objProperty);
         }

         //retorna o conjunto final
         return conjunto;
View Full Code Here

        final String str = row.get(i).trim();
        if (str.length() > 0) {
          if (r instanceof OntClass) {
            OntClass cls = (OntClass) r;
            Individual ind2 = createIndividual(row, i, cls);
            ObjectProperty p = getPropertyForARangeClass(cls);
            if (cls == null || ind2 == null || p == null
                || ind == null) {
              System.err.println("cls " + cls + "  p " + p
                  + "  ind2 " + ind2 + " ind " + ind);
            } else {
View Full Code Here

  }

 
  private ObjectProperty getPropertyForARangeClass(OntClass cs) {
    String nameOfProperty = "has" + cs.getLocalName();
    ObjectProperty op = newOntModel.createObjectProperty(cs.getNameSpace()
        + nameOfProperty);
    op.setDomain(classForTerms);
    op.setRange(cs);

    return op;

  }
View Full Code Here

     */
    public ObjectProperty createObjectPropertyByPropertyDefinition(PropertyDefinition propertyDefinition,
                                                                   List<Resource> domains,
                                                                   List<Resource> ranges) {
        log.debug("Creating Object property for property {}", propertyDefinition);
        ObjectProperty objectProperty = null;
        try {
            objectProperty = getObjectPropertyByReference(propertyDefinition.getUniqueRef());
        } catch (UnsupportedPolymorphismException e) {
            log.warn("Another type of resource has been created for the property definition: {}",
                propertyDefinition.getLocalname());
            return null;
        } catch (ConversionException e) {
            log.warn("Another type of resource has been created for the property definition: {}",
                propertyDefinition.getLocalname());
            return null;
        }

        if (objectProperty == null) {
            String propertyURI = namingStrategy.getObjectPropertyName(ontologyURI, propertyDefinition);
            objectProperty = ontModel.createObjectProperty(propertyURI);
            objectProperty.addProperty(CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP,
                propertyDefinition.getUniqueRef());
            if (propertyDefinition.getSourceObjectTypeRef() != null) {
                objectProperty.addProperty(CMSAdapterVocabulary.CMSAD_PROPERTY_SOURCE_OBJECT_PROP,
                    propertyDefinition.getSourceObjectTypeRef());
            } else {
                log.warn("Source object type reference not found on property definition {}",
                    propertyDefinition.getLocalname());
            }

            for (Resource domain : domains) {
                objectProperty.addDomain(domain);
            }
            for (Resource range : ranges) {
                objectProperty.addRange(range);
            }
            log.debug("ObjectProperty {} not found, creating new one...", propertyURI);
        } else {
            // Add domains to union class
            OntResource domain = objectProperty.getDomain();
            if (domain != null) {
                if (domain.isClass() && domain.asClass().isUnionClass()) {
                    UnionClass unclass = domain.asClass().asUnionClass();
                    for (Resource newDomain : domains) {
                        unclass.addOperand(newDomain);
                    }
                } else {
                    List<Resource> resources = new ArrayList<Resource>(domains);
                    resources.add(domain);
                    objectProperty.setDomain(createUnionClass(resources));
                }
            }

            // Add ranges to union class

            OntResource range = objectProperty.getRange();
            if (range != null) {
                if (range.isClass() && range.asClass().isUnionClass()) {
                    UnionClass unclass = range.asClass().asUnionClass();
                    for (Resource newRange : ranges) {
                        unclass.addOperand(newRange);
                    }
                } else {
                    List<Resource> resources = new ArrayList<Resource>(ranges);
                    resources.add(range);
                    objectProperty.setDomain(createUnionClass(resources));
                }
            }
        }
        return objectProperty;
    }
View Full Code Here

            OntologyResourceHelper orh = engine.getOntologyResourceHelper();

            if ((propDef.getPropertyType() == PropType.NAME) || (propDef.getPropertyType() == PropType.PATH)
                || (propDef.getPropertyType() == PropType.REFERENCE)) {

                ObjectProperty op = orh.createObjectPropertyByPropertyDefinition(propDef.getInstance(),
                    Arrays.asList(new Resource[] {subjectClass}), new ArrayList<Resource>());

                if (op == null) {
                    logger.warn("Failed to create ObjectProperty for property definition {}",
                        propDef.getName());
View Full Code Here

                    logger.warn("Error while getting referenced value {} ", referencedPath, e);
                }
            }
        }

        ObjectProperty objectProperty = null;

        try {
            objectProperty = orh.getObjectPropertyByReference(propDef.getUniqueRef());
        } catch (UnsupportedPolymorphismException e) {
            logger.warn("Another type of resource has been created for the property definition: {}",
View Full Code Here

    }

    public void testObjPropJenaToOwl() {
        JenaToOwlConvert j2o = new JenaToOwlConvert();
        OntModel model = ModelFactory.createOntologyModel();
        ObjectProperty jp = model.createObjectProperty(OP.toString());
        OWLObjectProperty wp = null;
        try {
            wp = j2o.ObjPropJenaToOwl(jp, RDFXML);
            if (wp == null) {
                fail("Some errors occurs");
            } else {
                assertEquals(wp.getIRI().toURI().toString(), jp.getURI().toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
            fail("Exception caugth");
        } finally {
View Full Code Here

    public void testObjPropOwlToJena() {
        JenaToOwlConvert j2o = new JenaToOwlConvert();
        OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
        OWLDataFactory factory = mgr.getOWLDataFactory();
        OWLObjectProperty op = factory.getOWLObjectProperty(IRI.create(OP));
        ObjectProperty jop = null;
        try {
            jop = j2o.ObjPropOwlToJena(op, RDFXML);
            if (jop == null) {
                fail("Some errore occurs");
            } else {
                assertEquals(jop.getURI(), op.getIRI().toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
            fail("Exception caught");
        } finally {
View Full Code Here

        JenaToOwlConvert j2o = new JenaToOwlConvert();
        OntModel model = ModelFactory.createOntologyModel();

        OntClass jenaclass = model.createClass(CLAZZ.toString());
        ObjectProperty jenaobprop = model.createObjectProperty(OP.toString());
        DatatypeProperty jenadataprop = model.createDatatypeProperty(DP.toString());
        Individual jenasub = model.createIndividual(SUBJECT.toString(), jenaclass);
        Individual jenaobj = model.createIndividual(OBJECT.toString(), jenaclass);
        AnnotationProperty jenaanno = model.createAnnotationProperty(label.toString());
        Literal value = model.createTypedLiteral(VALUE, DATATYPE.toString());
View Full Code Here

TOP

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

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.