Announcement

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

    OperationBinding Criteria

    I'm currently trying to filter the results of a fetch operation in my x.ds.xml datasource.

    On a boolean field I'm trying to only return fields that are false, and am using :

    Code:
    <operationBinding operationType="fetch">
    <criteria fieldName="deleted" value="false" operator="EQUALS" />
    </operationBinding>
    This almost works, however it is replacing my operator with the contains operator, ie :

    Code:
    criteria=[{value=false, fieldName=deleted, operator=contains}]
    How do I write the XML to get the desired operator to be used?

    #2
    This currently can't be done solely from XML (although it would be a handy enhancement). Instead, add a DMI that manipulates the criteria in the DSRequest (see getAdvancedCriteria()/setAdvancedCriteria()).

    Comment


      #3
      Is this still not supported?

      The doc for com.smartgwt.client.docs.serverds
      Class OperationBinding state:

      http://smartclient.com/smartgwtee/javadoc/com/smartgwt/client/docs/serverds/OperationBinding.html#criteria

      "Simple criteria: The field and value are just applied as an extra key/value pair in the criteria map, as long as the operator attribute is left unset, or is set to "equals". "

      Does that not imply I should be able to set the operator to "equals". I have tried but it always comes across as "contains".

      Comment


        #4
        This was added as an enhancement in 3.1, but the operatorId would be "equals" not "EQUALS".

        Comment


          #5
          What would the xml look like since I must have it wrong. Here is what I am trying:

          <criteria fieldName="enabled" value="1" operatorId="equals"/>

          I also tried:

          <criteria fieldName="enabled" value="1" operator="equals"/>

          Thanks.

          Comment


            #6
            The second one is correct, assuming there's a field "enabled", you are on 3.1, and 1 is a valid value present in the data.. if you're having trouble, post the complete DataSource definition and the logs for the request that isn't behaving how you'd like.

            Comment


              #7
              Here is our ds.xml file (I removed some fields that are not relevant:

              Code:
              <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
              <DataSource xmlns:fmt="WEB-INF/" ID="trigger" serverType="generic">
                  <fmt:bundle basename="dictionary"/>
                  <title><fmt:message key="ops_trigger.label"/></title>
                  <pluralTitle><fmt:message key="ops_trigger.label.plural"/></pluralTitle>
                  <fields>
                      <field name="name" type="text" length="100" required="true">
                          <title><fmt:message key="ops_trigger.name.label"/></title>
                          <prompt><fmt:message key="ops_trigger.name.hint"/></prompt>
                      </field>
                      <field name="enabledOpsfield" type="boolean">
                          <title><fmt:message key="ops_trigger.enabled_opsfield.label"/></title>
                          <prompt><fmt:message key="ops_trigger.enabled_opsfield.hint"/></prompt>
                      </field>
                      <field name="calendar" foreignKey="calendar.sysId" defaultValue="77171434c0a801c9016d5b2b5d17ddee">
                          <title><fmt:message key="ops_trigger.calendar.label"/></title>
                          <prompt><fmt:message key="ops_trigger.calendar.hint"/></prompt>
                      </field>
                      <field name="description" type="text" length="100">
                          <title><fmt:message key="ops_trigger.description.label"/></title>
                          <prompt><fmt:message key="ops_trigger.description.hint"/></prompt>
                      </field>
                  </fields>
                  <serverObject lookupStyle="new" className="xxx.TriggerDS"/>
                  <operationBindings>
              		<operationBinding operationType="fetch" operationId="findTriggerReferences">
              			<serverObject className="xxx.TriggerDS" methodName="findTriggerReferences" />
              		</operationBinding>
              		<operationBinding operationType="fetch" operationId="findActiveTriggers">
              			<serverObject className="xxx.TriggerDS" methodName="findActiveTriggers" />
              			<criteria fieldName="enabledOpsfield" value="1" operator="equals" />
              		</operationBinding>
                  </operationBindings>
              </DataSource>
              Here is the what I see on our server side DS:
              AdvancedCriteria ac = req.getAdvancedCriteria();
              System.out.println("AdvancedCriteria: " + ac.toString());

              AdvancedCriteria: AdvancedCriteria:[and:[{enabledOpsfield contains 1}]]

              We are using SmartGWT 4.0

              And here is the client request payload:
              Code:
              === 2013-02-26 16:12:30,839 [l0-9] DEBUG RPCManager - Request #1 (DSRequest) payload: {
                  criteria:{
                  },
                  operationConfig:{
                      dataSource:"trigger",
                      operationType:"fetch",
                      textMatchStyle:"substring"
                  },
                  startRow:0,
                  endRow:100,
                  sortBy:[
                      "name"
                  ],
                  componentId:"isc_ListGrid_0",
                  appID:"builtinApplication",
                  operation:"findActiveTriggers",
                  oldValues:{
                  }
              }

              Comment


                #8
                We really need the complete server log for the request (not just the log of the payload). It has a lot of details that could reveal the source of the issue.

                Comment


                  #9
                  From the smartClientServerLog.txt:
                  Code:
                  2013-02-27-11:17:03:186  DEBUG [btpool0-4] Processing 1 requests.
                  2013-02-27-11:17:03:208  DEBUG [btpool0-4] Request #1 (DSRequest) payload: {
                      criteria:{
                      },
                      operationConfig:{
                          dataSource:"trigger",
                          operationType:"fetch",
                          textMatchStyle:"substring"
                      },
                      startRow:0,
                      endRow:100,
                      sortBy:[
                          "name"
                      ],
                      componentId:"isc_ListGrid_0",
                      appID:"builtinApplication",
                      operation:"findActiveTriggers",
                      oldValues:{
                      }
                  }
                  2013-02-27-11:17:03:245  DEBUG [btpool0-4] Processing security checks for DataSource null, field null
                  2013-02-27-11:17:03:245  DEBUG [btpool0-4] DataSource trigger is not in the pre-checked list, processing...
                  2013-02-27-11:17:08:410   INFO [btpool0-4] DSResponse: List with 0 items

                  Comment


                    #10
                    That's missing a lot of the logs we normally see - did you disable log categories relative to the default? We're expecting various logs related to finding the DMI target, for example.

                    Comment


                      #11
                      I am using the same log4j configuration file that is in the samples with the only change being the ConversionPattern and the FILE_LOG location:

                      Code:
                      <?xml version="1.0" encoding="UTF-8" ?>
                      <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
                      
                      <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
                      
                        <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
                          <layout class="org.apache.log4j.PatternLayout">
                            <!-- 
                            <param name="ConversionPattern" value="=== %d [%.4t] %-5p %c{1} - %m%n" />
                            -->
                            <param name="ConversionPattern" value="%d{yyyy-MM-dd-HH:mm:ss:SSS} %6p [%t] %m%n" />
                          </layout>
                        </appender>
                      
                        <appender name="FILE_LOG" class="org.apache.log4j.FileAppender">
                          <param name="File" value="/Users/mcolwell/temp/smartClientServerLog.txt" />
                          <param name="Append" value="false" />
                          <layout class="org.apache.log4j.PatternLayout">
                            <param name="ConversionPattern" value="%d{yyyy-MM-dd-HH:mm:ss:SSS} %6p [%t] %m%n" />
                          </layout>
                        </appender>
                      
                          <!-- This appender is used by the "Server Logs" tab in the Developer Console. -->
                        <appender name="SmartClientLog" class="com.isomorphic.log.RevolvingMemoryAppender">
                          <param name="maxEntries" value="500" />
                          <layout class="org.apache.log4j.PatternLayout">
                            <param name="ConversionPattern" value="%d{yyyy-MM-dd-HH:mm:ss:SSS} %6p [%t] %m%n" />
                          </layout>
                        </appender>
                      
                          <!-- isomorphic log messages -->
                          <!-- The STDOUT appender defined above is set as the default appender for all Isomorphic
                               SmartClient server logging.  It should typically be visible in the console from which
                               you started the application server.
                               
                               Some Application Servers redirect stdout output to a file (typically called stdout.log
                               or something like that, so you should be able to find it there.
                      
                               If you can't find the server log, you should be able to use the SmartClientLog (above)
                               which is visible in the Developer Console under "Server Logs" and as a standalone log
                               viewer in /tools/serverLogViewer.jsp.  
                               
                               Failing all of the above, you can switch the appender-ref value for the com.isomorphic
                               category to use the FILE_LOG appender which will log to /smartClientServerLog.txt on
                               UNIX and C:\smartClientServerLog.txt on Windows.  You can change this by modifying the
                               value of the "File" param in the FILE_LOG definition above.
                          -->
                        <category name="com.isomorphic">
                          <priority value="DEBUG" />
                          <appender-ref ref="STDOUT" />
                          <appender-ref ref="FILE_LOG" />
                          <appender-ref ref="SmartClientLog" />
                        </category>
                      
                        <category name="com.isomorphic.base.Reflection">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.base.ISCInit">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.base.ConfigLoader">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.download.Download">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.sql.ValueSet">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.servlet.RequestContext">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.datasource.DataSource">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.datasource.BasicDataSource">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.datasource.AuditDSGenerator">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.validation.Validation">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.store.DataStructCache">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.assembly.FileAssembler">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.obfuscation.Obfuscator">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.servlet.PreCache">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.timing.Timing">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.resultData.ResultData">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.js.JSSyntaxScannerFilter">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.interfaces.InterfaceProvider">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.compression.Compression">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.servlet.ProxyHttpServletResponse">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="com.isomorphic.naming.JNDI">
                          <priority value="WARN" />
                        </category>
                      
                        <category name="com.isomorphic.scripting">
                          <priority value="INFO" />
                        </category>
                      
                        <category name="org.apache.velocity">
                          <priority value="WARN" />
                        </category>
                      
                        <category name="org.hibernate.SQL">
                          <priority value="DEBUG" />
                        </category>
                      
                          <!-- shows values bound to params in SQL query, but produces a lot of output -->
                          <!--
                        <category name="org.hibernate.type">
                          <priority value="DEBUG" />
                            <appender-ref ref="STDOUT"/>
                        </category>
                          -->
                      
                        <!-- embedded tomcat -->
                        <category name="org.apache">
                          <priority value="INFO" />
                          <appender-ref ref="STDOUT" />
                          <appender-ref ref="SmartClientLog" />
                        </category>
                      
                          <!-- hibernate log messages -->
                        <category name="org.hibernate">
                          <priority value="DEBUG" />
                          <appender-ref ref="STDOUT" />
                          <appender-ref ref="SmartClientLog" />
                        </category>
                      </log4j:configuration>

                      Comment


                        #12
                        OK.. at this point we'd suggest you:

                        1. make really sure you're using recent *server* .jars. Maybe someone upgraded the client side but not the server side

                        2. try to modify an SDK sample to see if you can show this feature not working. We already have automated tests showing it's working fine in general, but maybe you've got an edge case.

                        Comment

                        Working...
                        X