Package com.hp.hpl.jena.ontology

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


                                          int maxDepth,
                                          double initialScore,
                                          double degradingCoefficient,
                                          String keyword,
                                          List<RelatedKeyword> relatedKeywords) {
        OntClass ontClass = model.getOntClass(classURI);
        if (ontClass == null || ontClass.isAnon() || isClassNotValid(ontClass)) {
            log.warn("Can not find class with uri {}, skipping ...", classURI);
        } else if (maxDepth == 0) {
            log.debug("Max depth reached not examining the resource {}", classURI);
            return;
        } else {
            String rkw = ontClass.getLocalName();
            relatedKeywords.add(new RelatedKeywordImpl(rkw, initialScore, "Ontology"));
            log.debug("Added {} as a related keyword to {} by super class relation", rkw, keyword);
            log.debug("Computing super class closure of {} ", classURI);
            List<OntClass> superClasses = ontClass.listSuperClasses(true).toList();
            for (OntClass superClass : superClasses) {
                computeSuperClassClosure(superClass.getURI(), maxDepth - 1, initialScore
                                                                            / degradingCoefficient,
                    degradingCoefficient, keyword, relatedKeywords);
            }
View Full Code Here


                                        int maxDepth,
                                        double initialScore,
                                        double degradingCoefficient,
                                        String keyword,
                                        List<RelatedKeyword> relatedKeywords) {
        OntClass ontClass = model.getOntClass(classURI);
        if (ontClass == null || ontClass.isAnon() || isClassNotValid(ontClass)) {
            log.warn("Can not find class with uri {}, skipping ...", classURI);
        } else if (maxDepth == 0) {
            log.debug("Max depth reached not examining the resource {}", classURI);
            return;
        } else {
            String rkw = ontClass.getLocalName();
            relatedKeywords.add(new RelatedKeywordImpl(rkw, initialScore, "Ontology"));
            log.debug("Added {} as related keyword to {} by sub class relation", classURI, keyword);
            log.debug("Computing sub class closure of {} ", classURI);
            List<OntClass> subClasses = ontClass.listSubClasses(true).toList();
            for (OntClass subClass : subClasses) {
                computeSubClassClosure(subClass.getURI(), maxDepth - 1, initialScore / degradingCoefficient,
                    degradingCoefficient, keyword, relatedKeywords);
            }
        }
View Full Code Here

    private void computeInstanceClosure(String classURI,
                                        double initialScore,
                                        double degradingCoefficient,
                                        String keyword,
                                        List<RelatedKeyword> relatedKeywords) {
        OntClass ontClass = model.getOntClass(classURI);
        if (ontClass == null || ontClass.isAnon() || isClassNotValid(ontClass)) {
            log.warn("Can not find class with uri {}, skipping ...", classURI);
        } else {
            log.debug("Computing instance closure of class {} ", classURI);
            List<? extends OntResource> instances = ontClass.listInstances(true).toList();
            for (OntResource instance : instances) {
                if (instance == null || instance.isAnon() || !instance.isIndividual()) {
                    continue;
                } else {
                    Individual individual = instance.asIndividual();
View Full Code Here

     *            Unique reference of object for which the {@link OntClass} is requested.
     * @return {@link OntClass} instance.
     */
    public OntClass createOntClassByReference(String reference) {
        log.debug("Creating OWL Class for reference {}", reference);
        OntClass klass = null;

        try {
            klass = getOntClassByReference(reference);
        } catch (UnsupportedPolymorphismException e) {
            log.warn("Another type of resource has been created for the reference: {}", reference);
            return null;
        } catch (ConversionException e) {
            log.warn("Another type of resource has been created for the reference: {}", reference);
            return null;
        }

        if (klass == null) {
            String classURI = namingStrategy.getClassName(ontologyURI, reference);
            klass = ontModel.createClass(classURI);
            klass.addProperty(CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP, reference);
            log.debug("OWL Class {} not found for reference. Creating new one...", reference);
        }

        return klass;
    }
View Full Code Here

     *            {@link CMSObject} object for which the {@link OntClass} is requested.
     * @return {@link OntClass} instance.
     */
    public OntClass createOntClassByCMSObject(CMSObject cmsObject) {
        log.debug("Getting OWL Class for cms object = {}", cmsObject);
        OntClass klass = null;
        try {
            klass = getOntClassByReference(cmsObject.getUniqueRef());
        } catch (UnsupportedPolymorphismException e) {
            log.warn("Another type of resource has been created for the CMS object: {}",
                cmsObject.getLocalname());
            return null;
        } catch (ConversionException e) {
            log.warn("Another type of resource has been created for the CMS object: {}",
                cmsObject.getLocalname());
            return null;
        }

        if (klass == null) {
            String classURI = namingStrategy.getClassName(ontologyURI, cmsObject);
            klass = ontModel.createClass(classURI);
            klass.addProperty(CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP, cmsObject.getUniqueRef());
            log.debug("OWL Class {} not found creating...", classURI);
        }

        return klass;
    }
View Full Code Here

     *            {@link ObjectTypeDefinition} object for which the {@link OntClass} is requested.
     * @return {@link OntClass} instance.
     */
    public OntClass createOntClassByObjectTypeDefinition(ObjectTypeDefinition objectTypeDefinition) {
        log.debug("Getting OWL Class for node type {}", objectTypeDefinition);
        OntClass klass = null;

        try {
            klass = getOntClassByReference(objectTypeDefinition.getUniqueRef());
        } catch (UnsupportedPolymorphismException e) {
            log.warn("Another type of resource has been created for the object type definition: {}",
                objectTypeDefinition.getLocalname());
            return null;
        } catch (ConversionException e) {
            log.warn("Another type of resource has been created for the object type definition: {}",
                objectTypeDefinition.getLocalname());
            return null;
        }

        if (klass == null) {
            String classURI = namingStrategy.getClassName(ontologyURI, objectTypeDefinition);
            klass = ontModel.createClass(classURI);
            klass.addProperty(CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP,
                objectTypeDefinition.getUniqueRef());
            log.debug("OWL Class {} not found, creating new one...", classURI);
        }

        return klass;
View Full Code Here

     *            for which the union class is requested
     * @return {@link OntClass} instance.
     */
    public OntClass createUnionClass(RDFList list) {
        String unionClassURI = namingStrategy.getUnionClassURI(ontologyURI, list);
        OntClass unionClass = ontModel.createUnionClass(unionClassURI, list);
        return unionClass;
    }
View Full Code Here

     */
    private void createClassesForObjectTypes(List<ObjectType> objectTypes) throws Exception {
        // FIXME What about caching Common Domain model instances
        // for each object type create a class
        for (ObjectType type : objectTypes) {
            OntClass klass = orh.createOntClassByObjectTypeDefinition(CMISModelMapper
                    .getObjectTypeDefinition(type));
            for (PropertyDefinition<?> propDef : type.getPropertyDefinitions().values()) {
                org.apache.stanbol.cmsadapter.servicesapi.model.web.PropertyDefinition propertyDef = CMISModelMapper
                        .getPropertyDefinition(propDef);
                if (objectPropertyCheck(propertyDef)) {
                    orh.createObjectPropertyByPropertyDefinition(propertyDef,
                        Arrays.asList(new Resource[] {klass}), new ArrayList<Resource>(1));
                } else {
                    orh.createDatatypePropertyByPropertyDefinition(propertyDef,
                        Arrays.asList(new Resource[] {klass}));
                }
            }
        }

        // for each parent id create a superclass relation
        for (ObjectType type : objectTypes) {
            ObjectType parentType = type.getParentType();
            if (parentType != null) {
                OntClass klass = orh.createOntClassByObjectTypeDefinition(CMISModelMapper
                        .getObjectTypeDefinition(type));
                OntClass parentClass = orh.createOntClassByObjectTypeDefinition(CMISModelMapper
                        .getObjectTypeDefinition(parentType));
                klass.addSuperClass(parentClass);
            }
        }
    }
View Full Code Here

            List<Resource> ranges = new ArrayList<Resource>();

            List<ObjectType> allowedSourceTypes = relType.getAllowedSourceTypes();
            if (allowedSourceTypes != null) {
                for (ObjectType type : allowedSourceTypes) {
                    OntClass klass = orh.createOntClassByObjectTypeDefinition(CMISModelMapper
                            .getObjectTypeDefinition(type));
                    domains.add(klass);
                }
            }
            List<ObjectType> allowedTargetTypes = relType.getAllowedTargetTypes();
            if (allowedTargetTypes != null) {
                for (ObjectType type : allowedTargetTypes) {
                    OntClass klass = orh.createOntClassByObjectTypeDefinition(CMISModelMapper
                            .getObjectTypeDefinition(type));
                    ranges.add(klass);
                }
            }
View Full Code Here

    private void processSubsumptionBridgeCreate(SubsumptionBridge s,
                                                DObject parentObject,
                                                MappingEngine engine) throws RepositoryAccessException {

        OntologyResourceHelper orh = engine.getOntologyResourceHelper();
        OntClass parentClass = orh.createOntClassByCMSObject(parentObject.getInstance());
        if (parentClass != null) {
            processSubsumptionBridgeCreate(s.getPredicateName(), parentObject, engine, parentClass);
        } else {
            logger.warn("Failed to create OntClass for CMS Object {} while processing bridges for creation",
                parentObject.getName());
View Full Code Here

TOP

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

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.