Announcement

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

    AdvancedCriteria in OperationBinding

    Hi,

    I'm using v8.3p_2013-05-12/PowerEdition Deployment (built 2013-05-12) with PostgreSQL 9.2.2, Firefox 20.0.1 and Tomcat 7.0.33.

    In a couple of my DataSources I'm interested in using the criteria feature of operationBinding to restrict the set of data returned. I have seen examples which do this like:
    Code:
    <operationBinding operationType="fetch">
        <criteria fieldName="deleted" value="false"/>
    </operationBinding>
    I want to use more complicated Criteria in the operation binding.

    I have the case where I want to only return records which match a list of valid values. In Java I can do something like:
    Code:
    new Criterion("eventtype", OperatorId.EQUALS, new Integer[]{2, 4, 5, 11});
    And I'm interested in typical AdvancedCriteria such as:
    Code:
    new AdvancedCriteria(OperatorId.OR, new Criterion[]{
                    new Criterion("eventtype", OperatorId.EQUALS, 2),
                    new Criterion("nodetype", OperatorId.EQUALS, 4)
    });
    What is the syntax for including these two types of criteria in the operationBinding criteria clause?

    Thanks,
    Kevin

    #2
    You can simply insert an <AdvancedCriteria ...> element into your binding.
    For example:
    Code:
        <operationBindings>
            <operationBinding operationId="threatenedFetch" operationType="fetch">
                <criteria>
                    <AdvancedCriteria operator="iEquals" fieldName="status" value="Threatened" />
                </criteria>
    		</operationBinding>
        </operationBindings>
    Edit: To add a little more detail - for nested criteria you can do
    Code:
       <AdvancedCriteria operator="or">
            <criteria>
                 <AdvancedCriteria .../>
                 <AdvancedCriteria .../>
            </criteria>
       </AdvancedCriteria>
    Last edited by Isomorphic; 10 Jun 2013, 11:29. Reason: Added example of nested criteria

    Comment


      #3
      Hi I'm also trying to use AdvancedCriteria in the operationBinding criteria clause, but I can't seem to get the syntax correct. I'm using Power 3.1 (p20130423) with Oracle and FireFox.

      I want to do the below AdvancedCriteria in and operationBinding, could you let me know the correct format.

      Code:
      new AdvancedCriteria(OperatorId.OR, new Criterion[]{
                      new Criterion("type", OperatorId.EQUALS, "C"),
                      new Criterion("type", OperatorId.EQUALS, "G")
      });
      I've tried -
      Code:
              <AdvancedCriteria operator="or">
                <criteria>
                  <AdvancedCriteria  operator="equals" fieldName="type" value="C" />
                  <AdvancedCriteria  operator="equals" fieldName="type" value="G" />
                </criteria>
              </AdvancedCriteria>
      But it doesn't work.

      Thanks
      Andrew
      Last edited by andrew.toon; 20 Jun 2013, 07:49.

      Comment


        #4
        We don't currently support adding AdvancedCriteria via the <criteria> tag for any case more complex than just adding a number of criterions in a flat list, AND'd together. We do plan to add support for AdvancedCriteria of arbitrary complexity via the <criteria> tag, but there is no date for that right now.

        In the meantime, you can shift this logic to a DMI or a server-side script, or a custom whereClause. Moving it to the whereClause is particularly easy:
        Code:
        <whereClause>$defaultWhereClause AND (type = 'C' OR type = 'G')</whereClause>

        Comment

        Working...
        X