Announcement

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

    setCriteria and setSortBy methods on com.isomorphic.datasource.DSRequest

    We're using the Isomorphic classes for database access in our server side code, but the documentation is very sparse. For example;

    setCriteria(java.lang.Object criteria)
    Sets the criteria for this DSRequest.

    What sort of Object can the critiera be? A simple Map of field name and value seems to work. But is there any way to do more complex criteria like "field != value".

    I also don't see any documentation on the setSortBy() method, although sending it a value ORDER BY clause seems to work.

    Is there additional documentation available for Pro or EE users?

    #2
    What docs are you reading? Here's what comes with EE - it's much more specific and interlinks with further documentation.

    Comment


      #3
      I see there is a little more detail there. I hadn't clicked the link to the rest. But I still don't see how a Map or a List of Maps let's you specify different operators like < > IN, NOT IN, etc. And still no documentation on how to specify sort order.

      Comment


        #4
        In JavaDoc, if you don't click through, you see the first sentence of the doc only.

        An unfortunate typo kept the docs for setSortBy() from being seen. As getSortByFields() suggests, it takes either a String or List of Strings.

        Remember, the server side object is just a reflection of the client-side DSRequest. So there are additional clarifying docs there. In particular, the AdvancedCriteria format is covered in client-side docs.

        Comment


          #5
          I'm still not getting it. On the server side there is an isomorphic AdvancedCriteria class that doesn't have the same constructors as the client-side smartgwt AdvancedCriteria class. Should we use the client side classes on the server? If not, how do you construct and AdvancedCriteria on the server side.

          Comment


            #6
            Ignore the server-side AdvancedCriteria class and stick to documented classes. It's not documented because it's part of future functionality not ready for your use.

            The client side AdvancedCriteria docs explain the structure in terms of JavaScript collections... but it looks like those got wiped out too. We'll correct that, in the meantime, take a look at the SmartClient docs for AdvancedCriteria (which you should see on the AdvancedCriteria JavaDoc once we fix this issue) and note the link that explains how the criteria are translated to server-side Java Objects - basically Collections. To create AdvancedCriteria server-side, form those same collections in server-side Java code.

            Comment


              #7
              Are there any helpers to create the right sort of Collections. I'm not seeing a simple way to create a Collection that represents.

              var advancedCriteria = {
              _constructor:"AdvancedCriteria",
              operator:"and",
              criteria:[
              // this is a Criterion
              { fieldName:"salary", operator:"lessThan", value:"80000" },
              { operator:"or", criteria:[
              { fieldName:"title", operator:"iContains", value:"Manager" },
              { fieldName:"reports", operator:"notNull" }
              ]
              }
              ]
              }

              Comment

              Working...
              X