#22: Setup Ingredient Model
All checks were successful
Quality Check / Qualty Check (push) Successful in 8s

Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
Dominik Säume 2024-05-04 09:26:17 +02:00
parent 60b3d587ea
commit cbecf482b8
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C
2 changed files with 43 additions and 6 deletions

View file

@ -0,0 +1,36 @@
package de.hitec.nhplus.medication;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
public class Ingredient {
private SimpleIntegerProperty id;
private SimpleStringProperty name;
public Ingredient(int id, String name) {
this.id = new SimpleIntegerProperty(id);
this.name = new SimpleStringProperty(name);
}
public int getId() {
return id.get();
}
public SimpleIntegerProperty idProperty() {
return id;
}
public String getName() {
return name.get();
}
public SimpleStringProperty nameProperty() {
return name;
}
public void setName(String name) {
this.name.set(name);
}
}

View file

@ -12,7 +12,7 @@ public class Medication {
private SimpleIntegerProperty id; private SimpleIntegerProperty id;
private final SimpleStringProperty name; private final SimpleStringProperty name;
private final SimpleStringProperty manufacturer; private final SimpleStringProperty manufacturer;
private final SimpleListProperty<String> ingredients; private final SimpleListProperty<Ingredient> ingredients;
private final SimpleStringProperty possibleSideEffects; private final SimpleStringProperty possibleSideEffects;
private final SimpleStringProperty administrationMethod; private final SimpleStringProperty administrationMethod;
private final SimpleIntegerProperty currentStock; private final SimpleIntegerProperty currentStock;
@ -20,7 +20,7 @@ public class Medication {
public Medication( public Medication(
String name, String name,
String manufacturer, String manufacturer,
ObservableList<String> ingredients, ObservableList<Ingredient> ingredients,
String possibleSideEffects, String possibleSideEffects,
String administrationMethod, String administrationMethod,
int currentStock int currentStock
@ -37,7 +37,7 @@ public class Medication {
int id, int id,
String name, String name,
String manufacturer, String manufacturer,
ObservableList<String> ingredients, ObservableList<Ingredient> ingredients,
String possibleSideEffects, String possibleSideEffects,
String administrationMethod, String administrationMethod,
int currentStock int currentStock
@ -83,15 +83,15 @@ public class Medication {
this.manufacturer.set(manufacturer); this.manufacturer.set(manufacturer);
} }
public ObservableList<String> getIngredients() { public ObservableList<Ingredient> getIngredients() {
return ingredients.get(); return ingredients.get();
} }
public SimpleListProperty<String> ingredientsProperty() { public SimpleListProperty<Ingredient> ingredientsProperty() {
return ingredients; return ingredients;
} }
public void setIngredients(ObservableList<String> ingredients) { public void setIngredients(ObservableList<Ingredient> ingredients) {
this.ingredients.set(ingredients); this.ingredients.set(ingredients);
} }
@ -140,6 +140,7 @@ public class Medication {
.add("Manufacturer: " + this.getManufacturer()) .add("Manufacturer: " + this.getManufacturer())
.add("Ingredients: " + this.getIngredients() .add("Ingredients: " + this.getIngredients()
.stream() .stream()
.map(Ingredient::getName)
.collect(Collectors.joining(", ", "[", "]"))) .collect(Collectors.joining(", ", "[", "]")))
.add("Possible Side Effects: " + this.getPossibleSideEffects()) .add("Possible Side Effects: " + this.getPossibleSideEffects())
.add("Administration Method: " + this.getAdministrationMethod()) .add("Administration Method: " + this.getAdministrationMethod())