diff --git a/src/main/java/cz/smarteon/loxone/calendar/CalEntryBase.java b/src/main/java/cz/smarteon/loxone/calendar/CalEntryBase.java index 5a9b91e..0788db7 100644 --- a/src/main/java/cz/smarteon/loxone/calendar/CalEntryBase.java +++ b/src/main/java/cz/smarteon/loxone/calendar/CalEntryBase.java @@ -32,6 +32,7 @@ public abstract class CalEntryBase { protected static final String CREATE_ENTRY = "calendarcreateentry/"; protected static final String DELETE_ENTRY = "calendardeleteentry/"; + protected static final String UPDATE_ENTRY = "calendarupdateentry/"; /** * UUID of this calendar entry, should be unique. @@ -95,5 +96,18 @@ public CalendarCommand deleteEntryCommand(){ * * @return create calendar entry command */ - abstract public CalendarCommand createEntryCommand(); + public CalendarCommand createEntryCommand() { + return new CalendarCommand<>(CREATE_ENTRY + this, EmptyValue.class); + } + + /** + * Creates update calendar entry command. + * Command updates an existing calendar entry with the given parameters. + * + * @return update calendar entry command + * @param uuid - uuid of an existing entry to be updated + */ + public CalendarCommand updateEntryCommand(LoxoneUuid uuid) { + return new CalendarCommand<>(UPDATE_ENTRY + uuid + "/" + this, EmptyValue.class); + } } diff --git a/src/main/java/cz/smarteon/loxone/calendar/CalEntryDayOfWeek.java b/src/main/java/cz/smarteon/loxone/calendar/CalEntryDayOfWeek.java index 668dc63..ad2a639 100644 --- a/src/main/java/cz/smarteon/loxone/calendar/CalEntryDayOfWeek.java +++ b/src/main/java/cz/smarteon/loxone/calendar/CalEntryDayOfWeek.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import cz.smarteon.loxone.LoxoneUuid; -import cz.smarteon.loxone.user.EmptyValue; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; @@ -85,7 +84,8 @@ public CalEntryDayOfWeek( this.weekDayInMonth = weekDayInMonth.value; } - public CalendarCommand createEntryCommand(){ - return new CalendarCommand<>(CREATE_ENTRY + name + "/" + operatingMode + "/" + CAL_MODE + "/" + weekDayInMonth + "/" + weekDay + "/" + startMonth, EmptyValue.class); + @Override + public String toString() { + return name + "/" + operatingMode + "/" + CAL_MODE + "/" + weekDayInMonth + "/" + weekDay + "/" + startMonth; } } diff --git a/src/main/java/cz/smarteon/loxone/calendar/CalEntryEasterOffset.java b/src/main/java/cz/smarteon/loxone/calendar/CalEntryEasterOffset.java index f3111c3..6577882 100644 --- a/src/main/java/cz/smarteon/loxone/calendar/CalEntryEasterOffset.java +++ b/src/main/java/cz/smarteon/loxone/calendar/CalEntryEasterOffset.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import cz.smarteon.loxone.LoxoneUuid; -import cz.smarteon.loxone.user.EmptyValue; import lombok.Getter; import lombok.Setter; import org.jetbrains.annotations.NotNull; @@ -46,7 +45,8 @@ public CalEntryEasterOffset( this.easterOffset = easterOffset; } - public CalendarCommand createEntryCommand(){ - return new CalendarCommand<>(CREATE_ENTRY + name + "/" + operatingMode + "/" + CAL_MODE + "/" + easterOffset, EmptyValue.class); + @Override + public String toString() { + return name + "/" + operatingMode + "/" + CAL_MODE + "/" + easterOffset; } } diff --git a/src/main/java/cz/smarteon/loxone/calendar/CalEntryEveryYear.java b/src/main/java/cz/smarteon/loxone/calendar/CalEntryEveryYear.java index e6e4a75..9014702 100644 --- a/src/main/java/cz/smarteon/loxone/calendar/CalEntryEveryYear.java +++ b/src/main/java/cz/smarteon/loxone/calendar/CalEntryEveryYear.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import cz.smarteon.loxone.LoxoneUuid; -import cz.smarteon.loxone.user.EmptyValue; import lombok.Getter; import lombok.Setter; import org.jetbrains.annotations.NotNull; @@ -55,7 +54,8 @@ public CalEntryEveryYear( this.startDay = startDay; } - public CalendarCommand createEntryCommand(){ - return new CalendarCommand<>(CREATE_ENTRY + name + "/" + operatingMode + "/" + CAL_MODE + "/" + startMonth + "/" + startDay, EmptyValue.class); + @Override + public String toString() { + return name + "/" + operatingMode + "/" + CAL_MODE + "/" + startMonth + "/" + startDay; } } diff --git a/src/main/java/cz/smarteon/loxone/calendar/CalEntryPeriod.java b/src/main/java/cz/smarteon/loxone/calendar/CalEntryPeriod.java index 88bfb3c..9865a3c 100644 --- a/src/main/java/cz/smarteon/loxone/calendar/CalEntryPeriod.java +++ b/src/main/java/cz/smarteon/loxone/calendar/CalEntryPeriod.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import cz.smarteon.loxone.LoxoneUuid; -import cz.smarteon.loxone.user.EmptyValue; import lombok.Getter; import lombok.Setter; import org.jetbrains.annotations.NotNull; @@ -91,7 +90,8 @@ public CalEntryPeriod( this.endDay = endDay; } - public CalendarCommand createEntryCommand(){ - return new CalendarCommand<>(CREATE_ENTRY + name + "/" + operatingMode + "/" + CAL_MODE + "/" + startYear + "/" + startMonth + "/" + startDay + "/" + endYear + "/" + endMonth + "/" + endDay, EmptyValue.class); + @Override + public String toString() { + return name + "/" + operatingMode + "/" + CAL_MODE + "/" + startYear + "/" + startMonth + "/" + startDay + "/" + endYear + "/" + endMonth + "/" + endDay; } } diff --git a/src/main/java/cz/smarteon/loxone/calendar/CalEntryPeriodYearly.java b/src/main/java/cz/smarteon/loxone/calendar/CalEntryPeriodYearly.java index 8d8aaf7..c7d647c 100644 --- a/src/main/java/cz/smarteon/loxone/calendar/CalEntryPeriodYearly.java +++ b/src/main/java/cz/smarteon/loxone/calendar/CalEntryPeriodYearly.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import cz.smarteon.loxone.LoxoneUuid; -import cz.smarteon.loxone.user.EmptyValue; import lombok.Getter; import lombok.Setter; import org.jetbrains.annotations.NotNull; @@ -73,7 +72,8 @@ public CalEntryPeriodYearly( this.endDay = endDay; } - public CalendarCommand createEntryCommand(){ - return new CalendarCommand<>(CREATE_ENTRY + name + "/" + operatingMode + "/" + CAL_MODE + "/" + startMonth + "/" + startDay + "/" + endMonth + "/" + endDay, EmptyValue.class); + @Override + public String toString() { + return name + "/" + operatingMode + "/" + CAL_MODE + "/" + startMonth + "/" + startDay + "/" + endMonth + "/" + endDay; } } diff --git a/src/main/java/cz/smarteon/loxone/calendar/CalEntrySingleDay.java b/src/main/java/cz/smarteon/loxone/calendar/CalEntrySingleDay.java index ee9416f..8474041 100644 --- a/src/main/java/cz/smarteon/loxone/calendar/CalEntrySingleDay.java +++ b/src/main/java/cz/smarteon/loxone/calendar/CalEntrySingleDay.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import cz.smarteon.loxone.LoxoneUuid; -import cz.smarteon.loxone.user.EmptyValue; import lombok.Getter; import lombok.Setter; import org.jetbrains.annotations.NotNull; @@ -64,7 +63,8 @@ public CalEntrySingleDay( this.startDay = startDay; } - public CalendarCommand createEntryCommand(){ - return new CalendarCommand<>(CREATE_ENTRY + name + "/" + operatingMode + "/" + CAL_MODE + "/" + startYear + "/" + startMonth + "/" + startDay, EmptyValue.class); + @Override + public String toString() { + return name + "/" + operatingMode + "/" + CAL_MODE + "/" + startYear + "/" + startMonth + "/" + startDay; } } diff --git a/src/main/java/cz/smarteon/loxone/calendar/CalendarCommand.java b/src/main/java/cz/smarteon/loxone/calendar/CalendarCommand.java index 0348afd..9cfbda6 100644 --- a/src/main/java/cz/smarteon/loxone/calendar/CalendarCommand.java +++ b/src/main/java/cz/smarteon/loxone/calendar/CalendarCommand.java @@ -11,7 +11,7 @@ public class CalendarCommand extends LoxoneMessageCommand private static final String GET_ENTRIES = "calendargetentries/"; - private static final String COMMAND_PREFIX = "jdev/sps/"; + protected static final String COMMAND_PREFIX = "jdev/sps/"; protected CalendarCommand(String operation, Class valueType) { super(requireNonNull(operation, "operation can't be null"), diff --git a/src/test/kotlin/calendar/CalEntryDayOfWeekTest.kt b/src/test/kotlin/calendar/CalEntryDayOfWeekTest.kt index c568f6a..4c210c0 100644 --- a/src/test/kotlin/calendar/CalEntryDayOfWeekTest.kt +++ b/src/test/kotlin/calendar/CalEntryDayOfWeekTest.kt @@ -22,6 +22,7 @@ class CalEntryDayOfWeekTest { get { weekDayInMonth}.isEqualTo(1) get { weekDay }.isEqualTo(2) get { createEntryCommand().command }.isEqualTo("jdev/sps/calendarcreateentry/Day of week test/1/5/1/2/7") + get { updateEntryCommand(this.uuid).command }.isEqualTo("jdev/sps/calendarupdateentry/1b6f49d6-030f-9bc2-ffff504f94a03d3e/Day of week test/1/5/1/2/7") } } diff --git a/src/test/kotlin/calendar/CalEntryEasterOffsetTest.kt b/src/test/kotlin/calendar/CalEntryEasterOffsetTest.kt index 6268a95..2d1ae02 100644 --- a/src/test/kotlin/calendar/CalEntryEasterOffsetTest.kt +++ b/src/test/kotlin/calendar/CalEntryEasterOffsetTest.kt @@ -20,6 +20,7 @@ class CalEntryEasterOffsetTest { get { calMode }.isEqualTo(1) get { easterOffset }.isEqualTo(11) get { createEntryCommand().command }.isEqualTo("jdev/sps/calendarcreateentry/Eastern offset test/1/1/11") + get { updateEntryCommand(this.uuid).command }.isEqualTo("jdev/sps/calendarupdateentry/1b6f47dd-0243-9b2c-ffff504f94a03d3e/Eastern offset test/1/1/11") } } diff --git a/src/test/kotlin/calendar/CalEntryEveryYearTest.kt b/src/test/kotlin/calendar/CalEntryEveryYearTest.kt index 859f29d..ba67f04 100644 --- a/src/test/kotlin/calendar/CalEntryEveryYearTest.kt +++ b/src/test/kotlin/calendar/CalEntryEveryYearTest.kt @@ -21,6 +21,7 @@ class CalEntryEveryYearTest { get { startMonth }.isEqualTo(4) get { startDay }.isEqualTo(1) get { createEntryCommand().command }.isEqualTo("jdev/sps/calendarcreateentry/Every year test/1/0/4/1") + get { updateEntryCommand(this.uuid).command }.isEqualTo("jdev/sps/calendarupdateentry/1b6f47bd-0390-9b1e-ffff504f94a03d3e/Every year test/1/0/4/1") } } diff --git a/src/test/kotlin/calendar/CalEntryPeriodTest.kt b/src/test/kotlin/calendar/CalEntryPeriodTest.kt index e7b25b5..09ed88e 100644 --- a/src/test/kotlin/calendar/CalEntryPeriodTest.kt +++ b/src/test/kotlin/calendar/CalEntryPeriodTest.kt @@ -25,6 +25,7 @@ class CalEntryPeriodTest { get { endMonth }.isEqualTo(8) get { endDay }.isEqualTo(4) get { createEntryCommand().command }.isEqualTo("jdev/sps/calendarcreateentry/Period test/1/3/2024/8/3/2024/8/4") + get { updateEntryCommand(this.uuid).command }.isEqualTo("jdev/sps/calendarupdateentry/1b6f480b-0393-9b59-ffff504f94a03d3e/Period test/1/3/2024/8/3/2024/8/4") } } diff --git a/src/test/kotlin/calendar/CalEntryPeriodYearlyTest.kt b/src/test/kotlin/calendar/CalEntryPeriodYearlyTest.kt index 2dddef7..05993e1 100644 --- a/src/test/kotlin/calendar/CalEntryPeriodYearlyTest.kt +++ b/src/test/kotlin/calendar/CalEntryPeriodYearlyTest.kt @@ -23,6 +23,7 @@ class CalEntryPeriodYearlyTest { get { endMonth }.isEqualTo(7) get { endDay }.isEqualTo(6) get { createEntryCommand().command }.isEqualTo("jdev/sps/calendarcreateentry/Period every year test/1/4/7/1/7/6") + get { updateEntryCommand(this.uuid).command }.isEqualTo("jdev/sps/calendarupdateentry/1b6f49be-025c-9ba0-ffff504f94a03d3e/Period every year test/1/4/7/1/7/6") } } diff --git a/src/test/kotlin/calendar/CalEntrySingleDayTest.kt b/src/test/kotlin/calendar/CalEntrySingleDayTest.kt index 9934654..42475b1 100644 --- a/src/test/kotlin/calendar/CalEntrySingleDayTest.kt +++ b/src/test/kotlin/calendar/CalEntrySingleDayTest.kt @@ -22,6 +22,7 @@ class CalEntrySingleDayTest { get { startMonth }.isEqualTo(8) get { startDay }.isEqualTo(3) get { createEntryCommand().command }.isEqualTo("jdev/sps/calendarcreateentry/Single day test/1/2/2024/8/3") + get { updateEntryCommand(this.uuid).command }.isEqualTo("jdev/sps/calendarupdateentry/1b6f47f0-03b0-9b3d-ffff504f94a03d3e/Single day test/1/2/2024/8/3") } }