// Path: src/org/openchain/certification/I18N.java
// public final class I18N {
// 	
// 	static final Logger logger = LoggerFactory.getLogger(I18N.class);
// 
// 	private static final String BASE_RESOURCE_NAME = "messages"; //$NON-NLS-1$
// 
// 	/**
// 	 * @param key Key for the resource file
// 	 * @param language tag in IETF RFC 5646 format
// 	 * @return
// 	 */
// 	public static String getMessage(String key, String language, Object... args) {
// 		if (language == null) {
// 			language = User.DEFAULT_LANGUAGE;
// 		}
// 		Locale locale = Locale.forLanguageTag(language);
// 		if (locale == null) {
// 			logger.warn("Language "+language+" not supported by Java.  Using default language"); //$NON-NLS-1$ //$NON-NLS-2$
// 			locale = Locale.forLanguageTag(User.DEFAULT_LANGUAGE);
// 			if (locale == null) {
// 				logger.error("No locale for the default language"); //$NON-NLS-1$
// 				throw(new RuntimeException("No local for the default language")); //$NON-NLS-1$
// 			}
// 		}
// 		ResourceBundle.Control utf8Control = new Utf8ResourceBundleControl();
// 		ResourceBundle bundle = ResourceBundle.getBundle(BASE_RESOURCE_NAME, locale, utf8Control);
// 		String template = bundle.getString(key);
// 		try {
// 			MessageFormat mf = new MessageFormat(template, locale);
// 			return mf.format(args, new StringBuffer(), null).toString();
// 		} catch(IllegalArgumentException ex) {
// 			logger.error("Invalid argument for message template with key `"+key+"`: "+template, ex);
// 			return template;
// 		}
// 	}
// 
// }


import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.HashSet;
import org.openchain.certification.I18N;
import com.opencsv.CSVWriter;

	/**
	 * @return List of any warnings due to an invalid survey
	 */
	public List<String> verify(String language) {
		List<String> retval = new ArrayList<String>();
		Set<String> existingSections = new HashSet<String>();
		Set<String> existingQuestions = new HashSet<String>();
		Set<String> foundSubQuestions = new HashSet<String>();
		for (Section section:sections) {
			// Check for duplication section names
			if (existingSections.contains(section.getName())) {
				retval.add(I18N.getMessage("Survey.1", language, section.getName())); //$NON-NLS-1$
			}
			existingSections.add(section.getName());
			for (Question question:section.getQuestions()) {
				// Check for duplication question numbers
				if (existingQuestions.contains(question.getNumber())) {
					retval.add(I18N.getMessage("Survey.2", language, question.getNumber())); //$NON-NLS-1$
				}
				existingQuestions.add(question.getNumber());
				if (!Objects.equals(question.getSectionName(), section.getName())) {
					retval.add(I18N.getMessage("Survey.4", language, question.getNumber())); //$NON-NLS-1$
				}
				if (question instanceof SubQuestion) {
					SubQuestion subq = (SubQuestion)question;
					// Check to make sure we have enough subquestions
					if (subq.getAllSubquestions().size() < subq.getMinNumberValidatedAnswers()) {
						retval.add(I18N.getMessage("Survey.3", language, question.getNumber(), subq.getAllSubquestions().size(), subq.getMinNumberValidatedAnswers())); //$NON-NLS-1$
					}
// Path: src/org/openchain/certification/I18N.java
// public final class I18N {
// 	
// 	static final Logger logger = LoggerFactory.getLogger(I18N.class);
// 
// 	private static final String BASE_RESOURCE_NAME = "messages"; //$NON-NLS-1$
// 
// 	/**
// 	 * @param key Key for the resource file
// 	 * @param language tag in IETF RFC 5646 format
// 	 * @return
// 	 */
// 	public static String getMessage(String key, String language, Object... args) {
// 		if (language == null) {
// 			language = User.DEFAULT_LANGUAGE;
// 		}
// 		Locale locale = Locale.forLanguageTag(language);
// 		if (locale == null) {
// 			logger.warn("Language "+language+" not supported by Java.  Using default language"); //$NON-NLS-1$ //$NON-NLS-2$
// 			locale = Locale.forLanguageTag(User.DEFAULT_LANGUAGE);
// 			if (locale == null) {
// 				logger.error("No locale for the default language"); //$NON-NLS-1$
// 				throw(new RuntimeException("No local for the default language")); //$NON-NLS-1$
// 			}
// 		}
// 		ResourceBundle.Control utf8Control = new Utf8ResourceBundleControl();
// 		ResourceBundle bundle = ResourceBundle.getBundle(BASE_RESOURCE_NAME, locale, utf8Control);
// 		String template = bundle.getString(key);
// 		try {
// 			MessageFormat mf = new MessageFormat(template, locale);
// 			return mf.format(args, new StringBuffer(), null).toString();
// 		} catch(IllegalArgumentException ex) {
// 			logger.error("Invalid argument for message template with key `"+key+"`: "+template, ex);
// 			return template;
// 		}
// 	}
// 
// }


// Path: src/org/openchain/certification/model/Survey.java
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.HashSet;
import org.openchain.certification.I18N;
import com.opencsv.CSVWriter;


	/**
	 * @return List of any warnings due to an invalid survey
	 */
	public List<String> verify(String language) {
		List<String> retval = new ArrayList<String>();
		Set<String> existingSections = new HashSet<String>();
		Set<String> existingQuestions = new HashSet<String>();
		Set<String> foundSubQuestions = new HashSet<String>();
		for (Section section:sections) {
			// Check for duplication section names
			if (existingSections.contains(section.getName())) {
				retval.add(I18N.getMessage("Survey.1", language, section.getName())); //$NON-NLS-1$
			}
			existingSections.add(section.getName());
			for (Question question:section.getQuestions()) {
				// Check for duplication question numbers
				if (existingQuestions.contains(question.getNumber())) {
					retval.add(I18N.getMessage("Survey.2", language, question.getNumber())); //$NON-NLS-1$
				}
				existingQuestions.add(question.getNumber());
				if (!Objects.equals(question.getSectionName(), section.getName())) {
					retval.add(I18N.getMessage("Survey.4", language, question.getNumber())); //$NON-NLS-1$
				}
				if (question instanceof SubQuestion) {
					SubQuestion subq = (SubQuestion)question;
					// Check to make sure we have enough subquestions
					if (subq.getAllSubquestions().size() < subq.getMinNumberValidatedAnswers()) {
						retval.add(I18N.getMessage("Survey.3", language, question.getNumber(), subq.getAllSubquestions().size(), subq.getMinNumberValidatedAnswers())); //$NON-NLS-1$
					}
					for (Question subquestion:subq.getAllSubquestions()) {