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 com.hp.hpl.jena.ontology.OntProperty;
22 import com.hp.hpl.jena.ontology.Restriction;
23 import com.hp.hpl.jena.rdf.model.Property;
24 import ubic.basecode.ontology.model.OntologyRestriction;
25
26 import java.util.Set;
27
28
29
30
31
32 class RestrictionFactory {
33
34 public static OntologyRestriction asRestriction( Restriction restriction, Set<Restriction> additionalRestrictions ) {
35
36 OntProperty onProperty = restriction.getOnProperty();
37
38 if ( onProperty.isDatatypeProperty() ) {
39 return new OntologyDatatypeRestrictionImpl( restriction, additionalRestrictions );
40 } else if ( onProperty.isObjectProperty() ) {
41 if ( restriction.isCardinalityRestriction() ) {
42 return new OntologyCardinalityRestrictionImpl( restriction, additionalRestrictions );
43 }
44 return new OntologyClassRestrictionImpl( restriction, additionalRestrictions );
45
46 } else {
47 throw new UnsupportedOperationException( "Sorry, can't convert "
48 + restriction.getOnProperty().getClass().getName() );
49 }
50
51 }
52
53 }