1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package ubic.basecode.ontology.jena;
20
21 import java.util.Collection;
22 import java.util.HashSet;
23 import java.util.Set;
24
25 import com.hp.hpl.jena.ontology.ObjectProperty;
26 import com.hp.hpl.jena.ontology.OntClass;
27 import com.hp.hpl.jena.ontology.OntResource;
28 import com.hp.hpl.jena.ontology.Restriction;
29 import com.hp.hpl.jena.util.iterator.ExtendedIterator;
30 import ubic.basecode.ontology.model.OntologyTerm;
31
32
33
34
35 public class ObjectPropertyImpl extends OntologyPropertyImpl implements ubic.basecode.ontology.model.ObjectProperty {
36
37
38
39
40 private static final long serialVersionUID = 1L;
41 private final com.hp.hpl.jena.ontology.ObjectProperty resource;
42 private final Set<Restriction> additionalRestrictions;
43
44 public ObjectPropertyImpl( ObjectProperty resource, Set<Restriction> additionalRestrictions ) {
45 super( resource );
46 this.isFunctional = resource.isFunctionalProperty();
47 this.resource = resource;
48 this.additionalRestrictions = additionalRestrictions;
49 }
50
51 @Override
52 public Collection<OntologyTerm> getRange() {
53 ExtendedIterator<? extends OntResource> iterator = resource.listRange();
54 Collection<OntologyTerm> result = new HashSet<>();
55 while ( iterator.hasNext() ) {
56 OntResource r = iterator.next();
57 if ( r.isClass() ) {
58 OntClass class1 = r.asClass();
59 result.add( new OntologyTermImpl( class1, additionalRestrictions ) );
60 } else {
61 log.warn( "Don't know how to deal with " + r );
62 }
63 }
64 return result;
65 }
66 }