1
1
package edu .isi .oba ;
2
2
3
+ import edu .isi .oba .config .CONFIG_FLAG ;
3
4
import static edu .isi .oba .Oba .logger ;
4
5
5
6
import io .swagger .v3 .oas .models .examples .Example ;
@@ -35,9 +36,8 @@ class MapperSchema {
35
36
private OWLOntology ontology_cls ;
36
37
private OWLReasonerFactory reasonerFactory ;
37
38
public List <OWLClass > properties_range ;
38
- private boolean follow_references ;
39
- private Boolean default_descriptions ;
40
- private Boolean default_properties ;
39
+
40
+ private final Map <CONFIG_FLAG , Boolean > configFlags = new HashMap <>();
41
41
42
42
public List <OWLObjectProperty > propertiesFromObjectRestrictions ;
43
43
public Map <String , List <String >> propertiesFromObjectRestrictions_ranges ;
@@ -62,11 +62,9 @@ public Schema getSchema() {
62
62
return this .schema ;
63
63
}
64
64
65
- public MapperSchema (List <OWLOntology > ontologies , OWLClass cls , String clsDescription , Map <IRI , String > schemaNames , OWLOntology class_ontology , Boolean follow_references , Boolean default_descriptions , Boolean default_properties ) {
65
+ public MapperSchema (List <OWLOntology > ontologies , OWLClass cls , String clsDescription , Map <IRI , String > schemaNames , OWLOntology class_ontology , Map < CONFIG_FLAG , Boolean > configFlags ) {
66
66
this .schemaNames = schemaNames ;
67
- this .follow_references = follow_references ;
68
- this .default_descriptions = default_descriptions ;
69
- this .default_properties = default_properties ;
67
+ this .configFlags .putAll (configFlags );
70
68
this .cls = cls ;
71
69
this .cls_description = clsDescription ;
72
70
this .type = "object" ;
@@ -230,7 +228,7 @@ private Map<String, Schema> getDataProperties() {
230
228
}
231
229
232
230
List <String > propertyRanges = getCodeGenTypesByRangeData (ranges , odp );
233
- String propertyDescription = ObaUtils .getDescription (odp , this .ontology_cls , this .default_descriptions );
231
+ String propertyDescription = ObaUtils .getDescription (odp , this .ontology_cls , this .configFlags . get ( CONFIG_FLAG . DEFAULT_DESCRIPTIONS ) );
234
232
MapperDataProperty mapperProperty = new MapperDataProperty (propertyName , propertyDescription , isFunctional , restrictionValues , valuesFromDataRestrictions_ranges , propertyRanges , array , nullable );
235
233
try {
236
234
this .properties .put (mapperProperty .name , mapperProperty .getSchemaByDataProperty ());
@@ -242,7 +240,7 @@ private Map<String, Schema> getDataProperties() {
242
240
}
243
241
}
244
242
245
- if (this .default_properties ) {
243
+ if (this .configFlags . get ( CONFIG_FLAG . DEFAULT_DESCRIPTIONS ) ) {
246
244
properties .putAll (this .getDefaultProperties ());
247
245
}
248
246
@@ -338,7 +336,7 @@ private Map<String, Schema> getObjectProperties() {
338
336
339
337
String propertyURI = odp .getIRI ().toString ();
340
338
propertyNameURI .put (propertyURI , propertyName );
341
- List <String > propertyRanges = getCodeGenTypesByRangeObject (ranges , odp , owlThing , this . follow_references );
339
+ List <String > propertyRanges = getCodeGenTypesByRangeObject (ranges , odp , owlThing );
342
340
343
341
Map <String ,String > restrictionValues = new HashMap <String , String >() ;
344
342
for (OWLOntology ontology : this .ontologies ) {
@@ -358,7 +356,7 @@ private Map<String, Schema> getObjectProperties() {
358
356
}
359
357
}
360
358
361
- String propertyDescription = ObaUtils .getDescription (odp , this .ontology_cls , this .default_descriptions );
359
+ String propertyDescription = ObaUtils .getDescription (odp , this .ontology_cls , this .configFlags . get ( CONFIG_FLAG . DEFAULT_DESCRIPTIONS ) );
362
360
MapperObjectProperty mapperObjectProperty = new MapperObjectProperty (propertyName , propertyDescription , isFunctional , restrictionValues , propertyRanges );
363
361
try {
364
362
this .properties .put (mapperObjectProperty .name , mapperObjectProperty .getSchemaByObjectProperty ());
@@ -398,10 +396,9 @@ private List<String> getCodeGenTypesByRangeData(Set<OWLDataPropertyRangeAxiom> r
398
396
* @param ranges Represents a ObjectPropertyRange
399
397
* @param odp Represents a OWLObjectProperty
400
398
* @param owlThing
401
- * @param follow_references
402
399
* @return A list<String> with the properties
403
400
*/
404
- private List <String > getCodeGenTypesByRangeObject (Set <OWLObjectPropertyRangeAxiom > ranges , OWLObjectProperty odp , OWLClass owlThing , boolean follow_references ) {
401
+ private List <String > getCodeGenTypesByRangeObject (Set <OWLObjectPropertyRangeAxiom > ranges , OWLObjectProperty odp , OWLClass owlThing ) {
405
402
List <String > objectProperty = new ArrayList <>();
406
403
407
404
for (OWLObjectPropertyRangeAxiom propertyRangeAxiom : ranges ) {
@@ -412,9 +409,8 @@ private List<String> getCodeGenTypesByRangeObject(Set<OWLObjectPropertyRangeAxio
412
409
logger .info ("Ignoring owl:Thing" + odp );
413
410
} else {
414
411
this .properties_range .add (rangeClass .asOWLClass ());
415
- if (follow_references ) {
416
- objectProperty .add (getSchemaName (rangeClass .asOWLClass ()));
417
- }
412
+ if (this .configFlags .get (CONFIG_FLAG .FOLLOW_REFERENCES ))
413
+ objectProperty .add (getSchemaName (rangeClass .asOWLClass ()));
418
414
}
419
415
}
420
416
}
@@ -469,7 +465,7 @@ private void getClassRestrictions(OWLClass analyzedClass) {
469
465
} else {
470
466
for (OWLObjectProperty op : this .propertiesFromObjectRestrictions ) {
471
467
MapperObjectProperty mapperObjectProperty ;
472
- String propertyDescription = ObaUtils .getDescription (op , this .ontology_cls , this .default_descriptions );
468
+ String propertyDescription = ObaUtils .getDescription (op , this .ontology_cls , this .configFlags . get ( CONFIG_FLAG . DEFAULT_DESCRIPTIONS ) );
473
469
if (!this .propertiesFromObjectRestrictions_ranges .isEmpty ()) {
474
470
List <String > rangesOP = this .propertiesFromObjectRestrictions_ranges .get (this .sfp .getShortForm (op .getIRI ()));
475
471
for (String j : restrictionsValuesFromClass .keySet ()) {
@@ -536,7 +532,7 @@ private void getClassRestrictions(OWLClass analyzedClass) {
536
532
537
533
for (OWLDataProperty dp : this .propertiesFromDataRestrictions ) {
538
534
List <String > valuesFromDataRestrictions_ranges = new ArrayList <>();
539
- String propertyDescription = ObaUtils .getDescription (dp , this .ontology_cls , this .default_descriptions );
535
+ String propertyDescription = ObaUtils .getDescription (dp , this .ontology_cls , this .configFlags . get ( CONFIG_FLAG . DEFAULT_DESCRIPTIONS ) );
540
536
if (!this .propertiesFromDataRestrictions_ranges .isEmpty ()) {
541
537
List <String > rangesDP = this .propertiesFromDataRestrictions_ranges .get (this .sfp .getShortForm (dp .getIRI ()));
542
538
for (String j : restrictionsValuesFromClass .keySet ()) {
@@ -601,7 +597,7 @@ private void getClassRestrictions(OWLClass analyzedClass) {
601
597
this .properties = setProperties ();
602
598
}
603
599
604
- if (this .default_properties ) {
600
+ if (this .configFlags . get ( CONFIG_FLAG . DEFAULT_PROPERTIES ) ) {
605
601
this .properties .putAll (this .getDefaultProperties ());
606
602
}
607
603
}
0 commit comments