@@ -93,20 +93,14 @@ public void performOperation(CommandState state, CommandLine line) throws Except
9393 extractor .setFillGaps (CommandLineHelper .getBooleanValue (line , "fill-gaps" , false ));
9494 extractor .setExcludeDangling (CommandLineHelper .getBooleanValue (line , "no-dangling" , true ));
9595 extractor .includeImports (useImports );
96- if ( line .hasOption ("follow-property" ) ) {
97- for ( String property : line .getOptionValues ("follow-property" ) ) {
98- extractor .followProperty (getIRI (property , "follow-property" ));
99- }
96+ for ( String property : CommandLineHelper .getOptionalValues (line , "follow-property" ) ) {
97+ extractor .followProperty (getIRI (property , "follow-property" ));
10098 }
101- if ( line .hasOption ("follow-in" ) ) {
102- for ( String prefix : line .getOptionValues ("follow-in" ) ) {
103- extractor .includePrefix (getIRI (prefix , "follow-in" ).toString ());
104- }
99+ for ( String prefix : CommandLineHelper .getOptionalValues (line , "follow-in" ) ) {
100+ extractor .includePrefix (getIRI (prefix , "follow-in" ).toString ());
105101 }
106- if ( line .hasOption ("not-follow-in" ) ) {
107- for ( String prefix : line .getOptionValues ("not-follow-in" ) ) {
108- extractor .excludePrefix (getIRI (prefix , "not-follow-in" ).toString ());
109- }
102+ for ( String prefix : CommandLineHelper .getOptionalValues (line , "not-follow-in" ) ) {
103+ extractor .excludePrefix (getIRI (prefix , "not-follow-in" ).toString ());
110104 }
111105
112106 // Setting up the initial subset
@@ -136,30 +130,17 @@ public void performOperation(CommandState state, CommandLine line) throws Except
136130 }
137131
138132 // 2. From the name or IRI of a subset defined in the ontology
139- if ( line .hasOption ("subset" ) ) {
140- for ( String subsetName : line .getOptionValues ("subset" ) ) {
141- IRI subsetIRI = ioHelper .createIRI (subsetName );
142- if ( subsetIRI != null ) {
143- addToSubset (subset , extractor .getSubset (subsetIRI ), "Adding tagged class {}" );
144- } else {
145- addToSubset (subset , extractor .getSubset (subsetName ), "Adding tagged class {}" );
146- }
133+ for ( String subsetName : CommandLineHelper .getOptionalValues (line , "subset" ) ) {
134+ IRI subsetIRI = ioHelper .createIRI (subsetName );
135+ if ( subsetIRI != null ) {
136+ addToSubset (subset , extractor .getSubset (subsetIRI ), "Adding tagged class {}" );
137+ } else {
138+ addToSubset (subset , extractor .getSubset (subsetName ), "Adding tagged class {}" );
147139 }
148140 }
149141
150142 // 3. From an explicit list of terms
151- Set <IRI > terms = new HashSet <>();
152- if ( line .hasOption ("term" ) ) {
153- for ( String term : line .getOptionValues ("term" ) ) {
154- terms .add (getIRI (term , "term" ));
155- }
156- }
157- if ( line .hasOption ("term-file" ) ) {
158- for ( String termFile : line .getOptionValues ("term-file" ) ) {
159- terms .addAll (readFileAsIRIs (termFile ));
160- }
161- }
162- for ( IRI term : terms ) {
143+ for ( IRI term : CommandLineHelper .getTerms (ioHelper , line , true ) ) {
163144 if ( ontology .containsClassInSignature (term , useImports ? Imports .INCLUDED : Imports .EXCLUDED ) ) {
164145 subset .add (factory .getOWLClass (term ));
165146 logger .debug ("Adding selected class {}" , term );
0 commit comments