<commit_before>/**
 * The contents of this file are subject to the OpenMRS Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://license.openmrs.org
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * Copyright (C) OpenMRS, LLC.  All Rights Reserved.
 */
package org.openmrs.web.controller.concept;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.ConceptStopWord;
import org.openmrs.api.ConceptService;
import org.openmrs.api.ConceptStopWordException;
import org.openmrs.api.context.Context;
import org.openmrs.web.WebConstants;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * This is the controlling class for the conceptStopWordList.jsp page. This class used to view the list of 
 * ConceptStopWords with the Locale information. And also to delete ConceptStopWord(s).
 * 
 * @see org.openmrs.ConceptStopWord
 * 
 * @since 1.8
 */
@Controller
@RequestMapping(value = "admin/concepts/conceptStopWord.list")
public class ConceptStopWordListController {
	
	/** Logger for this class and subclasses */
	private static final Log log = LogFactory.getLog(ConceptStopWordListController.class);
	
	/**
	 * Handle the delete action
	 * 
	 * @param session http session
	 * @param conceptStopWordsToBeDeleted array of words to be deleted
	 * @return ConceptStopWordList view
	 * @should delete the given ConceptStopWord in the request parameter
	 * @should add the success delete message in session attribute
	 * @should add the already deleted error message in session attribute if delete the same word
	 *         twice
	 */
	@RequestMapping(method = RequestMethod.POST)
	public String handleSubmission(HttpSession session,
	        @RequestParam(required = false, value = "conceptStopWord") String[] conceptStopWordsToBeDeleted) {
		if (conceptStopWordsToBeDeleted != null) {
			
			ConceptService conceptService = Context.getConceptService();
			for (String conceptStopWordToBeDeleted : conceptStopWordsToBeDeleted) {
				try {
					conceptService.deleteConceptStopWord(new Integer(conceptStopWordToBeDeleted));
					session.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "general.deleted");
				}
				catch (ConceptStopWordException e) {
					log.error("Error on deleting concept stop word", e);
					session.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, e.getMessage());
				}
			}
		} else {
			session.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "ConceptStopWord.error.notSelect");
		}
		
		return showForm(session);
	}
	
	/**
	 * This method to load all the Concept Stop Words in the request attribute and return the
	 * ConceptStopWordList view
	 * 
	 * @param session http session
	 * @return ConceptStopWordList view
	 * @should return Concept Stop Word List View
	 * @should add all ConceptStopWords in session attribute
	 */
	@RequestMapping(method = RequestMethod.GET)
	public String showForm(HttpSession session) {
		
		ConceptService conceptService = Context.getConceptService();
		List<ConceptStopWord> conceptStopWordList = conceptService.getAllConceptStopWords();
		session.setAttribute("conceptStopWordList", conceptStopWordList);
		
		return "admin/concepts/conceptStopWordList";
	}
}<commit_msg>TRUNK-2555:Error and exception when running ConceptStopWordListControllerTest<commit_after>/**
 * The contents of this file are subject to the OpenMRS Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://license.openmrs.org
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * Copyright (C) OpenMRS, LLC.  All Rights Reserved.
 */
package org.openmrs.web.controller.concept;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.openmrs.ConceptStopWord;
import org.openmrs.api.ConceptService;
import org.openmrs.api.ConceptStopWordException;
import org.openmrs.api.context.Context;
import org.openmrs.web.WebConstants;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * This is the controlling class for the conceptStopWordList.jsp page. This class used to view the list of 
 * ConceptStopWords with the Locale information. And also to delete ConceptStopWord(s).
 * 
 * @see org.openmrs.ConceptStopWord
 * 
 * @since 1.8
 */
@Controller
@RequestMapping(value = "admin/concepts/conceptStopWord.list")
public class ConceptStopWordListController {
	
	/**
	 * Handle the delete action
	 * 
	 * @param session http session
	 * @param conceptStopWordsToBeDeleted array of words to be deleted
	 * @return ConceptStopWordList view
	 * @should delete the given ConceptStopWord in the request parameter
	 * @should add the success delete message in session attribute
	 * @should add the already deleted error message in session attribute if delete the same word
	 *         twice
	 */
	@RequestMapping(method = RequestMethod.POST)
	public String handleSubmission(HttpSession session,
	        @RequestParam(required = false, value = "conceptStopWord") String[] conceptStopWordsToBeDeleted) {
		if (conceptStopWordsToBeDeleted != null) {
			
			ConceptService conceptService = Context.getConceptService();
			for (String conceptStopWordToBeDeleted : conceptStopWordsToBeDeleted) {
				try {
					conceptService.deleteConceptStopWord(new Integer(conceptStopWordToBeDeleted));
					session.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "general.deleted");
				}
				catch (ConceptStopWordException e) {
					session.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, e.getMessage());
				}
			}
		} else {
			session.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "ConceptStopWord.error.notSelect");
		}
		
		return showForm(session);
	}
	
	/**
	 * This method to load all the Concept Stop Words in the request attribute and return the
	 * ConceptStopWordList view
	 * 
	 * @param session http session
	 * @return ConceptStopWordList view
	 * @should return Concept Stop Word List View
	 * @should add all ConceptStopWords in session attribute
	 */
	@RequestMapping(method = RequestMethod.GET)
	public String showForm(HttpSession session) {
		
		ConceptService conceptService = Context.getConceptService();
		List<ConceptStopWord> conceptStopWordList = conceptService.getAllConceptStopWords();
		session.setAttribute("conceptStopWordList", conceptStopWordList);
		
		return "admin/concepts/conceptStopWordList";
	}
}
{'fraction_non_alphanumeric': 0.08142423406017113, 'fraction_numerical': 0.0016560861164780568, 'mean_word_length': 4.710795902285264, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5632775', 'n_tokens_mistral': 2147, 'n_tokens_neox': 1942, 'n_words': 602}