org.gcube.messaging.common.consumerlibrary.query
Class Query<CALL extends RICall>

java.lang.Object
  extended by org.gcube.messaging.common.consumerlibrary.query.Query<CALL>
Type Parameters:
CALL -
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AccountingQuery, MonitoringQuery, NotificationQuery, SystemAccountingQuery

public abstract class Query<CALL extends RICall>
extends java.lang.Object
implements java.io.Serializable

Author:
Andrea Manzi(CERN)
See Also:
Serialized Form

Constructor Summary
Query()
           
 
Method Summary
 CALL getCall()
          get the CALL object
 java.lang.Long getDimensions(java.lang.String tableName)
          Get the dimension of the given table
 java.lang.String getGroupClause()
          get the grouping clause
 java.lang.String getLimitClause()
          get the limit clause
 java.lang.String getOrderClause()
          get the order clause for this query
 java.lang.String getQuery()
          Return the query string ( composed by the user query + grouping+ordering+limits)
 java.lang.String getResults()
          Get the Query result stored inside the query object
 java.util.ArrayList<java.util.ArrayList<java.lang.String>> getResultsAsArray()
          getResultsAsArray (first array contains columns names)
 void printQueryResults()
          Debug operation, used to print on log query results
 java.lang.String query()
          Generic SELECT/SHOW MYSQL query
 void setCall(CALL call)
          set the CALL object
 void setGroupClause(java.lang.String group)
          set the grouping clause
 void setLimitClause(java.lang.Integer limit)
          set the limit clause
 void setLimitClause(java.lang.Integer start, java.lang.Integer limit)
          set the limit clause and starting index
 void setOrderClause(java.lang.String order)
          set the order clause
 void setQuery(java.lang.String query)
          set the Query
 void setResults(java.lang.String results)
          set the results inside the query object
 JSONArray toJSON()
          get results as JSON object
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Query

public Query()
Method Detail

query

public java.lang.String query()
                       throws java.lang.Exception,
                              QueryNotSetException
Generic SELECT/SHOW MYSQL query

Returns:
A String containing the query results in JSON format
Throws:
java.lang.Exception - if the query is not valid, or is not a SELECT/SHOW statement
QueryNotSetException

toJSON

public JSONArray toJSON()
                 throws EmptyResultException
get results as JSON object

Returns:
A JSON containing the query results in JSON format
Throws:
JSONException
EmptyResultException

getDimensions

public java.lang.Long getDimensions(java.lang.String tableName)
                             throws java.lang.Exception
Get the dimension of the given table

Parameters:
tableName -
Returns:
the table dimension
Throws:
java.lang.Exception

printQueryResults

public void printQueryResults()
                       throws java.lang.Exception
Debug operation, used to print on log query results

Throws:
JSONException
java.lang.Exception

getCall

public CALL getCall()
get the CALL object

Returns:
the CALL object

setCall

public void setCall(CALL call)
set the CALL object

Parameters:
call - the call object

getResults

public java.lang.String getResults()
Get the Query result stored inside the query object

Returns:
a String object representing the query results

setResults

public void setResults(java.lang.String results)
set the results inside the query object

Parameters:
results -

getQuery

public java.lang.String getQuery()
Return the query string ( composed by the user query + grouping+ordering+limits)

Returns:
the query string ( composed by the user query + grouping+ordering+limits)

setQuery

public void setQuery(java.lang.String query)
set the Query

Parameters:
query - the query

getOrderClause

public java.lang.String getOrderClause()
get the order clause for this query

Returns:
the order clause

setOrderClause

public void setOrderClause(java.lang.String order)
set the order clause

Parameters:
order -

getLimitClause

public java.lang.String getLimitClause()
get the limit clause

Returns:

setLimitClause

public void setLimitClause(java.lang.Integer start,
                           java.lang.Integer limit)
set the limit clause and starting index

Parameters:
limit -
start -

setLimitClause

public void setLimitClause(java.lang.Integer limit)
set the limit clause

Parameters:
limit -

getGroupClause

public java.lang.String getGroupClause()
get the grouping clause

Returns:

setGroupClause

public void setGroupClause(java.lang.String group)
set the grouping clause

Parameters:
group -

getResultsAsArray

public java.util.ArrayList<java.util.ArrayList<java.lang.String>> getResultsAsArray()
                                                                             throws java.lang.Exception
getResultsAsArray (first array contains columns names)

Returns:
ArrayList>
Throws:
java.lang.Exception