Skip to main content
1-Visitor
April 14, 2020
Question

Insert values to Thing via Java sdk

  • April 14, 2020
  • 1 reply
  • 2643 views

Hi,

 

I want to insert time series data into a thing existing on TW foundation via java sdk. At run time, I might not have the visibility of the name of the stream that is linked with the thing. In such case, can I use SetPropertyValues service for this purpose? Or do I need to work with stream itself and use the services like addStreamEntry ? 

 

SetPropertyValues documentation is not clear enough for me. I can create the DataShapeDefinition and add the FieldDefinitions. How do we pass this as infoTable in valueCollection param in the call invokeService()? 

 

Regards,

Vaishnavee

1 reply

Support
April 17, 2020

Hi @vaishnavee.

 

You can associate the value stream with the Thing entity (on the General information page for the Thing).  Once the stream is associated and you begin binding properties from the java SDK to the Thing, you can configure the properties as logged, which will automatically log the data in the value stream as it changes (based on the data type change you select).

 

This page from the ThingWorx Help Center provides more information.

 

Regards.

 

--Sharon

 

 

 

1-Visitor
April 22, 2020

hi @slangley , For binding my properties via sdk, i would need to create a thing object in my client, right? One that has mapping of all the properties as on the server?

If so, I can not do this. I have the use case of - "given a thing name, update the properties with given values. For current timestamp/specified timestamp". 

So i need some thing more like an invokeService call using OOTB services SetPropertyValues/ UpdatePropertyValues.

 

I justverified that I can use -

VTQ vtq = new VTQ(IntegerPrimitive.convertFromObject(4444444));
client.writePropertyVTQ(RelationshipTypes.ThingworxEntityTypes.Things, "name", "propName", vtq, 30000);

I think i can use another constructor of VTQ if needed to update the value at particular timestamp. 

 

Still, I am curious as to know how is the service  SetPropertyValues intended to be used? What is the expected value if ValueCollection object in this service call?

Support
April 29, 2020

Hi @vaishnavee.
 

To respond in order or your concerns.....

 

From a security perspective, it would be expected that you would want to know something about the devices that are connecting and sending.  It would be a risk to let anything connect--you need to go through a modeling exercise for defining the properties, etc.   The Java SDK would be sending the data at the defined interval, but you would still need to define how it is stored.

 

In regard to your migration use case, ThingWorx has built-in functions that will allow the export of data in specific formats, such as .csv.  There are also database things that will allow you to configure a connection to an external database.  We also have extensions available for connecting with external systems available on the ThingWorx Marketplace.  The point here, is that the Java SDK is not needed for migrating information.

 

In regard to visibility, we're not sure who would require this information.  But it is recommended that you work with the ThingWorx developer on a solution, such as a mashup, or API to retrieve the needed information.

 

Getting back to the Java SDK, we recommend the guide we previously provided, as well as the example that comes with the Java SDK.  These examples should be adaptable to portions of your use case.

 

As this is becoming complicated for a quick response through the community, we recommend a services engagement for help to design and implement your solution.  To arrange for this, please reach out to the Sales team.

 

Regards.

 

--Sharon