$identifier, 'title' => $wpsProcess['title'], 'description' => $wpsProcess['description'] ]; }, $wpsProcessList, array_keys($wpsProcessList)); return $wpsProcessList; } static function getUserWpsProcess($identifier, $userLogin = null) { // TODO: $userLogin $defaultWpsProcessList = self::getDefaultWpsProcessList(); if (array_key_exists($identifier, $defaultWpsProcessList)) return Type_WpsProcess::build( $defaultWpsProcessList[$identifier] ); // TODO: fetch from DB - `CRM_#CACHE_ACL_FUNCTIONS` or object like UrlActions throw new Exception("Forbidden - wps function not exists or access denied", 403); } static function getDefaultWpsProcessList() { $defaultWpsProcessList = []; { $selectFeatureBase = [ 'dataInputs' => [ [ 'maxOccurs' => "1", 'minOccurs' => "1", 'identifier' => 'typeName', 'title' => "Feature typeName", 'description' => "Feature typeName eg. default_db/PROBLEMS", 'type' => 'literal', ], [ 'maxOccurs' => "unbounded", 'minOccurs' => "1", 'identifier' => 'primaryKey', 'title' => "Feature primaryKey", 'description' => "Feature primaryKey", 'type' => 'literal', ], ], // 'MimeType' => text/xml, 'Encoding' => base64, 'Schema' => http://foo.bar/gml/3.1.0/polygon.xsd 'defaultOutput' => [ 'MimeType' => "text/xml; subtype=wfs-collection/1.0" ], // TODO: result type - like Insert Wfs Transaction result - list of: Success (primaryKey = 123), ... 'supportedOutput' => [ [ 'MimeType' => "text/xml; subtype=wfs-collection/1.0" ], [ 'MimeType' => "text/xml; subtype=wfs-collection/1.1" ], [ 'MimeType' => "application/json" ], // [ 'MimeType' => "application/wfs-collection-1.0" ], // [ 'MimeType' => "application/wfs-collection-1.1" ], // [ 'MimeType' => "application/zip" ], ] ]; $defaultWpsProcessList['p5:selectFeature'] = array_merge([ 'title' => "Select feature", 'descriptin' => "Select feature (set attribute @selected to true)" ], $selectFeatureBase); $defaultWpsProcessList['p5:unselectFeature'] = array_merge([ 'title' => "Unselect feature", 'descriptin' => "Unselect feature (set attribute @selected to false)" ], $selectFeatureBase); } array_walk($defaultWpsProcessList, function (&$wpsFunction, $identifier) { $wpsFunction['identifier'] = $identifier; }); return $defaultWpsProcessList; } static function validateProcessArgs($wpsProcess, $args) { foreach ($wpsProcess->dataInputs as $input) { $identifier = $input->identifier; // TODO: required? minOccurs > 0 if ($input->minOccurs > 0 && empty($args[ $identifier ])) throw new Api_OwsException("Missing value for '{$identifier}'", 501, null, 'MissingParameterValue', 'request'); $totalValues = count($args[ $identifier ]); if ($totalValues > 1) { if ( 'unbounded' !== $input->maxOccurs && $totalValues > $input->maxOccurs ) { throw new Api_OwsException("Too many values for '{$identifier}'", 501, null, 'TooManyParameterValues', 'request'); } } // TODO: validate values with type definition - _xsdType } } static function executeProcess($wpsProcess, $args, $responseForm = 'json') { $className = implode("_", array_merge( [ 'Api', 'Process', ], array_map('ucfirst', explode(':', $wpsProcess->identifier)) ) ); if (!Lib::tryLoadClass($className)) { throw new Api_OwsException("Api Process not found '{$wpsProcess->identifier}'", 500, null, 'ApiProcessNotFound', 'request'); } $className::run($args, $responseForm); } }