HOW TO
In einigen Fällen müssen die Abhängigkeiten zwischen Portal for ArcGIS-Elementen bestimmt werden. Beispielsweise ist es möglich, dass bei einer Datenbereinigung eine Web-App und die damit verknüpfte Webkarte gelöscht werden müssen. Das manuelle Überprüfen dieser Abhängigkeiten kann mühsam sein. Alternativ kann dieser Prozess programmgesteuert mit der Administratorberechtigung und den folgenden ArcGIS API for Python-Funktionen ausgeführt werden: dependent_upon() und dependent_to().
Mit den folgenden Schritten wird beschrieben, wie Abhängigkeiten in Portal for ArcGIS mithilfe von ArcGIS API for Python gesucht werden.
from arcgis.gis import GIS from IPython.display import display
source = GIS("<portalurl>", "<admin_user>", "<admin_password>") source_users = source.users.search(query=None, sort_field='username', sort_order='asc', max_users=100, outside_org=False, exclude_system=True) source_items_by_id = {} print('User list: Role')
for user in source_users: print(user.username + "\t:\t" + str(user.role))
for user in source_users: num_items = 0 num_folders = 0 print("Collecting item ids for {}".format(user.username), end="\n\n") user_content = user.items()
for item in user_content: num_items += 1 source_items_by_id[item.itemid] = item print("\n\n Item: \t {2} \t\t\t id {0} is dependent on these items: \t {1}".format(item.itemid,item.dependent_upon(), item.title)) if (item.dependent_to()['total'] > 0): print("\t This item is also a dependency of these items: {}".format(item.dependent_to()))
folders = user.folders for folder in folders: num_folders += 1 folder_items = user.items(folder=folder['title']) for item in folder_items: num_items += 1 source_items_by_id[item.itemid] = item print("\n\n Item: \t {2} \t\t\t id {0} is dependent on these items: \t {1}".format(item.itemid,item.dependent_upon(), item.title)) if (item.dependent_to()['total'] > 0): print("\t This item is also a dependency of these items: {}".format(item.dependent_to())) print("Number of folders {} # Number of items {} # Number of users {}".format(str(num_folders), str(num_items), len(source_users)))
Nachfolgend finden Sie das vollständige Skript:
from arcgis.gis import GIS from IPython.display import display source = GIS("https://test.domain.com/portal", "portaladmin", "portaladmin") source_users = source.users.search(query=None, sort_field='username', sort_order='asc', max_users=100, outside_org=False, exclude_system=True) source_items_by_id = {} print('User list: Role') for user in source_users: print(user.username + "\t:\t" + str(user.role)) for user in source_users: num_items = 0 num_folders = 0 print("Collecting item ids for {}".format(user.username), end="\n\n") user_content = user.items() for item in user_content: num_items += 1 source_items_by_id[item.itemid] = item print("\n\n Item: \t {2} \t\t\t id {0} is dependent on these items: \t {1}".format(item.itemid,item.dependent_upon(), item.title)) if (item.dependent_to()['total'] > 0): print("\t This item is also a dependency of these items: {}".format(item.dependent_to())) folders = user.folders for folder in folders: num_folders += 1 folder_items = user.items(folder=folder['title']) for item in folder_items: num_items += 1 source_items_by_id[item.itemid] = item print("\n\n Item: \t {2} \t\t\t id {0} is dependent on these items: \t {1}".format(item.itemid,item.dependent_upon(), item.title)) if (item.dependent_to()['total'] > 0): print("\t This item is also a dependency of these items: {}".format(item.dependent_to())) print("Number of folders {} # Number of items {} # Number of users {}".format(str(num_folders), str(num_items), len(source_users)))
Unterstützung durch ArcGIS-Experten anfordern
Esri Support App herunterladen