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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. 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?

 

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

2 REPLIES 2

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);
slangley
23-Emerald II
(To:AymericR)

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

Announcements


Top Tags