Skip to content

Commit

Permalink
add deleteFeatures operation
Browse files Browse the repository at this point in the history
  • Loading branch information
davetimmins committed Oct 29, 2017
1 parent 4abef3e commit 2f30854
Show file tree
Hide file tree
Showing 12 changed files with 291 additions and 16 deletions.
4 changes: 3 additions & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ To migrate from ArcGIS.PCL to Anywhere.ArcGIS the following breaking changes nee

- `SecurePortalGateway` has been renamed to just `PortalGateway`.

- Internally all requests now use an `ArcGISServerOperation` type, this allows before and after actions to be invoked for the HTTP request.
- Internally all requests now use an `ArcGISServerOperation` type, this allows before and after actions to be invoked for the HTTP request.

- Renamed `GdbVersion` to `GeodatabaseVersion`.
2 changes: 1 addition & 1 deletion NUGET-DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ REST admin operations:

There are also methods to add / update and download attachments for a feature and you can extend this library by writing your own operations.

Refer to the integration test project for more examples.s
Refer to the integration test project for more examples.
2 changes: 1 addition & 1 deletion src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<RepositoryType>git</RepositoryType>
<PackageTags>ArcGIS ArcGISServer ArcGISOnline Esri REST netstandard anywhere GIS Mapping Map Location GeoLocation OAuth</PackageTags>
<PackageReleaseNotes>Initial port of ArcGIS.PCL to netstandard</PackageReleaseNotes>
<Version>1.0.0-beta.2</Version>
<Version>1.0.0-beta.3</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
46 changes: 46 additions & 0 deletions src/Anywhere.ArcGIS/Operation/ApplyEdits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public ApplyEdits(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Ac
Adds = new List<Feature<T>>();
Updates = new List<Feature<T>>();
Deletes = new List<long>();
RollbackOnFailure = true;
}

/// <summary>
Expand All @@ -42,6 +43,48 @@ public ApplyEdits(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Ac

[DataMember(Name = "deletes")]
public string DeleteIds { get { return Deletes == null ? string.Empty : string.Join(",", Deletes); } }

/// <summary>
/// Geodatabase version to apply the edits. This parameter applies only if the isDataVersioned property of the layer is true.
/// If the gdbVersion parameter is not specified, edits are made to the published map’s version.
/// This option was added at 10.1.
/// </summary>
[DataMember(Name = "gdbVersion")]
public string GeodatabaseVersion { get; set; }

/// <summary>
/// Optional parameter specifying whether the response will report the time features were deleted.
/// If returnEditMoment = true, the server will report the time in the response's editMoment key.
/// The default value is false.
/// This option was added at 10.5 and works with ArcGIS Server services only.
/// </summary>
[DataMember(Name = "returnEditMoment")]
public bool ReturnEditMoment { get; set; }

/// <summary>
/// Optional parameter to specify if the edits should be applied only if all submitted edits succeed.
/// If false, the server will apply the edits that succeed even if some of the submitted edits fail.
/// If true, the server will apply the edits only if all edits succeed. The default value is true.
/// Not all data supports setting this parameter.
/// Query the supportsRollbackonFailureParameter property of the layer to determine whether or not a layer supports setting this parameter.
/// If supportsRollbackOnFailureParameter = false for a layer, then when editing this layer, rollbackOnFailure will always be true, regardless of how the parameter is set.
/// However, if supportsRollbackonFailureParameter = true, this means the rollbackOnFailure parameter value will be honored on edit operations.
/// This option was added at 10.1.
/// </summary>
[DataMember(Name = "rollbackOnFailure")]
public bool RollbackOnFailure { get; set; }

/// <summary>
/// When set to true, the features and attachments in the adds, updates, deletes, and attachments parameters are identified by their globalIds.
/// When true, the service adds the new features and attachments while preserving the globalIds submitted in the payload.
/// If the globalId of a feature (or an attachment) collides with a pre-existing feature (or an attachment), that feature and/or attachment add fails.
/// Other adds, updates, or deletes are attempted if rollbackOnFailure is false.
/// If rollbackOnFailure is true, the whole operation fails and rolls back on any failure including a globalId collision.
/// When useGlobalIds is true, updates and deletes are identified by each feature or attachment globalId rather than their objectId or attachmentId.
/// This option was added at 10.4.
/// </summary>
[DataMember(Name = "useGlobalIds")]
public bool UseGlobalIds { get; set; }
}

/// <summary>
Expand Down Expand Up @@ -136,5 +179,8 @@ public class ApplyEditResponse : PortalResponse

[DataMember(Name = "success")]
public bool Success { get; set; }

[DataMember(Name = "editMoment")]
public string EditMoment { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Anywhere.ArcGIS/Operation/CommonParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public static class Operations
public const string Find = "find";
public const string ApplyEdits = "applyEdits";
public const string DeleteAttachments = "deleteAttachments";
public const string DeleteFeatures = "deleteFeatures";
public const string CreateReplica = "createReplica";
public const string UnregisterReplica = "unRegisterReplica";
public const string SingleInputGeocode = "find";
Expand Down
141 changes: 141 additions & 0 deletions src/Anywhere.ArcGIS/Operation/DeleteFeatures.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
using Anywhere.ArcGIS.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace Anywhere.ArcGIS.Operation
{
[DataContract]
public class DeleteFeatures : ArcGISServerOperation
{
public DeleteFeatures(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null)
: base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.DeleteFeatures, beforeRequest, afterRequest)
{
SpatialRelationship = SpatialRelationshipTypes.Intersects;
RollbackOnFailure = true;
}

/// <summary>
/// A where clause for the query filter. Any legal SQL where clause operating on the fields in the layer is allowed.
/// Features conforming to the specified where clause will be deleted.
/// </summary>
[DataMember(Name = "where")]
public string Where { get; set; }

/// <summary>
/// The object IDs of this layer/table to be deleted.
/// </summary>
[IgnoreDataMember]
public List<long> ObjectIds { get; set; }

/// <summary>
/// The list of object Ids to be deleted. This list is a comma delimited list of Ids.
/// </summary>
[DataMember(Name = "objectIds")]
public string ObjectIdsValue { get { return ObjectIds == null || !ObjectIds.Any() ? null : string.Join(",", ObjectIds); } }

/// <summary>
/// The geometry to apply as the spatial filter.
/// The structure of the geometry is the same as the structure of the json geometry objects returned by the ArcGIS REST API.
/// </summary>
/// <remarks>Default is empty</remarks>
[DataMember(Name = "geometry")]
public IGeometry Geometry { get; set; }

/// <summary>
/// The spatial reference of the input geometry.
/// </summary>
[DataMember(Name = "inSR")]
public SpatialReference InputSpatialReference
{
get { return Geometry == null ? null : Geometry.SpatialReference ?? null; }
}
/// <summary>
/// The type of geometry specified by the geometry parameter.
/// The geometry type can be an envelope, point, line, or polygon.
/// The default geometry type is "esriGeometryEnvelope".
/// Values: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope
/// </summary>
/// <remarks>Default is esriGeometryEnvelope</remarks>
[DataMember(Name = "geometryType")]
public string GeometryType
{
get
{
return Geometry == null
? GeometryTypes.Envelope
: GeometryTypes.TypeMap[Geometry.GetType()]();
}
}

/// <summary>
/// The spatial relationship to be applied on the input geometry while performing the query.
/// The supported spatial relationships include intersects, contains, envelope intersects, within, etc.
/// The default spatial relationship is "esriSpatialRelIntersects".
/// Values: esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin | esriSpatialRelRelation
/// </summary>
[DataMember(Name = "spatialRel")]
public string SpatialRelationship { get; set; }

/// <summary>
/// Geodatabase version to apply the edits. This parameter applies only if the isDataVersioned property of the layer is true.
/// If the gdbVersion parameter is not specified, edits are made to the published map’s version.
/// This option was added at 10.1.
/// </summary>
[DataMember(Name = "gdbVersion")]
public string GeodatabaseVersion { get; set; }

/// <summary>
/// Optional parameter specifying whether the response will report the time features were deleted.
/// If returnEditMoment = true, the server will report the time in the response's editMoment key.
/// The default value is false.
/// This option was added at 10.5 and works with ArcGIS Server services only.
/// </summary>
[DataMember(Name = "returnEditMoment")]
public bool ReturnEditMoment { get; set; }

/// <summary>
/// Optional parameter to specify if the edits should be applied only if all submitted edits succeed.
/// If false, the server will apply the edits that succeed even if some of the submitted edits fail.
/// If true, the server will apply the edits only if all edits succeed. The default value is true.
/// Not all data supports setting this parameter.
/// Query the supportsRollbackonFailureParameter property of the layer to determine whether or not a layer supports setting this parameter.
/// If supportsRollbackOnFailureParameter = false for a layer, then when editing this layer, rollbackOnFailure will always be true, regardless of how the parameter is set.
/// However, if supportsRollbackonFailureParameter = true, this means the rollbackOnFailure parameter value will be honored on edit operations.
/// This option was added at 10.1.
/// </summary>
[DataMember(Name = "rollbackOnFailure")]
public bool RollbackOnFailure { get; set; }
}

[DataContract]
public class DeleteFeaturesResponse : PortalResponse
{
[DataMember(Name = "deleteResults")]
public DeleteFeatureResult[] Results { get; set; }

/// <summary>
/// Only set when ObjectIds are not specified
/// </summary>
[DataMember(Name = "success")]
public bool? Success { get; set; }
}

[DataContract]
public class DeleteFeatureResult : PortalResponse
{
[DataMember(Name = "objectId")]
public long ObjectId { get; set; }

[DataMember(Name = "globalId")]
public string GlobalId { get; set; }

[DataMember(Name = "success")]
public bool Success { get; set; }

[DataMember(Name = "editMoment")]
public string EditMoment { get; set; }
}
}
20 changes: 17 additions & 3 deletions src/Anywhere.ArcGIS/Operation/Find.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Find(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action a
public string SearchText { get; set; }

/// <summary>
/// If false, the operation searches for an exact match of the SearchText string. An exact match is case sensitive.
/// If false, the operation searches for an exact match of the SearchText string. An exact match is case sensitive.
/// Otherwise, it searches for a value that contains the searchText provided. This search is not case sensitive
/// </summary>
/// <remarks>Default is true</remarks>
Expand Down Expand Up @@ -78,7 +78,7 @@ public Find(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action a
public int? MaxAllowableOffset { get; set; }

/// <summary>
/// This option can be used to specify the number of decimal places in the response geometries returned by the find operation.
/// This option can be used to specify the number of decimal places in the response geometries returned by the find operation.
/// This applies to X and Y values only (not m or z values).
/// </summary>
[DataMember(Name = "geometryPrecision")]
Expand All @@ -102,7 +102,21 @@ public Find(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action a
/// Switch map layers to point to an alternate geodabase version.
/// </summary>
[DataMember(Name = "gdbVersion")]
public string GdbVersion { get; set; }
public string GeodatabaseVersion { get; set; }

/// <summary>
/// If true, the values in the result will not be formatted i.e. numbers will returned as is and dates will be returned as epoch values.
/// This option was added at 10.5.
/// </summary>
[DataMember(Name = "returnUnformattedValues")]
public bool ReturnUnformattedValues { get; set; }

/// <summary>
/// If true, field names will be returned instead of field aliases.
/// This option was added at 10.5.
/// </summary>
[DataMember(Name = "returnFieldName")]
public bool ReturnFieldNames { get; set; }
}

[DataContract]
Expand Down
5 changes: 1 addition & 4 deletions src/Anywhere.ArcGIS/Operation/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,13 @@ public string GeometryType
[DataMember(Name = "objectIds")]
public string ObjectIdsValue { get { return ObjectIds == null || !ObjectIds.Any() ? null : string.Join(",", ObjectIds); } }


/// <summary>
/// The spatial reference of the returned geometry.
/// If not specified, the geometry is returned in the spatial reference of the input.
/// </summary>
[DataMember(Name = "outSR")]
public SpatialReference OutputSpatialReference { get; set; }



/// <summary>
/// The spatial relationship to be applied on the input geometry while performing the query.
/// The supported spatial relationships include intersects, contains, envelope intersects, within, etc.
Expand Down Expand Up @@ -170,7 +167,7 @@ public string Time
/// GeoDatabase version to query.
/// </summary>
[DataMember(Name = "gdbVersion")]
public string GdbVersion { get; set; }
public string GeodatabaseVersion { get; set; }

/// <summary>
/// If true, returns distinct values based on the fields specified in outFields.
Expand Down
31 changes: 31 additions & 0 deletions src/Anywhere.ArcGIS/PortalGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,37 @@
/// </summary>
public class PortalGateway : PortalGatewayBase
{
/// <summary>
/// Create a new <see cref="PortalGateway"/> using the default token service as discovered using the Info operation for the server
/// </summary>
/// <param name="rootUrl"></param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <param name="serializer"></param>
/// <param name="httpClientFunc"></param>
/// <param name="ct"></param>
/// <returns></returns>
public new static async Task<PortalGateway> Create(
string rootUrl, string username, string password,
ISerializer serializer = null, Func<HttpClient> httpClientFunc = null,
CancellationToken ct = default(CancellationToken))
{
if (string.IsNullOrWhiteSpace(rootUrl))
{
throw new ArgumentNullException(nameof(rootUrl), "rootUrl is null.");
}

var info = await new PortalGateway(rootUrl, serializer: serializer, httpClientFunc: httpClientFunc).Info(ct);

var result = new PortalGateway(
rootUrl,
tokenProvider: new TokenProvider(info.AuthenticationInfo?.TokenServicesUrl, username, password),
serializer: serializer,
httpClientFunc: httpClientFunc);

return result;
}

public PortalGateway(string rootUrl, ISerializer serializer = null, ITokenProvider tokenProvider = null, Func<HttpClient> httpClientFunc = null)
: base(rootUrl, serializer, tokenProvider, httpClientFunc)
{ }
Expand Down
Loading

0 comments on commit 2f30854

Please sign in to comment.