Compare commits
No commits in common. "79b46541a8104fa9794dd96c8817b36e3dcfa8a7" and "83910eca724f890d68cd83fd8a6628da09edb17b" have entirely different histories.
79b46541a8
...
83910eca72
6 changed files with 0 additions and 248 deletions
|
|
@ -21,9 +21,6 @@ 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.ShoppingListService;
|
|
||||||
import client.service.ShoppingListServiceImpl;
|
|
||||||
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;
|
||||||
|
|
@ -60,8 +57,6 @@ 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(ShoppingListServiceImpl.class);
|
|
||||||
binder.bind(new TypeLiteral<WebSocketDataService<Long, Ingredient>>() {}).toInstance(
|
binder.bind(new TypeLiteral<WebSocketDataService<Long, Ingredient>>() {}).toInstance(
|
||||||
new WebSocketDataService<>()
|
new WebSocketDataService<>()
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
package client.service;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import commons.FormalIngredient;
|
|
||||||
import commons.Recipe;
|
|
||||||
import commons.Unit;
|
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class NonFunctionalShoppingListService extends ShoppingListService {
|
|
||||||
@Inject
|
|
||||||
public NonFunctionalShoppingListService(ShoppingListViewModel viewModel) {
|
|
||||||
super(viewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putIngredient(FormalIngredient ingredient) {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putIngredient(FormalIngredient ingredient, Recipe recipe) {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putIngredient(FormalIngredient ingredient, String recipeName) {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putArbitraryItem(Double amount, String name, Unit unit) {
|
|
||||||
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<ShopListItem> getItems() {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String makePrintable() {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
package client.service;
|
|
||||||
|
|
||||||
import commons.FormalIngredient;
|
|
||||||
|
|
||||||
public class ShopListItem {
|
|
||||||
private FormalIngredient ingredient;
|
|
||||||
private String refRecipeName;
|
|
||||||
public ShopListItem(FormalIngredient ingredient, String refRecipeName) {
|
|
||||||
this.ingredient = ingredient;
|
|
||||||
this.refRecipeName = refRecipeName;
|
|
||||||
}
|
|
||||||
public ShopListItem(FormalIngredient ingredient) {
|
|
||||||
this.ingredient = ingredient;
|
|
||||||
this.refRecipeName = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormalIngredient getIngredient() {
|
|
||||||
return ingredient;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRefRecipeName() {
|
|
||||||
return refRecipeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefRecipeName(String refRecipeName) {
|
|
||||||
this.refRecipeName = refRecipeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIngredient(FormalIngredient ingredient) {
|
|
||||||
this.ingredient = ingredient;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package client.service;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import commons.FormalIngredient;
|
|
||||||
import commons.Recipe;
|
|
||||||
import commons.Unit;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class ShoppingListService {
|
|
||||||
private final ShoppingListViewModel viewModel;
|
|
||||||
@Inject
|
|
||||||
public ShoppingListService(ShoppingListViewModel viewModel) {
|
|
||||||
this.viewModel = viewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShoppingListViewModel getViewModel() {
|
|
||||||
return 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(Double amount, String name, Unit unit);
|
|
||||||
|
|
||||||
public abstract FormalIngredient purgeIngredient(Long id);
|
|
||||||
public abstract FormalIngredient purgeIngredient(String ingredientName);
|
|
||||||
|
|
||||||
public abstract void reset();
|
|
||||||
|
|
||||||
public abstract List<ShopListItem> getItems();
|
|
||||||
public abstract String makePrintable();
|
|
||||||
}
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
package client.service;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import commons.FormalIngredient;
|
|
||||||
import commons.Recipe;
|
|
||||||
import commons.Unit;
|
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ShoppingListServiceImpl extends ShoppingListService {
|
|
||||||
@Inject
|
|
||||||
public ShoppingListServiceImpl(ShoppingListViewModel viewModel) {
|
|
||||||
super(viewModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putIngredient(FormalIngredient ingredient) {
|
|
||||||
getViewModel().add(ingredient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putIngredient(FormalIngredient ingredient, Recipe recipe) {
|
|
||||||
putIngredient(ingredient, recipe.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putIngredient(FormalIngredient ingredient, String recipeName) {
|
|
||||||
getViewModel().add(ingredient, recipeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putArbitraryItem(Double amount, String name, Unit unit) {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FormalIngredient purgeIngredient(Long id) {
|
|
||||||
FormalIngredient i = getViewModel().get(id).getIngredient();
|
|
||||||
getViewModel().delete(id);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FormalIngredient purgeIngredient(String ingredientName) {
|
|
||||||
FormalIngredient i = getViewModel().get(ingredientName).getIngredient();
|
|
||||||
getViewModel().delete(ingredientName);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reset() {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ShopListItem> getItems() {
|
|
||||||
return getViewModel().getListItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String makePrintable() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
package client.service;
|
|
||||||
|
|
||||||
import commons.FormalIngredient;
|
|
||||||
import javafx.beans.property.ListProperty;
|
|
||||||
import javafx.beans.property.SimpleListProperty;
|
|
||||||
import javafx.collections.FXCollections;
|
|
||||||
import javafx.collections.ObservableList;
|
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
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<ShopListItem> listItems = new SimpleListProperty<>(FXCollections.observableArrayList());
|
|
||||||
public void addArbitrary() {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
public void add(FormalIngredient formalIngredient) {
|
|
||||||
listItems.get().add(new ShopListItem(formalIngredient));
|
|
||||||
}
|
|
||||||
public void add(FormalIngredient formalIngredient, String recipeName) {
|
|
||||||
listItems.get().add(new ShopListItem(formalIngredient, recipeName));
|
|
||||||
}
|
|
||||||
public ShopListItem get(Long id) {
|
|
||||||
return get(item -> item.getIngredient().getId().equals(id));
|
|
||||||
}
|
|
||||||
private ShopListItem get(Predicate<ShopListItem> matcher) {
|
|
||||||
return listItems.get().stream()
|
|
||||||
.filter(matcher)
|
|
||||||
.findFirst()
|
|
||||||
.orElseThrow(NullPointerException::new);
|
|
||||||
}
|
|
||||||
public ShopListItem get(String recipeName) {
|
|
||||||
return get(i -> i.getRefRecipeName().equals(recipeName));
|
|
||||||
}
|
|
||||||
public void delete(Long id) {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObservableList<ShopListItem> getListItems() {
|
|
||||||
return listItems.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deleting an item of name which is not associated to any recipe.
|
|
||||||
* @param name the name of the ingredient
|
|
||||||
*/
|
|
||||||
public void delete(String name) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue