Select to view content in your preferred language

How do I search a portal for sync enabled webmaps?

582
1
08-17-2020 04:39 AM
OrrinThomas
Emerging Contributor

Part of my application involves searching a portal for a list of portals items.  I would like to list only the webmaps that include a Geodatabase that isSyncEnabled().  The most direct way to do this would be with the PortalQueryParameters.  Limiting the query to just webmaps is straight forward using the constructor that takes a vector of PortalItem.Type as the first parameter.  Is there a way to use the searchQuerry string to limit it to just webmaps that include a sync enabled geodatabase?  Or just to those that support offline use?

If PortalQueryParamters doesn't work, is there a way to check the PortalItems?  I know that I can find out if they support offline use:  OfflineMapTask(PortalItem).getOfflineMapCapabilitiesAsync() ---> getLayerCapabilities() --> isSupportsOffline().  That helps, but offline use doesn't necessarily mean they support sync.

The isSyncEnabled() method appears in two places in the documentation: Geodatabase::isSyncEnabled(), and ArcGISFeatureServiceInfo::isSyncEnabled().  It appears (from the single documented constructor) that a geodatabse can only be constructed from a local file after downloading the geodatabase (impractical).  And ArcGISFeatureServiceInfo has no documented constructors, appears nowhere in the documentation except its own page, and is a final class that extends Object.  So, from what I can tell, developers have no access to it.  Am I missing something here?

0 Kudos
1 Reply
GayleYoung
Esri Contributor

Hi Orrin,

I'm sorry I can't speak to all of your points, however the following snippet may help you you access to `isSyncEnabled`. Bear in mind (and test) the load time of each of the Loadable objects in your environment) and the quantity of WebMaps and ServiceFeatureTables you are searching before you settle on this method. The following is untested:


```

ArcGISMap map = new ArcGISMap(portalItem);

...load map

List<Layer> layers = map.getOperationalLayers();
   

for (Layer layer : layers) {
   

    if (layer instanceof FeatureLayer) {
      if (((FeatureLayer)layer).getFeatureTable() != null) { // assume, may need to load FeatureLayer
        FeatureTable table = ((FeatureLayer)layer).getFeatureTable();
        if (table instanceof ServiceFeatureTable) {
          if (((ServiceFeatureTable)table).getUri() != null) { // assume, should not need to load ServiceFeatureTable
           

            // assume we get "..\FeatureServer\0", then remove "\n" to get "..FeatureServer"
            // if we didn't already look this server up, then look it up now
            if (!fetched(featureServer)) {            

              // Create and load a GeodatabaseSyncTask

             GeodatabaseSyncTask syncTask = new GeodatabaseSyncTask("https://xxxxxxx.FeatureServer");
             ... load

             boolean isSyncEnabled = syncTask.getFeatureServiceInfo().isSyncEnabled();
            }
          }
        }
      }
    }

```

Thanks,

Gayle. 

0 Kudos