Announcement

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

    RESTHandler FETCH and multiple fields result in unexpected XML

    Hi Isomorphic,

    there is a big difference between how IDACall and RESTHandler handle fetches for DataSources with field with multiple="true".
    For RESTHandler, the field is repeated n times, every time with a different value.
    For IDACall, you get an arry like EmployeeStatus:[
    "active",
    "terminated",
    "LOA"
    ]

    Please see this testcase (v12.0p_2019-02-21):

    BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.Version;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.AdvancedCriteria;
    import com.smartgwt.client.data.Criterion;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.SortSpecifier;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.types.SortDirection;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        private VLayout mainLayout;
    
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            mainLayout = new VLayout(20);
            mainLayout.setWidth100();
            mainLayout.setHeight100();
    
            {
                IButton recreateBtn = new IButton("Recreate fetchBadNoVelocityException");
                recreateBtn.setWidth(250);
                recreateBtn.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        recreate();
                    }
                });
                mainLayout.addMember(recreateBtn);
            }
            mainLayout.draw();
            recreate();
        }
    
        private void recreate() {
            Window w = new Window();
            w.setWidth("95%");
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle("Problem with Velocity and .ds.xml RequestModifier" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final ListGrid employeesGrid = new ListGrid();
            employeesGrid.setCanEdit(true);
            employeesGrid.setHeight100();
            employeesGrid.setAutoFetchData(false);
            employeesGrid.setDataSource(DataSource.get("employees"));
    
            ListGridField employeeId = new ListGridField("EmployeeId");
            ListGridField name = new ListGridField("Name");
            ListGridField gender = new ListGridField("Gender");
            ListGridField job = new ListGridField("Job");
            ListGridField employeeStatus = new ListGridField("EmployeeStatus");
    
            employeesGrid.setFields(employeeId, name, gender, job, employeeStatus);
            employeesGrid.setSort(new SortSpecifier[] { new SortSpecifier(name.getName(), SortDirection.ASCENDING) });
            employeesGrid.fetchData(new AdvancedCriteria(new Criterion(name.getName(), OperatorId.LESS_OR_EQUAL, "L")));
            w.addItem(employeesGrid);
            w.show();
        }
    }
    employees..ds.xml:
    Code:
    <DataSource
        ID="employees"
        serverType="sql"
        tableName="employeeTable"
        recordName="employee"
        testFileName="/examples/shared/ds/test_data/employees.data.xml"
        titleField="Name"
    >
        <fields>
            <field name="userOrder"       title="userOrder"       type="integer"  canEdit="false"    hidden="true"/>
            <field name="Name"            title="Name"            type="text"     length="128"/>
            <field name="EmployeeId"      title="Employee ID"     type="integer"  primaryKey="true"  required="true"/>
            <field name="ReportsTo"       title="Manager"         type="integer"  required="true" 
                   foreignKey="employees.EmployeeId"  rootValue="1" detail="true"/>
            <field name="Job"             title="Title"           type="text"     length="128"/> 
            <field name="Email"           title="Email"           type="text"     length="128"/>
            <field name="EmployeeType"    title="Employee Type"   type="text"     length="40"/>
            <field name="EmployeeStatus"  title="Status"          type="text"     multiple="true" length="40">
                <valueMap>
                    <value>active</value>
                    <value>terminated</value>
                    <value>LOA</value>
                </valueMap>
            </field>
            <field name="Salary"          title="Salary"          type="float"/>
            <field name="OrgUnit"         title="Org Unit"        type="text"     length="128"/>
            <field name="Gender"          title="Gender"          type="text"     length="7">
                <valueMap>
                    <value>male</value>
                    <value>female</value>
                </valueMap>
            </field>
            <field name="MaritalStatus"   title="Marital Status"  type="text"     length="10">
                <valueMap>
                    <value>married</value>
                    <value>single</value>
                </valueMap>
            </field>
        </fields>
    </DataSource>
    Start the testcase an change Abigail Meyler to have all three EmployeeStatus-values. Then send this ARC request (if using Chrome)

    ARC Request:
    Code:
    Post URL: http://127.0.0.1:8888/builtinds/sc/RESTHandler
    
    Body:
    <request>
        <dataSource>employees</dataSource>
        <operationType>fetch</operationType>
        <data>
            <EmployeeId>222</EmployeeId>
        </data>
    </request>
    Response:
    Code:
    <?xml version="1.0" ?>
    <response>
    <status>
    0
    </status>
    <queueStatus>
    0
    </queueStatus>
    <startRow>
    0
    </startRow>
    <endRow>
    1
    </endRow>
    <totalRows>
    1
    </totalRows>
    <queueStatus>
    0
    </queueStatus>
    <data>
    <record>
    <OrgUnit>
    Management
    </OrgUnit>
    <Salary>
    7400.0
    </Salary>
    <MaritalStatus>
    single
    </MaritalStatus>
    <Email>
    ameyler@server.com
    </Email>
    [B]<EmployeeStatus>
    active
    </EmployeeStatus>
    <EmployeeStatus>
    terminated
    </EmployeeStatus>
    <EmployeeStatus>
    LOA
    </EmployeeStatus>[/B]
    <userOrder>
    83
    </userOrder>
    <ReportsTo>
    185
    </ReportsTo>
    <Gender>
    female
    </Gender>
    <EmployeeId>
    222
    </EmployeeId>
    <Job>
    Dir Mat Mgmt Admin
    </Job>
    <Name>
    Abigail Meyler
    </Name>
    <EmployeeType>
    part time
    </EmployeeType>
     </record>
    </data>
     </response>
    I'm pretty sure that this is not on purpose, although I don't have any docs on this.

    Also, <queueStatus>0</queueStatus> is there in the response twice again (regression).

    Best regards
    Blama

    #2
    Hi Isomorphic,

    can you tell me if this on purpose or not? If not, I don't need a fix-date right now, I just need to know what it will look like when done, so we can prepare an integration.

    Best regards
    Blama

    Comment


      #3
      The XML structure was fixed shortly after you reported it, but there was an issue with the tag names of the inner values not matching our documentation, which we had to discuss. We plan to fix this back to SGWT 5.1p/SC 11.1p, as of the nightly builds dated tomorrow 2019-03-19.

      Comment


        #4
        Hi Isomorphic,

        thanks. Will the structure be something like (you are mentioning inner tags):
        Code:
        <EmployeeStatus>
        <value>active</value>
        <value>terminated</value>
        <value>LOA</value>
        </EmployeeStatus>
        You are saying "not matching our documentation". I did not find it documented what to expect somewhere. Can you tell me where this is?

        Thank you & Best regards
        Blama

        Comment


          #5
          Yes, that looks right for default output. We're referring to the docs for DataSourceField.childTagName

          Comment


            #6
            Hi Isomorphic,

            thanks, the fix is working for me using v12.0p_2019-03-23.

            Best regards
            Blama

            Comment

            Working...
            X