ThingWorx Model Definition in Composer > Modeling > Code Snippets > QueryImplementingThingsWithData
QueryImplementingThingsWithData
Description
You can use this service to query the Things that implement the Thing Template or Thing Shape on which the service is run. The result is an infotable that contains the Things that implement the Thing Template or Thing Shape and the effective property values of the Thing Template or Thing Shape on which the query is run.
Input
Parameter Name
Description
Base Type
maxItems
Maximum number of items to return in the result set. The default value is 500. This parameter is applied after all other filters are applied.
NUMBER
tags
The model tags associated with the source of this entry.
TAGS
nameMask
The name pattern for the entities that implement the Thing Template or Thing Shape.
STRING
query
The query criteria used to filter data.
Filters can only be written for the effective properties of the Thing Template or Thing Shape on which the service is run.
For more information, see Query Parameter for Query Services.
QUERY
Output
Parameter Name
Description
Base Type
result
Returns an infotable that contains the list of Things that implement the Thing Template or Thing Shape and the effective property values of the Thing Template or Thing Shape.
INFOTABLE
Example
In the following example, TestStream has a Data Shape that has Property1, Property2, and Property3 fields.
Entity
ShapeProp1
ShapeProp2
ShapeProp3
ThingShape1
Defined
NA
NA
ThingShape2
NA
NA
NA
ThingShape2
NA
NA
Defined
Entity
Parent Template
Prop1
Prop2
Prop3
Prop4
Implemented Shape
Effective Properties
Template1
Defined
NA
NA
NA
ThingShape1
Prop1, ShapeProp1
Template2
Template1
Inherited from Template1
Defined
NA
NA
ThingShape2
Prop1,
Prop2,
ShapeProp1,
ShapeProp2
Template3
Template2
Inherited from Template2
Inherited from Template2
Defined
NA
Prop1,
Prop2,
Prop3,
ShapePropy1,
ShapeProp2
Template4
Template2
Inherited from Template2
Inherited from Template2
NA
Defined
ThingShape4
Prop1,
Prop2,
Prop4,
ShapeProp1,
ShapeProp2,
ShapeProp4
Entity
Implements
Model Tags
Prop1
Prop2
Prop3
Prop4
ShapeProp1
ShapeProp2
ShapeProp4
Thing1
Template1
{vocabulary: "MT1", vocabularyTerm: "MT1-MTerm1"}
Val1-1
SVal1-1
Thing2
Template2
{vocabulary: "MT1", vocabularyTerm: "MT1-MTerm1"}
Val2-1
Val2-2
SVal2-1
SVal2-2
Thing3
Template3
{vocabulary: "MT1", vocabularyTerm: "MT1-MTerm1"}
Val3-1
Val3-2
Val3-3
SVal3-1
SVa3l-2
Thing4
Template4
{vocabulary: "MT1", vocabularyTerm: "MT1-MTerm2"}
Val4-1
Val4-2
Val4-4
SVal4-1
SVal3-2
SVal4-4
The following example shows a query for implementing Things with data using its supported parameters. This API call returns an infotable that contains the avatar, description, homeMashup, isSystemObject, name, tags, all properties defined in the Thing Template on which the query is run, and the immediate parent template of the Things that match the input parameters.
In the following query, avatar, description, homeMashup, isSystemObject, name, tags, Prop1, Prop2, Prop4, ShapeProp1, ShapeProp2, ShapeProp4, and the immediate parent template of the Thing are returned in the infotable.
result = ThingTemplates["Template4"].QueryImplementingThingsWithData({
maxItems: 50 /* NUMBER {"defaultValue":500} */,
nameMask: "T*" /* STRING */,
tags: "MT1:MT1-MTerm1",
query: "{\"filters\":{\"type\": \"LIKE\", \"fieldName\": \"Prop1\", \"value\": \"Val2*\" }}"

});
In the following query, avatar, description, homeMashup, isSystemObject, name, tags, Prop1, and ShapeProp1 of the Thing are returned in the infotable.
result = ThingShapes["ThingShape1"].QueryImplementingThingsWithData({
maxItems: 50 /* NUMBER {"defaultValue":500} */,
nameMask: "T*" /* STRING */,
tags: "MT1:MT1-MTerm1",
query: "{\"filters\":{\"type\": \"LIKE\", \"fieldName\": \"ShapeProp1\", \"value\": \"SVal*\" }}"

});
Was this helpful?