Since assets are always created with defaults now, no need to introspect. Also, remove white space in "empty" lines.

This commit is contained in:
Colin Kuskie 2010-01-13 11:15:25 -08:00
parent 2aefb5d316
commit bf097ac337

View file

@ -104,15 +104,15 @@ sub addRevision {
else { else {
$workingTag = WebGUI::VersionTag->getWorking($session); $workingTag = WebGUI::VersionTag->getWorking($session);
} }
#Create a dummy revision to be updated with real data later #Create a dummy revision to be updated with real data later
$session->db->beginTransaction; $session->db->beginTransaction;
my $sql = "insert into assetData" my $sql = "insert into assetData"
. " (assetId, revisionDate, revisedBy, tagId, status, url, ownerUserId, groupIdEdit, groupIdView)" . " (assetId, revisionDate, revisedBy, tagId, status, url, ownerUserId, groupIdEdit, groupIdView)"
. " values (?, ?, ?, ?, 'pending', ?, '3','3','7')" . " values (?, ?, ?, ?, 'pending', ?, '3','3','7')"
; ;
$session->db->write($sql,[ $session->db->write($sql,[
$self->getId, $self->getId,
$now, $now,
@ -120,17 +120,7 @@ sub addRevision {
$workingTag->getId, $workingTag->getId,
$self->getId, $self->getId,
]); ]);
my %defaults = ();
# get the default values of each property
foreach my $property ($self->meta->get_all_properties) {
$defaults{$property} = $property->form->{defaultValue};
#if (ref($defaults{$property}) eq 'ARRAY' && !$definition->{serialize}) {
if (ref($defaults{$property}) eq 'ARRAY') {
$defaults{$property} = $defaults{$property}->[0];
}
}
# prime the tables # prime the tables
foreach my $table ($self->meta->get_tables) { foreach my $table ($self->meta->get_tables) {
unless ($table eq "assetData") { unless ($table eq "assetData") {
@ -138,10 +128,10 @@ sub addRevision {
} }
} }
$session->db->commit; $session->db->commit;
# merge the defaults, current values, and the user set properties # current values, and the user set properties
my %mergedProperties = (%defaults, %{$self->get}, %{$properties}, (status => 'pending')); my %mergedProperties = (%{$self->get}, %{$properties}, (status => 'pending'));
# Force the packed head block to be regenerated # Force the packed head block to be regenerated
delete $mergedProperties{extraHeadTagsPacked}; delete $mergedProperties{extraHeadTagsPacked};
@ -152,7 +142,7 @@ sub addRevision {
$newVersion->setVersionLock; $newVersion->setVersionLock;
$newVersion->update(\%mergedProperties); $newVersion->update(\%mergedProperties);
$newVersion->setAutoCommitTag($workingTag) if (defined $autoCommitId); $newVersion->setAutoCommitTag($workingTag) if (defined $autoCommitId);
return $newVersion; return $newVersion;
} }
@ -401,7 +391,7 @@ sub moveAssetToVersionTag {
$self->setVersionTag($moveToTagId); $self->setVersionTag($moveToTagId);
my $versionTag = $self->session->db->quickScalar("SELECT tagId FROM assetData WHERE assetId=? AND revisionDate=?",[$self->getId,$self->get('revisionDate')]); my $versionTag = $self->session->db->quickScalar("SELECT tagId FROM assetData WHERE assetId=? AND revisionDate=?",[$self->getId,$self->get('revisionDate')]);
# If no revisions remain, delete the version tag # If no revisions remain, delete the version tag
if ( $tag->getRevisionCount <= 0 ) { if ( $tag->getRevisionCount <= 0 ) {
$tag->rollback; $tag->rollback;