Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    textMatchStyle substring now also goes for server-side added criteria

    Hello,

    using: SmartClient Version: v8.3p_2013-01-09/PowerEdition Deployment (built 2013-01-09)

    Since the recent versions, a change in the way you guys convert criteria to SQL has changed, in, for me, a bad way.

    This is because my app has a SecureIDACall servlet, an extension of your version, that should add a certain criteria to *each* fetch DSRequest:
    Code:
    {SaasCustomer_id : 12}
    My secureIDACall will add this like so:
    Code:
    public class SecureIDACall extends IDACall {
    
    	protected final Log logger = LogFactory.getLog(getClass());
    
    	public void processRequest(HttpServletRequest request,
    			HttpServletResponse response) throws ServletException, IOException {
                   //....
                  dsRequest.setFieldValue("SaasCustomer_id",user.getSaasCustomer_id());
    	     DSResponse resp = handleDSRequest(r, rpc, context);
    	     rpc.send(dsRequest, resp);
    
             }
    }
    In previous versions, this worked great; the criteria was added to the existing critiria and AND'ed to the query like so:

    Code:
    *some other criteria* AND SomeTable.SaasCustomer_id=12
    However, now, if there is a listgrid, and the incoming request has textMatchStyle="substring", it will resolve to:
    Code:
    *some other criteria* AND SomeTable.SaasCustomer_id LIKE %12%
    This way, I can't enforce the SaasCustomer_id to be exactly 12 anymore.

    Is there a workaround for this, *without* having to add it to each operationbinding manually, or downgrading? I use this pattern in multiple applications.
    Last edited by Sytematic; 21 Jan 2013, 05:36.

    #2
    There was a bugfix here where textMatchStyle was not being applied to integer fields, which prevented use cases like substring filtering on numeric IDs.

    Correct code for your situation (which would work with either version), would be to obtain AdvancedCriteria, and then add your additional criteria with the exact match operator.

    Comment


      #3
      Thanks. Two questions about your answer:

      1) Do you mean that this has been fixed after january 9th's build? Or do you mean that it was broken before, and the behaviour that I am seeing is actually the correct one, or ...?

      2) I had considered converting each standard criteria that comes in in SecureIDACall into an AdvancedCriteria, and AND'ing my SaasCustomer_id criteria.

      What is the best way to convert a normal criteria to advanced criteria, is there an api for this?

      Comment


        #4
        1. was broken, now fixed

        2. dsRequest.getAdvancedCriteria()

        Comment


          #5
          Great that works, I modified my SecureIDACall as follows:

          Code:
          AdvancedCriteria c = dsRequest.getAdvancedCriteria();
          c = addSaasCustomerIdToCriteria(c,user.getSaasCustomer_id());
          dsRequest.setAdvancedCriteria(c);
          With the helper function being:
          Code:
          private AdvancedCriteria addSaasCustomerIdToCriteria(
          			AdvancedCriteria c, int SaasCustomer_id) {
          	Criterion criterion = c.asCriterion();
          		
          	Criterion saasCriterion = new SimpleCriterion("SaasCustomer_id", "equals", SaasCustomer_id);
                  //AND'ing the current criteria, whatever they are, with the saasCriterion.		
          	AdvancedCriteria ret = new AdvancedCriteria(DefaultOperators.And, 
          			new Criterion[] {
          				saasCriterion , criterion
          			}
          	);
          
          	return ret;
          }
          ... for those who want to do something similar, like enforcing the AND'ing of some numeric value.

          Comment

          Working...
          X