197 |
sub StoreAttributeKey { |
sub StoreAttributeKey { |
198 |
# Get the parameters. |
# Get the parameters. |
199 |
my ($entityName, $attributeName, $type, $notes) = @_; |
my ($entityName, $attributeName, $type, $notes) = @_; |
200 |
|
# Declare the return variable. |
201 |
|
my $retVal; |
202 |
# Get the data type hash. |
# Get the data type hash. |
203 |
my %types = ERDB::GetDataTypes(); |
my %types = ERDB::GetDataTypes(); |
204 |
# Validate the initial input values. |
# Validate the initial input values. |
219 |
# Okay, we're ready to begin. Get the entity hash and the field hash. |
# Okay, we're ready to begin. Get the entity hash and the field hash. |
220 |
my $entityData = $entityHash->{$entityName}; |
my $entityData = $entityHash->{$entityName}; |
221 |
my $fieldHash = ERDB::GetEntityFieldHash($metadata, $entityName); |
my $fieldHash = ERDB::GetEntityFieldHash($metadata, $entityName); |
222 |
|
# Compare the old attribute data to the new data. |
223 |
|
my $bigChange = 1; |
224 |
|
if (exists $fieldHash->{$attributeName} && $fieldHash->{$attributeName}->{type} eq $type) { |
225 |
|
$bigChange = 0; |
226 |
|
} |
227 |
# Compute the attribute's relation name. |
# Compute the attribute's relation name. |
228 |
my $relName = join("", $entityName, map { ucfirst $_ } split(/-|_/, $attributeName)); |
my $relName = join("", $entityName, map { ucfirst $_ } split(/-|_/, $attributeName)); |
229 |
# Store the attribute's field data. Note the use of the "content" hash for |
# Store the attribute's field data. Note the use of the "content" hash for |
239 |
} |
} |
240 |
# Write the XML back out. |
# Write the XML back out. |
241 |
ERDB::WriteMetaXML($metadata, $FIG_Config::attrDBD); |
ERDB::WriteMetaXML($metadata, $FIG_Config::attrDBD); |
|
} |
|
242 |
# Open a database with the new XML. |
# Open a database with the new XML. |
243 |
my $retVal = CustomAttributes->new(); |
$retVal = CustomAttributes->new(); |
244 |
|
# Create the table if there has been a significant change. |
245 |
|
if ($bigChange) { |
246 |
|
$retVal->CreateTable($relName); |
247 |
|
} |
248 |
|
} |
249 |
return $retVal; |
return $retVal; |
250 |
} |
} |
251 |
|
|