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

import javax.inject.Inject;

import devopsdistilled.operp.client.items.controllers.EditItemPaneController;
import devopsdistilled.operp.client.items.models.BrandModel;
import devopsdistilled.operp.client.items.models.EditItemPaneModel;
import devopsdistilled.operp.client.items.models.ItemModel;
import devopsdistilled.operp.client.items.models.ProductModel;
import devopsdistilled.operp.client.items.views.EditItemPane;
import devopsdistilled.operp.server.data.entity.items.Item;

public class EditItemPaneControllerImpl implements EditItemPaneController {

	@Inject
	private EditItemPane view;

	@Inject
	private EditItemPaneModel model;

	@Inject
	private ItemModel itemModel;

	@Inject
	private ProductModel productModel;

	@Inject
	private BrandModel brandModel;

	@Override
	public void init() {

	}

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

	@Override
	public Item save(Item item) {
		return itemModel.saveAndUpdateModel(item);
	}

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

	}

}

@@ -162,16 +162,253 @@
 roller;%0A
+import devopsdistilled.operp.client.items.exceptions.ItemNameExistsException;%0Aimport devopsdistilled.operp.client.items.exceptions.NullFieldException;%0Aimport devopsdistilled.operp.client.items.exceptions.ProductBrandPairExistsException;%0A
 import d
@@ -1430,50 +1430,583 @@
 em) 
-%7B%0A%09%09// TODO Auto-generated method stub%0A%0A%09%7D%0A
+throws ProductBrandPairExistsException,%0A%09%09%09ItemNameExistsException, NullFieldException %7B%0A%0A%09%09if (item.getItemName() == null %7C%7C item.getProduct() == null%0A%09%09%09%09%7C%7C item.getBrand() == null %7C%7C item.getPrice() == null) %7B%0A%0A%09%09%09throw new NullFieldException();%0A%09%09%7D%0A%0A%09%09if (!itemModel.getService().isProductBrandPairValidForItem(%0A%09%09%09%09item.getItemId(), item.getProduct(), item.getBrand())) %7B%0A%0A%09%09%09throw new ProductBrandPairExistsException();%0A%09%09%7D%0A%0A%09%09if (!itemModel.getService().isItemNameValidForItem(item.getItemId(),%0A%09%09%09%09item.getItemName())) %7B%0A%0A%09%09%09throw new ItemNameExistsException();%0A%09%09%7D%0A%09%7D
 %0A%7D%0A

Define validate() method