aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-01-10 13:30:57 +0500
committerAbyss777 <abyss@fox5.ru>2017-01-10 13:30:57 +0500
commit21a7d70d20ac45fbf2a8d000ba8e9f93be5dd195 (patch)
tree9808dcc2fc176e0a9ace9214836aa296312a939a
parentfec3ab90ffd6819dbad5c592f6cca8b6c16a8edc (diff)
downloadtrackermap-server-21a7d70d20ac45fbf2a8d000ba8e9f93be5dd195.tar.gz
trackermap-server-21a7d70d20ac45fbf2a8d000ba8e9f93be5dd195.tar.bz2
trackermap-server-21a7d70d20ac45fbf2a8d000ba8e9f93be5dd195.zip
- Rename calendarData to data
- Cleanup Calendar model - Fix TripsTest
-rw-r--r--schema/changelog-3.10.xml2
-rw-r--r--setup/default.xml6
-rw-r--r--src/org/traccar/model/Calendar.java21
-rw-r--r--test/org/traccar/calendar/CalendarTest.java2
-rw-r--r--test/org/traccar/reports/TripsTest.java5
5 files changed, 16 insertions, 20 deletions
diff --git a/schema/changelog-3.10.xml b/schema/changelog-3.10.xml
index 996b2dc6a..d39b36112 100644
--- a/schema/changelog-3.10.xml
+++ b/schema/changelog-3.10.xml
@@ -15,7 +15,7 @@
<column name="name" type="VARCHAR(128)">
<constraints nullable="false" />
</column>
- <column name="calendardata" type="BLOB">
+ <column name="data" type="BLOB">
<constraints nullable="false" />
</column>
<column name="attributes" type="VARCHAR(4000)">
diff --git a/setup/default.xml b/setup/default.xml
index 81d7e6968..9f15e2f4b 100644
--- a/setup/default.xml
+++ b/setup/default.xml
@@ -322,14 +322,14 @@
</entry>
<entry key='database.insertCalendar'>
- INSERT INTO calendars (name, calendarData, attributes)
- VALUES (:name, :calendarData, :attributes)
+ INSERT INTO calendars (name, data, attributes)
+ VALUES (:name, :data, :attributes)
</entry>
<entry key='database.updateCalendar'>
UPDATE calendars SET
name = :name,
- calendarData = :calendarData,
+ data = :data,
attributes = :attributes
WHERE id = :id
</entry>
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;
}
diff --git a/test/org/traccar/calendar/CalendarTest.java b/test/org/traccar/calendar/CalendarTest.java
index 7f5bd7d29..0c8e1830b 100644
--- a/test/org/traccar/calendar/CalendarTest.java
+++ b/test/org/traccar/calendar/CalendarTest.java
@@ -42,7 +42,7 @@ public class CalendarTest {
"END:VEVENT\n" +
"END:VCALENDAR";
Calendar calendar = new Calendar();
- calendar.setCalendarData(calendarString.getBytes());
+ calendar.setData(calendarString.getBytes());
DateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ssX");
Date date = format.parse("2016-12-13 22:59:59+05");
diff --git a/test/org/traccar/reports/TripsTest.java b/test/org/traccar/reports/TripsTest.java
index 8adb1ceb0..dea101cf2 100644
--- a/test/org/traccar/reports/TripsTest.java
+++ b/test/org/traccar/reports/TripsTest.java
@@ -1,7 +1,7 @@
package org.traccar.reports;
-import org.junit.Ignore;
import org.junit.Test;
+import org.traccar.BaseTest;
import org.traccar.model.Position;
import org.traccar.reports.model.TripReport;
@@ -17,7 +17,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-public class TripsTest {
+public class TripsTest extends BaseTest {
private Date date(String time) throws ParseException {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
@@ -39,7 +39,6 @@ public class TripsTest {
return position;
}
- @Ignore
@Test
public void testDetectTripsSimple() throws ParseException {