<commit_before>package MetadataModel;

sub new
{
	my ($class, $sth) = @_;
	my $self = {};
	
	$self->{_sth} = $sth;
	
	bless $self, $class;
	
	$self->loadMetadata() if $sth;
	
	return $self;
}

sub loadMetadata
{
	my $self = shift;
	my $sth = $self->{_sth};
	
  #print "MetadataModel::loadMetadata: " . join(', ', @{$sth->{NAME}});
	$self->setFieldNames(@{$sth->{NAME}});
	$self->{_numFields} = $sth->{NUM_OF_FIELDS};
	$self->{_numericFieldFlags} = $sth->{mysql_is_num};
	$self->{_fieldTypeNames} = $sth->{mysql_type_name};
	$self->{_nullableFlags} = $sth->{NULLABLE};
	$self->{_priKeyFlags} = $sth->{mysql_is_pri_key};
	$self->{_fieldTypeCodes} = $sth->{mysql_type};
	$self->{_precisions} = $sth->{PRECISION};
	# Get the table name (I'm starting to think that DBI kinda sucks!)
	my $selectString = $sth->{Statement};
	my ($tableName) = ($selectString =~ /SELECT.+?FROM\s+(\w+)/ims);
	$self->{_tableName} = $tableName;
	
	# Needs work: This is an evil hack.  Normalize the database or get better metadata
	my %SET_FIELDS_BY_TABLE_NAME = (refs=>[project_name=>1],
									collections=>{lithadj=>1,pres_mode=>1,assembl_comps=>1,collection_coverage=>1,coll_meth=>1,lithadj2=>,feed_pred_traces=>1},
									#occurrences=>[],
									#authorities=>[],
									#opinions=>[],
									#reidentifications=>[]
									);
	$self->{_setFields} = \%SET_FIELDS_BY_TABLE_NAME;
}

sub isOfTypeSet
{
	my $self = shift;
	my $fieldName = shift;
	
	# If this field is of type 'set', get the correct value
	my %table_hash = %{$self->{_setFields}{$self->getTableName()}};

	if($table_hash{$fieldName})
	{
		return 1;
	}<commit_msg>+ sub loadMetadata:  changed the way the table name was being retrieved from   the mysql query.<commit_after>package MetadataModel;

sub new
{
	my ($class, $sth) = @_;
	my $self = {};
	
	$self->{_sth} = $sth;
	
	bless $self, $class;
	
	$self->loadMetadata() if $sth;
	
	return $self;
}

sub loadMetadata
{
	my $self = shift;
	my $sth = $self->{_sth};
	
  #print "MetadataModel::loadMetadata: " . join(', ', @{$sth->{NAME}});
	$self->setFieldNames(@{$sth->{NAME}});
	$self->{_numFields} = $sth->{NUM_OF_FIELDS};
	$self->{_numericFieldFlags} = $sth->{mysql_is_num};
	$self->{_fieldTypeNames} = $sth->{mysql_type_name};
	$self->{_nullableFlags} = $sth->{NULLABLE};
	$self->{_priKeyFlags} = $sth->{mysql_is_pri_key};
	$self->{_fieldTypeCodes} = $sth->{mysql_type};
	$self->{_precisions} = $sth->{PRECISION};
	# Get the table name (returns an array of all tables)
	my @tables = @{$sth->{mysql_table}};
	$self->{_tableName} = $tables[0];
	
	# Needs work: This is an evil hack.  Normalize the database or get better metadata
	my %SET_FIELDS_BY_TABLE_NAME = (refs=>[project_name=>1],
									collections=>{lithadj=>1,pres_mode=>1,assembl_comps=>1,collection_coverage=>1,coll_meth=>1,lithadj2=>,feed_pred_traces=>1},
									#occurrences=>[],
									#authorities=>[],
									#opinions=>[],
									#reidentifications=>[]
									);
	$self->{_setFields} = \%SET_FIELDS_BY_TABLE_NAME;
}

sub isOfTypeSet
{
	my $self = shift;
	my $fieldName = shift;
	
	# If this field is of type 'set', get the correct value
	my %table_hash = %{$self->{_setFields}{$self->getTableName()}};

	if($table_hash{$fieldName})
	{
		return 1;
	}
{'fraction_non_alphanumeric': 0.19647277227722773, 'fraction_numerical': 0.005878712871287129, 'mean_word_length': 4.479661016949152, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 81, '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': '3360637', 'n_tokens_mistral': 1420, 'n_tokens_neox': 1277, 'n_words': 241}