|
From: <fle...@us...> - 2006-10-31 15:56:39
|
Revision: 476
http://svn.sourceforge.net/magicmap/?rev=476&view=rev
Author: flederohr
Date: 2006-10-31 07:55:58 -0800 (Tue, 31 Oct 2006)
Log Message:
-----------
added rollbacks for all transactions and removed extensive logging
Modified Paths:
--------------
trunk/magicmapserver/.settings/org.eclipse.jdt.ui.prefs
trunk/magicmapserver/src/net/sf/magicmap/server/facade/MapFacade.java
trunk/magicmapserver/src/net/sf/magicmap/server/facade/PositionFacade.java
trunk/magicmapserver/src/net/sf/magicmap/server/facade/SessionFacade.java
Modified: trunk/magicmapserver/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- trunk/magicmapserver/.settings/org.eclipse.jdt.ui.prefs 2006-10-31 15:16:30 UTC (rev 475)
+++ trunk/magicmapserver/.settings/org.eclipse.jdt.ui.prefs 2006-10-31 15:55:58 UTC (rev 476)
@@ -1,6 +1,6 @@
-#Sat Jul 08 14:24:10 CEST 2006
+#Tue Oct 31 14:58:24 CET 2006
eclipse.preferences.version=1
-formatter_profile=_MagicMap Coding Conventions
+formatter_profile=_'MagicMap Coding Conventions'
formatter_settings_version=10
internal.default.compliance=default
org.eclipse.jdt.ui.exception.name=e
Modified: trunk/magicmapserver/src/net/sf/magicmap/server/facade/MapFacade.java
===================================================================
--- trunk/magicmapserver/src/net/sf/magicmap/server/facade/MapFacade.java 2006-10-31 15:16:30 UTC (rev 475)
+++ trunk/magicmapserver/src/net/sf/magicmap/server/facade/MapFacade.java 2006-10-31 15:55:58 UTC (rev 476)
@@ -64,6 +64,8 @@
}
}
JDOUtil.commit(tx);
+ } catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
} finally {
JDOUtil.closePM(pm);
}
@@ -171,6 +173,8 @@
++i;
}
JDOUtil.commit(tx);
+ } catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
} finally {
JDOUtil.closePM(pm);
}
@@ -245,6 +249,7 @@
}
JDOUtil.commit(tx);
} catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
e.printStackTrace();
if (e instanceof MapException) {
throw (MapException) e;
@@ -301,6 +306,7 @@
}
JDOUtil.commit(tx);
} catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
e.printStackTrace();
if (e instanceof MapException) {
throw (MapException) e;
@@ -398,6 +404,7 @@
}
JDOUtil.commit(tx);
} catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
e.printStackTrace();
if (e instanceof MapException) {
throw (MapException) e;
@@ -447,6 +454,7 @@
}
tx.commit();
} catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
e.printStackTrace();
if (e instanceof MapException) {
throw (MapException) e;
Modified: trunk/magicmapserver/src/net/sf/magicmap/server/facade/PositionFacade.java
===================================================================
--- trunk/magicmapserver/src/net/sf/magicmap/server/facade/PositionFacade.java 2006-10-31 15:16:30 UTC (rev 475)
+++ trunk/magicmapserver/src/net/sf/magicmap/server/facade/PositionFacade.java 2006-10-31 15:55:58 UTC (rev 476)
@@ -10,6 +10,7 @@
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
+import javax.jdo.Transaction;
import net.sf.magicmap.db.AccessPoint;
import net.sf.magicmap.db.Client;
@@ -38,15 +39,18 @@
SignalCharacterDTO character, String positionName, boolean fixed) throws SessionException, MapException{
this.logger.info("createOrUpdatePosition()");
PersistenceManager pm = null;
+ Transaction tx = null;
try {
pm = JDOUtil.pmfactory.getPersistenceManager();
- pm.currentTransaction().begin();
+ tx = pm.currentTransaction();
+ tx.begin();
createOrUpdatePositionInternal(sessionId, mapName, positionX, positionY, positionZ, character,
positionName, fixed, pm);
- if (pm.currentTransaction().isActive()) {
- pm.currentTransaction().commit();
+ if (tx.isActive()) {
+ tx.commit();
}
} catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
e.printStackTrace();
if (e instanceof MapException) {
throw (MapException) e;
@@ -97,28 +101,6 @@
pos.setPosY(positionY);
pos.setPosZ(positionZ);
PositionCache.getPositionCache().createOrUpdatePosition(map, pos, client.getMac());
-
- String string;
- int i = 0;
- try {
- FileOutputStream fs = new FileOutputStream(new File("referenzpunkt.txt"), true);
- PrintWriter pw = new PrintWriter(fs, true);
- while (i < character.getSimpleScanResults().length) {
- string = "TimeStamp: " + System.currentTimeMillis() + " SessionID: " + sessionId + " PositionName: "
- + positionName + " MapName: " + mapName + " Postition.X " + positionX + " Postition.Y "
- + positionY + " Postition.Z " + positionZ + " Fixed: " + fixed + " Character.getMacAP "
- + character.getSimpleScanResults()[i].getMacAP() + " Character.LastSeen: "
- + character.getSimpleScanResults()[i].getLastSeen() + " Character.noise "
- + character.getSimpleScanResults()[i].getNoise() + " Character.SignalLevel: "
- + character.getSimpleScanResults()[i].getSignalLevel();
- pw.println(string);
- ++i;
- }
- pw.close();
- fs.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
}
/**
@@ -145,7 +127,6 @@
}
return result;
} catch (Exception e) {
- // pm.currentTransaction().rollback();
throw new MapException("", e);
}
@@ -207,7 +188,6 @@
if (results != null && !results.isEmpty()) {
result = (Session) results.iterator().next();
} else {
- // pm.currentTransaction().rollback();
throw new SessionException("Session mit der id:" + sessionId + " existiert nicht");
}
return result;
@@ -233,7 +213,6 @@
if (results != null && !results.isEmpty()) {
result = (Client) results.iterator().next();
} else {
- // pm.currentTransaction().rollback();
throw new MapException("Client mit der mac-adresse:" + mac + " existiert nicht");
}
return result;
@@ -249,15 +228,18 @@
this.logger.info("createOrUpdateClientPosition()");
PersistenceManager pm = null;
+ Transaction tx = null;
try {
pm = JDOUtil.pmfactory.getPersistenceManager();
- pm.currentTransaction().begin();
+ tx = pm.currentTransaction();
+ tx.begin();
createOrUpdateClientPositionInternal(sessionId, mapName, positionX, positionY, positionZ, character,
clientMac, fixed, pm);
- if (pm.currentTransaction().isActive()) {
- pm.currentTransaction().commit();
+ if (tx.isActive()) {
+ tx.commit();
}
} catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
e.printStackTrace();
if (e instanceof MapException) {
throw (MapException) e;
@@ -305,31 +287,6 @@
pos.setPosZ(positionZ);
logger.info("inside createOrUpdateClientPositionInternal Z-Koordinate: " + positionZ);
PositionCache.getPositionCache().createOrUpdatePosition(map, pos);
-
- String string;
- int i = 0;
- try {
- FileOutputStream fs = new FileOutputStream(new File("client.txt"), true);
- PrintWriter pw = new PrintWriter(fs, true);
- if (character.getSimpleScanResults() != null) {
- while (i < character.getSimpleScanResults().length) {
- string = "TimeStamp: " + System.currentTimeMillis() + " SessionID: " + sessionId + " ClientMAC: "
- + clientMac + " MapName: " + mapName + " Postition.X " + positionX + " Postition.Y "
- + positionY + " Postition.Y " + positionY + " Postition.Z " + positionZ + " Fixed: "
- + fixed + " Character.getMacAP " + character.getSimpleScanResults()[i].getMacAP()
- + " Character.LastSeen: "
- //+ character.getSimpleScanResults()[i].getLastSeen() + " Character.noise "
- + character.getSimpleScanResults()[i].getNoise() + " Character.SignalLevel: "
- + character.getSimpleScanResults()[i].getSignalLevel();
- pw.println(string);
- ++i;
- }
- }
- pw.close();
- fs.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
}
/* (non-Javadoc)
@@ -339,9 +296,11 @@
int positionZ, String accessPointMac, boolean fixed) throws SessionException, MapException{
this.logger.info("createOrUpdateAccessPosition()");
PersistenceManager pm = null;
+ Transaction tx = null;
try {
pm = JDOUtil.pmfactory.getPersistenceManager();
- pm.currentTransaction().begin();
+ tx = pm.currentTransaction();
+ tx.begin();
checkSession(sessionId, pm);
Map map = checkMap(mapName, positionX, positionY, pm);
AccessPoint ap = findOrCreateAccessPoint(accessPointMac, pm);
@@ -360,10 +319,11 @@
pos.setPosY(positionY);
pos.setPosZ(positionZ);
PositionCache.getPositionCache().createOrUpdatePosition(map, pos);
- if (pm.currentTransaction().isActive()) {
- pm.currentTransaction().commit();
+ if (tx.isActive()) {
+ tx.commit();
}
} catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
e.printStackTrace();
if (e instanceof MapException) {
throw (MapException) e;
@@ -385,18 +345,21 @@
int newPositionZ, boolean fixed) throws SessionException, MapException{
this.logger.info("movePosition()");
PersistenceManager pm = null;
+ Transaction tx = null;
try {
pm = JDOUtil.pmfactory.getPersistenceManager();
- pm.currentTransaction().begin();
+ tx = pm.currentTransaction();
+ tx.begin();
checkSession(sessionId, pm);
Map map = checkMap(mapname, newPositionX, newPositionY, pm);
PositionCache.getPositionCache().movePosition(map, positionId, newPositionX, newPositionY, newPositionZ,
fixed);
//logger.info("Z-Koord.: " + newPositionZ);
- if (pm.currentTransaction().isActive()) {
- pm.currentTransaction().commit();
+ if (tx.isActive()) {
+ tx.commit();
}
} catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
e.printStackTrace();
if (e instanceof MapException) {
throw (MapException) e;
@@ -417,16 +380,19 @@
public void deletePosition(long sessionId, String mapname, long positionId) throws SessionException, MapException{
this.logger.info("deletePosition()");
PersistenceManager pm = null;
+ Transaction tx = null;
try {
pm = JDOUtil.pmfactory.getPersistenceManager();
- pm.currentTransaction().begin();
+ tx = pm.currentTransaction();
+ tx.begin();
checkSession(sessionId, pm);
Map map = checkMap(mapname, pm);
PositionCache.getPositionCache().removePosition(map, positionId);
- if (pm.currentTransaction().isActive()) {
- pm.currentTransaction().commit();
+ if (tx.isActive()) {
+ tx.commit();
}
} catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
e.printStackTrace();
if (e instanceof MapException) {
throw (MapException) e;
@@ -450,19 +416,22 @@
this.logger.info("getPositionsForMapSince() " + timeStamp);
PositionDTO[] result = null;
PersistenceManager pm = null;
+ Transaction tx = null;
try {
pm = JDOUtil.pmfactory.getPersistenceManager();
- pm.currentTransaction().begin();
+ tx = pm.currentTransaction();
+ tx.begin();
checkSession(sessionId, pm);
Map map = checkMap(mapName, pm);
result = PositionCache.getPositionCache().getPositionsForMapSince(map, timeStamp, timeflag);
for (int i = 0; i < result.length; i++) {
logger.info("Z in PositionFacade: " + result[i].getPosZ());
}
- if (pm.currentTransaction().isActive()) {
- pm.currentTransaction().commit();
+ if (tx.isActive()) {
+ tx.commit();
}
} catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
e.printStackTrace();
if (e instanceof MapException) {
throw (MapException) e;
@@ -484,20 +453,23 @@
SessionException, RemoteException{
this.logger.info("getPositionsForClientOnMap() ");
PersistenceManager pm = null;
+ Transaction tx = null;
String positionResult = null;
try {
pm = JDOUtil.pmfactory.getPersistenceManager();
- pm.currentTransaction().begin();
+ tx = pm.currentTransaction();
+ tx.begin();
checkSession(sessionId, pm);
Map map = checkMap(mapName, pm);
checkClient(clientMac, pm);
PositionDTO pos = PositionCache.getPositionCache().getPositionForClientOnMap(map, clientMac);
positionResult = String.valueOf(pos.getPosX()) + "#" + String.valueOf(pos.getPosY()) + "#"
+ String.valueOf(pos.isFixed());
- if (pm.currentTransaction().isActive()) {
- pm.currentTransaction().commit();
+ if (tx.isActive()) {
+ tx.commit();
}
} catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
e.printStackTrace();
if (e instanceof MapException) {
throw (MapException) e;
@@ -517,9 +489,11 @@
throws MapException, SessionException, RemoteException{
this.logger.info("setAccessPointHiddenStatus() ");
PersistenceManager pm = null;
+ Transaction tx = null;
try {
pm = JDOUtil.pmfactory.getPersistenceManager();
- pm.currentTransaction().begin();
+ tx = pm.currentTransaction();
+ tx.begin();
checkSession(sessionId, pm);
AccessPoint ap = findOrCreateAccessPoint(accessPointMac, pm);
ap.setHidden(hidden);
@@ -546,8 +520,9 @@
PositionCache.getPositionCache().createOrUpdatePosition(map, pos);
}
- pm.currentTransaction().commit();
+ if (tx.isActive()) tx.commit();
} catch (Exception e) {
+ if (tx.isActive()) tx.rollback();
e.printStackTrace();
if (e instanceof MapException) {
throw (MapException) e;
Modified: trunk/magicmapserver/src/net/sf/magicmap/server/facade/SessionFacade.java
===================================================================
--- trunk/magicmapserver/src/net/sf/magicmap/server/facade/SessionFacade.java 2006-10-31 15:16:30 UTC (rev 475)
+++ trunk/magicmapserver/src/net/sf/magicmap/server/facade/SessionFacade.java 2006-10-31 15:55:58 UTC (rev 476)
@@ -86,8 +86,9 @@
result = session.getId();
JDOUtil.commit(tx);
} catch (Exception e) {
+ if (tx.isActive())
+ tx.rollback();
this.logger.fatal("Fehler", e);
- JDOUtil.rollBack(tx);
throw new AuthenticationException(e.getMessage(), e);
} finally {
JDOUtil.closePM(pm);
@@ -149,8 +150,9 @@
pm.deletePersistent(session);
JDOUtil.commit(tx);
} catch (Exception e) {
+ if (tx.isActive())
+ tx.rollback();
this.logger.fatal("Fehler", e);
- JDOUtil.rollBack(tx);
throw new AuthenticationException(e.getMessage(), e);
} finally {
JDOUtil.closePM(pm);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <an...@us...> - 2008-01-28 13:55:55
|
Revision: 720
http://magicmap.svn.sourceforge.net/magicmap/?rev=720&view=rev
Author: anweiss
Date: 2008-01-28 05:55:25 -0800 (Mon, 28 Jan 2008)
Log Message:
-----------
added hashmaps for (client) nodes
Modified Paths:
--------------
trunk/magicmapserver/.classpath
trunk/magicmapserver/dblayer/src/net/sf/magicmap/db/Position.java
trunk/magicmapserver/dblayer/src/net/sf/magicmap/db/ScanResult.java
trunk/magicmapserver/src/net/sf/magicmap/server/cache/PositionCache.java
trunk/magicmapserver/src/net/sf/magicmap/server/dto/PositionDTO.java
trunk/magicmapserver/src/net/sf/magicmap/server/dto/SimpleScanResultDTO.java
trunk/magicmapserver/src/net/sf/magicmap/server/facade/PositionFacade.java
trunk/magicmapserver/src/net/sf/magicmap/server/interfaces/PositionFacadeInterface.java
trunk/magicmapserver/src/net/sf/magicmap/server/utils/Version.java
Modified: trunk/magicmapserver/.classpath
===================================================================
--- trunk/magicmapserver/.classpath 2008-01-28 13:22:14 UTC (rev 719)
+++ trunk/magicmapserver/.classpath 2008-01-28 13:55:25 UTC (rev 720)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry output="dblayer/bin" kind="src" path="dblayer/src"/>
+ <classpathentry kind="src" output="dblayer/bin" path="dblayer/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="web/WEB-INF/lib/log4j-1.2.8.jar"/>
<classpathentry kind="lib" path="web/WEB-INF/lib/jpox-20041204.032009.jar"/>
@@ -9,5 +9,10 @@
<classpathentry kind="lib" path="lib.dev/jasper-runtime.jar"/>
<classpathentry kind="lib" path="lib.dev/jsp-api.jar"/>
<classpathentry kind="lib" path="lib.dev/servlet-api.jar"/>
+ <classpathentry kind="var" path="TOMCAT_HOME/lib/servlet-api.jar"/>
+ <classpathentry kind="var" path="TOMCAT_HOME/lib/jasper.jar"/>
+ <classpathentry kind="var" path="TOMCAT_HOME/lib/jsp-api.jar"/>
+ <classpathentry kind="var" path="TOMCAT_HOME/lib/el-api.jar"/>
+ <classpathentry kind="var" path="TOMCAT_HOME/lib/annotations-api.jar"/>
<classpathentry kind="output" path="web/WEB-INF/classes"/>
</classpath>
Modified: trunk/magicmapserver/dblayer/src/net/sf/magicmap/db/Position.java
===================================================================
--- trunk/magicmapserver/dblayer/src/net/sf/magicmap/db/Position.java 2008-01-28 13:22:14 UTC (rev 719)
+++ trunk/magicmapserver/dblayer/src/net/sf/magicmap/db/Position.java 2008-01-28 13:55:25 UTC (rev 720)
@@ -5,6 +5,7 @@
package net.sf.magicmap.db;
import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
/**
@@ -38,7 +39,7 @@
* persistence-modifier="persistent"
* primary-key="true"
*/
- long id;
+ long id;
/**
*
@@ -47,7 +48,7 @@
* persistence-modifier="persistent"
* null-value="exception"
*/
- String name;
+ String name;
/**
* zugeh\xF6rige Karte
@@ -56,7 +57,7 @@
* persistence-modifier="persistent"
* null-value="exception"
*/
- Map map;
+ Map map;
/**
* x Position im Bild
@@ -65,7 +66,7 @@
* persistence-modifier="persistent"
* null-value="exception"
*/
- int posX;
+ int posX;
/**
* y Position im Bild
@@ -74,7 +75,7 @@
* persistence-modifier="persistent"
* null-value="exception"
*/
- int posY;
+ int posY;
/**
* z Position im Bild
@@ -83,7 +84,7 @@
* persistence-modifier="persistent"
* null-value="exception"
*/
- int posZ;
+ int posZ;
/**
* Zeit der loggens der Position
@@ -92,7 +93,7 @@
* persistence-modifier="persistent"
* null-value="exception"
*/
- long lastModified;
+ long lastModified;
/**
* schon gel\xF6scht?
@@ -100,7 +101,7 @@
* @jdo.field
* persistence-modifier="persistent"
*/
- int deleted;
+ int deleted;
/**
* fixiert
@@ -108,7 +109,7 @@
* @jdo.field
* persistence-modifier="persistent"
*/
- int fixed;
+ int fixed;
/**
* GridFields f\xFCr diesen Ort
@@ -119,7 +120,7 @@
* element-type="ScanResult"
* mapped-by="position"
*/
- Collection scanResults = new HashSet();
+ Collection scanResults = new HashSet();
/**
* Client, die diese Hardware haben
@@ -127,7 +128,7 @@
* @jdo.field
* persistence-modifier="persistent"
*/
- Client client;
+ Client client;
/**
* AccessPoints, die diese Hardware haben
@@ -135,15 +136,26 @@
* @jdo.field
* persistence-modifier="persistent"
*/
- AccessPoint accessPoint;
+ AccessPoint accessPoint;
/**
+ * @jdo.field
+ * persistence-modifier="persistent"
+ * collection-type="map"
+ * key-type="java.lang.String"
+ * value-type="java.lang.String"
+ * dependent="true"
+ * @jdo.join
+ */
+ java.util.Map attributes = new HashMap();
+
+ /**
*
* @param map
* @param posX
* @param posY
*/
- public Position(Map map, int posX, int posY, int posZ, String name) {
+ public Position(Map map, int posX, int posY, int posZ, String name, HashMap attributes) {
super();
this.map = map;
@@ -151,6 +163,7 @@
this.posY = posY;
this.posZ = posZ;
this.name = name;
+ this.attributes = attributes;
this.deleted = 0;
this.lastModified = System.currentTimeMillis();
@@ -310,4 +323,13 @@
this.posZ = posZ;
this.lastModified = System.currentTimeMillis();
}
+
+ public void setAttributes(HashMap<String,String> attributes){
+ this.attributes = attributes;
+ this.lastModified = System.currentTimeMillis();
+ }
+
+ public java.util.Map<String,String> getAttributes(){
+ return this.attributes;
+ }
}
\ No newline at end of file
Modified: trunk/magicmapserver/dblayer/src/net/sf/magicmap/db/ScanResult.java
===================================================================
--- trunk/magicmapserver/dblayer/src/net/sf/magicmap/db/ScanResult.java 2008-01-28 13:22:14 UTC (rev 719)
+++ trunk/magicmapserver/dblayer/src/net/sf/magicmap/db/ScanResult.java 2008-01-28 13:55:25 UTC (rev 720)
@@ -5,6 +5,7 @@
package net.sf.magicmap.db;
import java.sql.Timestamp;
+import java.util.HashMap;
/**
* @author msc
@@ -118,6 +119,18 @@
* persistence-modifier="persistent"
*/
int round = -1;
+
+ /**
+ * @jdo.field
+ * persistence-modifier="persistent"
+ * collection-type="map"
+ * key-type="java.lang.String"
+ * value-type="java.lang.String"
+ * dependent="true"
+ * @jdo.join
+ */
+ java.util.Map informations = new java.util.HashMap();
+
/**
* @param client
@@ -126,7 +139,7 @@
* @param noiseLevel
* @param logtime
*/
- public ScanResult(Client client, AccessPoint accessPoint, Double signalLevel, Double noiseLevel, Timestamp logtime) {
+ public ScanResult(Client client, AccessPoint accessPoint, Double signalLevel, Double noiseLevel, Timestamp logtime, HashMap<String,String> informations) {
super();
this.client = client;
@@ -134,6 +147,7 @@
this.signalLevel = signalLevel;
this.noiseLevel = noiseLevel;
this.logtime = logtime;
+ this.informations = informations;
}
public AccessPoint getAccessPoint(){
@@ -227,4 +241,12 @@
public void setPosition(Position position){
this.position = position;
}
+
+ public void setInformations(HashMap<String,String> informations){
+ this.informations = informations;
+ }
+
+ public HashMap<String,String> getInformations(){
+ return (new HashMap<String,String>(this.informations));
+ }
}
\ No newline at end of file
Modified: trunk/magicmapserver/src/net/sf/magicmap/server/cache/PositionCache.java
===================================================================
--- trunk/magicmapserver/src/net/sf/magicmap/server/cache/PositionCache.java 2008-01-28 13:22:14 UTC (rev 719)
+++ trunk/magicmapserver/src/net/sf/magicmap/server/cache/PositionCache.java 2008-01-28 13:55:25 UTC (rev 720)
@@ -5,6 +5,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.TreeMap;
@@ -37,7 +38,7 @@
* serial version id
*/
private static final long serialVersionUID = 1L;
- // Sigleton Hashtable
+ // Singleton Hashtable
private static final PositionCache single_positionCache = new PositionCache();
public static PositionCache getPositionCache(){
@@ -130,9 +131,9 @@
if (dtos != null) {
for (int i = 0; i < dtos.length; i++) {
AccessPoint ap = findOrCreateAccessPoint(dtos[i].getMacAP(), pm);
- //@TODO think about? ap.setSsid(dtos[i].getSsid());
+ // @TODO think about? ap.setSsid(dtos[i].getSsid());
ScanResult sr = new ScanResult(client, ap, dtos[i].getSignalLevel(), dtos[i].getNoise(), new Timestamp(
- dto.getLastModified()));
+ dto.getLastModified()), dtos[i].getInfos());
pm.makePersistent(sr);
sr.setPosition(pos);
}
@@ -150,15 +151,17 @@
Map map = checkMap(mapName, pm);
Position pos = checkPosition(position.getName(), map, pm);
if (pos == null) {
- pos = new Position(map, position.getPosX(), position.getPosY(), position.getPosZ(), position.getName());
+ pos = new Position(map, position.getPosX(), position.getPosY(), position.getPosZ(), position.getName(),
+ position.getAttributes());
logger.info("Position in db z: " + pos.getPosZ());
pm.makePersistent(pos);
+ } else {
+ pos.setPosX(position.getPosX());
+ pos.setPosY(position.getPosY());
+ pos.setPosZ(position.getPosZ());
+ pos.setAttributes(position.getAttributes());
}
pos.setDeleted(position.isDeleted());
- pos.setPosX(position.getPosX());
- pos.setPosY(position.getPosY());
- pos.setPosZ(position.getPosZ());
-
pos.setFixed(position.isFixed());
if (position.getClient() != null) {
@@ -261,10 +264,11 @@
while (scanIt.hasNext()) {
ScanResult sr = (ScanResult) scanIt.next();
- // Date lastSeen = null;
- // if (sr.getScantime() != null){
- // lastSeen = new Date(sr.getScantime().getTime());
- // }
+ // Date lastSeen = null;
+ // if (sr.getScantime() != null){
+ // lastSeen = new
+ // Date(sr.getScantime().getTime());
+ // }
SimpleScanResultDTO ssr = new SimpleScanResultDTO();
@@ -274,6 +278,7 @@
ssr.setNoise(sr.getNoiseLevel());
ssr.setSignalLevel(sr.getSignalLevel());
ssr.setSsid(sr.getAccessPoint().getSsid());
+ ssr.setInfos(sr.getInformations());
ArrayList<SimpleScanResultDTO> list;
if (dto.getCharacter().getSimpleScanResults() == null) {
@@ -288,6 +293,7 @@
(SimpleScanResultDTO[]) list.toArray(new SimpleScanResultDTO[0]));
}
}
+ HashMap attributes = new HashMap(pos.getAttributes());
getMapHashtable(map).addPositionFromDB(dto);
}
}
@@ -523,7 +529,7 @@
logger.info("leaving getPositionsSince()");
return positions.toArray(new PositionDTO[0]);
} else {
- Collection<String> newPositions = timeMap.tailMap(time+1).values();
+ Collection<String> newPositions = timeMap.tailMap(time + 1).values();
logger.info("Daten in timeMap: " + timeMap.toString());
logger.info("Daten in tailMap: " + newPositions.toString());
PositionDTO[] positions = new PositionDTO[newPositions.size()];
Modified: trunk/magicmapserver/src/net/sf/magicmap/server/dto/PositionDTO.java
===================================================================
--- trunk/magicmapserver/src/net/sf/magicmap/server/dto/PositionDTO.java 2008-01-28 13:22:14 UTC (rev 719)
+++ trunk/magicmapserver/src/net/sf/magicmap/server/dto/PositionDTO.java 2008-01-28 13:55:25 UTC (rev 720)
@@ -1,31 +1,33 @@
package net.sf.magicmap.server.dto;
+import java.util.HashMap;
+
/**
- * author schweige
- * date 03.12.2004
- * copyright (C) 2004 Martin Schweigert, Tobias H\xFCbner
+ * author schweige date 03.12.2004 copyright (C) 2004 Martin Schweigert, Tobias
+ * H\xFCbner
*
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
*/
public class PositionDTO {
- private Long id;
- private boolean deleted;
- private Long lastModified;
- private Integer posX;
- private Integer posY;
- private Integer posZ;
- private String name;
- private SignalCharacterDTO character;
- private boolean fixed;
+ private Long id;
+ private boolean deleted;
+ private Long lastModified;
+ private Integer posX;
+ private Integer posY;
+ private Integer posZ;
+ private String name;
+ private SignalCharacterDTO character;
+ private boolean fixed;
+ private HashMap<String, String> attributes;
- private AccessPointDTO accessPoint;
- private ClientDTO client;
+ private AccessPointDTO accessPoint;
+ private ClientDTO client;
public PositionDTO() {
//
@@ -87,7 +89,8 @@
this.posY = posY;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see net.sf.magicmap.server.facade.dto.DTO#getCSEP()
*/
protected String getCSEP(){
@@ -186,4 +189,21 @@
public void setPosZ(Integer posZ){
this.posZ = posZ;
}
+
+ /**
+ * @return Returns the infos
+ */
+ public HashMap<String, String> getAttributes(){
+ return this.attributes;
+ }
+
+ /**
+ * Sets the infos for this position.
+ *
+ * @param newInfos The new informations for this position.
+ */
+ public void setAttributes(HashMap<String, String> attributes){
+ this.attributes = attributes;
+ }
+
}
\ No newline at end of file
Modified: trunk/magicmapserver/src/net/sf/magicmap/server/dto/SimpleScanResultDTO.java
===================================================================
--- trunk/magicmapserver/src/net/sf/magicmap/server/dto/SimpleScanResultDTO.java 2008-01-28 13:22:14 UTC (rev 719)
+++ trunk/magicmapserver/src/net/sf/magicmap/server/dto/SimpleScanResultDTO.java 2008-01-28 13:55:25 UTC (rev 720)
@@ -1,6 +1,8 @@
package net.sf.magicmap.server.dto;
+import java.util.HashMap;
+
/**
* author schweige
* date 03.12.2004
@@ -14,11 +16,12 @@
*/
public class SimpleScanResultDTO {
- protected String ssid; // WLAN-Name (optional)
- protected String macAP; // MAC-Adresse AccessPoint
- protected Double signalLevel; // Signallevel in dB (negativer Wert)
- protected Double noise; // Signal-Rausch-Abstand (optional)
- protected Long lastSeen; // (optional)
+ protected String ssid; // WLAN-Name (optional)
+ protected String macAP; // MAC-Adresse AccessPoint
+ protected Double signalLevel; // Signallevel in dB (negativer Wert)
+ protected Double noise; // Signal-Rausch-Abstand (optional)
+ protected Long lastSeen; // (optional)
+ protected HashMap<String, String> infos; //additional informations for this scanresult
public SimpleScanResultDTO() {
@@ -93,4 +96,16 @@
public void setSignalLevel(Double signalLevel){
this.signalLevel = signalLevel;
}
+
+ /**
+ * @return infos The additional informations.
+ */
+ public HashMap<String, String> getInfos(){
+ return this.infos;
+ }
+
+ public void setInfos(HashMap<String, String> newInfos){
+ this.infos = newInfos;
+ }
+
}
\ No newline at end of file
Modified: trunk/magicmapserver/src/net/sf/magicmap/server/facade/PositionFacade.java
===================================================================
--- trunk/magicmapserver/src/net/sf/magicmap/server/facade/PositionFacade.java 2008-01-28 13:22:14 UTC (rev 719)
+++ trunk/magicmapserver/src/net/sf/magicmap/server/facade/PositionFacade.java 2008-01-28 13:55:25 UTC (rev 720)
@@ -6,7 +6,9 @@
import java.io.PrintWriter;
import java.rmi.RemoteException;
import java.util.Collection;
+import java.util.HashMap;
+import javax.jdo.CreateLifecycleListener;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
@@ -32,78 +34,7 @@
protected transient Category logger = Category.getInstance(this.getClass());
- /* (non-Javadoc)
- * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#createPosition(long, java.lang.String, int, int, net.sf.magicmap.server.facade.dto.SignalCharacter, java.lang.String)
- */
- public void createOrUpdatePosition(long sessionId, String mapName, int positionX, int positionY, int positionZ,
- SignalCharacterDTO character, String positionName, boolean fixed) throws SessionException, MapException{
- this.logger.info("createOrUpdatePosition()");
- PersistenceManager pm = null;
- Transaction tx = null;
- try {
- pm = JDOUtil.pmfactory.getPersistenceManager();
- tx = pm.currentTransaction();
- tx.begin();
- createOrUpdatePositionInternal(sessionId, mapName, positionX, positionY, positionZ, character,
- positionName, fixed, pm);
- if (tx.isActive()) {
- tx.commit();
- }
- } catch (Exception e) {
- if (tx.isActive()) tx.rollback();
- e.printStackTrace();
- if (e instanceof MapException) {
- throw (MapException) e;
- }
- if (e instanceof SessionException) {
- throw (SessionException) e;
- }
- } finally {
- JDOUtil.closePM(pm);
- }
- this.logger.info("createOrUpdatePosition() - done");
-
- }
-
/**
- * @param sessionId
- * @param mapName
- * @param positionX
- * @param positionY
- * @param character
- * @param positionName
- * @param pm
- * @throws SessionException
- * @throws MapException
- */
- private void createOrUpdatePositionInternal(long sessionId, String mapName, int positionX, int positionY,
- int positionZ, SignalCharacterDTO character, String positionName, boolean fixed, PersistenceManager pm)
- throws SessionException, MapException{
- Session session = checkSession(sessionId, pm);
- Client client = session.getClient();
- if (client == null) {
- throw new SessionException("Ung\xFCltige Session");
- }
- if (character == null || character.getSimpleScanResults() == null
- || character.getSimpleScanResults().length == 0) {
- throw new MapException("Signalcharacter enth\xE4lt keine Daten");
- }
- if (positionName == null || "".equals(positionName)) {
- throw new MapException("Name der Position darf nicht leer sein");
- }
- Map map = checkMap(mapName, positionX, positionY, pm);
-
- PositionDTO pos = new PositionDTO();
- pos.setCharacter(character);
- pos.setFixed(fixed);
- pos.setName(positionName);
- pos.setPosX(positionX);
- pos.setPosY(positionY);
- pos.setPosZ(positionZ);
- PositionCache.getPositionCache().createOrUpdatePosition(map, pos, client.getMac());
- }
-
- /**
* @param macAP
* @param pm
* @return
@@ -144,7 +75,7 @@
Map result = checkMap(mapName, pm);
if (positionX < 0 || positionY < 0 || positionX > (result.getImageWidth().intValue() - 1)
|| positionY > (result.getImageHeight().intValue() - 1)) {
- // pm.currentTransaction().rollback();
+ // pm.currentTransaction().rollback();
throw new MapException("Position ist nicht auf der Karte");
}
return result;
@@ -201,7 +132,7 @@
*/
private Client checkClient(String mac, PersistenceManager pm) throws MapException{
if (mac == null || "".equals(mac)) {
- // pm.currentTransaction().rollback();
+ // pm.currentTransaction().rollback();
throw new MapException("Client mac darf nicht leer sein");
}
Client result = null;
@@ -219,25 +150,26 @@
}
- /* (non-Javadoc)
- * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#createOrUpdateClientPosition(long, java.lang.String, int, int, net.sf.magicmap.server.facade.dto.SignalCharacter, java.lang.String)
- */
- public void createOrUpdateClientPosition(long sessionId, String mapName, int positionX, int positionY,
- int positionZ, SignalCharacterDTO character, String clientMac, boolean fixed) throws SessionException,
- MapException{
- this.logger.info("createOrUpdateClientPosition()");
-
+ // TODO: use the extra attributes!
+ public void createOrUpdatePosition(long sessionId, String type, String mapName, int positionX, int positionY, int positionZ,
+ SignalCharacterDTO character, String identifier, boolean fixed, HashMap<String, String> attributes) throws SessionException, MapException{
PersistenceManager pm = null;
Transaction tx = null;
- try {
+ System.out.println("CreateOrUpdate " + type );
+ try{
pm = JDOUtil.pmfactory.getPersistenceManager();
tx = pm.currentTransaction();
tx.begin();
- createOrUpdateClientPositionInternal(sessionId, mapName, positionX, positionY, positionZ, character,
- clientMac, fixed, pm);
- if (tx.isActive()) {
- tx.commit();
- }
+ if (type.equals("POSITION"))
+ createOrUpdatePositionInternal(sessionId, mapName, positionX, positionY, positionZ, character, identifier, fixed, attributes, pm);
+ else if (type.equals("CLIENT"))
+ createOrUpdateClientPositionInternal(sessionId, mapName, positionX, positionY, positionZ, character, identifier, fixed, attributes, pm);
+ else if (type.equals("ACCESSPOINT"))
+ createOrUpdateAccessPositionInternal(sessionId, mapName, positionX, positionY, positionZ, identifier, fixed, attributes, pm);
+
+ if(tx.isActive()) {
+ tx.commit();
+ }
} catch (Exception e) {
if (tx.isActive()) tx.rollback();
e.printStackTrace();
@@ -250,23 +182,138 @@
} finally {
JDOUtil.closePM(pm);
}
+ this.logger.info("createOrUpdatePositionGeneric() - done");
- this.logger.info("createOrUpdateClientPosition() - done");
}
+// /*
+// * (non-Javadoc)
+// *
+// * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#createPosition(long,
+// * java.lang.String, int, int,
+// * net.sf.magicmap.server.facade.dto.SignalCharacter, java.lang.String)
+// */
+// public void createOrUpdatePosition(long sessionId, String mapName, int positionX, int positionY, int positionZ,
+// SignalCharacterDTO character, String positionName, boolean fixed, HashMap<String, Object> attributes) throws SessionException, MapException{
+// this.logger.info("createOrUpdatePosition()");
+// PersistenceManager pm = null;
+// Transaction tx = null;
+// try {
+// pm = JDOUtil.pmfactory.getPersistenceManager();
+// tx = pm.currentTransaction();
+// tx.begin();
+// createOrUpdatePositionInternal(sessionId, mapName, positionX, positionY, positionZ, character,
+// positionName, fixed, attributes, pm);
+// if (tx.isActive()) {
+// tx.commit();
+// }
+// } catch (Exception e) {
+// if (tx.isActive()) tx.rollback();
+// e.printStackTrace();
+// if (e instanceof MapException) {
+// throw (MapException) e;
+// }
+// if (e instanceof SessionException) {
+// throw (SessionException) e;
+// }
+// } finally {
+// JDOUtil.closePM(pm);
+// }
+// this.logger.info("createOrUpdatePosition() - done");
+//
+// }
+
/**
* @param sessionId
* @param mapName
* @param positionX
* @param positionY
* @param character
+ * @param positionName
+ * @param pm
+ * @throws SessionException
+ * @throws MapException
+ */
+ private void createOrUpdatePositionInternal(long sessionId, String mapName, int positionX, int positionY,
+ int positionZ, SignalCharacterDTO character, String positionName, boolean fixed, HashMap<String, String> attributes, PersistenceManager pm)
+ throws SessionException, MapException{
+ Session session = checkSession(sessionId, pm);
+ Client client = session.getClient();
+ if (client == null) {
+ throw new SessionException("Ung\xFCltige Session");
+ }
+ if (character == null || character.getSimpleScanResults() == null
+ || character.getSimpleScanResults().length == 0) {
+ throw new MapException("Signalcharacter enth\xE4lt keine Daten");
+ }
+ if (positionName == null || "".equals(positionName)) {
+ throw new MapException("Name der Position darf nicht leer sein");
+ }
+ Map map = checkMap(mapName, positionX, positionY, pm);
+
+ PositionDTO pos = new PositionDTO();
+ pos.setCharacter(character);
+ pos.setFixed(fixed);
+ pos.setName(positionName);
+ pos.setPosX(positionX);
+ pos.setPosY(positionY);
+ pos.setPosZ(positionZ);
+ pos.setAttributes(attributes);
+ PositionCache.getPositionCache().createOrUpdatePosition(map, pos, client.getMac());
+ }
+
+// /*
+// * (non-Javadoc)
+// *
+// * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#createOrUpdateClientPosition(long,
+// * java.lang.String, int, int,
+// * net.sf.magicmap.server.facade.dto.SignalCharacter, java.lang.String)
+// */
+// public void createOrUpdateClientPosition(long sessionId, String mapName, int positionX, int positionY,
+// int positionZ, SignalCharacterDTO character, String clientMac, boolean fixed, HashMap<String, Object> attributes) throws SessionException,
+// MapException{
+// this.logger.info("createOrUpdateClientPosition()");
+//
+// PersistenceManager pm = null;
+// Transaction tx = null;
+// try {
+// pm = JDOUtil.pmfactory.getPersistenceManager();
+// tx = pm.currentTransaction();
+// tx.begin();
+// createOrUpdateClientPositionInternal(sessionId, mapName, positionX, positionY, positionZ, character,
+// clientMac, fixed, attributes, pm);
+// if (tx.isActive()) {
+// tx.commit();
+// }
+// } catch (Exception e) {
+// if (tx.isActive()) tx.rollback();
+// e.printStackTrace();
+// if (e instanceof MapException) {
+// throw (MapException) e;
+// }
+// if (e instanceof SessionException) {
+// throw (SessionException) e;
+// }
+// } finally {
+// JDOUtil.closePM(pm);
+// }
+//
+// this.logger.info("createOrUpdateClientPosition() - done");
+// }
+
+ /**
+ * @param sessionId
+ * @param mapName
+ * @p...
[truncated message content] |