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 - Dataset ID + Dataset
-% print $analysis_metadata->dataset_id; +% print "dataset_id.">".$analysis_metadata->dataset_id."";
@@ -111,4 +111,4 @@ $analysis_metadata <& /util/barcode.mas, identifier => "$identifier_prefix"."$trial_id", trial_id=> "$trial_id", trial_name=> "$trial_name", format=>"trial_qrcode" &> - + \ No newline at end of file diff --git a/mason/analyses/model_details.mas b/mason/analyses/model_details.mas index e392dd83e4..368afaccc9 100644 --- a/mason/analyses/model_details.mas +++ b/mason/analyses/model_details.mas @@ -73,6 +73,7 @@ jQuery(document).ready(function(){ jQuery('#model_name').html(""+response.model_info.model_name+""); jQuery('#model_description').html(response.model_info.model_description); jQuery('#model_type').html(response.model_info.model_type_name); + jQuery('#analysis_dataset_id').html(""+response.dataset.dataset_name+""); var model_properties_string = ''; for (var key in response.model_info.model_properties) { diff --git a/mason/dataset/index.mas b/mason/dataset/index.mas index df32ccc697..04634aeb16 100644 --- a/mason/dataset/index.mas +++ b/mason/dataset/index.mas @@ -99,6 +99,7 @@ $dataset_contents => '' % } Select Dataset in Wizard<% $wizard_link %> + Analyses using this dataset @@ -249,6 +250,21 @@ $dataset_contents => '' window.open(url,'_blank'); }) + + jQuery.ajax({ + type: 'GET', + url: '/ajax/dataset/get_child_analyses/<% $dataset_id %>', + success: function(response) { + if (response.error){ + alert(response.error); + } else { + jQuery('#dataset_analysis_usage').html(response.analysis_html_list); + } + }, + error: function(response) { + alert("Error retrieving analyses using this dataset."); + } + }); }); diff --git a/t/selenium2/breeders/breeder_search.t b/t/selenium2/breeders/breeder_search.t index ff6bda2814..80d16855e0 100644 --- a/t/selenium2/breeders/breeder_search.t +++ b/t/selenium2/breeders/breeder_search.t @@ -2,7 +2,7 @@ use strict; use lib 't/lib'; -use Test::More 'tests' => 110; +use Test::More 'tests' => 113; use SGN::Test::WWW::WebDriver; use Selenium::Remote::WDKeys 'KEYS'; @@ -390,6 +390,17 @@ $t->while_logged_in_as("submitter", sub { ok($selected_reloaded_elements =~ /IITA-TMS-IBA011412/, "Verify first column wizard, selected elements, after merging $fourth_list_name and two new elements: accession IITA-TMS-IBA011412"); ok($selected_reloaded_elements =~ /IITA-TMS-IBA30572/, "Verify first column wizard, selected elements, after merging $fourth_list_name and two new elements: accession IITA-TMS-IBA30572"); + # TEST WORKING MIXED MODEL AND DETAILS PAGE FOR DATASET 1 + $t->get_ok('/search/datasets'); + sleep(1); + + $t->find_element_ok("//a[text()='$dataset_name_1']",'xpath','checking for created dataset on dataset overview page')->click(); + sleep(5); + + my $child_analyses = $t->find_element('dataset_analysis_usage', 'id')->get_text(); + ok($child_analyses eq "(none)", 'checking initial analysis usage'); + sleep(1); + # DELETE DATASET $t->get_ok('/breeders/search'); sleep(3);