Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set id manually #32

Closed
johannes-riesterer opened this issue Nov 24, 2017 · 10 comments
Closed

Set id manually #32

johannes-riesterer opened this issue Nov 24, 2017 · 10 comments

Comments

@johannes-riesterer
Copy link

Dear SensorThings Team,

is it possible to set the id of an object manually at it's creation?
So for example, can i create a Thing with @iot.id': "Some unique identifier"?
Best Regards

Johannes Riesterer

@hylkevds
Copy link
Member

No, entity id's are always generated by the server, specifically, by the database. Any @iot.id you specify in the json is ignored.

@johannes-riesterer
Copy link
Author

Thank you for your fast reply. So the id is generated by postgre database? Do you think it is possible in principal? Is there a way to get the id of an entity one created? I couldn't find it in the response of the corresponding post request.

Thank you for your help

Johannes

@hylkevds
Copy link
Member

Yes, the id is generated by the database. In theory it's possible to allow user-generated ids, but it's a bad idea, since you lose the guarantee that generated ids are unique.

The Id is in the location header that you get in the response:

Req 33 - create-update-delete/create-entity
Upon successful completion, the response SHALL contain a HTTP location header that contains the selfLink of the created entity.

@johannes-riesterer
Copy link
Author

johannes-riesterer commented Nov 24, 2017 via email

@hylkevds
Copy link
Member

If you're trying to replicate a complete server then it might be a lot easier to make a database dump and import that, or use database replication.

When it comes to matching entities across servers it's better to use the metadata fields. You can add an external identifier to the properties of a Thing, and use that to find the correct Thing for your operations. We also have a branch that adds a properties field to all entities, not just Thing and Observation.

We can always talk about special feature requests.

@johannes-riesterer
Copy link
Author

we want to sync the datastream with a Kafka system and we need unique identifiers in order to be able to restore everything from the Kafka system and to introduce redundant systems.

@hylkevds
Copy link
Member

When synchronising with external systems, the properties fields are the way to go. There you can store any information about the external system that you need.
Redundancy is best done at database level, using datebase replication.

@johannes-riesterer
Copy link
Author

ok, thank you very much for your help. Where can i find that build with properties field for all entities?

@hylkevds
Copy link
Member

In the branch moreProperties, at the following url:
https://github.com/FraunhoferIOSB/SensorThingsServer/tree/moreProperties

@johannes-riesterer
Copy link
Author

thank you. In the first instance we can work with this approach. After a long discussion today, we still think that we need to set id's manually later on in the project. Are you interested in a collaboration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants