Package com.thingworx.entities.utils
Class EntityUtilities
- java.lang.Object
-
- com.thingworx.entities.utils.EntityUtilities
-
@ThingworxExtensionApiClass(since={6,6}, canInstantiate=true) public final class EntityUtilities extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description EntityUtilities()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
exists(java.lang.String name, RelationshipTypes.ThingworxRelationshipTypes type)
static RootEntity
findEntity(java.lang.String name, RelationshipTypes.ThingworxRelationshipTypes type)
Find an entity of a particular type, and check visibility permissions.static RootEntity
findEntityDirect(java.lang.String name, RelationshipTypes.ThingworxRelationshipTypes type)
Find an entity of a particular type, ignoring visibility permissions.void
operateOnEntities(RelationshipTypes.ThingworxRelationshipTypes type, java.util.function.Predicate<RootEntity> filter, java.util.function.Consumer<RootEntity> operation)
Perform an operation on the set of entities of a particular type after filtering the entities.void
operateOnEntitiesDirect(RelationshipTypes.ThingworxRelationshipTypes type, java.util.function.Predicate<RootEntity> filter, java.util.function.Consumer<RootEntity> operation)
Perform an operation on the set of entities of a particular type after filtering the entities.static void
validateEntityName(java.lang.String name)
-
-
-
Method Detail
-
validateEntityName
@ThingworxExtensionApiMethod(since={6,6}) public static void validateEntityName(java.lang.String name) throws InvalidRequestException
- Throws:
InvalidRequestException
- If an error occurs
-
exists
@ThingworxExtensionApiMethod(since={6,6}) public static boolean exists(java.lang.String name, RelationshipTypes.ThingworxRelationshipTypes type)
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 detecttype
- 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
@ThingworxExtensionApiMethod(since={6,6}) public static RootEntity findEntity(java.lang.String name, RelationshipTypes.ThingworxRelationshipTypes type)
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 entitytype
- - ThingworxRelationshipType of the entity- Returns:
- RootEntity matching the type and name if found and visible, otherwise null
-
findEntityDirect
@ThingworxExtensionApiMethod(since={6,6}) public static RootEntity findEntityDirect(java.lang.String name, RelationshipTypes.ThingworxRelationshipTypes type)
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 entitytype
- - ThingworxRelationshipType of the entity- Returns:
- RootEntity matching the type and name if found, otherwise null
-
operateOnEntities
@ThingworxExtensionApiMethod(since={7,2}) public void operateOnEntities(RelationshipTypes.ThingworxRelationshipTypes type, java.util.function.Predicate<RootEntity> filter, java.util.function.Consumer<RootEntity> operation)
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 operationfilter
- - how to select the entities for the operationoperation
- - what to do to each entity after filtering
-
operateOnEntitiesDirect
@ThingworxExtensionApiMethod(since={7,2}) public void operateOnEntitiesDirect(RelationshipTypes.ThingworxRelationshipTypes type, java.util.function.Predicate<RootEntity> filter, java.util.function.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 operationfilter
- - how to select the entities for the operationoperation
- - what to do to each entity after filtering
-
-