You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A clear and concise description of what the bug is.
Extract_Changes should return features of adds, updates, and deletes when the appropriate boolean parameter is set for edit type. If all parameters are set to true should return all. When a single serverGen number is used should return the appropriate edit type for all changes up until that server generation. When using a list range should return changes between server Gens. Adds and updates seem to return properly but updates do not.
Tested using various servergen parameters [minServerGen],[serverGen],[minServerGen,serverGen] and the latest layers Server Gens. Furthermore, serverGens were periodically polled to receive the latest after edits were made to test layers.
To Reproduce
Steps to reproduce the behavior:
Create a new feature layer collection of point and table layers, with sync and change tracking enabled. Add a new string field 'Name' to both.
check feature layer collection to make sure extract_changes can be conducted.
return latest server gens.
Examine Extract_Changes for various parameters, all payloads should be empty since they're are no features in point layer or table.
Add features to layers and table.
Return latest server gens and extract changes. SHOULD ONLY SEE ADDS
Create new features and update previous features. Return latest server gens and extract changes. SHOULD ONLY SEE ADDS AND UPDATES.
Finally, delete all features.
Return latest server gens and extract changes. SHOULD SEE ADDS, UPDATES, and DELETES.
importarcgisfromarcgis.gisimportGISgis=GIS("home")
pipinstallpyprojfromarcgis.featuresimportFeatureLayerCollection, GeoAccessor, GeoSeriesAccessor, FeatureLayer, FeatureSet, Featurefromarcgis.geometryimportGeometry, Point, Polyline, Polygon, MultiPoint, projectfromrandomimportuniform, randrangeimportinspectfrompyprojimportTransformerimporttimeextract_changes_test_item=gis.content.get('cc1c210c14ba4525a2f97e141070f02d')
transformer=Transformer.from_crs("epsg:4326", "epsg:3857", always_xy=True)
defprint_feature_sets(flc):
forlyrinflc.layers+flc.tables:
fs=lyr.query()
print(fs)
defcheck_for_changes(payload):
no_changes=Trueforeditinpayload['edits']:
if'id'inedit.keys():
layer_id=edit['id']
if'features'inedit.keys():
adds,updates,deletes=[],[],[]
features=edit['features']
if'adds'infeatures.keys():
adds=features['adds']
if'updates'infeatures.keys():
updates=features['updates']
if'deletes'infeatures.keys():
deletes=features['deletes']
ifaddsorupdatesordeletes:
no_changes=Falseprint(f"Changes detected in layer {layer_id}:")
ifadds:
print(f" Adds: {len(adds)}")
ifupdates:
print(f" Updates: {len(updates)}")
ifdeletes:
print(f" Deletes: {len(deletes)}")
ifno_changes:
print("No changes detected across all layers.")
defreturn_current_flc_properties(flc):
capabilities=flc.properties.capabilitiesprint(f"Current capabilities are: {capabilities}")
extractCapabilities=flc.properties.get("extractChangesCapabilities","no support")
print(f"Current extract changes capabilities: {extractCapabilities}")
ServerGens= []
SRs= []
changeTrackingInfo=flc.properties.changeTrackingInfolayerServerGens=changeTrackingInfo['layerServerGens']
layer_ids= []
forlyrinflc.layers+flc.tables:
layer_ids.append(lyr.properties.id)
if'geometryType'inlyr.properties:
print(f"ID: {lyr.properties.id} NAME: {lyr.properties.name} Type: {lyr.properties.type} GeoType: {lyr.properties.geometryType} Record Count: {lyr.query(where='1=1', return_count_only=True)}")
SRs.append(lyr.properties.extent.spatialReference)
else:
print(f"ID: {lyr.properties.id} NAME: {lyr.properties.name} Type: {lyr.properties.type} GeoType: None Record Count: {lyr.query(where='1=1', return_count_only=True)}")
ServerGens.append(lyr.properties.serverGens)
foridx,SGinenumerate(ServerGens):
id_mismatch,minServerGen_mismatch,serverGen_mismatch=False,False,FalselyrSG=layerServerGens[idx]
ifidx!=lyrSG['id']:
id_mismatch=TrueifSG['minServerGen'] !=lyrSG['minServerGen']:
minServerGen_mismatch=TrueifSG['serverGen'] !=lyrSG['serverGen']:
serverGen_mismatch=Trueifid_mismatchorminServerGen_mismatchorserverGen_mismatch:
print(f"Mismatch detected at idx {idx} for {SG} and {lyrSG}")
print(f"ServerGens: {ServerGens}")
print(f"layerServerGens: {layerServerGens}")
returnServerGens,layerServerGens,layer_idsdefcheck_extract_changes_by_diff_servergens(flc,ServerGens,layer_ids):
# check using different servergen parametersminServerGen=ServerGens[0]['minServerGen']
serverGen=ServerGens[0]['serverGen']
serverGen_options= [[minServerGen],[serverGen],[minServerGen,serverGen]]
foroptioninserverGen_options:
print(f"servergen={option}\n\n")
try:
print("If changes should be adds only")
insert_only=flc.extract_changes(layers=layer_ids,servergen=option,layer_servergen=None,return_inserts=True,return_updates=False,return_deletes=False,return_attachments=False,return_geometry_updates=False)
check_for_changes(insert_only)
print("\nIf changes should be updates only")
updates_only=flc.extract_changes(layers=layer_ids,servergen=option,layer_servergen=None,return_inserts=False,return_updates=True,return_deletes=False,return_attachments=False,return_geometry_updates=False)
check_for_changes(updates_only)
print("\nIf changes should be deletes only")
deletes_only=flc.extract_changes(layers=layer_ids,servergen=option,layer_servergen=None,return_inserts=False,return_updates=False,return_deletes=True,return_attachments=False,return_geometry_updates=False)
check_for_changes(deletes_only)
print("\nIf changes should RETURN ALL CHANGES")
all_only=flc.extract_changes(layers=layer_ids,servergen=option,layer_servergen=None,return_inserts=True,return_updates=True,return_deletes=True,return_attachments=True,return_geometry_updates=True)
check_for_changes(all_only)
exceptExceptionase:
print(e)
defcheck_extract_changes_by_layer_servergen(flc,layerServerGens,layer_ids):
# Check using layer_servergen parameterprint(f"layer_servergen={layerServerGens}\n\n")
try:
print("If changes should be adds only")
insert_only=flc.extract_changes(layers=layer_ids,servergen=None,layer_servergen=layerServerGens,return_inserts=True,return_updates=False,return_deletes=False,return_attachments=False,return_geometry_updates=False)
check_for_changes(insert_only)
print("\nIf changes should be updates only")
updates_only=flc.extract_changes(layers=layer_ids,servergen=None,layer_servergen=layerServerGens,return_inserts=False,return_updates=True,return_deletes=False,return_attachments=False,return_geometry_updates=False)
check_for_changes(updates_only)
print("\nIf changes should be deletes only")
deletes_only=flc.extract_changes(layers=layer_ids,servergen=None,layer_servergen=layerServerGens,return_inserts=False,return_updates=False,return_deletes=True,return_attachments=False,return_geometry_updates=False)
check_for_changes(deletes_only)
print("\nIf changes should RETURN ALL CHANGES")
all_only=flc.extract_changes(layers=layer_ids,servergen=None,layer_servergen=layerServerGens,return_inserts=True,return_updates=True,return_deletes=True,return_attachments=True,return_geometry_updates=True)
check_for_changes(all_only)
exceptExceptionase:
print(e)
defgen_random_coord():
# Generate random longitude and latitudelongitude=round(uniform(-120, -119), 2)
latitude=round(uniform(30, 31), 2)
# Transform the coordinates from WGS 84 to Web Mercatorx_3857, y_3857=transformer.transform(longitude, latitude)
returnx_3857, y_3857defcreate_point():
x, y=gen_random_coord()
# Create a point geometrypt=Point({
"x": x,
"y": y,
"spatialReference": {"wkid": 3857}
})
ifpt.is_valid():
returnGeometry(pt)
defcreate_adds(flc):
# Add Features to each layer and tableforlyrinflc.layers+flc.tables:
fields=lyr.properties.fieldsfeatures= []
attributes= {'Name': 'ADD'}
foriinrange(5):
if'geometryType'inlyr.properties:
iflyr.properties.geometryType=='esriGeometryPoint':
geom=create_point()
ifgeom:
feature=Feature(geometry=geom, attributes=attributes)
features.append(feature)
else:
feature=Feature(attributes=attributes)
features.append(feature)
iffeatures:
feature_set=FeatureSet(features=features,fields=fields)
iffeature_set:
add_result=lyr.edit_features(adds=feature_set)
print("Add Results:", add_result)
defcreate_updates(flc):
# Update Features by changing 'Name' from 'ADD' to 'UPDATE'forlyrinflc.layers+flc.tables:
fs=lyr.query()
forfeatureinfs.features:
feature.set_value(field_name='Name',value='UPDATE')
iffs:
update_result=lyr.edit_features(updates=fs,use_global_ids=True)
print("Update Results:", update_result)
defcreate_deletes(flc):
forlyrinflc.layers+flc.tables:
fs=lyr.query()
iffs:
delete_results=lyr.edit_features(deletes=fs)
print("Delete Results:", delete_results)
flc=FeatureLayerCollection.fromitem(extract_changes_test_item)
print_feature_sets(flc)
ServerGens,layerServerGens,layer_ids=return_current_flc_properties(flc)
check_extract_changes_by_diff_servergens(flc,ServerGens,layer_ids)
check_extract_changes_by_layer_servergen(flc,layerServerGens,layer_ids)
print("################################################################################################################################")
create_adds(flc)
print_feature_sets(flc)
time.sleep(60)
print("Should see Adds ONLY")
ServerGens,layerServerGens,layer_ids=return_current_flc_properties(flc)
check_extract_changes_by_diff_servergens(flc,ServerGens,layer_ids)
check_extract_changes_by_layer_servergen(flc,layerServerGens,layer_ids)
print("################################################################################################################################")
create_updates(flc)
create_adds(flc)
print_feature_sets(flc)
print("Should see Adds ONLY for inserts Only, should see UPDATES only for updates only, should see BOTH with all")
time.sleep(60)
ServerGens,layerServerGens,layer_ids=return_current_flc_properties(flc)
check_extract_changes_by_diff_servergens(flc,ServerGens,layer_ids)
check_extract_changes_by_layer_servergen(flc,layerServerGens,layer_ids)
error:
<copythefullerrormessagehere>
Screenshots
Expected behavior
when updates are applied to layers or tables Extract_changes method is not detecting or returning them.
Platform (please complete the following information):
OS: Windows 11
Browser chrome
Python API Version 2.2.0.1 Additional context
Add any other context about the problem here, attachments etc.
The text was updated successfully, but these errors were encountered:
some other weird phenomenon it looks as though updates are getting blended in with adds. when using first getting the latest servergen parameter using the latest values using:
@nanaeaubry I'm using AGOL with a standard Notebook. That being said I'm seeing the same issues with connecting to data with our 11.1 Enterprise Portal environments.
Describe the bug
A clear and concise description of what the bug is.
Extract_Changes should return features of adds, updates, and deletes when the appropriate boolean parameter is set for edit type. If all parameters are set to true should return all. When a single serverGen number is used should return the appropriate edit type for all changes up until that server generation. When using a list range should return changes between server Gens. Adds and updates seem to return properly but updates do not.
Tested using various servergen parameters [minServerGen],[serverGen],[minServerGen,serverGen] and the latest layers Server Gens. Furthermore, serverGens were periodically polled to receive the latest after edits were made to test layers.
To Reproduce
Steps to reproduce the behavior:
Create a new feature layer collection of point and table layers, with sync and change tracking enabled. Add a new string field 'Name' to both.
check feature layer collection to make sure extract_changes can be conducted.
return latest server gens.
Examine Extract_Changes for various parameters, all payloads should be empty since they're are no features in point layer or table.
Add features to layers and table.
Return latest server gens and extract changes. SHOULD ONLY SEE ADDS
Create new features and update previous features. Return latest server gens and extract changes. SHOULD ONLY SEE ADDS AND UPDATES.
Finally, delete all features.
Return latest server gens and extract changes. SHOULD SEE ADDS, UPDATES, and DELETES.
error:
Screenshots
Expected behavior
when updates are applied to layers or tables Extract_changes method is not detecting or returning them.
Platform (please complete the following information):
Additional context
Add any other context about the problem here, attachments etc.
The text was updated successfully, but these errors were encountered: