45 void addTransactionResult( QDomDocument &responseDoc, QDomElement &responseElem,
const QString &status,
46 const QString &locator,
const QString &message );
57 response.
setHeader(
"Content-Type",
"text/xml; charset=utf-8" );
58 response.
write( doc.toByteArray() );
72 if ( doc.setContent( parameters.value( QStringLiteral(
"REQUEST_BODY" ) ),
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( QStringLiteral(
"; " ) );
188 QString message = errorMessages.join( QStringLiteral(
"; " ) );
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 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.keys().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 );
359 #ifdef HAVE_SERVER_PYTHON_PLUGINS 369 QMap<QString, QString> propertyMap = action.
propertyMap;
373 const QMap<QString, int> fieldMap = provider->
fieldNameMap();
374 QMap<QString, int>::const_iterator fieldMapIt;
376 bool conversionSuccess;
380 #ifdef HAVE_SERVER_PYTHON_PLUGINS 381 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
384 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
389 QMap< QString, QString >::const_iterator it = propertyMap.constBegin();
390 for ( ; it != propertyMap.constEnd(); ++it )
392 fieldName = it.key();
393 fieldMapIt = fieldMap.find( fieldName );
394 if ( fieldMapIt == fieldMap.constEnd() )
398 QgsField field = fields.
at( fieldMapIt.value() );
399 QVariant value = it.value();
400 if ( value.isNull() )
405 action.
errorMsg = QStringLiteral(
"NOT NULL constraint error on layer '%1', field '%2'" ).arg( typeName, field.
name() );
412 if ( field.
type() == QVariant::Type::Int )
414 value = it.value().toInt( &conversionSuccess );
415 if ( !conversionSuccess )
418 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
423 else if ( field.
type() == QVariant::Type::Double )
425 value = it.value().toDouble( &conversionSuccess );
426 if ( !conversionSuccess )
429 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
434 else if ( field.
type() == QVariant::Type::LongLong )
436 value = it.value().toLongLong( &conversionSuccess );
437 if ( !conversionSuccess )
440 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
453 if ( !geometryElem.isNull() )
459 action.
errorMsg = QStringLiteral(
"Geometry from GML error on layer '%1'" ).arg( typeName );
466 action.
errorMsg = QStringLiteral(
"Error in change geometry on layer '%1'" ).arg( typeName );
476 #ifdef HAVE_SERVER_PYTHON_PLUGINS 483 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
486 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
502 action.
errorMsg = QStringLiteral(
"Error committing updates: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
507 action.
error =
false;
512 tdIt = aRequest.
deletes.begin();
513 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
518 if ( !mapLayerMap.keys().contains( typeName ) )
521 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
529 if ( !wfstDeleteLayerIds.contains( vlayer->
id() ) )
532 action.
errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg( typeName );
535 #ifdef HAVE_SERVER_PYTHON_PLUGINS 539 action.
errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg( typeName );
551 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS deletes on layer '%1'" ).arg( typeName );
574 #ifdef HAVE_SERVER_PYTHON_PLUGINS 575 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
578 action.
errorMsg = QStringLiteral(
"Feature modify permission denied" );
583 fids << feature.
id();
593 action.
errorMsg = QStringLiteral(
"Delete features failed on layer '%1'" ).arg( typeName );
602 action.
errorMsg = QStringLiteral(
"Error committing deletes: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
607 action.
error =
false;
611 tiIt = aRequest.
inserts.begin();
612 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
617 if ( !mapLayerMap.keys().contains( typeName ) )
620 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
628 if ( !wfstInsertLayerIds.contains( vlayer->
id() ) )
631 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
634 #ifdef HAVE_SERVER_PYTHON_PLUGINS 638 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
650 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS inserts on layer '%1'" ).arg( typeName );
666 action.
errorMsg = QStringLiteral(
"%1 '%2'" ).arg( ex.
message() ).arg( typeName );
669 #ifdef HAVE_SERVER_PYTHON_PLUGINS 673 QgsFeatureList::iterator featureIt = featureList.begin();
674 while ( featureIt != featureList.end() )
676 if ( !accessControl->
allowToEdit( vlayer, *featureIt ) )
679 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
696 action.
errorMsg = QStringLiteral(
"Insert features failed on layer '%1'" ).arg( typeName );
697 if ( provider ->hasErrors() )
709 action.
errorMsg = QStringLiteral(
"Error committing inserts: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
714 action.
error =
false;
717 for (
int j = 0; j < featureList.size(); j++ )
719 action.
insertFeatureIds << typeName +
"." + QString::number( featureList[j].
id() );
724 filterRestorer.reset();
734 const QMap<QString, int> fieldMap = provider->
fieldNameMap();
735 QMap<QString, int>::const_iterator fieldMapIt;
737 for (
int i = 0; i < featureNodeList.count(); i++ )
741 QDomElement featureElem = featureNodeList.at( i ).toElement();
742 QDomNode currentAttributeChild = featureElem.firstChild();
743 bool conversionSuccess =
true;
745 while ( !currentAttributeChild.isNull() )
747 QDomElement currentAttributeElement = currentAttributeChild.toElement();
748 QString attrName = currentAttributeElement.localName();
750 if ( attrName != QLatin1String(
"boundedBy" ) )
752 if ( attrName != QLatin1String(
"geometry" ) )
754 fieldMapIt = fieldMap.find( attrName );
755 if ( fieldMapIt == fieldMap.constEnd() )
760 QgsField field = fields.
at( fieldMapIt.value() );
761 QString attrValue = currentAttributeElement.text();
762 int attrType = field.
type();
764 QgsMessageLog::logMessage( QStringLiteral(
"attr: name=%1 idx=%2 value=%3" ).arg( attrName ).arg( fieldMapIt.value() ).arg( attrValue ) );
766 if ( attrType == QVariant::Int )
767 feat.
setAttribute( fieldMapIt.value(), attrValue.toInt( &conversionSuccess ) );
768 else if ( attrType == QVariant::Double )
769 feat.
setAttribute( fieldMapIt.value(), attrValue.toDouble( &conversionSuccess ) );
773 if ( !conversionSuccess )
788 currentAttributeChild = currentAttributeChild.nextSibling();
798 if ( !parameters.contains( QStringLiteral(
"OPERATION" ) ) )
802 if ( parameters.value( QStringLiteral(
"OPERATION" ) ).toUpper() != QStringLiteral(
"DELETE" ) )
808 if ( ( parameters.contains( QStringLiteral(
"FEATUREID" ) )
809 && ( parameters.contains( QStringLiteral(
"FILTER" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
810 || ( parameters.contains( QStringLiteral(
"FILTER" ) )
811 && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
812 || ( parameters.contains( QStringLiteral(
"BBOX" ) )
813 && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"FILTER" ) ) ) )
821 QStringList typeNameList;
823 if ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) )
825 QStringList fidList = parameters.value( QStringLiteral(
"FEATUREID" ) ).split(
',' );
827 QMap<QString, QgsFeatureIds> fidsMap;
829 QStringList::const_iterator fidIt = fidList.constBegin();
830 for ( ; fidIt != fidList.constEnd(); ++fidIt )
833 QString fid = *fidIt;
836 if ( !fid.contains(
'.' ) )
841 QString
typeName = fid.section(
'.', 0, 0 );
842 fid = fid.section(
'.', 1, 1 );
843 if ( !typeNameList.contains( typeName ) )
849 if ( fidsMap.contains( typeName ) )
851 fids = fidsMap.value( typeName );
853 fids.insert( fid.toInt() );
854 fidsMap.insert( typeName, fids );
857 QMap<QString, QgsFeatureIds>::const_iterator fidsMapIt = fidsMap.constBegin();
858 while ( fidsMapIt != fidsMap.constEnd() )
866 request.
deletes.append( action );
871 if ( !parameters.contains( QStringLiteral(
"TYPENAME" ) ) )
876 typeNameList = parameters.value( QStringLiteral(
"TYPENAME" ) ).split(
',' );
879 QStringList::const_iterator typeNameIt = typeNameList.constBegin();
880 for ( ; typeNameIt != typeNameList.constEnd(); ++typeNameIt )
883 typeName = typeName.trimmed();
888 request.
deletes.append( action );
892 if ( parameters.contains( QStringLiteral(
"EXP_FILTER" ) ) )
894 QString expFilterName = parameters.value( QStringLiteral(
"EXP_FILTER" ) );
895 QStringList expFilterList;
896 QRegExp rx(
"\\(([^()]+)\\)" );
897 if ( rx.indexIn( expFilterName, 0 ) == -1 )
899 expFilterList << expFilterName;
904 while ( ( pos = rx.indexIn( expFilterName, pos ) ) != -1 )
906 expFilterList << rx.cap( 1 );
907 pos += rx.matchedLength();
912 if ( request.
deletes.size() == expFilterList.size() )
915 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
916 QStringList::const_iterator expFilterIt = expFilterList.constBegin();
917 for ( ; dIt != request.
deletes.end(); ++dIt )
922 if ( expFilterIt != expFilterList.constEnd() )
924 expFilter = *expFilterIt;
926 std::shared_ptr<QgsExpression> filter(
new QgsExpression( expFilter ) );
929 if ( filter->hasParserError() )
935 if ( filter->needsGeometry() )
950 if ( parameters.contains( QStringLiteral(
"BBOX" ) ) )
953 QString bbox = parameters.value( QStringLiteral(
"BBOX" ) );
954 if ( bbox.isEmpty() )
960 QStringList corners = bbox.split(
',' );
961 if ( corners.size() != 4 )
969 for (
int i = 0; i < 4; i++ )
971 corners[i].replace(
' ',
'+' );
972 d[i] = corners[i].toDouble( &ok );
982 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
983 for ( ; dIt != request.
deletes.end(); ++dIt )
990 else if ( parameters.contains( QStringLiteral(
"FILTER" ) ) )
992 QString filterName = parameters.value( QStringLiteral(
"FILTER" ) );
993 QStringList filterList;
994 QRegExp rx(
"\\(([^()]+)\\)" );
995 if ( rx.indexIn( filterName, 0 ) == -1 )
997 filterList << filterName;
1002 while ( ( pos = rx.indexIn( filterName, pos ) ) != -1 )
1004 filterList << rx.cap( 1 );
1005 pos += rx.matchedLength();
1010 if ( request.
deletes.size() != filterList.size() )
1016 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1017 QStringList::const_iterator filterIt = filterList.constBegin();
1018 for ( ; dIt != request.
deletes.end(); ++dIt )
1023 QDomDocument filter;
1024 if ( filterIt != filterList.constEnd() )
1027 if ( !filter.setContent( *filterIt,
true, &errorMsg ) )
1033 QDomElement filterElem = filter.firstChildElement();
1036 if ( filterIt != filterList.constEnd() )
1051 QDomNodeList docChildNodes = docElem.childNodes();
1053 QDomElement actionElem;
1056 for (
int i = docChildNodes.count(); 0 < i; --i )
1058 actionElem = docChildNodes.at( i - 1 ).toElement();
1059 actionName = actionElem.localName();
1061 if ( actionName == QLatin1String(
"Insert" ) )
1064 request.
inserts.append( action );
1066 else if ( actionName == QLatin1String(
"Update" ) )
1069 request.
updates.append( action );
1071 else if ( actionName == QLatin1String(
"Delete" ) )
1074 request.
deletes.append( action );
1083 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1084 if ( typeName.contains(
':' ) )
1085 typeName = typeName.section(
':', 1, 1 );
1087 QDomElement filterElem = actionElem.firstChild().toElement();
1088 if ( filterElem.tagName() != QLatin1String(
"Filter" ) )
1098 action.
error =
false;
1100 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1102 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1110 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1111 if ( typeName.contains(
':' ) )
1112 typeName = typeName.section(
':', 1, 1 );
1114 QDomNodeList propertyNodeList = actionElem.elementsByTagName( QStringLiteral(
"Property" ) );
1115 if ( propertyNodeList.isEmpty() )
1120 QMap<QString, QString> propertyMap;
1121 QDomElement propertyElem;
1122 QDomElement nameElem;
1123 QDomElement valueElem;
1124 QDomElement geometryElem;
1126 for (
int l = 0; l < propertyNodeList.count(); ++l )
1128 propertyElem = propertyNodeList.at( l ).toElement();
1129 nameElem = propertyElem.elementsByTagName( QStringLiteral(
"Name" ) ).at( 0 ).toElement();
1130 valueElem = propertyElem.elementsByTagName( QStringLiteral(
"Value" ) ).at( 0 ).toElement();
1131 if ( nameElem.text() != QLatin1String(
"geometry" ) )
1133 propertyMap.insert( nameElem.text(), valueElem.text() );
1137 geometryElem = valueElem;
1141 QDomNodeList filterNodeList = actionElem.elementsByTagName( QStringLiteral(
"Filter" ) );
1143 if ( filterNodeList.size() != 0 )
1145 QDomElement filterElem = filterNodeList.at( 0 ).toElement();
1154 action.
error =
false;
1156 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1158 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1166 QDomNodeList featureNodeList = actionElem.childNodes();
1167 if ( featureNodeList.size() != 1 )
1173 for (
int i = 0; i < featureNodeList.count(); ++i )
1175 QString tempTypeName = featureNodeList.at( i ).toElement().localName();
1176 if ( tempTypeName.contains(
':' ) )
1177 tempTypeName = tempTypeName.section(
':', 1, 1 );
1179 if ( typeName.isEmpty() )
1181 typeName = tempTypeName;
1183 else if ( tempTypeName != typeName )
1192 action.
error =
false;
1194 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1196 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1205 void addTransactionResult( QDomDocument &responseDoc, QDomElement &responseElem,
const QString &status,
1206 const QString &locator,
const QString &message )
1208 QDomElement trElem = responseDoc.createElement( QStringLiteral(
"TransactionResult" ) );
1209 QDomElement stElem = responseDoc.createElement( QStringLiteral(
"Status" ) );
1210 QDomElement successElem = responseDoc.createElement( status );
1211 stElem.appendChild( successElem );
1212 trElem.appendChild( stElem );
1213 responseElem.appendChild( trElem );
1215 if ( !locator.isEmpty() )
1217 QDomElement locElem = responseDoc.createElement( QStringLiteral(
"Locator" ) );
1218 locElem.appendChild( responseDoc.createTextNode( locator ) );
1219 trElem.appendChild( locElem );
1222 if ( !message.isEmpty() )
1224 QDomElement mesElem = responseDoc.createElement( QStringLiteral(
"Message" ) );
1225 mesElem.appendChild( responseDoc.createTextNode( message ) );
1226 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
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.
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...
QList< transactionUpdate > updates
transactionUpdate parseUpdateActionElement(QDomElement &actionElem)
Transform Update element to transactionUpdate.
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.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
transactionRequest parseTransactionRequestBody(QDomElement &docElem)
Transform RequestBody root element to getFeatureRequest.
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.
Reads and writes project states.
void clearErrors()
Clear recorded errors.
transactionRequest parseTransactionParameters(QgsServerRequest::Parameters parameters)
transactionInsert parseInsertActionElement(QDomElement &actionElem)
Transform Insert element to transactionInsert.
Encapsulate a field in an attribute table or data source.
QList< transactionDelete > deletes
QStringList insertFeatureIds
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.
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.
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.
transactionDelete parseDeleteActionElement(QDomElement &actionElem)
Transform Delete element to transactionDelete.
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.
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.