Compare commits

..

No commits in common. "main" and "feature_updaeTaskListViewOnUpdate_M3" have entirely different histories.

56 changed files with 511 additions and 818 deletions

View File

@ -1,19 +1,32 @@
# GardenPlanner
# PM3-HS22-IT21b_WIN-Team1
PM3 FivePlants Gartenverwaltung
## Installations- und Gebrauchsanweisung
### Vorbedingungen
- Das Java Runtime Environment (JRE) muss in der Version 17 auf Ihrem Computer installiert sein.
- Das Java Development Kit (JDK) muss in der Version 17 auf Ihrem Computer installiert sein.
## Class Diagram
Umletino: https://www.umletino.com/umletino.html
### Installation und Starten der Applikation
1. Laden sie die neuste Version der Applikation herunter. Sie finden die Applikation hier:
https://github.zhaw.ch/schrom01/PM3-HS22-IT21b_WIN-Team1/tags
2. Extrahieren sie die heruntergeladene ZIP-Datei
3. Öffnen sie ein Kommandozeilenfenster und navigieren sie an den Speicherort der Entpack-ten Applikation.
4. Führen sie den Befehl: «./gradlew.bat run» (auf Windows) oder «./gradlew run» (auf ma-cOS und Linux) aus.
Draft File: doc/ClassDiagramDraft.uxf
### Anwendung
Eine Bedienungsanleitung finden Sie im Dokument ["Technischer Bericht II"](doc/PM3-HS22-IT21b_WIN-Technischer_Bericht_II-Team1.pdf) im Kapitel 6.3.3.
## Branch model
- production branch: `main`
## Projektdokumentation
Die gesamte Projektdokumentation ist im Dokument ["Technischer Bericht II"](doc/PM3-HS22-IT21b_WIN-Technischer_Bericht_II-Team1.pdf) zu finden.
This branch has a working version of the code.
- development branch: `dev`
This branch should contain a running (although not necessarily working) version of the code. Working states are to be merged into the `main` branch regularly.
- feature: `feature_xy_<Milestone>`
These branches contain features in active development. When the code is ready it will be merged into the `dev` branch.
- bugfix: `bugfix_xy_<Milestone>`
These branches are for bugfixes.
- documentation: `doc_xy_<Milestone>`
These branches are for javadoc and project documentation (such as the readme, class diagrams etc.).
## User Manual
- Search Plant List: if first Char is '#': only exact match in ID.

View File

@ -0,0 +1,92 @@
<diagram program="umletino" version="15.0.0"><zoom_level>10</zoom_level><element><id>UMLClass</id><coordinates><x>720</x><y>30</y><w>100</w><h>30</h></coordinates><panel_attributes>Main</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1240</x><y>250</y><w>300</w><h>140</h></coordinates><panel_attributes>&lt;&lt;Interface&gt;&gt;
PlantDatabase
--
+ getPlantList(zone: HardinessZone): List&lt;Plant&gt;
+ getPlant(id: long): Optional&lt;Plant&gt;</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>940</x><y>580</y><w>220</w><h>40</h></coordinates><panel_attributes>TaskListController</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1240</x><y>10</y><w>300</w><h>180</h></coordinates><panel_attributes>&lt;&lt;Record&gt;&gt;
Plant
--
+ id: long
+ name: String
+ description: String
+ spacing: int
+ lifecycle: List&lt;GrowthPhase&gt;
--
+ calculateStartDate(harvestDate: Date): Date
+ generateTasks()
</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1210</x><y>580</y><w>210</w><h>120</h></coordinates><panel_attributes>TaskListModel
--
- tasks: ListProperty&lt;Task&gt;
- taskDb: TaskDatabase
--
+ getTask(id: long): Optional&lt;Task&gt;
+ saveTask(task: Task)
+ removeTask(task: Task)</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>590</x><y>560</y><w>250</w><h>110</h></coordinates><panel_attributes>GardenPlanModel
--
- tasks: ListProperty&lt;Task&gt;
- gardenPlan: GardenPlan
--
+ savePlanting(planting: UserPlanting)
+ removePlanting(planting: UserPlanting)</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>340</x><y>550</y><w>180</w><h>80</h></coordinates><panel_attributes>GardenPlanController</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1660</x><y>720</y><w>490</w><h>240</h></coordinates><panel_attributes>Task
--
+ id: long
+ name: String {readOnly}
+ description: String {readOnly}
+ startDate: Date {readOnly}
+ isReadOnly: boolean {readOnly}
- interval: int
- endDate: Date
--
+ Task(name: String, description: String, startDate: String, isReadOnly: boolean): Task
+ withInterval(interval: int): Task
+ withEndDate(endDate: Date): Task
+ withId(id: long): Task
--
+ getInterval(): Optional&lt;int&gt;
+ getEndDate(): Optional&lt;Date&gt;</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1170</x><y>760</y><w>280</w><h>140</h></coordinates><panel_attributes>&lt;&lt;Interface&gt;&gt;
TaskDatabase
--
+ getTaskList(start: Date, end: Date): List&lt;Task&gt;
+ saveTask(Task task) throws ??Exception
+ removeTask(Task task) throws ??Exception</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>780</x><y>310</y><w>100</w><h>100</h></coordinates><panel_attributes>MainWindow</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>440</x><y>180</y><w>180</w><h>130</h></coordinates><panel_attributes>MainWindowController</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1340</x><y>1070</y><w>210</w><h>70</h></coordinates><panel_attributes>NotificationService
--
- taskDb: TaskDatabase
--
+ tick()</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1640</x><y>1210</y><w>240</w><h>140</h></coordinates><panel_attributes>&lt;&lt;Interface&gt;&gt;
WeatherProvider
--
+ getWeatherForecast: WeatherForecast</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1620</x><y>1040</y><w>400</w><h>100</h></coordinates><panel_attributes>WeatherService
--
- weatherPovider: WeatherProvider
- taskDb: TaskDatabase
--
+ WeatherService(provider: WeatherProvider, taskDb: TaskDatabase)
- updateTasks()</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1620</x><y>10</y><w>260</w><h>150</h></coordinates><panel_attributes>&lt;&lt;Record&gt;&gt;
GrowthPhase
--
+ startDate: Date
+ endDate: Date
+ type: GrowthPhaseType
</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1530</x><y>80</y><w>110</w><h>30</h></coordinates><panel_attributes>lt=&lt;-&gt;&gt;&gt;&gt;&gt;</panel_attributes><additional_attributes>90;10;10;10</additional_attributes></element><element><id>Text</id><coordinates><x>420</x><y>0</y><w>190</w><h>70</h></coordinates><panel_attributes>Note:
--
{final, readOnly} omitted on public data fields in &lt;&lt;Record&gt;&gt; Entities for clarity
style=wordwrap</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1440</x><y>820</y><w>240</w><h>30</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>220;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1300</x><y>690</y><w>30</w><h>90</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;70;10;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>600</x><y>980</y><w>210</w><h>120</h></coordinates><panel_attributes>&lt;&lt;Record&gt;&gt;
UserPlanting
--
+ plantId: long
+ asSowing: boolean
+ startDate: Date
+ area: int</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1380</x><y>180</y><w>30</w><h>90</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;10;10;70</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1950</x><y>10</y><w>140</w><h>120</h></coordinates><panel_attributes>&lt;&lt;Enumeration&gt;&gt;
GrowthPhaseType
--
SOW
PLANT
HARVEST</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1870</x><y>70</y><w>100</w><h>30</h></coordinates><panel_attributes>lt=&lt;-&gt;&gt;&gt;&gt;</panel_attributes><additional_attributes>80;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1150</x><y>590</y><w>80</w><h>30</h></coordinates><panel_attributes>lt=&lt;-&gt;&gt;&gt;&gt;</panel_attributes><additional_attributes>60;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>700</x><y>890</y><w>30</w><h>110</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;90;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>510</x><y>580</y><w>100</w><h>30</h></coordinates><panel_attributes>lt=&lt;-&gt;&gt;&gt;&gt;</panel_attributes><additional_attributes>80;10;10;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>570</x><y>760</y><w>280</w><h>140</h></coordinates><panel_attributes>&lt;&lt;Interface&gt;&gt;
GardenPlan
--
+ getPlantings(): List&lt;UserPlanting&gt;
+ addPlanting(plantId: long, startDate)
+ savePlanting(planting: UserPlanting)
</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>690</x><y>660</y><w>30</w><h>120</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;100;10;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>60</x><y>390</y><w>180</w><h>80</h></coordinates><panel_attributes>PlantingCell
{extends ListCell&lt;&gt;}</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>0</x><y>540</y><w>290</w><h>80</h></coordinates><panel_attributes>PlantingCellFactory
{implements Callback&lt;ListView&lt;UserPlanting&gt; &gt;}</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>140</x><y>460</y><w>30</w><h>100</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;10;10;80</additional_attributes></element><element><id>Relation</id><coordinates><x>1750</x><y>1130</y><w>30</w><h>100</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;80;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1350</x><y>890</y><w>120</w><h>200</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;10;100;180</additional_attributes></element><element><id>Relation</id><coordinates><x>1380</x><y>890</y><w>260</w><h>220</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;10;240;200</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1090</x><y>1060</y><w>200</w><h>50</h></coordinates><panel_attributes>JsonTaskDatabase</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1180</x><y>890</y><w>30</w><h>190</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>10;10;10;170</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1620</x><y>310</y><w>200</w><h>50</h></coordinates><panel_attributes>JsonPlantDatabase</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1530</x><y>320</y><w>110</w><h>30</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>10;10;90;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>300</x><y>800</y><w>200</w><h>50</h></coordinates><panel_attributes>JsonGardenPlan</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>490</x><y>810</y><w>100</w><h>30</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>80;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>280</x><y>570</y><w>80</w><h>30</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;10;60;10</additional_attributes></element><element><id>Relation</id><coordinates><x>850</x><y>400</y><w>220</w><h>200</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>200;180;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>440</x><y>400</y><w>390</w><h>170</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;150;370;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>850</x><y>120</y><w>160</w><h>60</h></coordinates><panel_attributes>PlantListController</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>760</x><y>50</y><w>90</w><h>280</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>70;260;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>610</x><y>230</y><w>190</w><h>140</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;10;170;120</additional_attributes></element><element><id>Relation</id><coordinates><x>870</x><y>170</y><w>80</w><h>210</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>60;10;10;190</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1020</x><y>290</y><w>160</w><h>60</h></coordinates><panel_attributes>PlantListModel</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1000</x><y>150</y><w>110</w><h>160</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>90;140;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1170</x><y>310</y><w>90</w><h>30</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>70;10;10;10</additional_attributes></element></diagram>

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -0,0 +1,7 @@
<diagram program="umletino" version="15.0.0"><zoom_level>10</zoom_level><element><id>UMLPackage</id><coordinates><x>390</x><y>60</y><w>340</w><h>100</h></coordinates><panel_attributes>UI</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>390</x><y>180</y><w>460</w><h>120</h></coordinates><panel_attributes>Domain</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>390</x><y>330</y><w>460</w><h>120</h></coordinates><panel_attributes>Technical Services</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>400</x><y>90</y><w>100</w><h>60</h></coordinates><panel_attributes>Views (JFX)</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>400</x><y>220</y><w>100</w><h>60</h></coordinates><panel_attributes>IO</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>400</x><y>370</y><w>100</w><h>60</h></coordinates><panel_attributes>Jackson</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>510</x><y>220</y><w>100</w><h>60</h></coordinates><panel_attributes>Types</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>620</x><y>220</y><w>100</w><h>60</h></coordinates><panel_attributes>Models</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>510</x><y>90</y><w>110</w><h>60</h></coordinates><panel_attributes>Controllers (JFX)</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>510</x><y>370</y><w>100</w><h>60</h></coordinates><panel_attributes>Logging</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>620</x><y>370</y><w>100</w><h>60</h></coordinates><panel_attributes>JavaFX</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>730</x><y>220</y><w>110</w><h>60</h></coordinates><panel_attributes>Services</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>730</x><y>370</y><w>110</w><h>60</h></coordinates><panel_attributes>HTTP/API</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>570</x><y>150</y><w>90</w><h>70</h></coordinates><panel_attributes>lt=.&gt;
</panel_attributes><additional_attributes>70;10;10;50</additional_attributes></element><element><id>Relation</id><coordinates><x>570</x><y>290</y><w>110</w><h>80</h></coordinates><panel_attributes>lt=.&gt;
</panel_attributes><additional_attributes>90;10;10;60</additional_attributes></element><element><id>Relation</id><coordinates><x>340</x><y>120</y><w>350</w><h>400</h></coordinates><panel_attributes>lt=.&gt;
</panel_attributes><additional_attributes>60;10;10;10;10;380;330;380;330;310</additional_attributes></element><element><id>Relation</id><coordinates><x>770</x><y>270</y><w>30</w><h>120</h></coordinates><panel_attributes>lt=.&gt;
</panel_attributes><additional_attributes>10;10;10;100</additional_attributes></element><element><id>Relation</id><coordinates><x>360</x><y>250</y><w>60</w><h>180</h></coordinates><panel_attributes>lt=.&gt;
</panel_attributes><additional_attributes>40;10;10;10;10;160;40;160</additional_attributes></element><element><id>Relation</id><coordinates><x>610</x><y>120</y><w>70</w><h>120</h></coordinates><panel_attributes>lt=.&gt;
</panel_attributes><additional_attributes>10;10;50;10;50;100</additional_attributes></element></diagram>

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

View File

@ -0,0 +1,144 @@
<diagram program="umletino" version="15.0.0"><zoom_level>10</zoom_level><element><id>UMLClass</id><coordinates><x>482</x><y>360</y><w>100</w><h>30</h></coordinates><panel_attributes>Main</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1082</x><y>380</y><w>370</w><h>100</h></coordinates><panel_attributes>&lt;&lt;Interface&gt;&gt;
PlantDatabase
--
+ getPlantList(zone: HardinessZone): List&lt;Plant&gt;
+ getPlantById(zone: HardinessZone id: long): Optional&lt;Plant&gt;</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>672</x><y>710</y><w>220</w><h>40</h></coordinates><panel_attributes>TaskListController</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1132</x><y>110</y><w>300</w><h>180</h></coordinates><panel_attributes>&lt;&lt;Record&gt;&gt;
Plant
--
+ id: long
+ name: String
+ description: String
+ spacing: int
+ lifecycle: List&lt;GrowthPhase&gt;
--
+ calculateStartDate(harvestDate: Date): Date
+ generateTasks()
</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>942</x><y>710</y><w>210</w><h>120</h></coordinates><panel_attributes>TaskListModel
--
- tasks: ListProperty&lt;Task&gt;
- taskDb: TaskDatabase
--
+ getTask(id: long): Optional&lt;Task&gt;
+ saveTask(task: Task)
+ removeTask(task: Task)</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>322</x><y>690</y><w>250</w><h>120</h></coordinates><panel_attributes>GardenPlanModel
--
- tasks: ListProperty&lt;Crop&gt;
- gardenPlan: GardenPlan
--
+ plantAsCrop(planting: UserPlanting)
+ removePlanting(planting: UserPlanting)</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>72</x><y>680</y><w>180</w><h>80</h></coordinates><panel_attributes>GardenPlanController</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1362</x><y>830</y><w>490</w><h>240</h></coordinates><panel_attributes>Task
--
+ id: long
+ name: String {readOnly}
+ description: String {readOnly}
+ startDate: Date {readOnly}
+ isOptional: boolean {readOnly}
- interval: int
- endDate: Date
--
+ Task(name: String, description: String, startDate: String, isReadOnly: boolean): Task
+ withInterval(interval: int): Task
+ withEndDate(endDate: Date): Task
+ withId(id: long): Task
--
+ getInterval(): Optional&lt;int&gt;
+ getEndDate(): Optional&lt;Date&gt;</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>902</x><y>930</y><w>280</w><h>140</h></coordinates><panel_attributes>&lt;&lt;Interface&gt;&gt;
TaskDatabase
--
+ getTaskList(start: Date, end: Date): List&lt;Task&gt;
+ saveTask(Task task) throws ??Exception
+ removeTask(Task task) throws ??Exception</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>442</x><y>440</y><w>170</w><h>80</h></coordinates><panel_attributes>MainWindowController</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>962</x><y>1310</y><w>210</w><h>70</h></coordinates><panel_attributes>NotificationService
--
- taskDb: TaskDatabase
--
+ tick()</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1412</x><y>1310</y><w>240</w><h>90</h></coordinates><panel_attributes>&lt;&lt;Interface&gt;&gt;
WeatherProvider
--
+ getWeatherForecast: WeatherForecast</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1392</x><y>1150</y><w>400</w><h>100</h></coordinates><panel_attributes>WeatherService
--
- weatherPovider: WeatherProvider
- taskDb: TaskDatabase
--
+ WeatherService(provider: WeatherProvider, taskDb: TaskDatabase)
- updateTasks()</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1502</x><y>110</y><w>260</w><h>150</h></coordinates><panel_attributes>&lt;&lt;Record&gt;&gt;
GrowthPhase
--
+ startDate: MonthDay
+ endDate: MonthDay
+ type: GrowthPhaseType
</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1422</x><y>180</y><w>100</w><h>40</h></coordinates><panel_attributes>lt=&lt;-&gt;&gt;&gt;&gt;&gt;
m1=*
m2=1</panel_attributes><additional_attributes>80;10;10;10</additional_attributes></element><element><id>Text</id><coordinates><x>152</x><y>130</y><w>190</w><h>70</h></coordinates><panel_attributes>Note:
--
{final, readOnly} omitted on public data fields in &lt;&lt;Record&gt;&gt; Entities for clarity
style=wordwrap</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1172</x><y>970</y><w>210</w><h>50</h></coordinates><panel_attributes>lt=&lt;.
m1=*
m2=1
returns &gt;</panel_attributes><additional_attributes>190;20;10;20</additional_attributes></element><element><id>Relation</id><coordinates><x>1032</x><y>820</y><w>140</w><h>130</h></coordinates><panel_attributes>lt=&lt;-
m1=1 external database
m2=1 internal list
accesses</panel_attributes><additional_attributes>10;110;10;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>322</x><y>1120</y><w>240</w><h>150</h></coordinates><panel_attributes>Crop
--
- cropId: Long
+ plantId: long {final, readOnly}
+ startDate: LocalDate {final, readOnly}
+ area: Double
--
+ withId(long): Crop
+ withArea(double): Crop
--
+ getCropId(): Optional&lt;Long&gt;</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1262</x><y>280</y><w>70</w><h>120</h></coordinates><panel_attributes>lt=&lt;.
m1=*
m2=1
returns</panel_attributes><additional_attributes>10;10;10;100</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1632</x><y>290</y><w>130</w><h>100</h></coordinates><panel_attributes>&lt;&lt;Enumeration&gt;&gt;
GrowthPhaseType
--
SOW
PLANT
HARVEST</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1582</x><y>250</y><w>70</w><h>120</h></coordinates><panel_attributes>lt=&lt;-&gt;&gt;&gt;&gt;
m1=1
m2=*</panel_attributes><additional_attributes>50;90;10;90;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>882</x><y>720</y><w>80</w><h>30</h></coordinates><panel_attributes>lt=&lt;-&gt;&gt;&gt;&gt;</panel_attributes><additional_attributes>60;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>432</x><y>1020</y><w>110</w><h>120</h></coordinates><panel_attributes>lt=&lt;.
m1=*
m2=1
returns / saves</panel_attributes><additional_attributes>10;100;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>242</x><y>710</y><w>100</w><h>30</h></coordinates><panel_attributes>lt=&lt;-&gt;&gt;&gt;&gt;</panel_attributes><additional_attributes>80;10;10;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>302</x><y>890</y><w>280</w><h>140</h></coordinates><panel_attributes>&lt;&lt;Interface&gt;&gt;
GardenPlan
--
+ getPlantings(): List&lt;UserPlanting&gt;
+ addPlanting(plantId: long, startDate)
+ savePlanting(planting: UserPlanting)
</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>422</x><y>800</y><w>80</w><h>110</h></coordinates><panel_attributes>lt=&lt;.
m1=1
m2=1
accesses</panel_attributes><additional_attributes>10;90;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1522</x><y>1240</y><w>30</w><h>90</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;70;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1062</x><y>1060</y><w>80</w><h>270</h></coordinates><panel_attributes>lt=&lt;-
m1=1
m2=1
accesses</panel_attributes><additional_attributes>10;10;10;250</additional_attributes></element><element><id>Relation</id><coordinates><x>1142</x><y>1060</y><w>270</w><h>170</h></coordinates><panel_attributes>lt=&lt;-
m1=1
m2=1
adds Tasks</panel_attributes><additional_attributes>10;10;10;140;250;140</additional_attributes></element><element><id>UMLClass</id><coordinates><x>822</x><y>1140</y><w>200</w><h>50</h></coordinates><panel_attributes>JsonTaskDatabase</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>912</x><y>1060</y><w>30</w><h>100</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>10;10;10;80</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1562</x><y>430</y><w>200</w><h>50</h></coordinates><panel_attributes>JsonPlantDatabase</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1442</x><y>440</y><w>140</w><h>30</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>10;10;120;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>32</x><y>930</y><w>200</w><h>50</h></coordinates><panel_attributes>JsonGardenPlan</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>222</x><y>940</y><w>100</w><h>30</h></coordinates><panel_attributes>lt=&lt;&lt;-</panel_attributes><additional_attributes>80;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>582</x><y>510</y><w>220</w><h>220</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>200;200;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>172</x><y>510</y><w>340</w><h>190</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;170;320;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>582</x><y>250</y><w>160</w><h>60</h></coordinates><panel_attributes>PlantListController</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>522</x><y>380</y><w>30</w><h>80</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>10;60;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>602</x><y>300</y><w>80</w><h>210</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>60;10;10;190</additional_attributes></element><element><id>UMLClass</id><coordinates><x>732</x><y>390</y><w>160</w><h>60</h></coordinates><panel_attributes>PlantListModel</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>732</x><y>280</y><w>90</w><h>130</h></coordinates><panel_attributes>lt=&lt;.</panel_attributes><additional_attributes>70;110;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>882</x><y>400</y><w>220</w><h>70</h></coordinates><panel_attributes>lt=&lt;-
m1=1\nexternal\ndatabase
m2=1\ninternal\nlist
accesses &gt;</panel_attributes><additional_attributes>200;20;10;20</additional_attributes></element><element><id>Relation</id><coordinates><x>582</x><y>0</y><w>190</w><h>50</h></coordinates><panel_attributes>lt=-
m1=0..n
m2=0..1
teaches to &gt;</panel_attributes><additional_attributes>10;20;170;20</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1412</x><y>530</y><w>420</w><h>200</h></coordinates><panel_attributes>TaskTemplate
--
+ name: String {readOnly}
+ description: String {readOnly}
+ relativeStartDate: int {readOnly}
- interval: Integer
- relativeEndDate: Integer
- isOptional: boolean
--
+ Task(name: String, description: String, startDate: String): TaskTemplate
+ setRelativeEndDate(relativeEndDate: int)
+ setInterval(interval: Integer)
+ generateTask(realStartDate: LocalDate): Task
</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1752</x><y>180</y><w>130</w><h>490</h></coordinates><panel_attributes>lt=&lt;-&gt;&gt;&gt;&gt;&gt;
m1=*
m2=1</panel_attributes><additional_attributes>80;460;110;460;110;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1602</x><y>720</y><w>90</w><h>130</h></coordinates><panel_attributes>lt=&lt;.
m1=*
m2=1
generates</panel_attributes><additional_attributes>10;110;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>562</x><y>770</y><w>400</w><h>40</h></coordinates><panel_attributes>lt=&lt;-
delegates generating Tasks</panel_attributes><additional_attributes>380;20;10;20</additional_attributes></element></diagram>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,70 @@
<diagram program="umletino" version="15.0.0"><zoom_level>12</zoom_level><element><id>UMLClass</id><coordinates><x>852</x><y>372</y><w>120</w><h>72</h></coordinates><panel_attributes>Gardener
--
Name
Type</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>144</x><y>372</y><w>120</w><h>120</h></coordinates><panel_attributes>Plant
--
name
description</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>600</x><y>372</y><w>120</w><h>84</h></coordinates><panel_attributes>Garden
--
Location
hardiness zone</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>384</x><y>372</y><w>120</w><h>72</h></coordinates><panel_attributes>Bed
--
Area</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1152</x><y>624</y><w>120</w><h>36</h></coordinates><panel_attributes>Weather</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>852</x><y>816</y><w>120</w><h>36</h></coordinates><panel_attributes>Calendar</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>852</x><y>96</y><w>144</w><h>72</h></coordinates><panel_attributes>Community
--
Plant Information
</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>288</x><y>636</y><w>120</w><h>72</h></coordinates><panel_attributes>Growth phase
--
duration</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>852</x><y>624</y><w>120</w><h>84</h></coordinates><panel_attributes>Gardening task
--
start date
end date
interval</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>852</x><y>156</y><w>120</w><h>240</h></coordinates><panel_attributes>lt=-
m1=0..*
m2=1..*
&lt; is part of </panel_attributes><additional_attributes>10;180;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>708</x><y>372</y><w>168</w><h>60</h></coordinates><panel_attributes>lt=-
m1=1
m2=1..*
&lt; has </panel_attributes><additional_attributes>120;20;10;20</additional_attributes></element><element><id>Relation</id><coordinates><x>252</x><y>372</y><w>156</w><h>60</h></coordinates><panel_attributes>lt=-
m1=1
m2=0..*
&lt; contains </panel_attributes><additional_attributes>110;20;10;20</additional_attributes></element><element><id>Relation</id><coordinates><x>252</x><y>444</y><w>156</w><h>216</h></coordinates><panel_attributes>lt=-
m1=1
m2=1..*
has &gt;</panel_attributes><additional_attributes>10;10;80;10;80;160</additional_attributes></element><element><id>Relation</id><coordinates><x>492</x><y>372</y><w>132</w><h>60</h></coordinates><panel_attributes>lt=-
m1=1
m2=1..*
&lt; contains </panel_attributes><additional_attributes>90;20;10;20</additional_attributes></element><element><id>Relation</id><coordinates><x>900</x><y>432</y><w>120</w><h>216</h></coordinates><panel_attributes>lt=-
m1=1
m2=1..*
&lt; manages </panel_attributes><additional_attributes>10;10;10;160</additional_attributes></element><element><id>Relation</id><coordinates><x>960</x><y>624</y><w>216</w><h>60</h></coordinates><panel_attributes>lt=-
m1=1
m2=1..*
&lt; manipulates</panel_attributes><additional_attributes>160;20;10;20</additional_attributes></element><element><id>Relation</id><coordinates><x>900</x><y>696</y><w>108</w><h>144</h></coordinates><panel_attributes>lt=-
m1=1
m2=0..*
&lt; contains</panel_attributes><additional_attributes>10;10;10;100</additional_attributes></element><element><id>Relation</id><coordinates><x>960</x><y>408</y><w>468</w><h>468</h></coordinates><panel_attributes>lt=-
m1=1
m2=1
&lt; informs </panel_attributes><additional_attributes>10;360;310;360;310;10;10;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>12</x><y>636</y><w>120</w><h>84</h></coordinates><panel_attributes>Need
--
start date
end date</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>60</x><y>432</y><w>108</w><h>228</h></coordinates><panel_attributes>lt=-
m1=1..*
m2=1..*
has &gt;</panel_attributes><additional_attributes>10;170;10;10;70;10</additional_attributes></element><element><id>Relation</id><coordinates><x>60</x><y>672</y><w>816</w><h>120</h></coordinates><panel_attributes>lt=-
m1=1
m2=1
requires &gt;</panel_attributes><additional_attributes>660;10;520;10;520;80;10;80;10;40</additional_attributes></element><element><id>UMLClass</id><coordinates><x>456</x><y>588</y><w>120</w><h>36</h></coordinates><panel_attributes>Team
</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>564</x><y>432</y><w>312</w><h>180</h></coordinates><panel_attributes>lt=-
m1=1
m2=1..*
contains of &gt;</panel_attributes><additional_attributes>10;130;240;10</additional_attributes></element><element><id>Relation</id><coordinates><x>564</x><y>600</y><w>312</w><h>60</h></coordinates><panel_attributes>lt=-
m1=1
m2=0..*
manages &gt;</panel_attributes><additional_attributes>10;20;240;20</additional_attributes></element><element><id>Relation</id><coordinates><x>960</x><y>156</y><w>216</w><h>240</h></coordinates><panel_attributes>lt=-
m1=0..n
m2=1..n
exchanges Informatione &gt;</panel_attributes><additional_attributes>10;10;10;180</additional_attributes></element><element><id>Relation</id><coordinates><x>120</x><y>648</y><w>192</w><h>60</h></coordinates><panel_attributes>lt=-
m1=0..n
m2=1
&lt; contains </panel_attributes><additional_attributes>10;20;140;20</additional_attributes></element></diagram>

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -12,7 +12,6 @@ import ch.zhaw.gartenverwaltung.types.Crop;
import ch.zhaw.gartenverwaltung.types.Pest;
import ch.zhaw.gartenverwaltung.types.Plant;
import ch.zhaw.gartenverwaltung.types.Task;
import javafx.application.Platform;
import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
@ -30,7 +29,6 @@ import javafx.stage.Stage;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -134,14 +132,8 @@ public class CropDetailController {
initializeTaskListProperty(crop);
TaskList.TaskListObserver taskListObserver = newTaskList -> {
Platform.runLater(() -> {
taskListProperty.clear();
try {
taskListProperty.addAll(gardenSchedule.getTaskListForCrop(crop.getCropId().get()));
} catch (IOException e) {
e.printStackTrace();
}
});
taskListProperty.clear();
taskListProperty.addAll(gardenSchedule.getTaskListForCrop(crop.getCropId().get()));
};
gardenSchedule.setTaskListObserver(taskListObserver);
@ -212,6 +204,7 @@ public class CropDetailController {
taskListProperty.clear();
taskListProperty.addAll(taskList);
} catch (IOException e) {
// TODO: Alert
LOG.log(Level.SEVERE, "Could not get task list for crop", e.getCause());
}
});
@ -237,8 +230,6 @@ public class CropDetailController {
Button edit = new Button();
Button delete = new Button();
edit.getStyleClass().add("button-class");
delete.getStyleClass().add("button-class");
HBox.setHgrow(edit, Priority.NEVER);
HBox.setHgrow(delete, Priority.NEVER);
setIconToButton(edit, "editIcon.png");
@ -322,10 +313,6 @@ public class CropDetailController {
DialogPane dialogPane = dialog.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
ButtonType saveTask;
if(newTask) {
saveTask = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE);
@ -374,10 +361,6 @@ public class CropDetailController {
DialogPane dialogPane = dialog.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
ButtonType save = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
dialogPane.getButtonTypes().addAll(save, ButtonType.CANCEL);
@ -409,18 +392,14 @@ public class CropDetailController {
alert.setTitle("Delete " + task.getName());
alert.setHeaderText("Are you sure want to delete this Task?");
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
alert.showAndWait()
.ifPresent(buttonType -> {
if (buttonType == ButtonType.OK) {
try {
gardenSchedule.removeTask(task);
//setTaskListProperty(this.crop);
} catch (IOException e) {
// TODO: Show error alert
LOG.log(Level.SEVERE, "Could not remove crop.", e);
}
}

View File

@ -13,46 +13,30 @@ import javafx.stage.Stage;
import java.io.IOException;
import java.util.Timer;
/**
* Main class of the Application
*/
public class Main extends Application {
Timer backGroundTaskTimer = new Timer();
BackgroundTasks backgroundTasks;
/**
* Method which is automatically called if Application is starting. It loads the scenes to stage and shows the stage.
* It creates a new Instance of BackgroundTasks and schedules them with a Timer instance to execute them every minute.
* @param stage Stage to show
* @throws IOException If loading Scenes can not access the fxml Resource File
*/
@Override
public void start(Stage stage) throws IOException {
AppLoader appLoader = new AppLoader();
backgroundTasks = new BackgroundTasks((TaskList) appLoader.getAppDependency(TaskList.class),(CropList) appLoader.getAppDependency(CropList.class), (PlantList) appLoader.getAppDependency(PlantList.class));
appLoader.loadSceneToStage("MainFXML.fxml", stage);
stage.setTitle("Gartenverwaltung");
stage.show();
backgroundTasks = new BackgroundTasks((TaskList) appLoader.getAppDependency(TaskList.class),(CropList) appLoader.getAppDependency(CropList.class), (PlantList) appLoader.getAppDependency(PlantList.class));
backGroundTaskTimer.scheduleAtFixedRate(backgroundTasks, 0, 60000);
}
/**
* Method which is automatically called when application is stopped.
* It cancels the timer to not execute the background tasks anymore.
*/
@Override
public void stop(){
backGroundTaskTimer.cancel();
}
/**
* The Main method launches the application
* @param args There are no arguments needed.
*/
public static void main(String[] args) {
launch();
}

View File

@ -16,7 +16,6 @@ import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import java.io.IOException;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -56,6 +55,7 @@ public class MainFXMLController {
@FXML
void goToHome() {
showPaneAsMainView("Home.fxml");
styleChangeButton(home_button);
}
/**
@ -64,6 +64,7 @@ public class MainFXMLController {
@FXML
void goToMyPlants() {
showPaneAsMainView("MyGarden.fxml");
styleChangeButton(myGarden_button);
}
/**
@ -72,6 +73,7 @@ public class MainFXMLController {
@FXML
void goToMySchedule() {
showPaneAsMainView("MySchedule.fxml");
styleChangeButton(mySchedule_button);
}
/**
@ -87,10 +89,6 @@ public class MainFXMLController {
DialogPane dialogPane = dialog.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
ButtonType saveSettings = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
dialogPane.getButtonTypes().addAll(saveSettings, ButtonType.CANCEL);
@ -157,6 +155,10 @@ public class MainFXMLController {
appLoader.loadAndCacheFxml("Plants.fxml");
}
private void styleChangeButton(Button button) {
//ToDo changeStyle of the menu buttons
}
/**
* loads the default FXML File
* {@inheritDoc}
@ -167,6 +169,7 @@ public class MainFXMLController {
try {
preloadPanes();
showPaneAsMainView("MyGarden.fxml");
styleChangeButton(myGarden_button);
} catch (IOException e) {
LOG.log(Level.SEVERE, "Failed to load FXML-Pane!", e);
}

View File

@ -19,7 +19,6 @@ import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
@ -100,6 +99,7 @@ public class MyGardenController {
* @throws IOException exception
*/
private HBox createHBoxForListView(Crop crop) throws HardinessZoneNotSetException, IOException {
//ToDo add better design
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).get();
HBox hBox = new HBox(10);
ImageView imageView = new ImageView();
@ -112,35 +112,17 @@ public class MyGardenController {
}
hBox.setMinHeight(100);
Label label = new Label(plant.name());
label.setMinWidth(100);
VBox vbox = new VBox(10);
HBox startDateHBox = new HBox(10);
Label startDateDescription = new Label("Start Date:");
startDateDescription.setMinWidth(75);
Label startDate = new Label(crop.getStartDate().toString());
startDateHBox.getChildren().addAll(startDateDescription, startDate);
HBox endDateHBox = new HBox(10);
Label endDateDescription = new Label("End Date:");
endDateDescription.setMinWidth(75);
Label endDate = new Label(crop.getStartDate().plusDays(plant.timeToHarvest(0)).toString());
endDateHBox.getChildren().addAll(endDateDescription, endDate);
vbox.getChildren().addAll(startDateHBox, endDateHBox);
vbox.setMaxWidth(2000);
HBox.setHgrow(vbox, Priority.ALWAYS);
label.setMaxWidth(2000);
HBox.setHgrow(label, Priority.ALWAYS);
Button details = new Button();
Button delete = new Button();
details.getStyleClass().add("button-class");
delete.getStyleClass().add("button-class");
setIconToButton(details, "detailsIcon.png");
setIconToButton(delete, "deleteIcon.png");
details.setOnAction(getGoToCropDetailEvent(crop));
delete.setOnAction(getDeleteCropEvent(crop));
hBox.getChildren().addAll(imageView, label, vbox, details, delete);
hBox.getChildren().addAll(imageView, label, details, delete);
return hBox;
}
@ -173,6 +155,7 @@ public class MyGardenController {
stage.setResizable(true);
stage.showAndWait();
} catch (IOException | PlantNotFoundException e) {
// TODO: show error alert
LOG.log(Level.SEVERE, "Could not load plant details.", e);
}
};
@ -203,12 +186,6 @@ public class MyGardenController {
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).get();
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Delete " + plant.name());
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
alert.setHeaderText("Are you sure want to delete this Crop?");
alert.setContentText("Deleting this crop will remove all associated tasks from your schedule.");
@ -218,6 +195,7 @@ public class MyGardenController {
try {
garden.removeCrop(crop);
} catch (IOException e) {
// TODO: Show error alert
LOG.log(Level.SEVERE, "Could not remove crop.", e);
}
}

View File

@ -24,7 +24,6 @@ import javafx.scene.layout.VBox;
import java.io.IOException;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -184,8 +183,6 @@ public class MyScheduleController {
Pane puffer = new Pane();
HBox.setHgrow(puffer, Priority.ALWAYS);
Button button = new Button("Task completed!");
button.getStyleClass().add("button-class");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
@ -209,12 +206,6 @@ public class MyScheduleController {
alert.setHeaderText("Are you sure you have completed this task?");
alert.setContentText("Confirming that you have completed the task will remove it from the schedule.");
DialogPane dialogPane = alert.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
alert.showAndWait()
.ifPresent(buttonType -> {
if (buttonType == ButtonType.OK) {

View File

@ -25,7 +25,6 @@ import javafx.scene.layout.VBox;
import java.io.IOException;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -83,10 +82,6 @@ public class PlantsController {
DialogPane dialogPane = dateSelection.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
ButtonType sowButton = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
dialogPane.getButtonTypes().addAll(sowButton, ButtonType.CANCEL);

View File

@ -6,58 +6,21 @@ import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import java.util.List;
import java.util.Objects;
/**
* Singleton Class to store default Settings and User Settings
*/
public class Settings {
/*
* The Class instance to use everywhere
*/
private static final Settings instance;
/**
* The current Hardiness zone initialized as default value Zone_8A
*/
private HardinessZone currentHardinessZone = HardinessZone.ZONE_8A;
/**
* Setting to show or hide the Tutorial in Main Menu
*/
private final BooleanProperty showTutorial = new SimpleBooleanProperty(false);
/**
* The SMTP Credentials which are used to send E-Mail Notifications
* The following Google Account is created for Testing:
* E-Mail Address: pm3.hs22.it21b.win.team1@gmail.com
* Account Password: Gartenverwaltung.PM3.2022
* SMTP Password: bisefhhjtrrhtoqr
*/
private SmtpCredentials smtpCredentials = new SmtpCredentials("imap.gmail.com", "587", "pm3.hs22.it21b.win.team1@gmail.com", "pm3.hs22.it21b.win.team1@gmail.com", "bisefhhjtrrhtoqr", true);
/**
* List of Receivers for E-Mailnotifications. Multiple E-Mailadresses can be separated by ";"
* Following Public E-mail address was used for Testing: pm3.hs22.it21b.win.team1@mailinator.com
* The E-Mail inbox of this address can be found here: https://www.mailinator.com/v4/public/inboxes.jsp?to=pm3.hs22.it21b.win.team1
*/
// Gmail Address: pm3.hs22.it21b.win.team1@gmail.com
// Gmail Passwort: Gartenverwaltung.PM3.2022
// E-Mail Inbox: https://www.mailinator.com/v4/public/inboxes.jsp?to=pm3.hs22.it21b.win.team1
private String mailNotificationReceivers = "pm3.hs22.it21b.win.team1@mailinator.com";
/**
* String Template to create E-Mail Subject for Notifications
* Variables: Task Name
*/
private String mailNotificationSubjectTemplate = "Task %s is due!";
/**
* String Template to create E-Mail Text for Notifications
* Variables: Task Name, plant Name, nextExecution, Task description
*/
private String mailNotificationTextTemplate = "Dear user\nYour gardentask %s for plant %s is due at %tF. Don't forget to confirm in your application if the task is done.\nTask description:\n%s";
private String mailNotificationSubjectTemplate = "Task %s is due!"; // {0} = Task Name
private String mailNotificationTextTemplate = "Dear user\nYour gardentask %s for plant %s is due at %tF. Don't forget to confirm in your application if the task is done.\nTask description:\n%s"; // {0} = Task Name, {1} = plantname, {2} = nextExecution, {3} = Task description
/**
* Location of the garden can be set by user (Used for Weather Service)
*/
private String location = "";
/*
Create Instance of Settings
*/
static {
instance = new Settings();
}
@ -66,21 +29,14 @@ public class Settings {
return Settings.instance;
}
/**
* Private constructor to prevent Classes from creating more instances
*/
private Settings() {}
public HardinessZone getCurrentHardinessZone() {
return currentHardinessZone;
}
/**
* Method to set the current Hardiness Zone. If no Hardiness Zone is given the default zone (ZONE_8A) will be used.
* @param currentHardinessZone the new Hardiness Zone
*/
public void setCurrentHardinessZone(HardinessZone currentHardinessZone) {
this.currentHardinessZone = Objects.requireNonNullElse(currentHardinessZone, HardinessZone.ZONE_8A);
this.currentHardinessZone = currentHardinessZone;
}
public void setShowTutorial (boolean showTutorial) {

View File

@ -12,7 +12,6 @@ import javafx.scene.image.ImageView;
import java.io.IOException;
import java.net.URL;
import java.util.Objects;
import java.util.ResourceBundle;
/**
@ -92,10 +91,6 @@ public class SettingsController implements Initializable {
DialogPane dialogPane = dialog.getDialogPane();
dialogPane.getStylesheets().add(
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
dialogPane.getStyleClass().add("myDialog");
ButtonType save = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
dialogPane.getButtonTypes().addAll(save, ButtonType.CANCEL);

View File

@ -7,7 +7,6 @@ import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import java.io.InputStream;
/**
* Controller class for the Tutorial.fxml file
@ -23,8 +22,6 @@ public class TutorialController {
public ImageView imgAddNewPlant;
public ImageView imgTaskList;
public ImageView imgSelectDate;
public ImageView imgAddTaskButton;
public ImageView imgDetailDeleteButtons;
private int page = 0;
@ -33,27 +30,10 @@ public class TutorialController {
switchViews();
setButtonAbilities();
setImageView(imgAddNewPlant, "add-new-plant.png");
setImageView(imgSelectDate, "select-sow-harvest.png");
setImageView(imgDetailDeleteButtons, "details-delete.png");
setImageView(imgTaskList, "schedule.png");
setImageView(imgAddTaskButton, "add-task.png");
}
/**
* update the given image view with screenshot or placeholder image.
* @param imageView the image view to update
* @param fileName the file name of the source
*/
private void setImageView(ImageView imageView, String fileName) {
InputStream is = PlantsController.class.getResourceAsStream("screenshots/" + fileName);
Image image;
if (is != null) {
image = new Image(String.valueOf(PlantsController.class.getResource("screenshots/" + fileName)));
} else {
image = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
}
imageView.setImage(image);
Image placeholder = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
imgAddNewPlant.setImage(placeholder);
imgSelectDate.setImage(placeholder);
imgTaskList.setImage(placeholder);
}
public void viewNextPage() {

View File

@ -17,57 +17,46 @@ import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Class with tasks which must be executed periodic and not triggered by user. Method run must be called in a fix interval.
*/
public class BackgroundTasks extends TimerTask {
private static final Logger LOG = Logger.getLogger(CropDetailController.class.getName());
private final TaskList taskList;
private final Notifier notifier;
private final WeatherGradenTaskPlanner weatherGardenTaskPlaner;
private void movePastTasks() throws IOException {
List<Task> taskList = this.taskList.getTaskList(LocalDate.MIN, LocalDate.now().minusDays(1));
taskList.forEach(task -> {
if (!task.isDone()) {
task.setNextExecution(LocalDate.now());
}
});
}
public BackgroundTasks(TaskList taskList, CropList cropList, PlantList plantList) {
this.taskList = taskList;
notifier = new Notifier(taskList, plantList, cropList);
weatherGardenTaskPlaner = new WeatherGradenTaskPlanner(taskList, plantList, cropList);
}
/**
* Changes the field "nextExecution" of all tasks if it's in the past to the actual date as long as they are not done.
* @throws IOException if the taskList can't be read.
*/
private void movePastTasks() throws IOException {
List<Task> taskList = this.taskList.getTaskList(LocalDate.MIN.plusDays(1), LocalDate.now().minusDays(1));
for (Task task : taskList) {
if (!task.isDone()) {
task.setNextExecution(LocalDate.now());
this.taskList.saveTask(task);
}
}
}
/**
* Method to call if Tasks should be executed. It calls all Background tasks after each other.
*/
@Override
public void run() {
try {
movePastTasks();
} catch (IOException e) {
e.printStackTrace();
LOG.log(Level.WARNING, "Could not execute Background Task: move past Tasks ", e.getCause());
LOG.log(Level.SEVERE, "Could not execute Background Task: move past Tasks ", e.getCause());
}
try {
weatherGardenTaskPlaner.refreshTasks();
} catch (IOException | HardinessZoneNotSetException | PlantNotFoundException e) {
e.printStackTrace();
LOG.log(Level.WARNING, "Could not execute Background Task: Refresh Tasks by WeatherGardenTaskPlaner ", e.getCause());
LOG.log(Level.SEVERE, "Could not execute Background Task: Refresh Tasks by WeatherGardenTaskPlaner ", e.getCause());
}
try {
notifier.sendNotifications();
} catch (IOException | MessagingException | HardinessZoneNotSetException e) {
e.printStackTrace();
LOG.log(Level.WARNING, "Could not execute Background Task: send Notification for due Tasks", e.getCause());
LOG.log(Level.SEVERE, "Could not execute Background Task: send Notification for due Tasks", e.getCause());
}
}
}

View File

@ -13,9 +13,6 @@ import javax.mail.MessagingException;
import java.io.IOException;
import java.time.LocalDate;
/**
* Class to send Notifications to the user
*/
public class Notifier {
private final TaskList taskList;
private final CropList cropList;
@ -28,13 +25,6 @@ public class Notifier {
this.plantList = plantList;
}
/**
* Method to send a Notification to the user for e specific Task
* @param task The task to use for notification
* @throws IOException if tasklist can not be read
* @throws MessagingException if E-Mail can not be sent for any reason
* @throws HardinessZoneNotSetException if hardiness zone is not set in plant list.
*/
private void sendNotification(Task task) throws IOException, MessagingException, HardinessZoneNotSetException {
String plantName = "unkown plant";
if(cropList.getCropById((task.getCropId())).isPresent()){
@ -48,12 +38,6 @@ public class Notifier {
eMailSender.sendMails(Settings.getInstance().getMailNotificationReceivers(), messageSubject, messageText);
}
/**
* Sends a notification to the user for each task which is due and not done every day as long as it's not done.
* @throws IOException if tasklist can not be read
* @throws MessagingException if E-Mail can not be sent for any reason
* @throws HardinessZoneNotSetException if hardiness zone is not set in plant list.
*/
public void sendNotifications() throws IOException, MessagingException, HardinessZoneNotSetException {
for (Task task : taskList.getTaskList(LocalDate.MIN, LocalDate.MAX)) {
if (task.getNextNotification() != null && task.getNextNotification().isBefore(LocalDate.now().minusDays(1))) {

View File

@ -10,20 +10,16 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* Class to send E-Mails
*/
public class EMailSender {
/**
* Method to send E-Mail to one or multiple recipients
* @param recipients recipients E-Mail addresses separated by ";"
* @param subject Subject of the E-Mail
* @param text E-Mail message Text as rear text or html
* @throws MessagingException If sending the E-Mail fails for any reason
*/
public EMailSender(){
}
public void sendMails(String recipients, String subject, String text) throws MessagingException {
printMail(recipients, subject, text);
// TODO replace printMail with implementation
printMail(recipients, subject, text); // TODO Remove Printing E-Mail to console to test it
MimeMessage message = new MimeMessage(Settings.getInstance().getSmtpCredentials().getSession());
message.addHeader("Content-type", "text/HTML; charset=UTF-8");
message.addHeader("format", "flowed");

View File

@ -5,10 +5,6 @@ import javax.mail.Session;
import java.net.Authenticator;
import java.util.Properties;
/**
* Class to store SMTP Credentials to send E-Mails and create
* corresponding Session Object
*/
public record SmtpCredentials(
String host,
String port,
@ -18,10 +14,6 @@ public record SmtpCredentials(
boolean startTLS
) {
/**
* Creates a Properties Object with SMTP Server Information
* @return the created Properties Object
*/
private Properties getProperties() {
Properties properties = new Properties();
properties.put("mail.smtp.host", host);
@ -31,10 +23,6 @@ public record SmtpCredentials(
return properties;
}
/**
* Creates a javax.mail.Authenticator Object with username and password for SMTP Server
* @return the created javax.mail.Authenticator Object
*/
private javax.mail.Authenticator getAuthenticator() {
return new javax.mail.Authenticator() {
@Override
@ -44,11 +32,10 @@ public record SmtpCredentials(
};
}
/**
* Method to get the Session Instance with the given SMTP Credentials
* @return the Session Instance
*/
public Session getSession() {
return Session.getInstance(getProperties(), getAuthenticator());
}
}

View File

@ -1,8 +1,5 @@
package ch.zhaw.gartenverwaltung.backgroundtasks.weather;
/**
* Enum of possible Weather events
*/
public enum SevereWeather {
FROST,SNOW,HAIL,NO_SEVERE_WEATHER,RAIN
}

View File

@ -9,18 +9,18 @@ import ch.zhaw.gartenverwaltung.types.*;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
/**
* The WeatherGardenTaskPlanner creates Tasks based on weather events and the rain amount from the last days
*
*/
public class WeatherGradenTaskPlanner {
private final TaskList taskList;
private final PlantList plantList;
private final CropList cropList;
WeatherService weatherService;
private final LocalDate dateSevereWeather = LocalDate.now();
private final LocalDate dateSevereWeather = LocalDate.of(2022,12,15);
public WeatherGradenTaskPlanner(TaskList taskList, PlantList plantList, CropList cropList) {
this.taskList = taskList;
@ -42,19 +42,13 @@ public class WeatherGradenTaskPlanner {
private void getSevereWeatherEvents() throws IOException {
SevereWeather actualWeather = weatherService.causeSevereWeather(1);
List<Crop> actualCrops = cropList.getCrops();
for (Crop crop : actualCrops) {
List<Task> actualCropTasks = taskList.getTaskForCrop(crop.getCropId().orElse(-1L));
if (SevereWeather.HAIL.equals(actualWeather)) {
createPreHailTask(crop, actualCropTasks);
} else if (SevereWeather.FROST.equals(actualWeather)) {
createPreFrostTask(crop, actualCropTasks);
} else if (SevereWeather.SNOW.equals(actualWeather)) {
createPreSnowTask(crop, actualCropTasks);
}
if (SevereWeather.HAIL.equals(actualWeather)) {
//ToDo creates hail task all 3 seconds, pls fix
//createPreHailTask();
} else if (SevereWeather.FROST.equals(actualWeather)) {
createPreFrostTask();
} else if (SevereWeather.SNOW.equals(actualWeather)) {
createPreSnowTask();
}
}
@ -64,69 +58,38 @@ public class WeatherGradenTaskPlanner {
}
/**
* Method to create a PreHailTask and saves it in the tasklist
* Method to create a PreHailTask
* @throws IOException If the database cannot be accessed
*/
private void createPreHailTask(Crop crop, List<Task> actualTasksForCrop) throws IOException {
private void createPreHailTask() throws IOException {
Task preHailTask = new Task("Hail",
"During a summer Thunderstorm it could hail heavily. THe Hail could damage the crops. To prevent damage cover the plants with a strong tarpaulin",
dateSevereWeather,dateSevereWeather.plusDays(1L),crop.getCropId().orElse(-1L));
"During a summer Thunderstorm it could hail heavily. THe Hail could damage the crops. To prevent damage cover the plants with a strong tarpaulin",
dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L));
taskList.saveTask(preHailTask);
List<Task> hailTasks = actualTasksForCrop.stream().filter(task -> task.getName().equals("Hail")).toList();
if(isNoSevereWeatherTaskAtDate(preHailTask, hailTasks) && hailTasks.isEmpty()){
taskList.saveTask(preHailTask);
}
}
/**
* Method to create a PreFrosttask and saves it in the tasklist
* Method to create a PreFrosttask
* @throws IOException If the database cannot be accessed
*/
private void createPreFrostTask(Crop crop, List<Task> actualTasksForCrop) throws IOException {
Task preFrostTask = new Task("Frost",
"The temperatur falls below zero degrees, cover especially the root with wool",
dateSevereWeather,dateSevereWeather.plusDays(1L),crop.getCropId().orElse(-1L));
List<Task> frostTasks = actualTasksForCrop.stream().filter(task -> task.getName().equals("Frost")).toList();
if(isNoSevereWeatherTaskAtDate(preFrostTask, frostTasks) && frostTasks.isEmpty()){
taskList.saveTask(preFrostTask);
}
private void createPreFrostTask() throws IOException {
Task preFrostTask = new Task("Frost",
"The temperatur falls below zero degrees, cover especially the root with wool",
dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L));
taskList.saveTask(preFrostTask);
}
/**
* Method to create a PreSnowTask and saves it in the tasklist
* Method to create a PreSnowTask
* @throws IOException If the database cannot be accessed
*/
private void createPreSnowTask(Crop crop, List<Task> actualTasksForCrop) throws IOException {
private void createPreSnowTask() throws IOException {
Task preSnowTask = new Task("Snow",
"The weather brings little snowfall. Cover your crops",
dateSevereWeather, dateSevereWeather.plusDays(1L), crop.getCropId().orElse(-1L));
List<Task> snowTasklist = actualTasksForCrop.stream().filter(task -> task.getName().equals("Snow")).toList();
if(isNoSevereWeatherTaskAtDate(preSnowTask, snowTasklist) && snowTasklist.isEmpty()){
taskList.saveTask(preSnowTask);
}
}
/**
* Method to create a PreSnowTask and saves it in the tasklist
* @param preSevereWeatherTask the Task which would be added if there is not already
* the same Type of severe weather task
* @param severeWeatherTasks List of severe weather tasks from e specific severe weather
* @return true If there is not already a severe weather task of the same type of preSevereWeatherTask
* task at the date of the preSevereWeatherTask
*/
private boolean isNoSevereWeatherTaskAtDate(Task preSevereWeatherTask, List<Task> severeWeatherTasks) {
List<Task> severeWeatherTasksAtDate = new ArrayList<>();
for (Task task : severeWeatherTasks) {
if (task.getStartDate() == preSevereWeatherTask.getStartDate()) {
severeWeatherTasksAtDate.add(task);
}
}
return severeWeatherTasksAtDate.isEmpty();
"The weather brings little snowfall. Cover your crops",
dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L));
taskList.saveTask(preSnowTask);
}
/**
@ -151,6 +114,9 @@ public class WeatherGradenTaskPlanner {
/**
* Method to set next execution date of the water plant tasks
* @param cropTaskList List with tasks from crops
* @throws IOException If the database cannot be accessed
* @throws HardinessZoneNotSetException If the hardiness zone is not available
* @throws PlantNotFoundException if the plant is not available for the watering task
*/
private void adjustNextExecutionOfWateringTasks(List<Task> cropTaskList){
for(Task task : cropTaskList){

View File

@ -1,6 +1,7 @@
package ch.zhaw.gartenverwaltung.backgroundtasks.weather;
/**
* The WeatherService is a class to cause weather events for the WeatherGardenTaskPlanner
*
*/
public class WeatherService {
private static final int NO_RAIN = 0;
@ -8,11 +9,6 @@ public class WeatherService {
private static final int RAIN = 25;
private static final int HEAVY_RAIN = 50;
/**
* Method to simmulate a Weather Service for testing
* @param randomWeather random int. Range: 1-3
* @return the selected SevereWeather
*/
public SevereWeather causeSevereWeather(int randomWeather) {
return switch (randomWeather) {
case 1 -> SevereWeather.HAIL;
@ -23,11 +19,6 @@ public class WeatherService {
}
/**
* Method to simulate a Weather Service for testing
* @param randomRainAmount random int. Range: 1-4
* @return the selected rain amount
*/
public int causeRainAmount(int randomRainAmount) {
return switch (randomRainAmount) {
case 1 -> NO_RAIN;

View File

@ -1,6 +1,5 @@
package ch.zhaw.gartenverwaltung.bootstrap;
import ch.zhaw.gartenverwaltung.CropDetailController;
import ch.zhaw.gartenverwaltung.Main;
import ch.zhaw.gartenverwaltung.io.*;
import ch.zhaw.gartenverwaltung.models.Garden;
@ -18,15 +17,12 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Class responsible for bootstrapping the application wide dependencies
* and injecting them into JavaFX Controllers.
*/
public class AppLoader {
private static final Logger LOG = Logger.getLogger(CropDetailController.class.getName());
/**
* Caching the panes
*/
@ -150,17 +146,12 @@ public class AppLoader {
try {
afterInjectMethod.invoke(controller);
} catch (IllegalAccessException | InvocationTargetException e) {
LOG.log(Level.SEVERE, "Could not invoke afterInjectMethod", e.getCause());
// TODO: Log
e.printStackTrace();
}
});
}
/**
* Method to get any AppDependency
* @param type Class of Dependency
* @return the App dependency
*/
public Object getAppDependency(Class<?> type) {
return dependencies.get(type.getSimpleName());
}

View File

@ -1,8 +1,5 @@
package ch.zhaw.gartenverwaltung.io;
/**
* Exceptionm which is thrown if Hardiness zone is not set in plant list.
*/
public class HardinessZoneNotSetException extends Exception {
public HardinessZoneNotSetException() {
super("HardinessZone must be set to retrieve plants!");

View File

@ -2,9 +2,6 @@ package ch.zhaw.gartenverwaltung.io;
import java.io.IOException;
/**
* Excption which is thrown if a JSON file has a invalid File format.
*/
class InvalidJsonException extends IOException {
public InvalidJsonException(String reason) {
super(reason);

View File

@ -50,6 +50,8 @@ public class Garden {
*/
public void plantAsCrop(Plant plant, LocalDate plantingDate) throws IOException, HardinessZoneNotSetException, PlantNotFoundException {
Crop crop = new Crop(plant.id(), plantingDate);
//TODO Add Area to Plant
//crop.withArea(0);
cropList.saveCrop(crop);
gardenSchedule.planTasksForCrop(crop);
plantedCrops.clear();

View File

@ -166,12 +166,14 @@ public class GardenSchedule {
dayTaskList.add(new ArrayList<>());
final int finalI = i;
weekTasks.forEach(task -> {
if(task.getNextExecution() != null) {
if (task.getNextExecution() == null) {
task.isDone();
} else {
LocalDate checkDate = task.getNextExecution();
do {
if (date.equals(task.getNextExecution()) || (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN)))) {
if (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN))) {
dayTaskList.get(finalI).add(task);
break;
}
checkDate = checkDate.plusDays(task.getInterval().orElse(0));
} while (!(task.getInterval().orElse(0) == 0) && checkDate.isBefore(LocalDate.now().plusDays(listLength)));

View File

@ -1,6 +1,5 @@
package ch.zhaw.gartenverwaltung.models;
import ch.zhaw.gartenverwaltung.Settings;
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
import ch.zhaw.gartenverwaltung.io.PlantList;
import ch.zhaw.gartenverwaltung.types.GrowthPhaseType;
@ -17,6 +16,7 @@ import java.util.stream.Collectors;
public class PlantListModel {
private final PlantList plantList;
private HardinessZone currentZone;
/**
* Comparators to create sorted Plant List
@ -33,15 +33,15 @@ public class PlantListModel {
}
private void setDefaultZone() {
Settings.getInstance().setCurrentHardinessZone(null);
currentZone = HardinessZone.ZONE_8A; // TODO: get Default Zone from Settings
}
public void setCurrentZone(HardinessZone currentZone) {
Settings.getInstance().setCurrentHardinessZone(currentZone);
this.currentZone = currentZone;
}
public HardinessZone getCurrentZone() {
return Settings.getInstance().getCurrentHardinessZone();
return currentZone;
}
/**

View File

@ -1,8 +1,5 @@
package ch.zhaw.gartenverwaltung.models;
/**
* Exception which is thrown if there is no plant in plant Database with the given id.
*/
public class PlantNotFoundException extends Exception {
public PlantNotFoundException() {
super("The selected Plant was not found in Database!");

View File

@ -40,6 +40,7 @@ public class Crop {
public Optional<Long> getCropId() {
return Optional.ofNullable(cropId);
}
public long getPlantId() { return plantId; }
public LocalDate getStartDate() { return startDate; }
public double getArea() { return area; }

View File

@ -68,7 +68,7 @@ public record Plant(
return growthPhase.group();
}
}
return 0;
return 0; // TODO implement
}
/**

View File

@ -1,7 +1,5 @@
package ch.zhaw.gartenverwaltung.types;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.time.LocalDate;
import java.util.Optional;
@ -57,13 +55,11 @@ public class Task {
* @param startDate The start date of the task
* @param endDate The maximum date on which the task should be executed
*/
public Task(String name, String description, LocalDate startDate, LocalDate endDate, long cropId) {
public Task(String name, String description, LocalDate startDate, LocalDate endDate) {
this.name = name;
this.description = description;
this.startDate = startDate;
nextExecution = startDate;
this.endDate = endDate;
this.cropId = cropId;
}
/**
@ -108,7 +104,7 @@ public class Task {
* @return Whether the Task is within the given range
*/
public boolean isInTimePeriod(LocalDate searchStartDate, LocalDate searchEndDate) {
return (endDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate)) || ((nextExecution != null && nextExecution.isBefore(searchEndDate.plusDays(1)) && nextExecution.isAfter(searchStartDate.minusDays(1))));
return endDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate) || (nextExecution != null && nextExecution.isBefore(searchEndDate) && nextExecution.isAfter(searchStartDate));
}
/**
@ -124,7 +120,6 @@ public class Task {
}
}
@JsonIgnore
public boolean isDone(){
return nextExecution == null;
}

View File

@ -4,9 +4,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.LocalDate;
/**
* Class which represents a Task if the start and enddate is not known yet.
*/
public class TaskTemplate {
@JsonProperty
private final String name;

View File

@ -19,19 +19,19 @@
<content>
<VBox fx:id="cropDetailVBox" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="781.0" prefWidth="897.0" spacing="5.0">
<children>
<Button styleClass="button-class" mnemonicParsing="false" onAction="#goBack" prefHeight="25.0" prefWidth="91.0" text="Go Back">
<Button mnemonicParsing="false" onAction="#goBack" prefHeight="25.0" prefWidth="91.0" text="Go Back">
<VBox.margin>
<Insets bottom="10.0" />
</VBox.margin>
</Button>
<Label styleClass="page-title" fx:id="cropName_label" text="Label">
<Label fx:id="cropName_label" text="Label">
<VBox.margin>
<Insets bottom="10.0" />
</VBox.margin>
</Label>
<HBox maxHeight="1.7976931348623157E308" prefHeight="268.0" prefWidth="855.0" spacing="10.0" VBox.vgrow="NEVER">
<children>
<GridPane styleClass="custom-container" maxWidth="1.7976931348623157E308" prefHeight="231.0" prefWidth="555.0" HBox.hgrow="ALWAYS">
<GridPane maxWidth="1.7976931348623157E308" prefHeight="231.0" prefWidth="555.0" HBox.hgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" maxWidth="284.0" minWidth="10.0" prefWidth="97.33334350585938" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="488.99999237060547" minWidth="10.0" prefWidth="481.9999898274739" />
@ -72,9 +72,6 @@
</GridPane.margin>
</Label>
</children>
<padding>
<Insets bottom="5.0" left="10.0" right="5.0" top="5.0" />
</padding>
</GridPane>
<ImageView fx:id="imageView" fitHeight="250.0" fitWidth="250.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER" />
</children>
@ -89,7 +86,7 @@
<Insets bottom="10.0" />
</VBox.margin>
</ListView>
<Button styleClass="button-class" fx:id="addTask_button" mnemonicParsing="false" onAction="#addTask" prefHeight="25.0" prefWidth="120.0" VBox.vgrow="NEVER" text="Add Task">
<Button fx:id="addTask_button" mnemonicParsing="false" onAction="#addTask" prefHeight="25.0" prefWidth="45.0" VBox.vgrow="NEVER">
<VBox.margin>
<Insets />
</VBox.margin>
@ -112,7 +109,7 @@
<Insets right="10.0" />
</HBox.margin>
</Label>
<Button styleClass="button-class" fx:id="area_button" mnemonicParsing="false" onAction="#setArea" prefHeight="25.0" prefWidth="116.0" text="Set Area" />
<Button fx:id="area_button" mnemonicParsing="false" onAction="#setArea" prefHeight="25.0" prefWidth="116.0" text="Set Area" />
</children>
<VBox.margin>
<Insets />

View File

@ -18,7 +18,7 @@
<content>
<VBox fx:id="homeVBox" prefHeight="1047.0" prefWidth="1019.0" spacing="10.0">
<children>
<Label styleClass="page-title" text="Garden Management">
<Label text="Garden Management">
<font>
<Font size="34.0" />
</font>
@ -34,7 +34,7 @@
<Insets />
</VBox.margin>
</Label>
<VBox styleClass="vbox" prefHeight="200.0" prefWidth="100.0" spacing="5.0">
<VBox prefHeight="200.0" prefWidth="100.0" spacing="5.0" style="-fx-background-color: white; -fx-border-color: black;">
<children>
<Label text="Base Functionalities:">
<font>
@ -79,7 +79,7 @@
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</VBox>
<VBox styleClass="vbox" prefHeight="200.0" prefWidth="100.0" spacing="5.0">
<VBox prefHeight="200.0" prefWidth="100.0" spacing="5.0" style="-fx-background-color: white; -fx-border-color: black;">
<children>
<Label text="Advanced Functionalities:">
<font>
@ -114,7 +114,7 @@
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</VBox>
<VBox styleClass="vbox" prefHeight="200.0" prefWidth="100.0" spacing="5.0">
<VBox prefHeight="200.0" prefWidth="100.0" spacing="5.0" style="-fx-background-color: white; -fx-border-color: black;">
<children>
<Label text="Weather Forcast:">
<font>
@ -139,7 +139,7 @@
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</VBox>
<VBox styleClass="vbox" prefHeight="200.0" prefWidth="100.0" spacing="15.0">
<VBox prefHeight="200.0" prefWidth="100.0" spacing="15.0" style="-fx-background-color: white; -fx-border-color: black;">
<children>
<Label text="Created by:">
<font>

View File

@ -12,7 +12,7 @@
<children>
<VBox layoutY="49.0" prefHeight="655.0" prefWidth="1175.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label styleClass="page-title" text="My Garden">
<Label text="My Garden">
<font>
<Font name="System Bold" size="28.0" />
</font>
@ -21,7 +21,7 @@
</VBox.margin>
</Label>
<ListView fx:id="myGarden_listView" maxHeight="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" />
<Button styleClass="button-class" fx:id="addPlant_button" mnemonicParsing="false" onAction="#addPlant" prefHeight="45.0" prefWidth="155.0" text="Add new Plant">
<Button fx:id="addPlant_button" mnemonicParsing="false" onAction="#addPlant" prefHeight="45.0" prefWidth="155.0" text="Add new Plant">
<VBox.margin>
<Insets />
</VBox.margin>

View File

@ -13,7 +13,7 @@
<children>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label styleClass="page-title" text="MySchedule" VBox.vgrow="NEVER">
<Label text="MySchedule" VBox.vgrow="NEVER">
<font>
<Font size="24.0" />
</font>
@ -33,7 +33,7 @@
<Insets />
</VBox.margin>
</ListView>
<VBox styleClass="custom-container" prefHeight="131.0" prefWidth="603.0" spacing="5.0" VBox.vgrow="NEVER">
<VBox prefHeight="131.0" prefWidth="603.0" spacing="5.0" style="-fx-background-color: white; -fx-border-color: black;" VBox.vgrow="NEVER">
<children>
<Label alignment="TOP_LEFT" maxWidth="1.7976931348623157E308" prefHeight="17.0" prefWidth="558.0" text="Importants Information:" wrapText="true" VBox.vgrow="NEVER">
<font>

View File

@ -17,7 +17,7 @@
<children>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label styleClass="page-title" prefHeight="45.0" prefWidth="903.0" text="Plants" VBox.vgrow="NEVER">
<Label prefHeight="45.0" prefWidth="903.0" text="Plants" VBox.vgrow="NEVER">
<font>
<Font name="System Bold" size="30.0" />
</font>
@ -32,14 +32,14 @@
<HBox alignment="CENTER_LEFT" minHeight="300.0" prefHeight="480.0" prefWidth="881.0" spacing="10.0" VBox.vgrow="ALWAYS">
<children>
<ListView fx:id="list_plants" maxWidth="1.7976931348623157E308" prefHeight="497.0" prefWidth="400.0" HBox.hgrow="ALWAYS" />
<Pane styleClass="custom-container" maxHeight="1.7976931348623157E308" maxWidth="300.0" minWidth="300.0" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="NEVER">
<Pane maxHeight="1.7976931348623157E308" maxWidth="300.0" minWidth="300.0" prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: white; -fx-border-color: black;" HBox.hgrow="NEVER">
<children>
<ImageView fx:id="img_plant" fitWidth="300" pickOnBounds="true" preserveRatio="true" />
</children>
</Pane>
</children>
</HBox>
<VBox styleClass="vbox" maxHeight="1.7976931348623157E308" prefHeight="237.0" prefWidth="879.0" VBox.vgrow="ALWAYS">
<VBox maxHeight="1.7976931348623157E308" prefHeight="237.0" prefWidth="879.0" style="-fx-background-color: white; -fx-border-color: black;" VBox.vgrow="ALWAYS">
<children>
<Label maxHeight="1.7976931348623157E308" prefHeight="33.0" prefWidth="919.0" text="Plant Information:" VBox.vgrow="NEVER">
<font>
@ -51,7 +51,7 @@
<Insets bottom="10.0" top="10.0" />
</padding>
</Label>
<Button styleClass="button-class" fx:id="selectSowDay_button" alignment="CENTER" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#selectSowDate" prefHeight="38.0" prefWidth="917.0" text="Select Harvest/Sow Day" VBox.vgrow="NEVER" />
<Button fx:id="selectSowDay_button" alignment="CENTER" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#selectSowDate" prefHeight="38.0" prefWidth="917.0" text="Select Harvest/Sow Day" VBox.vgrow="NEVER" />
</children>
<VBox.margin>
<Insets />
@ -67,7 +67,7 @@
<Insets />
</HBox.margin>
</AnchorPane>
<AnchorPane styleClass="custom-container" maxWidth="300.0" minHeight="0.0" minWidth="300.0" prefHeight="160.0" prefWidth="100.0">
<AnchorPane maxWidth="300.0" minHeight="0.0" minWidth="300.0" prefHeight="160.0" prefWidth="100.0" style="-fx-border-color: black; -fx-background-color: white;">
<children>
<VBox layoutX="38.0" layoutY="100.0" prefHeight="850.6666666666666" prefWidth="316.6666666666667" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
@ -78,7 +78,7 @@
</Label>
<TitledPane animated="false" text="Seasons">
<content>
<AnchorPane styleClass="custom-container" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VBox fx:id="seasons" layoutX="37.0" layoutY="-19.0" prefHeight="180.66666666666666" prefWidth="310.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
@ -87,7 +87,7 @@
</TitledPane>
<TitledPane animated="false" text="Climate Zones">
<content>
<AnchorPane styleClass="custom-container" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VBox fx:id="climate_zones" layoutX="36.0" layoutY="-19.0" prefHeight="180.66666666666666" prefWidth="310.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>

View File

@ -22,9 +22,9 @@
<Separator prefWidth="50.0" visible="false" HBox.hgrow="ALWAYS" />
<ButtonBar prefHeight="40.0" prefWidth="200.0">
<buttons>
<Button cancelButton="true" contentDisplay="CENTER" graphicTextGap="5.0" mnemonicParsing="false" onAction="#closeTutorial" styleClass="button-class" text="Close" />
<Button fx:id="previousPageButton" mnemonicParsing="false" onAction="#viewPreviousPage" styleClass="button-class" text="Previous" />
<Button fx:id="nextPageButton" defaultButton="true" mnemonicParsing="false" onAction="#viewNextPage" styleClass="button-class" text="Next" />
<Button cancelButton="true" contentDisplay="CENTER" graphicTextGap="5.0" mnemonicParsing="false" text="Close" onAction="#closeTutorial"/>
<Button fx:id="previousPageButton" mnemonicParsing="false" text="Previous" onAction="#viewPreviousPage"/>
<Button fx:id="nextPageButton" defaultButton="true" mnemonicParsing="false" text="Next" onAction="#viewNextPage" />
</buttons>
</ButtonBar>
</children>
@ -38,7 +38,7 @@
<children>
<VBox layoutX="30.0" layoutY="26.0" opacity="0.0" prefHeight="200.0" prefWidth="100.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Adding Crops">
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Managing Your Crops">
<font>
<Font size="24.0" />
</font>
@ -75,7 +75,7 @@
</children>
</TextFlow>
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
<ImageView fx:id="imgSelectDate" fitHeight="150.0" fitWidth="400.0" pickOnBounds="true" preserveRatio="true" />
<ImageView fx:id="imgSelectDate" fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
</children>
</HBox>
</children>
@ -83,50 +83,7 @@
<Insets />
</opaqueInsets>
</VBox>
<VBox layoutX="30.0" layoutY="30.0" prefHeight="200.0" prefWidth="100.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Managing Your Crops">
<font>
<Font size="24.0" />
</font>
</Text>
<Separator prefWidth="200.0">
<VBox.margin>
<Insets bottom="15.0" top="10.0" />
</VBox.margin>
</Separator>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Once you've added a crop to your garden, it will be displayed in the &quot;My Garden&quot; tab.">
<VBox.margin>
<Insets bottom="20.0" />
</VBox.margin>
</Text>
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<TextFlow lineSpacing="4.0" prefHeight="200.0" prefWidth="500.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="On the right hand side of the listing, you'll see two buttons.&#10;&#10;Button with the &quot;trash can&quot; icon lets you remove a crop from your garden plan. This will also delete all associated tasks.&#10;&#10;The button on the left will display the details of the crop in a new window." />
</children>
</TextFlow>
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
<ImageView fitHeight="70.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true" fx:id="imgDetailDeleteButtons"/>
</children></HBox>
<HBox layoutX="10.0" layoutY="105.0" prefHeight="100.0" prefWidth="200.0">
<children>
<TextFlow lineSpacing="4.0" prefHeight="200.0" prefWidth="500.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Here, you can also add your own custom tasks, by clicking the &quot;Add Task&quot; button.&#10;In the subsequently shown dialog, you can enter the corresponding details.&#10;&#10;Note: If you want to make a task recurring, you need to set both an interval (in days) AND an end date, so the task won't repeat for all eternity." />
</children>
</TextFlow>
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
<ImageView fitHeight="150.0" fitWidth="400.0" pickOnBounds="true" preserveRatio="true" fx:id="imgAddTaskButton"/>
</children>
</HBox>
</children>
<opaqueInsets>
<Insets />
</opaqueInsets>
</VBox>
<VBox opacity="0.0" prefHeight="200.0" prefWidth="100.0">
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Managing Your Tasks">
<font>
@ -154,9 +111,19 @@
</HBox.margin>
</TextFlow>
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
<ImageView fx:id="imgTaskList" fitHeight="200.0" fitWidth="400.0" pickOnBounds="true" preserveRatio="true" />
<ImageView fx:id="imgTaskList" fitHeight="98.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
</children>
</HBox>
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<TextFlow lineSpacing="4.0" prefHeight="200.0" prefWidth="500.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="You can also add your own custom tasks, by clicking the &quot;Add Task&quot; button.&#10;In the subsequently shown dialog, you can enter the corresponding details.&#10;&#10;Note: If you want to make a task recurring, you need to set both an interval (in days) AND an end date, so the task won't repeat for all eternity." />
</children>
</TextFlow>
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
</children></HBox>
</children>
<opaqueInsets>
<Insets />

View File

@ -1,86 +0,0 @@
.myDialog *.header-panel,
.myDialog *.header-panel .label {
-fx-background-color: #D3FFB5;
-fx-font-weight: bold;
}
.myDialog {
-fx-background-color: #EAFFE2;
-fx-border-color: black;
}
.myDialog .button {
-fx-border-color: darkgreen;
-fx-border-radius: 4;
-fx-border-width: 1.5;
-fx-background-color: #D1FFB7;
-fx-font-weight: bold;
-fx-font-size: 13
}
.myDialog .check-box .box {
-fx-background-color: #D3FFB5;
-fx-border-color:grey;
-fx-border-radius: 3;
}
.myDialog .combo-box .list-cell
{
-fx-background-color: #D1FFB7;
-fx-text-fill: -fx-text-base-color;
}
.myDialog .combo-box-popup .list-view
{
-fx-background-color: darkgreen, darkgreen;
-fx-background-insets: 0, 1;
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 8, 0.0 , 0 , 0 );
}
.myDialog .combo-box-popup .list-view .list-cell
{
-fx-padding: 4 0 4 5;
/* No alternate highlighting */
-fx-background-color: #EAFFE2;
}
.myDialog .combo-box-popup .list-view .list-cell:filled:selected, .combo-box-popup .list-view .list-cell:filled:selected:hover
{
-fx-background: -fx-accent;
-fx-text-fill: black;
-fx-background-color: #D1FFB7;
}
.myDialog .combo-box-popup .list-view .list-cell:filled:hover
{
-fx-text-fill: black;
-fx-background-color: #54B91C;
}
.myDialog .combo-box-base {
-fx-border-color: grey;
-fx-background-color: #D1FFB7;
}
.myDialog .combo-box-base:hover
{
-fx-color: #54B91C;
}
.myDialog .radio-button .radio {
-fx-background-color: #D3FFB5;
-fx-border-color:grey;
-fx-border-radius: 25;
}
.myDialog .date-picker .button {
-fx-border-color: none;
-fx-background-color: none;
}

View File

@ -1,19 +1,10 @@
.button-class {
-fx-border-color: darkgreen;
-fx-border-radius: 4;
-fx-border-width: 1.5;
-fx-background-color: #D1FFB7;
-fx-font-weight: bold;
-fx-font-size: 13
}
#home_button, #myGarden_button,
#mySchedule_button, #settings_button,
#tutorial_button, #menu_pane {
-fx-text-fill: white;
-fx-background-color: rgb(0,128,0);
-fx-border-color: rgb(0,128,0);
-fx-border-radius: 0;
}
#menubar {
@ -22,64 +13,13 @@
#home_button:hover, #myGarden_button:hover,
#mySchedule_button:hover, #settings_button:hover,
#tutorial_button:hover {
#tutorial_button:hover,
#home_button:focused, #myGarden_button:focused,
#mySchedule_button:focused, #settings_button:focused,
#tutorial_button:focused{
-fx-background-color: darkgreen;
}
.root, .scroll-pane, #homeVBox, #cropDetailVBox {
-fx-background-color: #F3FFEC;
}
.list-view {
-fx-border-color: black;
-fx-background-color: #EAFFE2;
}
.list-cell:even:filled:selected:focused .label,
.list-cell:even:filled:selected .label,
.list-cell:even {
-fx-background-color: #EAFFE2;
-fx-text-fill: black;
}
.list-cell:odd:filled:selected:focused .label,
.list-cell:odd:filled:selected .label,
.list-cell:odd {
-fx-background-color: #D3FFB5;
-fx-text-fill: black;
}
#list_plants .list-cell:even:filled:selected:focused,
#list_plants .list-cell:even:filled:selected,
#list_plants .list-cell:odd:filled:selected:focused,
#list_plants .list-cell:odd:filled:selected,
#scheduledPlants_listview .list-cell:even:filled:selected:focused,
#scheduledPlants_listview .list-cell:even:filled:selected,
#scheduledPlants_listview .list-cell:odd:filled:selected:focused,
#scheduledPlants_listview .list-cell:odd:filled:selected{
-fx-background-color: #7CD14B;
-fx-text-fill: white;
-fx-font-weight: bold;
}
.vbox, .custom-container {
-fx-background-color: #EAFFE2;
-fx-border-color: black;
}
.titled-pane > .title {
-fx-background-color: #D3FFB5;
-fx-border-color: black;
}
.page-title {
-fx-font-size: 20;
-fx-font-weight: bold;
}
.radio-button .radio {
-fx-background-color: #D3FFB5;
-fx-border-color:grey;
-fx-border-radius: 25;
}
-fx-background-color: #e6ffe6;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

View File

@ -1,91 +0,0 @@
package ch.zhaw.gartenverwaltung.backgroundtasks.weather;
import ch.zhaw.gartenverwaltung.io.*;
import ch.zhaw.gartenverwaltung.models.PlantNotFoundException;
import ch.zhaw.gartenverwaltung.types.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDate;
import java.time.MonthDay;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class WeatherGardenTaskPlannerTest {
private final URL testFile = JsonCropListTest.class.getResource("test-taskdb.json");
Plant examplePlantOnion;
Crop exampleCropOnion;
Task exampleTask;
Task exampleWeatherTask;
List<Crop> cropList;
List<Plant> plantList;
TaskList taskList;
@BeforeEach
void setUp() {
examplePlantOnion = new Plant(
20,
"summertime onion",
"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.",
null,
"15,30,2",
0,
"sandy to loamy, loose soil, free of stones",
new ArrayList<>(),
new WateringCycle(15, 3, null),
List.of(new GrowthPhase(MonthDay.of(6, 4), MonthDay.of(12, 4), 0, GrowthPhaseType.HARVEST, HardinessZone.ZONE_8A, new ArrayList<>()),
new GrowthPhase(MonthDay.of(4, 3), MonthDay.of(12, 4), 0, GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>()),
new GrowthPhase(MonthDay.of(8, 5), MonthDay.of(12, 4), 0, GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>()),
new GrowthPhase(MonthDay.of(2, 8), MonthDay.of(12, 4), 0, GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>()),
new GrowthPhase(MonthDay.of(10, 2), MonthDay.of(12, 4), 0, GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>())));
exampleCropOnion = new Crop(examplePlantOnion.id(), LocalDate.of(2022, 12, 5))
.withId(3L);
exampleTask = new Task("water plant","water the plant until the ground is wet enough",LocalDate.now(), LocalDate.now().plusDays(2L),3L);
exampleTask.setNextExecution(LocalDate.now().plusDays(1L));
exampleWeatherTask = new Task("Hail",
"During a summer Thunderstorm it could hail heavily. THe Hail could damage the crops. To prevent damage cover the plants with a strong tarpaulin",
LocalDate.now(),LocalDate.now().plusDays(1L),3L);
taskList = new JsonTaskList(testFile);
plantList = new ArrayList<>();
plantList.add(examplePlantOnion);
cropList = new ArrayList<>();
cropList.add(exampleCropOnion);
}
CropList mockCropList(List<Crop> cropList) throws IOException {
CropList croplist = mock(CropList.class);
when(croplist.getCrops()).thenReturn(cropList);
when(croplist.getCropById(3)).thenReturn(java.util.Optional.ofNullable(exampleCropOnion));
return croplist;
}
PlantList mockPlantDatabase(List<Plant> plantList) throws HardinessZoneNotSetException, IOException {
PlantList plantDatabase = mock(JsonPlantList.class);
when(plantDatabase.getPlantList(HardinessZone.ZONE_8A)).thenReturn(plantList);
when(plantDatabase.getPlantById(HardinessZone.ZONE_8A,20)).thenReturn(Optional.of(plantList.get(0)));
return plantDatabase;
}
@Test
void refreshtasks() throws HardinessZoneNotSetException, IOException, PlantNotFoundException {
WeatherGradenTaskPlanner weatherGradenTaskPlanner = new WeatherGradenTaskPlanner(taskList, mockPlantDatabase(plantList), mockCropList(cropList));
taskList.saveTask(exampleTask);
weatherGradenTaskPlanner.refreshTasks();
assertEquals(exampleTask.getName(),taskList.getTaskList(LocalDate.now(),LocalDate.now().plusDays(7)).get(0).getName());
assertEquals(LocalDate.now().plusDays(2L),taskList.getTaskList(LocalDate.now(),LocalDate.now().plusDays(7)).get(0).getNextExecution());
assertEquals(exampleWeatherTask.getName(),taskList.getTaskList(LocalDate.now(),LocalDate.now().plusDays(7)).get(1).getName());
assertEquals(exampleWeatherTask.getStartDate(),taskList.getTaskList(LocalDate.now(),LocalDate.now().plusDays(7)).get(1).getStartDate());
}
}

View File

@ -1,12 +1,7 @@
package ch.zhaw.gartenverwaltung.io;
import ch.zhaw.gartenverwaltung.models.GardenSchedule;
import ch.zhaw.gartenverwaltung.models.PlantNotFoundException;
import ch.zhaw.gartenverwaltung.types.Crop;
import ch.zhaw.gartenverwaltung.types.Task;
import javafx.application.Platform;
import org.junit.jupiter.api.*;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
@ -18,7 +13,6 @@ import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@ -33,22 +27,6 @@ public class JsonTaskListTest {
private final URL dbDataSource = this.getClass().getResource("test-taskdb.json");
private final URL testFile = this.getClass().getResource("template-taskdb.json");
@BeforeAll
static void setUpAll() {
try{
Platform.startup(()->{});
}catch (IllegalStateException ise){
//ignore double launches
}
}
@AfterAll
static void tearDownAll() {
//Dont do: Platform.exit();
}
@BeforeEach
void connectToDb() throws URISyntaxException, IOException {
assertNotNull(testFile);
@ -57,10 +35,6 @@ public class JsonTaskListTest {
testDatabase = new JsonTaskList(dbDataSource);
}
private void reloadDb() {
testDatabase = new JsonTaskList(dbDataSource);
}
@Test
@DisplayName("Check if results are retrieved completely")
void getTasks() {
@ -73,8 +47,7 @@ public class JsonTaskListTest {
throw new RuntimeException(e);
}
List<Long> ids = taskList.stream().map(t -> t.getId().orElse(0L)).toList();
Assertions.assertEquals(Arrays.asList(1L, 2L, 5L), ids);
Assertions.assertEquals(3, taskList.size());
}
@ -92,8 +65,7 @@ public class JsonTaskListTest {
throw new RuntimeException(e);
}
List<Long> ids = taskList.stream().map(t -> t.getId().orElse(0L)).toList();
Assertions.assertEquals(Arrays.asList(1L, 2L, 5L, 9L), ids);
Assertions.assertEquals(4, taskList.size());
} catch (IOException e) {
throw new RuntimeException(e);
@ -111,8 +83,7 @@ public class JsonTaskListTest {
taskList = testDatabase.getTaskList(LocalDate.parse("2022-04-30", formatter),
LocalDate.parse("2022-05-31", formatter));
List<Long> ids = taskList.stream().map(t -> t.getId().orElse(0L)).toList();
Assertions.assertEquals(Arrays.asList(1L, 5L), ids);
Assertions.assertEquals(2, taskList.size());
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -129,8 +100,8 @@ public class JsonTaskListTest {
throw new RuntimeException(e);
}
List<Long> ids = taskList.stream().map(t -> t.getId().orElse(0L)).toList();
Assertions.assertEquals(Arrays.asList(1L, 2L, 3L, 4L, 5L, 6L), ids);
Assertions.assertEquals(6, taskList.size());
}
@ -145,20 +116,10 @@ public class JsonTaskListTest {
}
Assertions.assertEquals(0, taskList.size());
try {
taskList = testDatabase.getTaskForCrop(1);
} catch (IOException e) {
throw new RuntimeException(e);
}
List<Long> ids = (taskList.stream().map( task -> task.getId().orElse(0L)).toList());
Assertions.assertEquals(Arrays.asList(7L, 8L), ids);
}
@Test
void testDefaultConstructor() {
void testDefaultConstructor(){
JsonTaskList db = new JsonTaskList();
try {
assertNotNull(db.getTaskForCrop(0));
@ -177,43 +138,6 @@ public class JsonTaskListTest {
} catch (IOException e) {
throw new RuntimeException(e);
}
ArgumentCaptor<List<Task>> captor = ArgumentCaptor.forClass(List.class);
verify(mockObs, times(1)).onChange(captor.capture());
List<Long> ids = captor.getValue().stream().map(t -> t.getId().orElse(0L)).toList();
Assertions.assertEquals(Arrays.asList(7L, 8L), ids);
}
@Test
@Tag("IntegrationTest")
void testComplete() {
JsonPlantList plantList = new JsonPlantList();
try {
testDatabase.removeTasksForCrop(0);
testDatabase.removeTasksForCrop(1);
} catch (IOException e) {
throw new RuntimeException(e);
}
GardenSchedule gardenSchedule = null;
try {
gardenSchedule = new GardenSchedule(testDatabase, plantList);
} catch (IOException e) {
throw new RuntimeException(e);
}
Crop crop = new Crop(3L, LocalDate.parse("2022-12-01", formatter));
try {
gardenSchedule.planTasksForCrop(crop);
reloadDb();
List<Task> tasks = gardenSchedule.getTaskList();
List<String> tasknames = (tasks.stream().map( task -> task.getName().substring(0,3).toLowerCase()).toList());
Assertions.assertEquals(Arrays.asList("ger","wat","hil","har"), tasknames);
} catch (IOException | PlantNotFoundException | HardinessZoneNotSetException e) {
throw new RuntimeException(e);
}
verify(mockObs, times(1)).onChange(ArgumentMatchers.anyList());
}
}

View File

@ -3,9 +3,6 @@ package ch.zhaw.gartenverwaltung.models;
import ch.zhaw.gartenverwaltung.io.*;
import ch.zhaw.gartenverwaltung.models.GardenSchedule;
import ch.zhaw.gartenverwaltung.types.*;
import javafx.application.Platform;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -32,21 +29,6 @@ class GardenScheduleTest {
List<TaskTemplate> exampleTaskTemplateList;
GardenSchedule model;
@BeforeAll
static void setUpAll() {
try{
Platform.startup(()->{});
}catch (IllegalStateException ise){
//ignore double launches
}
}
@AfterAll
static void tearDownAll() {
//Dont do: Platform.exit();
}
@BeforeEach
void setUp() throws IOException, HardinessZoneNotSetException {
createExampleTaskList();
@ -239,8 +221,5 @@ class GardenScheduleTest {
testTaskList.getTaskList(LocalDate.MIN,LocalDate.MAX).get(0);
}
@Test
void testPlantNotFoundException() throws HardinessZoneNotSetException, IOException {
assertThrowsExactly(PlantNotFoundException.class, () -> { model.planTasksForCrop(new Crop(0, exampleStartDate)); });
}
}

View File

@ -101,7 +101,7 @@ class PlantListModelTest {
@Test
void setCurrentZone() {
checkCurrentZone(HardinessZone.ZONE_8A);
checkCurrentZone(HardinessZone.ZONE_8A); // TODO change to get default zone from config
model.setCurrentZone(HardinessZone.ZONE_1A);
checkCurrentZone(HardinessZone.ZONE_1A);
model.setCurrentZone(HardinessZone.ZONE_8A);

View File

@ -26,8 +26,8 @@
"name" : "fertilize plant",
"description": "The fertilizer has to be mixed with water. Then fertilize the plants soil with the mixture",
"startDate" : "2022-06-01",
"nextExecution": "2022-06-01",
"nextNotification": "2022-06-01",
"nextExecution": "2022-05-01",
"nextNotification": "2022-05-01",
"endDate" : "2022-08-01",
"interval" : 28,
"cropId" : 0
@ -37,8 +37,8 @@
"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",
"nextExecution": "2022-07-01",
"nextNotification": "2022-07-01",
"nextExecution": "2022-05-01",
"nextNotification": "2022-05-01",
"endDate" : "2022-07-01",
"interval" : 0,
"cropId" : 0
@ -59,32 +59,10 @@
"name" : "harvest plant",
"description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ",
"startDate" : "2022-09-01",
"nextExecution": "2022-09-01",
"nextNotification": "2022-09-01",
"nextExecution": "2022-05-01",
"nextNotification": "2022-05-01",
"endDate" : "2022-09-01",
"interval" : 0,
"cropId" : 0
},
{
"id" : 7,
"name" : "sow plant",
"description": "Plant the seeds, crops in de bed.",
"startDate" : "2022-11-01",
"nextExecution": "2022-11-01",
"nextNotification": "2022-11-01",
"endDate" : "2022-11-01",
"interval" : 0,
"cropId" : 1
},
{
"id" : 8,
"name" : "harvest plant",
"description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ",
"startDate" : "2022-12-01",
"nextExecution": "2022-12-01",
"nextNotification": "2022-12-01",
"endDate" : "2022-12-01",
"interval" : 0,
"cropId" : 1
}
]