package gov.nih.nci.cananolab.ui;

import gov.nih.nci.cananolab.dto.common.ExperimentConfigBean;
import gov.nih.nci.cananolab.service.common.ExperimentConfigService;
import gov.nih.nci.cananolab.service.common.impl.ExperimentConfigServiceLocalImpl;
import gov.nih.nci.cananolab.ui.core.BaseAnnotationAction;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 * Submits and updates technique and associated instruments of an
 * ExperimentConfig
 *
 * @author pansu, tanq
 *
 */
public class SubmitExperimentConfigAction extends BaseAnnotationAction {

	private static Logger logger = Logger
			.getLogger(SubmitExperimentConfigAction.class);

	ActionForward create(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		ActionForward forward = null;
		if (request.getSession().getAttribute("experimentConfigToSave") != null) {
			ExperimentConfigBean configBean = (ExperimentConfigBean) (request
					.getSession().getAttribute("experimentConfigToSave"));
			ExperimentConfigService service = new ExperimentConfigServiceLocalImpl();
			service.saveExperimentConfig(configBean.getDomain());
		}
		return forward;
	}
}

@@ -93,16 +93,156 @@
 gBean;%0D%0A
+import gov.nih.nci.cananolab.dto.common.PublicationBean;%0D%0Aimport gov.nih.nci.cananolab.dto.particle.characterization.CharacterizationBean;%0D%0A
 import g
@@ -303,16 +303,16 @@
 rvice;%0D%0A
-
 import g
@@ -719,16 +719,71 @@
 apping;%0D
+%0Aimport org.apache.struts.validator.DynaValidatorForm;%0D
 %0A%0D%0A/**%0D%0A
@@ -1608,16 +1608,16 @@
 ;%0D%0A%09%09%7D%0D%0A
-
 %09%09return
@@ -1631,11 +1631,421 @@
 d;%0D%0A%09%7D%0D%0A
+%09%0D%0A%09%0D%0A%09public ActionForward addInstrument(ActionMapping mapping,%0D%0A%09%09%09ActionForm form, HttpServletRequest request,%0D%0A%09%09%09HttpServletResponse response) throws Exception %7B%0D%0A%09%09DynaValidatorForm theForm = (DynaValidatorForm) form;%0D%0A%09%09CharacterizationBean aCharbean = (CharacterizationBean) theForm%0D%0A%09%09%09%09.get(%22aChar%22);%0D%0A%09%09aCharbean.getTheExperimentConfig().addInstrument();%09%09%0D%0A%09%09return mapping.getInputForward();%0D%0A%09%7D%0D%0A
 %7D%0D%0A

add addInstrument()