An item in a portal. More...
Header: | #include <PortalItem.h> |
Since: | Esri::ArcGISRuntime 100.0 |
Inherits: | Esri::ArcGISRuntime::Item, Esri::ArcGISRuntime::Loadable, and Esri::ArcGISRuntime::JsonSerializable |
This class was introduced in Esri::ArcGISRuntime 100.0.
Public Functions
PortalItem(const QUrl &url, QObject *parent = nullptr) | |
PortalItem(Esri::ArcGISRuntime::Portal *portal, Esri::ArcGISRuntime::PortalItemType portalItemType, QObject *parent = nullptr) | |
PortalItem(Esri::ArcGISRuntime::Portal *portal, const QString &itemId, QObject *parent = nullptr) | |
PortalItem(const QString &itemId, QObject *parent = nullptr) | |
PortalItem(Esri::ArcGISRuntime::Portal *portal, QObject *parent = nullptr) | |
virtual | ~PortalItem() override |
Esri::ArcGISRuntime::PortalAccess | access() const |
void | addComment(const QString &comment) |
void | addRating(float rating) |
Esri::ArcGISRuntime::PortalGroupListModel * | adminGroups() const |
float | averageRating() const |
int | commentCount() const |
Esri::ArcGISRuntime::PortalItemCommentListModel * | comments() const |
QString | culture() const |
void | fetchComments() |
void | fetchGroups() |
QString | folderId() const |
bool | isCommentsEnabled() const |
Esri::ArcGISRuntime::PortalGroupListModel * | memberGroups() const |
Esri::ArcGISRuntime::PortalGroupListModel * | otherGroups() const |
QString | owner() const |
Esri::ArcGISRuntime::Portal * | portal() const |
int | ratingCount() const |
QUrl | serviceUrl() const |
void | shareWith(bool everyone, bool organization) |
void | shareWithGroups(const QStringList &groupIds) |
qint64 | size() const |
Esri::ArcGISRuntime::PortalItemType | type() const |
QString | typeName() const |
void | unshare() |
void | unshareGroups(const QStringList &groupIds) |
void | updateDataWithJson(const QString &json) |
void | updateDataWithUrl(const QUrl &fromUrl, const QString &fileName = QString()) |
QUrl | url() const |
int | viewCount() const |
Reimplemented Public Functions
virtual void | cancelLoad() override |
virtual void | load() override |
virtual Esri::ArcGISRuntime::Error | loadError() const override |
virtual Esri::ArcGISRuntime::LoadStatus | loadStatus() const override |
virtual void | retryLoad() override |
virtual QString | toJson() const override |
virtual QJsonObject | unknownJson() const override |
virtual QJsonObject | unsupportedJson() const override |
Signals
void | addCommentCompleted(bool success) |
void | addRatingCompleted(bool success) |
void | doneLoading(Esri::ArcGISRuntime::Error loadError) |
void | fetchCommentsCompleted(bool success) |
void | fetchDataProgressChanged(const Esri::ArcGISRuntime::NetworkRequestProgress &progress) |
void | fetchGroupsCompleted(bool success) |
void | loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus) |
void | shareWithCompleted(bool success) |
void | shareWithGroupsCompleted(bool success, const QStringList &failedToShareGroupIds) |
void | unshareCompleted(bool success) |
void | unshareGroupsCompleted(bool success, const QStringList &failedToUnshareGroupIds) |
void | updateDataCompleted(bool success, const QString &itemId) |
Static Public Members
Esri::ArcGISRuntime::PortalItem * | fromJson(const QString &json, Esri::ArcGISRuntime::Portal *portal = nullptr, QObject *parent = nullptr) |
Detailed Description
Contains information about an item of content within the portal. Each item has a unique identifier and a well-known URL that is independent of the user owning the item.
A new item can be created using PortalUser::addPortalItemWithJson or PortalUser::addPortalItemWithUrl; or an existing item can be loaded from an online portal using PortalItem::load.
An item may also have associated binary or textual data which can be downloaded separately.
Create a new portal item
To add a new item to a portal, create the PortalItem object passing the portal as a parameter to the constructor, then call PortalUser::addPortalItemWithJson or PortalUser::addPortalItemWithUrl. The portal user must have been created with credentials that provide sufficient privileges to add items to the portal. Before adding an item to the portal, the title and type must be set. If itemId is set, this will be ignored and a new unique ID will be provided when the item is added to the portal and loaded.
PortalItem* portalItem = new PortalItem(portal, parent); portalItem->setTitle("My Item"); portalItem->setType(PortalItemType::WebMap); portalItem->setTags(myTags); portal->portalUser()->addPortalItemWithJson(portalItem, json);
Load existing portal item
To load an existing item from portal, create PortalItem object with valid itemId or url, and call PortalItem::load.
The portal item ID can be used along with a portal URL to quickly instantiate a new portal item object. The ID can be determined from the URL of the item details web page or the map viewer URL (for maps only) in your portal. The item details page has the following format: http://www.arcgis.com/home/item.html?id=[itemId]
. The web map viewer has the following format: http://www.arcgis.com/home/webmap/viewer.html?webmap=[itemId]
. In both cases the [itemId] can be used as the ID to instantiate a portal item.
PortalItem* portalItem = new PortalItem(portal, itemId, parent); connect(portalItem, &PortalItem::doneLoading, this, [portalItem](){ qDebug() << "Item title:" << portalItem->title(); }); portalItem->load();
Retrieve an existing portal item
Alternatively, you can search for and load existing items in the portal using Portal::findItems or PortalUser::items. If you know the specific ID of the item you wish to retrieve, you can construct the portalItem by passing both the portal and the ID to its constructor and calling PortalItem::load to retrieve the details.
See also Layer::item, GeoModel::item, and Basemap::item.
Member Function Documentation
PortalItem::PortalItem (const QUrl &url, QObject *parent = nullptr)
Creates a portal item object.
- url - The URL to the portal item.
- parent - The optional parent QObject.
Use this object to create a portal item from a URL. The supported URL formats are:
- The REST Sharing API URL of the portal item (with or without the query parameter f=json). Example: https://www.arcgis.com/sharing/rest/content/items/c6a2c53ead68432586cc9ac9ec366055?f=json
- The REST Sharing API URL of the portal item data. Example: https://www.arcgis.com/sharing/rest/content/items/c6a2c53ead68432586cc9ac9ec366055/data
- The URL of the portal item details web page. Example: https://www.arcgis.com/home/item.html?id=c6a2c53ead68432586cc9ac9ec366055
- The URL of a webmap opened in the portal's map viewer web application (classic or new). Example: https://www.arcgis.com/home/webmap/viewer.html?webmap=8bf7167d20924cbf8e25e7b11c7c502c or https://www.arcgis.com/apps/mapviewer/index.html?webmap=8bf7167d20924cbf8e25e7b11c7c502c
- The URL of a webscene opened in the portal's scene viewer web application. Example: https://www.arcgis.com/home/webscene/viewer.html?webscene=74ec7d6ca482442ba24f80b708aec67e
PortalItem::PortalItem (Esri::ArcGISRuntime::Portal *portal, Esri::ArcGISRuntime::PortalItemType portalItemType , QObject *parent = nullptr)
Constructor that accepts a portal, a portal item type (portalItemType) and an optional parent.
This function was introduced in Esri::ArcGISRuntime 100.6.
PortalItem::PortalItem (Esri::ArcGISRuntime::Portal *portal, const QString &itemId , QObject *parent = nullptr)
Creates a portal item object for a specified portal and a specified item ID.
- portal - The portal.
- itemId - The item ID.
- parent - The optional parent QObject.
Use this constructor to instantiate a PortalItem from an existing item using its unique ID.
The portal item ID can be determined from the URL of the item details web page or the map viewer and scene viewer web applications in your portal. The item details page has the following format https://www.arcgis.com/home/item.html?id=[item_id]. The map viewer has the format https://www.arcgis.com/home/webmap/viewer.html?webmap=[item_id] or https://www.arcgis.com/apps/mapviewer/index.html?webmap=[item_id], depending on whether you use the classic map viewer or the new map viewer. The scene viewer has the following format https://www.arcgis.com/home/webscene/viewer.html?webscene=[item_id]. In all cases, the [item_id] can be used as the ID to instantiate a portal item.
See also portal and Item::itemId.
PortalItem::PortalItem (const QString &itemId , QObject *parent = nullptr)
Constructor that accepts an item ID (itemId) and an optional parent.
Use this constructor you wish to fetch a particular item from a portal. Call load on the resultant object to fetch the metadata for this item. Note that most of the getter methods will return nullptr
, 0
or an empty QString until the load operation is complete.
A portal item's ID can be obtained using the itemId method. The ID can also be determined from the URL of the item details web page or the map viewer URL (for maps only) in your portal. The item details page has the following format: http://www.arcgis.com/home/item.html?id=[itemId]
. The web map viewer has the following format: http://www.arcgis.com/home/webmap/viewer.html?webmap=[itemId]
. In both cases the [itemId] can be used as the ID to instantiate a portal item.
This constructor uses a default portal to https://www.arcgis.com.
PortalItem::PortalItem (Esri::ArcGISRuntime::Portal *portal, QObject *parent = nullptr)
Constructor that accepts a portal and an optional parent.
[signal]
void PortalItem::addCommentCompleted (bool success)
Signal emitted when the asynchronous addComment operation is complete.
- success - Whether adding comment completed successfully.
This function was introduced in Esri::ArcGISRuntime 100.1.
[signal]
void PortalItem::addRatingCompleted (bool success)
Signal emitted when the asynchronous addRating operation is complete.
- success - Whether adding rating completed successfully.
This function was introduced in Esri::ArcGISRuntime 100.1.
[signal]
void PortalItem::doneLoading (Esri::ArcGISRuntime::Error loadError )
Signal emitted when this object is done loading.
- loadError - Details about any error that may have occurred.
Note: If there is a load error it will also be emitted on the errorOccurred
signal.
[signal]
void PortalItem::fetchCommentsCompleted (bool success)
Signal emitted when the asynchronous fetchComments operation is complete.
- success - Whether fetching comments completed successfully.
This function was introduced in Esri::ArcGISRuntime 100.1.
[signal]
void PortalItem::fetchDataProgressChanged (const Esri::ArcGISRuntime::NetworkRequestProgress &progress)
Signal emitted periodically to report fetch data progress.
Information about the fetch data progress is returned in progress.
[signal]
void PortalItem::fetchGroupsCompleted (bool success)
Signal emitted when the asynchronous fetchGroups operation is complete.
- success - Whether fetching groups completed successfully.
This function was introduced in Esri::ArcGISRuntime 100.1.
[signal]
void PortalItem::loadStatusChanged (Esri::ArcGISRuntime::LoadStatus loadStatus )
Signal emitted when the loadStatus changes for this object.
See also Loadable.
[signal]
void PortalItem::shareWithCompleted (bool success)
Signal emitted when the asynchronous shareWith method completes.
The parameter success is true
when the operation succeeded, otherwise false
.
[signal]
void PortalItem::shareWithGroupsCompleted (bool success, const QStringList &failedToShareGroupIds )
Signal emitted when the asynchronous shareWithGroups method completes.
The parameter success is true
when the operation succeeded, otherwise false
. The parameter failedToShareGroupIds is the list of groups the item could not be shared with.
This function was introduced in Esri::ArcGISRuntime 100.1.
[signal]
void PortalItem::unshareCompleted (bool success)
Signal emitted when the asynchronous unshare method completes.
The parameter success is true
when the operation succeeded, otherwise false
.
[signal]
void PortalItem::unshareGroupsCompleted (bool success, const QStringList &failedToUnshareGroupIds )
Signal emitted when the asynchronous unshareGroups method completes.
The parameter success is true
when the operation succeeded, otherwise false
. The parameter failedToUnshareGroupIds is the list of groups the item could not be unshared with.
This function was introduced in Esri::ArcGISRuntime 100.1.
[signal]
void PortalItem::updateDataCompleted (bool success, const QString &itemId )
Signal emitted when the asynchronous updateDataWithJson or updateDataWithUrl method completes.
success Whether the update was successful. itemId The item ID of the PortalItem that was updated.
This function was introduced in Esri::ArcGISRuntime 100.1.
[override virtual]
PortalItem::~PortalItem ()
Destructor.
Esri::ArcGISRuntime::PortalAccess PortalItem::access() const
Returns the level of access to this item.
void PortalItem::addComment (const QString &comment)
Adds a comment to the PortalItem.
The addCommentCompleted signal will emit after the operation is complete.
void PortalItem::addRating (float rating)
Adds a rating to the PortalItem.
The addRatingCompleted signal will emit after the operation is complete.
rating must be a floating point number between 1.0 and 5.0.
Esri::ArcGISRuntime::PortalGroupListModel *PortalItem::adminGroups () const
Returns a list of groups that the item is in and for which the current portal user is an administrator.
To access these groups, call fetchGroups, and wait for the fetchGroupsCompleted signal to emit or an errorOccurred if unsuccessful.
float PortalItem::averageRating () const
Returns the average rating.
Uses a weighted average called "Bayesian average."
[override virtual]
void PortalItem::cancelLoad ()
Reimplements: Loadable::cancelLoad().
See Loadable.
int PortalItem::commentCount () const
Returns the number of comments for this item.
Esri::ArcGISRuntime::PortalItemCommentListModel *PortalItem::comments() const
Returns a list of comments about this item.
QString PortalItem::culture() const
Returns the item locale information (language and country).
void PortalItem::fetchComments ()
Starts an asynchronous task to fetch comments.
The fetchCommentsCompleted signal will emit after the operation is complete.
Example: Fetch the comments model for an item:
int totalCommentsCount = 0; connect(portalItem, &PortalItem::fetchCommentsCompleted, [portalItem, &totalCommentsCount](bool success) { if (!success) return; PortalItemCommentListModel* commentsModel = portalItem->comments(); if (!commentsModel) return; totalCommentsCount = commentsModel->size(); }); portalItem->fetchComments();
void PortalItem::fetchGroups ()
Starts an asynchronous task to fetch groups.
The fetchGroupsCompleted signal will emit after the operation is complete.
QString PortalItem::folderId () const
Returns the ID of the folder containing this item.
[static]
Esri::ArcGISRuntime::PortalItem *PortalItem::fromJson (const QString &json, Esri::ArcGISRuntime::Portal *portal = nullptr, QObject *parent = nullptr)
Creates a new PortalItem from json with an optional portal and parent.
If the portal is not specified, then the default Portal will be used (ArcGIS Online).
See also JsonSerializable.
bool PortalItem::isCommentsEnabled () const
Returns whether comments are allowed on the item.
[override virtual]
void PortalItem::load()
Reimplements: Loadable::load().
See Loadable.
[override virtual]
Esri::ArcGISRuntime::Error PortalItem::loadError () const
Reimplements: Loadable::loadError() const.
See Loadable.
[override virtual]
Esri::ArcGISRuntime::LoadStatus PortalItem::loadStatus () const
Reimplements: Loadable::loadStatus() const.
See Loadable.
Esri::ArcGISRuntime::PortalGroupListModel *PortalItem::memberGroups () const
Returns a list of groups that the item is in and for which the current portal user is a member (read-only).
To access these comments, call fetchGroups, and wait for the fetchGroupsCompleted signal to emit or an errorOccurred if unsuccessful.
Esri::ArcGISRuntime::PortalGroupListModel *PortalItem::otherGroups () const
Returns a list of groups that the item is in that are public or shared to the user's organization, but that the current portal user is not a member of (read-only).
To access these comments, call fetchGroups, and wait for the fetchGroupsCompleted signal to emit or an errorOccurred if unsuccessful.
QString PortalItem::owner() const
Returns the username of the user who owns this item.
Esri::ArcGISRuntime::Portal *PortalItem::portal() const
Returns the portal associated with this item.
int PortalItem::ratingCount () const
Returns the number of ratings received by this item.
[override virtual]
void PortalItem::retryLoad ()
Reimplements: Loadable::retryLoad().
See Loadable.
QUrl PortalItem::serviceUrl () const
Returns the service URL for this item.
void PortalItem::shareWith (bool everyone, bool organization)
Shares a PortalItem with everyone and/or the organization the item belongs to.
void PortalItem::shareWithGroups (const QStringList &groupIds )
Shares a PortalItem with the specified list of groupIds.
qint64 PortalItem::size() const
Returns the size of the item in bytes.
[override virtual]
QString PortalItem::toJson () const
Reimplements: JsonSerializable::toJson() const.
Returns the JSON representation of this object.
See also JsonSerializable.
Esri::ArcGISRuntime::PortalItemType PortalItem::type() const
Returns the item's type.
See also setType().
QString PortalItem::typeName () const
Returns the name of the type of this item.
[override virtual]
QJsonObject PortalItem::unknownJson () const
Reimplements: JsonSerializable::unknownJson() const.
Returns the unknown JSON of this object.
See also JsonSerializable.
void PortalItem::unshare()
Unshares the PortalItem with everyone.
void PortalItem::unshareGroups (const QStringList &groupIds )
Unshares a PortalItem with the specified list of groupIds.
[override virtual]
QJsonObject PortalItem::unsupportedJson () const
Reimplements: JsonSerializable::unsupportedJson() const.
Returns the unsupported JSON of this object.
See also JsonSerializable.
void PortalItem::updateDataWithJson (const QString &json)
Starts an asynchronous task to update the remote PortalItem with the provided json.
The portalItem will be updated using the following arguments:
- json. A string representation of the JSON to use when updating the item.
The updateDataCompleted signal will emit after the operation is complete.
This function was introduced in Esri::ArcGISRuntime 100.1.
void PortalItem::updateDataWithUrl (const QUrl &fromUrl , const QString &fileName = QString())
Starts an asynchronous task to update the remote PortalItem from a local or online url.
The portalItem will be updated using the following arguments:
- fromUrl. The local or online URL from which the portalItem will be populated. For local files, this should be of the form
"qrc:/example.csv"
or "file://"; for online resources this should be of the form"https://..."
. - fileName (optional). The name of the file which will be associated with the PortalItem (including extension). If a file name is not supplied, the portal item will have no file associated with it for future downloads.
Note: A file name is only relevant for certain item types such as PortalItemType.Image.
The updateDataCompleted signal will emit after the operation is complete.
This function was introduced in Esri::ArcGISRuntime 100.1.
See also Items and item types.
QUrl PortalItem::url() const
Returns the URL for the resource represented by the item.
int PortalItem::viewCount () const
Returns the number of times this item has been viewed.