<commit_before>package org.openforis.collect.designer.form;

import org.openforis.collect.model.CollectSurvey;

/**
 * 
 * @author <NAME>
 *
 */
public class SurveyMainInfoFormObject extends FormObject<CollectSurvey> {

	private String name;
	private boolean published;
	private String uri;
	private String description;
	private String projectName;
	private String projectCycle;
	
	@Override
	public void loadFrom(CollectSurvey source, String languageCode, String defaultLanguage) {
		name = source.getName();
		description = getDescription(source, languageCode, defaultLanguage);
		uri = source.getUri();
		published = source.isPublished();
		projectName = getProjectName(source, languageCode, defaultLanguage);
		projectCycle = source.getCycle();
	}
	
	@Override
	public void saveTo(CollectSurvey dest, String languageCode) {
		dest.setName(name);
		dest.setUri(uri);
		dest.setDescription(languageCode, description);
		dest.setProjectName(languageCode, projectName);
		dest.setCycle(projectCycle);
		dest.setPublished(published);
	}
	
	@Override
	protected void reset() {
		// TODO Auto-generated method stub
	}

	protected String getDescription(CollectSurvey source, String languageCode, String defaultLanguage) {
		String result = source.getDescription(languageCode);
		if ( result == null && languageCode != null && languageCode.equals(defaultLanguage) ) {
			//try to get the label associated to default language
			result = source.getDescription(null);
		}
		return result;
	}

	protected String getProjectName(CollectSurvey source, String languageCode, String defaultLanguage) {
		String result = source.getProjectName(languageCode);
		if ( result == null && languageCode != null && languageCode.equals(defaultLanguage) ) {
			//try to get the label associated to default language
			result = source.getDescription(null);
		}
		return result;
	}
	
	public String getName() {
		return name;
	}
<commit_msg>OFC-1251 - Project name not correctly shown in designer when language is not specified<commit_after>package org.openforis.collect.designer.form;

import org.openforis.collect.model.CollectSurvey;

/**
 * 
 * @author <NAME>
 *
 */
public class SurveyMainInfoFormObject extends FormObject<CollectSurvey> {

	private String name;
	private boolean published;
	private String uri;
	private String description;
	private String projectName;
	private String projectCycle;
	
	@Override
	public void loadFrom(CollectSurvey source, String languageCode, String defaultLanguage) {
		name = source.getName();
		description = getDescription(source, languageCode, defaultLanguage);
		uri = source.getUri();
		published = source.isPublished();
		projectName = getProjectName(source, languageCode, defaultLanguage);
		projectCycle = source.getCycle();
	}
	
	@Override
	public void saveTo(CollectSurvey dest, String languageCode) {
		dest.setName(name);
		dest.setUri(uri);
		dest.setDescription(languageCode, description);
		dest.setProjectName(languageCode, projectName);
		dest.setCycle(projectCycle);
		dest.setPublished(published);
	}
	
	@Override
	protected void reset() {
		// TODO Auto-generated method stub
	}

	protected String getDescription(CollectSurvey source, String languageCode, String defaultLanguage) {
		String result = source.getDescription(languageCode);
		if ( result == null && languageCode != null && languageCode.equals(defaultLanguage) ) {
			//try to get the label associated to default language
			result = source.getDescription(null);
		}
		return result;
	}

	protected String getProjectName(CollectSurvey source, String languageCode, String defaultLanguage) {
		String result = source.getProjectName(languageCode);
		if ( result == null && languageCode != null && languageCode.equals(defaultLanguage) ) {
			//try to get the label associated to default language
			result = source.getProjectName(null);
		}
		return result;
	}
	
	public String getName() {
		return name;
	}

{'fraction_non_alphanumeric': 0.09536016406049731, 'fraction_numerical': 0.0010253781081773904, 'mean_word_length': 5.040247678018575, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5400920', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1062, 'n_words': 296}