chg: [clusterRelations:view_relations] Attached referencing relations

pull/6120/head
mokaddem 2020-05-08 09:17:37 +02:00
parent 7328eb1ebd
commit d61e864a1e
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
4 changed files with 46 additions and 7 deletions

View File

@ -831,8 +831,8 @@ class GalaxyClustersController extends AppController
}
$cluster = $cluster[0];
$existingRelations = $this->GalaxyCluster->GalaxyClusterRelation->getExistingRelationships();
$cluster = $this->GalaxyCluster->attachReferencingRelations($this->Auth->user(), $cluster);
$cluster = $this->GalaxyCluster->attachClusterToRelations($this->Auth->user(), $cluster);
debug($existingRelations);
$treeRight = array(array(
'GalaxyCluster' => $cluster['GalaxyCluster'],
@ -849,7 +849,20 @@ class GalaxyClustersController extends AppController
$treeRight[0]['children'][] = $tmp;
}
$treeLeft = array();
$treeLeft = array(array(
'GalaxyCluster' => $cluster['GalaxyCluster'],
'children' => array()
));
foreach($cluster['ReferencingGalaxyClusterRelation'] as $relation) {
$tmp = array(
'Relation' => array_diff_key($relation, array_flip(array('GalaxyCluster'))),
'children' => array(
array('GalaxyCluster' => $relation['GalaxyCluster']),
)
);
$treeLeft[0]['children'][] = $tmp;
}
$tree = array(
'right' => $treeRight,
'left' => $treeLeft,

View File

@ -1399,6 +1399,7 @@ class AppModel extends Model
`tag_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
// TODO: ADD INDEXES
break;
case 'fixNonEmptySharingGroupID':
$sqlArray[] = 'UPDATE `events` SET `sharing_group_id` = 0 WHERE `distribution` != 4;';

View File

@ -579,7 +579,7 @@ class GalaxyCluster extends AppModel
public function attachClusterToRelations($user, $cluster)
{
if (isset($cluster['GalaxyClusterRelation'])) {
if (!empty($cluster['GalaxyClusterRelation'])) {
foreach ($cluster['GalaxyClusterRelation'] as $k => $relation) {
$conditions = array('conditions' => array('GalaxyCluster.id' => $relation['referenced_galaxy_cluster_id']));
$relatedCluster = $this->fetchGalaxyClusters($user, $conditions, false);
@ -588,6 +588,28 @@ class GalaxyCluster extends AppModel
}
}
}
if (!empty($cluster['ReferencingGalaxyClusterRelation'])) {
foreach ($cluster['ReferencingGalaxyClusterRelation'] as $k => $relation) {
$conditions = array('conditions' => array('GalaxyCluster.id' => $relation['galaxy_cluster_id']));
$relatedCluster = $this->fetchGalaxyClusters($user, $conditions, false);
if (!empty($relatedCluster)) {
$cluster['ReferencingGalaxyClusterRelation'][$k]['GalaxyCluster'] = $relatedCluster[0]['GalaxyCluster'];
}
}
}
return $cluster;
}
public function attachReferencingRelations($user, $cluster)
{
$referencingRelations = $this->GalaxyClusterRelation->fetchRelations($user, array('conditions' => array(
'referenced_galaxy_cluster_id' => $cluster['GalaxyCluster']['id']
)));
if (!empty($referencingRelations)) {
foreach ($referencingRelations as $k => $relation) {
$cluster['ReferencingGalaxyClusterRelation'][] = $relation['GalaxyClusterRelation'];
}
}
return $cluster;
}
}

View File

@ -52,8 +52,6 @@ echo $this->element('genericElements/assetLoader', array(
<script>
var treeData = <?= json_encode($tree) ?>;
var treeRight = treeData.right;
var treeLeft = treeData.left;
var margin = {top: 10, right: 10, bottom: 10, left: 20};
var treeWidth, treeHeight;
var colors = d3.scale.category10();
@ -121,11 +119,16 @@ echo $this->element('genericElements/assetLoader', array(
}
function buildTree() {
// drawTree(treeData.right, false);
drawTree(treeData.left, true);
}
function drawTree(data, orientationLeft) {
var $tree = $('#treeSVG');
treeWidth = $tree.width() - margin.right - margin.left;
treeHeight = $tree.height() - margin.top - margin.bottom;
var tree = d3.layout.tree(treeRight)
var tree = d3.layout.tree(data)
.size([treeHeight, treeWidth]);
var diagonal = function link(d) {
@ -141,7 +144,7 @@ echo $this->element('genericElements/assetLoader', array(
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var root = treeRight[0];
var root = data[0];
root.isRoot = true;
root.x0 = treeHeight / 2;
root.y0 = 0;