package qa.gov.moi.erp.web.dmi;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.isomorphic.datasource.DSRequest;
import com.isomorphic.datasource.DataSource;
import com.isomorphic.datasource.Validator;
import com.isomorphic.rpc.RPCManager;

public class TestLookupMainValidatorDMI
{

    @SuppressWarnings({ "rawtypes"})
    public boolean condition(Object value, Validator validator, String fieldName, Map record, DataSource ds, RPCManager rpc, HttpSession session,
                                                                                    HttpServletRequest request, DSRequest dsRequestParam) throws Exception
    {
        System.out.println("Entered the condition for lookup");
        DSRequest dsRequestRPC = dsRequestParam;
        
        if (fieldName.equalsIgnoreCase("COC_FIELD_DESCRIPTION") && "VCOC_LOOKUP_TABLE_test_update".equalsIgnoreCase(dsRequestRPC.getOperation()))
        {
            System.out.println("Entered the condition for lookup desc update: " + value);
            if (value.equals("test4"))
            {
               validator.addErrorMessageVariable("errorInLookUpDesc","This is a restricted value");
               return false;
                
            }
            
        }
        
        return true;
    }
}
