agave-common/common-core/src/main/java/org/iplantc/service/common/search/AgaveResourceSearchFilter.java
/**
     * Converts the search value given in a url query to the proper
     * object type for the hibernate query.
     *
     * @param searchTerm
     * @param searchValue
     * @return
     * @throws IllegalArgumentException
     */
Converts the search value given in a url query to the proper
object type for the hibernate query.

@param searchTerm
@param searchValue
@return
@throws IllegalArgumentException
Converts the search value given in a url query to the proper object type for the hibernate query . @param searchTerm @param searchValue @return @throws IllegalArgumentException
public Object filterAttributValue(SearchTerm searchTerm, String searchValue) throws IllegalArgumentException {
    	if (searchTerm == null) return null;
    	@SuppressWarnings("rawtypes")
    	Class searchTermType = getSearchTypeMappings().get(searchTerm.getSearchField());
    	String[] splitValues = StringUtils.split(searchValue, ",");
    	if (searchTerm.getOperator().isSetOperator() && searchTermType == Date.class) 
    	{
    	    if (searchTerm.getOperator() != SearchTerm.Operator.BETWEEN) {
    	        throw new IllegalArgumentException("Illegal use of IN operation for " + searchTerm.getSearchField() + 
                        ". To query multiple dates, plese specify a comma separated date range consisting of a start and end date/time expression.");
    	    } else if (splitValues.length == 0) {
    	        throw new IllegalArgumentException("Illegal date range format for " + searchTerm.getSearchField() + 
    	                ". Please specify a comma separated date range consisting of a start and end date/time expression.");
    	    }
    	    else if (splitValues.length == 1) {
    	    	List<Object> searchValues = new ArrayList<Object>();
    	    	Object strongTypeSearchValue = strongTypeSearchValue(searchTermType, searchTerm.getSearchField(), splitValues[0]);
    	    	searchValues.add(strongTypeSearchValue);
    	    	searchValues.add(strongTypeSearchValue);
    	    	return searchValues;
    	    } else if (splitValues.length > 2) {
    	        throw new IllegalArgumentException("Illegal date range format for " + searchTerm.getSearchField() + 
    	                ". Please specify a comma separated date range consisting of a start and end date/time expression.");
    	    } else {
    	        List<Object> searchValues = new ArrayList<Object>();
                for (String splitValue: splitValues)
                {
                    searchValues.add(strongTypeSearchValue(searchTermType, searchTerm.getSearchField(), splitValue));
                }
                return searchValues;
    	    }
    	}
    	else if (searchTerm.getOperator().isSetOperator() && splitValues.length > 1) 
    	{
    	    List<Object> searchValues = new ArrayList<Object>();
    		for (String splitValue: splitValues)
    		{
    			searchValues.add(strongTypeSearchValue(searchTermType, searchTerm.getSearchField(), splitValue));
    		}
    		return searchValues;
    	}
    	else if (searchTerm.getOperator().isSetOperator() && splitValues.length == 1) 
        {
    	    List<Object> searchValues = new ArrayList<Object>();
            searchValues.add(strongTypeSearchValue(searchTermType, searchTerm.getSearchField(), splitValues[0]));
            return searchValues; 
        }
    	else if (searchTermType == Boolean.class && !searchTerm.getOperator().isEqualityOperator())
    	{
    	    throw new IllegalArgumentException(String.format("Illegal search term operator for %s. " 
                    + "Boolean search terms may only be compared by equality. "
                    + "Please specify one of %s or %s.",
                    searchTerm.getSearchField(),
                    searchTerm.getSearchField() + ".EQ",
                    searchTerm.getSearchField() + ".NEQ"));
    	}
    	else
    	{
    	    return strongTypeSearchValue(searchTermType, searchTerm.getSearchField(), searchValue);
    	}
    }
public Object filterAttributValue ( SearchTerm searchTerm , String searchValue ) throws IllegalArgumentException { if ( searchTerm == null ) return null ; @ SuppressWarnings ( "rawtypes" ) Class searchTermType = getSearchTypeMappings ( ) . get ( searchTerm . getSearchField ( ) ) ; String [ ] splitValues = StringUtils . split ( searchValue , "," ) ; if ( searchTerm . getOperator ( ) . isSetOperator ( ) && searchTermType == Date . class ) { if ( searchTerm . getOperator ( ) != SearchTerm . Operator . BETWEEN ) { throw new IllegalArgumentException ( "Illegal use of IN operation for " + searchTerm . getSearchField ( ) + ". To query multiple dates, plese specify a comma separated date range consisting of a start and end date/time expression." ) ; } else if ( splitValues . length == 0 ) { throw new IllegalArgumentException ( "Illegal date range format for " + searchTerm . getSearchField ( ) + ". Please specify a comma separated date range consisting of a start and end date/time expression." ) ; } else if ( splitValues . length == 1 ) { List < Object > searchValues = new ArrayList < Object > ( ) ; Object strongTypeSearchValue = strongTypeSearchValue ( searchTermType , searchTerm . getSearchField ( ) , splitValues [ 0 ] ) ; searchValues . add ( strongTypeSearchValue ) ; searchValues . add ( strongTypeSearchValue ) ; return searchValues ; } else if ( splitValues . length > 2 ) { throw new IllegalArgumentException ( "Illegal date range format for " + searchTerm . getSearchField ( ) + ". Please specify a comma separated date range consisting of a start and end date/time expression." ) ; } else { List < Object > searchValues = new ArrayList < Object > ( ) ; for ( String splitValue : splitValues ) { searchValues . add ( strongTypeSearchValue ( searchTermType , searchTerm . getSearchField ( ) , splitValue ) ) ; } return searchValues ; } } else if ( searchTerm . getOperator ( ) . isSetOperator ( ) && splitValues . length > 1 ) { List < Object > searchValues = new ArrayList < Object > ( ) ; for ( String splitValue : splitValues ) { searchValues . add ( strongTypeSearchValue ( searchTermType , searchTerm . getSearchField ( ) , splitValue ) ) ; } return searchValues ; } else if ( searchTerm . getOperator ( ) . isSetOperator ( ) && splitValues . length == 1 ) { List < Object > searchValues = new ArrayList < Object > ( ) ; searchValues . add ( strongTypeSearchValue ( searchTermType , searchTerm . getSearchField ( ) , splitValues [ 0 ] ) ) ; return searchValues ; } else if ( searchTermType == Boolean . class && ! searchTerm . getOperator ( ) . isEqualityOperator ( ) ) { throw new IllegalArgumentException ( String . format ( "Illegal search term operator for %s. " + "Boolean search terms may only be compared by equality. " + "Please specify one of %s or %s." , searchTerm . getSearchField ( ) , searchTerm . getSearchField ( ) + ".EQ" , searchTerm . getSearchField ( ) + ".NEQ" ) ) ; } else { return strongTypeSearchValue ( searchTermType , searchTerm . getSearchField ( ) , searchValue ) ; } }
Converts the search value given in a url query to the proper
 object type for the hibernate query.
Converts the search value given in a url query to the proper object type for the hibernate query .
// if a single date value is given to a BETWEEN operation, we treat like an equality operation  // since precision is only guaranteed to the second. This is essentially the same as an EQ operation  // as the result will be anything within the the given time rounded down to 0 milliseconds and rounded  // up to .999 milliseconds. This is the only safe way to hedge against db precision issues going forward // without changing all DateTime fields to timestamps. //    	        throw new IllegalArgumentException("Illegal date range format for " + searchTerm.getSearchField() +  //    	                ". Please specify an end date/time expression in the date range.");