Announcement

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

    timeline + restdatasource

    We are currently having trouble understanding how to properly create a Timeline bound to a RestDataSource. We want to leverage the paging mechanism provided by smartGWT because the data size is potentially quite large.

    Our current logic is the following:
    1) Create the timeline (autoFetchData(false), a datasource is provided to the timeline as well).
    2) Fetch once all the data (from another datasource), so we can create the lanes. After that the datasource which is bound to the timeline will be providing the events with "lane" and "sublane" properties set.
    3) Call timeline.fetch(), so it can populate itself with data.

    The 3rd point is where we have currently an issue. We are able to verify that the datasource which is bound to the timeline actually returns the correct result. However, the callback in the timeline.fetch(null, new DSCallback...) has an empty Record[] in the dsResponse.getData() property and then no events are shown.

    If we do not set a datasource to the timeline, and instead use dataSource.fetchData() and in its callback we call timeline.setData() everything is fine, so we verified that the Records can actually be processed by the timeline and it's not an issue of the data given to it. But this is not what we want since paging is not going to work (is that correct?).

    Can you provide some insight? Maybe there is an example of a timeline bound to a RestDataSource?

    SmartClient Version: v10.0p_2014-09-25/Pro Deployment (built 2014-09-25)
    Last edited by klevi; 26 Sep 2014, 01:44. Reason: added smartgwt version

    #2
    Are you calling timeline.setLanes()? Is that happening before or after the timeline is drawn? Try calling it before draw.

    You mentioned calling timeline.fetch() - presumably, you meant fetchData()? - if you call dataSource.invalidateCache() right before calling timeline.fetchData(), does that fix it?

    Comment


      #3
      setLanes() is called before the timeline is drawn. Fetching is also initially applied before that.

      You are correct. I meant fetchData(). Calling invalidateCache() did not fix it.

      Have a look at the attached file. This is the actual source we are using (I have trimmed everything unnecessary). Take a look at the updateData() method, I have commented what I have tried and what I found out.

      I have also provided the datasource source - that is the datasource which is bound to the timeline, not the one which initially fetches the Orders to provide the lanes. But anyway I don't believe the datasource could be the problem because manually setting the events of the timeline using timeline.setData() with the records provided by this datasource actually works.

      Somehow, records are lost somewhere between the datasource transformResponse() (which I overrode just to print some records) and the DSCallback of the timeline.fetchData().
      Also just to clarify, it's not only the events that are not drawn, but the whole timeline.

      This in an excerpt from the logs:
      Code:
      09:44:34.492:XRP1:WARN:ResultSet:isc_ResultSet_3 (created by: isc_Timeline_0):fetchData callback: dsResponse.endRow set to:75. dsResponse.totalRows set to:45. endRow cannot exceed total dataset size. Clamping endRow to the end of the dataset (45).
      09:44:34.516:XRP1:WARN:Log:TypeError: _12 is null
      Stack from error.stack:
          CalendarView.refreshEvents() @ com.siemens.opal.ui.Main/sc/modules/ISC_Calendar.js:192:416
          Calendar.refreshSelectedView() @ com.siemens.opal.ui.Main/sc/modules/ISC_Calendar.js:373:1171
          Calendar.dataChanged() @ com.siemens.opal.ui.Main/sc/modules/ISC_Calendar.js:373:267
          anonymous() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js line 76 > Function:2:1
          thunk() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:319:25
          observation() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:316:375
          ResultSet._doneChangingData() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:1900:24
          ResultSet._handleNewData() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:1863:1
          isc.A.fetchRemoteDataReply() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:1849:98
          [c]Class.fireCallback() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:285:42
          [c]Class.fireCallback() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:353:279
          DataSource.fireResponseCallbacks() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:727:69
          DataSource._completeResponseProcessing() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:724:1
          DataSource._completeHandleXMLReply() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:701:256
          [c]Class.fireCallback() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:285:42
          [c]Class.fireCallback() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:353:279
          DataSource._completeDSResponseFromXML() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:706:45
          [c]Class.fireCallback() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:285:42
          [c]Class.fireCallback() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:353:279
          DataSource.recordsFromXML() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:710:43
          DataSource.selectRecords() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:707:203
          DataSource.dsResponseFromXML() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:701:502
          DataSource._handleXMLReply() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:701:172
          [c]Class.fireCallback() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:285:42
          .$37c() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:73:77
          [c]Class.fireCallback() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:285:42
          [c]Class.fireCallback() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:353:279
          anonymous() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:1664:130
          Zub/$wnd.isc.RPCManager.fireReplyCallback() @ com.siemens.opal.ui.Main/DF40A9F82342FF139794D0845D8305A0.cache.html:3083:3688
          [c]RPCManager.fireReplyCallbacks() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:1671:115
          [c]RPCManager.performOperationReply() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:1662:1
          RPCManager._performTransactionReply() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:1642:1
          [c]RPCManager.performTransactionReply() @ com.siemens.opal.ui.Main/sc/modules/ISC_DataBinding.js:1557:15
          anonymous() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js line 76 > Function:1:1
          [c]Class.fireCallback() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:285:42
          [c]Comm.performXmlTransactionReply() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:1231:75
          anonymous() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js line 76 > Function:1:1
          [c]Class.fireCallback() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:285:42
          Comm._fireXMLCallback() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:1211:443
          Comm.sendXmlHttpRequest/_13() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:1218:1188
      
      09:44:35.438:MUP4[E1]:WARN:Log:TypeError: _18 is null
      Stack from error.stack:
          CalendarView.getVisibleEvents() @ com.siemens.opal.ui.Main/sc/modules/ISC_Calendar.js:171:268
          CalendarView.refreshVisibleEvents() @ com.siemens.opal.ui.Main/sc/modules/ISC_Calendar.js:162:1
          CalendarView.resized() @ com.siemens.opal.ui.Main/sc/modules/ISC_Calendar.js:97:482
          isc.A.$5y() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2431:69
          Canvas._completeResizeBy() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2428:27
          Canvas.resizeBy() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2424:1
          Canvas.resizeTo() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2437:920
          Layout.resizeMembers() @ com.siemens.opal.ui.Main/sc/modules/ISC_Foundation.js:294:105
          Layout.layoutChildren() @ com.siemens.opal.ui.Main/sc/modules/ISC_Foundation.js:336:1
          Canvas._completeResizeBy() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2426:8
          Canvas.resizeBy() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2424:1
          Canvas.resizeTo() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2437:920
          Layout.resizeMembers() @ com.siemens.opal.ui.Main/sc/modules/ISC_Foundation.js:294:129
          Layout.layoutChildren() @ com.siemens.opal.ui.Main/sc/modules/ISC_Foundation.js:333:1
          Canvas._completeResizeBy() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2426:8
          Canvas.moveBy() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2381:7
          Canvas.moveTo() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2406:98
          Canvas.setRect() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2187:57
          Canvas._resolvePercentageSize() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2476:2
          Canvas.parentResized() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2473:366
          Canvas._resolveChildPercentSizes() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2437:673
          Canvas.layoutChildren() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2437:502
          Canvas._completeResizeBy() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2426:8
          Canvas.resizeBy() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2424:1
          Canvas.resizeTo() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2437:920
          Layout.resizeMembers() @ com.siemens.opal.ui.Main/sc/modules/ISC_Foundation.js:294:105
          Layout.layoutChildren() @ com.siemens.opal.ui.Main/sc/modules/ISC_Foundation.js:333:1
          Canvas._completeResizeBy() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2426:8
          Canvas.resizeBy() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2424:1
          Canvas.resizeTo() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:2437:920
          Layout.resizeMembers() @ com.siemens.opal.ui.Main/sc/modules/ISC_Foundation.js:294:105
          Layout.layoutChildren() @ com.siemens.opal.ui.Main/sc/modules/ISC_Foundation.js:333:1
          Layout.reflowNow() @ com.siemens.opal.ui.Main/sc/modules/ISC_Foundation.js:347:590
          Layout.reflow/<() @ com.siemens.opal.ui.Main/sc/modules/ISC_Foundation.js:347:480
          [c]EventHandler.runTeas() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:1606:106
          EventHandler._clearThread() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:1605:98
          [c]EventHandler.dispatch() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js:1608:1
          anonymous() @ com.siemens.opal.ui.Main/sc/modules/ISC_Core.js line 76 > Function:1:85
      Attached Files

      Comment


        #4
        This points to the values being delivered in the startDate field - calendar.getEventStartDate(record) is returning null.

        What format are your date-values being delivered in? You can check the values in your transformResponse() override.

        Comment


          #5
          This is the code:
          Code:
              for (Record record : records) {
                SC.logWarn("startDate == " + record.getAttribute("startDate"));
                SC.logWarn("startDate as String == " + record.getAttributeAsString("startDate"));
                SC.logWarn("startDate as Date == " + record.getAttributeAsDate("startDate"));
                SC.logWarn("endDate == " + record.getAttribute("endDate"));
                SC.logWarn("endDate as String == " + record.getAttributeAsString("endDate"));
                SC.logWarn("endDate as Date == " + record.getAttributeAsDate("endDate"));
              }
          This is the output:
          Code:
          13:05:08.066:XRP3:WARN:Log:startDate == Mon Sep 15 2014 09:00:00 GMT+0200
          13:05:08.067:XRP3:WARN:Log:startDate as String == Mon Sep 15 2014 09:00:00 GMT+0200
          13:05:08.068:XRP3:WARN:Log:startDate as Date == Mon Sep 15 09:00:00 GMT+200 2014
          13:05:08.069:XRP3:WARN:Log:endDate == Mon Sep 15 2014 09:00:00 GMT+0200
          13:05:08.070:XRP3:WARN:Log:endDate as String == Mon Sep 15 2014 09:00:00 GMT+0200
          13:05:08.071:XRP3:WARN:Log:endDate as Date == Mon Sep 15 09:00:00 GMT+200 2014
          I don't see any issues with this... the start and end dates are successfully converted to Date objects. I can verify that every Record has a "startDate" and "endDate" as well. They also have different "eventId"s.
          Also I assumed these exceptions are a side effect of the Record[] in the
          Code:
                  timeline.fetchData(null, new DSCallback() {
          
                    @Override
                    public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
          
                      Record[] records = dsResponse.getData();
                      SC.logWarn("records.length == " + records.length);
                    }
                  });
          is actually empty, even if the Datasource shows 45 rows returned.

          Comment


            #6
            What do you see in the Developer Console RPC tab? What actual response is being returned?

            We may need to see a running testcase that demonstrates the issue.

            Comment


              #7
              How shall we do that test case?
              I can provide the client, and the XML which the REST service should return, so you can host it on something lightweight - would that be OK for you?

              Comment


                #8
                Yes, that should be fine - just an entry point that builds your Timeline, including lane-data and the raw XML/a dummy response from the Dev Console should be enough

                Comment


                  #9
                  After some further testing, we were able to get the same crash you showed in your earlier post, where there was an issue with startDate data.

                  The reason was that one of the dates specified in XML was malformed - it was like this:

                  Code:
                  <endDate>2012-07-01 2012 23:59:59</endDate>
                  So, there was a value there, but it was invalid - our advice is that you look for similar issues in each date field in your test data, especially if somebody typed the values in. In particular, test entry 45.

                  Comment


                    #10
                    Thanks for the suggestions but I am unable to confirm that there is any problem with the dates. This is also impossible because they are coming from the database and are immediately transferred by the REST service.
                    Please find the test-case provided in the attached files. The "expected_response.txt" contains the test XML returned by the REST service. Of course you have to mock it somehow.
                    Note this piece of code in the constructor:
                    Code:
                        boolean showBroken = true;
                        if (showBroken) {
                          broken();
                        } else {
                          working();
                        }
                    Switch the showBroken flag to false if you want to see how the data looks like.
                    Attached Files
                    Last edited by klevi; 30 Sep 2014, 04:03. Reason: fixed typo

                    Comment


                      #11
                      A few things...

                      In your RestDataSource, you setRecordXPath() - see the doc for that method - you should be using setXmlRecordXPath() in your case.

                      In your function that calls setStartDate() and setEndDate() on the Calendar, don't do that - instead use setTimelineRange() which accepts both values and works after draw

                      In the expected_response, the endRow is wrong - it should be 39, because there are 40 rows in the file - but it is set to zero. Presumably, the mismatched totalRows value of 45 is just some arbitrary figure for this sample code.

                      You need to use setEvent*Canvas*HoverHTMLCustomizer() instead of setEventHoverHTMLCustomizer() - the latter doesn't work with EventCanvas which is the default class for rendering events in 5.0.

                      With those changes, this altered broken() method now works:

                      Code:
                        private void broken() {
                          createLanes();
                          // set up start and end dates before fetching
                          timeline.setTimelineRange(minDate, maxDate);
                          timeline.setDataSource(dataSource);
                          timeline.fetchData(null, new DSCallback() {
                            @Override
                            public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
                              determineMinMaxDate();
                              createIndicator();
                              updateResolution();
                            }
                      	});        
                        }
                      Note that we also addressed a related issue that may still be involed with this one - if you still see crashes regarding start/end dates after making the above changes, please retest with tomorrow's build before reporting back.

                      Comment


                        #12
                        With the latest SmartClient Version: v10.0p_2014-10-02/Pro Deployment (built 2014-10-02) this is now working.
                        Thanks for the additional things you have pointed out.

                        Comment

                        Working...
                        X