Announcement

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

    Passing generic objects as part of Criteria

    Isomorphic,

    I would like to know if I can pass generic objects, say a Student object as part of criteria. I would like to use this object in DMI. The addCriteria method on Criteria class only allows Strings, Int, Float etc..and arrays of all these types but not generic objects. Any way to pass objects to DMI from client side.

    Another observation: When I push in a variable via addCriteria method on criteria on client side, set it to a String array and don't define it in the ds.xml file, like: criteria.addCriteria("XYZ", new String[]{"A","B","C"}) , here XYZ not defined in ds.xml file. I don't want XYZ to be used in where clause generation which works fine. But the problem is the variable XYZ turns up in the DMI as a String with the first array element as the value - "A in this case". Is this behavior correct.

    Thanks.

    #2
    Criteria must be passed as a simple mapping from property names to values, or in AdvancedCriteria format. If you want to pass a bean you need to pass values in one of these formats, then you can populate the bean with values server-side via DataSource.setProperties().

    As far as the claimed issue with criteria and Arrays / Strings, we'd need to see a test case do we can see the behavior directly.

    Comment


      #3
      Isomorphic,

      I don't have a stand-alone test case at this point, but can share the some code:

      criteria addition:

      Code:
      criteria.addCriteria("MARKETING_AIRLINE", new String[]{"A","B","C"});
      DMI variable access:

      Code:
              System.out.println("Object type in DMI - " + dsRequest.getAdvancedCriteria().getFieldValue("MARKETING_AIRLINE").getClass() + " - " + dsRequest.getAdvancedCriteria().getFieldValue("MARKETING_AIRLINE"));
      Output statement in logs:

      Code:
      Object type in DMI - class java.lang.String - A
      criteria in logs:

      Code:
      criteria: {criteria:[{fieldName:"ORIGIN",operator:"equals",value:"BOM"},{fieldName:"DESTINATION",operator:"equals",value:"DEL"},{criteria:[{value:"A",fieldName:"MARKETING_AIRLINE",operator:"equals"},{value:"B",fieldName:"MARKETING_AIRLINE",operator:"equals"},{value:"C",fieldName:"MARKETING_AIRLINE",operator:"equals"}],operator:"or"},{fieldName:"dateRangeType",operator:"equals",value:"Monthly"},{fieldName:"fromDate",operator:"equals",value:"2430"},{fieldName:"toDate",operator:"equals",value:"2430"},{fieldName:"ORIGIN_LEVEL",operator:"equals",value:"Airport"},{fieldName:"DESTINATION_LEVEL",operator:"equals",value:"Airport"},{fieldName:"AIRLINE_TYPE",operator:"equals",value:"Marketing"},{fieldName:"REPORT_TYPE",operator:"equals",value:"AGGREGATE"},{fieldName:"DIR_SELECTION",operator:"equals",value:"NDIR"},{fieldName:"originSelection",operator:"equals",value:"Airport"},{fieldName:"destSelection",operator:"equals",value:"Airport"},{fieldName:"CLIENT_ID",operator:"equals",value:112},{fieldName:"PRODUCT_ID",operator:"equals",value:"NA_MIDT"}],operator:"and",_constructor:"AdvancedCriteria"}	values: {criteria:[{fieldName:"ORIGIN",operator:"equals",value:"BOM"},{fieldName:"DESTINATION",operator:"equals",value:"DEL"},{criteria:[{value:"A",fieldName:"MARKETING_AIRLINE",operator:"equals"},{value:"B",fieldName:"MARKETING_AIRLINE",operator:"equals"},{value:"C",fieldName:"MARKETING_AIRLINE",operator:"equals"}],operator:"or"},{fieldName:"dateRangeType",operator:"equals",value:"Monthly"},{fieldName:"fromDate",operator:"equals",value:"2430"},{fieldName:"toDate",operator:"equals",value:"2430"},{fieldName:"ORIGIN_LEVEL",operator:"equals",value:"Airport"},{fieldName:"DESTINATION_LEVEL",operator:"equals",value:"Airport"},{fieldName:"AIRLINE_TYPE",operator:"equals",value:"Marketing"},{fieldName:"REPORT_TYPE",operator:"equals",value:"AGGREGATE"},{fieldName:"DIR_SELECTION",operator:"equals",value:"NDIR"},{fieldName:"originSelection",operator:"equals",value:"Airport"},{fieldName:"destSelection",operator:"equals",value:"Airport"},{fieldName:"CLIENT_ID",operator:"equals",value:112},{fieldName:"PRODUCT_ID",operator:"equals",value:"NA_MIDT"}],operator:"and",_constructor:"AdvancedCriteria"}
      Thanks.

      Comment


        #4
        verision: Isomorphic SmartClient Framework (v8.2p_2012-04-03/Enterprise Deployment 2012-04-03)

        Comment


          #5
          Passing an Array in such a Criterion is a convenience over the more correct format of several individual Criteria combined in an OR. That's the representation used server-side so getFieldValue finds the first instance only.

          Comment


            #6
            Isomorphic,

            In your earlier response you had mentioned:

            "If you want to pass a bean you need to pass values in one of these formats, then you can populate the bean with values server-side via DataSource.setProperties(). "

            How do I pass map from client side. I mean should I use dsRequest.setParams() or something else.

            Thanks.

            Comment


              #7
              You can construct either Criteria or a Record from a Map, which would allow you to use fetchData, updateData or addData.

              Comment

              Working...
              X