Class EntityUtilities

java.lang.Object
com.thingworx.entities.utils.EntityUtilities

@ThingworxExtensionApiClass(since={6,6}, canInstantiate=true) public final class EntityUtilities extends Object
  • Constructor Details

    • EntityUtilities

      public EntityUtilities()
  • Method Details

    • validateEntityName

      @ThingworxExtensionApiMethod(since={6,6}) public static void validateEntityName(String name) throws InvalidRequestException
      Throws:
      InvalidRequestException - If an error occurs
    • exists



      Tests to see if the specified entity of the given type exists.

      This method is subject to the permissions assigned to the current user's security context.

      Parameters:
      name - the name of the entity to detect
      type - the type of the entity
      Returns:
      true if the entity exists, false if it does not or if the current user does not have the necessary visibility privileges
    • findEntity



      Find an entity of a particular type, and check visibility permissions. If the user in the current context does not have visibility permission to view the entity, this method will return null. For example, to find a Thing named "MyThing", do: findEntity("MyThing", ThingworxRelationshipTypes.Thing)
      Parameters:
      name - - String name of the entity
      type - - ThingworxRelationshipType of the entity
      Returns:
      RootEntity matching the type and name if found and visible, otherwise null
    • findEntityDirect



      Find an entity of a particular type, ignoring visibility permissions. This method bypasses the visibility check for the user in the current context, and will return the entity, if found, even if the user does not have visibility permission to view the entity. For example, to find a Thing named "MyThing", do: findEntityDirect("MyThing", ThingworxRelationshipTypes.Thing)
      Parameters:
      name - - String name of the entity
      type - - ThingworxRelationshipType of the entity
      Returns:
      RootEntity matching the type and name if found, otherwise null
    • operateOnEntities



      Perform an operation on the set of entities of a particular type after filtering the entities. Visibility will be added to the filter.
      Parameters:
      type - - the type of entity collection for the operation
      filter - - how to select the entities for the operation
      operation - - what to do to each entity after filtering
    • operateOnEntitiesDirect

      @ThingworxExtensionApiMethod(since={7,2}) public void operateOnEntitiesDirect(RelationshipTypes.ThingworxRelationshipTypes type, Predicate<RootEntity> filter, Consumer<RootEntity> operation)


      Perform an operation on the set of entities of a particular type after filtering the entities. Visibility is not checked.
      Parameters:
      type - - the type of entity collection for the operation
      filter - - how to select the entities for the operation
      operation - - what to do to each entity after filtering