diff options
author | Abyss777 <abyss@fox5.ru> | 2017-01-10 13:30:57 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-01-10 13:30:57 +0500 |
commit | 21a7d70d20ac45fbf2a8d000ba8e9f93be5dd195 (patch) | |
tree | 9808dcc2fc176e0a9ace9214836aa296312a939a /src/org/traccar/model | |
parent | fec3ab90ffd6819dbad5c592f6cca8b6c16a8edc (diff) | |
download | trackermap-server-21a7d70d20ac45fbf2a8d000ba8e9f93be5dd195.tar.gz trackermap-server-21a7d70d20ac45fbf2a8d000ba8e9f93be5dd195.tar.bz2 trackermap-server-21a7d70d20ac45fbf2a8d000ba8e9f93be5dd195.zip |
- Rename calendarData to data
- Cleanup Calendar model
- Fix TripsTest
Diffstat (limited to 'src/org/traccar/model')
-rw-r--r-- | src/org/traccar/model/Calendar.java | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/org/traccar/model/Calendar.java b/src/org/traccar/model/Calendar.java index 19b5fde16..94f6bc2a3 100644 --- a/src/org/traccar/model/Calendar.java +++ b/src/org/traccar/model/Calendar.java @@ -18,7 +18,6 @@ package org.traccar.model; import java.io.ByteArrayInputStream; import java.io.IOException; -import java.sql.SQLException; import java.util.Collection; import java.util.Date; @@ -29,12 +28,10 @@ import net.fortuna.ical4j.data.ParserException; import net.fortuna.ical4j.filter.Filter; import net.fortuna.ical4j.filter.PeriodRule; import net.fortuna.ical4j.filter.Rule; -import net.fortuna.ical4j.model.Component; import net.fortuna.ical4j.model.DateTime; import net.fortuna.ical4j.model.Dur; import net.fortuna.ical4j.model.Period; import net.fortuna.ical4j.model.component.CalendarComponent; -import net.fortuna.ical4j.validate.ValidationException; public class Calendar extends Extensible { @@ -48,16 +45,16 @@ public class Calendar extends Extensible { this.name = name; } - private byte[] calendarData; + private byte[] data; - public byte[] getCalendarData() throws ValidationException, IOException { - return calendarData.clone(); + public byte[] getData() { + return data.clone(); } - public void setCalendarData(byte[] calendarData) throws IOException, ParserException, SQLException { + public void setData(byte[] data) throws IOException, ParserException { CalendarBuilder builder = new CalendarBuilder(); - calendar = builder.build(new ByteArrayInputStream(calendarData)); - this.calendarData = calendarData.clone(); + calendar = builder.build(new ByteArrayInputStream(data)); + this.data = data.clone(); } private net.fortuna.ical4j.model.Calendar calendar; @@ -70,9 +67,9 @@ public class Calendar extends Extensible { public boolean checkMoment(Date date) { if (calendar != null) { Period period = new Period(new DateTime(date), new Dur(0, 0, 0, 0)); - Rule<Component> periodRule = new PeriodRule<Component>(period); - Filter<CalendarComponent> filter = new Filter<CalendarComponent>(new Rule[] {periodRule}, Filter.MATCH_ANY); - Collection<CalendarComponent> events = filter.filter(calendar.getComponents(Component.VEVENT)); + Rule<CalendarComponent> periodRule = new PeriodRule<>(period); + Filter<CalendarComponent> filter = new Filter<>(new Rule[] {periodRule}, Filter.MATCH_ANY); + Collection<CalendarComponent> events = filter.filter(calendar.getComponents(CalendarComponent.VEVENT)); if (events != null && !events.isEmpty()) { return true; } |