Part 2 - Branch Versioning with Parcel Fabric

Components of a Parcel Fabric Feature Service

A Parcel Fabric feature service consists of at least 5 endpoints (SOEs)

  • Mapping (.../MapServer)
  • Feature Access (.../FeatureServer)
  • Version Management (.../VersionManagementServer)
  • Validation (.../ValidationServer)
  • Parcel Fabric (../ParcelFabricServer)

Most Parcel Fabric editing operations will make use of the Feature Access, Version Management and Parcel Fabric endpoints.

Parcel editing workflow

At a high level, a typical parcel editing workflow will look like:

  1. Create a branch version to isolate edits from the default version. (Version Management)
  2. Start an edit session (Version Management)
  3. Create a new parcel Record feature (Feature Access)
  4. Edit one or more parcels (merge, divide, copy lines, etc.) (Parcel Fabric)
  5. Reconcile the current branch version with the default version. (Version Management)
  6. Post changes from the current version to the default version. (Version Management)
  7. Stop the edit session. (Version Management)
  8. Delete the version. (Version Management)

Based on this example, it is obvious that understanding versioned, multi-user editing is critical. The following notebooks will demonstrate how to list versions, create versions, start and stop edit sessions and reconcile and post edits.

from arcgis import GIS
from arcgis.features import _version
base_server_url = (
    "https://rextapilnx02eb.mysite.com/server/rest/services/WashingtonCounty/"
)
gis = GIS(
    "https://myenterprisesite.com/portal/",
    "my_user_name",
    "my_secure_password",
    verify_cert=False,
)
Setting `verify_cert` to False is a security risk, use at your own risk.

Access branch versions via Version Management Server

from arcgis.features._version import VersionManager

version_management_server_url = f"{base_server_url}/VersionManagementServer"
vms = VersionManager(version_management_server_url, gis)
vms.properties
{
  "name": "Version Management Server",
  "type": "Map Server Extension",
  "defaultVersionName": "sde.DEFAULT",
  "defaultVersionGuid": "{BD3F4817-9A00-41AC-B0CC-58F78DBAE0A1}",
  "capabilities": {
    "supportsConflictDetectionByAttribute": true,
    "supportsPartialPost": true,
    "supportsDifferencesFromMoment": true,
    "supportsDifferencesWithLayers": true,
    "supportsAsyncReconcile": true,
    "supportsAsyncPost": true,
    "supportsAsyncDifferences": true,
    "supportsOutSR": true
  }
}

Get all versions

versions = vms.all
versions
[<Version sde.DEFAULT @ {BD3F4817-9A00-41AC-B0CC-58F78DBAE0A1}>,
 <Version mycreator.merge_version_1 @ {D1FDA18B-7B15-4773-9D7D-814092D88171}>]

Create a version

The create method returns the properties of the new version. Use this info to get the fully qualified version name owner.version_name

new_version_name = "fabric_editor_1"
version = vms.create(new_version_name)
fq_version_name = version["versionInfo"]["versionName"]
print(fq_version_name)

version # view the version's properties
my_user_name.fabric_editor_1
{'versionInfo': {'versionName': 'my_user_name.fabric_editor_1',
  'versionGuid': '{EF1752A9-DF21-4D9B-819D-55F3D56BCE80}',
  'versionId': 16,
  'description': '',
  'creationDate': 1685640955750,
  'modifiedDate': 1685640955750,
  'reconcileDate': None,
  'evaluationDate': None,
  'previousAncestorDate': None,
  'commonAncestorDate': 1685640955750,
  'access': 'public'},
 'success': True}

Access the Version Management Server through the Parcel Fabric FeatureLayerCollection object

The versions property in a parcel fabric FeatureLayerCollection (FLC) creates a VersionManager object to create, update and use versions.

The FeatureServer endpoint is used to create a FeatureLayerCollection.

from arcgis.features.layer import FeatureLayerCollection

parcel_fabric_feature_server_url = f"{base_server_url}/FeatureServer"
parcel_fabric_flc = FeatureLayerCollection(parcel_fabric_feature_server_url, gis)

# print the version names from the FLC's versions property:
vms_from_flc = parcel_fabric_flc.versions
[v.properties.versionName for v in vms_from_flc.all]
['sde.DEFAULT', 'my_user_name.fabric_editor_1', 'mycreator.merge_version_1']

Branch Versioning Edit Sessions

A branch versioning edit session is the act of obtaining shared and exclusive locks on the feature class to prevent corruption in the branch version. Calling version.startReading will set a shared lock on the version which prevents another session from obtaining an exclusive lock. Other sessions can still access the version as read-only. Calling version.startEditing will set the exclusive lock which will prevent read access and write access to the version.

Keeping track of where one is within the edit sessions is made simple with a built in context manager.

from arcgis.features import _parcel

parcel_fabric_manager_url = f"{base_server_url}/ParcelFabricServer"

# start a 'read' session to acquire a shared lock and
# get a branch version by its name
with vms.get(fq_version_name, "read") as version:
    parcel_fabric_manager = _parcel.ParcelFabricManager(
        parcel_fabric_manager_url, gis, version, parcel_fabric_flc
    )

    # do parcel fabric or other feature service editing within the version
    # i.e. parcel_fabric_manager.copy_lines_to_parcel_type(...)

parcel_fabric_manager.properties
{
  "name": "Parcel Fabric Server",
  "type": "Map Server Extension",
  "ParcelFabricLayers": 1
}

Recocile, Post and Delete the version

When editing is complete, the new features can be posted from the new branch version to the default version. In this workflow, Reconcile must occur first. Once posted, the version can optionally be deleted.

version = vms.get(fq_version_name)

# version.reconcile()
# version.post

version.delete()
True

API Ref Documentation

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.