<commit_before><commit_msg>Refactoring of SqlDataTypeReference<commit_after>package Alatar::Model::Refs::SqlDataTypeReference;

use strict;
use Alatar::Model::SqlReference;
use Alatar::Model::SqlColumn;
use Alatar::Model::SqlFunction;
use Alatar::Model::SqlCursor;

our @ISA = qw(Alatar::Model::SqlReference);

sub new {
	my ($class,$owner,$name) = @_;
	my $this = $class->SUPER::new($owner,$name);
	$this->addBasicDataTypeIfNotExists();
 	bless($this,$class);
 	return $this;            
}

sub isSqlDataTypeReference {
	my ($this) = @_;
	return 1;
}

sub getObjectType {
	my ($this) = @_;
	return 'SqlDataTypeReference';
}

# setters and getters
sub setName {
	my ($this,$name) = @_;
	$this->SUPER::setName($name);
	$this->{name} =~ s/\(.*?\)//g;
	$this->{name} =~ s/\[.*?\]//g;
	$this->{name} = lc($this->{name});
}

# action

# If not yet referenced, the basic datatype (INTEGER, VARCHAR, etc.) is added to 
# the collection of database's objects
sub addBasicDataTypeIfNotExists {
	my ($this) = @_;
	my $database = $this->getOwner()->getDatabaseReference();
	my @datatypeObjects = $database->getSqlDataTypes();
	my $found = grep { $_->getName() eq $this->{name} } @datatypeObjects;
	if(!$found) {
		$database->addObject(Alatar::Model::SqlDataType->new($database,$this->{name}));
	}
}

1;
{'fraction_non_alphanumeric': 0.1967467079783114, 'fraction_numerical': 0.001549186676994578, 'mean_word_length': 5.364532019704433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '3420520', 'n_tokens_mistral': 471, 'n_tokens_neox': 467, 'n_words': 93}