diff --git a/js/source/legacy/brapi/PedigreeViewer.js b/js/source/legacy/brapi/PedigreeViewer.js index 6e37f00fc1..ad913baf07 100644 --- a/js/source/legacy/brapi/PedigreeViewer.js +++ b/js/source/legacy/brapi/PedigreeViewer.js @@ -84,27 +84,46 @@ function PedigreeViewer(server,auth,version,urlFunc){ }).map(function(ped_pro_germId){ var mother = null, father = null; - if(ped_pro_germId[0].parent1Type=="FEMALE"){ - mother = ped_pro_germId[0].parent1DbId; - } - if(ped_pro_germId[0].parent1Type=="MALE"){ - father = ped_pro_germId[0].parent1DbId; - } - if(ped_pro_germId[0].parent2Type=="FEMALE"){ - mother = ped_pro_germId[0].parent2DbId; - } - if(ped_pro_germId[0].parent2Type=="MALE"){ - father = ped_pro_germId[0].parent2DbId; + + if(version=='v1.3'){ + if(ped_pro_germId[0].parent1Type=="FEMALE"){ + mother = ped_pro_germId[0].parent1DbId; + } + if(ped_pro_germId[0].parent1Type=="MALE"){ + father = ped_pro_germId[0].parent1DbId; + } + if(ped_pro_germId[0].parent2Type=="FEMALE"){ + mother = ped_pro_germId[0].parent2DbId; + } + if(ped_pro_germId[0].parent2Type=="MALE"){ + father = ped_pro_germId[0].parent2DbId; + } + return { + 'id':ped_pro_germId[2], + 'mother_id':mother, + 'father_id':father, + 'name':ped_pro_germId[1].defaultDisplayName, + 'children':ped_pro_germId[1].progeny.filter(Boolean).map(function(d){ + return d.germplasmDbId; + }) + }; + } else { + var i = ped_pro_germId[0].parents.map(function(e) { return e.parentType; }).indexOf('FEMALE'); + var j = ped_pro_germId[0].parents.map(function(e) { return e.parentType; }).indexOf('MALE'); + + if(i>=0) mother = ped_pro_germId[0].parents[i].germplasmDbId; + if(j>=0) father = ped_pro_germId[0].parents[j].germplasmDbId; + + return { + 'id':ped_pro_germId[2], + 'mother_id':mother, + 'father_id':father, + 'name':ped_pro_germId[1].germplasmName, + 'children':ped_pro_germId[1].progeny.filter(Boolean).map(function(d){ + return d.germplasmDbId; + }) + }; } - return { - 'id':ped_pro_germId[2], - 'mother_id':mother, - 'father_id':father, - 'name':ped_pro_germId[1].defaultDisplayName, - 'children':ped_pro_germId[1].progeny.filter(Boolean).map(function(d){ - return d.germplasmDbId; - }) - }; }).each(function(node){ loaded_nodes[node.id] = node; }).all(callback); diff --git a/js/source/legacy/d3/d3-pedigree-tree.js b/js/source/legacy/d3/d3-pedigree-tree.js index 7cbc51122e..ae291b7af0 100644 --- a/js/source/legacy/d3/d3-pedigree-tree.js +++ b/js/source/legacy/d3/d3-pedigree-tree.js @@ -30,11 +30,11 @@ function pdgtree(){ //create working nodes from input data (we dont want to modify the input) - + var node_list = _wrap_nodes(data); node_list.forEach(function(d){_setNodeLevels(d);}); _setBestRootNodeLevels(node_list); - + //create intermediate nodes for intergenerational links var intermediates = {}; for (var n = node_list.length-1; n > -1; n--) { diff --git a/lib/CXGN/BrAPI/v2/Germplasm.pm b/lib/CXGN/BrAPI/v2/Germplasm.pm index 686302fb7d..fec3ea5c5f 100644 --- a/lib/CXGN/BrAPI/v2/Germplasm.pm +++ b/lib/CXGN/BrAPI/v2/Germplasm.pm @@ -334,8 +334,6 @@ sub germplasm_pedigree { }; } $cross_plan = $cross_type; - $mother = $female_parent_name ? $female_parent_name : "NA"; - $father = $male_parent_name ? $male_parent_name : "NA"; } #Cross information @@ -368,18 +366,24 @@ sub germplasm_pedigree { } } - my $parent = [ - { - germplasmDbId=>qq|$female_parent_stock_id|, + #Add parents: + my $parent = []; + if ($female_parent_stock_id){ + push @$parent, { + germplasmDbId=>$female_parent_stock_id ? qq|$female_parent_stock_id| : $female_parent_stock_id , germplasmName=>$mother, parentType=>'FEMALE', - }, - { - germplasmDbId=>qq|$male_parent_stock_id|, + }; + } + if ($male_parent_stock_id){ + push @$parent, { + germplasmDbId=>$male_parent_stock_id ? qq|$male_parent_stock_id| : $male_parent_stock_id, germplasmName=>$father, parentType=>'MALE', - }, - ]; + } + + } + %result = ( crossingProjectDbId=>$membership_info[0][0], crossingYear=>$membership_info[0][5], diff --git a/mason/pedigree/stock_pedigree.mas b/mason/pedigree/stock_pedigree.mas index dbec743539..08684aa574 100644 --- a/mason/pedigree/stock_pedigree.mas +++ b/mason/pedigree/stock_pedigree.mas @@ -215,7 +215,7 @@ $stock_id (function() { 'use strict'; var STOCK_ID = "<% $stock_id %>"; - var base_url="/brapi/v1"; + var base_url="/brapi/v2"; var auth_token; var require_login = "<% $c->get_conf('brapi_require_login') %>"; if (require_login === '1'){ @@ -225,7 +225,7 @@ $stock_id } } - var pdg = PedigreeViewer(base_url,auth_token,'v1.3',function(dbId){ + var pdg = PedigreeViewer(base_url,auth_token,'v2.0',function(dbId){ return "/stock/"+dbId+"/view"; }); pdg.newTree(STOCK_ID,function(){