package devopsdistilled.operp.client.items.controllers.impl;

import javax.inject.Inject;

import devopsdistilled.operp.client.items.controllers.CreateItemPaneController;
import devopsdistilled.operp.client.items.models.BrandModel;
import devopsdistilled.operp.client.items.models.CreateItemPaneModel;
import devopsdistilled.operp.client.items.models.ItemModel;
import devopsdistilled.operp.client.items.models.ProductModel;
import devopsdistilled.operp.client.items.views.CreateItemPane;
import devopsdistilled.operp.server.data.entity.items.Item;

public class CreateItemPaneControllerImpl implements CreateItemPaneController {

	@Inject
	private CreateItemPaneModel model;

	@Inject
	private CreateItemPane view;

	@Inject
	private ItemModel itemModel;

	@Inject
	private ProductModel productModel;

	@Inject
	private BrandModel brandModel;

	@Override
	public void init() {
		view.init();
		model.registerObserver(view);
		productModel.registerObserver(view);
		brandModel.registerObserver(view);
	}

	@Override
	public void validate(Item item) {
		// TODO Auto-generated method stub

	}

}

@@ -164,16 +164,180 @@
 roller;%0A
+import devopsdistilled.operp.client.items.exceptions.ItemNameExistsException;%0Aimport devopsdistilled.operp.client.items.exceptions.ProductBrandPairExistsException;%0A
 import d
@@ -1210,50 +1210,479 @@
 em) 
-%7B%0A%09%09// TODO Auto-generated method stub%0A
+throws ProductBrandPairExistsException,%0A%09%09%09ItemNameExistsException %7B%0A%0A%09%09if (itemModel.getService().isProductBrandPairExists(%0A%09%09%09%09item.getProduct().getProductName(),%0A%09%09%09%09item.getBrand().getBrandName())) %7B%0A%0A%09%09%09throw new ProductBrandPairExistsException();%0A%09%09%7D%0A%0A%09%09if (itemModel.getService().isItemNameExists(item.getItemName())) %7B%0A%0A%09%09%09throw new ItemNameExistsException();%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public Item save(Item item) %7B%0A%09%09return itemModel.getService().saveAndFlush(item);
 %0A%09%7D%0A
-%0A
 %7D%0A

Define validate() and save()