Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78013 - sandbox/icl/libs/xplore/br1/sqlbrowser
From: afojgo_at_[hidden]
Date: 2012-04-16 12:07:15


Author: jofaber
Date: 2012-04-16 12:07:14 EDT (Mon, 16 Apr 2012)
New Revision: 78013
URL: http://svn.boost.org/trac/boost/changeset/78013

Log:
Started a type extensible Dag model.
Added:
   sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql (contents, props changed)
   sandbox/icl/libs/xplore/br1/sqlbrowser/objects1_dag1.db (contents, props changed)
Binary files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/objects1.db
Text files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/ExtensibleObjectModel.sql | 7 +++-
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp | 52 +++++++++++++++++++++++----------------
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h | 1
   sandbox/icl/libs/xplore/br1/sqlbrowser/browserwidget.ui | 9 +++---
   4 files changed, 40 insertions(+), 29 deletions(-)

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/ExtensibleObjectModel.sql
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/ExtensibleObjectModel.sql (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/ExtensibleObjectModel.sql 2012-04-16 12:07:14 EDT (Mon, 16 Apr 2012)
@@ -1,6 +1,7 @@
-drop table Types;
+drop view Collections;
+drop table Dag;
 drop table Objects;
-drop table Groups;
+drop table Types;
 
 -- -----------------------------------------------------------------------------
 create table Types (id integer primary key, Name varchar);
@@ -63,3 +64,5 @@
   inner join Objects on Dag.Child = Objects.id
   inner join Types on Objects.TypeOf = Types.id
 
+-- ----------------------------------------------------------------------------
+-- ----------------------------------------------------------------------------

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql 2012-04-16 12:07:14 EDT (Mon, 16 Apr 2012)
@@ -0,0 +1,64 @@
+drop table StructType;
+drop table ObjectType;
+drop table RelationType;
+drop table EdgeType;
+drop table Vertex;
+drop table Edge;
+drop table Object;
+drop table Relation;
+
+create table StructType (id integer primary key, Name varchar);
+create table ObjectType (id integer primary key, refStructType integer, Name varchar);
+create table RelationType (id integer primary key, Name varchar);
+create table EdgeType (id integer primary key, refSourceObjectType integer, refTargetObjectType integer, refRelationType integer, Name varchar);
+create table Vertex (id integer primary key, refObjectType integer);
+create table Edge (id integer primary key, refEdgeType integer, refSourceVertex integer, refTargetVertex integer);
+create table Object (id integer primary key, refVertex integer);
+create table Relation (id integer primary key, refEdge integer);
+
+
+
+-- Dag Related Architecture Linking All
+-- D R A C U L A
+-- -----------------------------------------------------------------------------
+insert into StructType values (0, 'Nil');
+insert into StructType values (1, 'atom');
+insert into StructType values (2, 'composite');
+
+insert into ObjectType values (0, 0, 'Nil');
+insert into ObjectType values (1, 1, 'artist');
+insert into ObjectType values (2, 1, 'title');
+insert into ObjectType values (3, 1, 'recording');
+insert into ObjectType values (4, 2, 'artists');
+insert into ObjectType values (5, 2, 'genre');
+
+insert into RelationType values (0, 'Nil');
+insert into RelationType values (1, 'composed');
+insert into RelationType values (2, 'performed');
+insert into RelationType values (3, 'recorded as');
+insert into RelationType values (4, 'located');
+
+insert into EdgeType values (1, 1, 2, 1, 'artist composed title' );
+insert into EdgeType values (2, 1, 3, 2, 'artist performed record' );
+insert into EdgeType values (3, 2, 3, 3, 'title recorded as record');
+insert into EdgeType values (4, 3, 4, 4, 'record located at url' );
+
+insert into Vertex values (0, 0);
+insert into Vertex values (1, 1); -- artists
+insert into Vertex values (2, 1);
+insert into Vertex values (3, 1);
+insert into Vertex values (4, 2); -- titles
+insert into Vertex values (5, 2);
+
+insert into Edge values (0, 0, 0, 0);
+insert into Edge values (1, 1, 1, 4); -- artist:1 composed(1) title:4
+
+insert into Object values (0, 0);
+insert into Object values (1, 1);
+insert into Object values (2, 2);
+insert into Object values (3, 3);
+insert into Object values (4, 4);
+insert into Object values (5, 5);
+
+insert into Relation values (0, 0);
+insert into Relation values (1, 1);

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp 2012-04-16 12:07:14 EDT (Mon, 16 Apr 2012)
@@ -126,36 +126,25 @@
 
 void Browser::exec()
 {
+ /*REV
     if(sqlEdit->toPlainText().isEmpty())
     {
         rexec();
         return;
     }
+ */
 
- QSqlQueryModel *model = new QSqlQueryModel(ext_table);
-
+ QString curSql = sqlEdit->toPlainText();
+ QSqlQuery curQuery = QSqlQuery(connectionWidget->currentDatabase());
 
- QSqlQuery curQuery = QSqlQuery(sqlEdit->toPlainText(), connectionWidget->currentDatabase());
+ execMulti(curQuery, curSql);
 
- QStringList headers; //JODO handle headers
- headers << tr("Title") << tr("Description");
- DagModel* dagmo = new DagModel(); // Dag-Model
-
- QSqlQuery xpQuery = QSqlQuery("", connectionWidget->currentDatabase());
- QString dbg_query = QString(sqlEdit->toPlainText());
- xpQuery.exec(sqlEdit->toPlainText());
-
- // Populate the Dag Model from an sql-Query
- dagmo->getEdges(xpQuery); //Read edges from database
- dagmo->makeDag(); //Make a boost::graph internally
-
- QString dagStr = dagmo->setupDag(); //Build a tree representation from the boost::dag
 
- model->setQuery(curQuery);
- //REV? model->setQuery(QSqlQuery(sqlEdit->toPlainText(), connectionWidget->currentDatabase()));
+ /*
+ QSqlQueryModel *model = new QSqlQueryModel(ext_table);
 
+ model->setQuery(QSqlQuery(sqlEdit->toPlainText(), connectionWidget->currentDatabase()));
     ext_table->setModel(model);
- ext_tree->setModel(dagmo);//JOFA
 
     //JOFA additions ----------------------------------------------------------
     ext_table->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
@@ -173,10 +162,29 @@
     else
         emit statusMessage(tr("Query OK, number of affected rows: %1").arg(
                            model->query().numRowsAffected()));
-
+ */
     updateActions();
 }
 
+void Browser::execMulti(QSqlQuery& query, const QString& script)
+{
+ QStringList scriptQueries = script.split('\n');
+
+ foreach(QString queryTxt, scriptQueries)
+ {
+ if (queryTxt.trimmed().isEmpty()) {
+ continue;
+ }
+ if (!query.exec(queryTxt))
+ {
+ qFatal(QString("One of the query failed to execute."
+ " Error detail: " + query.lastError().text() + "\n" +
+ " Q:'" + queryTxt + "'").toLocal8Bit());
+ }
+ query.finish();
+ }
+}
+
 void Browser::rexec()
 {
     QSqlQueryModel *model = new QSqlQueryModel(ext_table);
@@ -289,8 +297,8 @@
         if (err.type() != QSqlError::NoError)
             QMessageBox::warning(this, tr("Unable to open database"), tr("An error occurred while "
                                        "opening the connection: ") + err.text());
- else
- rexec();
+ else//Execute an initial setup of the Dag
+ ;//JODO REV rexec();
     }
 }
 

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h 2012-04-16 12:07:14 EDT (Mon, 16 Apr 2012)
@@ -74,6 +74,7 @@
 public slots:
     void exec();
     void rexec();
+ void execMulti(QSqlQuery& query, const QString& script);
     QSqlTableModel* showTable(const QString &table);
     void showTree(QSqlTableModel *model);
     void showMetaData(const QString &table);

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/browserwidget.ui
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/browserwidget.ui (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browserwidget.ui 2012-04-16 12:07:14 EDT (Mon, 16 Apr 2012)
@@ -667,16 +667,16 @@
          </spacer>
         </item>
         <item>
- <widget class="QPushButton" name="clearButton">
+ <widget class="QPushButton" name="submitButton">
           <property name="text">
- <string>&amp;Clear</string>
+ <string>&amp;Submit</string>
           </property>
          </widget>
         </item>
         <item>
- <widget class="QPushButton" name="submitButton">
+ <widget class="QPushButton" name="clearButton">
           <property name="text">
- <string>&amp;Submit</string>
+ <string>&amp;Clear</string>
           </property>
          </widget>
         </item>
@@ -735,7 +735,6 @@
  <tabstops>
   <tabstop>sqlEdit</tabstop>
   <tabstop>clearButton</tabstop>
- <tabstop>submitButton</tabstop>
   <tabstop>connectionWidget</tabstop>
   <tabstop>ext_table</tabstop>
  </tabstops>

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/objects1.db
==============================================================================
Binary files. No diff available.

Added: sandbox/icl/libs/xplore/br1/sqlbrowser/objects1_dag1.db
==============================================================================
Binary file. No diff available.


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk