$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 = []; $wpsArgTypeName = [ 'minOccurs' => "1", 'maxOccurs' => "1", // 1 arg is required 'identifier' => 'typeName', 'title' => "Feature typeName", 'description' => "Feature typeName eg.: 'default_db/PROBLEMS'", 'dataType' => 'literal', 'xsdType' => 'p5:typeName', ]; $wpsArgPrimaryKey = [ 'minOccurs' => "1", 'maxOccurs' => "unbounded", // min 1 arg is required 'identifier' => 'primaryKey', 'title' => "Feature primaryKey", 'description' => "Feature primaryKey", 'dataType' => 'literal', 'xsdType' => 'p5:primaryKey', ]; $wpsArgRemoteTypeName = [ 'minOccurs' => "1", 'maxOccurs' => "1", // 1 arg is required 'identifier' => 'remoteTypeName', 'title' => "Remote Feature typeName", 'description' => "Remote Feature typeName eg.: 'default_db/PROBLEMS'", 'dataType' => 'literal', 'xsdType' => 'p5:typeName', ]; $wpsArgRemotePrimaryKey = [ 'minOccurs' => "1", 'maxOccurs' => "unbounded", // min 1 arg is required 'identifier' => 'remotePrimaryKey', 'title' => "Remote Feature primaryKey", 'description' => "Remote Feature primaryKey", 'dataType' => 'literal', 'xsdType' => 'p5:primaryKey', ]; { // Selected Feature $selectFeatureArgFilterQuery = [ 'minOccurs' => "0", 'maxOccurs' => "1", // optional max 1 arg 'identifier' => 'filterQuery', 'title' => "Query string", 'description' => "Query string eg.: 'f_ID=123&sf_Msgs=NEW_MSGS'", 'dataType' => 'literal', 'xsdType' => 'p5:queryString', ]; $selectFeatureBase = [ 'dataInputs' => [ $wpsArgTypeName, $wpsArgPrimaryKey, ], // 'MimeType' => text/xml, 'Encoding' => base64, 'Schema' => http://foo.bar/gml/3.1.0/polygon.xsd 'defaultOutput' => [ 'MimeType' => "application/json" ], // TODO: result type - like Insert Wfs Transaction result - list of: Success (primaryKey = 123), ... 'supportedOutput' => [ [ 'MimeType' => "application/json" ], [ 'MimeType' => "text/xml; subtype=wfs-collection/1.0" ], [ 'MimeType' => "text/xml; subtype=wfs-collection/1.1" ], // [ '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); $defaultWpsProcessList['p5:getSelectedFeatures'] = array_merge([ 'title' => "Get selected features", 'descriptin' => "Get list of selected features (with attribute @selected = true)" ], $selectFeatureBase); $defaultWpsProcessList['p5:unselectAllFeatures'] = array_merge([ 'title' => "Unselect all features", 'descriptin' => "Unselect all features (set attribute @selected to false)" ], $selectFeatureBase, [ 'dataInputs' => [ $wpsArgTypeName, ] ]); $defaultWpsProcessList['p5:selectAllFeaturesMatchingFilter'] = array_merge([ 'title' => "Select all features matching filter" ], $selectFeatureBase, [ 'dataInputs' => [ $wpsArgTypeName, array_merge($wpsArgPrimaryKey, [ 'minOccurs' => 0 ]), // optional arg $selectFeatureArgFilterQuery, ] ]); } { // Relations (ref's) $wpsArgTypeName = [ 'minOccurs' => "1", 'maxOccurs' => "1", // 1 arg is required 'identifier' => 'typeName', 'title' => "Feature typeName", 'description' => "Feature typeName eg.: 'default_db/PROBLEMS'", 'dataType' => 'literal', 'xsdType' => 'p5:typeName', ]; $relationsBase = [ 'dataInputs' => [ $wpsArgTypeName, array_merge($wpsArgPrimaryKey, [ 'maxOccurs' => 1 ]), $wpsArgRemoteTypeName, $wpsArgRemotePrimaryKey, ], // 'MimeType' => text/xml, 'Encoding' => base64, 'Schema' => http://foo.bar/gml/3.1.0/polygon.xsd 'defaultOutput' => [ 'MimeType' => "application/json" ], 'supportedOutput' => [ [ 'MimeType' => "application/json" ], ] ]; $defaultWpsProcessList['p5:getRelations'] = array_merge([ 'title' => "Fetch relations between features" ], $relationsBase, [ 'dataInputs' => [ $wpsArgTypeName, array_merge($wpsArgPrimaryKey, [ 'maxOccurs' => 1 ]), $wpsArgRemoteTypeName, ], ]); $defaultWpsProcessList['p5:createRelation'] = array_merge([ 'title' => "Create relation between features" ], $relationsBase); $defaultWpsProcessList['p5:deleteRelation'] = array_merge([ 'title' => "Delete relation between features" ], $relationsBase); } 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); } }