48 void addTransactionResult( QDomDocument &responseDoc, QDomElement &resultsElem,
49 const QString &locator,
const QString &message );
60 response.
setHeader(
"Content-Type",
"text/xml; charset=utf-8" );
61 response.
write( doc.toByteArray() );
70 transactionRequest aRequest;
75 if ( doc.setContent( request.
data(),
true, &errorMsg ) )
77 QDomElement docElem = doc.documentElement();
85 int actionCount = aRequest.inserts.size() + aRequest.updates.size() + aRequest.deletes.size();
86 if ( actionCount == 0 )
88 throw QgsRequestNotWellFormedException( QStringLiteral(
"No actions found" ) );
97 QDomElement respElem = resp.createElement( QStringLiteral(
"TransactionResponse" ) );
98 respElem.setAttribute( QStringLiteral(
"xmlns" ),
WFS_NAMESPACE );
99 respElem.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
100 respElem.setAttribute( QStringLiteral(
"xsi:schemaLocation" ),
WFS_NAMESPACE +
" http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" );
101 respElem.setAttribute( QStringLiteral(
"xmlns:ogc" ),
OGC_NAMESPACE );
102 respElem.setAttribute( QStringLiteral(
"version" ), QStringLiteral(
"1.1.0" ) );
103 resp.appendChild( respElem );
105 int totalInserted = 0;
106 int totalUpdated = 0;
107 int totalDeleted = 0;
111 QDomElement trsElem = doc.createElement( QStringLiteral(
"TransactionResults" ) );
114 QDomElement irsElem = doc.createElement( QStringLiteral(
"InsertResults" ) );
115 QList<transactionInsert>::iterator tiIt = aRequest.inserts.begin();
116 for ( ; tiIt != aRequest.inserts.end(); ++tiIt )
118 transactionInsert &action = *tiIt;
122 QString locator = action.handle;
123 if ( locator.isEmpty() )
125 locator = QStringLiteral(
"Insert:%1" ).arg( action.typeName );
127 addTransactionResult( resp, trsElem, locator, action.errorMsg );
131 QStringList::const_iterator fidIt = action.insertFeatureIds.constBegin();
132 for ( ; fidIt != action.insertFeatureIds.constEnd(); ++fidIt )
134 QString fidStr = *fidIt;
135 QDomElement irElem = doc.createElement( QStringLiteral(
"Feature" ) );
136 if ( !action.handle.isEmpty() )
138 irElem.setAttribute( QStringLiteral(
"handle" ), action.handle );
140 QDomElement fiElem = doc.createElement( QStringLiteral(
"ogc:FeatureId" ) );
141 fiElem.setAttribute( QStringLiteral(
"fid" ), fidStr );
142 irElem.appendChild( fiElem );
143 irsElem.appendChild( irElem );
146 totalInserted += action.insertFeatureIds.count();
149 QList<transactionUpdate>::iterator tuIt = aRequest.updates.begin();
150 for ( ; tuIt != aRequest.updates.end(); ++tuIt )
152 transactionUpdate &action = *tuIt;
156 QString locator = action.handle;
157 if ( locator.isEmpty() )
159 locator = QStringLiteral(
"Update:%1" ).arg( action.typeName );
161 addTransactionResult( resp, trsElem, locator, action.errorMsg );
163 totalUpdated += action.totalUpdated;
166 QList<transactionDelete>::iterator tdIt = aRequest.deletes.begin();
167 for ( ; tdIt != aRequest.deletes.end(); ++tdIt )
169 transactionDelete &action = *tdIt;
173 QString locator = action.handle;
174 if ( locator.isEmpty() )
176 locator = QStringLiteral(
"Delete:%1" ).arg( action.typeName );
178 addTransactionResult( resp, trsElem, locator, action.errorMsg );
180 totalDeleted += action.totalDeleted;
184 QDomElement summaryElem = doc.createElement( QStringLiteral(
"TransactionSummary" ) );
185 if ( aRequest.inserts.size() > 0 )
187 QDomElement totalInsertedElem = doc.createElement( QStringLiteral(
"TotalInserted" ) );
188 totalInsertedElem.appendChild( doc.createTextNode( QString::number( totalInserted ) ) );
189 summaryElem.appendChild( totalInsertedElem );
191 if ( aRequest.updates.size() > 0 )
193 QDomElement totalUpdatedElem = doc.createElement( QStringLiteral(
"TotalUpdated" ) );
194 totalUpdatedElem.appendChild( doc.createTextNode( QString::number( totalUpdated ) ) );
195 summaryElem.appendChild( totalUpdatedElem );
197 if ( aRequest.deletes.size() > 0 )
199 QDomElement totalDeletedElem = doc.createElement( QStringLiteral(
"TotalDeleted" ) );
200 totalDeletedElem.appendChild( doc.createTextNode( QString::number( totalDeleted ) ) );
201 summaryElem.appendChild( totalDeletedElem );
203 respElem.appendChild( summaryElem );
206 if ( errorCount > 0 && trsElem.hasChildNodes() )
208 respElem.appendChild( trsElem );
212 if ( aRequest.inserts.size() > 0 && irsElem.hasChildNodes() )
214 respElem.appendChild( irsElem );
221 #ifndef HAVE_SERVER_PYTHON_PLUGINS
225 QStringList typeNameList;
227 QList<transactionInsert>::iterator tiIt = aRequest.inserts.begin();
228 for ( ; tiIt != aRequest.inserts.end(); ++tiIt )
230 QString name = ( *tiIt ).typeName;
231 if ( !typeNameList.contains( name ) )
232 typeNameList << name;
234 QList<transactionUpdate>::iterator tuIt = aRequest.updates.begin();
235 for ( ; tuIt != aRequest.updates.end(); ++tuIt )
237 QString name = ( *tuIt ).typeName;
238 if ( !typeNameList.contains( name ) )
239 typeNameList << name;
241 QList<transactionDelete>::iterator tdIt = aRequest.deletes.begin();
242 for ( ; tdIt != aRequest.deletes.end(); ++tdIt )
244 QString name = ( *tdIt ).typeName;
245 if ( !typeNameList.contains( name ) )
246 typeNameList << name;
249 #ifdef HAVE_SERVER_PYTHON_PLUGINS
263 QMap<QString, QgsVectorLayer *> mapLayerMap;
278 if ( !typeNameList.contains( name ) )
287 throw QgsRequestNotWellFormedException( QStringLiteral(
"Layer error on '%1'" ).arg( name ) );
294 throw QgsRequestNotWellFormedException( QStringLiteral(
"Provider error on layer '%1'" ).arg( name ) );
302 throw QgsRequestNotWellFormedException( QStringLiteral(
"No capabilities to do WFS changes on layer '%1'" ).arg( name ) );
309 throw QgsSecurityAccessException( QStringLiteral(
"No permissions to do WFS changes on layer '%1'" ).arg( name ) );
311 #ifdef HAVE_SERVER_PYTHON_PLUGINS
315 throw QgsSecurityAccessException( QStringLiteral(
"No permissions to do WFS changes on layer '%1'" ).arg( name ) );
324 mapLayerMap[name] = vlayer;
328 tuIt = aRequest.updates.begin();
329 for ( ; tuIt != aRequest.updates.end(); ++tuIt )
331 transactionUpdate &action = *tuIt;
334 if ( !mapLayerMap.keys().contains(
typeName ) )
337 action.errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg(
typeName );
348 action.errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg(
typeName );
351 #ifdef HAVE_SERVER_PYTHON_PLUGINS
355 action.errorMsg = QStringLiteral(
"No permissions to do WFS updates on layer '%1'" ).arg(
typeName );
367 action.errorMsg = QStringLiteral(
"No capabilities to do WFS updates on layer '%1'" ).arg(
typeName );
384 if ( !action.serverFids.isEmpty() )
390 #ifdef HAVE_SERVER_PYTHON_PLUGINS
399 int totalUpdated = 0;
401 QMap<QString, QString> propertyMap = action.propertyMap;
402 QDomElement geometryElem = action.geometryElement;
405 const QMap<QString, int> fieldMap = provider->
fieldNameMap();
406 QMap<QString, int>::const_iterator fieldMapIt;
408 bool conversionSuccess;
412 #ifdef HAVE_SERVER_PYTHON_PLUGINS
413 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
416 action.errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg(
typeName );
421 QMap< QString, QString >::const_iterator it = propertyMap.constBegin();
422 for ( ; it != propertyMap.constEnd(); ++it )
424 fieldName = it.key();
425 fieldMapIt = fieldMap.find( fieldName );
426 if ( fieldMapIt == fieldMap.constEnd() )
430 QgsField field = fields.
at( fieldMapIt.value() );
431 QVariant value = it.value();
432 if ( value.isNull() )
437 action.errorMsg = QStringLiteral(
"NOT NULL constraint error on layer '%1', field '%2'" ).arg(
typeName, field.
name() );
444 if ( field.
type() == QVariant::Type::Int )
446 value = it.value().toInt( &conversionSuccess );
447 if ( !conversionSuccess )
450 action.errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg(
typeName );
455 else if ( field.
type() == QVariant::Type::Double )
457 value = it.value().toDouble( &conversionSuccess );
458 if ( !conversionSuccess )
461 action.errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg(
typeName );
466 else if ( field.
type() == QVariant::Type::LongLong )
468 value = it.value().toLongLong( &conversionSuccess );
469 if ( !conversionSuccess )
472 action.errorMsg = QStringLiteral(
"Property conversion error on layer '%1'" ).arg(
typeName );
485 if ( !geometryElem.isNull() )
491 action.errorMsg = QStringLiteral(
"Geometry from GML error on layer '%1'" ).arg(
typeName );
498 action.errorMsg = QStringLiteral(
"Error in change geometry on layer '%1'" ).arg(
typeName );
509 #ifdef HAVE_SERVER_PYTHON_PLUGINS
516 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
519 action.errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg(
typeName );
535 action.errorMsg = QStringLiteral(
"Error committing updates: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
540 action.totalUpdated = totalUpdated;
541 action.error =
false;
546 tdIt = aRequest.deletes.begin();
547 for ( ; tdIt != aRequest.deletes.end(); ++tdIt )
549 transactionDelete &action = *tdIt;
552 if ( !mapLayerMap.keys().contains(
typeName ) )
555 action.errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg(
typeName );
566 action.errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg(
typeName );
569 #ifdef HAVE_SERVER_PYTHON_PLUGINS
573 action.errorMsg = QStringLiteral(
"No permissions to do WFS deletes on layer '%1'" ).arg(
typeName );
585 action.errorMsg = QStringLiteral(
"No capabilities to do WFS deletes on layer '%1'" ).arg(
typeName );
602 if ( action.serverFids.isEmpty() )
605 action.errorMsg = QStringLiteral(
"No feature ids to do WFS deletes on layer '%1'" ).arg(
typeName );
612 #ifdef HAVE_SERVER_PYTHON_PLUGINS
626 #ifdef HAVE_SERVER_PYTHON_PLUGINS
627 if ( accessControl && !accessControl->
allowToEdit( vlayer, feature ) )
630 action.errorMsg = QStringLiteral(
"Feature modify permission denied" );
635 fids << feature.
id();
645 action.errorMsg = QStringLiteral(
"Delete features failed on layer '%1'" ).arg(
typeName );
654 action.errorMsg = QStringLiteral(
"Error committing deletes: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
659 action.totalDeleted = fids.count();
660 action.error =
false;
664 tiIt = aRequest.inserts.begin();
665 for ( ; tiIt != aRequest.inserts.end(); ++tiIt )
667 transactionInsert &action = *tiIt;
670 if ( !mapLayerMap.keys().contains(
typeName ) )
673 action.errorMsg = QStringLiteral(
"TypeName '%1' unknown" ).arg(
typeName );
684 action.errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg(
typeName );
687 #ifdef HAVE_SERVER_PYTHON_PLUGINS
691 action.errorMsg = QStringLiteral(
"No permissions to do WFS inserts on layer '%1'" ).arg(
typeName );
703 action.errorMsg = QStringLiteral(
"No capabilities to do WFS inserts on layer '%1'" ).arg(
typeName );
719 action.errorMsg = QStringLiteral(
"%1 '%2'" ).arg( ex.
message() ).arg(
typeName );
723 if ( featureList.empty() )
726 action.errorMsg = QStringLiteral(
"No features to insert in layer '%1'" ).arg(
typeName );
730 #ifdef HAVE_SERVER_PYTHON_PLUGINS
734 QgsFeatureList::iterator featureIt = featureList.begin();
735 while ( featureIt != featureList.end() )
737 if ( !accessControl->
allowToEdit( vlayer, *featureIt ) )
740 action.errorMsg = QStringLiteral(
"Feature modify permission denied on layer '%1'" ).arg(
typeName );
757 action.errorMsg = QStringLiteral(
"Insert features failed on layer '%1'" ).arg(
typeName );
758 if ( provider ->hasErrors() )
770 action.errorMsg = QStringLiteral(
"Error committing inserts: %1" ).arg( vlayer->
commitErrors().join( QStringLiteral(
"; " ) ) );
775 action.error =
false;
779 for (
const QgsFeature &feat : qgis::as_const( featureList ) )
786 filterRestorer.reset();
796 const QMap<QString, int> fieldMap = provider->
fieldNameMap();
797 QMap<QString, int>::const_iterator fieldMapIt;
799 for (
int i = 0; i < featureNodeList.count(); i++ )
803 QDomElement featureElem = featureNodeList.at( i ).toElement();
804 QDomNode currentAttributeChild = featureElem.firstChild();
805 bool conversionSuccess =
true;
807 while ( !currentAttributeChild.isNull() )
809 QDomElement currentAttributeElement = currentAttributeChild.toElement();
810 QString attrName = currentAttributeElement.localName();
812 if ( attrName != QLatin1String(
"boundedBy" ) )
814 if ( attrName != QLatin1String(
"geometry" ) )
816 fieldMapIt = fieldMap.find( attrName );
817 if ( fieldMapIt == fieldMap.constEnd() )
822 QgsField field = fields.
at( fieldMapIt.value() );
823 QString attrValue = currentAttributeElement.text();
824 int attrType = field.
type();
826 QgsMessageLog::logMessage( QStringLiteral(
"attr: name=%1 idx=%2 value=%3" ).arg( attrName ).arg( fieldMapIt.value() ).arg( attrValue ) );
828 if ( attrType == QVariant::Int )
829 feat.setAttribute( fieldMapIt.value(), attrValue.toInt( &conversionSuccess ) );
830 else if ( attrType == QVariant::Double )
831 feat.setAttribute( fieldMapIt.value(), attrValue.toDouble( &conversionSuccess ) );
833 feat.setAttribute( fieldMapIt.value(), attrValue );
835 if ( !conversionSuccess )
847 feat.setGeometry( g );
850 currentAttributeChild = currentAttributeChild.nextSibling();
860 if ( !parameters.contains( QStringLiteral(
"OPERATION" ) ) )
862 throw QgsRequestNotWellFormedException( QStringLiteral(
"OPERATION parameter is mandatory" ) );
864 if ( parameters.value( QStringLiteral(
"OPERATION" ) ).toUpper() != QStringLiteral(
"DELETE" ) )
866 throw QgsRequestNotWellFormedException( QStringLiteral(
"Only DELETE value is defined for OPERATION parameter" ) );
870 if ( ( parameters.contains( QStringLiteral(
"FEATUREID" ) )
871 && ( parameters.contains( QStringLiteral(
"FILTER" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
872 || ( parameters.contains( QStringLiteral(
"FILTER" ) )
873 && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"BBOX" ) ) ) )
874 || ( parameters.contains( QStringLiteral(
"BBOX" ) )
875 && ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) || parameters.contains( QStringLiteral(
"FILTER" ) ) ) )
881 transactionRequest request;
883 QStringList typeNameList;
885 if ( parameters.contains( QStringLiteral(
"FEATUREID" ) ) )
887 QStringList fidList = parameters.value( QStringLiteral(
"FEATUREID" ) ).split(
',' );
889 QMap<QString, QStringList> fidsMap;
891 QStringList::const_iterator fidIt = fidList.constBegin();
892 for ( ; fidIt != fidList.constEnd(); ++fidIt )
895 QString fid = *fidIt;
898 if ( !fid.contains(
'.' ) )
900 throw QgsRequestNotWellFormedException( QStringLiteral(
"FEATUREID has to have TYPENAME in the values" ) );
903 QString
typeName = fid.section(
'.', 0, 0 );
904 fid = fid.section(
'.', 1, 1 );
905 if ( !typeNameList.contains(
typeName ) )
919 QMap<QString, QStringList>::const_iterator fidsMapIt = fidsMap.constBegin();
920 while ( fidsMapIt != fidsMap.constEnd() )
922 transactionDelete action;
923 action.typeName = fidsMapIt.key();
925 action.serverFids = fidsMapIt.value();
928 request.deletes.append( action );
933 if ( !parameters.contains( QStringLiteral(
"TYPENAME" ) ) )
935 throw QgsRequestNotWellFormedException( QStringLiteral(
"TYPENAME is mandatory except if FEATUREID is used" ) );
938 typeNameList = parameters.value( QStringLiteral(
"TYPENAME" ) ).split(
',' );
941 QStringList::const_iterator typeNameIt = typeNameList.constBegin();
942 for ( ; typeNameIt != typeNameList.constEnd(); ++typeNameIt )
947 transactionDelete action;
950 request.deletes.append( action );
954 if ( parameters.contains( QStringLiteral(
"EXP_FILTER" ) ) )
956 QString expFilterName = parameters.value( QStringLiteral(
"EXP_FILTER" ) );
957 QStringList expFilterList;
958 QRegExp rx(
"\\(([^()]+)\\)" );
959 if ( rx.indexIn( expFilterName, 0 ) == -1 )
961 expFilterList << expFilterName;
966 while ( ( pos = rx.indexIn( expFilterName, pos ) ) != -1 )
968 expFilterList << rx.cap( 1 );
969 pos += rx.matchedLength();
974 if ( request.deletes.size() == expFilterList.size() )
977 QList<transactionDelete>::iterator dIt = request.deletes.begin();
978 QStringList::const_iterator expFilterIt = expFilterList.constBegin();
979 for ( ; dIt != request.deletes.end(); ++dIt )
981 transactionDelete &action = *dIt;
984 if ( expFilterIt != expFilterList.constEnd() )
986 expFilter = *expFilterIt;
988 std::shared_ptr<QgsExpression> filter(
new QgsExpression( expFilter ) );
991 if ( filter->hasParserError() )
997 if ( filter->needsGeometry() )
1001 action.featureRequest.setFilterExpression( filter->expression() );
1008 QgsMessageLog::logMessage(
"There has to be a 1:1 mapping between each element in a TYPENAME and the EXP_FILTER list" );
1012 if ( parameters.contains( QStringLiteral(
"BBOX" ) ) )
1015 QString bbox = parameters.value( QStringLiteral(
"BBOX" ) );
1016 if ( bbox.isEmpty() )
1018 throw QgsRequestNotWellFormedException( QStringLiteral(
"BBOX parameter is empty" ) );
1022 QStringList corners = bbox.split(
',' );
1023 if ( corners.size() != 4 )
1025 throw QgsRequestNotWellFormedException( QStringLiteral(
"BBOX has to be composed of 4 elements: '%1'" ).arg( bbox ) );
1031 for (
int i = 0; i < 4; i++ )
1033 corners[i].replace(
' ',
'+' );
1034 d[i] = corners[i].toDouble( &ok );
1037 throw QgsRequestNotWellFormedException( QStringLiteral(
"BBOX has to be composed of 4 double: '%1'" ).arg( bbox ) );
1044 QList<transactionDelete>::iterator dIt = request.deletes.begin();
1045 for ( ; dIt != request.deletes.end(); ++dIt )
1047 transactionDelete &action = *dIt;
1048 action.featureRequest.setFilterRect( extent );
1052 else if ( parameters.contains( QStringLiteral(
"FILTER" ) ) )
1054 QString filterName = parameters.value( QStringLiteral(
"FILTER" ) );
1055 QStringList filterList;
1056 QRegExp rx(
"\\(([^()]+)\\)" );
1057 if ( rx.indexIn( filterName, 0 ) == -1 )
1059 filterList << filterName;
1064 while ( ( pos = rx.indexIn( filterName, pos ) ) != -1 )
1066 filterList << rx.cap( 1 );
1067 pos += rx.matchedLength();
1072 if ( request.deletes.size() != filterList.size() )
1074 throw QgsRequestNotWellFormedException( QStringLiteral(
"There has to be a 1:1 mapping between each element in a TYPENAME and the FILTER list" ) );
1078 QList<transactionDelete>::iterator dIt = request.deletes.begin();
1079 QStringList::const_iterator filterIt = filterList.constBegin();
1080 for ( ; dIt != request.deletes.end(); ++dIt )
1082 transactionDelete &action = *dIt;
1085 QDomDocument filter;
1086 if ( filterIt != filterList.constEnd() )
1089 if ( !filter.setContent( *filterIt,
true, &errorMsg ) )
1091 throw QgsRequestNotWellFormedException( QStringLiteral(
"error message: %1. The XML string was: %2" ).arg( errorMsg, *filterIt ) );
1095 QDomElement filterElem = filter.firstChildElement();
1096 QStringList serverFids;
1097 action.featureRequest =
parseFilterElement( action.typeName, filterElem, serverFids, project );
1098 action.serverFids = serverFids;
1100 if ( filterIt != filterList.constEnd() )
1113 transactionRequest request;
1115 QDomNodeList docChildNodes = docElem.childNodes();
1117 QDomElement actionElem;
1120 for (
int i = docChildNodes.count(); 0 < i; --i )
1122 actionElem = docChildNodes.at( i - 1 ).toElement();
1123 actionName = actionElem.localName();
1125 if ( actionName == QLatin1String(
"Insert" ) )
1128 request.inserts.append( action );
1130 else if ( actionName == QLatin1String(
"Update" ) )
1133 request.updates.append( action );
1135 else if ( actionName == QLatin1String(
"Delete" ) )
1138 request.deletes.append( action );
1147 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1151 QDomElement filterElem = actionElem.firstChild().toElement();
1152 if ( filterElem.tagName() != QLatin1String(
"Filter" ) )
1154 throw QgsRequestNotWellFormedException( QStringLiteral(
"Delete action element first child is not Filter" ) );
1157 QStringList serverFids;
1160 transactionDelete action;
1162 action.featureRequest = featureRequest;
1163 action.serverFids = serverFids;
1164 action.error =
false;
1166 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1168 action.handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1177 QString
typeName = actionElem.attribute( QStringLiteral(
"typeName" ) );
1181 QDomNodeList propertyNodeList = actionElem.elementsByTagName( QStringLiteral(
"Property" ) );
1182 if ( propertyNodeList.isEmpty() )
1184 throw QgsRequestNotWellFormedException( QStringLiteral(
"Update action element must have one or more Property element" ) );
1187 QMap<QString, QString> propertyMap;
1188 QDomElement propertyElem;
1189 QDomElement nameElem;
1190 QDomElement valueElem;
1191 QDomElement geometryElem;
1193 for (
int l = 0; l < propertyNodeList.count(); ++l )
1195 propertyElem = propertyNodeList.at( l ).toElement();
1196 nameElem = propertyElem.elementsByTagName( QStringLiteral(
"Name" ) ).at( 0 ).toElement();
1197 valueElem = propertyElem.elementsByTagName( QStringLiteral(
"Value" ) ).at( 0 ).toElement();
1198 if ( nameElem.text() != QLatin1String(
"geometry" ) )
1200 propertyMap.insert( nameElem.text(), valueElem.text() );
1204 geometryElem = valueElem;
1208 QDomNodeList filterNodeList = actionElem.elementsByTagName( QStringLiteral(
"Filter" ) );
1210 QStringList serverFids;
1211 if ( filterNodeList.size() != 0 )
1213 QDomElement filterElem = filterNodeList.at( 0 ).toElement();
1218 transactionUpdate action;
1220 action.propertyMap = propertyMap;
1221 action.geometryElement = geometryElem;
1222 action.featureRequest = featureRequest;
1223 action.serverFids = serverFids;
1224 action.error =
false;
1226 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1228 action.handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1236 QDomNodeList featureNodeList = actionElem.childNodes();
1237 if ( featureNodeList.size() != 1 )
1239 throw QgsRequestNotWellFormedException( QStringLiteral(
"Insert action element must have one or more child node" ) );
1243 for (
int i = 0; i < featureNodeList.count(); ++i )
1245 QString tempTypeName = featureNodeList.at( i ).toElement().localName();
1246 if ( tempTypeName.contains(
':' ) )
1247 tempTypeName = tempTypeName.section(
':', 1, 1 );
1253 else if ( tempTypeName !=
typeName )
1255 throw QgsRequestNotWellFormedException( QStringLiteral(
"Insert action element must have one typename features" ) );
1259 transactionInsert action;
1261 action.featureNodeList = featureNodeList;
1262 action.error =
false;
1264 if ( actionElem.hasAttribute( QStringLiteral(
"handle" ) ) )
1266 action.handle = actionElem.attribute( QStringLiteral(
"handle" ) );
1275 void addTransactionResult( QDomDocument &responseDoc, QDomElement &resultsElem,
1276 const QString &locator,
const QString &message )
1278 QDomElement trElem = responseDoc.createElement( QStringLiteral(
"Action" ) );
1279 resultsElem.appendChild( trElem );
1281 if ( !locator.isEmpty() )
1283 trElem.setAttribute( QStringLiteral(
"locator" ), locator );
1286 if ( !message.isEmpty() )
1288 QDomElement mesElem = responseDoc.createElement( QStringLiteral(
"Message" ) );
1289 mesElem.appendChild( responseDoc.createTextNode( message ) );
1290 trElem.appendChild( mesElem );