diff options
| author | Viktoria Pundy <viktoria.pundy@aon.at> | 2018-06-01 09:45:31 +0200 | 
|---|---|---|
| committer | Tharre <tharre3@gmail.com> | 2018-06-02 00:14:15 +0200 | 
| commit | bf2a7ba5b9da2c4ee3deef275a36e9118f45f683 (patch) | |
| tree | d1805151def1e9b62abadd50e44a0c20745f7aca /src/main/java/at/ac/tuwien | |
| parent | 356d892d5bcfa865832f695c9b46c61fbceebf54 (diff) | |
| download | sepm-groupproject-bf2a7ba5b9da2c4ee3deef275a36e9118f45f683.tar.gz sepm-groupproject-bf2a7ba5b9da2c4ee3deef275a36e9118f45f683.tar.xz sepm-groupproject-bf2a7ba5b9da2c4ee3deef275a36e9118f45f683.zip  | |
Operations in archive are now sorted [#27299]
Diffstat (limited to 'src/main/java/at/ac/tuwien')
| -rw-r--r-- | src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java | 39 | 
1 files changed, 29 insertions, 10 deletions
diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java index 107ed2f..04f1dde 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java @@ -8,9 +8,11 @@ import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException;  import java.io.IOException;  import java.time.LocalDateTime;  import java.time.ZoneOffset; +import java.util.Arrays;  import java.util.Collection;  import java.util.EnumSet;  import java.util.HashSet; +import java.util.List;  import java.util.Objects;  import java.util.Set;  import java.util.stream.Collectors; @@ -18,7 +20,6 @@ import javafx.fxml.FXML;  import javafx.scene.control.Alert;  import javafx.scene.control.Alert.AlertType;  import javafx.scene.control.Button; -import javafx.scene.control.Hyperlink;  import javafx.scene.control.Label;  import javafx.scene.layout.AnchorPane;  import javafx.scene.layout.FlowPane; @@ -36,7 +37,6 @@ public class ArchiveOperationController {      @FXML private AnchorPane archiveOperationAP;      @FXML private AnchorPane apDetails;      @FXML private Label lblCodeHeader; -    @FXML private Hyperlink hypBack;      @FXML private Label lblOpCode;      @FXML private Label lblVehicles;      @FXML private Label lblDate; @@ -71,8 +71,7 @@ public class ArchiveOperationController {      private void setFlowPane() {          try {              archiveOperationFlowPane.getChildren().clear(); -            Set<Operation> operations = list; -            for (Operation operation : operations) { +            for (Operation operation : sortSet(list)) {                  OperationInArchiveController opInAController =                          OperationInArchiveController.create();                  opInAController.set(operation); @@ -93,26 +92,46 @@ public class ArchiveOperationController {              Alert alert = new Alert(Alert.AlertType.ERROR);              alert.setTitle("Fehler");              alert.setHeaderText("Fehler!"); -            alert.setContentText("Das Element konnte nicht geladen werden!"); +            alert.setContentText("Die Element konnte nicht geladen werden!");              alert.showAndWait();          }      } +    private List<Operation> sortSet(Set<Operation> operationsSet) { +        Operation[] array = operationsSet.toArray(new Operation[operationsSet.size()]); +        for (int i = array.length - 1; i > 0; i--) { +            for (int j = 0; j < i; j++) { +                LocalDateTime first = +                        LocalDateTime.ofInstant( +                                Objects.requireNonNull(array[j].created()), ZoneOffset.UTC); +                LocalDateTime second = +                        LocalDateTime.ofInstant( +                                Objects.requireNonNull(array[j + 1].created()), ZoneOffset.UTC); +                if (second.isBefore(first)) { +                    Operation help = array[j]; +                    array[j] = array[j + 1]; +                    array[j + 1] = help; +                } +            } +        } +        return Arrays.asList(array); +    } +      private Operation detailOperation;      private void setOperation() {          lblCodeHeader.setText(detailOperation.opCode());          String date = "am ";          if (detailOperation.created() != null) { -            LocalDateTime myDateTime = +            LocalDateTime dateTime =                      LocalDateTime.ofInstant(                              Objects.requireNonNull(detailOperation.created()), ZoneOffset.UTC);              date += -                    myDateTime.getDayOfMonth() +                    dateTime.getDayOfMonth()                              + "." -                            + myDateTime.getMonth().getValue() +                            + dateTime.getMonth().getValue()                              + "." -                            + myDateTime.getYear(); +                            + dateTime.getYear();              lblDate.setText(date);          } else {              lblDate.setText("---"); @@ -157,7 +176,7 @@ public class ArchiveOperationController {          createOperationController.setVisible(true);      } -    public void setVisible(boolean b) { +    void setVisible(boolean b) {          archiveOperationAP.setVisible(b);          backApMain.setVisible(b);          apMainDetails.setVisible(b);  | 
