Skip to content

Commit

Permalink
Add optional id to RuleAction annotation
Browse files Browse the repository at this point in the history
This id field has to be used to distinguish actions when the same method name is used for several actions.

Signed-off-by: Laurent Garnier <[email protected]>
  • Loading branch information
lolodomo committed Nov 2, 2024
1 parent 9646607 commit 40e791c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ public Response getActions(@PathParam("thingUID") @Parameter(description = "thin
continue;
}

String actionUid = thingActionsEntry.getKey() + "." + method.getName();
String actionUid = thingActionsEntry.getKey() + "."
+ (!ruleAction.id().isEmpty() ? ruleAction.id() : method.getName());
ActionType actionType = (ActionType) moduleTypeRegistry.get(actionUid, locale);
if (actionType == null) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

String description() default "";

String id() default "";

String[] tags() default {};

Visibility visibility() default Visibility.VISIBLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public Collection<ModuleInformation> parseAnnotations(String name, Object action
List<Output> outputs = getOutputsFromAction(method);

RuleAction ruleAction = method.getAnnotation(RuleAction.class);
String uid = name + "." + method.getName();
String uid = name + "." + (!ruleAction.id().isEmpty() ? ruleAction.id() : method.getName());
Set<String> tags = new HashSet<>(Arrays.asList(ruleAction.tags()));

ModuleInformation mi = new ModuleInformation(uid, actionProvider, method);
Expand Down

0 comments on commit 40e791c

Please sign in to comment.