package edu.wustl.catissuecore.query;




/**
 *<p>Title: Condition</p>
 *<p>Description:  Represents a condition</p>
 *<p>Copyright: (c) Washington University, School of Medicine 2005</p>
 *<p>Company: Washington University, School of Medicine, St. Louis.</p>
 *@author Aarti Sharma
 *@version 1.0
 */
public class Condition {
    
    /**
     * Data element of the condition 
     */
	private DataElement dataElement = new DataElement();
	
	/**
	 * Operator between data element and value
	 */
	private Operator operator = new Operator();
	
	/**
	 * Value
	 */
	private String value;
	
	public Condition()
	{
	    
	}

	/**
	 * Constructor
	 * @param dataElement Data element of the condition
	 * @param op Operator between data element and value
	 * @param value Value
	 */
	public Condition(DataElement dataElement, Operator op, String value)
	{
	    this.dataElement = dataElement;
	    this.operator = op;
	    this.value = value;
	}
	
	/**
	 * Forms String of this condition object
	 * @param tableSufix sufix that needs to be appended to table names
	 * @return
	 */
	public String toSQLString(int tableSufix)
	{
	    return new String(dataElement.toSQLString(tableSufix)+" "+ operator.toSQLString() + " " + value.toString() + " ");
	}

    public boolean equals(Object obj)
    {
        if (obj instanceof Condition) {
            Condition condition = (Condition)obj;
            if(!dataElement.equals(condition.dataElement))
                return false;
            if(!operator.equals(condition.operator))
                return false;
            if(!value.equals(condition.value))
            	return false;
            return true;
	    }
        
       else
           return false;
    }
    public int hashCode()
    {
       return 1;
    }
    public DataElement getDataElement()
    {
        return dataElement;
    }
    public void setDataElement(DataElement dataElement)
    {
        this.dataElement = dataElement;
    }
    public Operator getOperator()
    {
        return operator;
    }
    public void setOperator(Operator operator)
    {
        this.operator = operator;
    }
    public String getValue()
    {
        return value;
    }
    public void setValue(String value)
    {
        this.value = value;
    }
}
@@ -30,24 +30,125 @@
 e.query;%0D%0A%0D%0A
+import edu.wustl.catissuecore.util.global.Constants;%0D%0Aimport edu.wustl.common.util.logger.Logger;%0D%0A%0D%0A
 %0D%0A%0D%0A%0D%0A/**%0D%0A 
@@ -1280,89 +1280,1735 @@
     
-return new String(dataElement.toSQLString(tableSufix)+%22 %22+ operator.toSQLString()
+String newValue = new String(value);%0D%0A%09    String newOperator = new String(operator.getOperator());%0D%0A%09    Logger.out.debug(%22newValue...................%22+newValue);%0D%0A%09    Logger.out.debug(%22newOperator...................%22+newOperator);%0D%0A%09    if(newOperator.equals(Operator.STARTS_WITH))%0D%0A        %7B%0D%0A%09        newValue = newValue+%22%25%22;%0D%0A%09        newOperator = Operator.LIKE;%0D%0A        %7D%0D%0A        else if(newOperator.equals(Operator.ENDS_WITH))%0D%0A        %7B%0D%0A            newValue = %22%25%22+newValue;%0D%0A            newOperator = Operator.LIKE;%0D%0A        %7D%0D%0A        else if(newOperator.equals(Operator.CONTAINS))%0D%0A        %7B%0D%0A            newValue = %22%25%22+newValue+%22%25%22;%0D%0A            newOperator = Operator.LIKE;%0D%0A        %7D%0D%0A        Logger.out.debug(%22dataElement......................%22+dataElement.getFieldType());%0D%0A        %0D%0A        if (dataElement.getFieldType().equalsIgnoreCase(Constants.FIELD_TYPE_VARCHAR)%0D%0A        %09%09%7C%7C dataElement.getFieldType().equalsIgnoreCase(Constants.FIELD_TYPE_DATE) %0D%0A        %09%09%7C%7C dataElement.getFieldType().equalsIgnoreCase(Constants.FIELD_TYPE_TEXT))%0D%0A        %7B%0D%0A        %09if (dataElement.getFieldType().equalsIgnoreCase(Constants.FIELD_TYPE_VARCHAR) %0D%0A        %09        %09%7C%7C dataElement.getFieldType().equalsIgnoreCase(Constants.FIELD_TYPE_TEXT))%0D%0A        %09%7B%0D%0A        %09    newValue = %22'%22 + newValue + %22'%22;%0D%0A        %09%7D%0D%0A        %09else%0D%0A        %09%7B%0D%0A        %09    newValue = %22STR_TO_DATE('%22 + newValue + %22','%22 + Constants.MYSQL_DATE_PATTERN + %22')%22;%0D%0A        %09%7D%0D%0A        %7D%0D%0A        %0D%0A        Logger.out.debug(%22newOperator..........................%22+newOperator);%0D%0A        %0D%0A        Logger.out.debug(%22newValue...........................%22+newValue);%0D%0A%09    return new String(dataElement.toSQLString(tableSufix)+%22 %22+ newOperator
  + %22
@@ -3012,17 +3012,20 @@
 + %22 %22 + 
-v
+newV
 alue.toS

Wrote the logic of single quotes for strings and dates.