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 )
248 if ( !layer || layer->
type() != QgsMapLayer::LayerType::VectorLayer )
255 if ( !typeNameList.contains( name ) )
282 if ( !wfstUpdateLayerIds.contains( vlayer->
id() )
283 && !wfstDeleteLayerIds.contains( vlayer->
id() )
284 && !wfstInsertLayerIds.contains( vlayer->
id() ) )
300 mapLayerMap[name] = vlayer;
304 tuIt = aRequest.
updates.begin();
305 for ( ; tuIt != aRequest.
updates.end(); ++tuIt )
310 if ( !mapLayerMap.keys().contains( typeName ) )
313 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
321 if ( !wfstUpdateLayerIds.contains( vlayer->
id() ) )
324 action.
errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg( typeName );
330 action.
errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg( typeName );
342 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS updates on layer '%1'" ).arg( typeName );
365 #ifdef HAVE_SERVER_PYTHON_PLUGINS 376 QMap<QString, QString> propertyMap = action.
propertyMap;
381 QMap<QString, int>::const_iterator fieldMapIt;
383 bool conversionSuccess;
387 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
390 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
394 QMap< QString, QString >::const_iterator it = propertyMap.constBegin();
395 for ( ; it != propertyMap.constEnd(); ++it )
397 fieldName = it.key();
398 fieldMapIt = fieldMap.find( fieldName );
399 if ( fieldMapIt == fieldMap.constEnd() )
403 QgsField field = fields.
at( fieldMapIt.value() );
404 QVariant value = it.value();
405 if ( value.isNull() )
410 action.
errorMsg = QStringLiteral(
"NOT NULL constraint error on layer '%1', field '%2'" ).arg( typeName, field.
name() );
417 if ( field.
type() == QVariant::Type::Int )
419 value = it.value().toInt( &conversionSuccess );
420 if ( !conversionSuccess )
423 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
428 else if ( field.
type() == QVariant::Type::Double )
430 value = it.value().toDouble( &conversionSuccess );
431 if ( !conversionSuccess )
434 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
439 else if ( field.
type() == QVariant::Type::LongLong )
441 value = it.value().toLongLong( &conversionSuccess );
442 if ( !conversionSuccess )
445 action.
errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg( typeName );
458 if ( !geometryElem.isNull() )
464 action.
errorMsg = QStringLiteral(
"Geometry from GML error on layer '%1'" ).arg( typeName );
471 action.
errorMsg = QStringLiteral(
"Error in change geometry on layer '%1'" ).arg( typeName );
487 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
490 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
505 action.
errorMsg = QStringLiteral(
"Error committing updates: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
510 action.
error =
false;
515 tdIt = aRequest.
deletes.begin();
516 for ( ; tdIt != aRequest.
deletes.end(); ++tdIt )
521 if ( !mapLayerMap.keys().contains( typeName ) )
524 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
532 if ( !wfstDeleteLayerIds.contains( vlayer->
id() ) )
535 action.
errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg( typeName );
541 action.
errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg( typeName );
553 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS deletes on layer '%1'" ).arg( typeName );
573 action.
errorMsg = QStringLiteral(
"No feature ids to do WFS deletes on layer '%1'" ).arg( typeName );
580 #ifdef HAVE_SERVER_PYTHON_PLUGINS 594 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
597 action.
errorMsg = QStringLiteral(
"Feature modify permission denied" );
601 fids << feature.
id();
611 action.
errorMsg = QStringLiteral(
"Delete features failed on layer '%1'" ).arg( typeName );
620 action.
errorMsg = QStringLiteral(
"Error committing deletes: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
625 action.
error =
false;
629 tiIt = aRequest.
inserts.begin();
630 for ( ; tiIt != aRequest.
inserts.end(); ++tiIt )
635 if ( !mapLayerMap.keys().contains( typeName ) )
638 action.
errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg( typeName );
646 if ( !wfstInsertLayerIds.contains( vlayer->
id() ) )
649 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
652 #ifdef HAVE_SERVER_PYTHON_PLUGINS 656 action.
errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
669 action.
errorMsg = QStringLiteral(
"No capabilities to do WFS inserts on layer '%1'" ).arg( typeName );
685 action.
errorMsg = QStringLiteral(
"%1 '%2'" ).arg( ex.
message() ).arg( typeName );
689 if ( featureList.empty() )
692 action.
errorMsg = QStringLiteral(
"No features to insert in layer '%1'" ).arg( typeName );
696 #ifdef HAVE_SERVER_PYTHON_PLUGINS 700 QgsFeatureList::iterator featureIt = featureList.begin();
701 while ( featureIt != featureList.end() )
703 if ( !accessControl->
allowToEdit( vlayer, *featureIt ) )
706 action.
errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg( typeName );
723 action.
errorMsg = QStringLiteral(
"Insert features failed on layer '%1'" ).arg( typeName );
724 if ( provider ->hasErrors() )
736 action.
errorMsg = QStringLiteral(
"Error committing inserts: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
741 action.
error =
false;
745 for (
const QgsFeature &feat : qgis::as_const( featureList ) )
752 filterRestorer.reset();
763 QMap<QString, int>::const_iterator fieldMapIt;
765 for (
int i = 0; i < featureNodeList.count(); i++ )
769 QDomElement featureElem = featureNodeList.at( i ).toElement();
770 QDomNode currentAttributeChild = featureElem.firstChild();
771 bool conversionSuccess =
true;
773 while ( !currentAttributeChild.isNull() )
775 QDomElement currentAttributeElement = currentAttributeChild.toElement();
776 QString attrName = currentAttributeElement.localName();
778 if ( attrName != QLatin1String(
"boundedBy" ) )
780 if ( attrName != QLatin1String(
"geometry" ) )
782 fieldMapIt = fieldMap.find( attrName );
783 if ( fieldMapIt == fieldMap.constEnd() )
788 QgsField field = fields.
at( fieldMapIt.value() );
789 QString attrValue = currentAttributeElement.text();
790 int attrType = field.
type();
792 QgsMessageLog::logMessage( QStringLiteral(
"attr: name=%1 idx=%2 value=%3" ).arg( attrName ).arg( fieldMapIt.value() ).arg( attrValue ) );
794 if ( attrType == QVariant::Int )
795 feat.
setAttribute( fieldMapIt.value(), attrValue.toInt( &conversionSuccess ) );
796 else if ( attrType == QVariant::Double )
797 feat.
setAttribute( fieldMapIt.value(), attrValue.toDouble( &conversionSuccess ) );
801 if ( !conversionSuccess )
816 currentAttributeChild = currentAttributeChild.nextSibling();
826 if ( !parameters.contains( QStringLiteral(
"OPERATION" ) ) )
830 if ( parameters.value( QStringLiteral(
"OPERATION" ) ).toUpper() != QStringLiteral(
"DELETE" ) )
836 if ( ( parameters.contains( QStringLiteral(
"FEATUREID" ) )
837 && ( parameters.contains( QStringLiteral(
"FILTER" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
838 || ( parameters.contains( QStringLiteral(
"FILTER" ) )
839 && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
840 || ( parameters.contains( QStringLiteral(
"BBOX" ) )
841 && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"FILTER" ) ) ) )
849 QStringList typeNameList;
851 if ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) )
853 QStringList fidList = parameters.value( QStringLiteral(
"FEATUREID" ) ).split(
',' );
855 QMap<QString, QStringList> fidsMap;
857 QStringList::const_iterator fidIt = fidList.constBegin();
858 for ( ; fidIt != fidList.constEnd(); ++fidIt )
861 QString fid = *fidIt;
864 if ( !fid.contains(
'.' ) )
869 QString
typeName = fid.section(
'.', 0, 0 );
870 fid = fid.section(
'.', 1, 1 );
871 if ( !typeNameList.contains( typeName ) )
877 if ( fidsMap.contains( typeName ) )
879 fids = fidsMap.value( typeName );
882 fidsMap.insert( typeName, fids );
885 QMap<QString, QStringList>::const_iterator fidsMapIt = fidsMap.constBegin();
886 while ( fidsMapIt != fidsMap.constEnd() )
894 request.
deletes.append( action );
899 if ( !parameters.contains( QStringLiteral(
"TYPENAME" ) ) )
904 typeNameList = parameters.value( QStringLiteral(
"TYPENAME" ) ).split(
',' );
907 QStringList::const_iterator typeNameIt = typeNameList.constBegin();
908 for ( ; typeNameIt != typeNameList.constEnd(); ++typeNameIt )
911 typeName = typeName.trimmed();
916 request.
deletes.append( action );
920 if ( parameters.contains( QStringLiteral(
"EXP_FILTER" ) ) )
922 QString expFilterName = parameters.value( QStringLiteral(
"EXP_FILTER" ) );
923 QStringList expFilterList;
924 QRegExp rx(
"\\(([^()]+)\\)" );
925 if ( rx.indexIn( expFilterName, 0 ) == -1 )
927 expFilterList << expFilterName;
932 while ( ( pos = rx.indexIn( expFilterName, pos ) ) != -1 )
934 expFilterList << rx.cap( 1 );
935 pos += rx.matchedLength();
940 if ( request.
deletes.size() == expFilterList.size() )
943 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
944 QStringList::const_iterator expFilterIt = expFilterList.constBegin();
945 for ( ; dIt != request.
deletes.end(); ++dIt )
950 if ( expFilterIt != expFilterList.constEnd() )
952 expFilter = *expFilterIt;
954 std::shared_ptr<QgsExpression> filter(
new QgsExpression( expFilter ) );
957 if ( filter->hasParserError() )
963 if ( filter->needsGeometry() )
978 if ( parameters.contains( QStringLiteral(
"BBOX" ) ) )
981 QString bbox = parameters.value( QStringLiteral(
"BBOX" ) );
982 if ( bbox.isEmpty() )
988 QStringList corners = bbox.split(
',' );
989 if ( corners.size() != 4 )
997 for (
int i = 0; i < 4; i++ )
999 corners[i].replace(
' ',
'+' );
1000 d[i] = corners[i].toDouble( &ok );
1010 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1011 for ( ; dIt != request.
deletes.end(); ++dIt )
1018 else if ( parameters.contains( QStringLiteral(
"FILTER" ) ) )
1020 QString filterName = parameters.value( QStringLiteral(
"FILTER" ) );
1021 QStringList filterList;
1022 QRegExp rx(
"\\(([^()]+)\\)" );
1023 if ( rx.indexIn( filterName, 0 ) == -1 )
1025 filterList << filterName;
1030 while ( ( pos = rx.indexIn( filterName, pos ) ) != -1 )
1032 filterList << rx.cap( 1 );
1033 pos += rx.matchedLength();
1038 if ( request.
deletes.size() != filterList.size() )
1044 QList<transactionDelete>::iterator dIt = request.
deletes.begin();
1045 QStringList::const_iterator filterIt = filterList.constBegin();
1046 for ( ; dIt != request.
deletes.end(); ++dIt )
1051 QDomDocument filter;
1052 if ( filterIt != filterList.constEnd() )
1055 if ( !filter.setContent( *filterIt,
true, &errorMsg ) )
1061 QDomElement filterElem = filter.firstChildElement();
1062 QStringList serverFids;
1066 if ( filterIt != filterList.constEnd() )
1081 QDomNodeList docChildNodes = docElem.childNodes();
1083 QDomElement actionElem;
1086 for (
int i = docChildNodes.count(); 0 < i; --i )
1088 actionElem = docChildNodes.at( i - 1 ).toElement();
1089 actionName = actionElem.localName();
1091 if ( actionName == QLatin1String(
"Insert" ) )
1094 request.
inserts.append( action );
1096 else if ( actionName == QLatin1String(
"Update" ) )
1099 request.
updates.append( action );
1101 else if ( actionName == QLatin1String(
"Delete" ) )
1104 request.
deletes.append( action );
1113 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1114 if ( typeName.contains(
':' ) )
1115 typeName = typeName.section(
':', 1, 1 );
1117 QDomElement filterElem = actionElem.firstChild().toElement();
1118 if ( filterElem.tagName() != QLatin1String(
"Filter" ) )
1123 QStringList serverFids;
1130 action.
error =
false;
1132 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1134 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1142 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1143 if ( typeName.contains(
':' ) )
1144 typeName = typeName.section(
':', 1, 1 );
1146 QDomNodeList propertyNodeList = actionElem.elementsByTagName( QStringLiteral(
"Property" ) );
1147 if ( propertyNodeList.isEmpty() )
1152 QMap<QString, QString> propertyMap;
1153 QDomElement propertyElem;
1154 QDomElement nameElem;
1155 QDomElement valueElem;
1156 QDomElement geometryElem;
1158 for (
int l = 0; l < propertyNodeList.count(); ++l )
1160 propertyElem = propertyNodeList.at( l ).toElement();
1161 nameElem = propertyElem.elementsByTagName( QStringLiteral(
"Name" ) ).at( 0 ).toElement();
1162 valueElem = propertyElem.elementsByTagName( QStringLiteral(
"Value" ) ).at( 0 ).toElement();
1163 if ( nameElem.text() != QLatin1String(
"geometry" ) )
1165 propertyMap.insert( nameElem.text(), valueElem.text() );
1169 geometryElem = valueElem;
1173 QDomNodeList filterNodeList = actionElem.elementsByTagName( QStringLiteral(
"Filter" ) );
1175 QStringList serverFids;
1176 if ( filterNodeList.size() != 0 )
1178 QDomElement filterElem = filterNodeList.at( 0 ).toElement();
1188 action.
error =
false;
1190 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1192 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1200 QDomNodeList featureNodeList = actionElem.childNodes();
1201 if ( featureNodeList.size() != 1 )
1207 for (
int i = 0; i < featureNodeList.count(); ++i )
1209 QString tempTypeName = featureNodeList.at( i ).toElement().localName();
1210 if ( tempTypeName.contains(
':' ) )
1211 tempTypeName = tempTypeName.section(
':', 1, 1 );
1213 if ( typeName.isEmpty() )
1215 typeName = tempTypeName;
1217 else if ( tempTypeName != typeName )
1226 action.
error =
false;
1228 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1230 action.
handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1239 void addTransactionResult( QDomDocument &responseDoc, QDomElement &responseElem,
const QString &status,
1240 const QString &locator,
const QString &message )
1242 QDomElement trElem = responseDoc.createElement( QStringLiteral(
"TransactionResult" ) );
1243 QDomElement stElem = responseDoc.createElement( QStringLiteral(
"Status" ) );
1244 QDomElement successElem = responseDoc.createElement( status );
1245 stElem.appendChild( successElem );
1246 trElem.appendChild( stElem );
1247 responseElem.appendChild( trElem );
1249 if ( !locator.isEmpty() )
1251 QDomElement locElem = responseDoc.createElement( QStringLiteral(
"Locator" ) );
1252 locElem.appendChild( responseDoc.createTextNode( locator ) );
1253 trElem.appendChild( locElem );
1256 if ( !message.isEmpty() )
1258 QDomElement mesElem = responseDoc.createElement( QStringLiteral(
"Message" ) );
1259 mesElem.appendChild( responseDoc.createTextNode( message ) );
1260 trElem.appendChild( mesElem );
QgsFeatureRequest featureRequest
Class for parsing and evaluation of expressions (formerly called "search strings").
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...
bool layerInsertPermission(const QgsVectorLayer *layer) const
Returns the layer insert right.
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
QgsMapLayer::LayerType type() const
Returns the type of the layer.
transactionRequest parseTransactionRequestBody(QDomElement &docElem, const QgsProject *project)
Transform RequestBody root element to getFeatureRequest.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
virtual QgsAttributeList pkAttributeIndexes() const
Returns list of indexes of fields that make up the primary key.
bool layerUpdatePermission(const QgsVectorLayer *layer) const
Returns the layer update right.
SERVER_EXPORT QString getServerFid(const QgsFeature &feature, const QgsAttributeList &pkAttributes)
Returns the feature id based on primary keys.
QStringList commitErrors() const
Returns a list containing any error messages generated when attempting to commit changes to 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...
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
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
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...
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.
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.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
Reads and writes project states.
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.
QMap< QString, int > fieldNameMap() const
Returns a map where the key is the name of the field and the value is its index.
QStringList insertFeatureIds
bool allowToEdit(const QgsVectorLayer *layer, const QgsFeature &feature) const
Are we authorized to modify the following geometry.
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
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
virtual QgsVectorDataProvider::Capabilities capabilities() const
Returns flags containing the supported capabilities.
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
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.
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.
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).
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider.
QList< int > QgsAttributeList
QString message() const
Returns the exception message.
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.
bool layerDeletePermission(const QgsVectorLayer *layer) const
Returns the layer delete right.
Represents a vector layer which manages a vector based data sets.
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
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