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 );
218 QStringList typeNameList;
220 QList<transactionInsert>::iterator tiIt = aRequest.
inserts.begin();
221 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
223 QString name = ( *tiIt ).typeName;
224 if ( !typeNameList.contains( name ) )
225 typeNameList << name;
227 QList<transactionUpdate>::iterator tuIt = aRequest.
updates.begin();
228 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
230 QString name = ( *tuIt ).typeName;
231 if ( !typeNameList.contains( name ) )
232 typeNameList << name;
234 QList<transactionDelete>::iterator tdIt = aRequest.
deletes.begin();
235 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
237 QString name = ( *tdIt ).typeName;
238 if ( !typeNameList.contains( name ) )
239 typeNameList << name;
254 QMap<QString, QgsVectorLayer *> mapLayerMap;
255 for (
int i = 0; i < wfsLayerIds.size(); ++i )
262 if ( layer->
type() != QgsMapLayer::LayerType::VectorLayer )
269 if ( !typeNameList.contains( name ) )
296 if ( !wfstUpdateLayerIds.contains( vlayer->
id() )
297 && !wfstDeleteLayerIds.contains( vlayer->
id() )
298 && !wfstInsertLayerIds.contains( vlayer->
id() ) )
314 mapLayerMap[name] = vlayer;
318 tuIt = aRequest.
updates.begin();
319 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
324 if ( !mapLayerMap.keys().contains( typeName ) )
327 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
335 if ( !wfstUpdateLayerIds.contains( vlayer->
id() ) )
338 action.
errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg( typeName );
344 action.
errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg( typeName );
356 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS updates on layer '%1'" ).arg( typeName );
380 int totalUpdated = 0;
382 QMap<QString, QString> propertyMap = action.
propertyMap;
387 QMap<QString, int>::const_iterator fieldMapIt;
389 bool conversionSuccess;
393 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
396 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
400 QMap< QString, QString >::const_iterator it = propertyMap.constBegin();
401 for ( ; it != propertyMap.constEnd(); ++it )
403 fieldName = it.key();
404 fieldMapIt = fieldMap.find( fieldName );
405 if ( fieldMapIt == fieldMap.constEnd() )
409 QgsField field = fields.
at( fieldMapIt.value() );
410 QVariant value = it.value();
411 if ( value.isNull() )
416 action.
errorMsg = QStringLiteral(
"NOT NULL constraint error on layer '%1', field '%2'" ).arg( typeName, field.
name() );
423 if ( field.
type() == QVariant::Type::Int )
425 value = it.value().toInt( &conversionSuccess );
426 if ( !conversionSuccess )
429 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
434 else if ( field.
type() == QVariant::Type::Double )
436 value = it.value().toDouble( &conversionSuccess );
437 if ( !conversionSuccess )
440 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
445 else if ( field.
type() == QVariant::Type::LongLong )
447 value = it.value().toLongLong( &conversionSuccess );
448 if ( !conversionSuccess )
451 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
464 if ( !geometryElem.isNull() )
470 action.
errorMsg = QStringLiteral(
"Geometry from GML error on layer '%1'" ).arg( typeName );
477 action.
errorMsg = QStringLiteral(
"Error in change geometry on layer '%1'" ).arg( typeName );
494 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
497 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
512 action.
errorMsg = QStringLiteral(
"Error committing updates: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
518 action.
error =
false;
523 tdIt = aRequest.
deletes.begin();
524 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
529 if ( !mapLayerMap.keys().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 );
549 action.
errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg( typeName );
561 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS deletes on layer '%1'" ).arg( typeName );
584 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
587 action.
errorMsg = QStringLiteral(
"Feature modify permission denied" );
591 fids << feature.
id();
601 action.
errorMsg = QStringLiteral(
"Delete features failed on layer '%1'" ).arg( typeName );
610 action.
errorMsg = QStringLiteral(
"Error committing deletes: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
616 action.
error =
false;
620 tiIt = aRequest.
inserts.begin();
621 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
626 if ( !mapLayerMap.keys().contains( typeName ) )
629 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
637 if ( !wfstInsertLayerIds.contains( vlayer->
id() ) )
640 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
646 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
658 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS inserts on layer '%1'" ).arg( typeName );
674 action.
errorMsg = QStringLiteral(
"%1 '%2'" ).arg( ex.
message() ).arg( typeName );
680 QgsFeatureList::iterator featureIt = featureList.begin();
681 while ( featureIt != featureList.end() )
683 if ( !accessControl->
allowToEdit( vlayer, *featureIt ) )
686 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
702 action.
errorMsg = QStringLiteral(
"Insert features failed on layer '%1'" ).arg( typeName );
703 if ( provider ->hasErrors() )
715 action.
errorMsg = QStringLiteral(
"Error committing inserts: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
720 action.
error =
false;
723 for (
int j = 0; j < featureList.size(); j++ )
725 action.
insertFeatureIds << typeName +
"." + QString::number( featureList[j].
id() );
730 filterRestorer.reset();
741 QMap<QString, int>::const_iterator fieldMapIt;
743 for (
int i = 0; i < featureNodeList.count(); i++ )
747 QDomElement featureElem = featureNodeList.at( i ).toElement();
748 QDomNode currentAttributeChild = featureElem.firstChild();
749 bool conversionSuccess =
true;
751 while ( !currentAttributeChild.isNull() )
753 QDomElement currentAttributeElement = currentAttributeChild.toElement();
754 QString attrName = currentAttributeElement.localName();
756 if ( attrName != QLatin1String(
"boundedBy" ) )
758 if ( attrName != QLatin1String(
"geometry" ) )
760 fieldMapIt = fieldMap.find( attrName );
761 if ( fieldMapIt == fieldMap.constEnd() )
766 QgsField field = fields.
at( fieldMapIt.value() );
767 QString attrValue = currentAttributeElement.text();
768 int attrType = field.
type();
770 QgsMessageLog::logMessage( QStringLiteral(
"attr: name=%1 idx=%2 value=%3" ).arg( attrName ).arg( fieldMapIt.value() ).arg( attrValue ) );
772 if ( attrType == QVariant::Int )
773 feat.
setAttribute( fieldMapIt.value(), attrValue.toInt( &conversionSuccess ) );
774 else if ( attrType == QVariant::Double )
775 feat.
setAttribute( fieldMapIt.value(), attrValue.toDouble( &conversionSuccess ) );
779 if ( !conversionSuccess )
794 currentAttributeChild = currentAttributeChild.nextSibling();
804 if ( !parameters.contains( QStringLiteral(
"OPERATION" ) ) )
808 if ( parameters.value( QStringLiteral(
"OPERATION" ) ).toUpper() != QStringLiteral(
"DELETE" ) )
814 if ( ( parameters.contains( QStringLiteral(
"FEATUREID" ) )
815 && ( parameters.contains( QStringLiteral(
"FILTER" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
816 || ( parameters.contains( QStringLiteral(
"FILTER" ) )
817 && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
818 || ( parameters.contains( QStringLiteral(
"BBOX" ) )
819 && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"FILTER" ) ) ) )
827 QStringList typeNameList;
829 if ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) )
831 QStringList fidList = parameters.value( QStringLiteral(
"FEATUREID" ) ).split(
',' );
833 QMap<QString, QgsFeatureIds> fidsMap;
835 QStringList::const_iterator fidIt = fidList.constBegin();
836 for ( ; fidIt != fidList.constEnd(); ++fidIt )
839 QString fid = *fidIt;
842 if ( !fid.contains(
'.' ) )
847 QString
typeName = fid.section(
'.', 0, 0 );
848 fid = fid.section(
'.', 1, 1 );
849 if ( !typeNameList.contains( typeName ) )
855 if ( fidsMap.contains( typeName ) )
857 fids = fidsMap.value( typeName );
859 fids.insert( fid.toInt() );
860 fidsMap.insert( typeName, fids );
863 QMap<QString, QgsFeatureIds>::const_iterator fidsMapIt = fidsMap.constBegin();
864 while ( fidsMapIt != fidsMap.constEnd() )
872 request.
deletes.append( action );
877 if ( !parameters.contains( QStringLiteral(
"TYPENAME" ) ) )
882 typeNameList = parameters.value( QStringLiteral(
"TYPENAME" ) ).split(
',' );
885 QStringList::const_iterator typeNameIt = typeNameList.constBegin();
886 for ( ; typeNameIt != typeNameList.constEnd(); ++typeNameIt )
889 typeName = typeName.trimmed();
894 request.
deletes.append( action );
898 if ( parameters.contains( QStringLiteral(
"EXP_FILTER" ) ) )
900 QString expFilterName = parameters.value( QStringLiteral(
"EXP_FILTER" ) );
901 QStringList expFilterList;
902 QRegExp rx(
"\\(([^()]+)\\)" );
903 if ( rx.indexIn( expFilterName, 0 ) == -1 )
905 expFilterList << expFilterName;
910 while ( ( pos = rx.indexIn( expFilterName, pos ) ) != -1 )
912 expFilterList << rx.cap( 1 );
913 pos += rx.matchedLength();
918 if ( request.
deletes.size() == expFilterList.size() )
921 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
922 QStringList::const_iterator expFilterIt = expFilterList.constBegin();
923 for ( ; dIt != request.
deletes.end(); ++dIt )
928 if ( expFilterIt != expFilterList.constEnd() )
930 expFilter = *expFilterIt;
932 std::shared_ptr<QgsExpression> filter(
new QgsExpression( expFilter ) );
935 if ( filter->hasParserError() )
941 if ( filter->needsGeometry() )
956 if ( parameters.contains( QStringLiteral(
"BBOX" ) ) )
959 QString bbox = parameters.value( QStringLiteral(
"BBOX" ) );
960 if ( bbox.isEmpty() )
966 QStringList corners = bbox.split(
',' );
967 if ( corners.size() != 4 )
975 for (
int i = 0; i < 4; i++ )
977 corners[i].replace(
' ',
'+' );
978 d[i] = corners[i].toDouble( &ok );
988 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
989 for ( ; dIt != request.
deletes.end(); ++dIt )
996 else if ( parameters.contains( QStringLiteral(
"FILTER" ) ) )
998 QString filterName = parameters.value( QStringLiteral(
"FILTER" ) );
999 QStringList filterList;
1000 QRegExp rx(
"\\(([^()]+)\\)" );
1001 if ( rx.indexIn( filterName, 0 ) == -1 )
1003 filterList << filterName;
1008 while ( ( pos = rx.indexIn( filterName, pos ) ) != -1 )
1010 filterList << rx.cap( 1 );
1011 pos += rx.matchedLength();
1016 if ( request.
deletes.size() != filterList.size() )
1022 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1023 QStringList::const_iterator filterIt = filterList.constBegin();
1024 for ( ; dIt != request.
deletes.end(); ++dIt )
1029 QDomDocument filter;
1030 if ( filterIt != filterList.constEnd() )
1033 if ( !filter.setContent( *filterIt,
true, &errorMsg ) )
1039 QDomElement filterElem = filter.firstChildElement();
1042 if ( filterIt != filterList.constEnd() )
1057 QDomNodeList docChildNodes = docElem.childNodes();
1059 QDomElement actionElem;
1062 for (
int i = docChildNodes.count(); 0 < i; --i )
1064 actionElem = docChildNodes.at( i - 1 ).toElement();
1065 actionName = actionElem.localName();
1067 if ( actionName == QLatin1String(
"Insert" ) )
1070 request.
inserts.append( action );
1072 else if ( actionName == QLatin1String(
"Update" ) )
1075 request.
updates.append( action );
1077 else if ( actionName == QLatin1String(
"Delete" ) )
1080 request.
deletes.append( action );
1089 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1090 if ( typeName.contains(
':' ) )
1091 typeName = typeName.section(
':', 1, 1 );
1093 QDomElement filterElem = actionElem.firstChild().toElement();
1094 if ( filterElem.tagName() != QLatin1String(
"Filter" ) )
1104 action.
error =
false;
1106 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1108 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1116 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1117 if ( typeName.contains(
':' ) )
1118 typeName = typeName.section(
':', 1, 1 );
1120 QDomNodeList propertyNodeList = actionElem.elementsByTagName( QStringLiteral(
"Property" ) );
1121 if ( propertyNodeList.isEmpty() )
1126 QMap<QString, QString> propertyMap;
1127 QDomElement propertyElem;
1128 QDomElement nameElem;
1129 QDomElement valueElem;
1130 QDomElement geometryElem;
1132 for (
int l = 0; l < propertyNodeList.count(); ++l )
1134 propertyElem = propertyNodeList.at( l ).toElement();
1135 nameElem = propertyElem.elementsByTagName( QStringLiteral(
"Name" ) ).at( 0 ).toElement();
1136 valueElem = propertyElem.elementsByTagName( QStringLiteral(
"Value" ) ).at( 0 ).toElement();
1137 if ( nameElem.text() != QLatin1String(
"geometry" ) )
1139 propertyMap.insert( nameElem.text(), valueElem.text() );
1143 geometryElem = valueElem;
1147 QDomNodeList filterNodeList = actionElem.elementsByTagName( QStringLiteral(
"Filter" ) );
1149 if ( filterNodeList.size() != 0 )
1151 QDomElement filterElem = filterNodeList.at( 0 ).toElement();
1160 action.
error =
false;
1162 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1164 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1172 QDomNodeList featureNodeList = actionElem.childNodes();
1173 if ( featureNodeList.size() != 1 )
1179 for (
int i = 0; i < featureNodeList.count(); ++i )
1181 QString tempTypeName = featureNodeList.at( i ).toElement().localName();
1182 if ( tempTypeName.contains(
':' ) )
1183 tempTypeName = tempTypeName.section(
':', 1, 1 );
1185 if ( typeName.isEmpty() )
1187 typeName = tempTypeName;
1189 else if ( tempTypeName != typeName )
1198 action.
error =
false;
1200 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1202 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1211 void addTransactionResult( QDomDocument &responseDoc, QDomElement &resultsElem,
1212 const QString &locator,
const QString &message )
1214 QDomElement trElem = responseDoc.createElement( QStringLiteral(
"Action" ) );
1215 resultsElem.appendChild( trElem );
1217 if ( !locator.isEmpty() )
1219 trElem.setAttribute( QStringLiteral(
"locator" ), locator );
1222 if ( !message.isEmpty() )
1224 QDomElement mesElem = responseDoc.createElement( QStringLiteral(
"Message" ) );
1225 mesElem.appendChild( responseDoc.createTextNode( message ) );
1226 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.
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...
QgsMapLayer::LayerType type() const
Returns the type of the layer.
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
Query 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 null.
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