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