Announcement

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

    AdvancedCriteria in DataSource.implicitCriteria: is it possible?

    SmartClient Version: SNAPSHOT_v12.1d_2019-04-04/EVAL Deployment (expires 2019.06.03_07.20.41) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

    Hello, I'm trying to use DataSource.implicitCriteria with an AdvancedCriteria.

    I've tried this syntax:

    Code:
        <implicitCriteria operator="and" _constructor="AdvancedCriteria">
                <Criterion fieldName="DATA_CESSAZIONE" operator="isNull"/>
                <criterion operator="and">
                    <criteria>
                        <Criterion fieldName="DATA_DECORRENZA" operator="lessThan" value="$currentDateTime"/>
                        <Criterion fieldName="DATA_CESSAZIONE" operator="greaterThan" value="$currentDateTime"/>
                    </criteria>
                </criterion>
        </implicitCriteria>
    But it produces this fetch criteria:

    Code:
    2019-04-05 18:36:25,564 DEBUG RPCManager Request #1 (DSRequest) payload: {
        criteria:{
            _constructor:"AdvancedCriteria",
            operator:"and",
            Criterion:[
                {
                    fieldName:"DATA_CESSAZIONE",
                    operator:"isNull"
                },
                {
                    operator:"and",
                    criteria:[
                        {
                            fieldName:"DATA_DECORRENZA",
                            operator:"lessThan",
                            value:"$currentDateTime"
                        },
                        {
                            fieldName:"DATA_CESSAZIONE",
                            operator:"greaterThan",
                            value:"$currentDateTime"
                        }
                    ]
                }
            ]
        },
        operationConfig:{
            dataSource:"JOFC_PRESIDENTE_IN_CARICA",
            repo:null,
            operationType:"fetch",
            textMatchStyle:"exact"
        },
    ....
    and I see this message in the log:

    Code:
    2019-04-05 18:36:25,565 WARN  SQLWhereClause [builtinApplication.JOFC_PRESIDENTE_IN_CARICA_fetch] Subcriteria of AdvancedCriteria not an instance of List - using empty ArrayList
    So I've tried this:

    Code:
        <implicitCriteria operator="and" _constructor="AdvancedCriteria">
            <criteria>
                <Criterion fieldName="DATA_CESSAZIONE" operator="isNull"/>
                <criterion operator="and">
                    <criteria>
                        <Criterion fieldName="DATA_DECORRENZA" operator="lessThan" value="$currentDateTime"/>
                        <Criterion fieldName="DATA_CESSAZIONE" operator="greaterThan" value="$currentDateTime"/>
                    </criteria>
                </criterion>
            </criteria>
        </implicitCriteria>
    But on JOFC_PRESIDENTE_IN_CARICA.fetchData()
    I get this js error:
    Code:
    ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:32781 Uncaught TypeError: critArray.removeEmpty is not a function
        at Object.compressNestedCriteria (ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:32781)
        at cons._getCombinedImplicitCriteria (ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:17771)
        at cons.addImplicitCriteria (ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:17779)
        at cons.sendDSRequest (ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:22873)
        at cons.performDSOperation (ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:22701)
        at cons.fetchData (ISC_DataBinding.js?isc_version=v121d_2019-04-04.js:20842)
        at <anonymous>:1:27
    Is it possible to express an AdvancedCriteria in an implicitCriteria?

    Also: is it possible to use a velocity expression in it?

    #2
    You need a <criteria> tag around your set of top-level <criterion> tags - same format as you see elsewhere for <AdvancedCriteria>.

    We don’t support Velocity expressions in inplicitCriteria. You’ve got DMI and ServerScript and DSRequestModifiers as ways of doing dynamic, required criteria.

    Comment


      #3
      Originally posted by Isomorphic View Post
      You need a <criteria> tag around your set of top-level <criterion> tags - same format as you see elsewhere for <AdvancedCriteria>.
      You mean as in my 2nd try?
      Code:
          <implicitCriteria operator="or" _constructor="AdvancedCriteria">
              <criteria>
                  <Criterion fieldName="DATA_CESSAZIONE" operator="isNull"/>
                  <criterion operator="and">
                      <criteria>
                          <Criterion fieldName="DATA_DECORRENZA" operator="lessThan" value="$currentDateTime"/>
                          <Criterion fieldName="DATA_CESSAZIONE" operator="greaterThan" value="$currentDateTime"/>
                      </criteria>
                  </criterion>
              </criteria>
          </implicitCriteria>
      when I execute a fetchData on that dataSource, I get this js error:

      Code:
      10:27:45.244:TMR9:WARN:Log:TypeError: critArray.removeEmpty is not a function
      Stack from error.stack:
          compressNestedCriteria(<no args: exited>) on [Class DataSource] @ ISC_DataBinding.js:32781:23
          cons._getCombinedImplicitCriteria(<no args: exited>) on [DataSource ID:JOFC_PRESIDENTE_IN_CARICA] @ ISC_DataBinding.js:17771:57
          cons.addImplicitCriteria(<no args: exited>) on [DataSource ID:JOFC_PRESIDENTE_IN_CARICA] @ ISC_DataBinding.js:17779:37
          cons.sendDSRequest(<no args: exited>) on [DataSource ID:JOFC_PRESIDENTE_IN_CARICA] @ ISC_DataBinding.js:22873:14
          cons.performDSOperation(<no args: exited>) on [DataSource ID:JOFC_PRESIDENTE_IN_CARICA] @ ISC_DataBinding.js:22701:21
          cons.fetchData(<no args: exited>) on [DataSource ID:JOFC_PRESIDENTE_IN_CARICA] @ ISC_DataBinding.js:20842:14
          eval(<no args: exited>) @ [no file]:1:27
          cons.eval(<no args: exited>) on [Class Log] @ [no file]:3:8
          evalWithVars(<no args: exited>) on [Class Class] @ ISC_Core.js:7528:24
          cons.evaluate(expr=>"JOFC_PRESIDENTE_IN_CARICA.fetchData()...", evalVars=>Obj) on [Class Log] @ ISC_Core.js:29183:36
          cons.evaluate(expr=>"JOFC_PRESIDENTE_IN_CARICA.fetchData()
      ", evalVars=>Obj) on [LogViewer ID:undefined] @ ISC_Core.js:29984:24
          cons.evalJSWithDevConsoleVars(expression=>"JOFC_PRESIDENTE_IN_CARICA.fetchData()
      ", evalVars=>Obj, delayed=>null) on [DebugTarget ID:undefined] @ ISC_Core.js:59887:27
          cons.call(methodName=>Obj, args=>undef, callback=>undef) on [DebugTarget ID:undefined] @ ISC_Core.js:59289:16
          cons.handlePacket(packet=>Obj, originSocket=>[MessagingDMISocket ID:isc_MessagingDMISocket_3], originWindow=>[object Window]) on [DebugTarget ID:undefined] @ ISC_Core.js:59098:10
          cons.packetReceived(packet=>Obj, originSocket=>[MessagingDMISocket ID:isc_MessagingDMISocket_3], originWindow=>[object Window]) on [MessagingDMISocket ID:isc_MessagingDMISocket_0] @ ISC_Core.js:59150:19
          cons.receive(data=>Obj, originSocket=>[MessagingDMISocket ID:isc_MessagingDMISocket_3], originWindow=>[object Window]) on [MessagingDMISocket ID:isc_MessagingDMISocket_0] @ ISC_Core.js:58888:14
          cons.fireCallback(callback=>Obj, argNames=>null, args=>null, target=>null, catchErrors=>true) on [Class Timer] @ ISC_Core.js:7319:36
          cons._fireTimeout(ID=>"_timeout156", tmrID=>171, delayedTmrID=>undef) on [Class Timer] @ ISC_Core.js:47621:10
          <anonymous>() @ ISC_Core.js:47543:19
      is it a bug? please let me know if you need a standalone test case

      Originally posted by Isomorphic View Post
      We don’t support Velocity expressions in inplicitCriteria. You’ve got DMI and ServerScript and DSRequestModifiers as ways of doing dynamic, required criteria.
      ok, thanks
      Last edited by claudiobosticco; 9 Apr 2019, 00:35.

      Comment


        #4
        "criterion" needs a capital letter

        Comment


          #5
          ok, but this gives me the same js error:
          Code:
             
                 <implicitCriteria operator="or" _constructor="AdvancedCriteria">
                      <criteria>
                          <Criterion fieldName="DATA_CESSAZIONE" operator="isNull"/>
                          <Criterion operator="and">
                              <criteria>
                                  <Criterion fieldName="DATA_DECORRENZA" operator="lessThan" value="$currentDateTime"/>
                                  <Criterion fieldName="DATA_CESSAZIONE" operator="greaterThan" value="$currentDateTime"/>
                              </criteria>
                          </Criterion>
                      </criteria>
                  </implicitCriteria>
          client side, it is translated like that:
          Code:
          implicitCriteria:{
                  _constructor:"AdvancedCriteria",
                  operator:"or",
                  criteria:{
                      Criterion:[
                          {
                              fieldName:"DATA_CESSAZIONE",
                              operator:"isNull"
                          },
                          {
                              operator:"and",
                              criteria:[
                                  {
                                      fieldName:"DATA_DECORRENZA",
                                      operator:"lessThan",
                                      value:"$currentDateTime"
                                  },
                                  {
                                      fieldName:"DATA_CESSAZIONE",
                                      operator:"greaterThan",
                                      value:"$currentDateTime"
                                  }
                              ]
                          }
                      ]
                  }
              }

          Comment


            #6
            Hi Isomorphic,

            Originally posted by Isomorphic View Post
            "criterion" needs a capital letter
            this does IMHO not match what you said here, even if that one is not about implicitCriteria. I think clear rules and matching examples do really help here.
            I know that it is possible to find it somewhere in the docs, but you'd to know the docs really good if you ever stumble on something like this to get authoritative information.

            Don't get me wrong, I really like the wast amount of information in the docs and their thoroughness, but sometimes I do miss complex examples, like I also wrote in the linked thread and that would also have helped claudiobosticco here.

            Best regards
            Blama

            Comment


              #7
              Hi claudiobosticco,

              Originally posted by claudiobosticco View Post
              ok, but this gives me the same js error:
              ...
              client side, it is translated like that:
              Why *client* side? You are using the tag in a .ds.xml you load with DataSourceLoader, right? IMHO you should only see this in the server logs.
              The "$currentDateTime" is Velocity, so from #2 I assume this is not supposed to work this way.

              Best regards
              Blama

              Comment


                #8
                Hi Blama, yes I load the dataSource using the loadDS tag, and in the js version of the dataSource I see the implicitCriteria in that form, which doesn't seem correct, so I assume that's why I get a js error when executing dataSource.fetchData.

                Agreed for the Velocity syntax, I just want to understand the correct syntax (or help to understand if it's a bug), and then for my use case I'll use another technique.

                Comment


                  #9
                  Hi Isomorphic, Hi claudiobosticco

                  if #8 is true, this seems like an error to me and a case for this thread.
                  But I don't see any "Criterion" in my result (assuming that loadDS tag is just another way of a DataSourceLoader-call) using my existing .ds.xml.

                  claudiobosticco: Why do you have implicitCriteria in you .ds.xml anyway? I always so only have <criteria... tags and the docs also don't list implicitCriteria.
                  Perhaps it's just a wrong tag that does not get removed?

                  Best regards
                  Blama

                  Comment


                    #10
                    Originally posted by Blama View Post
                    claudiobosticco: Why do you have implicitCriteria in you .ds.xml anyway? I always so only have <criteria... tags and the docs also don't list implicitCriteria.
                    Perhaps it's just a wrong tag that does not get removed?
                    Hi Blama actually I saw it in the reference https://www.smartclient.com/smartcli...plicitCriteria and I assumed it's available also in the .ds.xml.

                    I've asked before about it https://forums.smartclient.com/forum...rid-updatedata and I didn't get a RTM response...for now ;-)

                    Comment


                      #11
                      Hi claudiobosticco,

                      from what it does I do think that the documented .ds.xml criteria do exactly what client side implicitCriteria do.
                      As I stumbled over it: .ds.xml criteria only apply to client initiated requests, not to server-requests (so the same like implicitCriteria defined on a clientside datasource). This is because they are a declarative security feature (this is as answer in some recent thread of mine. I can look it up if necessary.).

                      Best regards
                      Blama

                      Comment


                        #12
                        Apologies, we spoke in error about casing on Criterion - there is indeed a bug with the interpretation of implicitCriteria in DS xml - we'll take a look and update here when it's been fixed.

                        If you want to see things work in the meantime, you can specify your implicitCriteria in js code on the DS or on dataBoundComponents.

                        Comment


                          #13
                          This has now been fixed - you can test out the change in builds dated April 11.

                          For clarity, case doesn't matter because advancedCriteria.criteria / criterion.criteria is a multiple="true" field, and we're using the uniform format for such fields.

                          Comment


                            #14
                            Hi Isomorphic,

                            Originally posted by Isomorphic View Post
                            For clarity, case doesn't matter because advancedCriteria.criteria / criterion.criteria is a multiple="true" field, and we're using the uniform format for such fields.
                            Ah, that makes sense.

                            Originally posted by Isomorphic View Post
                            This has now been fixed - you can test out the change in builds dated April 11.
                            If this means that the tag is supported in .ds.xml DataSource and/or OperationBinding, could you add it to the docs?

                            Can you also explain the difference between implicitCriteria and OperationBinding.criteria?

                            Best regards
                            Blama

                            Comment


                              #15
                              What do you mean by "the tag is supported"? What tag?

                              OperationBinding.criteria is for a specific operationBinding and DataSource.implicitCriteria affects all fetches.

                              Comment

                              Working...
                              X