41#include <QRegularExpression>
49 void addTransactionResult( QDomDocument &responseDoc, QDomElement &responseElem,
const QString &status,
const QString &locator,
const QString &message );
58 response.
setHeader(
"Content-Type",
"text/xml; charset=utf-8" );
59 response.
write( doc.toByteArray() );
72 if ( doc.setContent( request.
data(),
true, &errorMsg ) )
74 QDomElement docElem = doc.documentElement();
83 if ( actionCount == 0 )
94 QDomElement respElem = resp.createElement( QStringLiteral(
"WFS_TransactionResponse" ) );
95 respElem.setAttribute( QStringLiteral(
"xmlns" ),
WFS_NAMESPACE );
96 respElem.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
97 respElem.setAttribute( QStringLiteral(
"xsi:schemaLocation" ),
WFS_NAMESPACE +
" http://schemas.opengis.net/wfs/1.0.0/wfs.xsd" );
98 respElem.setAttribute( QStringLiteral(
"xmlns:ogc" ),
OGC_NAMESPACE );
99 respElem.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0.0" ) );
100 resp.appendChild( respElem );
103 QStringList errorLocators;
104 QStringList errorMessages;
106 QList<transactionUpdate>::iterator tuIt = aRequest.
updates.begin();
107 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
113 if ( action.
handle.isEmpty() )
115 errorLocators << QStringLiteral(
"Update:%1" ).arg( action.
typeName );
119 errorLocators << action.
handle;
125 QList<transactionDelete>::iterator tdIt = aRequest.
deletes.begin();
126 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
132 if ( action.
handle.isEmpty() )
134 errorLocators << QStringLiteral(
"Delete:%1" ).arg( action.
typeName );
138 errorLocators << action.
handle;
144 QList<transactionInsert>::iterator tiIt = aRequest.
inserts.begin();
145 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
151 if ( action.
handle.isEmpty() )
153 errorLocators << QStringLiteral(
"Insert:%1" ).arg( action.
typeName );
157 errorLocators << action.
handle;
166 QString fidStr = *fidIt;
167 QDomElement irElem = doc.createElement( QStringLiteral(
"InsertResult" ) );
168 if ( !action.
handle.isEmpty() )
170 irElem.setAttribute( QStringLiteral(
"handle" ), action.
handle );
172 QDomElement fiElem = doc.createElement( QStringLiteral(
"ogc:FeatureId" ) );
173 fiElem.setAttribute( QStringLiteral(
"fid" ), fidStr );
174 irElem.appendChild( fiElem );
175 respElem.appendChild( irElem );
181 if ( errorCount == 0 )
183 addTransactionResult( resp, respElem, QStringLiteral(
"SUCCESS" ), QString(), QString() );
187 QString locator = errorLocators.join( QLatin1String(
"; " ) );
188 QString message = errorMessages.join( QLatin1String(
"; " ) );
189 if ( errorCount != actionCount )
191 addTransactionResult( resp, respElem, QStringLiteral(
"PARTIAL" ), locator, message );
195 addTransactionResult( resp, respElem, QStringLiteral(
"ERROR" ), locator, message );
204 QStringList typeNameList;
206 QList<transactionInsert>::iterator tiIt = aRequest.
inserts.begin();
207 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
209 QString name = ( *tiIt ).typeName;
210 if ( !typeNameList.contains( name ) )
211 typeNameList << name;
213 QList<transactionUpdate>::iterator tuIt = aRequest.
updates.begin();
214 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
216 QString name = ( *tuIt ).typeName;
217 if ( !typeNameList.contains( name ) )
218 typeNameList << name;
220 QList<transactionDelete>::iterator tdIt = aRequest.
deletes.begin();
221 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
223 QString name = ( *tdIt ).typeName;
224 if ( !typeNameList.contains( name ) )
225 typeNameList << name;
228#ifdef HAVE_SERVER_PYTHON_PLUGINS
232 ( void ) serverIface;
237 auto filterRestorer = std::make_unique<QgsOWSServerFilterRestorer>();
244 QMap<QString, QgsVectorLayer *> mapLayerMap;
245 for (
int i = 0; i < wfsLayerIds.size(); ++i )
255 if ( !typeNameList.contains( name ) )
282 if ( !wfstUpdateLayerIds.contains( vlayer->
id() )
283 && !wfstDeleteLayerIds.contains( vlayer->
id() )
284 && !wfstInsertLayerIds.contains( vlayer->
id() ) )
288#ifdef HAVE_SERVER_PYTHON_PLUGINS
301 mapLayerMap[name] = vlayer;
305 tuIt = aRequest.
updates.begin();
306 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
311 if ( !mapLayerMap.contains( typeName ) )
314 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
322 if ( !wfstUpdateLayerIds.contains( vlayer->
id() ) )
325 action.
errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg( typeName );
328#ifdef HAVE_SERVER_PYTHON_PLUGINS
332 action.
errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg( typeName );
344 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS updates on layer '%1'" ).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 = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).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 = QStringLiteral(
"NOT NULL constraint error on layer '%1', field '%2'" ).arg( typeName, field.
name() );
422 if ( field.
type() == QMetaType::Type::Int )
424 value = it.value().toInt( &conversionSuccess );
425 if ( !conversionSuccess )
428 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
433 else if ( field.
type() == QMetaType::Type::Double )
435 value = it.value().toDouble( &conversionSuccess );
436 if ( !conversionSuccess )
439 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
444 else if ( field.
type() == QMetaType::Type::LongLong )
446 value = it.value().toLongLong( &conversionSuccess );
447 if ( !conversionSuccess )
450 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
463 if ( !geometryElem.isNull() )
471 action.
errorMsg = QStringLiteral(
"Geometry from GML error on layer '%1'" ).arg( typeName );
478 action.
errorMsg = QStringLiteral(
"Error in change geometry on layer '%1'" ).arg( typeName );
488#ifdef HAVE_SERVER_PYTHON_PLUGINS
495 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
498 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
514 action.
errorMsg = QStringLiteral(
"Error committing updates: %1" ).arg( vlayer->
commitErrors().join( QLatin1String(
"; " ) ) );
519 action.
error =
false;
523 tdIt = aRequest.
deletes.begin();
524 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
529 if ( !mapLayerMap.contains( typeName ) )
532 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
540 if ( !wfstDeleteLayerIds.contains( vlayer->
id() ) )
543 action.
errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg( typeName );
546#ifdef HAVE_SERVER_PYTHON_PLUGINS
550 action.
errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg( typeName );
562 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS deletes on layer '%1'" ).arg( typeName );
582 action.
errorMsg = QStringLiteral(
"No feature ids to do WFS deletes on layer '%1'" ).arg( typeName );
589#ifdef HAVE_SERVER_PYTHON_PLUGINS
603#ifdef HAVE_SERVER_PYTHON_PLUGINS
604 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
607 action.
errorMsg = QStringLiteral(
"Feature modify permission denied" );
612 fids << feature.
id();
622 action.
errorMsg = QStringLiteral(
"Delete features failed on layer '%1'" ).arg( typeName );
631 action.
errorMsg = QStringLiteral(
"Error committing deletes: %1" ).arg( vlayer->
commitErrors().join( QLatin1String(
"; " ) ) );
636 action.
error =
false;
640 tiIt = aRequest.
inserts.begin();
641 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
646 if ( !mapLayerMap.contains( typeName ) )
649 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
657 if ( !wfstInsertLayerIds.contains( vlayer->
id() ) )
660 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
663#ifdef HAVE_SERVER_PYTHON_PLUGINS
667 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
679 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS inserts on layer '%1'" ).arg( typeName );
695 action.
errorMsg = QStringLiteral(
"%1 '%2'" ).arg( ex.
message(), typeName );
699 if ( featureList.empty() )
702 action.
errorMsg = QStringLiteral(
"No features to insert in layer '%1'" ).arg( typeName );
706#ifdef HAVE_SERVER_PYTHON_PLUGINS
710 QgsFeatureList::iterator featureIt = featureList.begin();
711 while ( featureIt != featureList.end() )
713 if ( !accessControl->
allowToEdit( vlayer, *featureIt ) )
716 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
733 action.
errorMsg = QStringLiteral(
"Insert features failed on layer '%1'" ).arg( typeName );
746 action.
errorMsg = QStringLiteral(
"Error committing inserts: %1" ).arg( vlayer->
commitErrors().join( QLatin1String(
"; " ) ) );
751 action.
error =
false;
755 for (
const QgsFeature &feat : std::as_const( featureList ) )
762 filterRestorer.reset();
771 Q_ASSERT( provider );
775 const QMap<QString, int> fieldMap = provider->fieldNameMap();
776 QMap<QString, int>::const_iterator fieldMapIt;
778 for (
int i = 0; i < featureNodeList.count(); i++ )
782 QDomElement featureElem = featureNodeList.at( i ).toElement();
783 QDomNode currentAttributeChild = featureElem.firstChild();
784 bool conversionSuccess =
true;
786 for ( ; !currentAttributeChild.isNull(); currentAttributeChild = currentAttributeChild.nextSibling() )
788 QDomElement currentAttributeElement = currentAttributeChild.toElement();
789 QString attrName = currentAttributeElement.localName();
791 if ( attrName != QLatin1String(
"boundedBy" ) )
793 if ( attrName != QLatin1String(
"geometry" ) )
795 fieldMapIt = fieldMap.find( attrName );
796 if ( fieldMapIt == fieldMap.constEnd() )
802 QgsField field = fields.
at( fieldMapIt.value() );
803 QString attrValue = currentAttributeElement.text();
804 int attrType = field.
type();
806 QgsMessageLog::logMessage( QStringLiteral(
"attr: name=%1 idx=%2 value=%3" ).arg( attrName ).arg( fieldMapIt.value() ).arg( attrValue ) );
808 if ( attrType == QMetaType::Type::Int )
809 feat.
setAttribute( fieldMapIt.value(), attrValue.toInt( &conversionSuccess ) );
810 else if ( attrType == QMetaType::Type::Double )
811 feat.
setAttribute( fieldMapIt.value(), attrValue.toDouble( &conversionSuccess ) );
815 if ( !conversionSuccess )
840 if ( !parameters.contains( QStringLiteral(
"OPERATION" ) ) )
844 if ( parameters.value( QStringLiteral(
"OPERATION" ) ).toUpper() != QLatin1String(
"DELETE" ) )
850 if ( ( parameters.contains( QStringLiteral(
"FEATUREID" ) )
851 && ( parameters.contains( QStringLiteral(
"FILTER" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
852 || ( parameters.contains( QStringLiteral(
"FILTER" ) ) && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
853 || ( parameters.contains( QStringLiteral(
"BBOX" ) ) && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"FILTER" ) ) ) ) )
860 QStringList typeNameList;
862 if ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) )
864 QStringList fidList = parameters.value( QStringLiteral(
"FEATUREID" ) ).split(
',' );
866 QMap<QString, QStringList> fidsMap;
868 QStringList::const_iterator fidIt = fidList.constBegin();
869 for ( ; fidIt != fidList.constEnd(); ++fidIt )
872 QString fid = *fidIt;
875 if ( !fid.contains(
'.' ) )
880 QString typeName = fid.section(
'.', 0, 0 );
881 fid = fid.section(
'.', 1, 1 );
882 if ( !typeNameList.contains( typeName ) )
884 typeNameList << typeName;
888 if ( fidsMap.contains( typeName ) )
890 fids = fidsMap.value( typeName );
893 fidsMap.insert( typeName, fids );
896 QMap<QString, QStringList>::const_iterator fidsMapIt = fidsMap.constBegin();
897 for ( ; fidsMapIt != fidsMap.constEnd(); ++fidsMapIt )
905 request.
deletes.append( action );
910 if ( !parameters.contains( QStringLiteral(
"TYPENAME" ) ) )
915 typeNameList = parameters.value( QStringLiteral(
"TYPENAME" ) ).split(
',' );
918 QStringList::const_iterator typeNameIt = typeNameList.constBegin();
919 for ( ; typeNameIt != typeNameList.constEnd(); ++typeNameIt )
921 QString typeName = *typeNameIt;
922 typeName = typeName.trimmed();
927 request.
deletes.append( action );
931 if ( parameters.contains( QStringLiteral(
"EXP_FILTER" ) ) )
933 QString expFilterName = parameters.value( QStringLiteral(
"EXP_FILTER" ) );
934 QStringList expFilterList;
935 const thread_local QRegularExpression rx(
"\\(([^()]+)\\)" );
936 QRegularExpressionMatchIterator matchIt = rx.globalMatch( expFilterName );
937 if ( !matchIt.hasNext() )
939 expFilterList << expFilterName;
943 while ( matchIt.hasNext() )
945 const QRegularExpressionMatch match = matchIt.next();
946 if ( match.hasMatch() )
948 QStringList matches = match.capturedTexts();
950 expFilterList.append( matches );
956 if ( request.
deletes.size() == expFilterList.size() )
959 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
960 QStringList::const_iterator expFilterIt = expFilterList.constBegin();
961 for ( ; dIt != request.
deletes.end(); ++dIt )
966 if ( expFilterIt != expFilterList.constEnd() )
968 expFilter = *expFilterIt;
970 std::shared_ptr<QgsExpression> filter(
new QgsExpression( expFilter ) );
973 if ( filter->hasParserError() )
979 if ( filter->needsGeometry() )
994 if ( parameters.contains( QStringLiteral(
"BBOX" ) ) )
997 QString bbox = parameters.value( QStringLiteral(
"BBOX" ) );
998 if ( bbox.isEmpty() )
1004 QStringList corners = bbox.split(
',' );
1005 if ( corners.size() != 4 )
1013 for (
int i = 0; i < 4; i++ )
1015 corners[i].replace(
' ',
'+' );
1016 d[i] = corners[i].toDouble( &ok );
1026 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1027 for ( ; dIt != request.
deletes.end(); ++dIt )
1034 else if ( parameters.contains( QStringLiteral(
"FILTER" ) ) )
1036 QString filterName = parameters.value( QStringLiteral(
"FILTER" ) );
1037 QStringList filterList;
1039 const thread_local QRegularExpression rx(
"\\(([^()]+)\\)" );
1040 QRegularExpressionMatchIterator matchIt = rx.globalMatch( filterName );
1041 if ( !matchIt.hasNext() )
1043 filterList << filterName;
1047 while ( matchIt.hasNext() )
1049 const QRegularExpressionMatch match = matchIt.next();
1050 if ( match.hasMatch() )
1052 QStringList matches = match.capturedTexts();
1053 matches.pop_front();
1054 filterList.append( matches );
1060 if ( request.
deletes.size() != filterList.size() )
1066 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1067 QStringList::const_iterator filterIt = filterList.constBegin();
1068 for ( ; dIt != request.
deletes.end(); ++dIt )
1073 QDomDocument filter;
1074 if ( filterIt != filterList.constEnd() )
1077 if ( !filter.setContent( *filterIt,
true, &errorMsg ) )
1083 QDomElement filterElem = filter.firstChildElement();
1084 QStringList serverFids;
1088 if ( filterIt != filterList.constEnd() )
1103 QDomNodeList docChildNodes = docElem.childNodes();
1105 QDomElement actionElem;
1108 for (
int i = docChildNodes.count(); 0 < i; --i )
1110 actionElem = docChildNodes.at( i - 1 ).toElement();
1111 actionName = actionElem.localName();
1113 if ( actionName == QLatin1String(
"Insert" ) )
1116 request.
inserts.append( action );
1118 else if ( actionName == QLatin1String(
"Update" ) )
1121 request.
updates.append( action );
1123 else if ( actionName == QLatin1String(
"Delete" ) )
1126 request.
deletes.append( action );
1135 QString typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1136 if ( typeName.contains(
':' ) )
1137 typeName = typeName.section(
':', 1, 1 );
1139 QDomElement filterElem = actionElem.firstChild().toElement();
1140 if ( filterElem.tagName() != QLatin1String(
"Filter" ) )
1145 QStringList serverFids;
1152 action.
error =
false;
1154 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1156 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1164 QString typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1165 if ( typeName.contains(
':' ) )
1166 typeName = typeName.section(
':', 1, 1 );
1168 QDomNodeList propertyNodeList = actionElem.elementsByTagName( QStringLiteral(
"Property" ) );
1169 if ( propertyNodeList.isEmpty() )
1174 QMap<QString, QString> propertyMap;
1175 QDomElement propertyElem;
1176 QDomElement nameElem;
1177 QDomElement valueElem;
1178 QDomElement geometryElem;
1180 for (
int l = 0; l < propertyNodeList.count(); ++l )
1182 propertyElem = propertyNodeList.at( l ).toElement();
1183 nameElem = propertyElem.elementsByTagName( QStringLiteral(
"Name" ) ).at( 0 ).toElement();
1184 valueElem = propertyElem.elementsByTagName( QStringLiteral(
"Value" ) ).at( 0 ).toElement();
1185 if ( nameElem.text() != QLatin1String(
"geometry" ) )
1187 propertyMap.insert( nameElem.text(), valueElem.text() );
1191 geometryElem = valueElem;
1195 QDomNodeList filterNodeList = actionElem.elementsByTagName( QStringLiteral(
"Filter" ) );
1197 QStringList serverFids;
1198 if ( filterNodeList.size() != 0 )
1200 QDomElement filterElem = filterNodeList.at( 0 ).toElement();
1210 action.
error =
false;
1212 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1214 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1222 QDomNodeList featureNodeList = actionElem.childNodes();
1223 if ( featureNodeList.size() != 1 )
1229 for (
int i = 0; i < featureNodeList.count(); ++i )
1231 QString tempTypeName = featureNodeList.at( i ).toElement().localName();
1232 if ( tempTypeName.contains(
':' ) )
1233 tempTypeName = tempTypeName.section(
':', 1, 1 );
1235 if ( typeName.isEmpty() )
1237 typeName = tempTypeName;
1239 else if ( tempTypeName != typeName )
1248 action.
error =
false;
1250 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1252 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1261 void addTransactionResult( QDomDocument &responseDoc, QDomElement &responseElem,
const QString &status,
const QString &locator,
const QString &message )
1263 QDomElement trElem = responseDoc.createElement( QStringLiteral(
"TransactionResult" ) );
1264 QDomElement stElem = responseDoc.createElement( QStringLiteral(
"Status" ) );
1265 QDomElement successElem = responseDoc.createElement( status );
1266 stElem.appendChild( successElem );
1267 trElem.appendChild( stElem );
1268 responseElem.appendChild( trElem );
1270 if ( !locator.isEmpty() )
1272 QDomElement locElem = responseDoc.createElement( QStringLiteral(
"Locator" ) );
1273 locElem.appendChild( responseDoc.createTextNode( locator ) );
1274 trElem.appendChild( locElem );
1277 if ( !message.isEmpty() )
1279 QDomElement mesElem = responseDoc.createElement( QStringLiteral(
"Message" ) );
1280 mesElem.appendChild( responseDoc.createTextNode( message ) );
1281 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