package gov.nih.nci.cananolab.ui.common;

import gov.nih.nci.cananolab.domain.common.PointOfContact;
import gov.nih.nci.cananolab.dto.common.UserBean;
import gov.nih.nci.cananolab.ui.core.InitSetup;
import gov.nih.nci.cananolab.ui.particle.InitNanoparticleSetup;
import gov.nih.nci.cananolab.ui.security.InitSecuritySetup;

import javax.servlet.http.HttpServletRequest;

/**
 * This class sets up information required for organization forms.
 * 
 * @author tanq
 * 
 */
public class InitPOCSetup {
	private InitPOCSetup() {
	}

	public static InitPOCSetup getInstance() {
		return new InitPOCSetup();
	}

	public void setPOCDropdowns(HttpServletRequest request) throws Exception {
		InitSetup.getInstance()
				.getDefaultAndOtherLookupTypes(request, "contactRoles",
						"POC", "contactRole", "otherContactRole", true);		
		InitSecuritySetup.getInstance().getAllVisibilityGroups(request);
		UserBean user = (UserBean) request.getSession().getAttribute("user");
		InitNanoparticleSetup.getInstance().getAllNanoparticleSampleNames(
				request, user);
	}

	
	public void persistPOCDropdowns(HttpServletRequest request,
			PointOfContact poc) throws Exception {	
		/**
		 * 
		 * HttpServletRequest request, String lookupName,
			String attribute, String otherAttribute, String value
		 */
		InitSetup.getInstance().persistLookup(request, "POC", "contactRoles",
				"otherContactRoles",
				poc.getRole());
		setPOCDropdowns(request);
	}	
}

@@ -144,16 +144,97 @@
 erBean;%0A
+import gov.nih.nci.cananolab.service.common.impl.PointOfContactServiceLocalImpl;%0A
 import g
@@ -269,24 +269,24 @@
 .InitSetup;%0A
-
 import gov.n
@@ -398,16 +398,45 @@
 Setup;%0A%0A
+import java.util.SortedSet;%0A%0A
 import j
@@ -601,16 +601,108 @@
 Setup %7B%0A
+%09private PointOfContactServiceLocalImpl pocService = new PointOfContactServiceLocalImpl();%0A%0A
 %09private
@@ -1247,16 +1247,58 @@
  user);%0A
+%09%09getAllOrganizationNames(request, user);%0A
 %09%7D%0A%0A%09%0A%09p
@@ -1675,10 +1675,326 @@
 t);%0A
-
 %09%7D%09%0A
+%09%0A%09public SortedSet%3CString%3E getAllOrganizationNames(%0A%09%09%09HttpServletRequest request, UserBean user) throws Exception %7B%0A%09%09SortedSet%3CString%3E organizationNames = pocService%0A%09%09%09%09.getAllOrganizationNames(user);%0A%09%09request.getSession().setAttribute(%22allOrganizationNames%22, organizationNames);%0A%09%09return organizationNames;%0A%09%7D%0A
 %7D%0A

add method getAllOrganizationNames