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

[rest] Add semantic tag registry + API to manage user tags #3646

Merged
merged 13 commits into from
Jun 16, 2023

Conversation

lolodomo
Copy link
Contributor

@lolodomo lolodomo commented Jun 7, 2023

Related to #3619

New registry for semantic tags.
New default semantic tags provider for all built-in semantic tags.
New managed provider to add/remove/update user semantic tags.
Storage of user semantic tags in a JSON DB file.
New REST API to add/remove/update user tags in the semantic model.
New REST API to get a sub-tree of the semantic tags.

Semantic tag class annotations are removed.

Semantic tag classes are now created at runtime.
Classes Locations, Equipments, Points and Properties are removed

Static methods SemanticTags.add removed
The adding of semantic tag classes is now managed only by the tag registry.

Avoids calling static method SemanticTags.getById when possible

SemanticsMetadataProvider service now requires semanticTagRegistry to start.

Signed-off-by: Laurent Garnier lg.hc@free.fr

@lolodomo lolodomo requested a review from a team as a code owner June 7, 2023 18:19
@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 7, 2023

@J-N-K : I am sorry, I was constrained to create a new PR, the previous PR #3636 was no more updating with my last commits.

The last change is the full removal of the tag class annotation (TagInfo). It should answer to @splatch comments (in the other PR) about TagInfo.

@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 7, 2023

Remains one comment from @splatch I have not yet answered:

Custom tags will not be properly recognized by SemanticsMetadataProvider, if they are registered later. There is fair chance that they will work on random basis, depending on initialization order of elements which register tags at runtime.

@lolodomo lolodomo changed the title Custom tagsAdd semantic tag registry + REST API to manage user tags Add semantic tag registry + REST API to manage user tags Jun 8, 2023
@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 8, 2023

I have now considered most of @splatch comments done in the old PR, the most important being the removal of static methods in SemanticTags that allowed to add tag class.
It should be ready for a new review.

@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 9, 2023

A final effort would be required to remove the last remaining static stuff in SemanticsTat class.
I will have a look this evening.

@lolodomo
Copy link
Contributor Author

A final effort would be required to remove the last remaining static stuff in SemanticsTat class. I will have a look this evening.

Done.
It is not possible to remove all static methods. For example, they are used for rules.

Related to openhab#3619

New registry for semantic tags.
New default semantic tags provider for all built-in semantic tags.
New managed provider to add/remove/update user semantic tags.
Storage of user semantic tags in a JSON DB file.
New REST API to add/remove/update user tags in the semantic model.
New REST API to get a sub-tree of the semantic tags.

Semantic tag class annotations are removed.

Semantic tag classes are now created at runtime.
Classes Locations, Equipments, Points and Properties are removed

Static methods SemanticTags.add removed
The adding of semantic tag classes is now managed only by the tag registry.

Avoids calling static method SemanticTags.getById when possible

SemanticsMetadataProvider service now requires semanticTagRegistry to start.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo
Copy link
Contributor Author

@J-N-K : I squashed all my commits. It is in my opinion now finished and ready for a review.

@J-N-K : did you start implementing a config file provider based on YAML ? You said you were interested to work on that. If not, I will start the implementation. This will be of course in another PR.

@lolodomo
Copy link
Contributor Author

Custom tags will not be properly recognized by SemanticsMetadataProvider, if they are registered later. There is fair chance that they will work on random basis, depending on initialization order of elements which register tags at runtime.

It is now OK because SemanticsMetadataProvider is now started only when the semantic tag registry is started. I added an OISGi dependency. So we are sure that all default tags and all managed tags are there when this service is started.
Later, when a config file provider will be implemented, we will have to take care again about that.

@J-N-K
Copy link
Member

J-N-K commented Jun 10, 2023

@lolodomo See main...J-N-K:openhab-core:yaml It is more a proof-of-concept than a full implementation, but I think that's the way to do it.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo
Copy link
Contributor Author

@lolodomo See main...J-N-K:openhab-core:yaml It is more a proof-of-concept than a full implementation, but I think that's the way to do it.

Ok, thank you, I will do it, your example will really help me, in particular the watch service stuff.

*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.core.semantics.model;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should move this to the internal (or semantics) package, because that's where the managed provider is.

Copy link
Contributor Author

@lolodomo lolodomo Jun 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked myself the question.
As it is a generated file, isn't it important to put it in a separate package to clearly identify it ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other bundles we use src/generated/java/org/... for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please tell me where I can find an example ?
I will have to add the generated path in the build path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

org.openhab.core.thing would be an example. But the classes are generated on the fly during build, I think this is not the case here. So maybe we leave it in place now. In the long run (when we have a YAML based provider), we could convert the CSV to YAML and then load that immediately, when we add the YAML based provider.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Also remove method isRemovable from registry interface.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo
Copy link
Contributor Author

The build failure has apparently no link with my PR:

[ERROR] Failed to read artifact descriptor for org.openhab.tools.sat.custom-checks:findbugs:jar:0.15.0: Could not transfer artifact org.openhab.tools.sat.custom-checks:findbugs:pom:0.15.0 from/to central (https://repo1.maven.org/maven2): /home/jenkins/jenkins-agent1/maven-repositories/3/org/openhab/tools/sat/custom-checks/findbugs/0.15.0/findbugs-0.15.0.pom.part (No such file or directory) -> [Help 1]

Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general looks good. It's not so easy to review if the behavior is always the same as before because the general concept changed. But there are a lot of tests, also for the new classes and that all looks good to me.

I have left only some minor comments and would prefer to merge ASAP.

*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.core.semantics.model;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

org.openhab.core.thing would be an example. But the classes are generated on the fly during build, I think this is not the case here. So maybe we leave it in place now. In the long run (when we have a YAML based provider), we could convert the CSV to YAML and then load that immediately, when we add the YAML based provider.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo
Copy link
Contributor Author

I have left only some minor comments and would prefer to merge ASAP

I believe you can merge now ;)

@splatch
Copy link
Contributor

splatch commented Jun 14, 2023

@lolodomo FYI, I wish to review changes later this or next week, in case I find anything I'll try to share them as a post-portem review. Sadly I ran out of spare time to catch up with what you did.
I do belive that major problem, which was related to coordination of access to static classes is gone, thus prime risk factor in this feature is eliminated.
Thank you for your work.

@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 15, 2023

IMHO, if this is fine for core maintainers, we should not delay the merge of this PR, considering the OH4 release planning and if we want a chance UI part to be implemented in time.

If necessary, enhancements could be provided later. One of them is the config file provider I am starting to work on and I hope I can submit another PR during the weekend or next week.

@J-N-K J-N-K added the rebuild Triggers the Jenkins PR build label Jun 15, 2023
@J-N-K J-N-K added enhancement An enhancement or new feature of the Core and removed rebuild Triggers the Jenkins PR build labels Jun 15, 2023
@J-N-K
Copy link
Member

J-N-K commented Jun 15, 2023

@lolodomo It seems there is a conflict after I merged the REST cache. Can you rebase? Thanks.

@lolodomo
Copy link
Contributor Author

@lolodomo It seems there is a conflict after I merged the REST cache. Can you rebase? Thanks.

Conflict resolved.

@J-N-K J-N-K merged commit f86635f into openhab:main Jun 16, 2023
@J-N-K J-N-K changed the title Add semantic tag registry + REST API to manage user tags [rest] Add semantic tag registry + API to manage user tags Jun 16, 2023
@J-N-K J-N-K added this to the 4.0 milestone Jun 16, 2023
@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 16, 2023

Thank you @J-N-K .

Can one of you trigger a new build of core framework so that we can then rebuild my HABot PR. We need to merge it ASAP now. Until that, HABot will no more compile in next snapshots.

@J-N-K
Copy link
Member

J-N-K commented Jun 16, 2023

florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Jun 18, 2023
Refs openhab/openhab-core#3646.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 12, 2023
)

* Add semantic tag registry + REST API to manage user tags

Related to openhab#3619

New registry for semantic tags.
New default semantic tags provider for all built-in semantic tags.
New managed provider to add/remove/update user semantic tags.
Storage of user semantic tags in a JSON DB file.
New REST API to add/remove/update user tags in the semantic model.
New REST API to get a sub-tree of the semantic tags.

Semantic tag class annotations are removed.

Semantic tag classes are now created at runtime.
Classes Locations, Equipments, Points and Properties are removed

Static methods SemanticTags.add removed
The adding of semantic tag classes is now managed only by the tag registry.

Avoids calling static method SemanticTags.getById when possible

SemanticsMetadataProvider service now requires semanticTagRegistry to start.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
GitOrigin-RevId: f86635f
@lolodomo lolodomo deleted the custom_tags branch January 4, 2024 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants