41#include <QRegularExpression>
44using namespace Qt::StringLiterals;
52 void addTransactionResult( QDomDocument &responseDoc, QDomElement &responseElem,
const QString &status,
const QString &locator,
const QString &message );
61 response.
setHeader(
"Content-Type",
"text/xml; charset=utf-8" );
62 response.
write( doc.toByteArray() );
75 if ( doc.setContent( request.
data(),
true, &errorMsg ) )
77 QDomElement docElem = doc.documentElement();
86 if ( actionCount == 0 )
97 QDomElement respElem = resp.createElement( u
"WFS_TransactionResponse"_s );
99 respElem.setAttribute( u
"xmlns:xsi"_s, u
"http://www.w3.org/2001/XMLSchema-instance"_s );
100 respElem.setAttribute( u
"xsi:schemaLocation"_s,
WFS_NAMESPACE +
" http://schemas.opengis.net/wfs/1.0.0/wfs.xsd" );
102 respElem.setAttribute( u
"version"_s, u
"1.0.0"_s );
103 resp.appendChild( respElem );
106 QStringList errorLocators;
107 QStringList errorMessages;
109 QList<transactionUpdate>::iterator tuIt = aRequest.
updates.begin();
110 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
116 if ( action.
handle.isEmpty() )
118 errorLocators << u
"Update:%1"_s.arg( action.
typeName );
122 errorLocators << action.
handle;
128 QList<transactionDelete>::iterator tdIt = aRequest.
deletes.begin();
129 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
135 if ( action.
handle.isEmpty() )
137 errorLocators << u
"Delete:%1"_s.arg( action.
typeName );
141 errorLocators << action.
handle;
147 QList<transactionInsert>::iterator tiIt = aRequest.
inserts.begin();
148 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
154 if ( action.
handle.isEmpty() )
156 errorLocators << u
"Insert:%1"_s.arg( action.
typeName );
160 errorLocators << action.
handle;
169 QString fidStr = *fidIt;
170 QDomElement irElem = doc.createElement( u
"InsertResult"_s );
171 if ( !action.
handle.isEmpty() )
173 irElem.setAttribute( u
"handle"_s, action.
handle );
175 QDomElement fiElem = doc.createElement( u
"ogc:FeatureId"_s );
176 fiElem.setAttribute( u
"fid"_s, fidStr );
177 irElem.appendChild( fiElem );
178 respElem.appendChild( irElem );
184 if ( errorCount == 0 )
186 addTransactionResult( resp, respElem, u
"SUCCESS"_s, QString(), QString() );
190 QString locator = errorLocators.join(
"; "_L1 );
191 QString message = errorMessages.join(
"; "_L1 );
192 if ( errorCount != actionCount )
194 addTransactionResult( resp, respElem, u
"PARTIAL"_s, locator, message );
198 addTransactionResult( resp, respElem, u
"ERROR"_s, locator, message );
207 QStringList typeNameList;
209 QList<transactionInsert>::iterator tiIt = aRequest.
inserts.begin();
210 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
212 QString name = ( *tiIt ).typeName;
213 if ( !typeNameList.contains( name ) )
214 typeNameList << name;
216 QList<transactionUpdate>::iterator tuIt = aRequest.
updates.begin();
217 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
219 QString name = ( *tuIt ).typeName;
220 if ( !typeNameList.contains( name ) )
221 typeNameList << name;
223 QList<transactionDelete>::iterator tdIt = aRequest.
deletes.begin();
224 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
226 QString name = ( *tdIt ).typeName;
227 if ( !typeNameList.contains( name ) )
228 typeNameList << name;
231#ifdef HAVE_SERVER_PYTHON_PLUGINS
235 ( void ) serverIface;
240 auto filterRestorer = std::make_unique<QgsOWSServerFilterRestorer>();
247 QMap<QString, QgsVectorLayer *> mapLayerMap;
248 for (
int i = 0; i < wfsLayerIds.size(); ++i )
258 if ( !typeNameList.contains( name ) )
285 if ( !wfstUpdateLayerIds.contains( vlayer->
id() )
286 && !wfstDeleteLayerIds.contains( vlayer->
id() )
287 && !wfstInsertLayerIds.contains( vlayer->
id() ) )
291#ifdef HAVE_SERVER_PYTHON_PLUGINS
304 mapLayerMap[name] = vlayer;
308 tuIt = aRequest.
updates.begin();
309 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
314 if ( !mapLayerMap.contains( typeName ) )
317 action.
errorMsg = u
"TypeName '%1' unknown"_s.arg( typeName );
325 if ( !wfstUpdateLayerIds.contains( vlayer->
id() ) )
328 action.
errorMsg = u
"No permissions to do WFS updates on layer '%1'"_s.arg( typeName );
331#ifdef HAVE_SERVER_PYTHON_PLUGINS
335 action.
errorMsg = u
"No permissions to do WFS updates on layer '%1'"_s.arg( typeName );
347 action.
errorMsg = u
"No capabilities to do WFS updates on layer '%1'"_s.arg( typeName );
370#ifdef HAVE_SERVER_PYTHON_PLUGINS
382 QMap<QString, QString> propertyMap = action.
propertyMap;
386 const QMap<QString, int> fieldMap = provider->
fieldNameMap();
387 QMap<QString, int>::const_iterator fieldMapIt;
389 bool conversionSuccess;
393#ifdef HAVE_SERVER_PYTHON_PLUGINS
394 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
397 action.
errorMsg = u
"Feature modify permission denied on layer '%1'"_s.arg( typeName );
402 QMap<QString, QString>::const_iterator it = propertyMap.constBegin();
403 for ( ; it != propertyMap.constEnd(); ++it )
405 fieldName = it.key();
406 fieldMapIt = fieldMap.find( fieldName );
407 if ( fieldMapIt == fieldMap.constEnd() )
411 QgsField field = fields.
at( fieldMapIt.value() );
412 QVariant value = it.value();
418 action.
errorMsg = u
"NOT NULL constraint error on layer '%1', field '%2'"_s.arg( typeName, field.
name() );
425 if ( field.
type() == QMetaType::Type::Int )
427 value = it.value().toInt( &conversionSuccess );
428 if ( !conversionSuccess )
431 action.
errorMsg = u
"Property conversion error on layer '%1'"_s.arg( typeName );
436 else if ( field.
type() == QMetaType::Type::Double )
438 value = it.value().toDouble( &conversionSuccess );
439 if ( !conversionSuccess )
442 action.
errorMsg = u
"Property conversion error on layer '%1'"_s.arg( typeName );
447 else if ( field.
type() == QMetaType::Type::LongLong )
449 value = it.value().toLongLong( &conversionSuccess );
450 if ( !conversionSuccess )
453 action.
errorMsg = u
"Property conversion error on layer '%1'"_s.arg( typeName );
466 if ( !geometryElem.isNull() )
474 action.
errorMsg = u
"Geometry from GML error on layer '%1'"_s.arg( typeName );
481 action.
errorMsg = u
"Error in change geometry on layer '%1'"_s.arg( typeName );
491#ifdef HAVE_SERVER_PYTHON_PLUGINS
498 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
501 action.
errorMsg = u
"Feature modify permission denied on layer '%1'"_s.arg( typeName );
517 action.
errorMsg = u
"Error committing updates: %1"_s.arg( vlayer->
commitErrors().join(
"; "_L1 ) );
522 action.
error =
false;
526 tdIt = aRequest.
deletes.begin();
527 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
532 if ( !mapLayerMap.contains( typeName ) )
535 action.
errorMsg = u
"TypeName '%1' unknown"_s.arg( typeName );
543 if ( !wfstDeleteLayerIds.contains( vlayer->
id() ) )
546 action.
errorMsg = u
"No permissions to do WFS deletes on layer '%1'"_s.arg( typeName );
549#ifdef HAVE_SERVER_PYTHON_PLUGINS
553 action.
errorMsg = u
"No permissions to do WFS deletes on layer '%1'"_s.arg( typeName );
565 action.
errorMsg = u
"No capabilities to do WFS deletes on layer '%1'"_s.arg( typeName );
585 action.
errorMsg = u
"No feature ids to do WFS deletes on layer '%1'"_s.arg( typeName );
592#ifdef HAVE_SERVER_PYTHON_PLUGINS
606#ifdef HAVE_SERVER_PYTHON_PLUGINS
607 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
610 action.
errorMsg = u
"Feature modify permission denied"_s;
615 fids << feature.
id();
625 action.
errorMsg = u
"Delete features failed on layer '%1'"_s.arg( typeName );
634 action.
errorMsg = u
"Error committing deletes: %1"_s.arg( vlayer->
commitErrors().join(
"; "_L1 ) );
639 action.
error =
false;
643 tiIt = aRequest.
inserts.begin();
644 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
649 if ( !mapLayerMap.contains( typeName ) )
652 action.
errorMsg = u
"TypeName '%1' unknown"_s.arg( typeName );
660 if ( !wfstInsertLayerIds.contains( vlayer->
id() ) )
663 action.
errorMsg = u
"No permissions to do WFS inserts on layer '%1'"_s.arg( typeName );
666#ifdef HAVE_SERVER_PYTHON_PLUGINS
670 action.
errorMsg = u
"No permissions to do WFS inserts on layer '%1'"_s.arg( typeName );
682 action.
errorMsg = u
"No capabilities to do WFS inserts on layer '%1'"_s.arg( typeName );
702 if ( featureList.empty() )
705 action.
errorMsg = u
"No features to insert in layer '%1'"_s.arg( typeName );
709#ifdef HAVE_SERVER_PYTHON_PLUGINS
713 QgsFeatureList::iterator featureIt = featureList.begin();
714 while ( featureIt != featureList.end() )
716 if ( !accessControl->
allowToEdit( vlayer, *featureIt ) )
719 action.
errorMsg = u
"Feature modify permission denied on layer '%1'"_s.arg( typeName );
736 action.
errorMsg = u
"Insert features failed on layer '%1'"_s.arg( typeName );
749 action.
errorMsg = u
"Error committing inserts: %1"_s.arg( vlayer->
commitErrors().join(
"; "_L1 ) );
754 action.
error =
false;
758 for (
const QgsFeature &feat : std::as_const( featureList ) )
765 filterRestorer.reset();
774 Q_ASSERT( provider );
778 const QMap<QString, int> fieldMap = provider->fieldNameMap();
779 QMap<QString, int>::const_iterator fieldMapIt;
781 for (
int i = 0; i < featureNodeList.count(); i++ )
785 QDomElement featureElem = featureNodeList.at( i ).toElement();
786 QDomNode currentAttributeChild = featureElem.firstChild();
787 bool conversionSuccess =
true;
789 for ( ; !currentAttributeChild.isNull(); currentAttributeChild = currentAttributeChild.nextSibling() )
791 QDomElement currentAttributeElement = currentAttributeChild.toElement();
792 QString attrName = currentAttributeElement.localName();
794 if ( attrName !=
"boundedBy"_L1 )
796 if ( attrName !=
"geometry"_L1 )
798 fieldMapIt = fieldMap.find( attrName );
799 if ( fieldMapIt == fieldMap.constEnd() )
805 QgsField field = fields.
at( fieldMapIt.value() );
806 QString attrValue = currentAttributeElement.text();
807 int attrType = field.
type();
809 QgsMessageLog::logMessage( u
"attr: name=%1 idx=%2 value=%3"_s.arg( attrName ).arg( fieldMapIt.value() ).arg( attrValue ) );
811 if ( attrType == QMetaType::Type::Int )
812 feat.
setAttribute( fieldMapIt.value(), attrValue.toInt( &conversionSuccess ) );
813 else if ( attrType == QMetaType::Type::Double )
814 feat.
setAttribute( fieldMapIt.value(), attrValue.toDouble( &conversionSuccess ) );
818 if ( !conversionSuccess )
843 if ( !parameters.contains( u
"OPERATION"_s ) )
847 if ( parameters.value( u
"OPERATION"_s ).toUpper() !=
"DELETE"_L1 )
853 if ( ( parameters.contains( u
"FEATUREID"_s )
854 && ( parameters.contains( u
"FILTER"_s ) || parameters.contains( u
"BBOX"_s ) ) )
855 || ( parameters.contains( u
"FILTER"_s ) && ( parameters.contains( u
"FEATUREID"_s ) || parameters.contains( u
"BBOX"_s ) ) )
856 || ( parameters.contains( u
"BBOX"_s ) && ( parameters.contains( u
"FEATUREID"_s ) || parameters.contains( u
"FILTER"_s ) ) ) )
863 QStringList typeNameList;
865 if ( parameters.contains( u
"FEATUREID"_s ) )
867 QStringList fidList = parameters.value( u
"FEATUREID"_s ).split(
',' );
869 QMap<QString, QStringList> fidsMap;
871 QStringList::const_iterator fidIt = fidList.constBegin();
872 for ( ; fidIt != fidList.constEnd(); ++fidIt )
875 QString fid = *fidIt;
878 if ( !fid.contains(
'.' ) )
883 QString typeName = fid.section(
'.', 0, 0 );
884 fid = fid.section(
'.', 1, 1 );
885 if ( !typeNameList.contains( typeName ) )
887 typeNameList << typeName;
891 if ( fidsMap.contains( typeName ) )
893 fids = fidsMap.value( typeName );
896 fidsMap.insert( typeName, fids );
899 QMap<QString, QStringList>::const_iterator fidsMapIt = fidsMap.constBegin();
900 for ( ; fidsMapIt != fidsMap.constEnd(); ++fidsMapIt )
908 request.
deletes.append( action );
913 if ( !parameters.contains( u
"TYPENAME"_s ) )
918 typeNameList = parameters.value( u
"TYPENAME"_s ).split(
',' );
921 QStringList::const_iterator typeNameIt = typeNameList.constBegin();
922 for ( ; typeNameIt != typeNameList.constEnd(); ++typeNameIt )
924 QString typeName = *typeNameIt;
925 typeName = typeName.trimmed();
930 request.
deletes.append( action );
934 if ( parameters.contains( u
"EXP_FILTER"_s ) )
936 QString expFilterName = parameters.value( u
"EXP_FILTER"_s );
937 QStringList expFilterList;
938 const thread_local QRegularExpression rx(
"\\(([^()]+)\\)" );
939 QRegularExpressionMatchIterator matchIt = rx.globalMatch( expFilterName );
940 if ( !matchIt.hasNext() )
942 expFilterList << expFilterName;
946 while ( matchIt.hasNext() )
948 const QRegularExpressionMatch match = matchIt.next();
949 if ( match.hasMatch() )
951 QStringList matches = match.capturedTexts();
953 expFilterList.append( matches );
959 if ( request.
deletes.size() == expFilterList.size() )
962 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
963 QStringList::const_iterator expFilterIt = expFilterList.constBegin();
964 for ( ; dIt != request.
deletes.end(); ++dIt )
969 if ( expFilterIt != expFilterList.constEnd() )
971 expFilter = *expFilterIt;
973 std::shared_ptr<QgsExpression> filter(
new QgsExpression( expFilter ) );
976 if ( filter->hasParserError() )
982 if ( filter->needsGeometry() )
997 if ( parameters.contains( u
"BBOX"_s ) )
1000 QString bbox = parameters.value( u
"BBOX"_s );
1001 if ( bbox.isEmpty() )
1007 QStringList corners = bbox.split(
',' );
1008 if ( corners.size() != 4 )
1016 for (
int i = 0; i < 4; i++ )
1018 corners[i].replace(
' ',
'+' );
1019 d[i] = corners[i].toDouble( &ok );
1029 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1030 for ( ; dIt != request.
deletes.end(); ++dIt )
1037 else if ( parameters.contains( u
"FILTER"_s ) )
1039 QString filterName = parameters.value( u
"FILTER"_s );
1040 QStringList filterList;
1042 const thread_local QRegularExpression rx(
"\\(([^()]+)\\)" );
1043 QRegularExpressionMatchIterator matchIt = rx.globalMatch( filterName );
1044 if ( !matchIt.hasNext() )
1046 filterList << filterName;
1050 while ( matchIt.hasNext() )
1052 const QRegularExpressionMatch match = matchIt.next();
1053 if ( match.hasMatch() )
1055 QStringList matches = match.capturedTexts();
1056 matches.pop_front();
1057 filterList.append( matches );
1063 if ( request.
deletes.size() != filterList.size() )
1069 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1070 QStringList::const_iterator filterIt = filterList.constBegin();
1071 for ( ; dIt != request.
deletes.end(); ++dIt )
1076 QDomDocument filter;
1077 if ( filterIt != filterList.constEnd() )
1080 if ( !filter.setContent( *filterIt,
true, &errorMsg ) )
1086 QDomElement filterElem = filter.firstChildElement();
1087 QStringList serverFids;
1091 if ( filterIt != filterList.constEnd() )
1106 QDomNodeList docChildNodes = docElem.childNodes();
1108 QDomElement actionElem;
1111 for (
int i = docChildNodes.count(); 0 < i; --i )
1113 actionElem = docChildNodes.at( i - 1 ).toElement();
1114 actionName = actionElem.localName();
1116 if ( actionName ==
"Insert"_L1 )
1119 request.
inserts.append( action );
1121 else if ( actionName ==
"Update"_L1 )
1124 request.
updates.append( action );
1126 else if ( actionName ==
"Delete"_L1 )
1129 request.
deletes.append( action );
1138 QString typeName = actionElem.attribute( u
"typeName"_s );
1139 if ( typeName.contains(
':' ) )
1140 typeName = typeName.section(
':', 1, 1 );
1142 QDomElement filterElem = actionElem.firstChild().toElement();
1143 if ( filterElem.tagName() !=
"Filter"_L1 )
1148 QStringList serverFids;
1155 action.
error =
false;
1157 if ( actionElem.hasAttribute( u
"handle"_s ) )
1159 action.
handle = actionElem.attribute( u
"handle"_s );
1167 QString typeName = actionElem.attribute( u
"typeName"_s );
1168 if ( typeName.contains(
':' ) )
1169 typeName = typeName.section(
':', 1, 1 );
1171 QDomNodeList propertyNodeList = actionElem.elementsByTagName( u
"Property"_s );
1172 if ( propertyNodeList.isEmpty() )
1177 QMap<QString, QString> propertyMap;
1178 QDomElement propertyElem;
1179 QDomElement nameElem;
1180 QDomElement valueElem;
1181 QDomElement geometryElem;
1183 for (
int l = 0; l < propertyNodeList.count(); ++l )
1185 propertyElem = propertyNodeList.at( l ).toElement();
1186 nameElem = propertyElem.elementsByTagName( u
"Name"_s ).at( 0 ).toElement();
1187 valueElem = propertyElem.elementsByTagName( u
"Value"_s ).at( 0 ).toElement();
1188 if ( nameElem.text() !=
"geometry"_L1 )
1190 propertyMap.insert( nameElem.text(), valueElem.text() );
1194 geometryElem = valueElem;
1198 QDomNodeList filterNodeList = actionElem.elementsByTagName( u
"Filter"_s );
1200 QStringList serverFids;
1201 if ( filterNodeList.size() != 0 )
1203 QDomElement filterElem = filterNodeList.at( 0 ).toElement();
1213 action.
error =
false;
1215 if ( actionElem.hasAttribute( u
"handle"_s ) )
1217 action.
handle = actionElem.attribute( u
"handle"_s );
1225 QDomNodeList featureNodeList = actionElem.childNodes();
1226 if ( featureNodeList.size() != 1 )
1232 for (
int i = 0; i < featureNodeList.count(); ++i )
1234 QString tempTypeName = featureNodeList.at( i ).toElement().localName();
1235 if ( tempTypeName.contains(
':' ) )
1236 tempTypeName = tempTypeName.section(
':', 1, 1 );
1238 if ( typeName.isEmpty() )
1240 typeName = tempTypeName;
1242 else if ( tempTypeName != typeName )
1251 action.
error =
false;
1253 if ( actionElem.hasAttribute( u
"handle"_s ) )
1255 action.
handle = actionElem.attribute( u
"handle"_s );
1264 void addTransactionResult( QDomDocument &responseDoc, QDomElement &responseElem,
const QString &status,
const QString &locator,
const QString &message )
1266 QDomElement trElem = responseDoc.createElement( u
"TransactionResult"_s );
1267 QDomElement stElem = responseDoc.createElement( u
"Status"_s );
1268 QDomElement successElem = responseDoc.createElement( status );
1269 stElem.appendChild( successElem );
1270 trElem.appendChild( stElem );
1271 responseElem.appendChild( trElem );
1273 if ( !locator.isEmpty() )
1275 QDomElement locElem = responseDoc.createElement( u
"Locator"_s );
1276 locElem.appendChild( responseDoc.createTextNode( locator ) );
1277 trElem.appendChild( locElem );
1280 if ( !message.isEmpty() )
1282 QDomElement mesElem = responseDoc.createElement( u
"Message"_s );
1283 mesElem.appendChild( responseDoc.createTextNode( message ) );
1284 trElem.appendChild( mesElem );
@ AddFeatures
Allows adding features.
@ ChangeGeometries
Allows modifications of geometries.
@ DeleteFeatures
Allows deletion of features.
@ ChangeAttributeValues
Allows modification of attribute values.
@ NoFlags
No flags are set.
QFlags< VectorProviderCapability > VectorProviderCapabilities
Vector data provider capabilities.
A helper class that centralizes restrictions given by all the access control filter plugins.
bool layerUpdatePermission(const QgsVectorLayer *layer) const
Returns the layer update right.
void filterFeatures(const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures) const override
Filter the features of the layer.
bool layerInsertPermission(const QgsVectorLayer *layer) const
Returns the layer insert right.
bool allowToEdit(const QgsVectorLayer *layer, const QgsFeature &feature) const
Are we authorized to modify the following geometry.
bool layerDeletePermission(const QgsVectorLayer *layer) const
Returns the layer delete right.
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Handles parsing and evaluation of expressions (formerly called "search strings").
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
Wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setFlags(Qgis::FeatureRequestFlags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Q_INVOKABLE bool setAttribute(int field, const QVariant &attr)
Sets an attribute's value by field index.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
@ ConstraintNotNull
Field may not be null.
Encapsulate a field in an attribute table or data source.
QgsFieldConstraints constraints
Container of fields for a vector layer.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
A geometry is the spatial representation of a feature.
QString wfsTypeName() const
Returns WFS typename for the layer.
Base class for all map layer types.
QgsMapLayerServerProperties * serverProperties()
Returns QGIS Server Properties for the map layer.
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
Adds a message to the log instance (and creates it if necessary).
static void applyAccessControlLayerFilters(const QgsAccessControl *accessControl, QgsMapLayer *mapLayer, QHash< QgsMapLayer *, QString > &originalLayerFilters)
Apply filter from AccessControl.
Exception base class for service exceptions.
QString message() const
Returns the exception message.
static QgsGeometry geometryFromGML(const QString &xmlString, const QgsOgcUtils::Context &context=QgsOgcUtils::Context())
Static method that creates geometry from GML.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
A rectangle specified with double values.
static QgsFeatureRequest updateFeatureRequestFromServerFids(QgsFeatureRequest &featureRequest, const QStringList &serverFids, const QgsVectorDataProvider *provider)
Returns the feature request based on feature ids build with primary keys.
static QString getServerFid(const QgsFeature &feature, const QgsAttributeList &pkAttributes)
Returns the feature id based on primary keys.
Defines interfaces exposed by QGIS Server and made available to plugins.
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
static QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
static QStringList wfstUpdateLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published as WFS-T with update capabilities.
static QStringList wfstInsertLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published as WFS-T with insert capabilities.
static QStringList wfstDeleteLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published as WFS-T with delete capabilities.
Defines requests passed to QgsService classes.
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
QMap< QString, QString > Parameters
virtual QByteArray data() const
Returns post/put data Check for QByteArray::isNull() to check if data is available.
Defines the response interface passed to QgsService.
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device.
virtual void setHeader(const QString &key, const QString &value)=0
Set Header entry Add Header entry to the response Note that it is usually an error to set Header afte...
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
Base class for vector data providers.
void clearErrors()
Clear recorded errors.
virtual Q_INVOKABLE Qgis::VectorProviderCapabilities capabilities() const
Returns flags containing the supported capabilities.
virtual QgsAttributeList pkAttributeIndexes() const
Returns list of indexes of fields that make up the primary key.
bool addFeatures(QgsFeatureList &flist, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a list of features to the sink.
QgsFields fields() const override=0
Returns the fields associated with this data provider.
QMap< QString, int > fieldNameMap() const
Returns a map where the key is the name of the field and the value is its index.
bool hasErrors() const
Provider has errors to report.
Represents a vector layer which manages a vector based dataset.
Q_INVOKABLE bool deleteFeatures(const QgsFeatureIds &fids, QgsVectorLayer::DeleteContext *context=nullptr)
Deletes a set of features from the layer (but does not commit it).
Q_INVOKABLE bool startEditing()
Makes the layer editable.
Q_INVOKABLE bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant(), bool skipDefaultValues=false, QgsVectorLayerToolsContext *context=nullptr)
Changes an attribute value for a feature (but does not immediately commit the changes).
QStringList commitErrors() const
Returns a list containing any error messages generated when attempting to commit changes to the layer...
Q_INVOKABLE bool rollBack(bool deleteBuffer=true)
Stops a current editing operation and discards any uncommitted edits.
Q_INVOKABLE bool commitChanges(bool stopEditing=true)
Attempts to commit to the underlying data provider any buffered changes made since the last to call t...
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const final
Queries the layer for features specified in request.
QgsVectorDataProvider * dataProvider() final
Returns the layer's data provider, it may be nullptr.
Q_INVOKABLE bool changeGeometry(QgsFeatureId fid, QgsGeometry &geometry, bool skipDefaultValue=false)
Changes a feature's geometry within the layer's edit buffer (but does not immediately commit the chan...
Exception thrown when data access violates access controls.
transactionInsert parseInsertActionElement(QDomElement &actionElem)
Transform Insert element to transactionInsert.
transactionDelete parseDeleteActionElement(QDomElement &actionElem, const QgsProject *project)
Transform Delete element to transactionDelete.
void performTransaction(transactionRequest &aRequest, QgsServerInterface *serverIface, const QgsProject *project)
Perform the transaction.
QDomDocument createTransactionDocument(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request)
Create a wfs transaction document.
transactionRequest parseTransactionRequestBody(QDomElement &docElem, const QgsProject *project)
Transform RequestBody root element to getFeatureRequest.
transactionRequest parseTransactionParameters(QgsServerRequest::Parameters parameters, const QgsProject *project)
void writeTransaction(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output WFS transaction response.
QgsFeatureList featuresFromGML(QDomNodeList featureNodeList, QgsVectorLayer *layer)
Transform GML feature nodes to features.
transactionUpdate parseUpdateActionElement(QDomElement &actionElem, const QgsProject *project)
Transform Update element to transactionUpdate.
const QString OGC_NAMESPACE
const QString WFS_NAMESPACE
QgsFeatureRequest parseFilterElement(const QString &typeName, QDomElement &filterElem, QgsProject *project)
Transform a Filter element to a feature request.
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
QList< QgsFeature > QgsFeatureList
QSet< QgsFeatureId > QgsFeatureIds
QList< int > QgsAttributeList
The Context struct stores the current layer and coordinate transform context.
QgsFeatureRequest featureRequest
QStringList insertFeatureIds
QDomNodeList featureNodeList
QList< transactionInsert > inserts
QList< transactionUpdate > updates
QList< transactionDelete > deletes
QMap< QString, QString > propertyMap
QgsFeatureRequest featureRequest
QDomElement geometryElement