chg: [galaxyCluster:view] Arrange data before exporting

pull/6120/head
mokaddem 2020-06-09 11:39:31 +02:00
parent be7ef90366
commit 79d3a47e5a
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
3 changed files with 14 additions and 6 deletions

View File

@ -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') {

View File

@ -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);

View File

@ -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)
{