com.partnersoft.maps.database
Class RoverDatabase

java.lang.Object
  extended by com.partnersoft.maps.database.RoverDatabase

public class RoverDatabase
extends java.lang.Object

Rover format data storage in an SQL database.

Copyright 2008 Partner Software, Inc.

Version:
$Id$
Author:
Paul Reavis

Constructor Summary
RoverDatabase()
           
RoverDatabase(SqlDatabase database)
           
RoverDatabase(java.lang.String path)
           
 
Method Summary
 int addEntity(java.lang.String frontendName, java.lang.String fileName, java.lang.String objectId, RoverEntity entity)
           
 void addFieldToDataTable(java.lang.String dataTypeName, java.lang.String fieldName, java.lang.String fieldDataType)
           
 void addFindItem(java.lang.String findName, java.lang.String itemName, int dataId)
           
 int addImageFile(byte[] imageBytes)
          This currently uses a trick - it creates a GUID by checksumming the bytes, and doesn't insert a new record if there is already one with the same checksum.
 RoverImageFile addImageFile(VfsFile file)
           
 void addRoverImage(VfsFile file, XyPoint center, double scale)
           
 RoverBytesInput areaBytesForEntityId(int id)
           
 RoverBytesSqlInput areaBytesIn(XyBounds bounds, double maximumScale)
           
 RoverBytesInput bytesForEntityId(int id)
           
 void clearTables()
           
 void close()
           
 void createDataTable(java.lang.String dataTypeName)
           
 void createTables()
           
 Naming dataForGuid(java.lang.String guid)
           
 Naming dataForId(int id)
           
 void dropTables()
           
 RoverEntity entityFor(int id)
           
 RoverAreaShapeTable getAreaTable()
           
 RoverCodec getCodec()
           
 SqlConnection getConnection()
           
 RoverDataTable getDataTable()
           
 int getEntityCount()
           
 RoverImageShapeTable getImageTable()
           
 RoverLineShapeTable getLineTable()
           
 RoverPointShapeTable getPointTable()
           
 RoverTextShapeTable getTextTable()
           
 RoverCodec getTiledCodec()
           
 RoverBytesInput imageBytesForEntityId(int id)
           
 RoverBytesSqlInput imageBytesIn(XyBounds bounds, double maximumScale)
           
 ImageSource imageSourceForId(int id)
           
 RoverBytesInput lineBytesForEntityId(int id)
           
 RoverBytesSqlInput lineBytesIn(XyBounds bounds, double maximumScale)
           
 java.util.List<byte[]> listBytes()
           
 java.util.List<byte[]> listBytesIn(XyBounds bounds, double maximumScale)
           
 java.util.List<RoverShape> listShapes()
           
 java.util.List<RoverShape> listShapesIn(XyBounds bounds, double maximumScale)
           
 void open()
           
 RoverBytesInput pointBytesForEntityId(int id)
           
 RoverBytesSqlInput pointBytesIn(XyBounds bounds, double maximumScale)
           
 void reloadFindItems(Naming<FindItemIndex> findItems)
           
 void removeByEntity(java.lang.String frontendName, java.lang.String fileName, java.lang.String entityName)
           
 void removeByFile(java.lang.String frontendName, java.lang.String fileName)
           
 void removeByFrontend(java.lang.String frontendName)
           
 RoverBytesInput textBytesForEntityId(int id)
           
 RoverBytesSqlInput textBytesIn(XyBounds bounds, double maximumScale)
           
 void updateMaximumScales(float[] areaMaximumScales, float[] imageMaximumScales, float[] lineMaximumScales, float[] pointMaximumScales, float[] textMaximumScales)
           
 void updateTiles()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoverDatabase

public RoverDatabase(java.lang.String path)
              throws java.sql.SQLException
Throws:
java.sql.SQLException

RoverDatabase

public RoverDatabase(SqlDatabase database)

RoverDatabase

public RoverDatabase()
Method Detail

open

public void open()
          throws java.sql.SQLException
Throws:
java.sql.SQLException

createTables

public void createTables()
                  throws java.sql.SQLException
Throws:
java.sql.SQLException

dropTables

public void dropTables()
                throws java.sql.SQLException
Throws:
java.sql.SQLException

clearTables

public void clearTables()
                 throws java.sql.SQLException
Throws:
java.sql.SQLException

close

public void close()
           throws java.sql.SQLException
Throws:
java.sql.SQLException

createDataTable

public void createDataTable(java.lang.String dataTypeName)
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

addFieldToDataTable

public void addFieldToDataTable(java.lang.String dataTypeName,
                                java.lang.String fieldName,
                                java.lang.String fieldDataType)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

dataForId

public Naming dataForId(int id)

dataForGuid

public Naming dataForGuid(java.lang.String guid)
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

removeByFrontend

public void removeByFrontend(java.lang.String frontendName)
                      throws java.sql.SQLException
Throws:
java.sql.SQLException

removeByFile

public void removeByFile(java.lang.String frontendName,
                         java.lang.String fileName)
                  throws java.sql.SQLException
Throws:
java.sql.SQLException

removeByEntity

public void removeByEntity(java.lang.String frontendName,
                           java.lang.String fileName,
                           java.lang.String entityName)
                    throws java.sql.SQLException
Throws:
java.sql.SQLException

addImageFile

public RoverImageFile addImageFile(VfsFile file)
                            throws java.io.IOException,
                                   java.sql.SQLException
Throws:
java.io.IOException
java.sql.SQLException

addImageFile

public int addImageFile(byte[] imageBytes)
                 throws java.io.IOException,
                        java.sql.SQLException
This currently uses a trick - it creates a GUID by checksumming the bytes, and doesn't insert a new record if there is already one with the same checksum. This may or may not be appropriate, but should be more efficient.

Parameters:
imageBytes -
Returns:
Throws:
java.io.IOException
java.sql.SQLException

addRoverImage

public void addRoverImage(VfsFile file,
                          XyPoint center,
                          double scale)
                   throws java.io.IOException,
                          java.sql.SQLException
Throws:
java.io.IOException
java.sql.SQLException

addEntity

public int addEntity(java.lang.String frontendName,
                     java.lang.String fileName,
                     java.lang.String objectId,
                     RoverEntity entity)
              throws java.sql.SQLException,
                     java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

addFindItem

public void addFindItem(java.lang.String findName,
                        java.lang.String itemName,
                        int dataId)
                 throws java.sql.SQLException,
                        java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

imageSourceForId

public ImageSource imageSourceForId(int id)

listShapes

public java.util.List<RoverShape> listShapes()

listShapesIn

public java.util.List<RoverShape> listShapesIn(XyBounds bounds,
                                               double maximumScale)

listBytes

public java.util.List<byte[]> listBytes()

listBytesIn

public java.util.List<byte[]> listBytesIn(XyBounds bounds,
                                          double maximumScale)

updateTiles

public void updateTiles()
                 throws java.sql.SQLException
Throws:
java.sql.SQLException

areaBytesIn

public RoverBytesSqlInput areaBytesIn(XyBounds bounds,
                                      double maximumScale)

lineBytesIn

public RoverBytesSqlInput lineBytesIn(XyBounds bounds,
                                      double maximumScale)

imageBytesIn

public RoverBytesSqlInput imageBytesIn(XyBounds bounds,
                                       double maximumScale)

pointBytesIn

public RoverBytesSqlInput pointBytesIn(XyBounds bounds,
                                       double maximumScale)

textBytesIn

public RoverBytesSqlInput textBytesIn(XyBounds bounds,
                                      double maximumScale)

areaBytesForEntityId

public RoverBytesInput areaBytesForEntityId(int id)

imageBytesForEntityId

public RoverBytesInput imageBytesForEntityId(int id)

lineBytesForEntityId

public RoverBytesInput lineBytesForEntityId(int id)

pointBytesForEntityId

public RoverBytesInput pointBytesForEntityId(int id)

textBytesForEntityId

public RoverBytesInput textBytesForEntityId(int id)

getCodec

public RoverCodec getCodec()

getTiledCodec

public RoverCodec getTiledCodec()

getConnection

public SqlConnection getConnection()

getEntityCount

public int getEntityCount()

getImageTable

public RoverImageShapeTable getImageTable()

getAreaTable

public RoverAreaShapeTable getAreaTable()

getLineTable

public RoverLineShapeTable getLineTable()

getPointTable

public RoverPointShapeTable getPointTable()

getTextTable

public RoverTextShapeTable getTextTable()

getDataTable

public RoverDataTable getDataTable()

bytesForEntityId

public RoverBytesInput bytesForEntityId(int id)

entityFor

public RoverEntity entityFor(int id)

reloadFindItems

public void reloadFindItems(Naming<FindItemIndex> findItems)

updateMaximumScales

public void updateMaximumScales(float[] areaMaximumScales,
                                float[] imageMaximumScales,
                                float[] lineMaximumScales,
                                float[] pointMaximumScales,
                                float[] textMaximumScales)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException