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