46 void addTransactionResult( QDomDocument &responseDoc, QDomElement &responseElem,
const QString &status,
47 const QString &locator,
const QString &message );
58 response.
setHeader(
"Content-Type",
"text/xml; charset=utf-8" );
59 response.
write( doc.toByteArray() );
73 if ( doc.setContent( parameters.value( QStringLiteral(
"REQUEST_BODY" ) ),
true, &errorMsg ) )
75 QDomElement docElem = doc.documentElement();
84 if ( actionCount == 0 )
95 QDomElement respElem = resp.createElement( QStringLiteral(
"WFS_TransactionResponse" ) );
96 respElem.setAttribute( QStringLiteral(
"xmlns" ),
WFS_NAMESPACE );
97 respElem.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
98 respElem.setAttribute( QStringLiteral(
"xsi:schemaLocation" ),
WFS_NAMESPACE +
" http://schemas.opengis.net/wfs/1.0.0/wfs.xsd" );
99 respElem.setAttribute( QStringLiteral(
"xmlns:ogc" ),
OGC_NAMESPACE );
100 respElem.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.0.0" ) );
101 resp.appendChild( respElem );
104 QStringList errorLocators;
105 QStringList errorMessages;
107 QList<transactionUpdate>::iterator tuIt = aRequest.
updates.begin();
108 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
114 if ( action.
handle.isEmpty() )
116 errorLocators << QStringLiteral(
"Update:%1" ).arg( action.
typeName );
120 errorLocators << action.
handle;
126 QList<transactionDelete>::iterator tdIt = aRequest.
deletes.begin();
127 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
133 if ( action.
handle.isEmpty() )
135 errorLocators << QStringLiteral(
"Delete:%1" ).arg( action.
typeName );
139 errorLocators << action.
handle;
145 QList<transactionInsert>::iterator tiIt = aRequest.
inserts.begin();
146 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
152 if ( action.
handle.isEmpty() )
154 errorLocators << QStringLiteral(
"Insert:%1" ).arg( action.
typeName );
158 errorLocators << action.
handle;
167 QString fidStr = *fidIt;
168 QDomElement irElem = doc.createElement( QStringLiteral(
"InsertResult" ) );
169 if ( !action.
handle.isEmpty() )
171 irElem.setAttribute( QStringLiteral(
"handle" ), action.
handle );
173 QDomElement fiElem = doc.createElement( QStringLiteral(
"ogc:FeatureId" ) );
174 fiElem.setAttribute( QStringLiteral(
"fid" ), fidStr );
175 irElem.appendChild( fiElem );
176 respElem.appendChild( irElem );
182 if ( errorCount == 0 )
184 addTransactionResult( resp, respElem, QStringLiteral(
"SUCCESS" ), QString(), QString() );
188 QString locator = errorLocators.join( QStringLiteral(
"; " ) );
189 QString message = errorMessages.join( QStringLiteral(
"; " ) );
190 if ( errorCount != actionCount )
192 addTransactionResult( resp, respElem, QStringLiteral(
"PARTIAL" ), locator, message );
196 addTransactionResult( resp, respElem, QStringLiteral(
"ERROR" ), locator, message );
205 QStringList typeNameList;
207 QList<transactionInsert>::iterator tiIt = aRequest.
inserts.begin();
208 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
210 QString name = ( *tiIt ).typeName;
211 if ( !typeNameList.contains( name ) )
212 typeNameList << name;
214 QList<transactionUpdate>::iterator tuIt = aRequest.
updates.begin();
215 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
217 QString name = ( *tuIt ).typeName;
218 if ( !typeNameList.contains( name ) )
219 typeNameList << name;
221 QList<transactionDelete>::iterator tdIt = aRequest.
deletes.begin();
222 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
224 QString name = ( *tdIt ).typeName;
225 if ( !typeNameList.contains( name ) )
226 typeNameList << name;
229 #ifdef HAVE_SERVER_PYTHON_PLUGINS 245 QMap<QString, QgsVectorLayer *> mapLayerMap;
246 for (
int i = 0; i < wfsLayerIds.size(); ++i )
256 if ( !typeNameList.contains( name ) )
283 if ( !wfstUpdateLayerIds.contains( vlayer->
id() )
284 && !wfstDeleteLayerIds.contains( vlayer->
id() )
285 && !wfstInsertLayerIds.contains( vlayer->
id() ) )
289 #ifdef HAVE_SERVER_PYTHON_PLUGINS 302 mapLayerMap[name] = vlayer;
306 tuIt = aRequest.
updates.begin();
307 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
312 if ( !mapLayerMap.keys().contains( typeName ) )
315 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
323 if ( !wfstUpdateLayerIds.contains( vlayer->
id() ) )
326 action.
errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg( typeName );
329 #ifdef HAVE_SERVER_PYTHON_PLUGINS 333 action.
errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg( typeName );
345 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS updates on layer '%1'" ).arg( typeName );
368 #ifdef HAVE_SERVER_PYTHON_PLUGINS 378 QMap<QString, QString> propertyMap = action.
propertyMap;
382 const QMap<QString, int> fieldMap = provider->
fieldNameMap();
383 QMap<QString, int>::const_iterator fieldMapIt;
385 bool conversionSuccess;
389 #ifdef HAVE_SERVER_PYTHON_PLUGINS 390 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
393 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
398 QMap< QString, QString >::const_iterator it = propertyMap.constBegin();
399 for ( ; it != propertyMap.constEnd(); ++it )
401 fieldName = it.key();
402 fieldMapIt = fieldMap.find( fieldName );
403 if ( fieldMapIt == fieldMap.constEnd() )
407 QgsField field = fields.
at( fieldMapIt.value() );
408 QVariant value = it.value();
409 if ( value.isNull() )
414 action.
errorMsg = QStringLiteral(
"NOT NULL constraint error on layer '%1', field '%2'" ).arg( typeName, field.
name() );
421 if ( field.
type() == QVariant::Type::Int )
423 value = it.value().toInt( &conversionSuccess );
424 if ( !conversionSuccess )
427 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
432 else if ( field.
type() == QVariant::Type::Double )
434 value = it.value().toDouble( &conversionSuccess );
435 if ( !conversionSuccess )
438 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
443 else if ( field.
type() == QVariant::Type::LongLong )
445 value = it.value().toLongLong( &conversionSuccess );
446 if ( !conversionSuccess )
449 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
462 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( QStringLiteral(
"; " ) ) );
516 action.
error =
false;
521 tdIt = aRequest.
deletes.begin();
522 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
527 if ( !mapLayerMap.keys().contains( typeName ) )
530 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
538 if ( !wfstDeleteLayerIds.contains( vlayer->
id() ) )
541 action.
errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg( typeName );
544 #ifdef HAVE_SERVER_PYTHON_PLUGINS 548 action.
errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg( typeName );
560 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS deletes on layer '%1'" ).arg( typeName );
580 action.
errorMsg = QStringLiteral(
"No feature ids to do WFS deletes on layer '%1'" ).arg( typeName );
587 #ifdef HAVE_SERVER_PYTHON_PLUGINS 601 #ifdef HAVE_SERVER_PYTHON_PLUGINS 602 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
605 action.
errorMsg = QStringLiteral(
"Feature modify permission denied" );
610 fids << feature.
id();
620 action.
errorMsg = QStringLiteral(
"Delete features failed on layer '%1'" ).arg( typeName );
629 action.
errorMsg = QStringLiteral(
"Error committing deletes: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
634 action.
error =
false;
638 tiIt = aRequest.
inserts.begin();
639 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
644 if ( !mapLayerMap.keys().contains( typeName ) )
647 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
655 if ( !wfstInsertLayerIds.contains( vlayer->
id() ) )
658 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
661 #ifdef HAVE_SERVER_PYTHON_PLUGINS 665 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
677 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS inserts on layer '%1'" ).arg( typeName );
693 action.
errorMsg = QStringLiteral(
"%1 '%2'" ).arg( ex.
message() ).arg( typeName );
697 if ( featureList.empty() )
700 action.
errorMsg = QStringLiteral(
"No features to insert in layer '%1'" ).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 = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
731 action.
errorMsg = QStringLiteral(
"Insert features failed on layer '%1'" ).arg( typeName );
732 if ( provider ->hasErrors() )
744 action.
errorMsg = QStringLiteral(
"Error committing inserts: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
749 action.
error =
false;
753 for (
const QgsFeature &feat : qgis::as_const( featureList ) )
760 filterRestorer.reset();
770 const QMap<QString, int> fieldMap = provider->
fieldNameMap();
771 QMap<QString, int>::const_iterator fieldMapIt;
773 for (
int i = 0; i < featureNodeList.count(); i++ )
777 QDomElement featureElem = featureNodeList.at( i ).toElement();
778 QDomNode currentAttributeChild = featureElem.firstChild();
779 bool conversionSuccess =
true;
781 while ( !currentAttributeChild.isNull() )
783 QDomElement currentAttributeElement = currentAttributeChild.toElement();
784 QString attrName = currentAttributeElement.localName();
786 if ( attrName != QLatin1String(
"boundedBy" ) )
788 if ( attrName != QLatin1String(
"geometry" ) )
790 fieldMapIt = fieldMap.find( attrName );
791 if ( fieldMapIt == fieldMap.constEnd() )
796 QgsField field = fields.
at( fieldMapIt.value() );
797 QString attrValue = currentAttributeElement.text();
798 int attrType = field.
type();
800 QgsMessageLog::logMessage( QStringLiteral(
"attr: name=%1 idx=%2 value=%3" ).arg( attrName ).arg( fieldMapIt.value() ).arg( attrValue ) );
802 if ( attrType == QVariant::Int )
803 feat.
setAttribute( fieldMapIt.value(), attrValue.toInt( &conversionSuccess ) );
804 else if ( attrType == QVariant::Double )
805 feat.
setAttribute( fieldMapIt.value(), attrValue.toDouble( &conversionSuccess ) );
809 if ( !conversionSuccess )
824 currentAttributeChild = currentAttributeChild.nextSibling();
834 if ( !parameters.contains( QStringLiteral(
"OPERATION" ) ) )
838 if ( parameters.value( QStringLiteral(
"OPERATION" ) ).toUpper() != QStringLiteral(
"DELETE" ) )
844 if ( ( parameters.contains( QStringLiteral(
"FEATUREID" ) )
845 && ( parameters.contains( QStringLiteral(
"FILTER" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
846 || ( parameters.contains( QStringLiteral(
"FILTER" ) )
847 && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
848 || ( parameters.contains( QStringLiteral(
"BBOX" ) )
849 && ( 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 ) )
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 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 )
919 typeName = typeName.trimmed();
924 request.
deletes.append( action );
928 if ( parameters.contains( QStringLiteral(
"EXP_FILTER" ) ) )
930 QString expFilterName = parameters.value( QStringLiteral(
"EXP_FILTER" ) );
931 QStringList expFilterList;
932 QRegExp rx(
"\\(([^()]+)\\)" );
933 if ( rx.indexIn( expFilterName, 0 ) == -1 )
935 expFilterList << expFilterName;
940 while ( ( pos = rx.indexIn( expFilterName, pos ) ) != -1 )
942 expFilterList << rx.cap( 1 );
943 pos += rx.matchedLength();
948 if ( request.
deletes.size() == expFilterList.size() )
951 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
952 QStringList::const_iterator expFilterIt = expFilterList.constBegin();
953 for ( ; dIt != request.
deletes.end(); ++dIt )
958 if ( expFilterIt != expFilterList.constEnd() )
960 expFilter = *expFilterIt;
962 std::shared_ptr<QgsExpression> filter(
new QgsExpression( expFilter ) );
965 if ( filter->hasParserError() )
971 if ( filter->needsGeometry() )
986 if ( parameters.contains( QStringLiteral(
"BBOX" ) ) )
989 QString bbox = parameters.value( QStringLiteral(
"BBOX" ) );
990 if ( bbox.isEmpty() )
996 QStringList corners = bbox.split(
',' );
997 if ( corners.size() != 4 )
1005 for (
int i = 0; i < 4; i++ )
1007 corners[i].replace(
' ',
'+' );
1008 d[i] = corners[i].toDouble( &ok );
1018 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1019 for ( ; dIt != request.
deletes.end(); ++dIt )
1026 else if ( parameters.contains( QStringLiteral(
"FILTER" ) ) )
1028 QString filterName = parameters.value( QStringLiteral(
"FILTER" ) );
1029 QStringList filterList;
1030 QRegExp rx(
"\\(([^()]+)\\)" );
1031 if ( rx.indexIn( filterName, 0 ) == -1 )
1033 filterList << filterName;
1038 while ( ( pos = rx.indexIn( filterName, pos ) ) != -1 )
1040 filterList << rx.cap( 1 );
1041 pos += rx.matchedLength();
1046 if ( request.
deletes.size() != filterList.size() )
1052 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1053 QStringList::const_iterator filterIt = filterList.constBegin();
1054 for ( ; dIt != request.
deletes.end(); ++dIt )
1059 QDomDocument filter;
1060 if ( filterIt != filterList.constEnd() )
1063 if ( !filter.setContent( *filterIt,
true, &errorMsg ) )
1069 QDomElement filterElem = filter.firstChildElement();
1070 QStringList serverFids;
1074 if ( filterIt != filterList.constEnd() )
1089 QDomNodeList docChildNodes = docElem.childNodes();
1091 QDomElement actionElem;
1094 for (
int i = docChildNodes.count(); 0 < i; --i )
1096 actionElem = docChildNodes.at( i - 1 ).toElement();
1097 actionName = actionElem.localName();
1099 if ( actionName == QLatin1String(
"Insert" ) )
1102 request.
inserts.append( action );
1104 else if ( actionName == QLatin1String(
"Update" ) )
1107 request.
updates.append( action );
1109 else if ( actionName == QLatin1String(
"Delete" ) )
1112 request.
deletes.append( action );
1121 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1122 if ( typeName.contains(
':' ) )
1123 typeName = typeName.section(
':', 1, 1 );
1125 QDomElement filterElem = actionElem.firstChild().toElement();
1126 if ( filterElem.tagName() != QLatin1String(
"Filter" ) )
1131 QStringList serverFids;
1138 action.
error =
false;
1140 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1142 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1150 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1151 if ( typeName.contains(
':' ) )
1152 typeName = typeName.section(
':', 1, 1 );
1154 QDomNodeList propertyNodeList = actionElem.elementsByTagName( QStringLiteral(
"Property" ) );
1155 if ( propertyNodeList.isEmpty() )
1160 QMap<QString, QString> propertyMap;
1161 QDomElement propertyElem;
1162 QDomElement nameElem;
1163 QDomElement valueElem;
1164 QDomElement geometryElem;
1166 for (
int l = 0; l < propertyNodeList.count(); ++l )
1168 propertyElem = propertyNodeList.at( l ).toElement();
1169 nameElem = propertyElem.elementsByTagName( QStringLiteral(
"Name" ) ).at( 0 ).toElement();
1170 valueElem = propertyElem.elementsByTagName( QStringLiteral(
"Value" ) ).at( 0 ).toElement();
1171 if ( nameElem.text() != QLatin1String(
"geometry" ) )
1173 propertyMap.insert( nameElem.text(), valueElem.text() );
1177 geometryElem = valueElem;
1181 QDomNodeList filterNodeList = actionElem.elementsByTagName( QStringLiteral(
"Filter" ) );
1183 QStringList serverFids;
1184 if ( filterNodeList.size() != 0 )
1186 QDomElement filterElem = filterNodeList.at( 0 ).toElement();
1196 action.
error =
false;
1198 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1200 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1208 QDomNodeList featureNodeList = actionElem.childNodes();
1209 if ( featureNodeList.size() != 1 )
1215 for (
int i = 0; i < featureNodeList.count(); ++i )
1217 QString tempTypeName = featureNodeList.at( i ).toElement().localName();
1218 if ( tempTypeName.contains(
':' ) )
1219 tempTypeName = tempTypeName.section(
':', 1, 1 );
1221 if ( typeName.isEmpty() )
1223 typeName = tempTypeName;
1225 else if ( tempTypeName != typeName )
1234 action.
error =
false;
1236 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1238 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1247 void addTransactionResult( QDomDocument &responseDoc, QDomElement &responseElem,
const QString &status,
1248 const QString &locator,
const QString &message )
1250 QDomElement trElem = responseDoc.createElement( QStringLiteral(
"TransactionResult" ) );
1251 QDomElement stElem = responseDoc.createElement( QStringLiteral(
"Status" ) );
1252 QDomElement successElem = responseDoc.createElement( status );
1253 stElem.appendChild( successElem );
1254 trElem.appendChild( stElem );
1255 responseElem.appendChild( trElem );
1257 if ( !locator.isEmpty() )
1259 QDomElement locElem = responseDoc.createElement( QStringLiteral(
"Locator" ) );
1260 locElem.appendChild( responseDoc.createTextNode( locator ) );
1261 trElem.appendChild( locElem );
1264 if ( !message.isEmpty() )
1266 QDomElement mesElem = responseDoc.createElement( QStringLiteral(
"Message" ) );
1267 mesElem.appendChild( responseDoc.createTextNode( message ) );
1268 trElem.appendChild( mesElem );
QgsFeatureRequest featureRequest
Class for parsing and evaluation of expressions (formerly called "search strings").
bool layerInsertPermission(const QgsVectorLayer *layer) const
Returns the layer insert right.
Wrapper for iterator of features from vector data provider or vector layer.
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...
A rectangle specified with double values.
Base class for all map layer types.
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...
QList< transactionInsert > inserts
QSet< QgsFeatureId > QgsFeatureIds
transactionRequest parseTransactionRequestBody(QDomElement &docElem, const QgsProject *project)
Transform RequestBody root element to getFeatureRequest.
virtual QgsVectorDataProvider::Capabilities capabilities() const
Returns flags containing the supported capabilities.
QMap< QString, int > fieldNameMap() const
Returns a map where the key is the name of the field and the value is its index.
QgsMapLayerType type() const
Returns the type of the layer.
SERVER_EXPORT QString getServerFid(const QgsFeature &feature, const QgsAttributeList &pkAttributes)
Returns the feature id based on primary keys.
bool addFeatures(QgsFeatureList &flist, QgsFeatureSink::Flags flags=nullptr) override
Adds a list of features to the sink.
QList< QgsFeature > QgsFeatureList
bool commitChanges()
Attempts to commit to the underlying data provider any buffered changes made since the last to call t...
bool startEditing()
Makes the layer editable.
Exception base class for service exceptions.
virtual QgsAttributeList pkAttributeIndexes() const
Returns list of indexes of fields that make up the primary key.
bool deleteFeatures(const QgsFeatureIds &fids)
Deletes a set of features from the layer (but does not commit it)
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
bool setAttribute(int field, const QVariant &attr)
Set an attribute's value by field index.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QString message() const
Returns the exception message.
bool layerDeletePermission(const QgsVectorLayer *layer) const
Returns the layer delete right.
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device...
QList< transactionUpdate > updates
QString layerTypeName(const QgsMapLayer *layer)
Returns typename from vector layer.
QDomElement geometryElement
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
static void applyAccessControlLayerFilters(const QgsAccessControl *accessControl, QgsMapLayer *mapLayer, QHash< QgsMapLayer *, QString > &originalLayerFilters)
Apply filter from AccessControl.
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
transactionRequest parseTransactionParameters(QgsServerRequest::Parameters parameters, const QgsProject *project)
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
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...
bool rollBack(bool deleteBuffer=true)
Stops a current editing operation and discards any uncommitted edits.
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...
QgsFields fields() const override=0
Returns the fields associated with this data provider.
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
This class wraps a request for features to a vector layer (or directly its vector data provider)...
const QString WFS_NAMESPACE
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
QgsFeatureRequest parseFilterElement(const QString &typeName, QDomElement &filterElem, const QgsProject *project)
Transform a Filter element to a feature request.
Allows modifications of geometries.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
void clearErrors()
Clear recorded errors.
transactionInsert parseInsertActionElement(QDomElement &actionElem)
Transform Insert element to transactionInsert.
Encapsulate a field in an attribute table or data source.
QList< transactionDelete > deletes
transactionUpdate parseUpdateActionElement(QDomElement &actionElem, const QgsProject *project)
Transform Update element to transactionUpdate.
QStringList insertFeatureIds
SERVER_EXPORT QgsFeatureRequest updateFeatureRequestFromServerFids(QgsFeatureRequest &featureRequest, const QStringList &serverFids, const QgsVectorDataProvider *provider)
Returns the feature request based on feature ids build with primary keys.
const QString OGC_NAMESPACE
QStringList commitErrors() const
Returns a list containing any error messages generated when attempting to commit changes to the layer...
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
static QgsGeometry geometryFromGML(const QString &xmlString)
Static method that creates geometry from GML.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins...
QgsFieldConstraints constraints
QgsFeatureRequest featureRequest
QDomNodeList featureNodeList
void writeTransaction(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output WFS transaction response.
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
RAII class to restore layer filters on destruction.
A helper class that centralizes restrictions given by all the access control filter plugins...
QgsFeatureList featuresFromGML(QDomNodeList featureNodeList, QgsVectorDataProvider *provider)
Transform GML feature nodes to features.
void filterFeatures(const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures) const override
Filter the features of the layer.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
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...
Exception thrown when data access violates access controls.
Allows deletion of features.
bool layerUpdatePermission(const QgsVectorLayer *layer) const
Returns the layer update right.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant(), bool skipDefaultValues=false)
Changes an attribute value for a feature (but does not immediately commit the changes).
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
QList< int > QgsAttributeList
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
bool nextFeature(QgsFeature &f)
This is the base class for vector data providers.
Represents a vector layer which manages a vector based data sets.
QMap< QString, QString > propertyMap
void performTransaction(transactionRequest &aRequest, QgsServerInterface *serverIface, const QgsProject *project)
Perform the transaction.
Allows modification of attribute values.
QDomDocument createTransactionDocument(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request)
Create a wfs transaction document.
transactionDelete parseDeleteActionElement(QDomElement &actionElem, const QgsProject *project)
Transform Delete element to transactionDelete.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
QMap< QString, QString > Parameters
bool allowToEdit(const QgsVectorLayer *layer, const QgsFeature &feature) const
Are we authorized to modify the following geometry.