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 ) )
287 if ( !wfstUpdateLayerIds.contains( vlayer->
id() ) && !wfstDeleteLayerIds.contains( vlayer->
id() ) && !wfstInsertLayerIds.contains( vlayer->
id() ) )
291#ifdef HAVE_SERVER_PYTHON_PLUGINS
303 mapLayerMap[name] = vlayer;
307 tuIt = aRequest.
updates.begin();
308 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
313 if ( !mapLayerMap.contains( typeName ) )
316 action.
errorMsg = u
"TypeName '%1' unknown"_s.arg( typeName );
324 if ( !wfstUpdateLayerIds.contains( vlayer->
id() ) )
327 action.
errorMsg = u
"No permissions to do WFS updates on layer '%1'"_s.arg( typeName );
330#ifdef HAVE_SERVER_PYTHON_PLUGINS
334 action.
errorMsg = u
"No permissions to do WFS updates on layer '%1'"_s.arg( typeName );
346 action.
errorMsg = u
"No capabilities to do WFS updates on layer '%1'"_s.arg( typeName );
367#ifdef HAVE_SERVER_PYTHON_PLUGINS
379 QMap<QString, QString> propertyMap = action.
propertyMap;
383 const QMap<QString, int> fieldMap = provider->
fieldNameMap();
384 QMap<QString, int>::const_iterator fieldMapIt;
386 bool conversionSuccess;
390#ifdef HAVE_SERVER_PYTHON_PLUGINS
391 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
394 action.
errorMsg = u
"Feature modify permission denied on layer '%1'"_s.arg( typeName );
399 QMap<QString, QString>::const_iterator it = propertyMap.constBegin();
400 for ( ; it != propertyMap.constEnd(); ++it )
402 fieldName = it.key();
403 fieldMapIt = fieldMap.find( fieldName );
404 if ( fieldMapIt == fieldMap.constEnd() )
408 QgsField field = fields.
at( fieldMapIt.value() );
409 QVariant value = it.value();
415 action.
errorMsg = u
"NOT NULL constraint error on layer '%1', field '%2'"_s.arg( typeName, field.
name() );
422 if ( field.
type() == QMetaType::Type::Int )
424 value = it.value().toInt( &conversionSuccess );
425 if ( !conversionSuccess )
428 action.
errorMsg = u
"Property conversion error on layer '%1'"_s.arg( typeName );
433 else if ( field.
type() == QMetaType::Type::Double )
435 value = it.value().toDouble( &conversionSuccess );
436 if ( !conversionSuccess )
439 action.
errorMsg = u
"Property conversion error on layer '%1'"_s.arg( typeName );
444 else if ( field.
type() == QMetaType::Type::LongLong )
446 value = it.value().toLongLong( &conversionSuccess );
447 if ( !conversionSuccess )
450 action.
errorMsg = u
"Property conversion error on layer '%1'"_s.arg( typeName );
463 if ( !geometryElem.isNull() )
471 action.
errorMsg = u
"Geometry from GML error on layer '%1'"_s.arg( typeName );
478 action.
errorMsg = u
"Error in change geometry on layer '%1'"_s.arg( typeName );
488#ifdef HAVE_SERVER_PYTHON_PLUGINS
495 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
498 action.
errorMsg = u
"Feature modify permission denied on layer '%1'"_s.arg( typeName );
514 action.
errorMsg = u
"Error committing updates: %1"_s.arg( vlayer->
commitErrors().join(
"; "_L1 ) );
519 action.
error =
false;
523 tdIt = aRequest.
deletes.begin();
524 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
529 if ( !mapLayerMap.contains( typeName ) )
532 action.
errorMsg = u
"TypeName '%1' unknown"_s.arg( typeName );
540 if ( !wfstDeleteLayerIds.contains( vlayer->
id() ) )
543 action.
errorMsg = u
"No permissions to do WFS deletes on layer '%1'"_s.arg( typeName );
546#ifdef HAVE_SERVER_PYTHON_PLUGINS
550 action.
errorMsg = u
"No permissions to do WFS deletes on layer '%1'"_s.arg( typeName );
562 action.
errorMsg = u
"No capabilities to do WFS deletes on layer '%1'"_s.arg( typeName );
580 action.
errorMsg = u
"No feature ids to do WFS deletes on layer '%1'"_s.arg( typeName );
587#ifdef HAVE_SERVER_PYTHON_PLUGINS
601#ifdef HAVE_SERVER_PYTHON_PLUGINS
602 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
605 action.
errorMsg = u
"Feature modify permission denied"_s;
610 fids << feature.
id();
620 action.
errorMsg = u
"Delete features failed on layer '%1'"_s.arg( typeName );
629 action.
errorMsg = u
"Error committing deletes: %1"_s.arg( vlayer->
commitErrors().join(
"; "_L1 ) );
634 action.
error =
false;
638 tiIt = aRequest.
inserts.begin();
639 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
644 if ( !mapLayerMap.contains( typeName ) )
647 action.
errorMsg = u
"TypeName '%1' unknown"_s.arg( typeName );
655 if ( !wfstInsertLayerIds.contains( vlayer->
id() ) )
658 action.
errorMsg = u
"No permissions to do WFS inserts on layer '%1'"_s.arg( typeName );
661#ifdef HAVE_SERVER_PYTHON_PLUGINS
665 action.
errorMsg = u
"No permissions to do WFS inserts on layer '%1'"_s.arg( typeName );
677 action.
errorMsg = u
"No capabilities to do WFS inserts on layer '%1'"_s.arg( typeName );
697 if ( featureList.empty() )
700 action.
errorMsg = u
"No features to insert in layer '%1'"_s.arg( typeName );
704#ifdef HAVE_SERVER_PYTHON_PLUGINS
708 QgsFeatureList::iterator featureIt = featureList.begin();
709 while ( featureIt != featureList.end() )
711 if ( !accessControl->
allowToEdit( vlayer, *featureIt ) )
714 action.
errorMsg = u
"Feature modify permission denied on layer '%1'"_s.arg( typeName );
731 action.
errorMsg = u
"Insert features failed on layer '%1'"_s.arg( typeName );
744 action.
errorMsg = u
"Error committing inserts: %1"_s.arg( vlayer->
commitErrors().join(
"; "_L1 ) );
749 action.
error =
false;
753 for (
const QgsFeature &feat : std::as_const( featureList ) )
760 filterRestorer.reset();
769 Q_ASSERT( provider );
773 const QMap<QString, int> fieldMap = provider->fieldNameMap();
774 QMap<QString, int>::const_iterator fieldMapIt;
776 for (
int i = 0; i < featureNodeList.count(); i++ )
780 QDomElement featureElem = featureNodeList.at( i ).toElement();
781 QDomNode currentAttributeChild = featureElem.firstChild();
782 bool conversionSuccess =
true;
784 for ( ; !currentAttributeChild.isNull(); currentAttributeChild = currentAttributeChild.nextSibling() )
786 QDomElement currentAttributeElement = currentAttributeChild.toElement();
787 QString attrName = currentAttributeElement.localName();
789 if ( attrName !=
"boundedBy"_L1 )
791 if ( attrName !=
"geometry"_L1 )
793 fieldMapIt = fieldMap.find( attrName );
794 if ( fieldMapIt == fieldMap.constEnd() )
800 QgsField field = fields.
at( fieldMapIt.value() );
801 QString attrValue = currentAttributeElement.text();
802 int attrType = field.
type();
804 QgsMessageLog::logMessage( u
"attr: name=%1 idx=%2 value=%3"_s.arg( attrName ).arg( fieldMapIt.value() ).arg( attrValue ) );
806 if ( attrType == QMetaType::Type::Int )
807 feat.
setAttribute( fieldMapIt.value(), attrValue.toInt( &conversionSuccess ) );
808 else if ( attrType == QMetaType::Type::Double )
809 feat.
setAttribute( fieldMapIt.value(), attrValue.toDouble( &conversionSuccess ) );
813 if ( !conversionSuccess )
838 if ( !parameters.contains( u
"OPERATION"_s ) )
842 if ( parameters.value( u
"OPERATION"_s ).toUpper() !=
"DELETE"_L1 )
848 if ( ( parameters.contains( u
"FEATUREID"_s ) && ( parameters.contains( u
"FILTER"_s ) || parameters.contains( u
"BBOX"_s ) ) )
849 || ( parameters.contains( u
"FILTER"_s ) && ( parameters.contains( u
"FEATUREID"_s ) || parameters.contains( u
"BBOX"_s ) ) )
850 || ( parameters.contains( u
"BBOX"_s ) && ( parameters.contains( u
"FEATUREID"_s ) || parameters.contains( u
"FILTER"_s ) ) ) )
857 QStringList typeNameList;
859 if ( parameters.contains( u
"FEATUREID"_s ) )
861 QStringList fidList = parameters.value( u
"FEATUREID"_s ).split(
',' );
863 QMap<QString, QStringList> fidsMap;
865 QStringList::const_iterator fidIt = fidList.constBegin();
866 for ( ; fidIt != fidList.constEnd(); ++fidIt )
869 QString fid = *fidIt;
872 if ( !fid.contains(
'.' ) )
877 QString typeName = fid.section(
'.', 0, 0 );
878 fid = fid.section(
'.', 1, 1 );
879 if ( !typeNameList.contains( typeName ) )
881 typeNameList << typeName;
885 if ( fidsMap.contains( typeName ) )
887 fids = fidsMap.value( typeName );
890 fidsMap.insert( typeName, fids );
893 QMap<QString, QStringList>::const_iterator fidsMapIt = fidsMap.constBegin();
894 for ( ; fidsMapIt != fidsMap.constEnd(); ++fidsMapIt )
902 request.
deletes.append( action );
907 if ( !parameters.contains( u
"TYPENAME"_s ) )
912 typeNameList = parameters.value( u
"TYPENAME"_s ).split(
',' );
915 QStringList::const_iterator typeNameIt = typeNameList.constBegin();
916 for ( ; typeNameIt != typeNameList.constEnd(); ++typeNameIt )
918 QString typeName = *typeNameIt;
919 typeName = typeName.trimmed();
924 request.
deletes.append( action );
928 if ( parameters.contains( u
"EXP_FILTER"_s ) )
930 QString expFilterName = parameters.value( u
"EXP_FILTER"_s );
931 QStringList expFilterList;
932 const thread_local QRegularExpression rx(
"\\(([^()]+)\\)" );
933 QRegularExpressionMatchIterator matchIt = rx.globalMatch( expFilterName );
934 if ( !matchIt.hasNext() )
936 expFilterList << expFilterName;
940 while ( matchIt.hasNext() )
942 const QRegularExpressionMatch match = matchIt.next();
943 if ( match.hasMatch() )
945 QStringList matches = match.capturedTexts();
947 expFilterList.append( matches );
953 if ( request.
deletes.size() == expFilterList.size() )
956 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
957 QStringList::const_iterator expFilterIt = expFilterList.constBegin();
958 for ( ; dIt != request.
deletes.end(); ++dIt )
963 if ( expFilterIt != expFilterList.constEnd() )
965 expFilter = *expFilterIt;
967 std::shared_ptr<QgsExpression> filter(
new QgsExpression( expFilter ) );
970 if ( filter->hasParserError() )
976 if ( filter->needsGeometry() )
991 if ( parameters.contains( u
"BBOX"_s ) )
994 QString bbox = parameters.value( u
"BBOX"_s );
995 if ( bbox.isEmpty() )
1001 QStringList corners = bbox.split(
',' );
1002 if ( corners.size() != 4 )
1010 for (
int i = 0; i < 4; i++ )
1012 corners[i].replace(
' ',
'+' );
1013 d[i] = corners[i].toDouble( &ok );
1023 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1024 for ( ; dIt != request.
deletes.end(); ++dIt )
1031 else if ( parameters.contains( u
"FILTER"_s ) )
1033 QString filterName = parameters.value( u
"FILTER"_s );
1034 QStringList filterList;
1036 const thread_local QRegularExpression rx(
"\\(([^()]+)\\)" );
1037 QRegularExpressionMatchIterator matchIt = rx.globalMatch( filterName );
1038 if ( !matchIt.hasNext() )
1040 filterList << filterName;
1044 while ( matchIt.hasNext() )
1046 const QRegularExpressionMatch match = matchIt.next();
1047 if ( match.hasMatch() )
1049 QStringList matches = match.capturedTexts();
1050 matches.pop_front();
1051 filterList.append( matches );
1057 if ( request.
deletes.size() != filterList.size() )
1063 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1064 QStringList::const_iterator filterIt = filterList.constBegin();
1065 for ( ; dIt != request.
deletes.end(); ++dIt )
1070 QDomDocument filter;
1071 if ( filterIt != filterList.constEnd() )
1074 if ( !filter.setContent( *filterIt,
true, &errorMsg ) )
1080 QDomElement filterElem = filter.firstChildElement();
1081 QStringList serverFids;
1085 if ( filterIt != filterList.constEnd() )
1100 QDomNodeList docChildNodes = docElem.childNodes();
1102 QDomElement actionElem;
1105 for (
int i = docChildNodes.count(); 0 < i; --i )
1107 actionElem = docChildNodes.at( i - 1 ).toElement();
1108 actionName = actionElem.localName();
1110 if ( actionName ==
"Insert"_L1 )
1113 request.
inserts.append( action );
1115 else if ( actionName ==
"Update"_L1 )
1118 request.
updates.append( action );
1120 else if ( actionName ==
"Delete"_L1 )
1123 request.
deletes.append( action );
1132 QString typeName = actionElem.attribute( u
"typeName"_s );
1133 if ( typeName.contains(
':' ) )
1134 typeName = typeName.section(
':', 1, 1 );
1136 QDomElement filterElem = actionElem.firstChild().toElement();
1137 if ( filterElem.tagName() !=
"Filter"_L1 )
1142 QStringList serverFids;
1149 action.
error =
false;
1151 if ( actionElem.hasAttribute( u
"handle"_s ) )
1153 action.
handle = actionElem.attribute( u
"handle"_s );
1161 QString typeName = actionElem.attribute( u
"typeName"_s );
1162 if ( typeName.contains(
':' ) )
1163 typeName = typeName.section(
':', 1, 1 );
1165 QDomNodeList propertyNodeList = actionElem.elementsByTagName( u
"Property"_s );
1166 if ( propertyNodeList.isEmpty() )
1171 QMap<QString, QString> propertyMap;
1172 QDomElement propertyElem;
1173 QDomElement nameElem;
1174 QDomElement valueElem;
1175 QDomElement geometryElem;
1177 for (
int l = 0; l < propertyNodeList.count(); ++l )
1179 propertyElem = propertyNodeList.at( l ).toElement();
1180 nameElem = propertyElem.elementsByTagName( u
"Name"_s ).at( 0 ).toElement();
1181 valueElem = propertyElem.elementsByTagName( u
"Value"_s ).at( 0 ).toElement();
1182 if ( nameElem.text() !=
"geometry"_L1 )
1184 propertyMap.insert( nameElem.text(), valueElem.text() );
1188 geometryElem = valueElem;
1192 QDomNodeList filterNodeList = actionElem.elementsByTagName( u
"Filter"_s );
1194 QStringList serverFids;
1195 if ( filterNodeList.size() != 0 )
1197 QDomElement filterElem = filterNodeList.at( 0 ).toElement();
1207 action.
error =
false;
1209 if ( actionElem.hasAttribute( u
"handle"_s ) )
1211 action.
handle = actionElem.attribute( u
"handle"_s );
1219 QDomNodeList featureNodeList = actionElem.childNodes();
1220 if ( featureNodeList.size() != 1 )
1226 for (
int i = 0; i < featureNodeList.count(); ++i )
1228 QString tempTypeName = featureNodeList.at( i ).toElement().localName();
1229 if ( tempTypeName.contains(
':' ) )
1230 tempTypeName = tempTypeName.section(
':', 1, 1 );
1232 if ( typeName.isEmpty() )
1234 typeName = tempTypeName;
1236 else if ( tempTypeName != typeName )
1245 action.
error =
false;
1247 if ( actionElem.hasAttribute( u
"handle"_s ) )
1249 action.
handle = actionElem.attribute( u
"handle"_s );
1258 void addTransactionResult( QDomDocument &responseDoc, QDomElement &responseElem,
const QString &status,
const QString &locator,
const QString &message )
1260 QDomElement trElem = responseDoc.createElement( u
"TransactionResult"_s );
1261 QDomElement stElem = responseDoc.createElement( u
"Status"_s );
1262 QDomElement successElem = responseDoc.createElement( status );
1263 stElem.appendChild( successElem );
1264 trElem.appendChild( stElem );
1265 responseElem.appendChild( trElem );
1267 if ( !locator.isEmpty() )
1269 QDomElement locElem = responseDoc.createElement( u
"Locator"_s );
1270 locElem.appendChild( responseDoc.createTextNode( locator ) );
1271 trElem.appendChild( locElem );
1274 if ( !message.isEmpty() )
1276 QDomElement mesElem = responseDoc.createElement( u
"Message"_s );
1277 mesElem.appendChild( responseDoc.createTextNode( message ) );
1278 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(), Qgis::StringFormat format=Qgis::StringFormat::PlainText)
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