package gov.nih.nci.calab.ui.submit;

/**
 * This class sets up input form for size characterization. 
 *  
 * @author pansu
 */

/* CVS $Id: NanoparticleSizeAction.java,v 1.23 2007-06-01 21:24:40 pansu Exp $ */

import gov.nih.nci.calab.domain.nano.characterization.Characterization;
import gov.nih.nci.calab.dto.characterization.CharacterizationBean;
import gov.nih.nci.calab.service.submit.SubmitNanoparticleService;
import gov.nih.nci.calab.ui.core.BaseCharacterizationAction;

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

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.validator.DynaValidatorActionForm;
import org.apache.struts.validator.DynaValidatorForm;

public class NanoparticleSizeAction extends BaseCharacterizationAction {

	/**
	 * Add or update the data to database
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward create(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		ActionForward forward = null;

		DynaValidatorActionForm theForm = (DynaValidatorActionForm) form;
		String particleName=theForm.getString("particleName");
		String particleType=theForm.getString("particleType");		

		CharacterizationBean charBean = super.prepareCreate(request, theForm);
		SubmitNanoparticleService service = new SubmitNanoparticleService();
		service.addParticleSize(particleType, particleName, charBean);

		ActionMessages msgs = new ActionMessages();
		ActionMessage msg = new ActionMessage("message.addParticleSize");
		msgs.add("message", msg);
		saveMessages(request, msgs);
		forward = mapping.findForward("success");

		return forward;
	}

	protected void setLoadFileRequest(HttpServletRequest request) {
		request.setAttribute("characterization", "size");
		request.setAttribute("loadFileForward", "sizeInputForm");
	}

	@Override
	//TODO delete this
	protected void setFormCharacterizationBean(DynaValidatorForm theForm, Characterization aChar) throws Exception {
		// TODO Auto-generated method stub
		
	}
}

@@ -172,9 +172,9 @@
  1.2
-3
+4
  200
@@ -183,18 +183,18 @@
 06-0
-1
+4
  21:2
-4:40
+9:09
  pan
@@ -806,68 +806,8 @@
 es;%0A
-import org.apache.struts.validator.DynaValidatorActionForm;%0A
 impo
@@ -1289,30 +1289,24 @@
 ynaValidator
-Action
 Form theForm
@@ -1322,22 +1322,16 @@
 alidator
-Action
 Form) fo

convert to used the more general DynaValidatorForm