001/**
002 * Copyright (C) 2007 - 2016, Jens Lehmann
003 *
004 * This file is part of DL-Learner.
005 *
006 * DL-Learner is free software; you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation; either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * DL-Learner is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
018 */
019package org.dllearner.core.owl;
020
021import java.util.SortedMap;
022import java.util.SortedSet;
023import java.util.TreeSet;
024
025import org.semanticweb.owlapi.model.OWLDataProperty;
026import org.semanticweb.owlapi.vocab.OWLRDFVocabulary;
027
028import uk.ac.manchester.cs.owl.owlapi.OWLDataPropertyImpl;
029
030/**
031 * Represents a hierarchy of datatype properties.
032 * 
033 * TODO: Currently, the role hierarchy pruning algorithm (analogous to the
034 * subsumption hierarchy) is not implemented.  
035 * 
036 * @author Jens Lehmann
037 *
038 */
039public class DatatypePropertyHierarchy extends AbstractHierarchy<OWLDataProperty>{
040
041        private static final OWLDataProperty OWL_TOP_DATA_PROPERTY = new OWLDataPropertyImpl(
042                        OWLRDFVocabulary.OWL_TOP_DATA_PROPERTY.getIRI());
043        private static final OWLDataProperty OWL_BOTTOM_DATA_PROPERTY = new OWLDataPropertyImpl(
044                        OWLRDFVocabulary.OWL_BOTTOM_DATA_PROPERTY.getIRI());
045
046        public DatatypePropertyHierarchy(
047                        SortedMap<OWLDataProperty, SortedSet<OWLDataProperty>> roleHierarchyUp,
048                        SortedMap<OWLDataProperty, SortedSet<OWLDataProperty>> roleHierarchyDown) {
049                super(roleHierarchyUp, roleHierarchyDown);
050        }
051        
052        public SortedSet<OWLDataProperty> getMoreGeneralRoles(OWLDataProperty role) {
053                return new TreeSet<>(getParents(role));
054        }
055        
056        public SortedSet<OWLDataProperty> getMoreSpecialRoles(OWLDataProperty role) {
057                return new TreeSet<>(getChildren(role));
058        }       
059        
060        public boolean isSubpropertyOf(OWLDataProperty subProperty, OWLDataProperty superProperty) {
061                return isChildOf(subProperty, superProperty);
062        }       
063
064        /**
065         * @return The most general roles.
066         */
067        public SortedSet<OWLDataProperty> getMostGeneralRoles() {
068                return getMostGeneralEntities();
069        }
070
071        /**
072         * @return The most special roles.
073         */
074        public SortedSet<OWLDataProperty> getMostSpecialRoles() {
075                return getMostSpecialEntities();
076        }
077
078        /* (non-Javadoc)
079         * @see org.dllearner.core.owl.AbstractHierarchy#getTopConcept()
080         */
081        @Override
082        public OWLDataProperty getTopConcept() {
083                return OWL_TOP_DATA_PROPERTY;
084        }
085
086        /* (non-Javadoc)
087         * @see org.dllearner.core.owl.AbstractHierarchy#getBottomConcept()
088         */
089        @Override
090        public OWLDataProperty getBottomConcept() {
091                return OWL_BOTTOM_DATA_PROPERTY;
092        }
093        
094        @Override
095        public DatatypePropertyHierarchy clone() {
096                return new DatatypePropertyHierarchy(getHierarchyUp(), getHierarchyDown());             
097        }
098}