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

Insert values to Thing via Java sdk

vaishnavee
12-Amethyst

Insert values to Thing via Java sdk

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

7 REPLIES 7
slangley
23-Emerald I
(To:vaishnavee)

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

 

 

 

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?

slangley
23-Emerald I
(To:vaishnavee)

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

Hi @slangley ,

 

Thank you for taking the time to reply in detail. We are working with Trial serer version so far, for understanding the platform. We do not own any licensed version and will not be needing one as we are just a middle layer that connects ThingWorx platform to other applications. So I'm not sure how much sales would be able to help us out in this scenario.

 

I just need a proper java documentation link for existing services - SetPropertyValues and UpdatePropertyValues. I will post a separate question for it.

 

Regards,

Vaishnavee

slangley
23-Emerald I
(To:slangley)

Hi @vaishnavee.

 

Did you review the Developer's guide that comes with the Java SDK?  If not, it should answer your questions regarding the services available for use from the edge. 

 

Regards.

 

--Sharon

slangley
23-Emerald I
(To:slangley)

Hi @vaishnavee.

 

We would recommend that you take a look at the Java SDK Tutorial to answer some of these questions.  Step 6 addresses your specific scenario, but it would be best to start from the beginning in order to understand the full context of the example provided.  Once you have done so, if you still have questions, please let us know.

 

Regards.

 

--Sharon

Hello @slangley ,

 

I went through the tutorial, and this is my understanding - 

1. We have a virtual thing class DeliveryTruckThing which requires all the aspects, field definitions, services, events explicitly defined using the annotations. This DeliveryTruckThing corresponds to the remote thing of the same name existing on the ThingWorx server.

2. We can bind this virtual thing with the connectedThingClient and do further operations like reading values of thing, pushing the updated values to ThingWorx server etc. 

 

This requires the knowledge of the structure of the thing defined on the remote ThingWorx server and is possible only for the user who is creating/owns these objects. 

 

I guess I should have mentioned this in the original question, I am working with a use case - data migration between two PLM applications. I need to migrate the data from ThingWorx to some other system (e.g. Excel, Dataases, PLM systems etc).

 

Here, I will not have any visibility of the actual entities existing in TW. I need a generic approach for -

1. Fetch all things

2. Fetch metadata of things, create a middle layer object, for inserting into another application, that represents this thing

3. Fetch (historical &/or current) data of the thing

4. Write data to thing, if needed.

 

From what I understand, I would need to take help of inokeService calls for this. As I mentioned, I have one approach - 

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

But I want to understand the working of the services SetPropertyValues and UpdatePropertyValues.

Can you please help me with a working example using Java sdk for these services ?

 

Regards,
Vaishnavee

Announcements