fr.cnes.sitools.dataset.database.mongodb
Class MongoDBDatabaseRequest

java.lang.Object
  extended by fr.cnes.sitools.dataset.database.mongodb.MongoDBDatabaseRequest
All Implemented Interfaces:
DatabaseRequest
Direct Known Subclasses:
MongoDBDistinctDatabaseRequest, MongoDBRangeDatabaseRequest

public class MongoDBDatabaseRequest
extends java.lang.Object
implements DatabaseRequest

Create a request NOSQL

Author:
m.gond (Akka Technologies

Constructor Summary
MongoDBDatabaseRequest(DatabaseRequestParameters params)
          Create a SQLDatabaseRequest
 
Method Summary
 java.lang.String buildURI()
          Build the URI to the current Record
 int calculateTotalCountFromBase()
          Compute from the database the number of Records in the current request
 void checkRequest()
          Check that the given request is correct and can be executed
 void close()
          Close the current MongoDB Cursor
 void createDistinctRequest()
          Create a SQL Distinct request
 MongoDBRequestModel createMongoDBRequestModel()
          Create a MongoDBRequestModel Object
 void createRequest()
          Create a Request
 int getCount()
          Get the number of results in the current request for pagination purpose
 java.lang.String getDistinctRequestAsString()
          Gets the distinct request as a String
 java.lang.String getKeysAsString()
          Get the list of keys (fields) as a String
 int getMaxResultsToSend()
          Gets the maxResultsToSend value
 int getPageSize()
          Get the number of records in the current request when no limit parameter is set
 java.util.List<java.lang.String> getPrimaryKeys()
          Get the list of primary keys in the DataSet
 Record getRecord()
          Return the current ResultSet in a Record object
 java.lang.String getRequestAsString()
          Gets the request as a String
 java.util.List<java.lang.String> getSelectedPrimaryKey()
          Get the selected primary keys
 int getStartIndex()
          Get the index of the first result in the current request
 int getTotalCount()
          get the number of records in the current request
 boolean isCountDone()
          If the count must be done or not
 boolean isLastResult()
          Deprecated. 
 boolean nextResult()
          Move the cursor on the next result.
 void setAttributeValues(Record record, com.mongodb.BasicDBObject dbObject)
          Fill in attributes for a given Record
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MongoDBDatabaseRequest

public MongoDBDatabaseRequest(DatabaseRequestParameters params)
Create a SQLDatabaseRequest

Parameters:
params - the request parameters
Method Detail

getPrimaryKeys

public java.util.List<java.lang.String> getPrimaryKeys()
Description copied from interface: DatabaseRequest
Get the list of primary keys in the DataSet

Specified by:
getPrimaryKeys in interface DatabaseRequest
Returns:
The list of primary keys

getSelectedPrimaryKey

public java.util.List<java.lang.String> getSelectedPrimaryKey()
Description copied from interface: DatabaseRequest
Get the selected primary keys

Specified by:
getSelectedPrimaryKey in interface DatabaseRequest
Returns:
a list of strings containing primary keys

createDistinctRequest

public void createDistinctRequest()
                           throws SitoolsException
Description copied from interface: DatabaseRequest
Create a SQL Distinct request

Specified by:
createDistinctRequest in interface DatabaseRequest
Throws:
SitoolsException - when occurs

createRequest

public void createRequest()
                   throws SitoolsException
Description copied from interface: DatabaseRequest
Create a Request

Specified by:
createRequest in interface DatabaseRequest
Throws:
SitoolsException - when request fails

createMongoDBRequestModel

public MongoDBRequestModel createMongoDBRequestModel()
                                              throws SitoolsException
Create a MongoDBRequestModel Object

Returns:
MongoDBRequestModel
Throws:
SitoolsException - throws SitoolsException

calculateTotalCountFromBase

public int calculateTotalCountFromBase()
                                throws SitoolsException
Description copied from interface: DatabaseRequest
Compute from the database the number of Records in the current request

Specified by:
calculateTotalCountFromBase in interface DatabaseRequest
Returns:
the number of total results or 0 if it cannot perform the request
Throws:
SitoolsException - if a database access error occurs or this method is called on a closed result set

getTotalCount

public int getTotalCount()
Description copied from interface: DatabaseRequest
get the number of records in the current request

Specified by:
getTotalCount in interface DatabaseRequest
Returns:
the number of records in the current request

getCount

public int getCount()
Description copied from interface: DatabaseRequest
Get the number of results in the current request for pagination purpose

Specified by:
getCount in interface DatabaseRequest
Returns:
the number of results in the current request for pagination purpose

getStartIndex

public final int getStartIndex()
Description copied from interface: DatabaseRequest
Get the index of the first result in the current request

Specified by:
getStartIndex in interface DatabaseRequest
Returns:
the index of the first result in the current request

nextResult

public boolean nextResult()
                   throws SitoolsException
Description copied from interface: DatabaseRequest
Move the cursor on the next result.

Specified by:
nextResult in interface DatabaseRequest
Returns:
true if the new current row is valid; false if there are no more rows
Throws:
SitoolsException - if a database access error occurs or this method is called on a closed result set

isLastResult

@Deprecated
public boolean isLastResult()
                     throws SitoolsException
Deprecated. 

Description copied from interface: DatabaseRequest
Retrieves whether the cursor is on the last row of this ResultSet object or is the last ResultSet to send.

Specified by:
isLastResult in interface DatabaseRequest
Returns:
true if the cursor is on the last row or is the last row to send.; false otherwise
Throws:
SitoolsException - if a database access error occurs or this method is called on a closed result set

getRecord

public Record getRecord()
                 throws SitoolsException
Description copied from interface: DatabaseRequest
Return the current ResultSet in a Record object

Specified by:
getRecord in interface DatabaseRequest
Returns:
the Record of the current ResultSet
Throws:
SitoolsException - if a database access error occurs or this method is called on a closed result set

buildURI

public final java.lang.String buildURI()
                                throws SitoolsException
Description copied from interface: DatabaseRequest
Build the URI to the current Record

Specified by:
buildURI in interface DatabaseRequest
Returns:
The URI to the current Record
Throws:
SitoolsException - if a database access error occurs or this method is called on a closed result set

setAttributeValues

public final void setAttributeValues(Record record,
                                     com.mongodb.BasicDBObject dbObject)
Fill in attributes for a given Record

Parameters:
record - the Record
dbObject - the dbObject containing the attributeValue

close

public void close()
           throws SitoolsException
Close the current MongoDB Cursor

Specified by:
close in interface DatabaseRequest
Throws:
SitoolsException - if there is an error while closing the MongoDB cursor

isCountDone

public final boolean isCountDone()
If the count must be done or not

Specified by:
isCountDone in interface DatabaseRequest
Returns:
true if the count is done, false otherwise

getMaxResultsToSend

public final int getMaxResultsToSend()
Gets the maxResultsToSend value

Specified by:
getMaxResultsToSend in interface DatabaseRequest
Returns:
the maxResultsToSend
See Also:
property in the sitools.properties file, Guide

getPageSize

public final int getPageSize()
Get the number of records in the current request when no limit parameter is set

Returns:
the number of records in the current request when no limit parameter is set
See Also:
property in the sitools.properties file, Guide

getDistinctRequestAsString

public final java.lang.String getDistinctRequestAsString()
                                                  throws SitoolsException
Description copied from interface: DatabaseRequest
Gets the distinct request as a String

Specified by:
getDistinctRequestAsString in interface DatabaseRequest
Returns:
the String of a Distinct request
Throws:
SitoolsException - when occurs

getRequestAsString

public final java.lang.String getRequestAsString()
                                          throws SitoolsException
Description copied from interface: DatabaseRequest
Gets the request as a String

Specified by:
getRequestAsString in interface DatabaseRequest
Returns:
the String of a Distinct request
Throws:
SitoolsException - when occurs

getKeysAsString

public final java.lang.String getKeysAsString()
Get the list of keys (fields) as a String

Returns:
the list of keys as a String

checkRequest

public void checkRequest()
                  throws SitoolsException
Description copied from interface: DatabaseRequest
Check that the given request is correct and can be executed

Specified by:
checkRequest in interface DatabaseRequest
Throws:
SitoolsException - if the given request is not correct


Copyright © 2010-2013 CNES. All Rights Reserved.