chg: [galaxyCluster:pull] Pull clusters before events and added support of published state

pull/6120/head
mokaddem 2020-06-25 10:47:54 +02:00
parent e5346f20a0
commit f4b003e01e
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 14 additions and 11 deletions

View File

@ -507,6 +507,7 @@ class GalaxyCluster extends AppModel
$results['errors'][] = $validationError[0]; $results['errors'][] = $validationError[0];
} }
} }
$results['success'] = $results['imported'] > 0;
return $results; return $results;
} }
@ -881,7 +882,7 @@ class GalaxyCluster extends AppModel
} }
$simpleParams = array( $simpleParams = array(
'uuid', 'galaxy_id', 'version', 'distribution', 'type', 'value', 'default', 'extends_uuid', 'tag_name' 'uuid', 'galaxy_id', 'version', 'distribution', 'type', 'value', 'default', 'extends_uuid', 'tag_name', 'published'
); );
foreach ($simpleParams as $k => $simpleParam) { foreach ($simpleParams as $k => $simpleParam) {
if (isset($filters[$simpleParam])) { if (isset($filters[$simpleParam])) {
@ -1424,6 +1425,7 @@ class GalaxyCluster extends AppModel
} else { } else {
$fails[$clusterId] = __('failed downloading the galaxy cluster'); $fails[$clusterId] = __('failed downloading the galaxy cluster');
} }
return true;
} }
public function downloadGalaxyClusterFromServer($clusterId, $server, $HttpSocket=null) public function downloadGalaxyClusterFromServer($clusterId, $server, $HttpSocket=null)

View File

@ -2648,6 +2648,15 @@ class Server extends AppModel
)); ));
return !empty($errors[$eventIds['error'][0]]) ? $errors[$eventIds['error'][0]] : __('Unknown issue.'); return !empty($errors[$eventIds['error'][0]]) ? $errors[$eventIds['error'][0]] : __('Unknown issue.');
} }
$pulledClusters = 0;
if (!empty($server['Server']['pull_galaxy_clusters'])) {
$this->GalaxyCluster = ClassRegistry::init('GalaxyCluster');
$pulledClusters = $this->GalaxyCluster->pullGalaxyClusters($user, $server, $technique);
if ($jobId) {
$job->saveField('progress', 10);
$job->saveField('message', 'Pulling galaxy clusters.');
}
}
$successes = array(); $successes = array();
$fails = array(); $fails = array();
// now process the $eventIds to pull each of the events sequentially // now process the $eventIds to pull each of the events sequentially
@ -2657,7 +2666,7 @@ class Server extends AppModel
$this->__pullEvent($eventId, $successes, $fails, $eventModel, $server, $user, $jobId, $force); $this->__pullEvent($eventId, $successes, $fails, $eventModel, $server, $user, $jobId, $force);
if ($jobId) { if ($jobId) {
if ($k % 10 == 0) { if ($k % 10 == 0) {
$job->saveField('progress', 50 * (($k + 1) / count($eventIds))); $job->saveField('progress', 10 + 40 * (($k + 1) / count($eventIds)));
} }
} }
} }
@ -2688,15 +2697,6 @@ class Server extends AppModel
$job->saveField('message', 'Pulling sightings.'); $job->saveField('message', 'Pulling sightings.');
} }
$pulledSightings = $eventModel->Sighting->pullSightings($user, $server); $pulledSightings = $eventModel->Sighting->pullSightings($user, $server);
$pulledClusters = 0;
if (isset($server['Server']['pull_galaxy_clusters']) && $server['Server']['pull_galaxy_clusters']) {
if ($jobId) {
$job->saveField('progress', 90);
$job->saveField('message', 'Pulling galaxy clusters.');
}
$this->GalaxyCluster = ClassRegistry::init('GalaxyCluster');
$pulledClusters = $this->GalaxyCluster->pullGalaxyClusters($user, $server, $technique);
}
if ($jobId) { if ($jobId) {
$job->saveField('progress', 100); $job->saveField('progress', 100);
$job->saveField('message', 'Pull completed.'); $job->saveField('message', 'Pull completed.');
@ -2783,6 +2783,7 @@ class Server extends AppModel
$HttpSocket = $this->setupHttpSocket($server, $HttpSocket); $HttpSocket = $this->setupHttpSocket($server, $HttpSocket);
$request = $this->setupSyncRequest($server); $request = $this->setupSyncRequest($server);
$uri = $url . '/galaxy_clusters/restSearch'; $uri = $url . '/galaxy_clusters/restSearch';
$filter_rules['published'] = 1;
$filter_rules['minimal'] = 1; $filter_rules['minimal'] = 1;
$filter_rules['custom'] = 1; $filter_rules['custom'] = 1;