SetSchemaRequest

public final class SetSchemaRequest extends Object

Encapsulates a request to update the schema of an AppSearchClient database.

The schema is composed of a collection of AppSearchSchema objects, each of which defines a unique type of data.

The first call to SetSchemaRequest will set the provided schema and store it within the AppSearchClient database.

Subsequent calls will compare the provided schema to the previously saved schema, to determine how to treat existing documents.

The following types of schema modifications are always safe and are made without deleting any existing documents:

  • Addition of new AppSearchSchema types
  • Addition of new properties to an existing AppSearchSchema type
  • Changing the cardinality of a property to be less restrictive

The following types of schema changes are not backwards compatible:

  • Removal of an existing AppSearchSchema type
  • Removal of a property from an existing AppSearchSchema type
  • Changing the data type of an existing property
  • Changing the cardinality of a property to be more restrictive

Providing a schema with incompatible changes, will throw an AppSearchException, with a message describing the incompatibility. As a result, the previously set schema will remain unchanged.

Backward incompatible changes can be made by :

Nested Class Summary

class SetSchemaRequest.Builder Builder for SetSchemaRequest objects. 

Constant Summary

int READ_ASSISTANT_APP_SEARCH_DATA The Manifest.permission.READ_ASSISTANT_APP_SEARCH_DATA AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)
int READ_CALENDAR The Manifest.permission.READ_CALENDAR AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)
int READ_CONTACTS The Manifest.permission.READ_CONTACTS AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)
int READ_EXTERNAL_STORAGE The Manifest.permission.READ_EXTERNAL_STORAGE AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)
int READ_HOME_APP_SEARCH_DATA The Manifest.permission.READ_HOME_APP_SEARCH_DATA AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)
int READ_SMS The Manifest.permission.READ_SMS AppSearch supported in SetSchemaRequest.Builder.addRequiredPermissionsForSchemaTypeVisibility(String, Set)

Public Method Summary

Map<StringMigrator>
getMigrators()
Returns the map of Migrator, the key will be the schema type of the Migrator associated with.
Map<StringPackageIdentifier>
getPubliclyVisibleSchemas()
Returns a mapping of publicly visible schemas to the PackageIdentifier specifying the package the schemas are from.
Map<StringSet<Set<Integer>>>
getRequiredPermissionsForSchemaTypeVisibility()
Returns a mapping of schema types to the Map of Manifest.permission combinations that querier must hold to access that schema type.
Set<AppSearchSchema>
getSchemas()
Returns the AppSearchSchema types that are part of this request.
Set<String>
getSchemasNotDisplayedBySystem()
Returns all the schema types that are opted out of being displayed and visible on any system UI surface.
Map<StringSet<SchemaVisibilityConfig>>
getSchemasVisibleToConfigs()
Returns a mapping of schema types to the set of SchemaVisibilityConfig that have access to that schema type.
Map<StringSet<PackageIdentifier>>
getSchemasVisibleToPackages()
Returns a mapping of schema types to the set of packages that have access to that schema type.
int
getVersion()
Returns the database overall schema version.
boolean
isForceOverride()
Returns whether this request will force the schema to be overridden.

Inherited Method Summary

Constants

public static final int READ_ASSISTANT_APP_SEARCH_DATA

public static final int READ_CALENDAR

public static final int READ_CONTACTS

public static final int READ_EXTERNAL_STORAGE

public static final int READ_HOME_APP_SEARCH_DATA

public static final int READ_SMS

Public Methods

public Map<StringMigrator> getMigrators ()

Returns the map of Migrator, the key will be the schema type of the Migrator associated with.

public Map<StringPackageIdentifier> getPubliclyVisibleSchemas ()

Returns a mapping of publicly visible schemas to the PackageIdentifier specifying the package the schemas are from.

public Map<StringSet<Set<Integer>>> getRequiredPermissionsForSchemaTypeVisibility ()

Returns a mapping of schema types to the Map of Manifest.permission combinations that querier must hold to access that schema type.

The querier could read the GenericDocument objects under the schemaType if they holds ALL required permissions of ANY of the individual value sets.

For example, if the Map contains {{permissionA, PermissionB}, {PermissionC, PermissionD}, {PermissionE}}.

  • A querier holds both PermissionA and PermissionB has access.
  • A querier holds both PermissionC and PermissionD has access.
  • A querier holds only PermissionE has access.
  • A querier holds both PermissionA and PermissionE has access.
  • A querier holds only PermissionA doesn't have access.
  • A querier holds both PermissionA and PermissionC doesn't have access.

It’s inefficient to call this method repeatedly.

Returns

public Set<AppSearchSchema> getSchemas ()

Returns the AppSearchSchema types that are part of this request.

public Set<String> getSchemasNotDisplayedBySystem ()

Returns all the schema types that are opted out of being displayed and visible on any system UI surface.

public Map<StringSet<SchemaVisibilityConfig>> getSchemasVisibleToConfigs ()

Returns a mapping of schema types to the set of SchemaVisibilityConfig that have access to that schema type.

It’s inefficient to call this method repeatedly.

public Map<StringSet<PackageIdentifier>> getSchemasVisibleToPackages ()

Returns a mapping of schema types to the set of packages that have access to that schema type.

It’s inefficient to call this method repeatedly.

public int getVersion ()

Returns the database overall schema version.

public boolean isForceOverride ()

Returns whether this request will force the schema to be overridden.