<commit_before><#include utilityPath + "all_imports.ftl" />
<@header?interpret />
package ${project_namespace}.provider.base;

import android.content.ContentValues;
import android.database.Cursor;

import java.util.ArrayList;

import org.joda.time.DateTime;
import org.joda.time.format.ISODateTimeFormat;

<#list entities?values + enums?values as entity>
	<#if (!entity.internal?? || !entity.internal && entity.fields?size > 0)>
import ${entity_namespace}.${InheritanceUtils.getCompleteNamespace(entity)};
	</#if>
</#list>

import ${project_namespace}.provider.${project_name?cap_first}Contract;

import ${project_namespace}.harmony.util.DateUtils;

/** ${project_name?cap_first} contract base.
 *
 * This class is regenerated. DO NOT MODIFY.
 */
public abstract class ${project_name?cap_first}ContractBase {

<#list entities?values as curr>		
	<#if (curr.fields?size > 0 || curr.inheritance??)>
			<#assign isTopMostSuperClass = (curr.inheritance?? && !curr.inheritance.superclass??) />
			<#assign singleTabInheritance = (curr.inheritance?? && curr.inheritance.inheritanceType?? && curr.inheritance.inheritanceType == "SingleTab") />
			<#assign joinedInheritance = (curr.inheritance?? && curr.inheritance.superclass?? && entities[curr.inheritance.superclass.name]?? && !singleTabInheritance) />
			<#if joinedInheritance>
				<#assign curr_ids = entities[curr.inheritance.superclass.name].ids />
				<#assign curr_fields = curr.fields?values + entities[curr.inheritance.superclass.name].ids />
				<#assign curr_relations = curr.relations + entities[curr.inheritance.superclass.name].relations />
			<#elseif (singleTabInheritance && curr.inheritance.superclass??)>
				<#assign curr_ids = entities[curr.inheritance.superclass.name].ids />
				<#assign curr_fields = curr.fields?values />
				<#assign curr_relations = curr.relations />
			<#else>
				<#assign curr_ids = curr.ids />
				<#assign curr_fields = curr.fields?values />
				<#assign curr_relations = curr.relations />
			</#if>
			<#assign hasInternalFields = false /><#list (curr_relations) as relation><#if (relation.internal)><#assign hasInternalFields = true /></#if></#list>
	/**
	 * Columns names and aliases for ${curr.name} entity.
	 */
	public interface ${curr.name}Columns<#if ((joinedInheritance || singleTabInheritance) && curr.inheritance.superclass??)> extends ${curr.inheritance.superclass.name}Columns</#if> {
		<#if (singleTabInheritance && !isTopMostSuperClass)>
		/** Identifier for inheritance. */
		public static final String DISCRIMINATOR_IDENTIFIER = "${curr.inheritance.discriminatorIdentifier}";
		</#if>
		<#list curr_fields as field>
			<#if (!field.relation?? || (field.relation.type!="OneToMany" && field.relation.type!="ManyToMany"))>
		/** ${field.columnName}. */
		public static final String ${NamingUtils.alias(field.name)} =
				"${field.columnName}";
		/** Alias. */
		public static final String ALIASED_${NamingUtils.alias(field.name)} =
				<#if !field.columnResult>${project_name?cap_first}Contract.${curr.name}.TABLE_NAME + "." + </#if>${NamingUtils.alias(field.name)};
			</#if>
		</#list>
		<#if (singleTabInheritance && isTopMostSuperClass)>
			/** userGroup. */
			public static final String ${NamingUtils.alias(curr.inheritance.discriminatorColumn.name)} = 
					"${curr.inheritance.discriminatorColumn.columnName}";
			/** Alias. */
			public static final String ALIASED_${NamingUtils.alias(curr.inheritance.discriminatorColumn.name)} = 
					${project_name?cap_first}Contract.${curr.name}.TABLE_NAME + "." + ${NamingUtils.alias(curr.inheritance.discriminatorColumn.name)};
		</#if>
	}

	/**
	 * Contract base class for ${curr.name} Entity.
	 */
	public static class ${curr.name}Base implements ${curr.name}Columns {
		/** Table name of SQLite database. */
		public static final String TABLE_NAME = <#if singleTabInheritance && !isTopMostSuperClass>${project_name?cap_first}Contract.${curr.inheritance.superclass.name}.TABLE_NAME<#else>"${curr.name}"</#if>;
		/** Global Fields. */
		public static final String[] COLS = new String[] {
	<#assign firstFieldDone=false />
	<#list curr_fields as field>
		<#if (!field.relation?? || (field.relation.type!="OneToMany" && field.relation.type!="ManyToMany"))>
	<#if (firstFieldDone)>,</#if>
			${field.owner?cap_first}Columns.${NamingUtils.alias(field.name)}<#assign firstFieldDone=true /></#if></#list>
	<#if singleTabInheritance && !isTopMostSuperClass>
		<#list curr.inheritance.superclass.fields?values as field>
			<#if (!field.relation?? || (field.relation.type!="OneToMany" && field.relation.type!="ManyToMany"))>
		<#if (firstFieldDone)>,</#if>
			${field.owner?cap_first}Columns.${NamingUtils.alias(field.name)}<#assign firstFieldDone=true /></#if></#list>
	</#if>
		};

		/** Global Fields. */
		public static final String[] ALIASED_COLS = new String[] {
	<#assign firstFieldDone=false />
	<#assign allFields = ViewUtils.getAllFields(curr)?values />
	<#list allFields as field>
		<#if (!field.relation?? || (field.relation.type!="OneToMany" && field.relation.type!="ManyToMany"))>
	<#if (firstFieldDone)>,</#if>
			${field.owner?cap_first}Columns.ALIASED_${NamingUtils.alias(field.name)}<#assign firstFieldDone=true /></#if></#list>
		};

	<#if !curr.internal>
		<#if (hasInternalFields)>
		/** Convert ${curr.name} entity to Content Values for database.
		 *
		 * @param item ${curr.name} entity object<#list (curr_relations) as relation><#if relation.relation.type=="ManyToOne" && relation.internal>
		 * @param ${relation.relation.targetEntity?lower_case}Id ${relation.relation.targetEntity?lower_case} id</#if></#list>
		 * @return ContentValues object
		 */
		public static ContentValues itemToContentValues(final ${curr.name} item<#list (curr_relations) as relation><#if relation.relation.type=="ManyToOne" && relation.internal>,
					int ${relation.relation.targetEntity?lower_case}Id</#if></#list>) {
			final ContentValues result = ${project_name?cap_first}Contract.${curr.name}.itemToContentValues(item);
		<#list curr_fields as field>
			<#if (field.internal)>
			result.put(${NamingUtils.alias(field.name)},
					String.valueOf(${field.relation.targetEntity?lower_case}Id));
			</#if>
		</#list>
			return result;
		}
		</#if>

		/**<commit_msg>Fix #3748 & Fix #3842<commit_after><#include utilityPath + "all_imports.ftl" />
<@header?interpret />
package ${project_namespace}.provider.base;

import android.content.ContentValues;
import android.database.Cursor;

import java.util.ArrayList;

import org.joda.time.DateTime;
import org.joda.time.format.ISODateTimeFormat;

<#list entities?values + enums?values as entity>
	<#if (!entity.internal?? || !entity.internal && entity.fields?size > 0)>
import ${entity_namespace}.${InheritanceUtils.getCompleteNamespace(entity)};
	</#if>
</#list>

import ${project_namespace}.provider.${project_name?cap_first}Contract;

import ${project_namespace}.harmony.util.DateUtils;

/** ${project_name?cap_first} contract base.
 *
 * This class is regenerated. DO NOT MODIFY.
 */
public abstract class ${project_name?cap_first}ContractBase {

<#list entities?values as curr>		
	<#if (curr.fields?size > 0 || curr.inheritance??)>
			<#assign isTopMostSuperClass = (curr.inheritance?? && !curr.inheritance.superclass??) />
			<#assign singleTabInheritance = (curr.inheritance?? && curr.inheritance.inheritanceType?? && curr.inheritance.inheritanceType == "SingleTab") />
			<#assign joinedInheritance = (curr.inheritance?? && curr.inheritance.superclass?? && entities[curr.inheritance.superclass.name]?? && !singleTabInheritance) />
			<#if joinedInheritance>
				<#assign curr_ids = entities[curr.inheritance.superclass.name].ids />
				<#assign curr_fields = curr.fields?values + entities[curr.inheritance.superclass.name].ids />
				<#assign curr_relations = curr.relations + entities[curr.inheritance.superclass.name].relations />
			<#elseif (singleTabInheritance && curr.inheritance.superclass??)>
				<#assign curr_ids = entities[curr.inheritance.superclass.name].ids />
				<#assign curr_fields = curr.fields?values />
				<#assign curr_relations = curr.relations + entities[curr.inheritance.superclass.name].relations  />
			<#else>
				<#assign curr_ids = curr.ids />
				<#assign curr_fields = curr.fields?values />
				<#assign curr_relations = curr.relations />
			</#if>
			<#assign hasInternalFields = false /><#list (curr_relations) as relation><#if (relation.internal)><#assign hasInternalFields = true /></#if></#list>
	/**
	 * Columns names and aliases for ${curr.name} entity.
	 */
	public interface ${curr.name}Columns<#if ((joinedInheritance || singleTabInheritance) && curr.inheritance.superclass??)> extends ${curr.inheritance.superclass.name}Columns</#if> {
		<#if (singleTabInheritance && !isTopMostSuperClass)>
		/** Identifier for inheritance. */
		public static final String DISCRIMINATOR_IDENTIFIER = "${curr.inheritance.discriminatorIdentifier}";
		</#if>
		<#list curr_fields as field>
			<#if (!field.relation?? || (field.relation.type!="OneToMany" && field.relation.type!="ManyToMany"))>
		/** ${field.columnName}. */
		public static final String ${NamingUtils.alias(field.name)} =
				"${field.columnName}";
		/** Alias. */
		public static final String ALIASED_${NamingUtils.alias(field.name)} =
				<#if !field.columnResult>${project_name?cap_first}Contract.${curr.name}.TABLE_NAME + "." + </#if>${NamingUtils.alias(field.name)};
			</#if>
		</#list>
		<#if (singleTabInheritance && isTopMostSuperClass)>
			/** userGroup. */
			public static final String ${NamingUtils.alias(curr.inheritance.discriminatorColumn.name)} = 
					"${curr.inheritance.discriminatorColumn.columnName}";
			/** Alias. */
			public static final String ALIASED_${NamingUtils.alias(curr.inheritance.discriminatorColumn.name)} = 
					${project_name?cap_first}Contract.${curr.name}.TABLE_NAME + "." + ${NamingUtils.alias(curr.inheritance.discriminatorColumn.name)};
		</#if>
	}

	/**
	 * Contract base class for ${curr.name} Entity.
	 */
	public static class ${curr.name}Base implements ${curr.name}Columns {
		/** Table name of SQLite database. */
		public static final String TABLE_NAME = <#if singleTabInheritance && !isTopMostSuperClass>${project_name?cap_first}Contract.${curr.inheritance.superclass.name}.TABLE_NAME<#else>"${curr.name}"</#if>;
		/** Global Fields. */
		public static final String[] COLS = new String[] {
	<#assign firstFieldDone=false />
	<#list curr_fields as field>
		<#if (!field.relation?? || (field.relation.type!="OneToMany" && field.relation.type!="ManyToMany"))>
	<#if (firstFieldDone)>,</#if>
			${field.owner?cap_first}Columns.${NamingUtils.alias(field.name)}<#assign firstFieldDone=true /></#if></#list>
	<#if singleTabInheritance && !isTopMostSuperClass>
		<#list curr.inheritance.superclass.fields?values as field>
			<#if (!field.relation?? || (field.relation.type!="OneToMany" && field.relation.type!="ManyToMany"))>
		<#if (firstFieldDone)>,</#if>
			${field.owner?cap_first}Columns.${NamingUtils.alias(field.name)}<#assign firstFieldDone=true /></#if></#list>
	</#if>
		};

		/** Global Fields. */
		public static final String[] ALIASED_COLS = new String[] {
	<#assign firstFieldDone=false />
	<#assign allFields = ViewUtils.getAllFields(curr)?values />
	<#list allFields as field>
		<#if (!field.relation?? || (field.relation.type!="OneToMany" && field.relation.type!="ManyToMany"))>
	<#if (firstFieldDone)>,</#if>
			${field.owner?cap_first}Columns.ALIASED_${NamingUtils.alias(field.name)}<#assign firstFieldDone=true /></#if></#list>
		};

	<#if !curr.internal>
		<#if (hasInternalFields)>
		/** Convert ${curr.name} entity to Content Values for database.
		 *
		 * @param item ${curr.name} entity object<#list (curr_relations) as relation><#if relation.relation.type=="ManyToOne" && relation.internal>
		 * @param ${relation.relation.targetEntity?lower_case}Id ${relation.relation.targetEntity?lower_case} id</#if></#list>
		 * @return ContentValues object
		 */
		public static ContentValues itemToContentValues(final ${curr.name} item<#list (curr_relations) as relation><#if relation.relation.type=="ManyToOne" && relation.internal>,
					final int ${relation.name?uncap_first}Id</#if></#list>) {
			final ContentValues result = ${project_name?cap_first}Contract.${curr.name}.itemToContentValues(item);
		<#list curr_fields as field>
			<#if (field.internal)>
			result.put(${NamingUtils.alias(field.name)},
					String.valueOf(${field.name?uncap_first}Id));
			</#if>
		</#list>
			return result;
		}
		</#if>

		/**
{'fraction_non_alphanumeric': 0.17326494630549769, 'fraction_numerical': 0.0009616925789389325, 'mean_word_length': 5.248873309964948, 'pattern_counts': {'":': 0, '<': 175, '<?xml version=': 0, '>': 179, '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': '7318996', 'n_tokens_mistral': 4374, 'n_tokens_neox': 4064, 'n_words': 693}