Skip to content

Commit

Permalink
Merge pull request #5131 from solgenomics/topic/fix_observationUnitPUI
Browse files Browse the repository at this point in the history
fix the observationUnitPUI url in the BrAPI observationunits call
  • Loading branch information
lukasmueller authored Oct 1, 2024
2 parents c6525c0 + 2cdf291 commit be9c4ba
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
28 changes: 24 additions & 4 deletions lib/CXGN/BrAPI/v2/ObservationUnits.pm
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ sub _search {
$data_level = ['all'];
}
}
my $page_obj = CXGN::Page->new();
my $main_production_site_url = $page_obj->get_hostname();
my $main_production_site_url = $c->config->{main_production_site_url};

my $lt = CXGN::List::Transform->new();

Expand Down Expand Up @@ -186,31 +185,52 @@ sub _search {
$additional_info = $additional_info_json ? decode_json($additional_info_json) : undef;
}

my $entry_type = $obs_unit->{is_a_control} ? 'check' : 'test';
my %numbers;

my $entry_type = $obs_unit->{is_a_control} ? 'check' : 'test';
$numbers{entry_type} = $entry_type;

my $replicate = $obs_unit->{rep};
$numbers{replicate} = $replicate;

my $block = $obs_unit->{block};
$numbers{block} = $block;

my $plot;

my $plant;

my $family_stock_id;

my $family_name;

## Following code lines add observationUnitParent to additionalInfo, useful for BI
if ($obs_unit->{obsunit_type_name} eq 'plant') {
$plant = $obs_unit->{plant_number};

$numbers{plant} = $plant;

if ($plant_parents{$obs_unit->{obsunit_stock_id}}) {
my $plot_object = $plant_parents{$obs_unit->{obsunit_stock_id}};
$plot = $plot_object->{plot_number};

$numbers{plot} = $plot;

$additional_info->{observationUnitParent} = $plot_object->{id};
}
} else {
$plot = $obs_unit->{plot_number};
$numbers{plot} = $plot;
}

## Format position coordinates
my $level_name = $obs_unit->{obsunit_type_name};

print STDERR "LEVEL NAME: ".Dumper(\%numbers);

my $level_order = _order($level_name) + 0;
my $level_code = eval "\$$level_name" || "";

my $level_code = $numbers{$level_name}; ###### eval "\$$level_name" || "";

if ( $level_order_arrayref && ! grep { $_ eq $level_order } @{$level_order_arrayref} ) { next; }
if ( $level_code_arrayref && ! grep { $_ eq $level_code } @{$level_code_arrayref} ) { next; }
Expand Down
Loading

0 comments on commit be9c4ba

Please sign in to comment.