diff --git a/lib/CXGN/BrAPI/v2/ObservationUnits.pm b/lib/CXGN/BrAPI/v2/ObservationUnits.pm index a2752f699d..9d289f4750 100644 --- a/lib/CXGN/BrAPI/v2/ObservationUnits.pm +++ b/lib/CXGN/BrAPI/v2/ObservationUnits.pm @@ -858,21 +858,7 @@ sub _refresh_matviews { my $bs = CXGN::BreederSearch->new( { dbh=>$dbh, dbname=>$c->config->{dbname}, } ); # Refresh materialized view so data can be retrieved - my $refresh = $bs->refresh_matviews($c->config->{dbhost}, $c->config->{dbname}, $c->config->{dbuser}, $c->config->{dbpass}, 'phenotypes', 'concurrent', $c->config->{basepath}); - # Wait until materialized view is reset. Wait 5 minutes total, then throw an error - my $refreshing = 1; - my $refresh_time = 0; - while ($refreshing && $refresh_time < $timeout) { - my $refresh_status = $bs->matviews_status(); - if (!$refresh->{connection}->alive) { - $refreshing = 0; - } elsif ($refresh_time >= $timeout) { - return {error => CXGN::BrAPI::JSONResponse->return_error($self->status, "Refreshing materialized views is taking too long to return a response", 500)}; - } else { - sleep 1; - $refresh_time += 1; - } - } + $bs->refresh_matviews($c->config->{dbhost}, $c->config->{dbname}, $c->config->{dbuser}, $c->config->{dbpass}, 'phenotypes', 'concurrent', $c->config->{basepath}, 0); } sub _order { diff --git a/lib/CXGN/List/Validate/Plugin/Traits.pm b/lib/CXGN/List/Validate/Plugin/Traits.pm index d20e397423..b89fd54eb5 100644 --- a/lib/CXGN/List/Validate/Plugin/Traits.pm +++ b/lib/CXGN/List/Validate/Plugin/Traits.pm @@ -13,6 +13,7 @@ sub validate { my $schema = shift; my $list = shift; my $validator = shift; + my $context = SGN::Context->new; my @missing; my @wrong_ids; @@ -27,6 +28,9 @@ sub validate { my @parts = split (/\|/ , $term); my ($db_name, $accession) = split ":", pop @parts; my $trait_name = join '|', @parts; + if(!$context->get_conf('list_trait_require_id')) { + $trait_name = $term; + } $accession =~ s/\s+$//; $accession =~ s/^\s+//; @@ -35,16 +39,27 @@ sub validate { $trait_name =~ s/\s+$//; $trait_name =~ s/^\s+//; + print STDERR $db_name."\n"; + print STDERR $trait_name."\n"; + if (!$context->get_conf('list_trait_require_id') && ($db_name eq '' || $db_name eq $trait_name)) { + $db_name = $context->get_conf('trait_ontology_db_name'); + } + my $db_rs = $schema->resultset("General::Db")->search( { 'me.name' => $db_name }); if ($db_rs->count() == 0) { - #print STDERR "Problem found with term $term at db $db_name\n"; + print STDERR "Problem found with term $term at db $db_name\n"; push @missing, $term; } else { my $db = $db_rs->first(); my $query = { 'dbxref.db_id' => $db->db_id(), - 'dbxref.accession' => $accession, }; + + if (!$context->get_conf('list_trait_require_id') && $accession eq '') { + $query->{'me.name'} = $trait_name; + } else { + $query->{'dbxref.accession'} = $accession; + } if ( $db_name eq 'COMP' && $validator->{composable_validation_check_name} ) { $query->{'me.name'} = $trait_name; } @@ -52,13 +67,13 @@ sub validate { my $is_missing = 0; if ($rs->count == 0) { - #print STDERR "Problem found with term $term at cvterm rs from accession $accession point 2\n"; + print STDERR "Problem found with term $term at cvterm rs from accession $accession point 2\n"; push @missing, $term; $is_missing = 1; } else { my $rs_var = $rs->search_related('cvterm_relationship_subjects', {'type.name' => 'VARIABLE_OF'}, { 'join' => 'type'}); if ($rs_var->count == 0) { - #print STDERR "Problem found with term $term at variable check point 3\n"; + print STDERR "Problem found with term $term at variable check point 3\n"; push @missing, $term; $is_missing = 1; } @@ -89,7 +104,7 @@ sub validate { } } - # print STDERR Dumper \@missing; + print STDERR Dumper \@missing; print STDERR Dumper \@wrong_ids; return { missing => \@missing, diff --git a/sgn.conf b/sgn.conf index 44a07516fd..744653f381 100644 --- a/sgn.conf +++ b/sgn.conf @@ -79,6 +79,8 @@ allow_repeat_measures 0 #export trait names as synonyms (1) or the original trait name (0) fieldbook_trait_synonym 1 +list_trait_require_id 1 + # Cluster backend backend Slurm