<commit_before>package gov.nih.nci.cabig.caaers.web.study;

import gov.nih.nci.cabig.caaers.utils.Lov;
import gov.nih.nci.cabig.caaers.dao.ResearchStaffDao;
import gov.nih.nci.cabig.caaers.dao.SiteDao;
import gov.nih.nci.cabig.caaers.dao.SiteInvestigatorDao;
import gov.nih.nci.cabig.caaers.dao.StudyDao;
import gov.nih.nci.cabig.caaers.dao.AgentDao;
import gov.nih.nci.cabig.caaers.dao.DiseaseTermDao;
import gov.nih.nci.cabig.caaers.domain.Identifier;
import gov.nih.nci.cabig.caaers.domain.ResearchStaff;
import gov.nih.nci.cabig.caaers.domain.Site;
import gov.nih.nci.cabig.caaers.domain.SiteInvestigator;
import gov.nih.nci.cabig.caaers.domain.Study;
import gov.nih.nci.cabig.caaers.domain.StudyInvestigator;
import gov.nih.nci.cabig.caaers.domain.StudyPersonnel;
import gov.nih.nci.cabig.caaers.domain.StudySite;
import gov.nih.nci.cabig.caaers.domain.StudyAgent;
import gov.nih.nci.cabig.caaers.domain.StudyDisease;
import gov.nih.nci.cabig.caaers.domain.Agent;
import gov.nih.nci.cabig.caaers.tools.editors.DaoBasedEditor;
import gov.nih.nci.cabig.caaers.utils.ConfigProperty;
import gov.nih.nci.cabig.caaers.web.ControllerTools;
import gov.nih.nci.cabig.caaers.web.tabbedflow.AbstractTabbedFlowFormController;
import gov.nih.nci.cabig.caaers.web.tabbedflow.Flow;
import gov.nih.nci.cabig.caaers.web.tabbedflow.Tab;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

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

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author Kulasekaran
 */
public class CreateStudyController extends AbstractTabbedFlowFormController<Study> {
	
	private static Log log = LogFactory.getLog(CreateStudyController.class);
	private StudyDao studyDao;
	private SiteDao siteDao;
	private AgentDao agentDao;
	private DiseaseTermDao diseaseTermDao;
	private SiteInvestigatorDao siteInvestigatorDao;
	private ResearchStaffDao researchStaffDao;
	private ConfigProperty configurationProperty;
	
	public CreateStudyController() {		
        setCommandClass(Study.class);        

        Flow<Study> flow = new Flow<Study>("Create Study");       
        
        flow.addTab(new Tab<Study>("Study Details", "Study Details", "study/study_details") {
            public Map<String, Object> referenceData() {
            	            	
                Map<String, Object> refdata = super.referenceData();
                Map <String, List<Lov>> configMap = configurationProperty.getMap();
                
                refdata.put("diseaseCodeRefData", configMap.get("diseaseCodeRefData"));
    	  		refdata.put("monitorCodeRefData",  configMap.get("monitorCodeRefData"));
    	  		refdata.put("phaseCodeRefData",  configMap.get("phaseCodeRefData"));
    	  		refdata.put("sponsorCodeRefData",  configMap.get("sponsorCodeRefData"));
    	  		refdata.put("statusRefData",  configMap.get("statusRefData"));
    	  		refdata.put("typeRefData",  configMap.get("typeRefData"));                
    	  		refdata.put("multiInstitutionIndicator", getBooleanList());
    	  		refdata.put("randomizedIndicator", getBooleanList());
    	  		refdata.put("blindedIndicator", getBooleanList());
    	  		refdata.put("nciIdentifier", getBooleanList());
    	  		return refdata;
            }
            
            @Override
            public void validate(Study command, Errors errors) {
                boolean longTitle = command.getLongTitle() == null || command.getLongTitle().equals("");                
                if (longTitle) errors.rejectValue("longTitle", "REQUIRED", "Missing Long Title");                
            }
            
            @Override
            public boolean isAllowDirtyForward() {
                return false;
            }
        });
        flow.addTab(new Tab<Study>("Study Identifiers", "Study Identifiers", "study/study_identifiers"){
            
        	public Map<String, Object> referenceData() {
                Map<String, Object> refdata = super.referenceData();
                Map <String, List<Lov>> configMap = configurationProperty.getMap();
                
                refdata.put("identifiersSourceRefData", getSites());
                refdata.put("identifiersTypeRefData", configMap.get("identifiersType"));                    
    	  		return refdata;
        	}
        });                 
        flow.addTab(new Tab<Study>("Study Sites", "Study Sites", "study/study_studysite") {
            
        	public Map<String, Object> referenceData() {
                Map<String, Object> refdata = super.referenceData();  
                Map <String, List<Lov>> configMap = configurationProperty.getMap();
                
                refdata.put("sitesRefData", getSites());
                refdata.put("studySiteStatusRefData", configMap.get("studySiteStatusRefData"));
    	  		refdata.put("studySiteRoleCodeRefData",  configMap.get("studySiteRoleCodeRefData"));
                return refdata;
           
        	}        	
        });

        flow.addTab(new Tab<Study>("Study Investigators", "Study Investigators", "study/study_investigator") {
            
        	public Map<String, Object> referenceData() {
                Map<String, Object> refdata = super.referenceData();
                Map <String, List<Lov>> configMap = configurationProperty.getMap();
                //List<StudySite> studySites = new ArrayList<StudySite>();
                //refdata.put("siteInvestigatorRefData", getSiteInvestigator());
                refdata.put("invRoleCodeRefData", configMap.get("invRoleCodeRefData"));
                refdata.put("invStatusCodeRefData", configMap.get("invStatusCodeRefData"));
                return refdata;           
        	}        	
        });
        
        flow.addTab(new Tab<Study>("Study Personnel", "Study Personnel", "study/study_personnels") {
            
        	public Map<String, Object> referenceData() {
                Map<String, Object> refdata = super.referenceData();  
                Map <String, List<Lov>> configMap = configurationProperty.getMap();
                //List<StudySite> studySites = new ArrayList<StudySite>();
                //refdata.put("researchStaffRefData", getResearchStaff());
                refdata.put("invRoleCodeRefData", configMap.get("invRoleCodeRefData"));
                refdata.put("invStatusCodeRefData", configMap.get("invStatusCodeRefData"));
                
                return refdata;           
        	}        	
        });
 
		flow.addTab(new Tab<Study>("Study Agents", "Study Agents", "study/study_studyagent") {
            
        	public Map<String, Object> referenceData() {
                Map<String, Object> refdata = super.referenceData();
                return refdata;
           
        	}        	
        });
		
		flow.addTab(new Tab<Study>("Study Disease", "Study Disease", "study/study_studydisease") {
            
        	public Map<String, Object> referenceData() {
                Map<String, Object> refdata = super.referenceData();
                return refdata;
           
        	}        	
        });
        
        
        flow.addTab(new Tab<Study>("Review and Submit", "Review and Submit", "study/study_reviewsummary"));                        
        setFlow(flow);        
    }
	
	protected void initBinder(HttpServletRequest request,
			ServletRequestDataBinder binder) throws Exception {
		super.initBinder(request, binder);
		binder.registerCustomEditor(Date.class, ControllerTools
				.getDateEditor(true));
		binder.registerCustomEditor(Site.class, new DaoBasedEditor(
				siteDao));
		binder.registerCustomEditor(Agent.class, new DaoBasedEditor(
				agentDao));
		binder.registerCustomEditor(SiteInvestigator.class, new DaoBasedEditor(
				siteInvestigatorDao));<commit_msg>changed the short title of tabs(pages)<commit_after>package gov.nih.nci.cabig.caaers.web.study;

import gov.nih.nci.cabig.caaers.utils.Lov;
import gov.nih.nci.cabig.caaers.dao.ResearchStaffDao;
import gov.nih.nci.cabig.caaers.dao.SiteDao;
import gov.nih.nci.cabig.caaers.dao.SiteInvestigatorDao;
import gov.nih.nci.cabig.caaers.dao.StudyDao;
import gov.nih.nci.cabig.caaers.dao.AgentDao;
import gov.nih.nci.cabig.caaers.dao.DiseaseTermDao;
import gov.nih.nci.cabig.caaers.domain.Identifier;
import gov.nih.nci.cabig.caaers.domain.ResearchStaff;
import gov.nih.nci.cabig.caaers.domain.Site;
import gov.nih.nci.cabig.caaers.domain.SiteInvestigator;
import gov.nih.nci.cabig.caaers.domain.Study;
import gov.nih.nci.cabig.caaers.domain.StudyInvestigator;
import gov.nih.nci.cabig.caaers.domain.StudyPersonnel;
import gov.nih.nci.cabig.caaers.domain.StudySite;
import gov.nih.nci.cabig.caaers.domain.StudyAgent;
import gov.nih.nci.cabig.caaers.domain.StudyDisease;
import gov.nih.nci.cabig.caaers.domain.Agent;
import gov.nih.nci.cabig.caaers.tools.editors.DaoBasedEditor;
import gov.nih.nci.cabig.caaers.utils.ConfigProperty;
import gov.nih.nci.cabig.caaers.web.ControllerTools;
import gov.nih.nci.cabig.caaers.web.tabbedflow.AbstractTabbedFlowFormController;
import gov.nih.nci.cabig.caaers.web.tabbedflow.Flow;
import gov.nih.nci.cabig.caaers.web.tabbedflow.Tab;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

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

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author Kulasekaran
 */
public class CreateStudyController extends AbstractTabbedFlowFormController<Study> {
	
	private static Log log = LogFactory.getLog(CreateStudyController.class);
	private StudyDao studyDao;
	private SiteDao siteDao;
	private AgentDao agentDao;
	private DiseaseTermDao diseaseTermDao;
	private SiteInvestigatorDao siteInvestigatorDao;
	private ResearchStaffDao researchStaffDao;
	private ConfigProperty configurationProperty;
	
	public CreateStudyController() {		
        setCommandClass(Study.class);        

        Flow<Study> flow = new Flow<Study>("Create Study");       
        
        flow.addTab(new Tab<Study>("Study Details", "Details", "study/study_details") {
            public Map<String, Object> referenceData() {
            	            	
                Map<String, Object> refdata = super.referenceData();
                Map <String, List<Lov>> configMap = configurationProperty.getMap();
                
                refdata.put("diseaseCodeRefData", configMap.get("diseaseCodeRefData"));
    	  		refdata.put("monitorCodeRefData",  configMap.get("monitorCodeRefData"));
    	  		refdata.put("phaseCodeRefData",  configMap.get("phaseCodeRefData"));
    	  		refdata.put("sponsorCodeRefData",  configMap.get("sponsorCodeRefData"));
    	  		refdata.put("statusRefData",  configMap.get("statusRefData"));
    	  		refdata.put("typeRefData",  configMap.get("typeRefData"));                
    	  		refdata.put("multiInstitutionIndicator", getBooleanList());
    	  		refdata.put("randomizedIndicator", getBooleanList());
    	  		refdata.put("blindedIndicator", getBooleanList());
    	  		refdata.put("nciIdentifier", getBooleanList());
    	  		return refdata;
            }
            
            @Override
            public void validate(Study command, Errors errors) {
                boolean longTitle = command.getLongTitle() == null || command.getLongTitle().equals("");                
                if (longTitle) errors.rejectValue("longTitle", "REQUIRED", "Missing Long Title");                
            }
            
            @Override
            public boolean isAllowDirtyForward() {
                return false;
            }
        });
        flow.addTab(new Tab<Study>("Study Identifiers", "Identifiers", "study/study_identifiers"){
            
        	public Map<String, Object> referenceData() {
                Map<String, Object> refdata = super.referenceData();
                Map <String, List<Lov>> configMap = configurationProperty.getMap();
                
                refdata.put("identifiersSourceRefData", getSites());
                refdata.put("identifiersTypeRefData", configMap.get("identifiersType"));                    
    	  		return refdata;
        	}
        });                 
        flow.addTab(new Tab<Study>("Study Sites", "Sites", "study/study_studysite") {
            
        	public Map<String, Object> referenceData() {
                Map<String, Object> refdata = super.referenceData();  
                Map <String, List<Lov>> configMap = configurationProperty.getMap();
                
                refdata.put("sitesRefData", getSites());
                refdata.put("studySiteStatusRefData", configMap.get("studySiteStatusRefData"));
    	  		refdata.put("studySiteRoleCodeRefData",  configMap.get("studySiteRoleCodeRefData"));
                return refdata;
           
        	}        	
        });

        flow.addTab(new Tab<Study>("Study Investigators", "Investigators", "study/study_investigator") {
            
        	public Map<String, Object> referenceData() {
                Map<String, Object> refdata = super.referenceData();
                Map <String, List<Lov>> configMap = configurationProperty.getMap();
                //List<StudySite> studySites = new ArrayList<StudySite>();
                //refdata.put("siteInvestigatorRefData", getSiteInvestigator());
                refdata.put("invRoleCodeRefData", configMap.get("invRoleCodeRefData"));
                refdata.put("invStatusCodeRefData", configMap.get("invStatusCodeRefData"));
                return refdata;           
        	}        	
        });
        
        flow.addTab(new Tab<Study>("Study Personnel", "Personnel", "study/study_personnels") {
            
        	public Map<String, Object> referenceData() {
                Map<String, Object> refdata = super.referenceData();  
                Map <String, List<Lov>> configMap = configurationProperty.getMap();
                //List<StudySite> studySites = new ArrayList<StudySite>();
                //refdata.put("researchStaffRefData", getResearchStaff());
                refdata.put("invRoleCodeRefData", configMap.get("invRoleCodeRefData"));
                refdata.put("invStatusCodeRefData", configMap.get("invStatusCodeRefData"));
                
                return refdata;           
        	}        	
        });
 
		flow.addTab(new Tab<Study>("Study Agents", "Agents", "study/study_studyagent") {
            
        	public Map<String, Object> referenceData() {
                Map<String, Object> refdata = super.referenceData();
                return refdata;
           
        	}        	
        });
		
		flow.addTab(new Tab<Study>("Study Disease", "Disease", "study/study_studydisease") {
            
        	public Map<String, Object> referenceData() {
                Map<String, Object> refdata = super.referenceData();
                return refdata;
           
        	}        	
        });
        
        
        flow.addTab(new Tab<Study>("Review and Submit", "Review and Submit", "study/study_reviewsummary"));                        
        setFlow(flow);        
    }
	
	protected void initBinder(HttpServletRequest request,
			ServletRequestDataBinder binder) throws Exception {
		super.initBinder(request, binder);
		binder.registerCustomEditor(Date.class, ControllerTools
				.getDateEditor(true));
		binder.registerCustomEditor(Site.class, new DaoBasedEditor(
				siteDao));
		binder.registerCustomEditor(Agent.class, new DaoBasedEditor(
				agentDao));
		binder.registerCustomEditor(SiteInvestigator.class, new DaoBasedEditor(
				siteInvestigatorDao));
{'fraction_non_alphanumeric': 0.11428219194970105, 'fraction_numerical': 0.0, 'mean_word_length': 2.659824046920821, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1093837', 'n_tokens_mistral': 5040, 'n_tokens_neox': 4798, 'n_words': 723}