diff --git a/js/source/legacy/CXGN/Transformation.js b/js/source/legacy/CXGN/Transformation.js new file mode 100644 index 0000000000..22fe02d8d3 --- /dev/null +++ b/js/source/legacy/CXGN/Transformation.js @@ -0,0 +1,30 @@ +function deleteTransformationID(transformation_stock_id){ + + const confirmation = confirm('Are you sure you want to delete this transformation ID? The deletion cannot be undone.'); + + if (confirmation) { + jQuery.ajax({ + url: '/ajax/transformation/delete', + data: {'transformation_stock_id' : transformation_stock_id}, + method: 'POST', + destroy: true, + beforeSend: function(response) { + jQuery('#working_modal').modal('show'); + }, + success: function(response) { + jQuery('#working_modal').modal('hide'); + if (response.success == 1) { + alert('Deletion was successful'); + location.reload(); + } + if (response.error) { + alert(response.error); + } + }, + error: function(response) { + jQuery('#working_modal').modal('hide'); + alert('An error occurred during deletion'); + } + }); + } +} diff --git a/lib/CXGN/Transformation/Transformation.pm b/lib/CXGN/Transformation/Transformation.pm index 22b4964412..2a1a3aa614 100644 --- a/lib/CXGN/Transformation/Transformation.pm +++ b/lib/CXGN/Transformation/Transformation.pm @@ -41,6 +41,27 @@ has 'transformation_stock_id' => ( is => 'rw', ); +has 'transformants' => ( + isa => 'ArrayRef|Undef', + is => 'rw', + lazy => 1, + builder => '_get_transformants', +); + +has 'obsoleted_transformants' => ( + isa => 'ArrayRef|Undef', + is => 'rw', + lazy => 1, + builder => '_get_obsoleted_transformants', +); + +has 'tracking_identifier' => ( + isa => 'ArrayRef|Undef', + is => 'rw', + lazy => 1, + builder => '_get_tracking_identifier', +); + sub get_active_transformations_in_project { my $self = shift; @@ -121,7 +142,7 @@ sub get_inactive_transformations_in_project { } -sub get_transformants { +sub _get_transformants { my $self = shift; my $schema = $self->schema(); my $transformation_stock_id = $self->transformation_stock_id(); @@ -143,11 +164,11 @@ sub get_transformants { push @transformants, [$stock_id, $stock_name] } - return \@transformants; + $self->transformants(\@transformants); } -sub get_obsoleted_transformants { +sub _get_obsoleted_transformants { my $self = shift; my $schema = $self->schema(); my $transformation_stock_id = $self->transformation_stock_id(); @@ -171,7 +192,8 @@ sub get_obsoleted_transformants { push @obsoleted_transformants, [$stock_id, $stock_name, $obsolete_note, $obsolete_date, $sp_person_id] } - return \@obsoleted_transformants; + $self->obsoleted_transformants(\@obsoleted_transformants); + } @@ -241,7 +263,7 @@ sub get_associated_projects { } -sub get_tracking_identifier { +sub _get_tracking_identifier { my $self = shift; my $schema = $self->schema(); my $transformation_stock_id = $self->transformation_stock_id(); @@ -256,12 +278,13 @@ sub get_tracking_identifier { $h->execute($material_of_type_id, $transformation_stock_id); - my @tracking_identifiers = (); + my @tracking_identifier_info = (); while (my ($stock_id, $stock_name) = $h->fetchrow_array()){ - push @tracking_identifiers, [$stock_id, $stock_name] + push @tracking_identifier_info, [$stock_id, $stock_name] } - return \@tracking_identifiers; + $self->tracking_identifier(\@tracking_identifier_info); + } @@ -311,6 +334,114 @@ sub get_default_plant_material { } +sub delete { + my $self = shift; + my $schema = $self->schema(); + my $dbh = $self->schema()->storage()->dbh(); + my $transformation_stock_id = $self->transformation_stock_id(); + my $tracking_identifier = $self->tracking_identifier(); + my $transformants = $self->transformants(); + my $number_of_transformants = scalar(@$transformants); + my $obsoleted_transformants = $self->obsoleted_transformants(); + my $number_of_obsoleted_transformants = scalar(@$obsoleted_transformants); + + eval { + $dbh->begin_work(); + + my $transformation_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, "transformation", "stock_type")->cvterm_id(); + my $tracking_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, "tracking_identifier", "stock_type")->cvterm_id(); + my $transformation_experiment_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'transformation_experiment', 'experiment_type')->cvterm_id(); + my $tracking_experiment_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'tracking_activity', 'experiment_type')->cvterm_id(); + + if (($number_of_transformants > 0) || ($number_of_obsoleted_transformants > 0)) { + die "Transformation ID has associated transformants. Cannot delete.\n"; + } + + my $transformation_rs = $schema->resultset("Stock::Stock")->find ({stock_id => $transformation_stock_id, type_id => $transformation_type_id}); + if (!$transformation_rs) { + die "This stock id is not a transformation ID. Cannot delete.\n"; + } + + my $transformation_experiment_id; + my $nd_q = "SELECT nd_experiment.nd_experiment_id FROM nd_experiment_stock + JOIN nd_experiment ON (nd_experiment_stock.nd_experiment_id = nd_experiment.nd_experiment_id) + WHERE nd_experiment.type_id = ? AND nd_experiment_stock.stock_id = ?"; + + my $nd_h = $schema->storage->dbh()->prepare($nd_q); + $nd_h->execute($transformation_experiment_type_id, $transformation_stock_id); + my @nd_experiment_ids= $nd_h->fetchrow_array(); + if (scalar @nd_experiment_ids == 1) { + $transformation_experiment_id = $nd_experiment_ids[0]; + } else { + die "Error retrieving experiment id"; + } + + #delete the nd_experiment_md_files entries + my $md_files_q = "DELETE FROM phenome.nd_experiment_md_files WHERE nd_experiment_id = ?"; + my $md_files_h = $schema->storage->dbh()->prepare($md_files_q); + $md_files_h->execute($transformation_experiment_id); + + # delete the nd_experiment entries + my $q2= "delete from nd_experiment where nd_experiment.nd_experiment_id = ? AND nd_experiment.type_id = ?"; + my $h2 = $dbh->prepare($q2); + $h2->execute($transformation_experiment_id, $transformation_experiment_type_id); + + # delete stock owner entries + # + my $q3 = "delete from phenome.stock_owner where stock_id=?"; + my $h3 = $dbh->prepare($q3); + $h3->execute($transformation_stock_id); + + # delete the stock entries + my $q4 = "delete from stock where stock.stock_id=? and stock.type_id = ?"; + my $h4 = $dbh->prepare($q4); + $h4->execute($transformation_stock_id, $transformation_type_id); + + #if linking with tracking tool, delete tracking identifier entry + if (scalar @$tracking_identifier > 0) { + my $tracking_experiment_id; + my $tracking_stock_id = $tracking_identifier->[0]->[0]; + my $tracking_nd_q = "SELECT nd_experiment.nd_experiment_id FROM nd_experiment_stock + JOIN nd_experiment ON (nd_experiment_stock.nd_experiment_id = nd_experiment.nd_experiment_id) + WHERE nd_experiment.type_id = ? AND nd_experiment_stock.stock_id = ?"; + + my $tracking_nd_h = $schema->storage->dbh()->prepare($tracking_nd_q); + $tracking_nd_h->execute($tracking_experiment_type_id, $tracking_stock_id); + my @tracking_nd_experiment_ids= $tracking_nd_h->fetchrow_array(); + if (scalar @tracking_nd_experiment_ids == 1) { + $tracking_experiment_id = $tracking_nd_experiment_ids[0]; + } else { + die "Error retrieving experiment id"; + } + + # delete the tracking nd_experiment entries + my $tracking_q2= "delete from nd_experiment where nd_experiment.nd_experiment_id = ? AND nd_experiment.type_id = ?"; + my $tracking_h2 = $dbh->prepare($tracking_q2); + $tracking_h2->execute($tracking_experiment_id, $tracking_experiment_type_id); + + # delete tracking stock owner entries + my $tracking_q3 = "delete from phenome.stock_owner where stock_id=?"; + my $tracking_h3 = $dbh->prepare($tracking_q3); + $tracking_h3->execute($tracking_stock_id); + + # delete the tracking stock entries + my $tracking_q4 = "delete from stock where stock.stock_id=? and stock.type_id = ?"; + my $tracking_h4 = $dbh->prepare($tracking_q4); + $h4->execute($tracking_stock_id, $tracking_type_id); + } + }; + + if ($@) { + print STDERR "An error occurred while deleting transformation id ".$transformation_stock_id."$@\n"; + $dbh->rollback(); + return $@; + } else { + $dbh->commit(); + return 0; + } +} + + ### 1; ### diff --git a/lib/SGN/Controller/AJAX/TrackingActivity.pm b/lib/SGN/Controller/AJAX/TrackingActivity.pm index 5cd0480851..5935b49ee6 100644 --- a/lib/SGN/Controller/AJAX/TrackingActivity.pm +++ b/lib/SGN/Controller/AJAX/TrackingActivity.pm @@ -469,7 +469,7 @@ sub get_activity_summary :Path('/ajax/tracking_activity/summary') :Args(1) { my $obsoleted_transformant_count; if ($material_stock_type eq 'transformation') { my $transformation_obj = CXGN::Transformation::Transformation->new({schema=>$schema, dbh=>$dbh, transformation_stock_id=>$material_stock_id}); - my $obsoleted_transformants = $transformation_obj->get_obsoleted_transformants(); + my $obsoleted_transformants = $transformation_obj->obsoleted_transformants(); if ($obsoleted_transformants) { $obsoleted_transformant_count = scalar @$obsoleted_transformants; } @@ -652,26 +652,19 @@ sub update_status_POST : Args(0) { return; } - my @user_roles = $c->user->roles(); - my %has_roles = (); - map { $has_roles{$_} = 1; } @user_roles; - - if (! ( (exists($has_roles{$program_name}) && exists($has_roles{submitter})) || exists($has_roles{curator}))) { - $c->stash->{rest} = { error => "You need to be either a curator, or a submitter associated with breeding program $program_name to update status." }; - return; - } - my $user_id = $c->user()->get_object()->get_sp_person_id(); my $tracking_identifier_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, "tracking_identifier", 'stock_type')->cvterm_id(); my $transformation_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, "transformation", 'stock_type')->cvterm_id(); - my $identifier_rs = $schema->resultset("Stock::Stock")->find( { stock_id => $identifier_id, type_id => $tracking_identifier_type_id }); - if (!$identifier_rs) { - $c->stash->{rest} = { error_string => 'Error. No tracking identifier entry found in the database.' }; - return; - } else { - push @stocks_to_update, $identifier_id; + if ($identifier_id ne 'NA') { + my $identifier_rs = $schema->resultset("Stock::Stock")->find( { stock_id => $identifier_id, type_id => $tracking_identifier_type_id }); + if (!$identifier_rs) { + $c->stash->{rest} = { error_string => 'Error. No tracking identifier entry found in the database.' }; + return; + } else { + push @stocks_to_update, $identifier_id; + } } my $material_stock_type_id; @@ -739,15 +732,6 @@ sub reverse_status_POST : Args(0) { return; } - my @user_roles = $c->user->roles(); - my %has_roles = (); - map { $has_roles{$_} = 1; } @user_roles; - - if (! ( (exists($has_roles{$program_name}) && exists($has_roles{submitter})) || exists($has_roles{curator}))) { - $c->stash->{rest} = { error => "You need to be either a curator, or a submitter associated with breeding program $program_name to update status." }; - return; - } - my $user_id = $c->user()->get_object()->get_sp_person_id(); my $status_type_id; diff --git a/lib/SGN/Controller/AJAX/Transformation.pm b/lib/SGN/Controller/AJAX/Transformation.pm index c349292bfc..9bb2be6045 100644 --- a/lib/SGN/Controller/AJAX/Transformation.pm +++ b/lib/SGN/Controller/AJAX/Transformation.pm @@ -47,8 +47,8 @@ sub add_transformation_project_POST :Args(0){ my $project_description = $c->req->param('project_description'); $project_name =~ s/^\s+|\s+$//g; - if (!$c->user()){ - $c->stash->{rest} = {error => "You need to be logged in to add a transformation project."}; + if (!$c->user()) { + $c->res->redirect( uri( path => '/user/login', query => { goto_url => $c->req->uri->path_query } ) ); return; } @@ -163,8 +163,8 @@ sub add_transformation_identifier_POST :Args(0){ my $transformation_project_id = $c->req->param('transformation_project_id'); $transformation_identifier =~ s/^\s+|\s+$//g; - if (!$c->user()){ - $c->stash->{rest} = {error => "You need to be logged in to add a transformation ID."}; + if (!$c->user()) { + $c->res->redirect( uri( path => '/user/login', query => { goto_url => $c->req->uri->path_query } ) ); return; } @@ -423,9 +423,8 @@ sub get_active_transformations_in_project :Path('/ajax/transformation/active_tra foreach my $r (@$result){ my ($transformation_id, $transformation_name, $plant_id, $plant_name, $vector_id, $vector_name, $notes, $status_type) =@$r; my $transformation_obj = CXGN::Transformation::Transformation->new({schema=>$schema, dbh=>$dbh, transformation_stock_id=>$transformation_id}); - my $transformants = $transformation_obj->get_transformants(); + my $transformants = $transformation_obj->transformants(); my $number_of_transformants = scalar(@$transformants); - push @transformations, [qq{$transformation_name}, qq{$plant_name}, qq{$vector_name}, $notes, $number_of_transformants]; } @@ -454,7 +453,7 @@ sub get_inactive_transformation_ids_in_project :Path('/ajax/transformation/inact $status_type = ''.'COMPLETED'.''; } my $transformation_obj = CXGN::Transformation::Transformation->new({schema=>$schema, dbh=>$dbh, transformation_stock_id=>$transformation_id}); - my $transformants = $transformation_obj->get_transformants(); + my $transformants = $transformation_obj->transformants(); my $number_of_transformants = scalar(@$transformants); push @transformations, [qq{$transformation_name}, $status_type, qq{$plant_name}, qq{$vector_name}, $notes, $number_of_transformants]; @@ -480,8 +479,8 @@ sub add_transformants_POST :Args(0){ my $program_name = $c->req->param('program_name'); my $source_info = $c->req->param('source_info'); - if (!$c->user()){ - $c->stash->{rest} = {error => "You need to be logged in to add new transformants."}; + if (!$c->user()) { + $c->res->redirect( uri( path => '/user/login', query => { goto_url => $c->req->uri->path_query } ) ); return; } @@ -548,7 +547,7 @@ sub add_transformants_POST :Args(0){ my $tracking_transformation = $c->config->{tracking_transformation}; if ($tracking_transformation) { my $transformation_obj = CXGN::Transformation::Transformation->new({schema=>$schema, dbh=>$dbh, transformation_stock_id=>$transformation_stock_id}); - my $tracking_identifier = $transformation_obj->get_tracking_identifier(); + my $tracking_identifier = $transformation_obj->tracking_identifier(); my $tracking_identifier_name = $tracking_identifier->[0]->[1]; my $time = DateTime->now(); @@ -587,9 +586,10 @@ sub add_transformants_using_list_POST : Args(0) { my $program_name = $c->req->param("program_name"); if (!$c->user()) { - $c->stash->{rest} = { error_string => "You must be logged in to add new transformants." }; + $c->res->redirect( uri( path => '/user/login', query => { goto_url => $c->req->uri->path_query } ) ); return; } + if (!($c->user()->has_role('submitter') or $c->user()->has_role('curator'))) { $c->stash->{rest} = { error_string => "You do not have sufficient privileges to add new transformants." }; return; @@ -676,7 +676,7 @@ sub get_transformants :Path('/ajax/transformation/transformants') :Args(1) { my $transformation_obj = CXGN::Transformation::Transformation->new({schema=>$schema, dbh=>$dbh, transformation_stock_id=>$transformation_stock_id}); - my $result = $transformation_obj->get_transformants(); + my $result = $transformation_obj->transformants(); my @transformants; foreach my $r (@$result){ @@ -701,7 +701,7 @@ sub get_obsoleted_transformants :Path('/ajax/transformation/obsoleted_transforma my $transformation_obj = CXGN::Transformation::Transformation->new({schema=>$schema, dbh=>$dbh, transformation_stock_id=>$transformation_stock_id}); - my $result = $transformation_obj->get_obsoleted_transformants(); + my $result = $transformation_obj->obsoleted_transformants(); my @obsoleted_transformants; foreach my $r (@$result){ @@ -733,8 +733,8 @@ sub set_autogenerated_name_format_POST :Args(0){ my $name_format = $c->req->param('name_format'); my $program_name = $c->req->param('program_name'); - if (!$c->user()){ - $c->stash->{rest} = {error => "You need to be logged in to set autogenerated name format."}; + if (!$c->user()) { + $c->res->redirect( uri( path => '/user/login', query => { goto_url => $c->req->uri->path_query } ) ); return; } @@ -786,8 +786,8 @@ sub set_default_plant_material_POST :Args(0){ my $default_plant_material_name = $c->req->param('default_plant_material'); my $program_name = $c->req->param('program_name'); - if (!$c->user()){ - $c->stash->{rest} = {error => "You need to be logged in to add new autogenerated name info."}; + if (!$c->user()) { + $c->res->redirect( uri( path => '/user/login', query => { goto_url => $c->req->uri->path_query } ) ); return; } @@ -859,8 +859,8 @@ sub add_autogenerated_name_metadata_POST :Args(0){ my $time = DateTime->now(); my $date = $time->ymd(); - if (!$c->user()){ - $c->stash->{rest} = {error => "You need to be logged in to add new autogenerated name metadata."}; + if (!$c->user()) { + $c->res->redirect( uri( path => '/user/login', query => { goto_url => $c->req->uri->path_query } ) ); return; } @@ -906,6 +906,89 @@ sub add_autogenerated_name_metadata_POST :Args(0){ } +sub get_all_transformation_ids_in_project :Path('/ajax/transformation/all_transformation_ids_in_project') :Args(1) { + my $self = shift; + my $c = shift; + my $project_id = shift; + my $schema = $c->dbic_schema("Bio::Chado::Schema"); + my $dbh = $c->dbc->dbh; + + my $transformation_obj = CXGN::Transformation::Transformation->new({schema=>$schema, dbh=>$dbh, project_id=>$project_id}); + + my $active_transformations = $transformation_obj->get_active_transformations_in_project(); + my $inactive_transformations = $transformation_obj->get_inactive_transformations_in_project(); + + my @transformations; + foreach my $active_id (@$active_transformations){ + my $transformation_id = $active_id->[0]; + my $transformation_name = $active_id->[1]; + my $status_type = 'ACTIVE'; + my $transformation_obj = CXGN::Transformation::Transformation->new({schema=>$schema, dbh=>$dbh, transformation_stock_id=>$transformation_id}); + my $transformants = $transformation_obj->transformants(); + my $number_of_transformants = scalar(@$transformants); + push @transformations, { + transformation_id => $transformation_id, + transformation_name => $transformation_name, + status_type => $status_type, + number_of_transformants => $number_of_transformants + }; + } + + foreach my $inactive_id (@$inactive_transformations){ + my $transformation_id = $inactive_id->[0]; + my $transformation_name = $inactive_id->[1]; + my $status_type = $inactive_id->[7]; + my $status_display; + if ($status_type eq 'completed_metadata') { + $status_display = 'COMPLETED'; + } elsif ($status_type eq 'terminated_metadata') { + $status_display = 'TERMINATED'; + } + my $transformation_obj = CXGN::Transformation::Transformation->new({schema=>$schema, dbh=>$dbh, transformation_stock_id=>$transformation_id}); + my $transformants = $transformation_obj->transformants(); + my $number_of_transformants = scalar(@$transformants); + push @transformations, { + transformation_id => $transformation_id, + transformation_name => $transformation_name, + status_type => $status_display, + number_of_transformants => $number_of_transformants + }; + } + + $c->stash->{rest} = { data => \@transformations }; + +} + + +sub delete_transformation_id : Path('/ajax/transformation/delete') : ActionClass('REST') {} + +sub delete_transformation_id_POST :Args(0){ + my ($self, $c) = @_; + my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado'); + my $dbh = $c->dbc->dbh; + my $transformation_stock_id = $c->req->param('transformation_stock_id'); + + if (!$c->user()) { + $c->res->redirect( uri( path => '/user/login', query => { goto_url => $c->req->uri->path_query } ) ); + return; + } + + if (!$c->user()->check_roles("curator")) { + $c->stash->{rest} = { error => "You do not have the correct role to delete transformation ID. Please contact us." }; + $c->detach(); + } + + my $transformation_obj = CXGN::Transformation::Transformation->new({schema=>$schema, dbh=>$dbh, transformation_stock_id=>$transformation_stock_id}); + my $error = $transformation_obj->delete(); + + if ($error) { + $c->stash->{rest} = { error => "An error occurred attempting to delete the transformation ID. ($@)" }; + return; + } + + $c->stash->{rest} = { success => 1 }; +} + ### 1;# diff --git a/lib/SGN/Controller/ActivityInfo.pm b/lib/SGN/Controller/ActivityInfo.pm index edbd55b248..13b8c8305f 100644 --- a/lib/SGN/Controller/ActivityInfo.pm +++ b/lib/SGN/Controller/ActivityInfo.pm @@ -124,7 +124,8 @@ sub activity_details :Path('/activity/details') : Args(1) { $c->stash->{project_id} = $tracking_project_id; $c->stash->{activity_type} = $activity_type; $c->stash->{program_name} = $program_name; - $c->stash->{source_info} = $source_info_string; + $c->stash->{source_info} = $source_info_string; + $c->stash->{stock_type_page} = 'tracking_id'; $c->stash->{template} = '/tracking_activities/activity_info_details.mas'; } diff --git a/lib/SGN/Controller/Transformation.pm b/lib/SGN/Controller/Transformation.pm index 6cceb7b193..73385a159d 100644 --- a/lib/SGN/Controller/Transformation.pm +++ b/lib/SGN/Controller/Transformation.pm @@ -17,6 +17,17 @@ sub transformation_page : Path('/transformation') Args(1) { my $id = shift; my $schema = $c->dbic_schema("Bio::Chado::Schema"); my $dbh = $c->dbc->dbh; + my $user_role; + + if (! $c->user()) { + $c->res->redirect( uri( path => '/user/login', query => { goto_url => $c->req->uri->path_query } ) ); + return; + } + + if ($c->user() && $c->user()->check_roles("curator")) { + $user_role = "curator"; + } + my $transformation_stock_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'transformation', 'stock_type')->cvterm_id(); my $transformation = $schema->resultset("Stock::Stock")->find( { stock_id => $id, type_id => $transformation_stock_type_id } ); @@ -34,6 +45,15 @@ sub transformation_page : Path('/transformation') Args(1) { my $transformation_obj = CXGN::Transformation::Transformation->new({schema=>$schema, dbh=>$dbh, transformation_stock_id=>$transformation_id}); my $info = $transformation_obj->get_transformation_info(); + my $transformants = $transformation_obj->transformants(); + my $number_of_transformants = scalar(@$transformants); + my $obsoleted_transformants = $transformation_obj->obsoleted_transformants(); + my $number_of_obsoleted_transformants = scalar(@$obsoleted_transformants); + my $has_associated_transformants; + if (($number_of_transformants > 0) || ($number_of_obsoleted_transformants > 0)) { + $has_associated_transformants = 1; + } + my $plant_material_id = $info->[0]->[0]; my $plant_material_name = $info->[0]->[1]; my $vector_id = $info->[0]->[2]; @@ -45,11 +65,12 @@ sub transformation_page : Path('/transformation') Args(1) { my $updated_status_type = $info->[0]->[5]; my $completed_metadata; my $terminated_metadata; + my $status_display; if ($updated_status_type eq 'terminated_metadata') { - $updated_status_type = ''.'TERMINATED'.''; + $status_display = ''.'TERMINATED'.''; $terminated_metadata = 1; } elsif ($updated_status_type eq 'completed_metadata') { - $updated_status_type = ''.'COMPLETED'.''; + $status_display = ''.'COMPLETED'.''; $completed_metadata = 1; } @@ -79,12 +100,17 @@ sub transformation_page : Path('/transformation') Args(1) { my $name_format = $transformation_project->get_autogenerated_name_format(); my $identifier_link; + my $identifier_id; + my $identifier_name; my $tracking_transformation = $c->config->{tracking_transformation}; if ($tracking_transformation) { - my $tracking_info = $transformation_obj->get_tracking_identifier(); - my $identifier_id = $tracking_info->[0]->[0]; - my $identifier_name = $tracking_info->[0]->[1]; + my $tracking_info = $transformation_obj->tracking_identifier(); + $identifier_id = $tracking_info->[0]->[0]; + $identifier_name = $tracking_info->[0]->[1]; $identifier_link = qq{$identifier_name}; + } else { + $identifier_id = 'NA'; + $identifier_name = 'NA'; } my $source_info_hash = {}; @@ -103,12 +129,21 @@ sub transformation_page : Path('/transformation') Args(1) { $c->stash->{updated_status_type} = $updated_status_type; $c->stash->{updated_status_string} = $updated_status_string; $c->stash->{user_id} = $c->user ? $c->user->get_object()->get_sp_person_id() : undef; + $c->stash->{user_role} = $user_role; $c->stash->{identifier_link} = $identifier_link; $c->stash->{project_link} = $project_link; $c->stash->{program_id} = $program_id; $c->stash->{program_name} = $program_name; $c->stash->{name_format} = $name_format; $c->stash->{source_info} = $source_info_string; + $c->stash->{stock_type_page} = 'transformation_id'; + $c->stash->{identifier_id} = $identifier_id; + $c->stash->{identifier_name} = $identifier_name; + $c->stash->{material_id} = $transformation_id; + $c->stash->{material_name} = $transformation_name; + $c->stash->{status_display} = $status_display; + $c->stash->{has_associated_transformants} = $has_associated_transformants; + $c->stash->{template} = '/transformation/transformation.mas'; } diff --git a/mason/tracking_activities/activity_info_details.mas b/mason/tracking_activities/activity_info_details.mas index 2da4e2f4a8..67b76800cd 100644 --- a/mason/tracking_activities/activity_info_details.mas +++ b/mason/tracking_activities/activity_info_details.mas @@ -18,6 +18,7 @@ $status_display => undef $user_role $project_id $activity_type +$stock_type_page $source_info => undef %args> @@ -166,10 +167,11 @@ $source_info => undef