diff --git a/js/source/entries/mixedmodels.js b/js/source/entries/mixedmodels.js index be743b3738..7eec211a6c 100644 --- a/js/source/entries/mixedmodels.js +++ b/js/source/entries/mixedmodels.js @@ -11,7 +11,7 @@ export function init(main_div) { var dataset_id; - alert("WELCOME TO MIXED MODELS!"); + // alert("WELCOME TO MIXED MODELS!"); get_select_box("datasets", "mixed_model_dataset_select", { "checkbox_name": "mixed_model_dataset_select_checkbox" }); jQuery('#mixed_model_analysis_prepare_button').removeClass('active').addClass('inactive'); diff --git a/lib/CXGN/Dataset.pm b/lib/CXGN/Dataset.pm index d48f618267..b46f0010ad 100644 --- a/lib/CXGN/Dataset.pm +++ b/lib/CXGN/Dataset.pm @@ -54,6 +54,7 @@ use Moose; use Moose::Util::TypeConstraints; use Data::Dumper; use JSON::Any; +use JSON::XS; use CXGN::BreederSearch; use CXGN::People::Schema; use CXGN::Phenotypes::PhenotypeMatrix; @@ -448,7 +449,7 @@ sub set_dataset_public { if ($@) { return "An error occurred, $@"; } else { - return undef; + return; } } } @@ -474,7 +475,7 @@ sub set_dataset_private { if ($@) { return "An error occurred, $@"; } else { - return undef; + return; } } } @@ -1258,7 +1259,7 @@ sub delete { if ($@) { return "An error occurred, $@"; } else { - return undef; + return; } } @@ -1280,11 +1281,41 @@ sub update_description { if ($@) { return "An error occurred, $@"; } else { - return undef; + return; } } } +=head2 get_child_analyses() + +# Retrieves the list of analyses that use this dataset. + +=cut + +sub get_child_analyses { + my $self = shift; + my $dataset_id = $self->sp_dataset_id(); + + my $dbh = $self->schema->storage->dbh(); + + my $analysis_info_type_id = SGN::Model::Cvterm->get_cvterm_row($self->schema, 'analysis_metadata_json', 'project_property')->cvterm_id(); + + my $analysis_q = "select DISTINCT project.name, project.project_id FROM projectprop + JOIN project USING (project_id) + WHERE projectprop.type_id=$analysis_info_type_id + AND analysisinfo.value::json->>'dataset_id'=?;"; + my $h = $dbh->prepare($analysis_q); + $h->execute($dataset_id); + + my @html = (); + + while (my ($analysis_name, $analysis_id) = $h->fetchrow_array()){ + push @html, "".$analysis_name.""; + } + + return join(" | ", @html); +} + 1; diff --git a/lib/SGN/Controller/AJAX/Dataset.pm b/lib/SGN/Controller/AJAX/Dataset.pm index c2c55c5515..3fe477fa9c 100644 --- a/lib/SGN/Controller/AJAX/Dataset.pm +++ b/lib/SGN/Controller/AJAX/Dataset.pm @@ -356,6 +356,38 @@ sub get_dataset :Path('/ajax/dataset/get') Args(1) { $c->stash->{rest} = { dataset => $dataset_data }; } +sub get_child_analyses :Path('/ajax/dataset/get_child_analyses') Args(1) { + my $self = shift; + my $c = shift; + my $dataset_id = shift; + + my $sp_person_id = $c->user() ? $c->user->get_object()->get_sp_person_id() : undef; + + my $dataset = CXGN::Dataset->new( + { + schema => $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id), + people_schema => $c->dbic_schema("CXGN::People::Schema", undef, $sp_person_id), + sp_dataset_id=> $dataset_id, + }); + + my $analysis_list; + eval { + $analysis_list = $dataset->get_child_analyses(); + }; + + if ($@){ + $c->stash->{rest} = {error => "Error retrieving analyses using this dataset. $@"}; + } + + if ($analysis_list eq "") { + $analysis_list = "(none)"; + } + + print STDERR "Got the following list of accessions using this dataset: $analysis_list \n"; + + $c->stash->{rest} = { analysis_html_list => $analysis_list }; +} + sub retrieve_dataset_dimension :Path('/ajax/dataset/retrieve') Args(2) { my $self = shift; diff --git a/mason/analyses/analysis_details.mas b/mason/analyses/analysis_details.mas index b30cce5d3c..047d574b37 100644 --- a/mason/analyses/analysis_details.mas +++ b/mason/analyses/analysis_details.mas @@ -75,10 +75,10 @@ $analysis_metadata -