aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-01-11 12:09:52 +1100
committerGitHub <noreply@github.com>2017-01-11 12:09:52 +1100
commit6d75b43716c252f69c19afd2c6e7a9457a32a638 (patch)
tree9808dcc2fc176e0a9ace9214836aa296312a939a /src/org/traccar
parentfec3ab90ffd6819dbad5c592f6cca8b6c16a8edc (diff)
parent21a7d70d20ac45fbf2a8d000ba8e9f93be5dd195 (diff)
downloadtrackermap-server-6d75b43716c252f69c19afd2c6e7a9457a32a638.tar.gz
trackermap-server-6d75b43716c252f69c19afd2c6e7a9457a32a638.tar.bz2
trackermap-server-6d75b43716c252f69c19afd2c6e7a9457a32a638.zip
Merge pull request #2770 from Abyss777/cleanup_calendars
Cleanup calendar model
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/model/Calendar.java21
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;
}