Skip to content

Commit d2eac49

Browse files
committed
UPDATE: 'map' managing for processes
1 parent 0d6f8f9 commit d2eac49

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

wps/controllers/processes_exec_rest.classic.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @license https://www.mozilla.org/MPL/ Mozilla Public Licence
1010
*/
1111

12+
use LizmapApi\Utils;
1213
use LizmapWPS\WPS\Authenticator;
1314
use LizmapWPS\WPS\Error;
1415
use LizmapWPS\WPS\RequestHandler;
@@ -18,7 +19,7 @@
1819
class processes_exec_restCtrl extends RestApiCtrl
1920
{
2021
/**
21-
* Create a job thanks to a processID and a Map.
22+
* Create a job thanks to a processID and a Map with a repository and a project.
2223
*
2324
* @return jResponseJson|object the response object containing information about the job created
2425
*/
@@ -32,17 +33,22 @@ public function post(): object
3233
}
3334

3435
$processID = $this->param('processid');
35-
$map = $this->param('map');
36+
$repository = $this->param('repository');
37+
$project = $this->param('project');
3638
$data = $this->request->getBody();
3739

3840
try {
3941
if ($processID != null) {
42+
$repositoryObject = lizmap::getRepository($repository);
43+
if (is_null($repositoryObject)) {
44+
throw new \Exception('No repository "'.$repository.'" found', 404);
45+
}
46+
$path = Utils::getLastPartPath($repositoryObject->getOriginalPath());
4047
$url = UrlServerUtil::retrieveServerURL('pygiswps_server_url').
4148
'processes/'.
4249
$processID.
4350
'/execution'.
44-
'?map='.
45-
$map;
51+
'?map='.$path.$project.'.qgs';
4652
$response = RequestHandler::curlRequestPOST($url, $data);
4753
} else {
4854
$response = Error::setJSONError($rep, '400', 'Process id not found.');

wps/controllers/processes_rest.classic.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @license https://www.mozilla.org/MPL/ Mozilla Public Licence
1010
*/
1111

12+
use LizmapApi\Utils;
1213
use LizmapWPS\WPS\Authenticator;
1314
use LizmapWPS\WPS\Error;
1415
use LizmapWPS\WPS\RequestHandler;
@@ -20,6 +21,7 @@ class processes_restCtrl extends RestApiCtrl
2021
/**
2122
* Retrieves all processes.
2223
* If a specific processID is set, return it.
24+
* Optionals 'repository' and 'project' to build map path.
2325
*
2426
* @return jResponseJson|object the response object containing processes information
2527
*/
@@ -34,13 +36,19 @@ public function get(): object
3436

3537
$url = UrlServerUtil::retrieveServerURL('pygiswps_server_url').'processes';
3638
$processID = $this->param('processid');
37-
$map = $this->param('map');
39+
$repository = $this->param('repository');
40+
$project = $this->param('project');
3841

3942
try {
4043
if ($processID != null) {
4144
$url = $url.'/'.$processID;
42-
if ($map != null) {
43-
$url = $url.'?map='.$map;
45+
if ($repository != null && $project != null) {
46+
$repositoryObject = lizmap::getRepository($repository);
47+
if (is_null($repositoryObject)) {
48+
throw new \Exception('No repository "'.$repository.'" found', 404);
49+
}
50+
$path = Utils::getLastPartPath($repositoryObject->getOriginalPath());
51+
$url = $url.'?map='.$path.$project.'.qgs';
4452
}
4553
$response = RequestHandler::curlRequestGET($url);
4654
} else {

0 commit comments

Comments
 (0)