Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e96280cd0c | ||
|
|
bfe3fcfb79 | ||
|
|
b70a758099 | ||
|
|
86a9eeaf2e |
@@ -14,6 +14,7 @@ import javafx.fxml.FXML;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
@@ -72,6 +73,9 @@ public class CropDetailController {
|
||||
@FXML
|
||||
private Label spacing_label;
|
||||
|
||||
@FXML
|
||||
private Button editTaskList_button;
|
||||
|
||||
@FXML
|
||||
void editTaskList() {
|
||||
|
||||
@@ -114,6 +118,9 @@ public class CropDetailController {
|
||||
} catch (HardinessZoneNotSetException | IOException e) {
|
||||
throw new PlantNotFoundException();
|
||||
}
|
||||
setIconToButton(editTaskList_button, "editIcon.png");
|
||||
setIconToButton(area_button, "areaIcon.png");
|
||||
setIconToButton(location_button, "locationIcon.png");
|
||||
}
|
||||
|
||||
private void createTaskLists(Crop crop) {
|
||||
@@ -149,4 +156,17 @@ public class CropDetailController {
|
||||
pests_vbox.getChildren().addAll(label, hBox);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* adds icon to button
|
||||
* @param button the button which get the icon
|
||||
* @param iconFileName file name of icon
|
||||
*/
|
||||
private void setIconToButton(Button button, String iconFileName) {
|
||||
Image img = new Image(String.valueOf(getClass().getResource("icons/" + iconFileName)));
|
||||
ImageView imageView = new ImageView(img);
|
||||
imageView.setFitHeight(20);
|
||||
imageView.setPreserveRatio(true);
|
||||
button.setGraphic(imageView);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,12 @@ import ch.zhaw.gartenverwaltung.bootstrap.AfterInject;
|
||||
import ch.zhaw.gartenverwaltung.bootstrap.AppLoader;
|
||||
import ch.zhaw.gartenverwaltung.bootstrap.ChangeViewEvent;
|
||||
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
|
||||
@@ -33,7 +36,10 @@ public class MainFXMLController {
|
||||
private Button mySchedule_button;
|
||||
|
||||
@FXML
|
||||
private Button plants_button;
|
||||
private Button settings_button;
|
||||
|
||||
@FXML
|
||||
private Button tutorial_button;
|
||||
|
||||
@FXML
|
||||
void goToHome() {
|
||||
@@ -54,9 +60,31 @@ public class MainFXMLController {
|
||||
}
|
||||
|
||||
@FXML
|
||||
void goToPlants() {
|
||||
showPaneAsMainView("Plants.fxml");
|
||||
styleChangeButton(plants_button);
|
||||
public void openSettings(ActionEvent actionEvent) throws IOException {
|
||||
Dialog<ButtonType> dialog = new Dialog<>();
|
||||
dialog.setTitle("Settings");
|
||||
dialog.setHeaderText("Settings");
|
||||
dialog.setResizable(false);
|
||||
|
||||
DialogPane dialogPane = dialog.getDialogPane();
|
||||
|
||||
ButtonType saveSettings = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
|
||||
dialogPane.getButtonTypes().addAll(saveSettings, ButtonType.CANCEL);
|
||||
|
||||
if (appLoader.loadPaneToDialog("Settings.fxml", dialogPane) instanceof SettingsController controller) {
|
||||
|
||||
dialog.showAndWait()
|
||||
.ifPresent(button -> {
|
||||
if (button.equals(saveSettings)) {
|
||||
controller.saveSettings();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void goToTutorial(ActionEvent actionEvent) {
|
||||
//showPaneAsMainView("Tutorial.fxml");
|
||||
styleChangeButton(tutorial_button);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,11 +128,32 @@ public class MainFXMLController {
|
||||
public void init() {
|
||||
try {
|
||||
preloadPanes();
|
||||
showPaneAsMainView("Home.fxml");
|
||||
styleChangeButton(home_button);
|
||||
showPaneAsMainView("MyGarden.fxml");
|
||||
styleChangeButton(myGarden_button);
|
||||
} catch (IOException e) {
|
||||
LOG.log(Level.SEVERE, "Failed to load FXML-Pane!", e);
|
||||
}
|
||||
setIconToButton(home_button, "homeIcon.png");
|
||||
setIconToButton(settings_button, "settingsIcon.png");
|
||||
Settings.getInstance().getShowTutorialProperty().addListener((observable, oldValue, newValue) -> {
|
||||
tutorial_button.setVisible(newValue);
|
||||
});
|
||||
tutorial_button.setVisible(Settings.getInstance().getShowTutorial());
|
||||
}
|
||||
|
||||
/**
|
||||
* adds icon to button
|
||||
* @param button the button which get the icon
|
||||
* @param iconFileName file name of icon
|
||||
*/
|
||||
private void setIconToButton(Button button, String iconFileName) {
|
||||
Image img = new Image(String.valueOf(getClass().getResource("icons/" + iconFileName)));
|
||||
ImageView imageView = new ImageView(img);
|
||||
imageView.setFitHeight(20);
|
||||
imageView.setPreserveRatio(true);
|
||||
button.setGraphic(imageView);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
@@ -43,6 +44,8 @@ public class MyGardenController {
|
||||
public AnchorPane myGardenRoot;
|
||||
@FXML
|
||||
private VBox myPlants_vbox;
|
||||
@FXML
|
||||
private Button addPlant_button;
|
||||
|
||||
@AfterInject
|
||||
@SuppressWarnings("unused")
|
||||
@@ -59,6 +62,7 @@ public class MyGardenController {
|
||||
} catch (HardinessZoneNotSetException | IOException e) {
|
||||
LOG.log(Level.SEVERE, "Could not update view of croplist!", e);
|
||||
}
|
||||
setIconToButton(addPlant_button, "addIcon.png");
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -91,8 +95,10 @@ public class MyGardenController {
|
||||
label.setMaxWidth(2000);
|
||||
HBox.setHgrow(label, Priority.ALWAYS);
|
||||
|
||||
Button details = new Button("Details");
|
||||
Button delete = new Button("delete");
|
||||
Button details = new Button("");
|
||||
Button delete = new Button("");
|
||||
setIconToButton(details, "detailsIcon.png");
|
||||
setIconToButton(delete, "deleteIcon.png");
|
||||
details.setOnAction(getGoToCropDetailEvent(crop));
|
||||
delete.setOnAction(getDeleteCropEvent(crop));
|
||||
|
||||
@@ -100,6 +106,19 @@ public class MyGardenController {
|
||||
return hBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds icon to button
|
||||
* @param button the button which get the icon
|
||||
* @param iconFileName file name of icon
|
||||
*/
|
||||
private void setIconToButton(Button button, String iconFileName) {
|
||||
Image img = new Image(String.valueOf(getClass().getResource("icons/" + iconFileName)));
|
||||
ImageView imageView = new ImageView(img);
|
||||
imageView.setFitHeight(20);
|
||||
imageView.setPreserveRatio(true);
|
||||
button.setGraphic(imageView);
|
||||
}
|
||||
|
||||
private EventHandler<ActionEvent> getGoToCropDetailEvent(Crop crop) {
|
||||
return (event) -> {
|
||||
try {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package ch.zhaw.gartenverwaltung;
|
||||
|
||||
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
|
||||
public class Settings {
|
||||
private HardinessZone currentHardinessZone = HardinessZone.ZONE_8A;
|
||||
private static Settings instance;
|
||||
private final BooleanProperty showTutorial = new SimpleBooleanProperty(false);
|
||||
|
||||
static {
|
||||
instance = new Settings();
|
||||
@@ -23,4 +26,16 @@ public class Settings {
|
||||
public void setCurrentHardinessZone(HardinessZone currentHardinessZone) {
|
||||
this.currentHardinessZone = currentHardinessZone;
|
||||
}
|
||||
|
||||
public void setShowTutorial (boolean showTutorial) {
|
||||
this.showTutorial.setValue(showTutorial);
|
||||
}
|
||||
|
||||
public BooleanProperty getShowTutorialProperty() {
|
||||
return this.showTutorial;
|
||||
}
|
||||
|
||||
public boolean getShowTutorial() {
|
||||
return this.showTutorial.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package ch.zhaw.gartenverwaltung;
|
||||
|
||||
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ComboBox;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class SettingsController implements Initializable {
|
||||
Settings settings = Settings.getInstance();
|
||||
|
||||
@FXML
|
||||
private ComboBox<HardinessZone> selectHardinessZone_comboBox;
|
||||
|
||||
@FXML
|
||||
private CheckBox showTutorial_checkBox;
|
||||
|
||||
/**
|
||||
* save selected values to {@link Settings}
|
||||
*/
|
||||
public void saveSettings() {
|
||||
settings.setShowTutorial(showTutorial_checkBox.isSelected());
|
||||
settings.setCurrentHardinessZone(selectHardinessZone_comboBox.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* save default values form {@link Settings}
|
||||
* @param location location
|
||||
* @param resources resources
|
||||
*/
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
showTutorial_checkBox.setSelected(settings.getShowTutorial());
|
||||
selectHardinessZone_comboBox.getItems().addAll(HardinessZone.values());
|
||||
selectHardinessZone_comboBox.setValue(settings.getCurrentHardinessZone());
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@ public class JsonCropList implements CropList {
|
||||
public JsonCropList(URL dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Optional;
|
||||
* The reads are cached to minimize file-io operations.
|
||||
*/
|
||||
public class JsonPlantList implements PlantList {
|
||||
private final URL dataSource = getClass().getResource("plantdb.json");
|
||||
private final URL dataSource;
|
||||
|
||||
private HardinessZone currentZone;
|
||||
private Map<Long, Plant> plantMap = Collections.emptyMap();
|
||||
@@ -44,6 +44,13 @@ public class JsonPlantList implements PlantList {
|
||||
imageModule.addDeserializer(Image.class, new PlantImageDeserializer());
|
||||
}
|
||||
|
||||
public JsonPlantList() {
|
||||
this.dataSource = getClass().getResource("plantdb.json");
|
||||
}
|
||||
public JsonPlantList(URL dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* If no data is currently loaded, or the specified zone differs
|
||||
* from the {@link #currentZone}, data is loaded from {@link #dataSource}.
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class JsonTaskList implements TaskList {
|
||||
IdProvider idProvider;
|
||||
private final URL dataSource = getClass().getResource("taskdb.json");
|
||||
private final URL dataSource;
|
||||
private final static String INVALID_DATASOURCE_MSG = "Invalid datasource specified!";
|
||||
|
||||
private Map<Long, Task> taskMap = Collections.emptyMap();
|
||||
@@ -43,6 +43,13 @@ public class JsonTaskList implements TaskList {
|
||||
timeModule.addSerializer(LocalDate.class, dateSerializer);
|
||||
}
|
||||
|
||||
public JsonTaskList() {
|
||||
this.dataSource = getClass().getResource("taskdb.json");
|
||||
}
|
||||
public JsonTaskList(URL dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* If no data is currently loaded, data is loaded from {@link #dataSource}.
|
||||
* In any case, the values of {@link #taskMap} are returned.
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<ImageView fx:id="imageView" fitHeight="300.0" fitWidth="300.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER" />
|
||||
</children>
|
||||
</HBox>
|
||||
<Label text="Growth Phases:">
|
||||
<Label text="Tasks:">
|
||||
<VBox.margin>
|
||||
<Insets bottom="10.0" />
|
||||
</VBox.margin>
|
||||
@@ -90,7 +90,7 @@
|
||||
<Insets bottom="10.0" />
|
||||
</VBox.margin>
|
||||
</VBox>
|
||||
<Button mnemonicParsing="false" onAction="#editTaskList" prefHeight="25.0" prefWidth="92.0" text="Edit Tasklist">
|
||||
<Button fx:id="editTaskList_button" mnemonicParsing="false" onAction="#editTaskList" prefHeight="25.0" prefWidth="45.0">
|
||||
<VBox.margin>
|
||||
<Insets bottom="10.0" />
|
||||
</VBox.margin>
|
||||
@@ -113,7 +113,7 @@
|
||||
<Insets right="10.0" />
|
||||
</HBox.margin>
|
||||
</Label>
|
||||
<Button fx:id="area_button" mnemonicParsing="false" onAction="#setArea" prefHeight="25.0" prefWidth="116.0" text="Add Area" />
|
||||
<Button fx:id="area_button" mnemonicParsing="false" onAction="#setArea" prefHeight="25.0" prefWidth="116.0" text="Set Area" />
|
||||
</children>
|
||||
<VBox.margin>
|
||||
<Insets bottom="10.0" />
|
||||
@@ -131,7 +131,7 @@
|
||||
<Insets right="10.0" />
|
||||
</HBox.margin>
|
||||
</Label>
|
||||
<Button fx:id="location_button" mnemonicParsing="false" onAction="#setLocation" prefHeight="25.0" prefWidth="115.0" text="Add Location" />
|
||||
<Button fx:id="location_button" mnemonicParsing="false" onAction="#setLocation" prefHeight="25.0" prefWidth="115.0" text="Set Location" />
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<children>
|
||||
<VBox layoutX="75.0" layoutY="73.0" prefHeight="729.0" prefWidth="1060.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<Label text="Gartenverwaltung">
|
||||
<Label text="Garden Management">
|
||||
<font>
|
||||
<Font size="34.0" />
|
||||
</font>
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
<children>
|
||||
<HBox maxWidth="35.0" minHeight="35.0" prefHeight="38.0" prefWidth="1110.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<Button fx:id="home_button" mnemonicParsing="false" onAction="#goToHome" prefHeight="38.0" prefWidth="121.0" text="Home" HBox.hgrow="NEVER" />
|
||||
<Button fx:id="plants_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToPlants" prefHeight="38.0" prefWidth="121.0" text="Plants" />
|
||||
<Button fx:id="home_button" mnemonicParsing="false" onAction="#goToHome" prefHeight="38.0" prefWidth="40.0" HBox.hgrow="NEVER" />
|
||||
<Button fx:id="myGarden_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToMyPlants" prefHeight="38.0" prefWidth="121.0" text="My Garden" />
|
||||
<Button fx:id="mySchedule_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToMySchedule" prefHeight="38.0" prefWidth="121.0" text="My Schedule" />
|
||||
<Button fx:id="tutorial_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToTutorial" prefHeight="38.0" prefWidth="121.0" text="Tutorial" />
|
||||
<Pane maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" />
|
||||
<Button fx:id="settings_button" maxHeight="1.7976931348623157E308" mnemonicParsing="false" onAction="#openSettings" prefHeight="38.0" prefWidth="40.0" HBox.hgrow="NEVER" />
|
||||
</children>
|
||||
</HBox>
|
||||
<AnchorPane fx:id="mainPane" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="35.0" />
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<Font name="System Bold" size="17.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<TitledPane animated="false" text="Saison">
|
||||
<TitledPane animated="false" text="Seasons">
|
||||
<content>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||
<children>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import javafx.scene.control.ComboBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
|
||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="80.0" prefWidth="374.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.SettingsController">
|
||||
<children>
|
||||
<VBox layoutX="14.0" layoutY="14.0" prefHeight="73.0" prefWidth="374.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<HBox prefHeight="23.0" prefWidth="334.0">
|
||||
<children>
|
||||
<Label maxWidth="1.7976931348623157E308" text="Show Tutorial Menu" HBox.hgrow="ALWAYS" />
|
||||
<CheckBox fx:id="showTutorial_checkBox" mnemonicParsing="false" />
|
||||
</children>
|
||||
<VBox.margin>
|
||||
<Insets left="10.0" right="10.0" top="10.0" />
|
||||
</VBox.margin>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER_LEFT" layoutX="20.0" layoutY="20.0" prefHeight="23.0" prefWidth="334.0">
|
||||
<children>
|
||||
<Label maxWidth="1.7976931348623157E308" text="Select Default Hardiness Zone" HBox.hgrow="ALWAYS" />
|
||||
<ComboBox fx:id="selectHardinessZone_comboBox" prefWidth="150.0" promptText="Hardniness Zone" />
|
||||
</children>
|
||||
<VBox.margin>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</VBox.margin>
|
||||
</HBox>
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
After Width: | Height: | Size: 8.8 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 31 KiB |
@@ -28,8 +28,8 @@ public class JsonCropListTest {
|
||||
/**
|
||||
* Files to isolate the test-units
|
||||
*/
|
||||
private final URL dbDataSource = this.getClass().getResource("user-crops.json");
|
||||
private final URL testFile = this.getClass().getResource("test-user-crops.json");
|
||||
private final URL dbDataSource = this.getClass().getResource("test-user-crops.json");
|
||||
private final URL testFile = this.getClass().getResource("template-user-crops.json");
|
||||
|
||||
@BeforeEach
|
||||
void connectToDb() throws URISyntaxException, IOException {
|
||||
|
||||
@@ -8,17 +8,22 @@ import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
public class JsonPlantListTest {
|
||||
private final URL testFile = this.getClass().getResource("test-plantdb.json");
|
||||
PlantList testDatabase;
|
||||
|
||||
@BeforeEach
|
||||
void connectToDb() {
|
||||
testDatabase = new JsonPlantList();
|
||||
assertNotNull(testFile);
|
||||
testDatabase = new JsonPlantList(testFile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,27 +18,27 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
public class JsonTaskListTest {
|
||||
|
||||
TaskList testDatabase;
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
private final URL dbDataSource = this.getClass().getResource("taskdb.json");
|
||||
private final URL testFile = this.getClass().getResource("test-taskdb.json");
|
||||
private final URL dbDataSource = this.getClass().getResource("test-taskdb.json");
|
||||
private final URL testFile = this.getClass().getResource("template-taskdb.json");
|
||||
|
||||
@BeforeEach
|
||||
void connectToDb() throws URISyntaxException, IOException {
|
||||
assertNotNull(testFile);
|
||||
assertNotNull(dbDataSource);
|
||||
Files.copy(Path.of(testFile.toURI()), Path.of(dbDataSource.toURI()), StandardCopyOption.REPLACE_EXISTING);
|
||||
testDatabase = new JsonTaskList();
|
||||
testDatabase = new JsonTaskList(dbDataSource);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Check if results are retrieved completely")
|
||||
void getTasks() {
|
||||
|
||||
List<Task> taskList = null;
|
||||
List<Task> taskList;
|
||||
try {
|
||||
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022", formatter),
|
||||
LocalDate.parse("31.05.2022", formatter));
|
||||
taskList = testDatabase.getTaskList(LocalDate.parse("2022-04-30", formatter),
|
||||
LocalDate.parse("2022-05-31", formatter));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class JsonTaskListTest {
|
||||
Task task = new Task("Testtask", "This is a test Task.", LocalDate.parse("01.05.2022", formatter), 1);
|
||||
try {
|
||||
testDatabase.saveTask(task);
|
||||
List<Task> taskList = null;
|
||||
List<Task> taskList;
|
||||
try {
|
||||
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022", formatter),
|
||||
LocalDate.parse("31.05.2022", formatter));
|
||||
@@ -72,13 +72,13 @@ public class JsonTaskListTest {
|
||||
@Test
|
||||
@DisplayName("Remove task.")
|
||||
void removeTask() {
|
||||
Task task = new Task("Dummy", "Dummy", LocalDate.parse("31.05.2022", formatter), 1).withId(2);
|
||||
Task task = new Task("Dummy", "Dummy", LocalDate.parse("2022-05-31", formatter), 1).withId(2);
|
||||
try {
|
||||
testDatabase.removeTask(task);
|
||||
List<Task> taskList = null;
|
||||
List<Task> taskList;
|
||||
|
||||
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022", formatter),
|
||||
LocalDate.parse("31.05.2022", formatter));
|
||||
taskList = testDatabase.getTaskList(LocalDate.parse("2022-04-30", formatter),
|
||||
LocalDate.parse("2022-05-31", formatter));
|
||||
|
||||
Assertions.assertEquals(2, taskList.size());
|
||||
} catch (IOException e) {
|
||||
@@ -90,7 +90,7 @@ public class JsonTaskListTest {
|
||||
|
||||
@Test
|
||||
void getTaskForCrop() {
|
||||
List<Task> taskList = null;
|
||||
List<Task> taskList;
|
||||
try {
|
||||
taskList = testDatabase.getTaskForCrop(0);
|
||||
} catch (IOException e) {
|
||||
@@ -104,7 +104,7 @@ public class JsonTaskListTest {
|
||||
@Disabled("Disabled until removing works")
|
||||
@Test
|
||||
void removeTasksForCrop() {
|
||||
List<Task> taskList = null;
|
||||
List<Task> taskList;
|
||||
try {
|
||||
testDatabase.removeTasksForCrop(0);
|
||||
taskList = testDatabase.getTaskForCrop(0);
|
||||
|
||||
@@ -22,8 +22,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class GardenPlanModelTest {
|
||||
private final URL dbDataSource = JsonCropList.class.getResource("user-crops.json");
|
||||
private final URL testFile = JsonCropList.class.getResource("test-user-crops.json");
|
||||
private final URL dbDataSource = JsonCropListTest.class.getResource("test-user-crops.json");
|
||||
private final URL testFile = JsonCropListTest.class.getResource("template-user-crops.json");
|
||||
|
||||
CropList cropList;
|
||||
List<Crop> exampleCrops;
|
||||
|
||||
@@ -1,257 +0,0 @@
|
||||
[
|
||||
{
|
||||
"id": 0,
|
||||
"name": "Potato",
|
||||
"description": "The potato is a tuber, round or oval, with small white roots called 'eyes', that are growth buds. The size varies depending on the variety; the colour of the skin can be white, yellow or even purple.",
|
||||
"light": 6,
|
||||
"spacing": "35",
|
||||
"soil": "sandy",
|
||||
"image": "potato.jpg",
|
||||
"pests": [
|
||||
{
|
||||
"name": "Rot",
|
||||
"description": "Rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
|
||||
"measures": "Less water."
|
||||
}
|
||||
],
|
||||
"lifecycle": [
|
||||
{
|
||||
"startDate": "03-10",
|
||||
"endDate": "04-10",
|
||||
"type": "SOW",
|
||||
"zone": "ZONE_8A",
|
||||
"group": 0,
|
||||
"wateringCycle": {
|
||||
"litersPerSqM": 0,
|
||||
"interval": null,
|
||||
"notes": []
|
||||
},
|
||||
"taskTemplates": [
|
||||
{
|
||||
"name": "Germinate",
|
||||
"relativeStartDate": -14,
|
||||
"relativeEndDate": null,
|
||||
"description": "\"Take an egg carton and fill it with soil. Put the seedling deep enaugh so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.\"",
|
||||
"interval": null,
|
||||
"isOptional": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"startDate": "04-10",
|
||||
"endDate": "07-10",
|
||||
"type": "PLANT",
|
||||
"zone": "ZONE_8A",
|
||||
"group": 0,
|
||||
"wateringCycle": {
|
||||
"litersPerSqM": 25,
|
||||
"interval": 7,
|
||||
"notes": []
|
||||
},
|
||||
"taskTemplates": [
|
||||
{
|
||||
"name": "hilling",
|
||||
"relativeStartDate": 0,
|
||||
"relativeEndDate": null,
|
||||
"description": "\"When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.\"",
|
||||
"interval": 21,
|
||||
"isOptional": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"startDate": "06-10",
|
||||
"endDate": "08-10",
|
||||
"type": "HARVEST",
|
||||
"zone": "ZONE_8A",
|
||||
"group": 0,
|
||||
"wateringCycle": {
|
||||
"litersPerSqM": 0,
|
||||
"interval": null,
|
||||
"notes": []
|
||||
},
|
||||
"taskTemplates": [
|
||||
{
|
||||
"name": "Harvest",
|
||||
"relativeStartDate": 0,
|
||||
"relativeEndDate": null,
|
||||
"description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.",
|
||||
"interval": null,
|
||||
"isOptional": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Early Carrot",
|
||||
"description": "Carrot, (Daucus carota), herbaceous, generally biennial plant of the Apiaceae family that produces an edible taproot. Among common varieties root shapes range from globular to long, with lower ends blunt to pointed. Besides the orange-coloured roots, white-, yellow-, and purple-fleshed varieties are known.",
|
||||
"image": "carrot.jpg",
|
||||
"lifecycle": [
|
||||
{
|
||||
"startDate": "02-20",
|
||||
"endDate": "03-10",
|
||||
"zone": "ZONE_8A",
|
||||
"type": "SOW",
|
||||
"wateringCycle": {
|
||||
"litersPerSqM": 15,
|
||||
"interval": 3,
|
||||
"notes": []
|
||||
},
|
||||
"taskTemplates": [
|
||||
{
|
||||
"name": "hilling",
|
||||
"relativeStartDate": 0,
|
||||
"relativeEndDate": 0,
|
||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||
"interval": null,
|
||||
"isOptional": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"startDate": "03-10",
|
||||
"endDate": "05-10",
|
||||
"zone": "ZONE_8A",
|
||||
"type": "PLANT",
|
||||
"wateringCycle": {
|
||||
"litersPerSqM": 25,
|
||||
"interval": 3,
|
||||
"notes": [
|
||||
"Be careful not to pour water over the leaves, as this will lead to sunburn."
|
||||
]
|
||||
},
|
||||
"taskTemplates": [
|
||||
{
|
||||
"name": "hilling",
|
||||
"relativeStartDate": 0,
|
||||
"relativeEndDate": null,
|
||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||
"interval": 15,
|
||||
"isOptional": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"startDate": "05-10",
|
||||
"endDate": "05-20",
|
||||
"zone": "ZONE_8A",
|
||||
"type": "HARVEST",
|
||||
"wateringCycle": {
|
||||
"litersPerSqM": 0,
|
||||
"interval": null,
|
||||
"notes": []
|
||||
},
|
||||
"taskTemplates": [
|
||||
{
|
||||
"name": "Harvesting",
|
||||
"relativeStartDate": 0,
|
||||
"relativeEndDate": 14,
|
||||
"description": "When the leaves turn to a yellowish brown. Do not harvest earlier. The plant will show when it's ready.",
|
||||
"interval": null,
|
||||
"isOptional": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"soil": "sandy to loamy, loose soil, free of stones",
|
||||
"spacing": "5,35,2.5",
|
||||
"pests": [
|
||||
{
|
||||
"name": "Rot",
|
||||
"description": "rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
|
||||
"measures": "less water"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Summertime Onion",
|
||||
"description": "Onion, (Allium cepa), herbaceous biennial plant in the amaryllis family (Amaryllidaceae) grown for its edible bulb. The onion is likely native to southwestern Asia but is now grown throughout the world, chiefly in the temperate zones. Onions are low in nutrients but are valued for their flavour and are used widely in cooking. They add flavour to such dishes as stews, roasts, soups, and salads and are also served as a cooked vegetable.",
|
||||
"image": "onion.jpg",
|
||||
"lifecycle": [
|
||||
{
|
||||
"startDate": "03-15",
|
||||
"endDate": "04-10",
|
||||
"type": "SOW",
|
||||
"zone": "ZONE_8A",
|
||||
"group": 0,
|
||||
"wateringCycle": {
|
||||
"litersPerSqM": 15,
|
||||
"interval": 4,
|
||||
"notes": [
|
||||
|
||||
]
|
||||
},
|
||||
"taskTemplates": [
|
||||
{
|
||||
"name": "hilling",
|
||||
"relativeStartDate": 0,
|
||||
"relativeEndDate": 0,
|
||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||
"interval": null,
|
||||
"isOptional": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"startDate": "04-10",
|
||||
"endDate": "07-10",
|
||||
"type": "PLANT",
|
||||
"zone": "ZONE_8A",
|
||||
"group": 0,
|
||||
"wateringCycle": {
|
||||
"litersPerSqM": 25,
|
||||
"interval": 3,
|
||||
"notes": [
|
||||
""
|
||||
]
|
||||
},
|
||||
"taskTemplates": [
|
||||
{
|
||||
"name": "hilling",
|
||||
"relativeStartDate": 0,
|
||||
"relativeEndDate": null,
|
||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||
"interval": 15,
|
||||
"isOptional": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"startDate": "07-10",
|
||||
"endDate": "09-20",
|
||||
"type": "HARVEST",
|
||||
"zone": "ZONE_8A",
|
||||
"group": 0,
|
||||
"wateringCycle": {
|
||||
"litersPerSqM": 0,
|
||||
"interval": null,
|
||||
"notes": [
|
||||
|
||||
]
|
||||
},
|
||||
"taskTemplates": [
|
||||
{
|
||||
"name": "Harvesting",
|
||||
"relativeStartDate": 0,
|
||||
"relativeEndDate": 14,
|
||||
"description": "When ready for harvest, the leaves on your onion plants will start to flop over. This happens at the \"neck\" of the onion and it signals that the plant has stopped growing and is ready for storage. Onions should be harvested soon thereafter",
|
||||
"interval": null,
|
||||
"isOptional": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"soil": "sandy to loamy, loose soil, free of stones",
|
||||
"spacing": "15,30,2",
|
||||
"pests": [
|
||||
{
|
||||
"name": "Rot",
|
||||
"description": "rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
|
||||
"measures": "less water"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -1,11 +1,11 @@
|
||||
[
|
||||
{
|
||||
"id" : 1,
|
||||
"name" : "sow plant",
|
||||
"description": "Plant the seeds, crops in de bed.",
|
||||
"startDate" : "2022-05-01",
|
||||
"endDate" : "2022-05-01",
|
||||
"interval" : 0,
|
||||
"id" : 1,
|
||||
"name" : "sow plant",
|
||||
"description": "Plant the seeds, crops in de bed.",
|
||||
"startDate" : "2022-05-01",
|
||||
"endDate" : "2022-05-01",
|
||||
"interval" : 0,
|
||||
"cropId" : 0
|
||||
},
|
||||
{
|
||||
@@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"cropId": 0,
|
||||
"plantId": 1,
|
||||
"startDate": "2023-02-25",
|
||||
"area": 0.5
|
||||
},
|
||||
{
|
||||
"cropId": 1,
|
||||
"plantId": 1,
|
||||
"startDate": "2023-03-01",
|
||||
"area": 0.5
|
||||
},
|
||||
{
|
||||
"cropId": 2,
|
||||
"plantId": 0,
|
||||
"startDate": "2023-03-25",
|
||||
"area": 1.5
|
||||
}
|
||||
]
|
||||
@@ -31,7 +31,7 @@
|
||||
"name": "Germinate",
|
||||
"relativeStartDate": -14,
|
||||
"relativeEndDate": null,
|
||||
"description": "\"Take an egg carton and fill it with soil. Put the seedling deep enaugh so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.\"",
|
||||
"description": "Take an egg carton and fill it with soil. Put the seedling deep enough so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.",
|
||||
"interval": null,
|
||||
"isOptional": false
|
||||
}
|
||||
@@ -53,7 +53,7 @@
|
||||
"name": "hilling",
|
||||
"relativeStartDate": 0,
|
||||
"relativeEndDate": null,
|
||||
"description": "\"When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.\"",
|
||||
"description": "When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.",
|
||||
"interval": 21,
|
||||
"isOptional": false
|
||||
}
|
||||
@@ -94,6 +94,7 @@
|
||||
"endDate": "03-10",
|
||||
"zone": "ZONE_8A",
|
||||
"type": "SOW",
|
||||
"group": 0,
|
||||
"wateringCycle": {
|
||||
"litersPerSqM": 15,
|
||||
"interval": 3,
|
||||
@@ -115,6 +116,7 @@
|
||||
"endDate": "05-10",
|
||||
"zone": "ZONE_8A",
|
||||
"type": "PLANT",
|
||||
"group": 0,
|
||||
"wateringCycle": {
|
||||
"litersPerSqM": 25,
|
||||
"interval": 3,
|
||||
@@ -138,6 +140,7 @@
|
||||
"endDate": "05-20",
|
||||
"zone": "ZONE_8A",
|
||||
"type": "HARVEST",
|
||||
"group": 0,
|
||||
"wateringCycle": {
|
||||
"litersPerSqM": 0,
|
||||
"interval": null,
|
||||
@@ -1,56 +1,2 @@
|
||||
[
|
||||
{
|
||||
"id" : 1,
|
||||
"name" : "sow plant",
|
||||
"description": "Plant the seeds, crops in de bed.",
|
||||
"startDate" : "2022-05-01",
|
||||
"endDate" : "2022-05-01",
|
||||
"interval" : 0,
|
||||
"cropId" : 0
|
||||
},
|
||||
{
|
||||
"id" : 2,
|
||||
"name" : "water plant",
|
||||
"description": "water the plant, so that the soil is wet around the plant.",
|
||||
"startDate" : "2022-05-01",
|
||||
"endDate" : "2022-09-01",
|
||||
"interval" : 2,
|
||||
"cropId" : 0
|
||||
},
|
||||
{
|
||||
"id" : 3,
|
||||
"name" : "fertilize plant",
|
||||
"description": "The fertilizer has to be mixed with water. Then fertilize the plants soil with the mixture",
|
||||
"startDate" : "2022-06-01",
|
||||
"endDate" : "2022-08-01",
|
||||
"interval" : 28,
|
||||
"cropId" : 0
|
||||
},
|
||||
{
|
||||
"id" : 4,
|
||||
"name" : "covering plant",
|
||||
"description": "Take a big enough coverage for the plants. Cover the whole plant with a bit space between the plant and the coverage",
|
||||
"startDate" : "2022-07-01",
|
||||
"endDate" : "2022-07-01",
|
||||
"interval" : 0,
|
||||
"cropId" : 0
|
||||
},
|
||||
{
|
||||
"id" : 5,
|
||||
"name" : "look after plant",
|
||||
"description": "Look for pest or illness at the leaves of the plant. Check the soil around the plant, if the roots are enough covered with soil",
|
||||
"startDate" : "2022-05-01",
|
||||
"endDate" : "2022-09-01",
|
||||
"interval" : 5,
|
||||
"cropId" : 0
|
||||
},
|
||||
{
|
||||
"id" : 6,
|
||||
"name" : "harvest plant",
|
||||
"description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ",
|
||||
"startDate" : "2022-09-01",
|
||||
"endDate" : "2022-09-01",
|
||||
"interval" : 0,
|
||||
"cropId" : 0
|
||||
}
|
||||
]
|
||||
@@ -1,20 +1,2 @@
|
||||
[
|
||||
{
|
||||
"cropId": 0,
|
||||
"plantId": 1,
|
||||
"startDate": "2023-02-25",
|
||||
"area": 0.5
|
||||
},
|
||||
{
|
||||
"cropId": 1,
|
||||
"plantId": 1,
|
||||
"startDate": "2023-03-01",
|
||||
"area": 0.5
|
||||
},
|
||||
{
|
||||
"cropId": 2,
|
||||
"plantId": 0,
|
||||
"startDate": "2023-03-25",
|
||||
"area": 1.5
|
||||
}
|
||||
]
|
||||
@@ -1,2 +0,0 @@
|
||||
[
|
||||
]
|
||||