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.DatatypeProperty;
22 import com.hp.hpl.jena.ontology.OntProperty;
23 import com.hp.hpl.jena.ontology.OntResource;
24 import com.hp.hpl.jena.ontology.Restriction;
25
26 import java.util.Set;
27
28
29
30
31 class PropertyFactory {
32
33
34
35
36
37
38 public static ubic.basecode.ontology.model.OntologyProperty asProperty( OntProperty property, Set<Restriction> additionalRestrictions ) {
39
40 if ( property.isObjectProperty() ) {
41 return new ObjectPropertyImpl( property.asObjectProperty(), additionalRestrictions );
42 } else if ( property.isDatatypeProperty() ) {
43 return new DatatypePropertyImpl( property.asDatatypeProperty() );
44 } else {
45 return null;
46 }
47
48 }
49
50 public static Class<?> convertType( DatatypeProperty resource ) {
51 Class<?> type = java.lang.String.class;
52
53 OntResource range = resource.getRange();
54 if ( range != null ) {
55 String uri = range.getURI();
56
57 if ( uri == null ) {
58 type = java.lang.String.class;
59 } else if ( uri.equals( "http://www.w3.org/2001/XMLSchema#&xsd;string" ) ) {
60 type = java.lang.String.class;
61 } else if ( uri.equals( "http://www.w3.org/2001/XMLSchema#&xsd;boolean" ) ) {
62 type = java.lang.Boolean.class;
63 } else if ( uri.equals( "http://www.w3.org/2001/XMLSchema#&xsd;float" ) ) {
64 type = java.lang.Double.class;
65 } else if ( uri.equals( "http://www.w3.org/2001/XMLSchema#&xsd;double" ) ) {
66 type = java.lang.Double.class;
67 } else if ( uri.equals( "http://www.w3.org/2001/XMLSchema#&xsd;int" ) ) {
68 type = java.lang.Integer.class;
69 } else if ( uri.equals( "http://www.w3.org/2001/XMLSchema#&xsd;date" ) ) {
70 type = java.util.Date.class;
71 }
72 }
73 return type;
74 }
75 }