Skip to content

Commit

Permalink
[m-o] Fix @ActionOutput annotations (openhab#17654)
Browse files Browse the repository at this point in the history
Related to openhab#17636

Signed-off-by: Laurent Garnier <[email protected]>
  • Loading branch information
lolodomo authored and KaaNee committed Nov 8, 2024
1 parent 1450d75 commit 6b4c3cb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public class SendMailActions implements ThingActions {
private Map<String, String> headers = new HashMap<>();

@RuleAction(label = "@text/sendMessageActionLabel", description = "@text/sendMessageActionDescription")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean sendMail(
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendMail(
@ActionInput(name = "recipient") @Nullable String recipient,
@ActionInput(name = "subject") @Nullable String subject,
@ActionInput(name = "text") @Nullable String text) {
return sendMailWithAttachments(recipient, subject, text, List.of());
}

@RuleAction(label = "@text/sendAttachmentMessageActionLabel", description = "@text/sendAttachmentMessageActionDescription")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean sendMailWithAttachment(
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendMailWithAttachment(
@ActionInput(name = "recipient") @Nullable String recipient,
@ActionInput(name = "subject") @Nullable String subject, @ActionInput(name = "text") @Nullable String text,
@ActionInput(name = "url") @Nullable String url) {
Expand All @@ -72,7 +72,7 @@ public class SendMailActions implements ThingActions {
}

@RuleAction(label = "@text/sendAttachmentsMessageActionLabel", description = "@text/sendAttachmentsMessageActionDescription")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean sendMailWithAttachments(
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendMailWithAttachments(
@ActionInput(name = "recipient") @Nullable String recipient,
@ActionInput(name = "subject") @Nullable String subject, @ActionInput(name = "text") @Nullable String text,
@ActionInput(name = "urlList", type = "List<String>") @Nullable List<String> urlList) {
Expand Down Expand Up @@ -141,15 +141,15 @@ public static boolean sendMailWithAttachments(ThingActions actions, @Nullable St
}

@RuleAction(label = "@text/sendHTMLMessageActionLabel", description = "@text/sendHTMLMessageActionDescription")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean sendHtmlMail(
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendHtmlMail(
@ActionInput(name = "recipient") @Nullable String recipient,
@ActionInput(name = "subject") @Nullable String subject,
@ActionInput(name = "htmlContent") @Nullable String htmlContent) {
return sendHtmlMailWithAttachments(recipient, subject, htmlContent, List.of());
}

@RuleAction(label = "@text/sendHTMLAttachmentMessageActionLabel", description = "@text/sendHTMLAttachmentMessageActionDescription")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean sendHtmlMailWithAttachment(
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendHtmlMailWithAttachment(
@ActionInput(name = "recipient") @Nullable String recipient,
@ActionInput(name = "subject") @Nullable String subject,
@ActionInput(name = "htmlContent") @Nullable String htmlContent,
Expand All @@ -162,7 +162,7 @@ public static boolean sendMailWithAttachments(ThingActions actions, @Nullable St
}

@RuleAction(label = "@text/sendHTMLAttachmentsMessageActionLabel", description = "@text/sendHTMLAttachmentsMessageActionDescription")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean sendHtmlMailWithAttachments(
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendHtmlMailWithAttachments(
@ActionInput(name = "recipient") @Nullable String recipient,
@ActionInput(name = "subject") @Nullable String subject,
@ActionInput(name = "htmlContent") @Nullable String htmlContent,
Expand Down Expand Up @@ -244,7 +244,7 @@ public void setThingHandler(@Nullable ThingHandler handler) {
}

@RuleAction(label = "@text/addHeaderActionLabel", description = "@text/addHeaderActionDescription")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean addHeader(
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean addHeader(
@ActionInput(name = "name") @Nullable String name, @ActionInput(name = "value") @Nullable String value) {
if (name != null && !name.isEmpty()) {
if (value != null && !value.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void setThingHandler(@Nullable ThingHandler handler) {
}

@RuleAction(label = "backup the Cube data", description = "Creates a backup of the MAX! Cube data.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean backup() {
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean backup() {
MaxCubeBridgeHandler actionsHandler = handler;
if (actionsHandler == null) {
logger.info("MaxCubeActions: Action service ThingHandler is null!");
Expand All @@ -67,7 +67,7 @@ public static boolean backup(ThingActions actions) {
}

@RuleAction(label = "reset the Cube configuration", description = "Resets the MAX! Cube room and device information. Devices will need to be included again!")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean resetConfig() {
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean resetConfig() {
MaxCubeBridgeHandler actionsHandler = handler;
if (actionsHandler == null) {
logger.info("MaxCubeActions: Action service ThingHandler is null!");
Expand All @@ -82,7 +82,7 @@ public static boolean reset(ThingActions actions) {
}

@RuleAction(label = "restart the Cube", description = "Restarts the MAX! Cube.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean reboot() {
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean reboot() {
MaxCubeBridgeHandler actionsHandler = handler;
if (actionsHandler == null) {
logger.info("MaxCubeActions: Action service ThingHandler is null!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void setThingHandler(@Nullable ThingHandler handler) {
}

@RuleAction(label = "delete the device from the Cube", description = "Deletes the device from the MAX! Cube. Device will need to be included again!")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean deleteFromCube() {
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean deleteFromCube() {
MaxDevicesHandler actionsHandler = handler;
if (actionsHandler == null) {
logger.info("MaxDevicesActions: Action service ThingHandler is null!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.automation.annotation.ActionInput;
import org.openhab.core.automation.annotation.ActionOutput;
import org.openhab.core.automation.annotation.ActionOutputs;
import org.openhab.core.automation.annotation.RuleAction;
import org.openhab.core.thing.binding.ThingActions;
import org.openhab.core.thing.binding.ThingActionsScope;
Expand Down Expand Up @@ -159,7 +160,7 @@ public static void setBypassTo(ThingActions actions, int day, int month) {
}

@RuleAction(label = "@text/action.getErrorMessages.label", description = "@text/action.getErrorMessages.description")
public @ActionOutput(name = "errorMessages", type = "java.util.List<String>") List<String> getErrorMessages() {
public @ActionOutput(label = "Error Messages", type = "java.util.List<String>") List<String> getErrorMessages() {
HeliosEasyControlsHandler handler = this.handler;
return (handler != null) ? handler.getErrorMessages() : new ArrayList<>();
}
Expand All @@ -169,7 +170,7 @@ public static List<String> getErrorMessages(ThingActions actions) {
}

@RuleAction(label = "@text/action.getWarningMessages.label", description = "@text/action.getWarningMessages.description")
public @ActionOutput(name = "warningMessages", type = "java.util.List<String>") List<String> getWarningMessages() {
public @ActionOutput(label = "Warning Messages", type = "java.util.List<String>") List<String> getWarningMessages() {
HeliosEasyControlsHandler handler = this.handler;
return (handler != null) ? handler.getWarningMessages() : new ArrayList<>();
}
Expand All @@ -179,7 +180,7 @@ public static List<String> getWarningMessages(ThingActions actions) {
}

@RuleAction(label = "@text/action.getInfoMessages.label", description = "@text/action.getInfoMessages.description")
public @ActionOutput(name = "infoMessages", type = "java.util.List<String>") List<String> getInfoMessages() {
public @ActionOutput(label = "Info Messages", type = "java.util.List<String>") List<String> getInfoMessages() {
HeliosEasyControlsHandler handler = this.handler;
return (handler != null) ? handler.getInfoMessages() : new ArrayList<>();
}
Expand All @@ -189,7 +190,7 @@ public static List<String> getInfoMessages(ThingActions actions) {
}

@RuleAction(label = "@text/action.getStatusMessages.label", description = "@text/action.getStatusMessages.description")
public @ActionOutput(name = "statusMessages", type = "java.util.List<String>") List<String> getStatusMessages() {
public @ActionOutput(label = "Status Messages", type = "java.util.List<String>") List<String> getStatusMessages() {
HeliosEasyControlsHandler handler = this.handler;
return (handler != null) ? handler.getStatusMessages() : new ArrayList<>();
}
Expand All @@ -199,7 +200,11 @@ public static List<String> getStatusMessages(ThingActions actions) {
}

@RuleAction(label = "@text/action.getMessages.label", description = "@text/action.getMessages.description")
public @ActionOutput(name = "errorMessages", type = "java.util.List<String>") @ActionOutput(name = "warningMessages", type = "java.util.List<String>") @ActionOutput(name = "infoMessages", type = "java.util.List<String>") @ActionOutput(name = "statusMessages", type = "java.util.List<String>") Map<String, Object> getMessages() {
public @ActionOutputs({
@ActionOutput(name = "errorMessages", label = "Error Messages", type = "java.util.List<String>"),
@ActionOutput(name = "warningMessages", label = "Warning Messages", type = "java.util.List<String>"),
@ActionOutput(name = "infoMessages", label = "Info Messages", type = "java.util.List<String>"),
@ActionOutput(name = "statusMessages", label = "Status Messages", type = "java.util.List<String>") }) Map<String, Object> getMessages() {
Map<String, Object> messages = new HashMap<>();
HeliosEasyControlsHandler handler = this.handler;
if (handler != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.openhab.binding.openwebnet.internal.handler.OpenWebNetBridgeHandler;
import org.openhab.core.automation.annotation.ActionInput;
import org.openhab.core.automation.annotation.ActionOutput;
import org.openhab.core.automation.annotation.ActionOutputs;
import org.openhab.core.automation.annotation.RuleAction;
import org.openhab.core.thing.binding.ThingActions;
import org.openhab.core.thing.binding.ThingActionsScope;
Expand Down Expand Up @@ -61,7 +62,7 @@ public void setThingHandler(@Nullable ThingHandler handler) {
}

@RuleAction(label = "sendMessage", description = "@text/action.sendMessage.desc")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean sendMessage(
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendMessage(
@ActionInput(name = "message", label = "message", description = "@text/action.sendMessage.input.message.desc") @Nullable String message) {
@Nullable
Boolean s = (Boolean) sendMessageInternal(message).get("success");
Expand All @@ -73,8 +74,9 @@ public void setThingHandler(@Nullable ThingHandler handler) {
}

@RuleAction(label = "sendMessageWithResponse", description = "@text/action.sendMessageWithResponse.desc")
public @ActionOutput(name = "success", type = "java.lang.Boolean") @ActionOutput(name = "responseMessages", type = "java.util.List<String>") Map<String, Object> sendMessageWithResponse(
@ActionInput(name = "message", label = "message", description = "@text/action.sendMessage.input.message.desc") @Nullable String message) {
public @ActionOutputs({ @ActionOutput(name = "success", label = "Success", type = "java.lang.Boolean"),
@ActionOutput(name = "responseMessages", label = "Response Messages", type = "java.util.List<String>") }) Map<String, Object> sendMessageWithResponse(
@ActionInput(name = "message", label = "message", description = "@text/action.sendMessage.input.message.desc") @Nullable String message) {
return sendMessageInternal(message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void setThingHandler(@Nullable ThingHandler handler) {
}

@RuleAction(label = "virtualPress", description = "@text/action.virtualPress.desc")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean virtualPress(
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean virtualPress(
@ActionInput(name = "press", label = "press", description = "@text/action.virtualPress.input.press.desc") @Nullable String press,
@ActionInput(name = "button", label = "button", description = "@text/action.virtualPress.input.button.desc") int button) {
OpenWebNetScenarioHandler handler = scenarioHandler;
Expand Down

0 comments on commit 6b4c3cb

Please sign in to comment.