Announcement

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

    DMI:DSResponse.getDataList returns null, while query works

    [Using the Power nightly of 06-30-2011]

    Hello,

    I have a DMI that does an extra DSRequest that does some extra fetch. The problem is that while the query works and returns 6 rows, myDSResponse.getDataList() returns null.

    The DMI looks like this:
    Code:
    public DSResponse remove(DSRequest req) throws Exception {
    	//fetch all lecture_presence_rows of this 
    	DSRequest presence = new DSRequest("Lecture_presence_Student", "fetch");
    	presence.setOperationId("AlsoJoinOnCourseEdition");
    	presence.setRPCManager(req.getRPCManager());
    	presence.setCriteria("students_id", req.getFieldValue("students_id"));
    	DSResponse resp = presence.execute();
    	List data = resp.getDataList();
    	// ****** data is null here, while query worked! and actually returned 6 rows.
    }
    The query worked:
    Code:
    === 2011-07-05 10:25:50,435 [l0-5] INFO  SQLDriver - [builtinApplication.AlsoJoinOnCourseEdition] Executing SQL query on 'Mysql': SELECT Student.phone, Lecture_presence_Student.reason, Student.sofinummer, Student.street, Student.surname, Student.city, Student.voorletter, Student.archived, Student.cellphone, Student.birthdate, Student.gender, Lecture_presence_Student.presence_id, Student.number_addition, CourseEdition_students_Student.students_id, Lecture_presence_Student.status, Student.tussenvoegsel, Student.number, Student.firstname, Student.postcode, Student.country, Student.birthplace, Student.email, Student.Moodle_id, Student.active, CourseEdition.CourseEdition_id FROM Lecture_presence_Student 
                       INNER JOIN Student ON Lecture_presence_Student.Student_id = Student.Student_id 
                       INNER JOIN Lecture ON Lecture_presence_Student.Lecture_id = Lecture.Lecture_id
                       INNER JOIN CourseEdition_students_Student ON CourseEdition_students_Student.Student_id=Student.Student_id
                       INNER JOIN CourseEdition ON Lecture.CourseEdition_id=CourseEdition.CourseEdition_id 
           WHERE (CourseEdition_students_Student.students_id='95')
    === 2011-07-05 10:25:50,471 [l0-5] INFO  DSResponse - [builtinApplication.AlsoJoinOnCourseEdition] DSResponse: List with 6 items
    This is the ds.xml operationBinding In question:
    Code:
        <operationBinding requiresRole="ROLE_USER" requiresAuthentication="true" operationType="fetch" operationId="AlsoJoinOnCourseEdition" > 
          <tableClause>Lecture_presence_Student 
                       INNER JOIN Student ON Lecture_presence_Student.Student_id = Student.Student_id 
                       INNER JOIN Lecture ON Lecture_presence_Student.Lecture_id = Lecture.Lecture_id
                       INNER JOIN CourseEdition_students_Student ON CourseEdition_students_Student.Student_id=Student.Student_id
                       INNER JOIN CourseEdition ON Lecture.CourseEdition_id=CourseEdition.CourseEdition_id 
          </tableClause> 
        </operationBinding>
    Am I doing something wrong, or is this a bug? When step-debugging, the object actually DOES contain a JSON string of the returned rows... Bug in API?

    #2
    At a glance this is just not possible: setData() is printing out the log about the number of items so a subsequent call to getData() cannot help but retrieve the data setData() has just stored under the key "data".

    setParameter is equivalent to setProperty()/getProperty(). Can you use these APIs to tell us what's under the "data" property when this getDataList() API isn't working for you?

    Code:
    public void setData(Object data) {
        setParameter("data", data);
        if (data instanceof List) {
            long rowCount = ((List)data).size();
            log.info("DSResponse: List with " + rowCount + " items");
        } else if (data instanceof Map) {
    	long rowCount = ((Map)data).size();
            log.info("DSResponse: Map with " + rowCount + " keys");
        }
    }
    
    public List getDataList() {
        Object data = getData();
        if (data instanceof JSONFilter) data = ((JSONFilter)data).getObj();
        if (data instanceof List) return (List)data;
        return null;
    }
    
    public Object getData() {
        return getParameter("data");
    }

    Comment


      #3
      Okay, thanks.

      This returns an JSONFilter object:
      Code:
      Object o = response.getData();
      It is indeed pretty strange cos there's not htat much happening, and on other parts where I use similar code, it works.

      I did this as a workaround, and now it works
      Code:
      DSResponse resp = presence.execute();
      //List data = resp.getDataList();
      Object d=resp.getData();
      JSONFilter j = (JSONFilter) d;
      List data = (List) j.getObj();
      I have no idea why this would happen...

      Comment

      Working...
      X