Announcement

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

    Working with advanced criteria in DMI

    Isomorphic,

    I have a situation where I cannot push some fields in the defaultWhereClause and need to construct my own whereClause for those fields in DMI and push that to the ds.xml via addToTemplateContext. I need this because I have a query which calculates share at different levels, so query has sub-query. But if I look at the structure of advanced criteria as map in DMI, it's bit complex with lots of Lists and HashMap. What is the best way to read through this map and identify the fields that I would like to use in my custom where clause construction.

    What I mean is, is there any utility methods which when supplied with fieldName identifies any possible conditions within the advancedCriteriaMap and then gives it to you as a Criterion etc. instead of me writing the whole map navigation code.

    Thanks.

    #2
    See DSRequest.getAdvancedCriteria() - there is a whole slew of helper classes for conveniently navigating and modifying this structure.

    Comment


      #3
      Isomorphic,

      I only see these three methods in the API on AdvancedCriteria

      Code:
       Criterion	asCriterion() 
                Convert AdvancedCriteria into Criterion format.
       java.util.Map	getCriteriaAsMap() 
                Convert AdvancedCriteria into Map object.
       java.lang.Object	getFieldValue(java.lang.String fieldName) 
                Search for the value of given field recursively going deep.
      So the output I can get to is the getCriteriaAsMap which I have to manually navigate. All other methods in dsRequest like getCriteriaValue return only the first value of the field.

      Thanks.

      Comment


        #4
        Ah, the problem is, in this case there are a few methods that you need that aren't documented. Please consider the following as though they are supported APIs (their functionality should be self-explanatory):

        Criterion.getFieldName(), getValue(), getOperatorId()
        LogicalCriterion.getCriteria()
        RangeCriterion.getMin(), getMax()
        SetCriterion.getValues()

        We'll get these officially doc'd. Please let us know if you see other methods with the public qualifier that you seem to need to use in order to do traversal.

        Comment


          #5
          Isomorphic,

          Are there any criteria utility methods for server side like splitCriteria,combineCriteria which are available on client-side.

          Thanks.

          Comment


            #6
            No, sorry, we did not add such methods server-side.

            Comment


              #7
              Originally posted by Isomorphic View Post
              See DSRequest.getAdvancedCriteria() - there is a whole slew of helper classes for conveniently navigating and modifying this structure.
              Can you please name mentioned helper classes? I can't find anything useful to modify AdvancedCriteria, all that i found is Evaluator.

              Or the only way to modify advancedCriteria (for example substitute a criterion) is to work with Map?

              Comment


                #8
                Do you see packages com.isomorphic.criteria and com.isomorphic.criteria.criterion, with all those helper classes? That's what we meant. Also utility methods such as dsRequest.getCriteriaValue().

                Together these classes make it pretty easy to work with and modify AdvancedCriteria. Let us know if you have further helper methods to suggest.

                Comment

                Working...
                X