Skip to content

Commit

Permalink
Merge pull request #4 from davetimmins/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
davetimmins authored Oct 31, 2017
2 parents 491eaeb + 1e3480e commit da70f9f
Show file tree
Hide file tree
Showing 16 changed files with 327 additions and 32 deletions.
10 changes: 7 additions & 3 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
Why the change? Well there are 2 main reasons, the first is that this is now a netstandard library rather than a portable class library (PCL), so the old naming didn't really apply. Secondly, NuGet now has package Id reservations and so I can't use ArcGIS as the suffix anymore.

To migrate from ArcGIS.PCL to Anywhere.ArcGIS the following breaking changes need to be done / reviewed:
To migrate from [ArcGIS.PCL](https://github.com/davetimmins/ArcGIS.PCL/) to [Anywhere.ArcGIS](https://github.com/davetimmins/Anywhere.ArcGIS/) the following __breaking__ :boom: changes need to be done / reviewed:

- All namespaces have changed from `ArcGIS.ServiceModel.*` to `Anywhere.ArcGIS.*`.

- You no longer need to call the static `ISerializer` `Init()` method as JSON.NET is now baked in.
- You no longer need to call the static `ISerializer.Init()` method as JSON.NET is now baked in as the default.

- `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`.

- Removed `Disabled` from `ICryptoProvider` and replaced it with `Enabled` which is `false` by default, so to opt in to trying to encrypt token requests (admin endpoint only) you now need to call `CryptoProviderFactory.Enabled = true;` once in your app code.
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.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Supports the following as typed operations:
- `QueryForExtent` return the bounding extent for the result of the query operation
- `Find` search across _n_ layers and fields in a service
- `ApplyEdits` post adds, updates and deletes to a feature service layer
- `DeleteFeatures` delete features in a feature layer or table
- `Geocode` single line of input to perform a geocode using a custom locator or the Esri world locator
- `Suggest` lightweight geocode operation that only returns text results, commonly used for predictive searching
- `ReverseGeocode` find location candidates for a input point location
Expand Down
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
2 changes: 1 addition & 1 deletion src/Anywhere.ArcGIS/ArcGISOnlineAppLoginOAuthProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void Dispose()

public string RootUrl
{
get { return "https://www.arcgis.com/sharing/oauth2/token"; }
get { return "https://www.arcgis.com/sharing/rest/oauth2/token"; }
}

public bool CancelPendingRequests { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/Anywhere.ArcGIS/CryptoProviderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public static class CryptoProviderFactory
{
public static Func<ICryptoProvider> Get { get; set; }

public static bool Disabled { get; set; }
public static bool Enabled { get; set; }

static CryptoProviderFactory()
{
Get = (() => { return Disabled ? null : new RsaEncrypter(); });
Get = (() => { return Enabled ? new RsaEncrypter() : null; });
}
}

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
Loading

0 comments on commit da70f9f

Please sign in to comment.