Class EntityService

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

public class EntityService
extends Object
  • Constructor Details

  • Method Details

    • createEntity

      public void createEntity​(String entityType, String jsonEntityData, String jsonEntityAcl, IServerCallback callback)
      Method creates a new entity on the server.
      Parameters:
      entityType - The entity type as defined by the user
      jsonEntityData - The entity's data as a json String
      jsonEntityAcl - The entity's access control list as json. A null acl implies default permissions which make the entity readable/writeable by only the player.
      callback - Callback.
    • deleteEntity

      public void deleteEntity​(String entityId, int version, IServerCallback callback)
      Method deletes the given entity on the server.
      Parameters:
      entityId - The id of the entity to update
      version - Current version of the entity. If the version of the entity on the server does not match the version passed in, the server operation will fail. Use -1 to skip version checking.
      callback - Callback.
    • deleteSingleton

      public void deleteSingleton​(String entityType, int version, IServerCallback callback)
      Method deletes the given singleton on the server. Note that if there are multiple entities with the same entityType, this call will only delete the first one found.
      Parameters:
      entityType - The entity type as defined by the user
      version - Current version of the entity. If the version of the entity on the server does not match the version passed in, the server operation will fail. Use -1 to skip version checking.
      callback - The callback handler
    • getEntitiesByType

      public void getEntitiesByType​(String entityType, IServerCallback callback)
      Method returns all player entities that match the given type.
      Parameters:
      entityType - The entity type to search for
      callback - The callback
    • getEntity

      public void getEntity​(String entityId, IServerCallback callback)
      Method to get a specific entity.
      Parameters:
      entityId - The id of the entity
      callback - The callback handler
    • getSingleton

      public void getSingleton​(String entityType, IServerCallback callback)
      Method retrieves a singleton entity on the server. If the entity doesn't exist, null is returned.
      Parameters:
      entityType - The entity type as defined by the user
      callback - The callback handler
    • getSharedEntityForProfileId

      public void getSharedEntityForProfileId​(String profileId, String entityId, IServerCallback callback)
      Method returns a shared entity for the given profile and entity ID. An entity is shared if its ACL allows for the currently logged in user to read the data. Service Name - Entity Service Operation - READ_SHARED_ENTITY
      Parameters:
      profileId - The the profile ID of the player who owns the entity
      entityId - The ID of the entity that will be retrieved
      callback - The method to be invoked when the server response is received
    • getSharedEntitiesForProfileId

      public void getSharedEntitiesForProfileId​(String profileId, IServerCallback callback)
      Method returns all shared entities for the given profile id. An entity is shared if its ACL allows for the currently logged in user to read the data. Service Name - Entity Service Operation - ReadShared
      Parameters:
      profileId - The profile id to retrieve shared entities for
      callback - The method to be invoked when the server response is received
    • getSharedEntitiesListForProfileId

      public void getSharedEntitiesListForProfileId​(String profileId, String whereJson, String orderByJson, int maxReturn, IServerCallback callback)
      Method gets list of shared entities for the specified profile based on type and/or where clause Service Name - Entity Service Operation - READ_SHARED_ENTITIES_LIST
      Parameters:
      profileId - The profile ID to retrieve shared entities for
      whereJson - Mongo style query
      orderByJson - Sort order
      maxReturn - The maximum number of entities to return
      callback - The method to be invoked when the server response is received
    • updateEntity

      public void updateEntity​(String entityId, String entityType, String jsonEntityData, String jsonEntityAcl, int version, IServerCallback callback)
      Method updates a new entity on the server. This operation results in the entity data being completely replaced by the passed in JSON String.
      Parameters:
      entityId - The id of the entity to update
      entityType - The entity type as defined by the user
      jsonEntityData - The entity's data as a json String.
      jsonEntityAcl - The entity's access control list as json. A null acl implies default permissions which make the entity readable/writeable by only the player.
      version - Current version of the entity. If the version of the entity on the server does not match the version passed in, the server operation will fail. Use -1 to skip version checking.
      callback - Callback.
    • updateSharedEntity

      public void updateSharedEntity​(String targetProfileId, String entityId, String entityType, String jsonEntityData, int version, IServerCallback callback)
      Method updates a shared entity owned by another user. This operation results in the entity data being completely replaced by the passed in JSON string. Service Name - Entity Service Operation - UpdateShared
      Parameters:
      entityId - The id of the entity to update
      targetProfileId - The id of the profile who owns the shared entity
      entityType - The entity type as defined by the user
      jsonEntityData - The entity's data as a json string.
      version - The version of the entity to update. Use -1 to indicate the newest version
      callback - The method to be invoked when the server response is received
    • updateSingleton

      public void updateSingleton​(String entityType, String jsonEntityData, String jsonAclData, int version, IServerCallback callback)
      Method updates a singleton entity on the server. This operation results in the entity data being completely replaced by the passed in JSON string. If the entity doesn't exist it is created.
      Parameters:
      entityType - The entity type as defined by the user
      jsonEntityData - The entity's data as a json string
      jsonAclData - The entity's access control list as json. A null acl implies default permissions which make the entity readable/writeable by only the player.
      version - Current version of the entity. If the version of the entity on the server does not match the version passed in, the server operation will fail. Use -1 to skip version checking.
      callback - The callback handler
    • getList

      public void getList​(String whereJson, String orderByJson, int maxReturn, IServerCallback callback)
      Method gets list of entities from the server base on type and/or where clause Service Name - Entity Service Operation - GET_LIST
      Parameters:
      whereJson - Mongo style query string
      orderByJson - Sort order
      maxReturn - The maximum number of entities to return
      callback - The callback object
    • getListCount

      public void getListCount​(String whereJson, IServerCallback callback)
      Method gets a count of entities based on the where clause Service Name - Entity Service Operation - GET_LIST_COUNT
      Parameters:
      whereJson - Mongo style query string
      callback - The callback object
    • getPage

      public void getPage​(String jsonContext, IServerCallback callback)
      Method uses a paging system to iterate through user entities After retrieving a page of entities with this method, use GetPageOffset() to retrieve previous or next pages. Service Name - Entity Service Operation - GET_PAGE
      Parameters:
      jsonContext - The json context for the page request. See the portal appendix documentation for format.
      callback - The callback object
    • getPageOffset

      public void getPageOffset​(String context, int pageOffset, IServerCallback callback)
      Method to retrieve previous or next pages after having called the GetPage method. Service Name - Entity Service Operation - GET_PAGE_BY_OFFSET
      Parameters:
      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 - The callback object
    • incrementUserEntityData

      public void incrementUserEntityData​(String entityId, String jsonData, IServerCallback callback)
      Partial increment of entity data field items. Partial set of items incremented as specified. Service Name - entity Service Operation - INCREMENT_USER_ENTITY_DATA
      Parameters:
      entityId - The id of the entity to update
      jsonData - The entity's data object
      callback - The callback object
    • incrementSharedUserEntityData

      public void incrementSharedUserEntityData​(String entityId, String targetProfileId, String jsonData, IServerCallback callback)
      Partial increment of entity data field items. Partial set of items incremented as specified. Service Name - entity Service Operation - INCREMENT_USER_ENTITY_DATA
      Parameters:
      entityId - The id of the entity to update
      targetProfileId - Profile ID of the entity owner
      jsonData - The entity's data object
      callback - The callback object