feat(client/nutrition-model): init modules for shopping list; missing impl but it has interface :)
This commit is contained in:
parent
83910eca72
commit
fe2f9ac1c3
4 changed files with 120 additions and 0 deletions
|
|
@ -21,6 +21,9 @@ import client.scenes.nutrition.NutritionDetailsCtrl;
|
||||||
import client.scenes.nutrition.NutritionViewCtrl;
|
import client.scenes.nutrition.NutritionViewCtrl;
|
||||||
import client.scenes.recipe.IngredientListCtrl;
|
import client.scenes.recipe.IngredientListCtrl;
|
||||||
import client.scenes.recipe.RecipeStepListCtrl;
|
import client.scenes.recipe.RecipeStepListCtrl;
|
||||||
|
import client.service.NonFunctionalShoppingListService;
|
||||||
|
import client.service.ShoppingListService;
|
||||||
|
import client.service.ShoppingListViewModel;
|
||||||
import client.utils.ConfigService;
|
import client.utils.ConfigService;
|
||||||
import client.utils.LocaleManager;
|
import client.utils.LocaleManager;
|
||||||
import client.utils.server.ServerUtils;
|
import client.utils.server.ServerUtils;
|
||||||
|
|
@ -57,6 +60,8 @@ public class MyModule implements Module {
|
||||||
binder.bind(new TypeLiteral<WebSocketDataService<Long, Recipe>>() {}).toInstance(
|
binder.bind(new TypeLiteral<WebSocketDataService<Long, Recipe>>() {}).toInstance(
|
||||||
new WebSocketDataService<>()
|
new WebSocketDataService<>()
|
||||||
);
|
);
|
||||||
|
binder.bind(ShoppingListViewModel.class).toInstance(new ShoppingListViewModel());
|
||||||
|
binder.bind(ShoppingListService.class).to(NonFunctionalShoppingListService.class);
|
||||||
binder.bind(new TypeLiteral<WebSocketDataService<Long, Ingredient>>() {}).toInstance(
|
binder.bind(new TypeLiteral<WebSocketDataService<Long, Ingredient>>() {}).toInstance(
|
||||||
new WebSocketDataService<>()
|
new WebSocketDataService<>()
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package client.service;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import commons.FormalIngredient;
|
||||||
|
import commons.Recipe;
|
||||||
|
import commons.RecipeIngredient;
|
||||||
|
import javafx.util.Pair;
|
||||||
|
import org.apache.commons.lang3.NotImplementedException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class NonFunctionalShoppingListService extends ShoppingListService {
|
||||||
|
@Inject
|
||||||
|
public NonFunctionalShoppingListService(ShoppingListViewModel viewModel) {
|
||||||
|
super(viewModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putIngredient(RecipeIngredient ingredient) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putIngredient(RecipeIngredient ingredient, Recipe recipe) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putIngredient(RecipeIngredient ingredient, String recipeName) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putArbitraryItem(String name) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FormalIngredient purgeIngredient(Long id) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FormalIngredient purgeIngredient(String ingredientName) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Pair<FormalIngredient, Optional<String>>> getItems() {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String makePrintable() {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
30
client/src/main/java/client/service/ShoppingListService.java
Normal file
30
client/src/main/java/client/service/ShoppingListService.java
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
package client.service;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import commons.FormalIngredient;
|
||||||
|
import commons.Recipe;
|
||||||
|
import commons.RecipeIngredient;
|
||||||
|
import javafx.util.Pair;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public abstract class ShoppingListService {
|
||||||
|
private ShoppingListViewModel viewModel;
|
||||||
|
@Inject
|
||||||
|
public ShoppingListService(ShoppingListViewModel viewModel) {
|
||||||
|
this.viewModel = viewModel;
|
||||||
|
}
|
||||||
|
public abstract void putIngredient(FormalIngredient ingredient);
|
||||||
|
public abstract void putIngredient(FormalIngredient ingredient, Recipe recipe);
|
||||||
|
public abstract void putIngredient(FormalIngredient ingredient, String recipeName);
|
||||||
|
public abstract void putArbitraryItem(String name);
|
||||||
|
|
||||||
|
public abstract FormalIngredient purgeIngredient(Long id);
|
||||||
|
public abstract FormalIngredient purgeIngredient(String ingredientName);
|
||||||
|
|
||||||
|
public abstract void reset();
|
||||||
|
|
||||||
|
public abstract List<Pair<FormalIngredient, Optional<String>>> getItems();
|
||||||
|
public abstract String makePrintable();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package client.service;
|
||||||
|
|
||||||
|
import commons.FormalIngredient;
|
||||||
|
import javafx.beans.property.ListProperty;
|
||||||
|
import javafx.beans.property.SimpleListProperty;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.util.Pair;
|
||||||
|
import org.apache.commons.lang3.NotImplementedException;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class ShoppingListViewModel {
|
||||||
|
/**
|
||||||
|
* The formal ingredient provides the ingredient and its amount,
|
||||||
|
* and the string (optional) describes the recipe where it came from.
|
||||||
|
*/
|
||||||
|
private final ListProperty<Pair<FormalIngredient, Optional<String>>> listItems = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||||
|
public void addArbitrary() {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue