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 ;
8
9
9
10
import java .util .*;
10
11
11
- import org .openapitools .codegen .examples .ExampleGenerator ;
12
12
import org .semanticweb .owlapi .apibinding .OWLManager ;
13
13
import org .semanticweb .owlapi .model .*;
14
14
import org .semanticweb .owlapi .reasoner .OWLReasoner ;
@@ -35,9 +35,8 @@ class MapperSchema {
35
35
private OWLOntology ontology_cls ;
36
36
private OWLReasonerFactory reasonerFactory ;
37
37
public List <OWLClass > properties_range ;
38
- private boolean follow_references ;
39
- private Boolean default_descriptions ;
40
- private Boolean default_properties ;
38
+
39
+ private final Map <CONFIG_FLAG , Boolean > configFlags = new HashMap <>();
41
40
42
41
public List <OWLObjectProperty > propertiesFromObjectRestrictions ;
43
42
public Map <String , List <String >> propertiesFromObjectRestrictions_ranges ;
@@ -62,11 +61,9 @@ public Schema getSchema() {
62
61
return this .schema ;
63
62
}
64
63
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 ) {
64
+ public MapperSchema (List <OWLOntology > ontologies , OWLClass cls , String clsDescription , Map <IRI , String > schemaNames , OWLOntology class_ontology , Map < CONFIG_FLAG , Boolean > configFlags ) {
66
65
this .schemaNames = schemaNames ;
67
- this .follow_references = follow_references ;
68
- this .default_descriptions = default_descriptions ;
69
- this .default_properties = default_properties ;
66
+ this .configFlags .putAll (configFlags );
70
67
this .cls = cls ;
71
68
this .cls_description = clsDescription ;
72
69
this .type = "object" ;
@@ -255,7 +252,7 @@ private Map<String, Schema> getDataProperties() {
255
252
}
256
253
257
254
List <String > propertyRanges = getCodeGenTypesByRangeData (ranges , odp );
258
- String propertyDescription = ObaUtils .getDescription (odp , this .ontology_cls , this .default_descriptions );
255
+ String propertyDescription = ObaUtils .getDescription (odp , this .ontology_cls , this .configFlags . get ( CONFIG_FLAG . DEFAULT_DESCRIPTIONS ) );
259
256
MapperDataProperty mapperProperty = new MapperDataProperty (propertyName , propertyDescription , isFunctional , restrictionValues , valuesFromDataRestrictions_ranges , propertyRanges , array , nullable );
260
257
try {
261
258
this .properties .put (mapperProperty .name , mapperProperty .getSchemaByDataProperty ());
@@ -267,7 +264,7 @@ private Map<String, Schema> getDataProperties() {
267
264
}
268
265
}
269
266
270
- if (this .default_properties ) {
267
+ if (this .configFlags . get ( CONFIG_FLAG . DEFAULT_DESCRIPTIONS ) ) {
271
268
properties .putAll (this .getDefaultProperties ());
272
269
}
273
270
@@ -364,7 +361,7 @@ private Map<String, Schema> getObjectProperties() {
364
361
365
362
String propertyURI = odp .getIRI ().toString ();
366
363
propertyNameURI .put (propertyURI , propertyName );
367
- List <String > propertyRanges = getCodeGenTypesByRangeObject (ranges , odp , owlThing , this . follow_references );
364
+ List <String > propertyRanges = getCodeGenTypesByRangeObject (ranges , odp , owlThing );
368
365
369
366
Map <String ,String > restrictionValues = new HashMap <String , String >() ;
370
367
for (OWLOntology ontology : this .ontologies ) {
@@ -383,7 +380,7 @@ private Map<String, Schema> getObjectProperties() {
383
380
propertyRanges .clear ();
384
381
}
385
382
386
- String propertyDescription = ObaUtils .getDescription (odp , this .ontology_cls , this .default_descriptions );
383
+ String propertyDescription = ObaUtils .getDescription (odp , this .ontology_cls , this .configFlags . get ( CONFIG_FLAG . DEFAULT_DESCRIPTIONS ) );
387
384
MapperObjectProperty mapperObjectProperty = new MapperObjectProperty (propertyName , propertyDescription , isFunctional , restrictionValues , propertyRanges );
388
385
try {
389
386
this .properties .put (mapperObjectProperty .name , mapperObjectProperty .getSchemaByObjectProperty ());
@@ -421,10 +418,9 @@ private List<String> getCodeGenTypesByRangeData(Set<OWLDataPropertyRangeAxiom> r
421
418
* @param ranges Represents a ObjectPropertyRange
422
419
* @param odp Represents a OWLObjectProperty
423
420
* @param owlThing
424
- * @param follow_references
425
421
* @return A list<String> with the properties
426
422
*/
427
- private List <String > getCodeGenTypesByRangeObject (Set <OWLObjectPropertyRangeAxiom > ranges , OWLObjectProperty odp , OWLClass owlThing , boolean follow_references ) {
423
+ private List <String > getCodeGenTypesByRangeObject (Set <OWLObjectPropertyRangeAxiom > ranges , OWLObjectProperty odp , OWLClass owlThing ) {
428
424
List <String > objectProperty = new ArrayList <>();
429
425
430
426
for (OWLObjectPropertyRangeAxiom propertyRangeAxiom : ranges ) {
@@ -436,7 +432,7 @@ private List<String> getCodeGenTypesByRangeObject(Set<OWLObjectPropertyRangeAxio
436
432
}
437
433
else {
438
434
this .properties_range .add (rangeClass .asOWLClass ());
439
- if (follow_references )
435
+ if (this . configFlags . get ( CONFIG_FLAG . FOLLOW_REFERENCES ) )
440
436
objectProperty .add (getSchemaName (rangeClass .asOWLClass ()));
441
437
}
442
438
}
@@ -488,7 +484,7 @@ private void getClassRestrictions(OWLClass analyzedClass) {
488
484
} else {
489
485
for (OWLObjectProperty op : this .propertiesFromObjectRestrictions ) {
490
486
MapperObjectProperty mapperObjectProperty ;
491
- String propertyDescription = ObaUtils .getDescription (op , this .ontology_cls , this .default_descriptions );
487
+ String propertyDescription = ObaUtils .getDescription (op , this .ontology_cls , this .configFlags . get ( CONFIG_FLAG . DEFAULT_DESCRIPTIONS ) );
492
488
if (!this .propertiesFromObjectRestrictions_ranges .isEmpty ()) {
493
489
List <String > rangesOP = this .propertiesFromObjectRestrictions_ranges .get (this .sfp .getShortForm (op .getIRI ()));
494
490
for (String j : restrictionsValuesFromClass .keySet ()) {
@@ -512,7 +508,7 @@ private void getClassRestrictions(OWLClass analyzedClass) {
512
508
513
509
for (OWLDataProperty dp : this .propertiesFromDataRestrictions ) {
514
510
List <String > valuesFromDataRestrictions_ranges = new ArrayList <>();
515
- String propertyDescription = ObaUtils .getDescription (dp , this .ontology_cls , this .default_descriptions );
511
+ String propertyDescription = ObaUtils .getDescription (dp , this .ontology_cls , this .configFlags . get ( CONFIG_FLAG . DEFAULT_DESCRIPTIONS ) );
516
512
if (!this .propertiesFromDataRestrictions_ranges .isEmpty ()) {
517
513
List <String > rangesDP = this .propertiesFromDataRestrictions_ranges .get (this .sfp .getShortForm (dp .getIRI ()));
518
514
for (String j : restrictionsValuesFromClass .keySet ()) {
@@ -537,7 +533,7 @@ private void getClassRestrictions(OWLClass analyzedClass) {
537
533
}
538
534
}
539
535
540
- if (this .default_properties ) {
536
+ if (this .configFlags . get ( CONFIG_FLAG . DEFAULT_PROPERTIES ) ) {
541
537
this .properties .putAll (this .getDefaultProperties ());
542
538
}
543
539
}
0 commit comments