diff --git a/app/Controller/GalaxiesController.php b/app/Controller/GalaxiesController.php index 498a7c6ba..a69d8f497 100644 --- a/app/Controller/GalaxiesController.php +++ b/app/Controller/GalaxiesController.php @@ -243,6 +243,9 @@ class GalaxiesController extends AppController ); $clusters = $this->Galaxy->GalaxyCluster->fetchGalaxyClusters($this->Auth->user(),$options, $full=true); $clusters = $this->Galaxy->GalaxyCluster->unsetFieldsForExport($clusters); + foreach ($clusters as $k => $cluster) { + $clusters[$k] = $this->Galaxy->GalaxyCluster->arrangeDataForExport($cluster); + } $content = json_encode($clusters, JSON_PRETTY_PRINT); $this->response->body($content); if ($this->request->data['download'] == 'download') { diff --git a/app/Controller/GalaxyClustersController.php b/app/Controller/GalaxyClustersController.php index 435b90c8c..247501dd0 100644 --- a/app/Controller/GalaxyClustersController.php +++ b/app/Controller/GalaxyClustersController.php @@ -206,13 +206,8 @@ class GalaxyClustersController extends AppController throw new NotFoundException('Cluster not found.'); } if ($this->_isRest()) { - $models = array('Galaxy', 'GalaxyElement', 'GalaxyClusterRelation', 'Org', 'Orgc', 'TargettingClusterRelation'); - foreach ($models as $model) { - $cluster['GalaxyCluster'][$model] = $cluster[$model]; - unset($cluster[$model]); - } + $cluster = $this->GalaxyCluster->arrangeDataForExport($cluster); return $this->RestResponse->viewData($cluster, $this->response->type()); - // return $this->RestResponse->viewData(array('GalaxyCluster' => $cluster['GalaxyCluster']), $this->response->type()); } else { $cluster = $this->GalaxyCluster->attachExtendByInfo($this->Auth->user(), $cluster); $cluster = $this->GalaxyCluster->attachExtendFromInfo($this->Auth->user(), $cluster); diff --git a/app/Model/GalaxyCluster.php b/app/Model/GalaxyCluster.php index 1d3c73544..cdfb7eaa0 100644 --- a/app/Model/GalaxyCluster.php +++ b/app/Model/GalaxyCluster.php @@ -156,6 +156,16 @@ class GalaxyCluster extends AppModel $this->GalaxyClusterRelation->deleteAll(array('GalaxyClusterRelation.galaxy_cluster_uuid' => $this->uuid)); } + public function arrangeDataForExport($cluster) + { + $models = array('Galaxy', 'GalaxyElement', 'GalaxyClusterRelation', 'Org', 'Orgc', 'TargettingClusterRelation'); + foreach ($models as $model) { + $cluster['GalaxyCluster'][$model] = $cluster[$model]; + unset($cluster[$model]); + } + return $cluster; + } + // Respecting ACL, save a cluster, its elements and set correct fields public function saveCluster($user, $cluster, $allowEdit=false) {