Skip to main content
4-Participant
April 26, 2024
Solved

Java SDK - How can I pass a function call to ValueCollection

  • April 26, 2024
  • 2 replies
  • 828 views

Hello,

I am using the Java SDK to invoke service QueryImplementingThingsOptimized 

 

let result = ThingTemplates["LoraDeviceGenericModel"].QueryImplementingThingsOptimized(

{

    maxItems: 1000,

});

 

The corresponding Java code is as follows;

 

ValueCollection getEntityListParams = new ValueCollection();

getEntityListParams.SetNumberValue("maxItems", BATCH_THINGS);

getEntityListParams.SetNumberValue("offset", offset);

InfoTable queryResult = thingClient.invokeService(ThingTemplates, "LoraDeviceGenericModel", "QueryImplementingThingsOptimized",

getEntityListParams, TIMEOUT_30_000_MS);

 

But this call could be optimized by using a filter on returned fields;

 

function entityList(inarray) {

let out = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({ dataShapeName: 'EntityList' });

inarray.forEach(entry => out.AddRow({ name: entry, description: entry }));

return out;

}

let result = ThingTemplates["LoraDeviceGenericModel"].QueryImplementingThingsOptimized(

{

maxItems: 1000,

basicPropertyNames: entityList(['name']),

propertyNames:entityList(['name'])

}

);

 

My Question is how can I do this via the Java SDK.

 

ValueCollection getEntityListParams = new ValueCollection();

getEntityListParams.SetNumberValue("maxItems", BATCH_THINGS);

 

How do I need to populate the ValueCollection to set the  basicPropertyNames and propertyNames entries?

 

Best answer by Sathishkumar_C

try to use follwoing code and appropriate values as parameters. Tried with Thingworx SDK 9.5

ThingTemplate genericThingTemplate = (ThingTemplate) EntityUtilities.findEntity("GenericThing", ThingworxRelationshipTypes.ThingTemplate);
 InfoTable data = genericThingTemplate.QueryImplementingThingsOptimized(1000, , nameMask, query, withPermissions, basicPropertyNames, propertyNames, networkName, networkParentNode, networkMaxDepth, offset);

2 replies

17-Peridot
April 29, 2024

try to use follwoing code and appropriate values as parameters. Tried with Thingworx SDK 9.5

ThingTemplate genericThingTemplate = (ThingTemplate) EntityUtilities.findEntity("GenericThing", ThingworxRelationshipTypes.ThingTemplate);
 InfoTable data = genericThingTemplate.QueryImplementingThingsOptimized(1000, , nameMask, query, withPermissions, basicPropertyNames, propertyNames, networkName, networkParentNode, networkMaxDepth, offset);
Community Manager
December 5, 2024

Hi @AymericR 

 

It appears you may have received a solution to your problem.  If so, please mark the response as the Accepted Solution for the benefit of others in the community.

 

Regards.

 

--Sharon