All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.protege.editor.owl.model.hierarchy.tabbed.AbstractOWLObjectHierarchyCreator Maven / Gradle / Ivy

Go to download

OWL ontology editing infrastructure used by the Protege desktop application.

The newest version!
package org.protege.editor.owl.model.hierarchy.tabbed;

import com.google.common.base.Optional;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyChange;
import org.slf4j.LoggerFactory;

import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/*
 * Copyright (C) 2007, University of Manchester
 *
 *
 */

/**
 * Author: Matthew Horridge
* The University Of Manchester
* Medical Informatics Group
* Date: 16-Jul-2006

* [email protected]
* www.cs.man.ac.uk/~horridgm

*/ public abstract class AbstractOWLObjectHierarchyCreator { private OWLDataFactory dataFactory; private OWLOntology ontology; private List edges; public AbstractOWLObjectHierarchyCreator(OWLDataFactory dataFactory, OWLOntology ontology, List edges) { this.dataFactory = dataFactory; this.ontology = ontology; this.edges = edges; } public OWLDataFactory getDataFactory() { return dataFactory; } public OWLOntology getOntology() { return ontology; } protected List hierarchyCreationStart() { return Collections.emptyList(); } public List createHierarchy() { List changes = new ArrayList<>(); changes.addAll(hierarchyCreationStart()); for (Edge e : edges) { if (e.isRoot()) { changes.add(getChange(e.getChild(), dataFactory)); } else { changes.add(getChange(e.getChild(), e.getParent(), dataFactory)); } } changes.addAll(hierarchyCreationEnd()); return changes; } protected List hierarchyCreationEnd() { return Collections.emptyList(); } protected IRI getIRI(String s) { try { final Optional defaultDocURI = ontology.getOntologyID().getDefaultDocumentIRI(); return IRI.create(new URI(defaultDocURI.get().getScheme(), defaultDocURI.get().toURI().getSchemeSpecificPart(), s)); } catch (Exception e) { LoggerFactory.getLogger(AbstractOWLObjectHierarchyCreator.class) .error("An error occurred whilst creating an IRI: {}", e); } return null; } public abstract OWLOntologyChange getChange(String objName, OWLDataFactory dataFactory); public abstract OWLOntologyChange getChange(String childName, String parentName, OWLDataFactory dataFactory); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy