|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.caleigo.core.service.SQLToolKitPS
This class constanis help methods for building valid SQL language statements based on CEL entities, descriptors and qualifiers. The class can be used by any IDataService implementation that connects to SQL based databases.
Nested Class Summary | |
static class |
SQLToolKitPS.BooleanCharTypeConverter
|
static class |
SQLToolKitPS.BooleanTypeConverter
|
static class |
SQLToolKitPS.CompositeQualifierParser
Parser for CompositeQualifiers. |
static class |
SQLToolKitPS.DateTypeConverter
|
static interface |
SQLToolKitPS.IDataTypeConverter
|
static interface |
SQLToolKitPS.IQualifierParser
|
static class |
SQLToolKitPS.NegateQualifierParser
|
class |
SQLToolKitPS.RelationQualifierParser
Class for parsing RelationQualifiers. |
static class |
SQLToolKitPS.StringTypeConverter
|
Constructor Summary | |
SQLToolKitPS()
Constructs a new SQLToolKitPS and does necessary initialization |
Method Summary | |
void |
addDataTypeConverter(DataType dataType,
SQLToolKitPS.IDataTypeConverter converter)
|
void |
addQualifierParser(java.lang.Class qualifierClass,
SQLToolKitPS.IQualifierParser parser)
Adds a qualifierParser for the specified qualifier class. |
java.lang.String |
buildDataString(DataType type,
java.lang.Object data)
|
java.lang.String |
buildDeleteCommand(IEntityDescriptor descriptor,
Qualifier qualifier,
java.util.ArrayList values)
Build the delete SQL Prepared Statement Query |
java.sql.PreparedStatement |
buildDeleteStatement(IEntityDescriptor descriptor,
Qualifier qualifier,
java.sql.Connection connection)
Build a Delete Prepared Statement from a EntityDescriptor and a Qualifier |
java.lang.String |
buildFromExpresion(IEntityDescriptor descriptor,
Qualifier qualifier)
This method creates a comma seperated string with the source name of all referenced entity descriptors. |
java.lang.String |
buildInsertCommand(IEntity entity)
Build the SQL Insert String for Prepared statements |
java.sql.PreparedStatement |
buildInsertStatement(IEntity entity,
java.sql.Connection connection,
boolean generateKeys)
Build a PreparedStatement for inserting the Entity |
java.lang.String |
buildSelectCommand(DataQuery query,
java.util.ArrayList values)
|
java.lang.String |
buildSelectCommand(IEntityDescriptor descriptor,
Qualifier qualifier,
java.util.ArrayList values)
Builds the select query to be used by a PreparedStatement |
java.sql.PreparedStatement |
buildSelectStatement(IEntityDescriptor descriptor,
Qualifier qualifier,
java.sql.Connection connection)
Builds a Select PreparedStatement from a IEntityDescriptor and a Qualifier |
java.lang.String |
buildUpdateCommand(IEntity entity,
Qualifier qualifier,
java.util.ArrayList values)
Build the Prepared Statement SQL query for for an update of an entity |
java.sql.PreparedStatement |
buildUpdateStatement(IEntity entity,
Qualifier qualifier,
java.sql.Connection connection)
Build a Update Prepared Statement from a Entity and a Qualifier |
java.lang.String |
buildWhereExpresion(Qualifier qualifier,
java.util.ArrayList values)
Builds a WHERE Prepared statement from a qualifier |
SQLToolKitPS.IDataTypeConverter |
getDataTypeConverter(DataType dataType)
|
protected java.util.Set |
getQualifierDescriptorSet(Qualifier qualifier)
Returns a Set containing the entity descriptors meaded for the WHERE statement built by the submited qualifier. |
SQLToolKitPS.IQualifierParser |
getQualifierParser(java.lang.Class qualifierClass)
|
boolean |
isQuotingIdentifiers()
|
java.lang.String |
prepareWildcards(java.lang.String dataString)
|
java.lang.String |
quoteIdentifier(java.lang.String indentifier)
|
void |
setQuotingIdentifiers(boolean allwaysQuote)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SQLToolKitPS()
Method Detail |
public void addDataTypeConverter(DataType dataType, SQLToolKitPS.IDataTypeConverter converter)
public SQLToolKitPS.IDataTypeConverter getDataTypeConverter(DataType dataType)
public void addQualifierParser(java.lang.Class qualifierClass, SQLToolKitPS.IQualifierParser parser)
qualifierClass
- The qualifier class that should be handled by the parserparser
- The parser that should handle the qualifier classpublic SQLToolKitPS.IQualifierParser getQualifierParser(java.lang.Class qualifierClass)
public void setQuotingIdentifiers(boolean allwaysQuote)
public boolean isQuotingIdentifiers()
public java.lang.String buildSelectCommand(DataQuery query, java.util.ArrayList values)
public java.lang.String buildSelectCommand(IEntityDescriptor descriptor, Qualifier qualifier, java.util.ArrayList values)
descriptor
- The Entity type to be queriedqualifier
- The qualifier that identies the wanted subset of entitiesvalues
- ArrayList that should be populated with the data to be set by the PreparedStatement
public java.sql.PreparedStatement buildSelectStatement(IEntityDescriptor descriptor, Qualifier qualifier, java.sql.Connection connection) throws java.sql.SQLException
descriptor
- IEntityDescriptor that identied the Type of entity wantedqualifier
- Qualifier that is used to limit the result to a wanted subset of entitiesconnection
- SQL Connection that is the link to the database
java.sql.SQLException
- throwmn if a database problem occurspublic java.lang.String buildUpdateCommand(IEntity entity, Qualifier qualifier, java.util.ArrayList values)
entity
- The entity that should be updatedqualifier
- The qualifier that uniqely identifies the entityvalues
- Should be populated with all data to be set in the query and in the correct order.
public java.sql.PreparedStatement buildUpdateStatement(IEntity entity, Qualifier qualifier, java.sql.Connection connection) throws java.sql.SQLException
entity
- The entity containing the data to be updatedqualifier
- A qualifier that identifies the entity to be updatedconnection
- A reference to a SQL connection
java.sql.SQLException
- thrown if there was a problem with the sql connectionpublic java.lang.String buildInsertCommand(IEntity entity)
entity
- The entity to be inserted
public java.sql.PreparedStatement buildInsertStatement(IEntity entity, java.sql.Connection connection, boolean generateKeys) throws java.sql.SQLException
entity
- The entity to be insertedconnection
- The SQL connections that should handle the StatementgenerateKeys
- Set to true if Generated Keys should be returned
java.sql.SQLException
- Returned if an SQLException occuredpublic java.lang.String buildDeleteCommand(IEntityDescriptor descriptor, Qualifier qualifier, java.util.ArrayList values)
descriptor
- The descriptor that describes the entity/ies being removedqualifier
- The qualifier that identifies the entities to be removedvalues
- Should be updated with the data that should complement the PreparedStatement
public java.sql.PreparedStatement buildDeleteStatement(IEntityDescriptor descriptor, Qualifier qualifier, java.sql.Connection connection) throws java.sql.SQLException
descriptor
- A IEntityDescriptor stating what descriptor type to be deletedqualifier
- A qualifier that identifies the subset of entities to be removedconnection
- A reference to a SQL connection
java.sql.SQLException
- thrown if there was a problem with the sql connectionpublic java.lang.String buildFromExpresion(IEntityDescriptor descriptor, Qualifier qualifier)
descriptor
- The descriptor that describes the entity/iesqualifier
- The qualifier that identifies the entities
public java.lang.String buildWhereExpresion(Qualifier qualifier, java.util.ArrayList values)
qualifier
- The qualifier that should be parsedvalues
- The data stored should be stored in values in the same order it is being added to the generated query
public java.lang.String buildDataString(DataType type, java.lang.Object data)
public java.lang.String prepareWildcards(java.lang.String dataString)
protected java.util.Set getQualifierDescriptorSet(Qualifier qualifier)
public java.lang.String quoteIdentifier(java.lang.String indentifier)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |