package com.veggie.src.java.controllers.media;

import com.veggie.src.java.controllers.Controller;
import com.veggie.src.java.form.*;
import com.veggie.src.java.notification.*;
import com.veggie.src.java.database.*;

import java.util.List;

public class EditItemController implements Controller {

	//Instance Variables
	private int itemID;
	private Notification notification;
	private Form editItemForm;
	private ItemDatabaseManager manager;

	//Methods
	public EditItemController(int id) {
		itemID = id;
		AbstractFormBuilder builder = AbstractFormBuilderFactory.getInstance().createFormBuilder();
		builder.addField("Status");
		editItemForm = builder.getResult();
		manager = AbstractDatabaseManagerFactory.getInstance().createItemDatabaseManager();
	}

	public Form activate() {
		return editItemForm;
	}

	public Notification submitForm(Form form) {
		List<String> formData = editItemForm.getData();
		//TO DO
		return notification;
	}

	public void respondToNotification(Notification notif) {
		//TO DO
	}

}

@@ -208,16 +208,65 @@
 abase.*;
+%0Aimport com.veggie.src.java.core.media.MediaItem;
 %0A%0Aimport
@@ -366,29 +366,8 @@
 les%0A
-%09private int itemID;%0A
 %09pri
@@ -507,32 +507,11 @@
 ler(
-int id) %7B%0A%09%09itemID = id;
+) %7B
 %0A%09%09A
@@ -601,16 +601,47 @@
 lder();%0A
+%09%09builder.addField(%22Item ID%22);%0A
 %09%09builde
@@ -894,65 +894,136 @@
 %7B%0A%09%09
-List%3CString%3E formData = editItemForm
+editItemForm = form;%0A%09%09notification = AbstractNotificationFactory
 .get
-Data();%0A%09%09//TO DO
+Instance().createConfirmNotification(%22Proceed with edit?%22);
 %0A%09%09r
@@ -1109,15 +1109,450 @@
 %7B%0A%09%09
-//TO DO
+if (notif.ok()) %7B%0A%09%09%09List%3CString%3E formData = editItemForm.getData();%0A%09%09%09switch (Integer.parseInt(formData.get(1))) %7B%0A%09%09%09%09case MediaItem.AVAILABLE:%0A%09%09%09%09%09manager.markAvailable(Integer.parseInt(formData.get(0)));%0A%09%09%09%09%09break;%0A%09%09%09%09case MediaItem.UNAVAILABLE:%0A%09%09%09%09%09manager.markUnavailable(Integer.parseInt(formData.get(0)));%0A%09%09%09%09%09break;%0A%09%09%09%09case MediaItem.RESERVED:%0A%09%09%09%09%09manager.markReserved(Integer.parseInt(formData.get(0)));%0A%09%09%09%09%09break;%0A%09%09%09%7D%0A%09%09%7D
 %0A%09%7D%0A

Implement EditItemController