|
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
+ * @param positionX
+ * @param positionY
+ * @param character
* @param clientMac
* @param pm
* @throws SessionException
* @throws MapException
*/
private void createOrUpdateClientPositionInternal(long sessionId, String mapName, int positionX, int positionY,
- int positionZ, SignalCharacterDTO character, String clientMac, boolean fixed, PersistenceManager pm)
+ int positionZ, SignalCharacterDTO character, String clientMac, boolean fixed, HashMap<String, String> attributes, PersistenceManager pm)
throws SessionException, MapException{
checkSession(sessionId, pm);
Map map = checkMap(mapName, positionX, positionY, pm);
@@ -285,61 +332,80 @@
pos.setPosX(positionX);
pos.setPosY(positionY);
pos.setPosZ(positionZ);
+ pos.setAttributes(attributes);
logger.info("inside createOrUpdateClientPositionInternal Z-Koordinate: " + positionZ);
PositionCache.getPositionCache().createOrUpdatePosition(map, pos);
}
- /* (non-Javadoc)
- * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#createOrUpdateAccessPosition(long, java.lang.String, int, int, net.sf.magicmap.server.facade.dto.SignalCharacter, java.lang.String)
- */
- public void createOrUpdateAccessPosition(long sessionId, String mapName, int positionX, int positionY,
- int positionZ, String accessPointMac, boolean fixed) throws SessionException, MapException{
- this.logger.info("createOrUpdateAccessPosition()");
- PersistenceManager pm = null;
- Transaction tx = null;
- try {
- pm = JDOUtil.pmfactory.getPersistenceManager();
- tx = pm.currentTransaction();
- tx.begin();
- checkSession(sessionId, pm);
- Map map = checkMap(mapName, positionX, positionY, pm);
- AccessPoint ap = findOrCreateAccessPoint(accessPointMac, pm);
+// /*
+// * (non-Javadoc)
+// *
+// * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#createOrUpdateAccessPosition(long,
+// * java.lang.String, int, int,
+// * net.sf.magicmap.server.facade.dto.SignalCharacter, java.lang.String)
+// */
+// public void createOrUpdateAccessPosition(long sessionId, String mapName, int positionX, int positionY,
+// int positionZ, String accessPointMac, boolean fixed, HashMap<String, Object> attributes) throws SessionException, MapException{
+// this.logger.info("createOrUpdateAccessPosition()");
+// PersistenceManager pm = null;
+// Transaction tx = null;
+// try {
+// pm = JDOUtil.pmfactory.getPersistenceManager();
+// tx = pm.currentTransaction();
+// tx.begin();
+//
+// createOrUpdateAccessPositionInternal(sessionId, mapName, positionX, positionY, positionZ, accessPointMac,
+// 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("createOrUpdateAccessPosition() - done");
+//
+// }
- PositionDTO pos = new PositionDTO();
- if (ap != null) {
- AccessPointDTO apDTO = new AccessPointDTO();
- apDTO.setMac(ap.getMac());
- apDTO.setSsid(ap.getSsid()); // zur zeit noch nicht verwendet TODO ssid setzen
- apDTO.setHidden(ap.getHidden());
- pos.setAccessPoint(apDTO);
- }
- pos.setFixed(fixed);
- pos.setName(accessPointMac);
- pos.setPosX(positionX);
- pos.setPosY(positionY);
- pos.setPosZ(positionZ);
- PositionCache.getPositionCache().createOrUpdatePosition(map, pos);
- 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);
+ private void createOrUpdateAccessPositionInternal(long sessionId, String mapName, int positionX, int positionY,
+ int positionZ, String accessPointMac, boolean fixed, HashMap<String, String> attributes, PersistenceManager pm) throws SessionException,
+ MapException{
+ checkSession(sessionId, pm);
+ Map map = checkMap(mapName, positionX, positionY, pm);
+ AccessPoint ap = findOrCreateAccessPoint(accessPointMac, pm);
+
+ PositionDTO pos = new PositionDTO();
+ if (ap != null) {
+ AccessPointDTO apDTO = new AccessPointDTO();
+ apDTO.setMac(ap.getMac());
+ apDTO.setSsid(ap.getSsid()); // zur zeit noch nicht verwendet
+ // TODO: ssid setzen
+ apDTO.setHidden(ap.getHidden());
+ pos.setAccessPoint(apDTO);
}
- this.logger.info("createOrUpdateAccessPosition() - done");
-
+ pos.setFixed(fixed);
+ pos.setName(accessPointMac);
+ pos.setPosX(positionX);
+ pos.setPosY(positionY);
+ pos.setPosZ(positionZ);
+ pos.setAttributes(attributes);
+ PositionCache.getPositionCache().createOrUpdatePosition(map, pos);
}
- /* (non-Javadoc)
- * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#movePosition(long, long, int, int)
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#movePosition(long,
+ * long, int, int)
*/
public void movePosition(long sessionId, String mapname, long positionId, int newPositionX, int newPositionY,
int newPositionZ, boolean fixed) throws SessionException, MapException{
@@ -354,7 +420,7 @@
Map map = checkMap(mapname, newPositionX, newPositionY, pm);
PositionCache.getPositionCache().movePosition(map, positionId, newPositionX, newPositionY, newPositionZ,
fixed);
- //logger.info("Z-Koord.: " + newPositionZ);
+ // logger.info("Z-Koord.: " + newPositionZ);
if (tx.isActive()) {
tx.commit();
}
@@ -374,8 +440,11 @@
}
- /* (non-Javadoc)
- * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#deletePosition(long, long)
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#deletePosition(long,
+ * long)
*/
public void deletePosition(long sessionId, String mapname, long positionId) throws SessionException, MapException{
this.logger.info("deletePosition()");
@@ -408,11 +477,14 @@
}
- /* (non-Javadoc)
- * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#getPositionsForMapSince(long, java.lang.String, long)
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#getPositionsForMapSince(long,
+ * java.lang.String, long, boolean)
*/
- public PositionDTO[] getPositionsForMapSince(long sessionId, String mapName, long timeStamp, boolean timeflag)
- throws MapException, SessionException{
+ public PositionDTO[] getPositionsForMapSince(long sessionId, String[] types, String mapName, long timeStamp,
+ boolean timeflag) throws MapException, SessionException{
this.logger.info("getPositionsForMapSince() " + timeStamp);
PositionDTO[] result = null;
PersistenceManager pm = null;
@@ -446,8 +518,11 @@
return result;
}
- /* (non-Javadoc)
- * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#getPositionsForClientOnMap(long, java.lang.String, java.lang.String)
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sf.magicmap.server.facade.interfaces.PositionFacadeInterface#getPositionsForClientOnMap(long,
+ * java.lang.String, java.lang.String)
*/
public String getPositionForClientOnMap(long sessionId, String mapName, String clientMac) throws MapException,
SessionException, RemoteException{
@@ -508,7 +583,8 @@
if (ap != null) {
AccessPointDTO apDTO = new AccessPointDTO();
apDTO.setMac(ap.getMac());
- apDTO.setSsid(ap.getSsid()); // zur zeit noch nicht verwendet TODO ssid setzen
+ apDTO.setSsid(ap.getSsid()); // zur zeit noch nicht verwendet
+ // TODO ssid setzen
apDTO.setHidden(hidden);
pos.setAccessPoint(apDTO);
}
Modified: trunk/magicmapserver/src/net/sf/magicmap/server/interfaces/PositionFacadeInterface.java
===================================================================
--- trunk/magicmapserver/src/net/sf/magicmap/server/interfaces/PositionFacadeInterface.java 2008-01-28 13:22:14 UTC (rev 719)
+++ trunk/magicmapserver/src/net/sf/magicmap/server/interfaces/PositionFacadeInterface.java 2008-01-28 13:55:25 UTC (rev 720)
@@ -2,6 +2,7 @@
package net.sf.magicmap.server.interfaces;
import java.rmi.RemoteException;
+import java.util.HashMap;
import net.sf.magicmap.server.dto.PositionDTO;
import net.sf.magicmap.server.dto.SignalCharacterDTO;
@@ -21,53 +22,57 @@
*/
public interface PositionFacadeInterface {
- /**
- * legt eine neue Position an
- *
- * @param sessionId g\xFCltige sessionId
- * @param mapName Name der Karte
- * @param positionX x-Position im Image
- * @param positionY y-Position im Image
- * @param character Signalcharacteristik an dieser Position
- * @param Name der Position (Ort an dieser Position)
- * @throws SessionException ung\xFCltige session
- * @throws MapException Fehlende Karte, inkosistente Positionsangaben
- */
- public abstract void createOrUpdatePosition(long sessionId, String mapName, int positionX, int positionY,
- int positionZ, SignalCharacterDTO character, String positionName, boolean fixed) throws SessionException,
- MapException, RemoteException;
+ public abstract void createOrUpdatePosition(long sessionId, String type, String mapName, int positionX,
+ int positionY, int positionZ, SignalCharacterDTO character, String positionName, boolean fixed,
+ HashMap<String, String> attributes) throws SessionException, MapException, RemoteException;
- /**
- * Legt eine Position f\xFCr einen Client fest oder korrigiert diese
- *
- * @param sessionId g\xFCltige sessionId
- * @param mapName Name der Karte
- * @param positionX x-Position im Image
- * @param positionY y-Position im Image
- * @param character Signalcharacteristik an dieser Position
- * @param clientMac Macc Adresse, des zu positionierenden Clients
- * @throws SessionException ung\xFCltige session
- * @throws MapException Fehlende Karte, inkosistente Positionsangaben
- */
- public abstract void createOrUpdateClientPosition(long sessionId, String mapName, int positionX, int positionY,
- int positionZ, SignalCharacterDTO character, String clientMac, boolean fixed) throws SessionException,
- MapException, RemoteException;
+ // /**
+ // * legt eine neue Position an
+ // *
+ // * @param sessionId g\xFCltige sessionId
+ // * @param mapName Name der Karte
+ // * @param positionX x-Position im Image
+ // * @param positionY y-Position im Image
+ // * @param character Signalcharacteristik an dieser Position
+ // * @param Name der Position (Ort an dieser Position)
+ // * @throws SessionException ung\xFCltige session
+ // * @throws MapException Fehlende Karte, inkosistente Positionsangaben
+ // */
+ // public abstract void createOrUpdatePosition(long sessionId, String mapName, int positionX, int positionY,
+ // int positionZ, SignalCharacterDTO character, String positionName, boolean fixed) throws SessionException,
+ // MapException, RemoteException;
+ //
+ // /**
+ // * Legt eine Position f\xFCr einen Client fest oder korrigiert diese
+ // *
+ // * @param sessionId g\xFCltige sessionId
+ // * @param mapName Name der Karte
+ // * @param positionX x-Position im Image
+ // * @param positionY y-Position im Image
+ // * @param character Signalcharacteristik an dieser Position
+ // * @param clientMac Macc Adresse, des zu positionierenden Clients
+ // * @throws SessionException ung\xFCltige session
+ // * @throws MapException Fehlende Karte, inkosistente Positionsangaben
+ // */
+ // public abstract void createOrUpdateClientPosition(long sessionId, String mapName, int positionX, int positionY,
+ // int positionZ, SignalCharacterDTO character, String clientMac, boolean fixed) throws SessionException,
+ // MapException, RemoteException;
+ //
+ // /**
+ // * Legt eine Position f\xFCr einen AccessPoint fest oder korrigiert diese
+ // *
+ // * @param sessionId g\xFCltige sessionId
+ // * @param mapName Name der Karte
+ // * @param positionX x-Position im Image
+ // * @param positionY y-Position im Image
+ // * @param accessPointMac Macc Adresse, des zu positionierenden Clients
+ // * @throws SessionException ung\xFCltige session
+ // * @throws MapException Fehlende Karte, inkosistente Positionsangaben
+ // */
+ // public abstract void createOrUpdateAccessPosition(long sessionId, String mapName, int positionX, int positionY,
+ // int positionZ, String accessPointMac, boolean fixed) throws SessionException, MapException, RemoteException;
/**
- * Legt eine Position f\xFCr einen AccessPoint fest oder korrigiert diese
- *
- * @param sessionId g\xFCltige sessionId
- * @param mapName Name der Karte
- * @param positionX x-Position im Image
- * @param positionY y-Position im Image
- * @param accessPointMac Macc Adresse, des zu positionierenden Clients
- * @throws SessionException ung\xFCltige session
- * @throws MapException Fehlende Karte, inkosistente Positionsangaben
- */
- public abstract void createOrUpdateAccessPosition(long sessionId, String mapName, int positionX, int positionY,
- int positionZ, String accessPointMac, boolean fixed) throws SessionException, MapException, RemoteException;
-
- /**
* Verschiebt eine beliebige Position auf der Karte
*
* @param sessionId g\xFCltige session id
@@ -103,8 +108,8 @@
* @return Liste aller Positionen der Karte
* @throws MapException Fehlende Karte
*/
- public abstract PositionDTO[] getPositionsForMapSince(long sessionId, String mapName, long timeStamp,
- boolean timeflag) throws MapException, SessionException, RemoteException;
+ public abstract PositionDTO[] getPositionsForMapSince(long sessionId, String[] types, String mapName,
+ long timeStamp, boolean timeflag) throws MapException, SessionException, RemoteException;
/**
* Liefert aktuelle Position des Clients mit der angegebenen MacAdresse
Modified: trunk/magicmapserver/src/net/sf/magicmap/server/utils/Version.java
===================================================================
--- trunk/magicmapserver/src/net/sf/magicmap/server/utils/Version.java 2008-01-28 13:22:14 UTC (rev 719)
+++ trunk/magicmapserver/src/net/sf/magicmap/server/utils/Version.java 2008-01-28 13:55:25 UTC (rev 720)
@@ -14,5 +14,5 @@
*/
public interface Version {
- public static final String PROTOCOL_VERSION = "0.8";
+ public static final String PROTOCOL_VERSION = "0.9";
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|