Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to search for terminated features #192

Merged
merged 4 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,26 @@ private void doExport() {
if (query.isUseFeatureVersionFilter()) {
SimpleFeatureVersionFilter featureVersionFilter = query.getFeatureVersionFilter();

if (featureVersionFilter.getMode() != SimpleFeatureVersionFilterMode.LATEST) {
if (featureVersionFilter.getMode() == SimpleFeatureVersionFilterMode.AT
|| featureVersionFilter.getMode() == SimpleFeatureVersionFilterMode.TERMINATED_AT) {
if (!featureVersionFilter.isSetStartDate()) {
viewController.errorMessage(Language.I18N.getString("common.dialog.error.incorrectFilter"),
Language.I18N.getString("export.dialog.error.featureVersion.startDate"));
Language.I18N.getString("export.dialog.error.featureVersion.date"));
return;
}

if (featureVersionFilter.getMode() == SimpleFeatureVersionFilterMode.BETWEEN) {
if (!featureVersionFilter.isSetEndDate()) {
viewController.errorMessage(Language.I18N.getString("common.dialog.error.incorrectFilter"),
Language.I18N.getString("export.dialog.error.featureVersion.endDate"));
return;
} else if (featureVersionFilter.getStartDate().compare(featureVersionFilter.getEndDate()) != DatatypeConstants.LESSER) {
viewController.errorMessage(Language.I18N.getString("common.dialog.error.incorrectFilter"),
Language.I18N.getString("export.dialog.error.featureVersion.range"));
return;
}
} else if (featureVersionFilter.getMode() == SimpleFeatureVersionFilterMode.BETWEEN) {
if (!featureVersionFilter.isSetStartDate()) {
viewController.errorMessage(Language.I18N.getString("common.dialog.error.incorrectFilter"),
Language.I18N.getString("export.dialog.error.featureVersion.startDate"));
return;
} else if (!featureVersionFilter.isSetEndDate()) {
viewController.errorMessage(Language.I18N.getString("common.dialog.error.incorrectFilter"),
Language.I18N.getString("export.dialog.error.featureVersion.endDate"));
return;
} else if (featureVersionFilter.getStartDate().compare(featureVersionFilter.getEndDate()) != DatatypeConstants.LESSER) {
viewController.errorMessage(Language.I18N.getString("common.dialog.error.incorrectFilter"),
Language.I18N.getString("export.dialog.error.featureVersion.range"));
return;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,23 +734,26 @@ private void doExport() {
if (query.isUseFeatureVersionFilter()) {
SimpleFeatureVersionFilter featureVersionFilter = query.getFeatureVersionFilter();

if (featureVersionFilter.getMode() != SimpleFeatureVersionFilterMode.LATEST) {
if (featureVersionFilter.getMode() == SimpleFeatureVersionFilterMode.AT
|| featureVersionFilter.getMode() == SimpleFeatureVersionFilterMode.TERMINATED_AT) {
if (!featureVersionFilter.isSetStartDate()) {
viewController.errorMessage(Language.I18N.getString("common.dialog.error.incorrectFilter"),
Language.I18N.getString("export.dialog.error.featureVersion.startDate"));
Language.I18N.getString("export.dialog.error.featureVersion.date"));
return;
}

if (featureVersionFilter.getMode() == SimpleFeatureVersionFilterMode.BETWEEN) {
if (!featureVersionFilter.isSetEndDate()) {
viewController.errorMessage(Language.I18N.getString("common.dialog.error.incorrectFilter"),
Language.I18N.getString("export.dialog.error.featureVersion.endDate"));
return;
} else if (featureVersionFilter.getStartDate().compare(featureVersionFilter.getEndDate()) != DatatypeConstants.LESSER) {
viewController.errorMessage(Language.I18N.getString("common.dialog.error.incorrectFilter"),
Language.I18N.getString("export.dialog.error.featureVersion.range"));
return;
}
} else if (featureVersionFilter.getMode() == SimpleFeatureVersionFilterMode.BETWEEN) {
if (!featureVersionFilter.isSetStartDate()) {
viewController.errorMessage(Language.I18N.getString("common.dialog.error.incorrectFilter"),
Language.I18N.getString("export.dialog.error.featureVersion.startDate"));
return;
} else if (!featureVersionFilter.isSetEndDate()) {
viewController.errorMessage(Language.I18N.getString("common.dialog.error.incorrectFilter"),
Language.I18N.getString("export.dialog.error.featureVersion.endDate"));
return;
} else if (featureVersionFilter.getStartDate().compare(featureVersionFilter.getEndDate()) != DatatypeConstants.LESSER) {
viewController.errorMessage(Language.I18N.getString("common.dialog.error.incorrectFilter"),
Language.I18N.getString("export.dialog.error.featureVersion.range"));
return;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.citydb.config.project.query.filter.selection.comparison.LessThanOrEqualToOperator;
import org.citydb.config.project.query.filter.selection.comparison.NullOperator;
import org.citydb.config.project.query.filter.selection.logical.AndOperator;
import org.citydb.config.project.query.filter.selection.logical.NotOperator;
import org.citydb.config.project.query.filter.selection.logical.OrOperator;

import javax.xml.bind.annotation.XmlAttribute;
Expand All @@ -57,7 +58,9 @@ public SimpleFeatureVersionFilterMode getMode() {
}

public void setMode(SimpleFeatureVersionFilterMode mode) {
this.mode = mode;
if (mode != null) {
this.mode = mode;
}
}

public XMLGregorianCalendar getStartDate() {
Expand Down Expand Up @@ -87,18 +90,25 @@ public void setEndDate(XMLGregorianCalendar endDate) {
public AbstractPredicate toPredicate() {
if (mode == SimpleFeatureVersionFilterMode.LATEST) {
return new NullOperator("core:terminationDate");
} else if (startDate != null && (mode == SimpleFeatureVersionFilterMode.AT || endDate != null)) {
XMLGregorianCalendar creationDate = mode == SimpleFeatureVersionFilterMode.AT ?
startDate :
endDate;
} else if (mode == SimpleFeatureVersionFilterMode.TERMINATED) {
return new NotOperator(new NullOperator("core:terminationDate"));
} else if (startDate != null) {
if (mode == SimpleFeatureVersionFilterMode.TERMINATED_AT) {
return new LessThanOrEqualToOperator("core:terminationDate", startDate.toXMLFormat());
} else if (mode == SimpleFeatureVersionFilterMode.AT
|| (mode == SimpleFeatureVersionFilterMode.BETWEEN && endDate != null)) {
XMLGregorianCalendar creationDate = mode == SimpleFeatureVersionFilterMode.AT ?
startDate :
endDate;

return new AndOperator(
new LessThanOrEqualToOperator("core:creationDate", creationDate.toXMLFormat()),
new OrOperator(
new GreaterThanOperator("core:terminationDate", startDate.toXMLFormat()),
new NullOperator("core:terminationDate")
)
);
return new AndOperator(
new LessThanOrEqualToOperator("core:creationDate", creationDate.toXMLFormat()),
new OrOperator(
new GreaterThanOperator("core:terminationDate", startDate.toXMLFormat()),
new NullOperator("core:terminationDate")
)
);
}
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public enum SimpleFeatureVersionFilterMode {
@XmlEnumValue("at")
AT("at"),
@XmlEnumValue("between")
BETWEEN("between");
BETWEEN("between"),
@XmlEnumValue("terminated")
TERMINATED("terminated"),
@XmlEnumValue("terminatedAt")
TERMINATED_AT("terminatedAt");

private final String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ filter.button.mode.simple=Einfacher Filter
filter.button.mode.xml=XML-Abfrage
filter.label.featureVersion.latest=Aktuelle Version
filter.label.featureVersion.valid=G�ltige Version
filter.label.featureVersion.terminated=Terminierte Version
filter.label.featureVersion.at=am
filter.label.featureVersion.from=vom
filter.label.featureVersion.to=bis
filter.label.featureVersion.all=alle
filter.label.boundingBox.overlaps=Alle �berlappenden Objekte
filter.label.boundingBox.within=Nur Objekte innerhalb
filter.label.boundingBox.rows=Kacheln in Zeilen
Expand Down Expand Up @@ -188,6 +190,7 @@ export.dialog.error.incompleteData=Exportdaten unvollst
export.dialog.error.incorrectData=Exportdaten fehlerhaft
export.dialog.error.incompleteData.dataset=Bitte geben Sie den zu exportierenden Datensatz an.
export.dialog.error.incorrectData.sql=Bitte geben Sie einen SQL Filter an.
export.dialog.error.featureVersion.date=Bitte geben Sie ein g�ltiges Datum an.
export.dialog.error.featureVersion.startDate=Bitte geben Sie ein g�ltiges Anfangsdatum an.
export.dialog.error.featureVersion.endDate=Bitte geben Sie ein g�ltiges Enddatum an.
export.dialog.error.featureVersion.range=Das Anfangsdatum muss vor dem Enddatum liegen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ filter.button.mode.simple=Simple filter
filter.button.mode.xml=XML query
filter.label.featureVersion.latest=Latest version
filter.label.featureVersion.valid=Valid version
filter.label.featureVersion.terminated=Terminated version
filter.label.featureVersion.at=at
filter.label.featureVersion.from=from
filter.label.featureVersion.to=to
filter.label.featureVersion.all=all
filter.label.boundingBox.overlaps=All overlapping features
filter.label.boundingBox.within=Only features inside
filter.label.boundingBox.rows=Tile into rows
Expand Down Expand Up @@ -188,6 +190,7 @@ export.dialog.error.incompleteData=Incomplete export information
export.dialog.error.incorrectData=Incorrect export information
export.dialog.error.incompleteData.dataset=Please name the file to be exported.
export.dialog.error.incorrectData.sql=Please enter a SQL filter.
export.dialog.error.featureVersion.date=Please enter a valid date.
export.dialog.error.featureVersion.startDate=Please enter a valid start date.
export.dialog.error.featureVersion.endDate=Please enter a valid end date.
export.dialog.error.featureVersion.range=The start date must be lesser than the end date.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public class FeatureVersionOption implements CliOption {

@CommandLine.Option(names = {"-R", "--feature-version-timestamp"}, paramLabel = "<timestamp[,timestamp]>",
description = "Timestamp given as date <YYYY-MM-DD> or date-time <YYYY-MM-DDThh:mm:ss[(+|-)hh:mm]> with " +
"optional UTC offset. Use one timestamp with 'at' and two timestamps defining a time range " +
"with 'between'.")
"optional UTC offset. Use one timestamp with 'at' and 'terminated_at', and two timestamps " +
"defining a time range with 'between'.")
private String timestamp;

private OffsetDateTime startDateTime;
Expand Down Expand Up @@ -82,6 +82,8 @@ enum Version {
latest(SimpleFeatureVersionFilterMode.LATEST),
at(SimpleFeatureVersionFilterMode.AT),
between(SimpleFeatureVersionFilterMode.BETWEEN),
terminated(SimpleFeatureVersionFilterMode.TERMINATED),
terminated_at(SimpleFeatureVersionFilterMode.TERMINATED_AT),
all(null);

private final SimpleFeatureVersionFilterMode mode;
Expand All @@ -107,14 +109,14 @@ public void preprocess(CommandLine commandLine) throws Exception {
featureVersionFilter.setMode(version.mode);

if (timestamp != null) {
if (version == Version.latest) {
if (version == Version.latest || version == Version.terminated) {
throw new CommandLine.ParameterException(commandLine,
"Error: The feature version '" + version + "' does not take a timestamp");
}

String[] timestamps = timestamp.split(",");

if (version == Version.at && timestamps.length != 1) {
if ((version == Version.at || version == Version.terminated_at) && timestamps.length != 1) {
throw new CommandLine.ParameterException(commandLine,
"Error: The feature version '" + version + "' requires only one timestamp");
} else if (version == Version.between && timestamps.length != 2) {
Expand Down