package com.csc.library.inqbean;

import com.csc.library.database.MyInquiry;

public class Inq_vw_empwork_year extends MyInquiry{
  
	public void setFilter(String s) {	
 		s=this.modifyExpression(s);	
 		super.setFilter(s);
  	}//end override method setFilter()
	
	/**
	 * @author _NUISS
	 * @since 20/02/2552
	 * @see �Ѵ��� modify whereClause �������ͧ�ҡ Report �� Operater 'OR'
	 *			<br>����� 
	 * @category ������ �Ѻ class ��� inherit MyInquiry ������
	 *			<br>��ͧ��� override method setFilter()
	 *			<br>���͵�ͧ��� modify whereClause �ա��
	 */
	private String modifyExpression(String strExpression){
		strExpression = strExpression.toUpperCase();
		StringBuffer  newExpression = new StringBuffer();
		String[] strSplitAND =  strExpression.split(" AND ");
	 	String strYearOption ="";	 
	 	String strMonthOption ="";
		//Step 1.Split Expression
		for(int rowAnd=0;rowAnd<strSplitAND.length;rowAnd++){	
			  if(strSplitAND[rowAnd].indexOf("WORKYEAR")>=0){
				  strYearOption =" OR WORKYEAR='0' ";
			  }else{
				  strYearOption ="";
			  }//end if 
			  
			  if(strSplitAND[rowAnd].indexOf("WORKMONTH")>=0){
				  strMonthOption =" OR WORKMONTH='0' ";
			  }else{
				  strMonthOption ="";
			  }//end if 
			  
			  newExpression.append("("+strSplitAND[rowAnd] + strYearOption + strMonthOption +")");
			  if(rowAnd<(strSplitAND.length-1)){
				  newExpression.append(" AND ");
			  }//end if 	
		}//end for rowAnd 
	
		return newExpression.toString();
	}//end method modifyExpression()
	 
}//end class