<commit_before>package org.mifos.framework.components.audit.persistence;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.hibernate.HibernateException;
import org.mifos.application.NamedQueryConstants;
import org.mifos.application.customer.business.CustomFieldDefinitionEntity;
import org.mifos.application.master.business.LookUpEntity;
import org.mifos.application.master.business.LookUpLabelEntity;
import org.mifos.application.master.business.LookUpValueLocaleEntity;
import org.mifos.application.meeting.business.RecurrenceTypeEntity;
import org.mifos.application.productdefinition.business.PrdStatusEntity;
import org.mifos.framework.exceptions.PersistenceException;
import org.mifos.framework.persistence.Persistence;

public class AuditConfigurationPersistence extends Persistence {

	public Map<String, String> retrieveAllCustomFieldsDefinition(Short localeId)
			throws PersistenceException {
		Map<String, String> valueMap = new HashMap<String, String>();
		try {
			List<CustomFieldDefinitionEntity> customFields = (List<CustomFieldDefinitionEntity>) executeNamedQuery(
					NamedQueryConstants.RETRIEVE_ALL_CUSTOM_FIELDS, null);
			for (Iterator<CustomFieldDefinitionEntity> iter = customFields
					.iterator(); iter.hasNext();) {
				CustomFieldDefinitionEntity customFieldDefinitionEntity = iter
						.next();
				LookUpEntity lookUpEntity = customFieldDefinitionEntity
						.getLookUpEntity();
				Set<LookUpLabelEntity> lookUpLabelSet = lookUpEntity
						.getLookUpLabelSet();
				for (Iterator<LookUpLabelEntity> iterator = lookUpLabelSet.iterator(); iterator
						.hasNext();) {
					LookUpLabelEntity lookUpLabel = iterator.next();
					if (lookUpLabel.getLocaleId().equals(localeId)) {
						valueMap.put(customFieldDefinitionEntity.getFieldId()
								.toString(), lookUpLabel.getLabelName());
					}
				}
			}
		} catch (HibernateException he) {
			throw new PersistenceException(he);
		}
		return valueMap;

	}
	
	public Map<String, String>  retrieveProductStatus(Short localeId) throws PersistenceException{
		Map<String, String> valueMap = new HashMap<String, String>();
		try {
			List<PrdStatusEntity> productStates = (List<PrdStatusEntity>) executeNamedQuery(
					NamedQueryConstants.ALL_PRD_STATES, null);
			for (Iterator<PrdStatusEntity> iter = productStates
					.iterator(); iter.hasNext();) {
				PrdStatusEntity prdStatusEntity = iter
						.next();
				Set<LookUpValueLocaleEntity> lookUpValueLocaleSet= prdStatusEntity.getPrdState().getLookUpValue().getLookUpValueLocales();
				for (Iterator<LookUpValueLocaleEntity> iterator = lookUpValueLocaleSet.iterator(); iterator
						.hasNext();) {
					LookUpValueLocaleEntity lookUpValueLocaleEntity = iterator.next();
					if (lookUpValueLocaleEntity.getLocaleId().equals(localeId)) {
						valueMap.put(prdStatusEntity.getOfferingStatusId().toString(), lookUpValueLocaleEntity.getLookUpValue());
					}
				}
			}
		} catch (HibernateException he) {
			throw new PersistenceException(he);
		}
		return valueMap;
	}
	
	public Map<String, String>  retrieveRecurrenceTypes(Short localeId) throws PersistenceException{
		Map<String, String> valueMap = new HashMap<String, String>();
		try {
			List<RecurrenceTypeEntity> recurrenceTypes = (List<RecurrenceTypeEntity>) executeNamedQuery(
					NamedQueryConstants.FETCH_ALL_RECURRENCE_TYPES, null);
			for (Iterator<RecurrenceTypeEntity> iter = recurrenceTypes
					.iterator(); iter.hasNext();) {
				RecurrenceTypeEntity recurrenceTypeEntity = iter
						.next();
				valueMap.put(recurrenceTypeEntity.getRecurrenceId().toString(), recurrenceTypeEntity.getRecurrenceName());
			}
		} catch (HibernateException he) {
			throw new PersistenceException(he);
		}
		return valueMap;
	}
	
}<commit_msg>Fix compiler warnings, iterate using for loop, other little cleanups.<commit_after>package org.mifos.framework.components.audit.persistence;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.hibernate.HibernateException;
import org.mifos.application.NamedQueryConstants;
import org.mifos.application.customer.business.CustomFieldDefinitionEntity;
import org.mifos.application.master.business.LookUpEntity;
import org.mifos.application.master.business.LookUpLabelEntity;
import org.mifos.application.master.business.LookUpValueLocaleEntity;
import org.mifos.application.meeting.business.RecurrenceTypeEntity;
import org.mifos.application.productdefinition.business.PrdStatusEntity;
import org.mifos.framework.exceptions.PersistenceException;
import org.mifos.framework.persistence.Persistence;

public class AuditConfigurationPersistence extends Persistence {

	public Map<String, String> retrieveAllCustomFieldsDefinition(Short localeId)
			throws PersistenceException {
		Map<String, String> valueMap = new HashMap<String, String>();
		try {
			List<CustomFieldDefinitionEntity> customFields = executeNamedQuery(
					NamedQueryConstants.RETRIEVE_ALL_CUSTOM_FIELDS, null);
			for (CustomFieldDefinitionEntity field : customFields) {
				LookUpEntity lookUpEntity = field
						.getLookUpEntity();
				Set<LookUpLabelEntity> lookUpLabelSet = lookUpEntity
						.getLookUpLabelSet();
				for (LookUpLabelEntity lookUpLabel : lookUpLabelSet) {
					if (lookUpLabel.getLocaleId().equals(localeId)) {
						valueMap.put(field.getFieldId()
								.toString(), lookUpLabel.getLabelName());
					}
				}
			}
		} catch (HibernateException e) {
			throw new PersistenceException(e);
		}
		return valueMap;
	}
	
	public Map<String, String> retrieveProductStatus(Short localeId) 
	throws PersistenceException{
		Map<String, String> valueMap = new HashMap<String, String>();
		try {
			List<PrdStatusEntity> productStates = executeNamedQuery(
					NamedQueryConstants.ALL_PRD_STATES, null);
			for (PrdStatusEntity prdStatusEntity : productStates) {
				Set<LookUpValueLocaleEntity> lookUpValueLocaleSet = 
					prdStatusEntity.getPrdState()
					    .getLookUpValue().getLookUpValueLocales();
				for (LookUpValueLocaleEntity lookup : lookUpValueLocaleSet) {
					if (lookup.getLocaleId().equals(localeId)) {
						valueMap.put(
							prdStatusEntity.getOfferingStatusId().toString(), 
							lookup.getLookUpValue());
					}
				}
			}
		} catch (HibernateException e) {
			throw new PersistenceException(e);
		}
		return valueMap;
	}
	
	public Map<String, String> retrieveRecurrenceTypes(Short localeId) 
	throws PersistenceException {
		Map<String, String> valueMap = new HashMap<String, String>();
		try {
			List<RecurrenceTypeEntity> recurrenceTypes = executeNamedQuery(
					NamedQueryConstants.FETCH_ALL_RECURRENCE_TYPES, null);
			for (RecurrenceTypeEntity recurrence : recurrenceTypes) {
				valueMap.put(
					recurrence.getRecurrenceId().toString(), 
					recurrence.getRecurrenceName());
			}
		} catch (HibernateException e) {
			throw new PersistenceException(e);
		}
		return valueMap;
	}
	
}
{'fraction_non_alphanumeric': 0.09741465504927868, 'fraction_numerical': 0.0, 'mean_word_length': 5.240641711229946, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, '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': '5568108', 'n_tokens_mistral': 2384, 'n_tokens_neox': 2032, 'n_words': 363}