44 void addTransactionResult( QDomDocument &responseDoc, QDomElement &resultsElem,
45 const QString &locator,
const QString &message );
56 response.
setHeader(
"Content-Type",
"text/xml; charset=utf-8" );
57 response.
write( doc.toByteArray() );
71 if ( doc.setContent( parameters.value( QStringLiteral(
"REQUEST_BODY" ) ),
true, &errorMsg ) )
73 QDomElement docElem = doc.documentElement();
82 if ( actionCount == 0 )
93 QDomElement respElem = resp.createElement( QStringLiteral(
"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.1.0/wfs.xsd" );
97 respElem.setAttribute( QStringLiteral(
"xmlns:ogc" ),
OGC_NAMESPACE );
98 respElem.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.1.0" ) );
99 resp.appendChild( respElem );
101 int totalInserted = 0;
102 int totalUpdated = 0;
103 int totalDeleted = 0;
107 QDomElement trsElem = doc.createElement( QStringLiteral(
"TransactionResults" ) );
110 QDomElement irsElem = doc.createElement( QStringLiteral(
"InsertResults" ) );
111 QList<transactionInsert>::iterator tiIt = aRequest.
inserts.begin();
112 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
118 QString locator = action.
handle;
119 if ( locator.isEmpty() )
121 locator = QStringLiteral(
"Insert:%1" ).arg( action.
typeName );
123 addTransactionResult( resp, trsElem, locator, action.
errorMsg );
130 QString fidStr = *fidIt;
131 QDomElement irElem = doc.createElement( QStringLiteral(
"Feature" ) );
132 if ( !action.
handle.isEmpty() )
134 irElem.setAttribute( QStringLiteral(
"handle" ), action.
handle );
136 QDomElement fiElem = doc.createElement( QStringLiteral(
"ogc:FeatureId" ) );
137 fiElem.setAttribute( QStringLiteral(
"fid" ), fidStr );
138 irElem.appendChild( fiElem );
139 irsElem.appendChild( irElem );
145 QList<transactionUpdate>::iterator tuIt = aRequest.
updates.begin();
146 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
152 QString locator = action.
handle;
153 if ( locator.isEmpty() )
155 locator = QStringLiteral(
"Update:%1" ).arg( action.
typeName );
157 addTransactionResult( resp, trsElem, locator, action.
errorMsg );
162 QList<transactionDelete>::iterator tdIt = aRequest.
deletes.begin();
163 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
169 QString locator = action.
handle;
170 if ( locator.isEmpty() )
172 locator = QStringLiteral(
"Delete:%1" ).arg( action.
typeName );
174 addTransactionResult( resp, trsElem, locator, action.
errorMsg );
180 QDomElement summaryElem = doc.createElement( QStringLiteral(
"TransactionSummary" ) );
181 if ( aRequest.
inserts.size() > 0 )
183 QDomElement totalInsertedElem = doc.createElement( QStringLiteral(
"TotalInserted" ) );
184 totalInsertedElem.appendChild( doc.createTextNode( QString::number( totalInserted ) ) );
185 summaryElem.appendChild( totalInsertedElem );
187 if ( aRequest.
updates.size() > 0 )
189 QDomElement totalUpdatedElem = doc.createElement( QStringLiteral(
"TotalUpdated" ) );
190 totalUpdatedElem.appendChild( doc.createTextNode( QString::number( totalUpdated ) ) );
191 summaryElem.appendChild( totalUpdatedElem );
193 if ( aRequest.
deletes.size() > 0 )
195 QDomElement totalDeletedElem = doc.createElement( QStringLiteral(
"TotalDeleted" ) );
196 totalDeletedElem.appendChild( doc.createTextNode( QString::number( totalDeleted ) ) );
197 summaryElem.appendChild( totalDeletedElem );
199 respElem.appendChild( summaryElem );
202 if ( errorCount > 0 && trsElem.hasChildNodes() )
204 respElem.appendChild( trsElem );
208 if ( aRequest.
inserts.size() > 0 && irsElem.hasChildNodes() )
210 respElem.appendChild( irsElem );
217 #ifndef HAVE_SERVER_PYTHON_PLUGINS 221 QStringList typeNameList;
223 QList<transactionInsert>::iterator tiIt = aRequest.
inserts.begin();
224 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
226 QString name = ( *tiIt ).typeName;
227 if ( !typeNameList.contains( name ) )
228 typeNameList << name;
230 QList<transactionUpdate>::iterator tuIt = aRequest.
updates.begin();
231 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
233 QString name = ( *tuIt ).typeName;
234 if ( !typeNameList.contains( name ) )
235 typeNameList << name;
237 QList<transactionDelete>::iterator tdIt = aRequest.
deletes.begin();
238 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
240 QString name = ( *tdIt ).typeName;
241 if ( !typeNameList.contains( name ) )
242 typeNameList << name;
245 #ifdef HAVE_SERVER_PYTHON_PLUGINS 259 QMap<QString, QgsVectorLayer *> mapLayerMap;
260 for (
int i = 0; i < wfsLayerIds.size(); ++i )
274 if ( !typeNameList.contains( name ) )
301 if ( !wfstUpdateLayerIds.contains( vlayer->
id() )
302 && !wfstDeleteLayerIds.contains( vlayer->
id() )
303 && !wfstInsertLayerIds.contains( vlayer->
id() ) )
307 #ifdef HAVE_SERVER_PYTHON_PLUGINS 320 mapLayerMap[name] = vlayer;
324 tuIt = aRequest.
updates.begin();
325 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
330 if ( !mapLayerMap.keys().contains( typeName ) )
333 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
341 if ( !wfstUpdateLayerIds.contains( vlayer->
id() ) )
344 action.
errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg( typeName );
347 #ifdef HAVE_SERVER_PYTHON_PLUGINS 351 action.
errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg( typeName );
363 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS updates on layer '%1'" ).arg( typeName );
378 #ifdef HAVE_SERVER_PYTHON_PLUGINS 387 int totalUpdated = 0;
389 QMap<QString, QString> propertyMap = action.
propertyMap;
393 const QMap<QString, int> fieldMap = provider->
fieldNameMap();
394 QMap<QString, int>::const_iterator fieldMapIt;
396 bool conversionSuccess;
400 #ifdef HAVE_SERVER_PYTHON_PLUGINS 401 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
404 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
409 QMap< QString, QString >::const_iterator it = propertyMap.constBegin();
410 for ( ; it != propertyMap.constEnd(); ++it )
412 fieldName = it.key();
413 fieldMapIt = fieldMap.find( fieldName );
414 if ( fieldMapIt == fieldMap.constEnd() )
418 QgsField field = fields.
at( fieldMapIt.value() );
419 QVariant value = it.value();
420 if ( value.isNull() )
425 action.
errorMsg = QStringLiteral(
"NOT NULL constraint error on layer '%1', field '%2'" ).arg( typeName, field.
name() );
432 if ( field.
type() == QVariant::Type::Int )
434 value = it.value().toInt( &conversionSuccess );
435 if ( !conversionSuccess )
438 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
443 else if ( field.
type() == QVariant::Type::Double )
445 value = it.value().toDouble( &conversionSuccess );
446 if ( !conversionSuccess )
449 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
454 else if ( field.
type() == QVariant::Type::LongLong )
456 value = it.value().toLongLong( &conversionSuccess );
457 if ( !conversionSuccess )
460 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
473 if ( !geometryElem.isNull() )
479 action.
errorMsg = QStringLiteral(
"Geometry from GML error on layer '%1'" ).arg( typeName );
486 action.
errorMsg = QStringLiteral(
"Error in change geometry on layer '%1'" ).arg( typeName );
497 #ifdef HAVE_SERVER_PYTHON_PLUGINS 504 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
507 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
523 action.
errorMsg = QStringLiteral(
"Error committing updates: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
529 action.
error =
false;
534 tdIt = aRequest.
deletes.begin();
535 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
540 if ( !mapLayerMap.keys().contains( typeName ) )
543 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
551 if ( !wfstDeleteLayerIds.contains( vlayer->
id() ) )
554 action.
errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg( typeName );
557 #ifdef HAVE_SERVER_PYTHON_PLUGINS 561 action.
errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg( typeName );
573 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS deletes on layer '%1'" ).arg( typeName );
596 #ifdef HAVE_SERVER_PYTHON_PLUGINS 597 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
600 action.
errorMsg = QStringLiteral(
"Feature modify permission denied" );
605 fids << feature.
id();
615 action.
errorMsg = QStringLiteral(
"Delete features failed on layer '%1'" ).arg( typeName );
624 action.
errorMsg = QStringLiteral(
"Error committing deletes: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
630 action.
error =
false;
634 tiIt = aRequest.
inserts.begin();
635 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
640 if ( !mapLayerMap.keys().contains( typeName ) )
643 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
651 if ( !wfstInsertLayerIds.contains( vlayer->
id() ) )
654 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
657 #ifdef HAVE_SERVER_PYTHON_PLUGINS 661 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
673 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS inserts on layer '%1'" ).arg( typeName );
689 action.
errorMsg = QStringLiteral(
"%1 '%2'" ).arg( ex.
message() ).arg( typeName );
692 #ifdef HAVE_SERVER_PYTHON_PLUGINS 696 QgsFeatureList::iterator featureIt = featureList.begin();
697 while ( featureIt != featureList.end() )
699 if ( !accessControl->
allowToEdit( vlayer, *featureIt ) )
702 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
719 action.
errorMsg = QStringLiteral(
"Insert features failed on layer '%1'" ).arg( typeName );
720 if ( provider ->hasErrors() )
732 action.
errorMsg = QStringLiteral(
"Error committing inserts: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
737 action.
error =
false;
740 for (
int j = 0; j < featureList.size(); j++ )
742 action.
insertFeatureIds << typeName +
"." + QString::number( featureList[j].
id() );
747 filterRestorer.reset();
757 const QMap<QString, int> fieldMap = provider->
fieldNameMap();
758 QMap<QString, int>::const_iterator fieldMapIt;
760 for (
int i = 0; i < featureNodeList.count(); i++ )
764 QDomElement featureElem = featureNodeList.at( i ).toElement();
765 QDomNode currentAttributeChild = featureElem.firstChild();
766 bool conversionSuccess =
true;
768 while ( !currentAttributeChild.isNull() )
770 QDomElement currentAttributeElement = currentAttributeChild.toElement();
771 QString attrName = currentAttributeElement.localName();
773 if ( attrName != QLatin1String(
"boundedBy" ) )
775 if ( attrName != QLatin1String(
"geometry" ) )
777 fieldMapIt = fieldMap.find( attrName );
778 if ( fieldMapIt == fieldMap.constEnd() )
783 QgsField field = fields.
at( fieldMapIt.value() );
784 QString attrValue = currentAttributeElement.text();
785 int attrType = field.
type();
787 QgsMessageLog::logMessage( QStringLiteral(
"attr: name=%1 idx=%2 value=%3" ).arg( attrName ).arg( fieldMapIt.value() ).arg( attrValue ) );
789 if ( attrType == QVariant::Int )
790 feat.
setAttribute( fieldMapIt.value(), attrValue.toInt( &conversionSuccess ) );
791 else if ( attrType == QVariant::Double )
792 feat.
setAttribute( fieldMapIt.value(), attrValue.toDouble( &conversionSuccess ) );
796 if ( !conversionSuccess )
811 currentAttributeChild = currentAttributeChild.nextSibling();
821 if ( !parameters.contains( QStringLiteral(
"OPERATION" ) ) )
825 if ( parameters.value( QStringLiteral(
"OPERATION" ) ).toUpper() != QStringLiteral(
"DELETE" ) )
831 if ( ( parameters.contains( QStringLiteral(
"FEATUREID" ) )
832 && ( parameters.contains( QStringLiteral(
"FILTER" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
833 || ( parameters.contains( QStringLiteral(
"FILTER" ) )
834 && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
835 || ( parameters.contains( QStringLiteral(
"BBOX" ) )
836 && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"FILTER" ) ) ) )
844 QStringList typeNameList;
846 if ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) )
848 QStringList fidList = parameters.value( QStringLiteral(
"FEATUREID" ) ).split(
',' );
850 QMap<QString, QgsFeatureIds> fidsMap;
852 QStringList::const_iterator fidIt = fidList.constBegin();
853 for ( ; fidIt != fidList.constEnd(); ++fidIt )
856 QString fid = *fidIt;
859 if ( !fid.contains(
'.' ) )
864 QString
typeName = fid.section(
'.', 0, 0 );
865 fid = fid.section(
'.', 1, 1 );
866 if ( !typeNameList.contains( typeName ) )
872 if ( fidsMap.contains( typeName ) )
874 fids = fidsMap.value( typeName );
876 fids.insert( fid.toInt() );
877 fidsMap.insert( typeName, fids );
880 QMap<QString, QgsFeatureIds>::const_iterator fidsMapIt = fidsMap.constBegin();
881 while ( fidsMapIt != fidsMap.constEnd() )
889 request.
deletes.append( action );
894 if ( !parameters.contains( QStringLiteral(
"TYPENAME" ) ) )
899 typeNameList = parameters.value( QStringLiteral(
"TYPENAME" ) ).split(
',' );
902 QStringList::const_iterator typeNameIt = typeNameList.constBegin();
903 for ( ; typeNameIt != typeNameList.constEnd(); ++typeNameIt )
906 typeName = typeName.trimmed();
911 request.
deletes.append( action );
915 if ( parameters.contains( QStringLiteral(
"EXP_FILTER" ) ) )
917 QString expFilterName = parameters.value( QStringLiteral(
"EXP_FILTER" ) );
918 QStringList expFilterList;
919 QRegExp rx(
"\\(([^()]+)\\)" );
920 if ( rx.indexIn( expFilterName, 0 ) == -1 )
922 expFilterList << expFilterName;
927 while ( ( pos = rx.indexIn( expFilterName, pos ) ) != -1 )
929 expFilterList << rx.cap( 1 );
930 pos += rx.matchedLength();
935 if ( request.
deletes.size() == expFilterList.size() )
938 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
939 QStringList::const_iterator expFilterIt = expFilterList.constBegin();
940 for ( ; dIt != request.
deletes.end(); ++dIt )
945 if ( expFilterIt != expFilterList.constEnd() )
947 expFilter = *expFilterIt;
949 std::shared_ptr<QgsExpression> filter(
new QgsExpression( expFilter ) );
952 if ( filter->hasParserError() )
958 if ( filter->needsGeometry() )
973 if ( parameters.contains( QStringLiteral(
"BBOX" ) ) )
976 QString bbox = parameters.value( QStringLiteral(
"BBOX" ) );
977 if ( bbox.isEmpty() )
983 QStringList corners = bbox.split(
',' );
984 if ( corners.size() != 4 )
992 for (
int i = 0; i < 4; i++ )
994 corners[i].replace(
' ',
'+' );
995 d[i] = corners[i].toDouble( &ok );
1005 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1006 for ( ; dIt != request.
deletes.end(); ++dIt )
1013 else if ( parameters.contains( QStringLiteral(
"FILTER" ) ) )
1015 QString filterName = parameters.value( QStringLiteral(
"FILTER" ) );
1016 QStringList filterList;
1017 QRegExp rx(
"\\(([^()]+)\\)" );
1018 if ( rx.indexIn( filterName, 0 ) == -1 )
1020 filterList << filterName;
1025 while ( ( pos = rx.indexIn( filterName, pos ) ) != -1 )
1027 filterList << rx.cap( 1 );
1028 pos += rx.matchedLength();
1033 if ( request.
deletes.size() != filterList.size() )
1039 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1040 QStringList::const_iterator filterIt = filterList.constBegin();
1041 for ( ; dIt != request.
deletes.end(); ++dIt )
1046 QDomDocument filter;
1047 if ( filterIt != filterList.constEnd() )
1050 if ( !filter.setContent( *filterIt,
true, &errorMsg ) )
1056 QDomElement filterElem = filter.firstChildElement();
1059 if ( filterIt != filterList.constEnd() )
1074 QDomNodeList docChildNodes = docElem.childNodes();
1076 QDomElement actionElem;
1079 for (
int i = docChildNodes.count(); 0 < i; --i )
1081 actionElem = docChildNodes.at( i - 1 ).toElement();
1082 actionName = actionElem.localName();
1084 if ( actionName == QLatin1String(
"Insert" ) )
1087 request.
inserts.append( action );
1089 else if ( actionName == QLatin1String(
"Update" ) )
1092 request.
updates.append( action );
1094 else if ( actionName == QLatin1String(
"Delete" ) )
1097 request.
deletes.append( action );
1106 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1107 if ( typeName.contains(
':' ) )
1108 typeName = typeName.section(
':', 1, 1 );
1110 QDomElement filterElem = actionElem.firstChild().toElement();
1111 if ( filterElem.tagName() != QLatin1String(
"Filter" ) )
1121 action.
error =
false;
1123 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1125 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1133 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1134 if ( typeName.contains(
':' ) )
1135 typeName = typeName.section(
':', 1, 1 );
1137 QDomNodeList propertyNodeList = actionElem.elementsByTagName( QStringLiteral(
"Property" ) );
1138 if ( propertyNodeList.isEmpty() )
1143 QMap<QString, QString> propertyMap;
1144 QDomElement propertyElem;
1145 QDomElement nameElem;
1146 QDomElement valueElem;
1147 QDomElement geometryElem;
1149 for (
int l = 0; l < propertyNodeList.count(); ++l )
1151 propertyElem = propertyNodeList.at( l ).toElement();
1152 nameElem = propertyElem.elementsByTagName( QStringLiteral(
"Name" ) ).at( 0 ).toElement();
1153 valueElem = propertyElem.elementsByTagName( QStringLiteral(
"Value" ) ).at( 0 ).toElement();
1154 if ( nameElem.text() != QLatin1String(
"geometry" ) )
1156 propertyMap.insert( nameElem.text(), valueElem.text() );
1160 geometryElem = valueElem;
1164 QDomNodeList filterNodeList = actionElem.elementsByTagName( QStringLiteral(
"Filter" ) );
1166 if ( filterNodeList.size() != 0 )
1168 QDomElement filterElem = filterNodeList.at( 0 ).toElement();
1177 action.
error =
false;
1179 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1181 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1189 QDomNodeList featureNodeList = actionElem.childNodes();
1190 if ( featureNodeList.size() != 1 )
1196 for (
int i = 0; i < featureNodeList.count(); ++i )
1198 QString tempTypeName = featureNodeList.at( i ).toElement().localName();
1199 if ( tempTypeName.contains(
':' ) )
1200 tempTypeName = tempTypeName.section(
':', 1, 1 );
1202 if ( typeName.isEmpty() )
1204 typeName = tempTypeName;
1206 else if ( tempTypeName != typeName )
1215 action.
error =
false;
1217 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1219 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1228 void addTransactionResult( QDomDocument &responseDoc, QDomElement &resultsElem,
1229 const QString &locator,
const QString &message )
1231 QDomElement trElem = responseDoc.createElement( QStringLiteral(
"Action" ) );
1232 resultsElem.appendChild( trElem );
1234 if ( !locator.isEmpty() )
1236 trElem.setAttribute( QStringLiteral(
"locator" ), locator );
1239 if ( !message.isEmpty() )
1241 QDomElement mesElem = responseDoc.createElement( QStringLiteral(
"Message" ) );
1242 mesElem.appendChild( responseDoc.createTextNode( message ) );
1243 trElem.appendChild( mesElem );
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...
transactionDelete parseDeleteActionElement(QDomElement &actionElem)
Transform Delete element to transactionDelete.
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...
QSet< QgsFeatureId > QgsFeatureIds
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.
QgsFeatureRequest featureRequest
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.
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...
QString layerTypeName(const QgsMapLayer *layer)
Returns typename from vector layer.
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
transactionRequest parseTransactionParameters(QgsServerRequest::Parameters parameters)
transactionRequest parseTransactionRequestBody(QDomElement &docElem)
Transform RequestBody root element to getFeatureRequest.
QList< transactionUpdate > updates
static void applyAccessControlLayerFilters(const QgsAccessControl *accessControl, QgsMapLayer *mapLayer, QHash< QgsMapLayer *, QString > &originalLayerFilters)
Apply filter from AccessControl.
QMap< QString, QString > propertyMap
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
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.
QList< transactionInsert > inserts
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.
QDomNodeList featureNodeList
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)...
void writeTransaction(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output WFS transaction response.
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.
Reads and writes project states.
void clearErrors()
Clear recorded errors.
QgsFeatureList featuresFromGML(QDomNodeList featureNodeList, QgsVectorDataProvider *provider)
Transform GML feature nodes to features.
Encapsulate a field in an attribute table or data source.
const QString OGC_NAMESPACE
QDomDocument createTransactionDocument(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request)
Create a wfs transaction document.
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...
QStringList insertFeatureIds
transactionUpdate parseUpdateActionElement(QDomElement &actionElem)
Transform Update element to transactionUpdate.
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
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.
QList< transactionDelete > deletes
RAII class to restore layer filters on destruction.
void performTransaction(transactionRequest &aRequest, QgsServerInterface *serverIface, const QgsProject *project)
Perform the transaction.
A helper class that centralizes restrictions given by all the access control filter plugins...
void filterFeatures(const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures) const override
Filter the features of the layer.
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).
QDomElement geometryElement
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
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.
Allows modification of attribute values.
transactionInsert parseInsertActionElement(QDomElement &actionElem)
Transform Insert element to transactionInsert.
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.
QgsFeatureRequest featureRequest