Embedding/using OpenRPT

Developers
Israel
2007-09-07
2013-04-26
  • Israel
    Israel
    2007-09-07

    I apologize if this is a stupid question, but I can't seem to find any documentation on the subject. According to the OpenRPT homepage, OpenRPTis embedable, but all the documentation I can find just refers to the standalone. How would I go about embedding it in my Qt 4 application? What I am envisioning is an interface (which I could write) where the user pushes a button and gets a list of available reports. They select the one they want, enter the parameters they want from a list of available parameters and hit print, whereupon OpenRPT takes care of the rest. Is there any documentation I can read that will help me with this process?

    In a related question, for this to work, the reports would need to be stored in the database, which OpenRPT is capable of. But whenever I try to save to my database, I get an error indicating that the table(s) it is looking for don't exist. Where can I find what tables/columns it needs to store the data? Thanks!

    Israel Brewster

     
    • Chris Ryan
      Chris Ryan
      2007-09-07

      There is no written documentation as you are thinking. The RPTrender application whoever is an example, as well as a usable tool, that demonstrates how to use the renderer. The renderer it self if a library. By including the appropriate openreports.h file and linking against the librenderer library you can instantiate the various objects to render reports. Take a look at the source in openrpt/OpenRPT/renderapp.

      For the table there is a tool in CVS openrpt/OpenRPT/bldtbls that can be built and used to create the table. This tool will handle PostgreSQL and MySQL databases. However if plain sql is your thing this is the table creation statement for PostgreSQL:

      CREATE TABLE report (
          report_id SERIAL PRIMARY KEY,
          report_name text,
          report_sys boolean,
          report_source text,
          report_descrip text,
          report_grade integer NOT NULL,
          report_loaddate timestamp
      );

      If you have specific question or problems after looking at the renderapp source please let us know and we will try to answer your questions.

       
    • Israel
      Israel
      2007-09-11

      Thanks for the info. I was able to get the SQL table set up and functioning properly. The renderapp source is of little help, as there is so much stuff in there dealing with the actual interface, and how the data is retrieved from the user that I have found trying to pull out the parts relevant to the actual report generation and printing to be a very difficult task. I'll keep looking, however.

      Looking at the openreports.txt file, it would appear that the basic procedure is to include the openreports.h file and link against the renderer library, instantiate an orReport object using the name of the report stored in the database and a list of parameters, and then call the print function on the orReport object. Is this correct? If so, that does leave me with a couple of questions. First, what sort of contents does the QStringList parameter list need? I looked at the renderapp source, but while I THINK I found the section that deals with this, there were so many levels of variables and function calls that I couldn't make heads or tales out of what the final result would be. Secondly, how does it know what database connection to use- does it just assume the default connection? That would actually work for me, but it seems that it would be important to know.

      In an related question, when I tried the above to see if i could make it work without any parameters, upon linking I got a whole slew of undefined symbol errors, apparently from the renderer library. The output is shown below. What am I missing here? Thanks again for the help.
      Undefined Symbols:
      ParameterList::append(Parameter const&)
      Parameter::Parameter(QString const&, QVariant const&)
      Parameter::Parameter(Parameter const&)
      XSqlQuery::exec()
      XSqlQuery::first()
      XSqlQuery::prepare(char const*)
      XSqlQuery::bindValue(char const*, QVariant const&)
      XSqlQuery::XSqlQuery(QSqlDatabase)
      XSqlQuery::~XSqlQuery()
      XSqlQuery::value(char const*) const
      QUUDecode(QString const&, QString*, int*)
      Q3GListIterator::Q3GListIterator(Q3GList const&)
      Q3GListIterator::~Q3GListIterator()
      Q3GListIterator::operator++()
      Q3PtrCollection::newItem(void*)
      Q3GList::compareItems(void*, void*)
      Q3GList::read(QDataStream&, void*&)
      Q3GList::clear()
      Q3GList::locate(unsigned int)
      Q3GList::~Q3GList()
      Q3GList::~Q3GList()
      Q3GList::~Q3GList()
      XSqlQuery::getFieldTotal(QString&)
      XSqlQuery::trackFieldTotal(QString&)
      XSqlQuery::XSqlQuery(QString const&, QSqlDatabase)
      Q3GList::write(QDataStream&, void*) const
      XSqlQuery::value(int) const
      typeinfo for Q3PtrCollection
      Q3GList::append(void*)
      Q3GList::Q3GList()
      Q3GList::takeAt(unsigned int)
      ParameterList::value(QString const&, bool*) const
      ParameterList::value(int, bool*) const
      ParameterList::append(char const*, QVariant const&)
      ParameterList::append(char const*, int)
      ParameterList::name(int) const
      /Users/israel/Desktop/AssetTracker/librenderer.a(openreports_wrapper.o) reference to undefined ParameterList::append(Parameter const&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(openreports_wrapper.o) reference to undefined Parameter::Parameter(QString const&, QVariant const&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(openreports_wrapper.o) reference to undefined Parameter::Parameter(Parameter const&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(openreports_wrapper.o) reference to undefined XSqlQuery::exec()
      /Users/israel/Desktop/AssetTracker/librenderer.a(openreports_wrapper.o) reference to undefined XSqlQuery::first()
      /Users/israel/Desktop/AssetTracker/librenderer.a(openreports_wrapper.o) reference to undefined XSqlQuery::prepare(char const*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(openreports_wrapper.o) reference to undefined XSqlQuery::bindValue(char const*, QVariant const&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(openreports_wrapper.o) reference to undefined XSqlQuery::XSqlQuery(QSqlDatabase)
      /Users/israel/Desktop/AssetTracker/librenderer.a(openreports_wrapper.o) reference to undefined XSqlQuery::~XSqlQuery()
      /Users/israel/Desktop/AssetTracker/librenderer.a(openreports_wrapper.o) reference to undefined XSqlQuery::value(char const*) const
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined QUUDecode(QString const&, QString*, int*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined Q3GListIterator::Q3GListIterator(Q3GList const&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined Q3GListIterator::~Q3GListIterator()
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined Q3GListIterator::operator++()
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined Q3PtrCollection::newItem(void*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined Q3GList::compareItems(void*, void*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined Q3GList::read(QDataStream&, void*&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined Q3GList::clear()
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined Q3GList::locate(unsigned int)
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined Q3GList::~Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined Q3GList::~Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined Q3GList::~Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined Parameter::Parameter(Parameter const&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined XSqlQuery::getFieldTotal(QString&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined XSqlQuery::trackFieldTotal(QString&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined XSqlQuery::first()
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined XSqlQuery::XSqlQuery(QString const&, QSqlDatabase)
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined XSqlQuery::~XSqlQuery()
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined Q3GList::write(QDataStream&, void*) const
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined XSqlQuery::value(int) const
      /Users/israel/Desktop/AssetTracker/librenderer.a(orprerender.o) reference to undefined typeinfo for Q3PtrCollection
      /Users/israel/Desktop/AssetTracker/librenderer.a(parsexmlutils.o) reference to undefined Q3PtrCollection::newItem(void*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(parsexmlutils.o) reference to undefined Q3GList::compareItems(void*, void*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(parsexmlutils.o) reference to undefined Q3GList::read(QDataStream&, void*&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(parsexmlutils.o) reference to undefined Q3GList::clear()
      /Users/israel/Desktop/AssetTracker/librenderer.a(parsexmlutils.o) reference to undefined Q3GList::append(void*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(parsexmlutils.o) reference to undefined Q3GList::Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(parsexmlutils.o) reference to undefined Q3GList::~Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(parsexmlutils.o) reference to undefined Q3GList::~Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(parsexmlutils.o) reference to undefined Q3GList::~Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(parsexmlutils.o) reference to undefined Q3GList::write(QDataStream&, void*) const
      /Users/israel/Desktop/AssetTracker/librenderer.a(parsexmlutils.o) reference to undefined typeinfo for Q3PtrCollection
      /Users/israel/Desktop/AssetTracker/librenderer.a(querysource.o) reference to undefined Q3PtrCollection::newItem(void*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(querysource.o) reference to undefined Q3GList::compareItems(void*, void*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(querysource.o) reference to undefined Q3GList::read(QDataStream&, void*&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(querysource.o) reference to undefined Q3GList::clear()
      /Users/israel/Desktop/AssetTracker/librenderer.a(querysource.o) reference to undefined Q3GList::append(void*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(querysource.o) reference to undefined Q3GList::locate(unsigned int)
      /Users/israel/Desktop/AssetTracker/librenderer.a(querysource.o) reference to undefined Q3GList::takeAt(unsigned int)
      /Users/israel/Desktop/AssetTracker/librenderer.a(querysource.o) reference to undefined Q3GList::Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(querysource.o) reference to undefined Q3GList::~Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(querysource.o) reference to undefined Q3GList::~Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(querysource.o) reference to undefined Q3GList::~Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(querysource.o) reference to undefined Q3GList::write(QDataStream&, void*) const
      /Users/israel/Desktop/AssetTracker/librenderer.a(querysource.o) reference to undefined typeinfo for Q3PtrCollection
      /Users/israel/Desktop/AssetTracker/librenderer.a(moc_querysource.o) reference to undefined Q3PtrCollection::newItem(void*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(moc_querysource.o) reference to undefined Q3GList::compareItems(void*, void*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(moc_querysource.o) reference to undefined Q3GList::read(QDataStream&, void*&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(moc_querysource.o) reference to undefined Q3GList::clear()
      /Users/israel/Desktop/AssetTracker/librenderer.a(moc_querysource.o) reference to undefined Q3GList::~Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(moc_querysource.o) reference to undefined Q3GList::~Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(moc_querysource.o) reference to undefined Q3GList::write(QDataStream&, void*) const
      /Users/israel/Desktop/AssetTracker/librenderer.a(moc_querysource.o) reference to undefined typeinfo for Q3PtrCollection
      /Users/israel/Desktop/AssetTracker/librenderer.a(graph.o) reference to undefined Q3PtrCollection::newItem(void*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(graph.o) reference to undefined Q3GList::compareItems(void*, void*)
      /Users/israel/Desktop/AssetTracker/librenderer.a(graph.o) reference to undefined Q3GList::read(QDataStream&, void*&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(graph.o) reference to undefined Q3GList::clear()
      /Users/israel/Desktop/AssetTracker/librenderer.a(graph.o) reference to undefined Q3GList::locate(unsigned int)
      /Users/israel/Desktop/AssetTracker/librenderer.a(graph.o) reference to undefined Q3GList::~Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(graph.o) reference to undefined Q3GList::~Q3GList()
      /Users/israel/Desktop/AssetTracker/librenderer.a(graph.o) reference to undefined Q3GList::write(QDataStream&, void*) const
      /Users/israel/Desktop/AssetTracker/librenderer.a(graph.o) reference to undefined typeinfo for Q3PtrCollection
      /Users/israel/Desktop/AssetTracker/librenderer.a(orutils.o) reference to undefined XSqlQuery::XSqlQuery(QString const&, QSqlDatabase)
      /Users/israel/Desktop/AssetTracker/librenderer.a(orutils.o) reference to undefined ParameterList::value(QString const&, bool*) const
      /Users/israel/Desktop/AssetTracker/librenderer.a(orutils.o) reference to undefined ParameterList::value(int, bool*) const
      /Users/israel/Desktop/AssetTracker/librenderer.a(metasql.o) reference to undefined ParameterList::append(char const*, QVariant const&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(metasql.o) reference to undefined ParameterList::append(char const*, int)
      /Users/israel/Desktop/AssetTracker/librenderer.a(metasql.o) reference to undefined Parameter::Parameter(Parameter const&)
      /Users/israel/Desktop/AssetTracker/librenderer.a(metasql.o) reference to undefined XSqlQuery::exec()
      /Users/israel/Desktop/AssetTracker/librenderer.a(metasql.o) reference to undefined XSqlQuery::XSqlQuery(QSqlDatabase)
      /Users/israel/Desktop/AssetTracker/librenderer.a(metasql.o) reference to undefined XSqlQuery::~XSqlQuery()
      /Users/israel/Desktop/AssetTracker/librenderer.a(metasql.o) reference to undefined ParameterList::name(int) const
      /Users/israel/Desktop/AssetTracker/librenderer.a(metasql.o) reference to undefined ParameterList::value(QString const&, bool*) const
      /Users/israel/Desktop/AssetTracker/librenderer.a(metasql.o) reference to undefined ParameterList::value(int, bool*) const
      collect2: ld returned 1 exit status

       
    • Chris Ryan
      Chris Ryan
      2007-09-11

      The way you put it is probably about the simplest way to do it. The document you are reding is really old and out-dated. The orReport class is the old renderer and depending on your options it will compile, by default as a wrapper object around the new paradigm, which is a more extensible implementation, but we will focus on the simpler stuff first.

      The differences in your overview that I would add to, and should fix all the linking problems you encountered is adding the openrpt/common directory to the include path and linking against the common library in the openrpt/lib directory.

      As for the QStringList this the original method of passing parameters and is ordinal based. The code still supports this but from the renderer but the MetaSQL functionality doesn't use the ordinal based system. The new method uses the ParameterList class, in openrpt/common/parameter.h, which is an overloaded QList<Parameter>. Parameter is a key/value pair. ParameterList has a function called append with a name  and value (QVariant) arguments. The following is an example that covers 99% of all code I have ever written using ParameterList:

      ParameterList params;
      params.append("somevalue", 3);
      params.append("another", "value");
      params.append("more", somevariable);

      For the database the class will use the default if you do not pass an alternate as an argument to the constructor. The constructor actually has several overloaded methods which you can review. However most of the time you will use the form that specifies reportname, paramaterlist, database. You can leave the database off and you can even leave the parameter list off if you don't have any parameters.

      The following is an example:

      orReport report("reportnameindatabase", params, qdbvar);
      if(report.isValid()) report.print(qprintervar);
      else report.reportError(this);

      I hope this has helped. If you have any more questions or if something I had said is confusing please let me know.

       
    • Israel
      Israel
      2007-09-12

      Thanks, I have it working now, after adding the Qt3 support framework to my project in addition to the libraries. Is there a way to pull a list of parameters from the loaded report? I notice that there is a doParamsSatisfy() function, which I would assume would check to see if it has a good list, but that just returns a boolean, not a list of what remains to be satisfied. I need some way to present the user with a list of parameters based on the report selected, if possible. Thanks again, you have been most helpfull!

      Israel Brewster

       
    • Chris Ryan
      Chris Ryan
      2007-09-12

      This functionality was never really completed; partially because we changed from the ordinal paramsters to the MetaSQL named paramters. The alternative approach which was started was the Defined Parameters within the report definition. This was a means to allow report designers to define the parameters that a report would require or could take optionally. If you loaded a report definition and used these you could check the paramterlist to make sure all the required fields were present. However there is no infrastructure at this time to do so programatically.