Skip to content

Commit

Permalink
Enhance DSS pathname sorting logic
Browse files Browse the repository at this point in the history
Enhance DSS pathname sorting logic to account for non-gridded records in the DSS file. Use a common utility method to sort records among all Vortex utilities.
  • Loading branch information
Tom Brauer committed Mar 17, 2023
1 parent 616f150 commit 44cc253
Show file tree
Hide file tree
Showing 20 changed files with 66 additions and 184 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ repositories {

dependencies {
implementation(project(":vortex-api"))
implementation(project(":vortex-ui"))
implementation("com.google.inject:guice:5.0.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.4.2")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.4.2")
Expand Down
1 change: 1 addition & 0 deletions calculator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repositories {

dependencies {
implementation(project(":vortex-api"))
implementation(project(":vortex-ui"))
implementation("org.slf4j:slf4j-simple:1.7.25")
implementation("com.google.inject:guice:5.0.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.4.2")
Expand Down
26 changes: 3 additions & 23 deletions calculator/src/main/java/calculator/WizardData.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

import javafx.beans.property.*;
import javafx.collections.ObservableList;
import mil.army.usace.hec.vortex.ui.Util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.Comparator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class WizardData {
Expand Down Expand Up @@ -50,15 +46,7 @@ public SimpleListProperty<String> availableVariablesProperty() {

public void setAvailableVariables(ObservableList<String> grids) {
if(getInFile().endsWith("dss")) {
try {
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("ddMMMuuuu:HHmm")
.toFormatter();
grids.sort(Comparator.comparing(s -> LocalDateTime.parse(s.split("/")[4], formatter)));
} catch (Exception e) {
logger.log(Level.SEVERE, e, e::getMessage);
}
Util.sortDssVariables(grids);
}
availableVariables.set(grids);
}
Expand All @@ -69,15 +57,7 @@ public SimpleListProperty<String> selectedVariablesProperty() {

public void setSelectedVariables(ObservableList<String> grids) {
if(getInFile().endsWith("dss")) {
try {
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("ddMMMuuuu:HHmm")
.toFormatter();
grids.sort(Comparator.comparing(s -> LocalDateTime.parse(s.split("/")[4], formatter)));
} catch (Exception e) {
logger.log(Level.SEVERE, e, e::getMessage);
}
Util.sortDssVariables(grids);
}
selectedVariables.set(grids);
}
Expand Down
1 change: 1 addition & 0 deletions clipper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repositories {

dependencies {
implementation(project(":vortex-api"))
implementation(project(":vortex-ui"))
implementation("org.slf4j:slf4j-simple:1.7.25")
implementation("com.google.inject:guice:5.0.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.4.2")
Expand Down
1 change: 1 addition & 0 deletions grid-to-point-converter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repositories {

dependencies {
implementation(project(":vortex-api"))
implementation(project(":vortex-ui"))
implementation("org.slf4j:slf4j-simple:1.7.25")
implementation("org.openjfx:javafx-fxml:11")
implementation("com.google.inject:guice:5.0.1")
Expand Down
19 changes: 5 additions & 14 deletions grid-to-point-converter/src/main/java/converter/WizardData.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.ObservableList;
import mil.army.usace.hec.vortex.ui.Util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.DateTimeParseException;
import java.util.Comparator;
import java.util.List;

public class WizardData {
Expand Down Expand Up @@ -39,15 +35,7 @@ public SimpleListProperty<String> availableVariablesProperty() {

public void setAvailableVariables(ObservableList<String> grids) {
if(getInFile().endsWith("dss")) {
try {
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("ddMMMuuuu:HHmm")
.toFormatter();
grids.sort(Comparator.comparing(s -> LocalDateTime.parse(s.split("/")[4], formatter)));
} catch (DateTimeParseException e) {
e.printStackTrace();
}
Util.sortDssVariables(grids);
}
availableVariables.set(grids);
}
Expand All @@ -57,6 +45,9 @@ public SimpleListProperty<String> selectedVariablesProperty() {
}

public void setSelectedVariables(ObservableList<String> grids) {
if(getInFile().endsWith("dss")) {
Util.sortDssVariables(grids);
}
selectedVariables.set(grids);
}

Expand Down
1 change: 1 addition & 0 deletions image-exporter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repositories {

dependencies {
implementation(project(":vortex-api"))
implementation(project(":vortex-ui"))
implementation("org.slf4j:slf4j-simple:1.7.25")
implementation("com.google.inject:guice:5.0.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.4.2")
Expand Down
19 changes: 5 additions & 14 deletions image-exporter/src/main/java/image/exporter/WizardData.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.ObservableList;
import mil.army.usace.hec.vortex.ui.Util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.DateTimeParseException;
import java.util.Comparator;
import java.util.List;

public class WizardData {
Expand Down Expand Up @@ -37,15 +33,7 @@ public SimpleListProperty<String> availableVariablesProperty() {

public void setAvailableVariables(ObservableList<String> grids) {
if(getInFile().endsWith("dss")) {
try {
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("ddMMMuuuu:HHmm")
.toFormatter();
grids.sort(Comparator.comparing(s -> LocalDateTime.parse(s.split("/")[4], formatter)));
} catch (DateTimeParseException e) {
e.printStackTrace();
}
Util.sortDssVariables(grids);
}
availableVariables.set(grids);
}
Expand All @@ -55,6 +43,9 @@ public SimpleListProperty<String> selectedVariablesProperty() {
}

public void setSelectedVariables(ObservableList<String> grids) {
if(getInFile().endsWith("dss")) {
Util.sortDssVariables(grids);
}
selectedVariables.set(grids);
}

Expand Down
1 change: 1 addition & 0 deletions importer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repositories {

dependencies {
implementation(project(":vortex-api"))
implementation(project(":vortex-ui"))
implementation("org.slf4j:slf4j-simple:1.7.25")
implementation("com.google.inject:guice:5.0.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.4.2")
Expand Down
24 changes: 2 additions & 22 deletions importer/src/main/java/importer/WizardData.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import mil.army.usace.hec.vortex.ui.Util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.DateTimeParseException;
import java.util.*;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -62,24 +59,7 @@ public void setAvailableVariables(ObservableList<String> variables) {
.collect(Collectors.toSet());

if(extensions.size() == 1 && extensions.iterator().next().equals("dss")) {
try {
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("ddMMMuuuu:HHmm")
.toFormatter();
//Sort based on D part
variables.sort(Comparator.comparing(s -> LocalDateTime.parse(s.split("/", 7)[4], formatter)));
//Sort based on A part
variables.sort(Comparator.comparing(s -> s.split("/", 7)[1]));
//Sort based on B part
variables.sort(Comparator.comparing(s -> s.split("/", 7)[2]));
//Sort based on C part
variables.sort(Comparator.comparing(s -> s.split("/", 7)[3]));
//Sort based on F part
variables.sort(Comparator.comparing(s -> s.split("/", 7)[6]));
} catch (DateTimeParseException e) {
e.printStackTrace();
}
Util.sortDssVariables(variables);
}
availableVariables.set(variables);
}
Expand Down
1 change: 1 addition & 0 deletions normalizer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repositories {

dependencies {
implementation(project(":vortex-api"))
implementation(project(":vortex-ui"))
implementation("org.slf4j:slf4j-simple:1.7.25")
implementation("com.google.inject:guice:5.0.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.4.2")
Expand Down
29 changes: 6 additions & 23 deletions normalizer/src/main/java/normalizer/WizardData.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.ObservableList;
import mil.army.usace.hec.vortex.ui.Util;

import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.DateTimeParseException;
import java.util.Comparator;
import java.util.List;

public class WizardData {
Expand Down Expand Up @@ -63,15 +59,7 @@ public SimpleListProperty<String> availableSourceGridsProperty() {

public void setAvailableSourceGrids(ObservableList<String> grids) {
if(getSourceFile().endsWith("dss")) {
try {
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("ddMMMuuuu:HHmm")
.toFormatter();
grids.sort(Comparator.comparing(s -> LocalDateTime.parse(s.split("/")[4], formatter)));
} catch (DateTimeParseException e) {
e.printStackTrace();
}
Util.sortDssVariables(grids);
}
availableSourceGrids.set(grids);
}
Expand All @@ -85,6 +73,9 @@ public SimpleListProperty<String> selectedSourceGridsProperty() {
}

public void setSelectedSourceGrids(ObservableList<String> grids) {
if(getSourceFile().endsWith("dss")) {
Util.sortDssVariables(grids);
}
selectedSourceGrids.set(grids);
}

Expand All @@ -106,15 +97,7 @@ public SimpleListProperty<String> availableNormalGridsProperty() {

public void setAvailableNormalGrids(ObservableList<String> grids) {
if(getNormalsFile().endsWith("dss")) {
try {
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("ddMMMuuuu:HHmm")
.toFormatter();
grids.sort(Comparator.comparing(s -> LocalDateTime.parse(s.split("/")[4], formatter)));
} catch (DateTimeParseException e) {
e.printStackTrace();
}
Util.sortDssVariables(grids);
}
availableNormalGrids.set(grids);
}
Expand Down
1 change: 1 addition & 0 deletions sanitizer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repositories {

dependencies {
implementation(project(":vortex-api"))
implementation(project(":vortex-ui"))
implementation("org.slf4j:slf4j-simple:1.7.25")
implementation("com.google.inject:guice:5.0.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.4.2")
Expand Down
26 changes: 3 additions & 23 deletions sanitizer/src/main/java/sanitizer/WizardData.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.ObservableList;
import mil.army.usace.hec.vortex.ui.Util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.Comparator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class WizardData {
Expand Down Expand Up @@ -44,15 +40,7 @@ public SimpleListProperty<String> availableVariablesProperty() {

public void setAvailableVariables(ObservableList<String> grids) {
if(getInFile().endsWith("dss")) {
try {
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("ddMMMuuuu:HHmm")
.toFormatter();
grids.sort(Comparator.comparing(s -> LocalDateTime.parse(s.split("/")[4], formatter)));
} catch (Exception e) {
logger.log(Level.SEVERE, e, e::getMessage);
}
Util.sortDssVariables(grids);
}
availableVariables.set(grids);
}
Expand All @@ -63,15 +51,7 @@ public SimpleListProperty<String> selectedVariablesProperty() {

public void setSelectedVariables(ObservableList<String> grids) {
if(getInFile().endsWith("dss")) {
try {
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("ddMMMuuuu:HHmm")
.toFormatter();
grids.sort(Comparator.comparing(s -> LocalDateTime.parse(s.split("/")[4], formatter)));
} catch (Exception e) {
logger.log(Level.SEVERE, e, e::getMessage);
}
Util.sortDssVariables(grids);
}
selectedVariables.set(grids);
}
Expand Down
1 change: 1 addition & 0 deletions time-shifter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repositories {

dependencies {
implementation(project(":vortex-api"))
implementation(project(":vortex-ui"))
implementation("org.slf4j:slf4j-simple:1.7.25")
implementation("com.google.inject:guice:5.0.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.4.2")
Expand Down
19 changes: 5 additions & 14 deletions time-shifter/src/main/java/shifter/WizardData.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.ObservableList;
import mil.army.usace.hec.vortex.ui.Util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.DateTimeParseException;
import java.util.Comparator;
import java.util.List;

public class WizardData {
Expand Down Expand Up @@ -39,15 +35,7 @@ public SimpleListProperty<String> availableVariablesProperty() {

public void setAvailableVariables(ObservableList<String> grids) {
if(getInFile().endsWith("dss")) {
try {
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("ddMMMuuuu:HHmm")
.toFormatter();
grids.sort(Comparator.comparing(s -> LocalDateTime.parse(s.split("/")[4], formatter)));
} catch (DateTimeParseException e) {
e.printStackTrace();
}
Util.sortDssVariables(grids);
}
availableVariables.set(grids);
}
Expand All @@ -57,6 +45,9 @@ public SimpleListProperty<String> selectedVariablesProperty() {
}

public void setSelectedVariables(ObservableList<String> grids) {
if(getInFile().endsWith("dss")) {
Util.sortDssVariables(grids);
}
selectedVariables.set(grids);
}

Expand Down
1 change: 1 addition & 0 deletions transposer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repositories {

dependencies {
implementation(project(":vortex-api"))
implementation(project(":vortex-ui"))
implementation("org.slf4j:slf4j-simple:1.7.25")
implementation("com.google.inject:guice:5.0.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.4.2")
Expand Down
Loading

0 comments on commit 44cc253

Please sign in to comment.