40#include <QRegularExpression>
48 void addTransactionResult( QDomDocument &responseDoc, QDomElement &responseElem,
const QString &status,
const QString &locator,
const QString &message );
57 response.
setHeader(
"Content-Type",
"text/xml; charset=utf-8" );
58 response.
write( doc.toByteArray() );
71 if ( doc.setContent( request.
data(),
true, &errorMsg ) )
73 QDomElement docElem = doc.documentElement();
82 if ( actionCount == 0 )
93 QDomElement respElem = resp.createElement( QStringLiteral(
"WFS_TransactionResponse" ) );
94 respElem.setAttribute( QStringLiteral(
"xmlns" ),
WFS_NAMESPACE );
95 respElem.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
96 respElem.setAttribute( QStringLiteral(
"xsi:schemaLocation" ),
WFS_NAMESPACE +
" http://schemas.opengis.net/wfs/1.0.0/wfs.xsd" );
97 respElem.setAttribute( QStringLiteral(
"xmlns:ogc" ),
OGC_NAMESPACE );
98 respElem.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0.0" ) );
99 resp.appendChild( respElem );
102 QStringList errorLocators;
103 QStringList errorMessages;
105 QList<transactionUpdate>::iterator tuIt = aRequest.
updates.begin();
106 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
112 if ( action.
handle.isEmpty() )
114 errorLocators << QStringLiteral(
"Update:%1" ).arg( action.
typeName );
118 errorLocators << action.
handle;
124 QList<transactionDelete>::iterator tdIt = aRequest.
deletes.begin();
125 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
131 if ( action.
handle.isEmpty() )
133 errorLocators << QStringLiteral(
"Delete:%1" ).arg( action.
typeName );
137 errorLocators << action.
handle;
143 QList<transactionInsert>::iterator tiIt = aRequest.
inserts.begin();
144 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
150 if ( action.
handle.isEmpty() )
152 errorLocators << QStringLiteral(
"Insert:%1" ).arg( action.
typeName );
156 errorLocators << action.
handle;
165 QString fidStr = *fidIt;
166 QDomElement irElem = doc.createElement( QStringLiteral(
"InsertResult" ) );
167 if ( !action.
handle.isEmpty() )
169 irElem.setAttribute( QStringLiteral(
"handle" ), action.
handle );
171 QDomElement fiElem = doc.createElement( QStringLiteral(
"ogc:FeatureId" ) );
172 fiElem.setAttribute( QStringLiteral(
"fid" ), fidStr );
173 irElem.appendChild( fiElem );
174 respElem.appendChild( irElem );
180 if ( errorCount == 0 )
182 addTransactionResult( resp, respElem, QStringLiteral(
"SUCCESS" ), QString(), QString() );
186 QString locator = errorLocators.join( QLatin1String(
"; " ) );
187 QString message = errorMessages.join( QLatin1String(
"; " ) );
188 if ( errorCount != actionCount )
190 addTransactionResult( resp, respElem, QStringLiteral(
"PARTIAL" ), locator, message );
194 addTransactionResult( resp, respElem, QStringLiteral(
"ERROR" ), locator, message );
203 QStringList typeNameList;
205 QList<transactionInsert>::iterator tiIt = aRequest.
inserts.begin();
206 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
208 QString name = ( *tiIt ).typeName;
209 if ( !typeNameList.contains( name ) )
210 typeNameList << name;
212 QList<transactionUpdate>::iterator tuIt = aRequest.
updates.begin();
213 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
215 QString name = ( *tuIt ).typeName;
216 if ( !typeNameList.contains( name ) )
217 typeNameList << name;
219 QList<transactionDelete>::iterator tdIt = aRequest.
deletes.begin();
220 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
222 QString name = ( *tdIt ).typeName;
223 if ( !typeNameList.contains( name ) )
224 typeNameList << name;
227#ifdef HAVE_SERVER_PYTHON_PLUGINS
231 ( void ) serverIface;
243 QMap<QString, QgsVectorLayer *> mapLayerMap;
244 for (
int i = 0; i < wfsLayerIds.size(); ++i )
254 if ( !typeNameList.contains( name ) )
281 if ( !wfstUpdateLayerIds.contains( vlayer->
id() )
282 && !wfstDeleteLayerIds.contains( vlayer->
id() )
283 && !wfstInsertLayerIds.contains( vlayer->
id() ) )
287#ifdef HAVE_SERVER_PYTHON_PLUGINS
300 mapLayerMap[name] = vlayer;
304 tuIt = aRequest.
updates.begin();
305 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
310 if ( !mapLayerMap.contains(
typeName ) )
313 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg(
typeName );
321 if ( !wfstUpdateLayerIds.contains( vlayer->
id() ) )
324 action.
errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg(
typeName );
327#ifdef HAVE_SERVER_PYTHON_PLUGINS
331 action.
errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg(
typeName );
343 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS updates on layer '%1'" ).arg(
typeName );
366#ifdef HAVE_SERVER_PYTHON_PLUGINS
376 QMap<QString, QString> propertyMap = action.
propertyMap;
380 const QMap<QString, int> fieldMap = provider->
fieldNameMap();
381 QMap<QString, int>::const_iterator fieldMapIt;
383 bool conversionSuccess;
387#ifdef HAVE_SERVER_PYTHON_PLUGINS
388 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
391 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg(
typeName );
396 QMap<QString, QString>::const_iterator it = propertyMap.constBegin();
397 for ( ; it != propertyMap.constEnd(); ++it )
399 fieldName = it.key();
400 fieldMapIt = fieldMap.find( fieldName );
401 if ( fieldMapIt == fieldMap.constEnd() )
405 QgsField field = fields.
at( fieldMapIt.value() );
406 QVariant value = it.value();
412 action.
errorMsg = QStringLiteral(
"NOT NULL constraint error on layer '%1', field '%2'" ).arg(
typeName, field.
name() );
419 if ( field.
type() == QMetaType::Type::Int )
421 value = it.value().toInt( &conversionSuccess );
422 if ( !conversionSuccess )
425 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg(
typeName );
430 else if ( field.
type() == QMetaType::Type::Double )
432 value = it.value().toDouble( &conversionSuccess );
433 if ( !conversionSuccess )
436 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg(
typeName );
441 else if ( field.
type() == QMetaType::Type::LongLong )
443 value = it.value().toLongLong( &conversionSuccess );
444 if ( !conversionSuccess )
447 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg(
typeName );
460 if ( !geometryElem.isNull() )
468 action.
errorMsg = QStringLiteral(
"Geometry from GML error on layer '%1'" ).arg(
typeName );
475 action.
errorMsg = QStringLiteral(
"Error in change geometry on layer '%1'" ).arg(
typeName );
485#ifdef HAVE_SERVER_PYTHON_PLUGINS
492 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
495 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg(
typeName );
511 action.
errorMsg = QStringLiteral(
"Error committing updates: %1" ).arg( vlayer->
commitErrors().join( QLatin1String(
"; " ) ) );
516 action.
error =
false;
520 tdIt = aRequest.
deletes.begin();
521 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
526 if ( !mapLayerMap.contains(
typeName ) )
529 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg(
typeName );
537 if ( !wfstDeleteLayerIds.contains( vlayer->
id() ) )
540 action.
errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg(
typeName );
543#ifdef HAVE_SERVER_PYTHON_PLUGINS
547 action.
errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg(
typeName );
559 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS deletes on layer '%1'" ).arg(
typeName );
579 action.
errorMsg = QStringLiteral(
"No feature ids to do WFS deletes on layer '%1'" ).arg(
typeName );
586#ifdef HAVE_SERVER_PYTHON_PLUGINS
600#ifdef HAVE_SERVER_PYTHON_PLUGINS
601 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
604 action.
errorMsg = QStringLiteral(
"Feature modify permission denied" );
609 fids << feature.
id();
619 action.
errorMsg = QStringLiteral(
"Delete features failed on layer '%1'" ).arg(
typeName );
628 action.
errorMsg = QStringLiteral(
"Error committing deletes: %1" ).arg( vlayer->
commitErrors().join( QLatin1String(
"; " ) ) );
633 action.
error =
false;
637 tiIt = aRequest.
inserts.begin();
638 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
643 if ( !mapLayerMap.contains(
typeName ) )
646 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg(
typeName );
654 if ( !wfstInsertLayerIds.contains( vlayer->
id() ) )
657 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg(
typeName );
660#ifdef HAVE_SERVER_PYTHON_PLUGINS
664 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg(
typeName );
676 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS inserts on layer '%1'" ).arg(
typeName );
696 if ( featureList.empty() )
699 action.
errorMsg = QStringLiteral(
"No features to insert in layer '%1'" ).arg(
typeName );
703#ifdef HAVE_SERVER_PYTHON_PLUGINS
707 QgsFeatureList::iterator featureIt = featureList.begin();
708 while ( featureIt != featureList.end() )
710 if ( !accessControl->
allowToEdit( vlayer, *featureIt ) )
713 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg(
typeName );
730 action.
errorMsg = QStringLiteral(
"Insert features failed on layer '%1'" ).arg(
typeName );
743 action.
errorMsg = QStringLiteral(
"Error committing inserts: %1" ).arg( vlayer->
commitErrors().join( QLatin1String(
"; " ) ) );
748 action.
error =
false;
752 for (
const QgsFeature &feat : std::as_const( featureList ) )
759 filterRestorer.reset();
768 Q_ASSERT( provider );
772 const QMap<QString, int> fieldMap = provider->fieldNameMap();
773 QMap<QString, int>::const_iterator fieldMapIt;
775 for (
int i = 0; i < featureNodeList.count(); i++ )
779 QDomElement featureElem = featureNodeList.at( i ).toElement();
780 QDomNode currentAttributeChild = featureElem.firstChild();
781 bool conversionSuccess =
true;
783 while ( !currentAttributeChild.isNull() )
785 QDomElement currentAttributeElement = currentAttributeChild.toElement();
786 QString attrName = currentAttributeElement.localName();
788 if ( attrName != QLatin1String(
"boundedBy" ) )
790 if ( attrName != QLatin1String(
"geometry" ) )
792 fieldMapIt = fieldMap.find( attrName );
793 if ( fieldMapIt == fieldMap.constEnd() )
798 QgsField field = fields.
at( fieldMapIt.value() );
799 QString attrValue = currentAttributeElement.text();
800 int attrType = field.
type();
802 QgsMessageLog::logMessage( QStringLiteral(
"attr: name=%1 idx=%2 value=%3" ).arg( attrName ).arg( fieldMapIt.value() ).arg( attrValue ) );
804 if ( attrType == QMetaType::Type::Int )
805 feat.
setAttribute( fieldMapIt.value(), attrValue.toInt( &conversionSuccess ) );
806 else if ( attrType == QMetaType::Type::Double )
807 feat.
setAttribute( fieldMapIt.value(), attrValue.toDouble( &conversionSuccess ) );
811 if ( !conversionSuccess )
827 currentAttributeChild = currentAttributeChild.nextSibling();
837 if ( !parameters.contains( QStringLiteral(
"OPERATION" ) ) )
841 if ( parameters.value( QStringLiteral(
"OPERATION" ) ).toUpper() != QLatin1String(
"DELETE" ) )
847 if ( ( parameters.contains( QStringLiteral(
"FEATUREID" ) )
848 && ( parameters.contains( QStringLiteral(
"FILTER" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
849 || ( parameters.contains( QStringLiteral(
"FILTER" ) ) && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
850 || ( parameters.contains( QStringLiteral(
"BBOX" ) ) && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"FILTER" ) ) ) ) )
857 QStringList typeNameList;
859 if ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) )
861 QStringList fidList = parameters.value( QStringLiteral(
"FEATUREID" ) ).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 ) )
893 QMap<QString, QStringList>::const_iterator fidsMapIt = fidsMap.constBegin();
894 while ( fidsMapIt != fidsMap.constEnd() )
902 request.
deletes.append( action );
907 if ( !parameters.contains( QStringLiteral(
"TYPENAME" ) ) )
912 typeNameList = parameters.value( QStringLiteral(
"TYPENAME" ) ).split(
',' );
915 QStringList::const_iterator typeNameIt = typeNameList.constBegin();
916 for ( ; typeNameIt != typeNameList.constEnd(); ++typeNameIt )
924 request.
deletes.append( action );
928 if ( parameters.contains( QStringLiteral(
"EXP_FILTER" ) ) )
930 QString expFilterName = parameters.value( QStringLiteral(
"EXP_FILTER" ) );
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( QStringLiteral(
"BBOX" ) ) )
994 QString bbox = parameters.value( QStringLiteral(
"BBOX" ) );
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( QStringLiteral(
"FILTER" ) ) )
1033 QString filterName = parameters.value( QStringLiteral(
"FILTER" ) );
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 == QLatin1String(
"Insert" ) )
1113 request.
inserts.append( action );
1115 else if ( actionName == QLatin1String(
"Update" ) )
1118 request.
updates.append( action );
1120 else if ( actionName == QLatin1String(
"Delete" ) )
1123 request.
deletes.append( action );
1132 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1136 QDomElement filterElem = actionElem.firstChild().toElement();
1137 if ( filterElem.tagName() != QLatin1String(
"Filter" ) )
1142 QStringList serverFids;
1149 action.
error =
false;
1151 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1153 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1161 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1165 QDomNodeList propertyNodeList = actionElem.elementsByTagName( QStringLiteral(
"Property" ) );
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( QStringLiteral(
"Name" ) ).at( 0 ).toElement();
1181 valueElem = propertyElem.elementsByTagName( QStringLiteral(
"Value" ) ).at( 0 ).toElement();
1182 if ( nameElem.text() != QLatin1String(
"geometry" ) )
1184 propertyMap.insert( nameElem.text(), valueElem.text() );
1188 geometryElem = valueElem;
1192 QDomNodeList filterNodeList = actionElem.elementsByTagName( QStringLiteral(
"Filter" ) );
1194 QStringList serverFids;
1195 if ( filterNodeList.size() != 0 )
1197 QDomElement filterElem = filterNodeList.at( 0 ).toElement();
1207 action.
error =
false;
1209 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1211 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
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 );
1236 else if ( tempTypeName !=
typeName )
1245 action.
error =
false;
1247 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1249 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1258 void addTransactionResult( QDomDocument &responseDoc, QDomElement &responseElem,
const QString &status,
const QString &locator,
const QString &message )
1260 QDomElement trElem = responseDoc.createElement( QStringLiteral(
"TransactionResult" ) );
1261 QDomElement stElem = responseDoc.createElement( QStringLiteral(
"Status" ) );
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( QStringLiteral(
"Locator" ) );
1270 locElem.appendChild( responseDoc.createTextNode( locator ) );
1271 trElem.appendChild( locElem );
1274 if ( !message.isEmpty() )
1276 QDomElement mesElem = responseDoc.createElement( QStringLiteral(
"Message" ) );
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...
Class for 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.
This class 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.
Base class for all map layer types.
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)
Adds a message to the log instance (and creates it if necessary).
RAII class to restore layer filters on destruction.
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.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
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.
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
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.
This is the 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 data sets.
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).
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
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...
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
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.
SERVER_EXPORT QgsFeatureRequest updateFeatureRequestFromServerFids(QgsFeatureRequest &featureRequest, const QStringList &serverFids, const QgsVectorDataProvider *provider)
Returns the feature request based on feature ids build with primary keys.
SERVER_EXPORT QString getServerFid(const QgsFeature &feature, const QgsAttributeList &pkAttributes)
Returns the feature id based on primary keys.
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
SERVER_EXPORT QStringList wfstUpdateLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published as WFS-T with update capabilities.
SERVER_EXPORT QStringList wfstInsertLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published as WFS-T with insert capabilities.
SERVER_EXPORT QStringList wfstDeleteLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published as WFS-T with delete capabilities.
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.
QString layerTypeName(const QgsMapLayer *layer)
Returns typename from vector layer.
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.
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