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

/**
 * This class creates nanoparticle general information and assigns visibility  
 *  
 * @author pansu
 */

/* CVS $Id: AddParticlePropertiesAction.java,v 1.2 2006-08-10 18:36:10 pansu Exp $ */

import gov.nih.nci.calab.dto.particle.DendrimerBean;
import gov.nih.nci.calab.dto.particle.LiposomeBean;
import gov.nih.nci.calab.dto.particle.ParticleBean;
import gov.nih.nci.calab.dto.particle.PolymerBean;
import gov.nih.nci.calab.service.submit.AddParticlePropertiesService;
import gov.nih.nci.calab.ui.core.AbstractDispatchAction;

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.DynaValidatorForm;

public class AddParticlePropertiesAction extends AbstractDispatchAction {
	public ActionForward create(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		ActionForward forward = null;
		// TODO fill in details for sample information */
		DynaValidatorForm theForm = (DynaValidatorForm) form;
		String particleType = (String) theForm.get("particleType");
		ParticleBean particle = (ParticleBean) theForm.get("particle");
		AddParticlePropertiesService service = new AddParticlePropertiesService();
		service.addParticleProperties(particleType, particle);

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

		return forward;
	}

	public ActionForward setup(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		DynaValidatorForm theForm = (DynaValidatorForm) form;
		String particleType = (String) theForm.get("particleType");
		String particleName = (String) theForm.get("particleName");
		if (particleType.equalsIgnoreCase("dendrimer")) {
			DendrimerBean particle = new DendrimerBean();
			particle.setName(particleName);
			theForm.set("particle", particle);
		} else if (particleType.equalsIgnoreCase("liposome")) {
			LiposomeBean particle = new LiposomeBean();
			particle.setName(particleName);
			theForm.set("particle", particle);

		} else if (particleType.equalsIgnoreCase("polymer")) {
			PolymerBean particle = new PolymerBean();
			particle.setName(particleName);
			theForm.set("particle", particle);
		}
		theForm.set("particlePage", mapping.findForward(
				particleType.toLowerCase()).getPath());
		return mapping.getInputForward();
	}

	public boolean loginRequired() {
		return true;
	}
}

@@ -191,17 +191,17 @@
 ava,v 1.
-2
+3
  2006-08
@@ -206,24 +206,25 @@
 08-1
-0 18:36:10 pansu
+1 12:57:01 zengje
  Exp
@@ -268,25 +268,189 @@
 article.
-Dendrimer
+BuckyballBean;%0Aimport gov.nih.nci.calab.dto.particle.DendrimerBean;%0Aimport gov.nih.nci.calab.dto.particle.FullereneBean;%0A//import gov.nih.nci.calab.dto.particle.GoldParticle
 Bean;%0Aim
@@ -594,32 +594,86 @@
 le.PolymerBean;%0A
+import gov.nih.nci.calab.dto.particle.QuantumdotBean;%0A
 import gov.nih.n
@@ -2903,16 +2903,767 @@
 le);%0A%09%09%7D
+ else if (particleType.equalsIgnoreCase(%22buckyball%22)) %7B%0A%09%09%09BuckyballBean particle = new BuckyballBean();%0A%09%09%09particle.setName(particleName);%0A%09%09%09theForm.set(%22particle%22, particle);%0A%09%09%7D else if (particleType.equalsIgnoreCase(%22fullerene%22)) %7B%0A%09%09%09FullereneBean particle = new FullereneBean();%0A%09%09%09particle.setName(particleName);%0A%09%09%09theForm.set(%22particle%22, particle);%0A%09%09%7D else if (particleType.equalsIgnoreCase(%22quantum dot%22)) %7B%0A%09%09%09QuantumdotBean particle = new QuantumdotBean();%0A%09%09%09particle.setName(particleName);%0A%09%09%09theForm.set(%22particle%22, particle);%0A%09%09%7D %0A//%09%09else if (particleType.equalsIgnoreCase(%22gold particle%22)) %7B%0A//%09%09%09GoldParticleBean particle = new GoldParticleBean();%0A//%09%09%09particle.setName(particleName);%0A//%09%09%09theForm.set(%22particle%22, particle);%0A//%09%09%7D
 %0A%09%09theFo

Add buckyball, fullerene, and quantum dot.