Class CustomEntityService

java.lang.Object
com.bitheads.braincloud.services.CustomEntityService

public class CustomEntityService
extends Object
  • Constructor Details

  • Method Details

    • createEntity

      public void createEntity​(String entityType, String dataJson, String acl, long timeToLive, Boolean isOwned, IServerCallback callback)
      Method creates a new entity on the server.
      Parameters:
      entityType - The entity type as defined by the user
      dataJson - The entity's data as a json String
      acl - The entity's access control list as json. A null acl implies default permissions which make the entity readable/writeable by only the player.
      timeToLive - The duration of time, in milliseconds, the custom entity should live before being expired. 0 indicates never expires.
      isOwned - Boolean to indicate whether the current user should be recorded as the owner of the object. If owned, the object will be automatically deleted if/when the user is deleted.
      callback - Callback.
    • deleteEntity

      public void deleteEntity​(String entityType, String entityId, int version, IServerCallback callback)
      Deletes the specified custom entity on the server, enforcing ownership/ACL permissions.
      Parameters:
      entityType - The entity type as defined by the user
      entityId - The id of the entity to delete
      version - The version of the entity to delete. Use -1 to indicate the newest version
      callback - Callback.
    • getCount

      public void getCount​(String entityType, String whereJson, IServerCallback callback)
      Counts the number of custom entities meeting the specified where clause, enforcing ownership/ACL permissions.
      Parameters:
      entityType - The entity type as defined by the user
      whereJson - The where clause, as JSON object.
      callback - Callback.
    • getRandomEntitiesMatching

      public void getRandomEntitiesMatching​(String entityType, String whereJson, int maxReturn, IServerCallback callback)
      Gets a list of up to maxReturn randomly selected custom entities from the server based on the entity type and where condition.
      Parameters:
      entityType - The entity type as defined by the user
      whereJson - mongo style query string
      maxReturn - max number of returns
      callback - Callback.
    • getPage

      @Deprecated public void getPage​(String entityType, int rowsPerPage, String searchJson, String sortJson, Boolean doCount, IServerCallback callback)
      Deprecated.
      Use getEntityPage instead - removal after October 26 2021
      Retrieves first page of custom entities from the server based on the custom entity type and specified query context, enforcing ownership/ACL permissions.
      Parameters:
      entityType - The entity type as defined by the user
      rowsPerPage - Quantity of rows per page
      searchJson - Data to look for
      sortJson - Data to sort by
      doCount - For collections with more than 1,000 records, it is recommended that doCount be set to false for better performance.
      callback - Callback.
    • getEntityPage

      public void getEntityPage​(String entityType, String context, IServerCallback callback)
      Retrieves first page of custom entities from the server based on the custom entity type and specified query context, enforcing ownership/ACL permissions.
      Parameters:
      entityType - The entity type as defined by the user
      context - A context object describing the desired paging behaviour
      callback - Callback.
    • getPageOffset

      @Deprecated public void getPageOffset​(String entityType, String context, int pageOffset, IServerCallback callback)
      Deprecated.
      Use getEntityPageOffset instead - removal after October 26 2021
      Gets the page of custom entities from the server based on the encoded context and specified page offset, enforcing ownership/ACL permissions.
      Parameters:
      entityType - The entity type as defined by the user
      context - The context string returned from the server from a previous call to GetPage or GetPageOffse
      pageOffset - The positive or negative page offset to fetch. Uses the last page retrieved using the context string to determine a starting point.
      callback - Callback.
    • getEntityPageOffset

      public void getEntityPageOffset​(String entityType, String context, int pageOffset, IServerCallback callback)
      Gets the page of custom entities from the server based on the encoded context and specified page offset, enforcing ownership/ACL permissions.
      Parameters:
      entityType - The entity type as defined by the user
      context - The context string returned from the server from a previous call to GetPage or GetPageOffset.
      pageOffset - The positive or negative page offset to fetch. Uses the last page retrieved using the context string to determine a starting point.
      callback - Callback.
    • readEntity

      public void readEntity​(String entityType, String entityId, IServerCallback callback)
      Reads a custom entity, enforcing ownership/ACL permissions.
      Parameters:
      entityType - The entity type as defined by the user
      entityId - The id of custom entity being read.
      callback - Callback.
    • updateEntity

      public void updateEntity​(String entityType, String entityId, int version, String dataJson, String acl, long timeToLive, IServerCallback callback)
      Replaces the specified custom entity's data, and optionally updates the acl and expiry, on the server, enforcing current ownership/ACL permissions.
      Parameters:
      entityType - The entity type as defined by the user
      entityId - The id of custom entity being updated.
      version - Version of the custom entity being updated.
      dataJson - New custom data, as JSON, to replace existing custom data.
      acl - New access control list settings to replace existing acl. Optional, ignored if null.
      timeToLive - The duration of time, in milliseconds, the custom entity should live from now before being expired. Null indicates never expires. To indicate no change, use -1.
      callback - Callback.
    • updateEntityFields

      public void updateEntityFields​(String entityType, String entityId, int version, String fieldsJson, IServerCallback callback)
      Replaces the specified custom entity's data, and optionally updates the acl and expiry, on the server, enforcing current ownership/ACL permissions.
      Parameters:
      entityType - The entity type as defined by the user
      entityId - The id of custom entity being updated.
      version - Version of the custom entity being updated.
      fieldsJson - Specific fields, as JSON, to set within entity's custom data.
      callback - Callback.
    • updateEntityFieldsSharded

      public void updateEntityFieldsSharded​(String entityType, String entityId, int version, String fieldsJson, String shardKeyJson, IServerCallback callback)
      Replaces the specified custom entity's data, and optionally updates the acl and expiry, on the server, enforcing current ownership/ACL permissions.
      Parameters:
      entityType - The entity type as defined by the user
      entityId - The id of custom entity being updated.
      version - Version of the custom entity being updated.
      fieldsJson - Specific fields, as JSON, to set within entity's custom data.
      shardKeyJson - The shard key field(s) and value(s), as JSON, applicable to the entity being updated.
      callback - Callback.
    • deleteEntities

      public void deleteEntities​(String entityType, String deleteCriteria, IServerCallback callback)
      deletes Entities based on the criteria
      Parameters:
      entityType - The entity type as defined by the user
      deleteCriteria - The delete criteria to be applied.
      callback - Callback.
    • deleteSingleton

      public void deleteSingleton​(String entityType, int version, IServerCallback callback)
      Deletes the specified custom entity singleton, owned by the session's user, for the specified entity type, on the server.
      Parameters:
      entityType - The entity type as defined by the user
      version - Version of the custom entity singleton being deleted.
      callback - Callback.
    • updateSingleton

      public void updateSingleton​(String entityType, int version, String dataJson, String acl, long timeToLive, IServerCallback callback)
      Updates the singleton owned by the user for the specified custom entity type on the server, creating the singleton if it does not exist. This operation results in the owned singleton's data being completely replaced by the passed in JSON object.
      Parameters:
      entityType - The entity type as defined by the user
      version - Version of the custom entity singleton being updated.
      dataJson - The singleton entity's custom field data, as JSON.
      acl - The singleton entity's Access Control List as an object. A null ACL implies default permissions which make the entity readable by others.
      timeToLive - The duration of time, in milliseconds, the singleton custom entity should live before being expired. Null indicates never expires. Value of -1 indicates no change for updates.
      callback - Callback.
    • updateSingletonFields

      public void updateSingletonFields​(String entityType, int version, String fieldsJson, IServerCallback callback)
      Partially updates the data, of the singleton owned by the user for the specified custom entity type, with the specified fields, on the server
      Parameters:
      entityType - The entity type as defined by the user
      version - Version of the custom entity singleton being updated.
      fieldsJson - Specific fields, as JSON, to set within singleton entity's custom data.
      callback - Callback.
    • incrementData

      public void incrementData​(String entityType, String entityId, String fieldsJson, IServerCallback callback)
      Increments the specified fields by the specified amount within custom entity data on the server, enforcing ownership/ACL permissions.
      Parameters:
      entityType - The entity type as defined by the user
      entityId - The id of custom entity being updated.
      fieldsJson - Specific fields, as JSON, within entity's custom data, with respective increment amount.
      callback - Callback.
    • readSingleton

      public void readSingleton​(String entityType, IServerCallback callback)
      Reads the custom entity singleton owned by the session's user.
      Parameters:
      entityType - The entity type as defined by the user
      callback - Callback.
    • incrementSingletonData

      public void incrementSingletonData​(String entityType, String fieldsJson, IServerCallback callback)
      Increments the specified fields of the singleton owned by the user by the specified amount within the custom entity data on the server.
      Parameters:
      entityType - The type of custom entity being updated.
      fieldsJson - Specific fields, as JSON, within entity's custom data with respective increment amount.
      callback - Callback.