diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-06-02 18:49:33 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-06-02 18:49:33 +1200 |
commit | f1466358d853516cd69a6effc678798f2b7ec20b (patch) | |
tree | deae5f432bb570d24b4bfb39a70aa9b73bbde270 /src/org/traccar/TrackerEventHandler.java | |
parent | d6429d5f2b23db26b9f1fba2918a4c2cbc75eaf4 (diff) | |
download | trackermap-server-f1466358d853516cd69a6effc678798f2b7ec20b.tar.gz trackermap-server-f1466358d853516cd69a6effc678798f2b7ec20b.tar.bz2 trackermap-server-f1466358d853516cd69a6effc678798f2b7ec20b.zip |
Re-factor old database methods
Diffstat (limited to 'src/org/traccar/TrackerEventHandler.java')
-rw-r--r-- | src/org/traccar/TrackerEventHandler.java | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/org/traccar/TrackerEventHandler.java b/src/org/traccar/TrackerEventHandler.java index 8d8a03e35..eee866a6d 100644 --- a/src/org/traccar/TrackerEventHandler.java +++ b/src/org/traccar/TrackerEventHandler.java @@ -16,19 +16,20 @@ package org.traccar; import java.util.List; -import org.jboss.netty.channel.*; +import org.jboss.netty.channel.ChannelHandler; +import org.jboss.netty.channel.ChannelHandlerContext; +import org.jboss.netty.channel.ChannelStateEvent; +import org.jboss.netty.channel.ExceptionEvent; +import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler; import org.jboss.netty.handler.timeout.IdleStateEvent; -import org.traccar.database.DataCache; import org.traccar.helper.Log; -import org.traccar.database.DataManager; -import org.traccar.model.Event; import org.traccar.model.Position; @ChannelHandler.Sharable public class TrackerEventHandler extends IdleStateAwareChannelHandler { - private Long processSinglePosition(Position position) { + private void processSinglePosition(Position position) { if (position == null) { Log.info("processSinglePosition null message"); } else { @@ -40,14 +41,11 @@ public class TrackerEventHandler extends IdleStateAwareChannelHandler { Log.info(s.toString()); } - // Write position to database - Long id = null; try { - id = Context.getDataManager().addPosition(position); + Context.getDataManager().addPosition(position); } catch (Exception error) { Log.warning(error); } - return id; } @Override @@ -55,18 +53,18 @@ public class TrackerEventHandler extends IdleStateAwareChannelHandler { Long id = null; Position lastPostition = null; if (e.getMessage() instanceof Position) { - id = processSinglePosition((Position) e.getMessage()); + processSinglePosition((Position) e.getMessage()); lastPostition = (Position) e.getMessage(); } else if (e.getMessage() instanceof List) { List<Position> positions = (List<Position>) e.getMessage(); for (Position position : positions) { - id = processSinglePosition(position); + processSinglePosition(position); lastPostition = position; } } if (lastPostition != null) { try { - Context.getDataManager().updateLatestPosition(lastPostition, id); + Context.getDataManager().updateLatestPosition(lastPostition); Context.getDataCache().update(lastPostition); } catch (Exception error) { Log.warning(error); |