diff --git a/xyz-hub-service/src/main/java/com/here/xyz/httpconnector/util/jobs/Job.java b/xyz-hub-service/src/main/java/com/here/xyz/httpconnector/util/jobs/Job.java index ed9f733f56..20e0540f2d 100644 --- a/xyz-hub-service/src/main/java/com/here/xyz/httpconnector/util/jobs/Job.java +++ b/xyz-hub-service/src/main/java/com/here/xyz/httpconnector/util/jobs/Job.java @@ -767,8 +767,8 @@ public void setSource(DatasetDescription source) { Ref ref = space.getVersionRef(); - if (ref != null && ref.isSingleVersion() && !ref.isHead()) - export.setTargetVersion("" + ref.getVersion()); + if (ref != null && !ref.isHead() && ( ref.isSingleVersion() || ref.isRange() ) ) + export.setTargetVersion( ref.toString() ); export.setFilters(space.getFilters()); if (export.getFilters() != null) { diff --git a/xyz-models/src/main/java/com/here/xyz/models/hub/Ref.java b/xyz-models/src/main/java/com/here/xyz/models/hub/Ref.java index edf319529e..64eff14ea1 100644 --- a/xyz-models/src/main/java/com/here/xyz/models/hub/Ref.java +++ b/xyz-models/src/main/java/com/here/xyz/models/hub/Ref.java @@ -88,7 +88,7 @@ public String toString() { if (allVersions) return ALL_VERSIONS; if( isRange() ) - return String.format("[%d..%d]",version, fromVersion); + return String.format("%d..%d",fromVersion,version); return String.valueOf(version); } @@ -131,7 +131,7 @@ public long getFromVersion() { } public long getToVersion() { - return getVersion(); + return version; } public boolean isHead() { @@ -143,7 +143,7 @@ public boolean isAllVersions() { } public boolean isSingleVersion() { - return !isAllVersions(); + return !isAllVersions() && !isRange(); } public boolean isRange() { diff --git a/xyz-psql-connector/src/main/java/com/here/xyz/psql/query/GetFeatures.java b/xyz-psql-connector/src/main/java/com/here/xyz/psql/query/GetFeatures.java index 0fd65eb663..a4c42b34fe 100644 --- a/xyz-psql-connector/src/main/java/com/here/xyz/psql/query/GetFeatures.java +++ b/xyz-psql-connector/src/main/java/com/here/xyz/psql/query/GetFeatures.java @@ -169,6 +169,7 @@ AND id in ( select distinct id FROM ${schema}.${table} WHERE version between #{f private SQLQuery buildVersionComparison(SelectiveEvent event) { Ref ref = event.getRef(); + if (event.getVersionsToKeep() == 1 || ref.isAllVersions() || ref.isHead()) return new SQLQuery(""); @@ -205,8 +206,13 @@ private SQLQuery buildBaseVersionCheckFragment(String versionParamName) { private SQLQuery buildMinVersionFragment(SelectiveEvent event) { Ref ref = event.getRef(); - boolean isHeadOrAllVersions = ref.isHead() || ref.isAllVersions(); - long version = isHeadOrAllVersions ? Long.MAX_VALUE : ref.getVersion(); + + long version = Long.MAX_VALUE; // => ref.isHead() || ref.isAllVersions(); + + if( ref.isSingleVersion() && !ref.isHead() ) + version = ref.getVersion(); + else if( ref.isRange() ) + version = ref.getToVersion(); // HEAD -> Long.MAX_VALUE; if (event.getVersionsToKeep() > 1) return new SQLQuery("AND greatest(#{minVersion}, (SELECT max(version) - #{versionsToKeep} FROM ${schema}.${table})) <= #{version}") @@ -214,7 +220,7 @@ private SQLQuery buildMinVersionFragment(SelectiveEvent event) { .withNamedParameter("minVersion", event.getMinVersion()) .withNamedParameter("version", version); - return isHeadOrAllVersions ? new SQLQuery("") : new SQLQuery("AND #{version} = (SELECT max(version) AS HEAD FROM ${schema}.${table})") + return version == Long.MAX_VALUE ? new SQLQuery("") : new SQLQuery("AND #{version} = (SELECT max(version) AS HEAD FROM ${schema}.${table})") .withNamedParameter("version", version); }