diff --git a/impexp-client-cli/src/main/java/org/citydb/cli/options/deleter/QueryOption.java b/impexp-client-cli/src/main/java/org/citydb/cli/options/deleter/QueryOption.java index 64b4f02b7..8e1c9ee00 100644 --- a/impexp-client-cli/src/main/java/org/citydb/cli/options/deleter/QueryOption.java +++ b/impexp-client-cli/src/main/java/org/citydb/cli/options/deleter/QueryOption.java @@ -48,7 +48,6 @@ import org.citydb.registry.ObjectRegistry; import picocli.CommandLine; -import javax.xml.datatype.DatatypeFactory; import java.util.ArrayList; import java.util.List; @@ -92,14 +91,14 @@ public QueryConfig toQueryConfig() { queryConfig.setFeatureTypeFilter(typeNamesOption.toFeatureTypeFilter()); } - if (featureVersionOption != null) { - DatatypeFactory datatypeFactory = ObjectRegistry.getInstance().getDatatypeFactory(); - SimpleFeatureVersionFilter versionFilter = featureVersionOption.toFeatureVersionFilter(datatypeFactory); - if (versionFilter != null) { - AbstractPredicate predicate = versionFilter.toPredicate(); - if (predicate != null) { - predicates.add(predicate); - } + SimpleFeatureVersionFilter versionFilter = featureVersionOption != null ? + featureVersionOption.toFeatureVersionFilter(ObjectRegistry.getInstance().getDatatypeFactory()) : + FeatureVersionOption.defaultFeatureVersionFilter(); + + if (versionFilter != null) { + AbstractPredicate predicate = versionFilter.toPredicate(); + if (predicate != null) { + predicates.add(predicate); } } diff --git a/impexp-client-cli/src/main/java/org/citydb/cli/options/exporter/QueryOption.java b/impexp-client-cli/src/main/java/org/citydb/cli/options/exporter/QueryOption.java index 8105b6bbb..5b2ef77e0 100644 --- a/impexp-client-cli/src/main/java/org/citydb/cli/options/exporter/QueryOption.java +++ b/impexp-client-cli/src/main/java/org/citydb/cli/options/exporter/QueryOption.java @@ -48,7 +48,6 @@ import org.citydb.registry.ObjectRegistry; import picocli.CommandLine; -import javax.xml.datatype.DatatypeFactory; import java.util.ArrayList; import java.util.List; @@ -104,14 +103,14 @@ public QueryConfig toQueryConfig() { queryConfig.setFeatureTypeFilter(typeNamesOption.toFeatureTypeFilter()); } - if (featureVersionOption != null) { - DatatypeFactory datatypeFactory = ObjectRegistry.getInstance().getDatatypeFactory(); - SimpleFeatureVersionFilter versionFilter = featureVersionOption.toFeatureVersionFilter(datatypeFactory); - if (versionFilter != null) { - AbstractPredicate predicate = versionFilter.toPredicate(); - if (predicate != null) { - predicates.add(predicate); - } + SimpleFeatureVersionFilter versionFilter = featureVersionOption != null ? + featureVersionOption.toFeatureVersionFilter(ObjectRegistry.getInstance().getDatatypeFactory()) : + FeatureVersionOption.defaultFeatureVersionFilter(); + + if (versionFilter != null) { + AbstractPredicate predicate = versionFilter.toPredicate(); + if (predicate != null) { + predicates.add(predicate); } } diff --git a/impexp-config/src/main/java/org/citydb/config/project/query/simple/SimpleFeatureVersionFilter.java b/impexp-config/src/main/java/org/citydb/config/project/query/simple/SimpleFeatureVersionFilter.java index b2abd6e11..fdcd7fb9d 100644 --- a/impexp-config/src/main/java/org/citydb/config/project/query/simple/SimpleFeatureVersionFilter.java +++ b/impexp-config/src/main/java/org/citydb/config/project/query/simple/SimpleFeatureVersionFilter.java @@ -53,7 +53,7 @@ public class SimpleFeatureVersionFilter { private XMLGregorianCalendar endDate; public SimpleFeatureVersionFilterMode getMode() { - return mode; + return mode != null ? mode : SimpleFeatureVersionFilterMode.LATEST; } public void setMode(SimpleFeatureVersionFilterMode mode) { diff --git a/impexp-plugin-api/src/main/java/org/citydb/plugin/cli/FeatureVersionOption.java b/impexp-plugin-api/src/main/java/org/citydb/plugin/cli/FeatureVersionOption.java index 153250d83..4efb11f7f 100644 --- a/impexp-plugin-api/src/main/java/org/citydb/plugin/cli/FeatureVersionOption.java +++ b/impexp-plugin-api/src/main/java/org/citydb/plugin/cli/FeatureVersionOption.java @@ -46,8 +46,8 @@ import java.time.temporal.ChronoField; public class FeatureVersionOption implements CliOption { - @CommandLine.Option(names = {"-r", "--feature-version"}, required = true, - description = "Feature version: ${COMPLETION-CANDIDATES}.") + @CommandLine.Option(names = {"-r", "--feature-version"}, required = true, defaultValue = "latest", + description = "Feature version: ${COMPLETION-CANDIDATES} (default: ${DEFAULT-VALUE}).") private Version version; @CommandLine.Option(names = {"-R", "--feature-version-timestamp"}, paramLabel = "", @@ -60,6 +60,10 @@ public class FeatureVersionOption implements CliOption { private OffsetDateTime endDateTime; private SimpleFeatureVersionFilter featureVersionFilter; + public static SimpleFeatureVersionFilter defaultFeatureVersionFilter() { + return new SimpleFeatureVersionFilter(); + } + public SimpleFeatureVersionFilter toFeatureVersionFilter(DatatypeFactory datatypeFactory) { if (featureVersionFilter != null) { if (startDateTime != null) {