org.kuali.rice.core.jdbc
Class SqlBuilder

java.lang.Object
  extended by org.kuali.rice.core.jdbc.SqlBuilder

public class SqlBuilder
extends Object

This is a description of what this class does - Garey don't forget to fill this in.

Author:
Kuali Rice Team (rice.collab@kuali.org)

Field Summary
private  DateTimeService dateTimeService
           
private  DatabasePlatform dbPlatform
           
private static org.apache.log4j.Logger LOG
           
 
Constructor Summary
SqlBuilder()
           
 
Method Summary
private  void addAndCriteria(String propertyName, String propertyValue, Class propertyType, boolean caseInsensitive, Criteria criteria, boolean allowWildcards)
           
 void addCriteria(String propertyName, String propertyValue, Class propertyType, boolean caseInsensitive, boolean allowWildcards, Criteria criteria)
           
private  void addDateRangeCriteria(String propertyName, String propertyValue, Criteria criteria, Class propertyType)
           
private  void addLogicalOperatorCriteria(String propertyName, String propertyValue, Class propertyType, boolean caseInsensitive, Criteria criteria, String splitValue, boolean allowWildcards)
           
private  void addNotCriteria(String propertyName, String propertyValue, Class propertyType, boolean caseInsensitive, Criteria criteria, boolean allowWildcards)
           
private  void addNumericRangeCriteria(String propertyName, String propertyValue, Criteria criteria, Class propertyType)
           
private  void addOrCriteria(String propertyName, String propertyValue, Class propertyType, boolean caseInsensitive, Criteria criteria, boolean allowWildcards)
           
private  void addStringRangeCriteria(String propertyName, String propertyValue, Criteria criteria, Class propertyType, boolean caseInsensitive, boolean allowWildcards)
           
 void andCriteria(Criteria addToThisCriteria, Criteria newCriteria)
           
 void andCriteria(String columnName, String searchValue, String tableName, String tableAlias, Class propertyType, boolean caseInsensitive, boolean allowWildcards, Criteria addToThisCriteria)
           
static String cleanDate(String string)
           
static String cleanNumeric(String value)
           
static String cleanNumericOfValidOperators(String string)
           
private static String cleanUpperBound(String stringDate)
          When dealing with upperbound dates, it is a business requirement that if a timestamp isn't already stated append 23:59:59 to the end of the date.
static boolean containsRangeCharacters(String string)
           
private static String convertSimpleDateToDateRange(String stringDate)
          This method will take a whole date like 03/02/2009 and convert it into 03/02/2009 ..
 Criteria createCriteria(String columnName, String searchValue, String tableName, String tableAlias, Class propertyType)
           
 Criteria createCriteria(String columnName, String searchValue, String tableName, String tableAlias, Class propertyType, boolean caseInsensitive, boolean allowWildcards)
           
private  String getCaseAndLiteralPropertyName(String propertyName, boolean caseInsensitive)
           
private  String getCaseAndLiteralPropertyValue(String propertyValue, boolean caseInsensitive, boolean allowWildcards)
           
static List<String> getCleanedSearchableValues(String valueEntered, String propertyDataType)
          This method splits the values then cleans them of any other query characters like *?!><...
protected  DateTimeService getDateTimeService()
           
 DatabasePlatform getDbPlatform()
           
protected static void getSearchableValueRecursive(String valueEntered, List lRet)
           
static List<String> getSearchableValues(String valueEntered)
          This method splits the valueEntered on locical operators and, or, and between
 boolean isValidDate(String dateString)
           
static boolean isValidNumber(String value)
           
 void orCriteria(String columnName, String searchValue, String tableName, String tableAlias, Class propertyType, boolean caseInsensitive, boolean allowWildcards, Criteria addToThisCriteria)
           
private  Timestamp parseDate(String dateString)
           
 void setDateTimeService(DateTimeService dateTimeService)
           
 void setDbPlatform(DatabasePlatform dbPlatform)
           
static BigDecimal stringToBigDecimal(String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final org.apache.log4j.Logger LOG

dateTimeService

private DateTimeService dateTimeService

dbPlatform

private DatabasePlatform dbPlatform
Constructor Detail

SqlBuilder

public SqlBuilder()
Method Detail

createCriteria

public Criteria createCriteria(String columnName,
                               String searchValue,
                               String tableName,
                               String tableAlias,
                               Class propertyType)

createCriteria

public Criteria createCriteria(String columnName,
                               String searchValue,
                               String tableName,
                               String tableAlias,
                               Class propertyType,
                               boolean caseInsensitive,
                               boolean allowWildcards)

andCriteria

public void andCriteria(String columnName,
                        String searchValue,
                        String tableName,
                        String tableAlias,
                        Class propertyType,
                        boolean caseInsensitive,
                        boolean allowWildcards,
                        Criteria addToThisCriteria)

andCriteria

public void andCriteria(Criteria addToThisCriteria,
                        Criteria newCriteria)

orCriteria

public void orCriteria(String columnName,
                       String searchValue,
                       String tableName,
                       String tableAlias,
                       Class propertyType,
                       boolean caseInsensitive,
                       boolean allowWildcards,
                       Criteria addToThisCriteria)

addCriteria

public void addCriteria(String propertyName,
                        String propertyValue,
                        Class propertyType,
                        boolean caseInsensitive,
                        boolean allowWildcards,
                        Criteria criteria)
See Also:
public Object findObjectByMap(Object example, Map formProps) { Criteria jpaCriteria = new Criteria(example.getClass().getName()); Iterator propsIter = formProps.keySet().iterator(); while (propsIter.hasNext()) { String propertyName = (String) propsIter.next(); String searchValue = ""; if (formProps.get(propertyName) != null) { searchValue = (formProps.get(propertyName)).toString(); } if (StringUtils.isNotBlank(searchValue) & PropertyUtils.isWriteable(example, propertyName)) { Class propertyType = ObjectUtils.getPropertyType(example, propertyName, persistenceStructureService); if (TypeUtils.isIntegralClass(propertyType) || TypeUtils.isDecimalClass(propertyType)) { if (propertyType.equals(Long.class)) { jpaCriteria.eq(propertyName, new Long(searchValue)); } else { jpaCriteria.eq(propertyName, new Integer(searchValue)); } } else if (TypeUtils.isTemporalClass(propertyType)) { jpaCriteria.eq(propertyName, parseDate(ObjectUtils.clean(searchValue))); } else { jpaCriteria.eq(propertyName, searchValue); } } } return new QueryByCriteria(entityManager, jpaCriteria).toQuery().getSingleResult(); }

addOrCriteria

private void addOrCriteria(String propertyName,
                           String propertyValue,
                           Class propertyType,
                           boolean caseInsensitive,
                           Criteria criteria,
                           boolean allowWildcards)

addAndCriteria

private void addAndCriteria(String propertyName,
                            String propertyValue,
                            Class propertyType,
                            boolean caseInsensitive,
                            Criteria criteria,
                            boolean allowWildcards)

addNotCriteria

private void addNotCriteria(String propertyName,
                            String propertyValue,
                            Class propertyType,
                            boolean caseInsensitive,
                            Criteria criteria,
                            boolean allowWildcards)

addLogicalOperatorCriteria

private void addLogicalOperatorCriteria(String propertyName,
                                        String propertyValue,
                                        Class propertyType,
                                        boolean caseInsensitive,
                                        Criteria criteria,
                                        String splitValue,
                                        boolean allowWildcards)

parseDate

private Timestamp parseDate(String dateString)

isValidDate

public boolean isValidDate(String dateString)

cleanDate

public static String cleanDate(String string)

containsRangeCharacters

public static boolean containsRangeCharacters(String string)

addDateRangeCriteria

private void addDateRangeCriteria(String propertyName,
                                  String propertyValue,
                                  Criteria criteria,
                                  Class propertyType)

isValidNumber

public static boolean isValidNumber(String value)

cleanNumericOfValidOperators

public static String cleanNumericOfValidOperators(String string)

cleanNumeric

public static String cleanNumeric(String value)

stringToBigDecimal

public static BigDecimal stringToBigDecimal(String value)

addNumericRangeCriteria

private void addNumericRangeCriteria(String propertyName,
                                     String propertyValue,
                                     Criteria criteria,
                                     Class propertyType)

addStringRangeCriteria

private void addStringRangeCriteria(String propertyName,
                                    String propertyValue,
                                    Criteria criteria,
                                    Class propertyType,
                                    boolean caseInsensitive,
                                    boolean allowWildcards)

getCaseAndLiteralPropertyName

private String getCaseAndLiteralPropertyName(String propertyName,
                                             boolean caseInsensitive)

getCaseAndLiteralPropertyValue

private String getCaseAndLiteralPropertyValue(String propertyValue,
                                              boolean caseInsensitive,
                                              boolean allowWildcards)

getDateTimeService

protected DateTimeService getDateTimeService()

setDateTimeService

public void setDateTimeService(DateTimeService dateTimeService)
Parameters:
dateTimeService - the dateTimeService to set

getDbPlatform

public DatabasePlatform getDbPlatform()

setDbPlatform

public void setDbPlatform(DatabasePlatform dbPlatform)

cleanUpperBound

private static String cleanUpperBound(String stringDate)
When dealing with upperbound dates, it is a business requirement that if a timestamp isn't already stated append 23:59:59 to the end of the date. This ensures that you are searching for the entire day.


convertSimpleDateToDateRange

private static String convertSimpleDateToDateRange(String stringDate)
This method will take a whole date like 03/02/2009 and convert it into 03/02/2009 .. 03/02/20009 00:00:00 This is used for non-range searchable attributes

Parameters:
stringDate -
Returns:

getCleanedSearchableValues

public static List<String> getCleanedSearchableValues(String valueEntered,
                                                      String propertyDataType)
This method splits the values then cleans them of any other query characters like *?!><...

Parameters:
valueEntered -
propertyDataType -
Returns:

getSearchableValues

public static List<String> getSearchableValues(String valueEntered)
This method splits the valueEntered on locical operators and, or, and between

Parameters:
valueEntered -
Returns:

getSearchableValueRecursive

protected static void getSearchableValueRecursive(String valueEntered,
                                                  List lRet)


Copyright © 2004-2011 The Kuali Foundation. All Rights Reserved.