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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Changing default value on property definiton

jasong
12-Amethyst

Changing default value on property definiton

I am unsure of the best way to change the default value on a property definition on a ThingShape when that ThingShape is instantiated on 1 or more things. I am doing this from within the Java SDK.

We of course have ThingShape.AddPropertyDefinition() but once that is created, the only way I can see to update the default value is to remove the property definition and then add it again with the new data. That feels unsafe, when the shape is used by one or more Things, although I suspect that the values on things will be retained over that moment of not actually having a property definition.

I'd be interested in hearing how you folks think I should handle that situation, to remove and add, whether I need to RestarThingsImplementingThingShape afterwards, or there is a seemingly more legit way to do it or if can be added to the SDK in a future version... etc.

Thanks everyone!

3 REPLIES 3

As far as I know, if you are talking about persistent properties, once it are initiated the first time with the default value, the instance property won't change if you change the default value.

The only workaround could be to search for all implementing things, and if  Instance Property Value it's equal to previous default value set it with the new default value.

jasong
12-Amethyst
(To:CarlesColl)

Right of course, I am not trying to change the values on existing things. But I am trying to change the value for future yet to be created things that use that shape.

Sorry I didn't understood well the question you want to change the Default value right from code. If you really need to do it right now, you will need to use the REST API to query for ThingShape metadata, update the JSON and set it back again, you just need to see how Composer does it...

Announcements


Top Tags