diff --git a/impexp-client-cli/src/main/java/org/citydb/cli/operation/deleter/QueryOption.java b/impexp-client-cli/src/main/java/org/citydb/cli/operation/deleter/QueryOption.java index a4126efe7..5102185b7 100644 --- a/impexp-client-cli/src/main/java/org/citydb/cli/operation/deleter/QueryOption.java +++ b/impexp-client-cli/src/main/java/org/citydb/cli/operation/deleter/QueryOption.java @@ -68,63 +68,86 @@ public class QueryOption implements CliOption { @CommandLine.ArgGroup private XMLQueryOption xmlQueryOption; - public QueryConfig toQueryConfig() { - if (typeNamesOption != null - || featureVersionOption != null - || resourceIdOption != null - || databaseIdOption != null - || boundingBoxOption != null - || counterOption != null - || sqlSelectOption != null) { - QueryConfig queryConfig = new QueryConfig(); - List predicates = new ArrayList<>(); - - if (typeNamesOption != null) { - queryConfig.setFeatureTypeFilter(typeNamesOption.toFeatureTypeFilter()); - } + private void addFeatureTypeFilter(QueryConfig queryConfig) { + if (typeNamesOption != null) { + queryConfig.setFeatureTypeFilter(typeNamesOption.toFeatureTypeFilter()); + } + } - SimpleFeatureVersionFilter versionFilter = featureVersionOption != null ? - featureVersionOption.toFeatureVersionFilter() : - FeatureVersionOption.defaultFeatureVersionFilter(); + private void addVersionFilter(QueryConfig queryOption, List predicates) { + SimpleFeatureVersionFilter versionFilter = featureVersionOption != null ? + featureVersionOption.toFeatureVersionFilter() : + FeatureVersionOption.defaultFeatureVersionFilter(); - if (versionFilter != null) { - AbstractPredicate predicate = versionFilter.toPredicate(); - if (predicate != null) { - predicates.add(predicate); - } + if (versionFilter != null) { + AbstractPredicate predicate = versionFilter.toPredicate(); + if (predicate != null) { + predicates.add(predicate); } + } + } - if (resourceIdOption != null) { - ResourceIdOperator idOperator = resourceIdOption.toResourceIdOperator(); - if (idOperator != null) { - predicates.add(idOperator); - } + private void addResourceIdOperator(List predicates) { + if (resourceIdOption != null) { + ResourceIdOperator idOperator = resourceIdOption.toResourceIdOperator(); + if (idOperator != null) { + predicates.add(idOperator); } + } + } - if (databaseIdOption != null) { - DatabaseIdOperator idOperator = databaseIdOption.toDatabaseIdOperator(); - if (idOperator != null) { - predicates.add(idOperator); - } + private void addDatabaseIdOption(List predicates) { + if (databaseIdOption != null) { + DatabaseIdOperator idOperator = databaseIdOption.toDatabaseIdOperator(); + if (idOperator != null) { + predicates.add(idOperator); } + } + } - if (boundingBoxOption != null) { - AbstractSpatialOperator spatialOperator = boundingBoxOption.toSpatialOperator(); - if (spatialOperator != null) { - predicates.add(spatialOperator); - } + private void addBoundingBoxOptionPredicates(List predicates) { + if (boundingBoxOption != null) { + AbstractSpatialOperator spatialOperator = boundingBoxOption.toSpatialOperator(); + if (spatialOperator != null) { + predicates.add(spatialOperator); } + } + } - if (counterOption != null) { - queryConfig.setCounterFilter(counterOption.toCounterFilter()); - } + private void addCounterOptionFilter(QueryConfig queryConfig) { + if (counterOption != null) { + queryConfig.setCounterFilter(counterOption.toCounterFilter()); + } + } - if (sqlSelectOption != null) { - SelectOperator selectOperator = sqlSelectOption.toSelectOperator(); - if (selectOperator != null) { - predicates.add(selectOperator); - } + private void addSqlSelectPredicates(List predicates) { + if (sqlSelectOption != null) { + SelectOperator selectOperator = sqlSelectOption.toSelectOperator(); + if (selectOperator != null) { + predicates.add(selectOperator); } + } + } + + public QueryConfig toQueryConfig() { + if (typeNamesOption != null + || featureVersionOption != null + || resourceIdOption != null + || databaseIdOption != null + || boundingBoxOption != null + || counterOption != null + || sqlSelectOption != null) { + QueryConfig queryConfig = new QueryConfig(); + List predicates = new ArrayList<>(); + + addFeatureTypeFilter(queryConfig); + addVersionFilter(queryConfig, predicates); + addResourceIdOperator(predicates); + addDatabaseIdOption(predicates); + addBoundingBoxOptionPredicates(predicates); + addCounterOptionFilter(queryConfig); + addSqlSelectPredicates(predicates); + if (!predicates.isEmpty()) { AndOperator andOperator = new AndOperator();