fr.cnes.sitools.datasource.mongodb.business
Class SitoolsMongoDBDataSource

java.lang.Object
  extended by fr.cnes.sitools.datasource.mongodb.business.SitoolsMongoDBDataSource
All Implemented Interfaces:
SitoolsDataSource

public class SitoolsMongoDBDataSource
extends java.lang.Object
implements SitoolsDataSource

Encapsulation of javax.sql.DataSource for : - Schema connection management - Presentation of generic methods for SQL database consulting FIXME ne plus utiliser JdbcRowSet implementation de sun >> warning au runtime

Author:
AKKA

Constructor Summary
SitoolsMongoDBDataSource(SitoolsDataSourceModel key, com.mongodb.Mongo mongo)
          Object build by DataSource encapsulation
 
Method Summary
 void close()
          Close all connections
 int countQuery(MongoDBRequestModel request)
          Gets the number of records for a given request model
 int countQuery(java.lang.String json, java.lang.String collectionName)
          Gets the number of records for a given query
 java.util.List<java.lang.Object> distinctQuery(java.lang.String key, MongoDBRequestModel request)
          Make the SQL request
 com.mongodb.DB getDatabase()
          Get a DB object to the database of the DataSource
 DataSourceType getDataSourceType()
          Get the type of the datasource
 SitoolsDataSourceModel getDsModel()
          Gets the DataSource Model
 org.restlet.Restlet getExplorer()
          Gets the explorer value
 java.util.List<java.lang.String> getMetadata(java.lang.String collectionName)
          Get the list of fields of a collection
 com.mongodb.Mongo getMongo()
          Gets the mongo value
 java.util.List<Table> getTableList()
          Gets the tableList value
 java.util.List<java.lang.String> getTableNameList()
          Gets the tableNameList value
 com.mongodb.DBCursor limitedQuery(MongoDBRequestModel request)
          Execute a query
 void setDsModel(SitoolsDataSourceModel dsModel)
          Sets the data source model
 void setExplorer(org.restlet.Restlet explorer)
          Sets the value of explorer
 void setMongo(com.mongodb.Mongo mongo)
          Sets the value of mongo
 void setTableList(java.util.List<Table> tableList)
          Sets the value of tableList
 void setTableNameList(java.util.List<java.lang.String> tableNameList)
          Sets the value of tableNameList
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SitoolsMongoDBDataSource

public SitoolsMongoDBDataSource(SitoolsDataSourceModel key,
                                com.mongodb.Mongo mongo)
Object build by DataSource encapsulation

Parameters:
key - the key associated to the source
mongo - the mongo db instance
Method Detail

getMetadata

public java.util.List<java.lang.String> getMetadata(java.lang.String collectionName)
Get the list of fields of a collection

Parameters:
collectionName - the name of the mongoDB collection
Returns:
name of related columns of the table TODO evolution return List

distinctQuery

public java.util.List<java.lang.Object> distinctQuery(java.lang.String key,
                                                      MongoDBRequestModel request)
Make the SQL request

Parameters:
key - the key
request - the mongoBD request model
Returns:
List of Object

limitedQuery

public com.mongodb.DBCursor limitedQuery(MongoDBRequestModel request)
Execute a query

Parameters:
request - the mongoBD request model
Returns:
DBCursor

countQuery

public int countQuery(java.lang.String json,
                      java.lang.String collectionName)
Gets the number of records for a given query

Parameters:
json - the json query
collectionName - the collection name to query
Returns:
the number of records for the query, -1 if there is an error

countQuery

public int countQuery(MongoDBRequestModel request)
Gets the number of records for a given request model

Parameters:
request - the mongoBD request model
Returns:
int

getDsModel

public SitoolsDataSourceModel getDsModel()
Gets the DataSource Model

Specified by:
getDsModel in interface SitoolsDataSource
Returns:
the dsModel

setDsModel

public void setDsModel(SitoolsDataSourceModel dsModel)
Sets the data source model

Specified by:
setDsModel in interface SitoolsDataSource
Parameters:
dsModel - the dsModel to set

getExplorer

public org.restlet.Restlet getExplorer()
Gets the explorer value

Returns:
the explorer

setExplorer

public void setExplorer(org.restlet.Restlet explorer)
Sets the value of explorer

Parameters:
explorer - the explorer to set

getTableNameList

public java.util.List<java.lang.String> getTableNameList()
Gets the tableNameList value

Returns:
the tableNameList

setTableNameList

public void setTableNameList(java.util.List<java.lang.String> tableNameList)
Sets the value of tableNameList

Parameters:
tableNameList - the tableNameList to set

getTableList

public java.util.List<Table> getTableList()
Gets the tableList value

Returns:
the tableList

setTableList

public void setTableList(java.util.List<Table> tableList)
Sets the value of tableList

Parameters:
tableList - the tableList to set

close

public void close()
Close all connections

Specified by:
close in interface SitoolsDataSource

getDatabase

public com.mongodb.DB getDatabase()
Get a DB object to the database of the DataSource

Returns:
a DB object

getMongo

public com.mongodb.Mongo getMongo()
Gets the mongo value

Returns:
the mongo

setMongo

public void setMongo(com.mongodb.Mongo mongo)
Sets the value of mongo

Parameters:
mongo - the mongo to set

getDataSourceType

public DataSourceType getDataSourceType()
Description copied from interface: SitoolsDataSource
Get the type of the datasource

Specified by:
getDataSourceType in interface SitoolsDataSource
Returns:
the type of the datasource


Copyright © 2010-2013 CNES. All Rights Reserved.