cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

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

AymericR
3-Newcomer

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

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?

 

1 REPLY 1

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);
Announcements


Top Tags