• XPages based Calendar Controls in Teamroom Template AND RDBMS DB

    By cyrus mobaraki 1 decade ago

    Hello,

    Could someone give me some hint related to the Xpages. I would like to interact Xpage calendar code used in the following project “teamrmOpenNTF.ntf” with the postgres database.

    My aim is to read data from Postgres database and show the entry from a table in Postgres Database depend of the date and time into the Calendar page. I like to keep all existing functionalities but instead of Lotus note DB (views) using the Postgres DB.

    I have used the Calendar.xsp, CalendarEntry.xsp  XPages and its Custome Control (calendarView), Forms (calendarOutline) and the Views (Event) from the “teamrmOpenNTF.ntf”  into my project which I am developing now.

    http://www.openntf.org/Projects/pmt.nsf/downloadcounter?openagent&project=TeamRoom%20OpenNTF%208.5.2&release=01/29/11&unid=AFAAF409DB2424EA862578270037127F&attachment=Teamroom110129.zip


    in the teamrmOpenNTF.ntf example the backend database used is the Lotus Notes database using view and Forms. I would like to use the same code but instead to get the data from my “Postgres” database and render it to the calendar page.

     
    Either I have to change the view (calendarOutlin) to get the data from my DB or change the following code (calendarView Coustom Control) to fetch the data from the db and ignore the forms and views used from “teamrmOpenNTF.ntf” application.

    If my assumption is correct then I don’t know how I can do this and which one is the best option. Can you help me please to achieve this goal or that is something not achievable at the moments with Xpage Calendar.




        preventDojoStore="false">

       
       
          viewName="calendarOutline" var="entry" contentType="text/plain"
          colCalendarDate="CalDateTime" colEntryIcon="Icon"
        colStartTime="StartDateTime" colEndTime="EndDateTime"
        colSubject="For" colChair="Chair">
    javascript:sessionScope.CompactJson2=="true"}
    ]]>
       




    Many thanks in advance for your help and time.

     

    Best Regards

    Cyrus

    • re “Postgres” database

      By Martin Donnelly 1 decade ago

      Is your  “Postgres” database an RDBMS db or an NSF - just to clarify?

      Since you are looking at the teamroom example, have you looked at the JSON data returned to browser by the ? Ultimately you need to emulate this data structure - see example at end of page.

      If you have Firebug installed you can see that the last request issued on the team room calendar page is an ajax request like this:

      http://server/db.nsf/calendar.xsp/inoteslegacyjson?startKey=20101128T000000,00Z&untilKey=20101226T000000,00Z

      If you expand the response you will see a stream of data In the JSON column, which is used to populate the calendar.

      The generates this JSON based on the params provided in the page, e.g. name of calendar view, columns required etc..

              viewName="calendarOutline" var="entry" contentType="text/plain"
              colCalendarDate="CalDateTime" colEntryIcon="Icon"
            colStartTime="StartDateTime" colEndTime="EndDateTime"
            colSubject="For" colChair="Chair">

      If you look at the implementation of calendarJsonLegacyService (DominoCalendarJsonLegacyService.java) you will see how it does this.  And you will see that it is just an implementation of a REST service - and that you can provide your own REST services.  Typically people point the calendarJsonLegacyService at their Domino calendar view. If the data is somewhere else, you could write a service to extract it and return the JSON as shown below.

      JSON :

      {
          "@timestamp":"20110127T191400",
          "@toplevelentries":"2",
          "viewentry":
          [
            {
                "@unid":"A180742A15AB07D0802577FC00512D0F",
                "@noteid":"91E",
                "@position":"1",
                "@read":"true",
                "@siblings":"2",
                "entrydata":
                [
                  {
                      "@columnnumber":"0",
                      "@name":"$134",
                      "datetime":
                      {
                          "0":"20101202T140000"
                      }
                  },
                  {
                      "@columnnumber":"1",
                      "@name":"$149",
                      "number":
                      {
                          "0":158
                      }
                  },
                  {
                      "@columnnumber":"2",
                      "@name":"$144",
                      "datetime":
                      {
                          "0":"20101202T140000"
                      }
                  },
                  {
                      "@columnnumber":"3",
                      "@name":"$146",
                      "datetime":
                      {
                          "0":"20101202T150000"
                      }
                  },
                  {
                      "@columnnumber":"4",
                      "@name":"$147",
                      "text":
                      {
                          "0":"Meeting: OGS Demo (14:00)"
                      }
                  },
                  {
                      "@columnnumber":"5",
                      "@name":"$153",
                      "text":
                      {
                          "0":"Martin Donnelly"
                      }
                  }
                ]
            },
            {
                "@unid":"DD9D70D359CF7008802577FC003F8799",
                "@noteid":"91A",
                "@position":"2",
                "@read":"true",
                "@siblings":"2",
                "entrydata":
                [
                  {
                      "@columnnumber":"0",
                      "@name":"$134",
                      "datetime":
                      {
                          "0":"20101203T140000"
                      }
                  },
                  {
                      "@columnnumber":"1",
                      "@name":"$149",
                      "number":
                      {
                          "0":158
                      }
                  },
                  {
                      "@columnnumber":"2",
                      "@name":"$144",
                      "datetime":
                      {
                          "0":"20101203T140000"
                      }
                  },
                  {
                      "@columnnumber":"3",
                      "@name":"$146",
                      "datetime":
                      {
                          "0":"20101203T150000"
                      }
                  },
                  {
                      "@columnnumber":"4",
                      "@name":"$147",
                      "text":
                      {
                          "0":"Meeting: OGS Demo (14:00)"
                      }
                  },
                  {
                      "@columnnumber":"5",
                      "@name":"$153",
                      "text":
                      {
                          "0":"Martin Donnelly"
                      }
                  }
                ]
            }
          ]
      }