001 // This file is part of AceWiki.
002 // Copyright 2008-2012, AceWiki developers.
003 //
004 // AceWiki is free software: you can redistribute it and/or modify it under the terms of the GNU
005 // Lesser General Public License as published by the Free Software Foundation, either version 3 of
006 // the License, or (at your option) any later version.
007 //
008 // AceWiki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
009 // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
010 // Lesser General Public License for more details.
011 //
012 // You should have received a copy of the GNU Lesser General Public License along with AceWiki. If
013 // not, see http://www.gnu.org/licenses/.
014
015 package ch.uzh.ifi.attempto.acewiki.owl;
016
017 import java.util.ArrayList;
018
019 import org.semanticweb.owlapi.model.IRI;
020 import org.semanticweb.owlapi.model.OWLAnnotation;
021 import org.semanticweb.owlapi.model.OWLDataFactory;
022 import org.semanticweb.owlapi.model.OWLDeclarationAxiom;
023 import org.semanticweb.owlapi.model.OWLLogicalEntity;
024
025 import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl;
026 import uk.ac.manchester.cs.owl.owlapi.OWLDeclarationAxiomImpl;
027 import ch.uzh.ifi.attempto.acewiki.core.AbstractOntologyElement;
028
029 /**
030 * This is a partial implementation of an ontology element that has an OWL representation.
031 *
032 * @author Tobias Kuhn
033 */
034 public abstract class AbstractOWLOntoElement extends AbstractOntologyElement
035 implements OWLOntoElement {
036
037 private static OWLDataFactory dataFactory = new OWLDataFactoryImpl();
038
039 public final IRI getIRI() {
040 String baseIRI = "";
041 if (getOntology() != null) {
042 baseIRI = getOntology().getURI();
043 }
044 return IRI.create(baseIRI + "#" + getIRISuffix());
045 }
046
047 /**
048 * Returns the suffix of the OWL identifier of this ontology element. Such identifiers are IRIs
049 * and the suffix is the part after the hash sign.
050 *
051 * @return The IRI suffix.
052 */
053 public abstract String getIRISuffix();
054
055 /**
056 * Returns the OWL data factory object.
057 *
058 * @return The OWL data factory.
059 */
060 public OWLDataFactory getOWLDataFactory() {
061 return dataFactory;
062 }
063
064 public OWLDeclarationAxiom getOWLDeclaration() {
065 OWLLogicalEntity owl = getOWLRepresentation();
066 if (owl == null) {
067 return null;
068 } else {
069 return new OWLDeclarationAxiomImpl(
070 dataFactory,
071 getOWLRepresentation(),
072 new ArrayList<OWLAnnotation>()
073 );
074 }
075 }
076
077 }