Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78047 - sandbox/icl/libs/xplore/br1/sqlbrowser
From: afojgo_at_[hidden]
Date: 2012-04-17 12:57:45


Author: jofaber
Date: 2012-04-17 12:57:44 EDT (Tue, 17 Apr 2012)
New Revision: 78047
URL: http://svn.boost.org/trac/boost/changeset/78047

Log:
Type extensible Dag model. Building example Dag.
Binary files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/objects1.db
Text files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql | 48 +++++++++++--
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp | 31 ++++++--
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h | 11 ++
   sandbox/icl/libs/xplore/br1/sqlbrowser/browserwidget.ui | 137 +++++++++++++++++++++------------------
   4 files changed, 142 insertions(+), 85 deletions(-)

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/TypeExtensibleDag.sql 2012-04-17 12:57:44 EDT (Tue, 17 Apr 2012)
@@ -10,16 +10,14 @@
 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 EdgeType (id integer primary key, refSourceObjectType integer, refRelationType integer, refTargetObjectType 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 Edge (id integer primary key, refSourceVertex integer, refEdgeType 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');
@@ -38,20 +36,20 @@
 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 (1, 1, 1, 2, 'artist composed title' );
+insert into EdgeType values (2, 1, 2, 3, '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 (1, 1);
 insert into Vertex values (2, 1);
 insert into Vertex values (3, 1);
-insert into Vertex values (4, 2); -- titles
+insert into Vertex values (4, 2);
 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 Edge values (1, 1, 1, 4);
 
 insert into Object values (0, 0);
 insert into Object values (1, 1);
@@ -62,3 +60,35 @@
 
 insert into Relation values (0, 0);
 insert into Relation values (1, 1);
+
+-- -------------------------------------
+-- Dag Related Architecture Linking All
+-- D R A C U L A
+
+create view EdgeSignature as
+select
+ (select StructType.Name from ObjectType as ObjT2
+ inner join ObjectType on ObjT2.id = EdgeType.refSourceObjectType
+ inner join StructType on StructType.id = ObjT2.refStructType) as SrcS,
+ (select ObjectType.Name from ObjectType where ObjectType.id = EdgeType.refSourceObjectType) as SrcT,
+ RelationType.Name as RelT,
+ StructType.Name as TrgS,
+ ObjectType.Name as TrgT,
+ EdgeType.Name
+from EdgeType
+ inner join ObjectType on EdgeType.refTargetObjectType = ObjectType.id
+ inner join RelationType on EdgeType.refRelationType = RelationType.id
+ inner join StructType on ObjectType.refStructType = StructType.id
+
+
+insert into Vertex values (0, 0);
+insert into Vertex values (1, 1);
+insert into Vertex values (2, 1);
+insert into Vertex values (3, 1);
+insert into Vertex values (4, 2);
+insert into Vertex values (5, 2);
+
+-- ------------------------------
+1(artist) 1(Name) 1(Text)
+1(artist) 2(Birth) 7(Date)
+

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-17 12:57:44 EDT (Tue, 17 Apr 2012)
@@ -126,7 +126,7 @@
 
 void Browser::exec()
 {
- /*REV
+ /*JODO REV
     if(sqlEdit->toPlainText().isEmpty())
     {
         rexec();
@@ -134,13 +134,6 @@
     }
     */
 
- QString curSql = sqlEdit->toPlainText();
- QSqlQuery curQuery = QSqlQuery(connectionWidget->currentDatabase());
-
- execMulti(curQuery, curSql);
-
-
- /*
     QSqlQueryModel *model = new QSqlQueryModel(ext_table);
 
     model->setQuery(QSqlQuery(sqlEdit->toPlainText(), connectionWidget->currentDatabase()));
@@ -162,12 +155,28 @@
     else
         emit statusMessage(tr("Query OK, number of affected rows: %1").arg(
                            model->query().numRowsAffected()));
- */
+
     updateActions();
 }
 
-void Browser::execMulti(QSqlQuery& query, const QString& script)
+bool Browser::runScript()
+{
+ QString curSql = sqlEdit->toPlainText();
+ QSqlQuery curQuery = QSqlQuery(connectionWidget->currentDatabase());
+
+ bool success = execMulti(curQuery, curSql);
+
+ if(success)
+ emit statusMessage(tr("Script executed successfully."));
+ else
+ emit statusMessage(tr("Error(s), Script aborted."));
+
+ return success;
+}
+
+bool Browser::execMulti(QSqlQuery& query, const QString& script)
 {
+ bool success = true;
     QStringList scriptQueries = script.split('\n');
 
     foreach(QString queryTxt, scriptQueries)
@@ -180,9 +189,11 @@
             qFatal(QString("One of the query failed to execute."
                            " Error detail: " + query.lastError().text() + "\n" +
                            " Q:'" + queryTxt + "'").toLocal8Bit());
+ success = false;
         }
         query.finish();
     }
+ return success;
 }
 
 void Browser::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-17 12:57:44 EDT (Tue, 17 Apr 2012)
@@ -74,7 +74,8 @@
 public slots:
     void exec();
     void rexec();
- void execMulti(QSqlQuery& query, const QString& script);
+ bool runScript();
+ bool execMulti(QSqlQuery& query, const QString& script);
     QSqlTableModel* showTable(const QString &table);
     void showTree(QSqlTableModel *model);
     void showMetaData(const QString &table);
@@ -96,17 +97,25 @@
 
     void on_connectionWidget_metaDataRequested(const QString &table)
     { showMetaData(table); }
+
     void on_submitButton_clicked()
     {
         exec();
         sqlEdit->setFocus();
     }
+
     void on_clearButton_clicked()
     {
         sqlEdit->clear();
         sqlEdit->setFocus();
     }
 
+ void on_scriptButton_clicked()
+ {
+ runScript();
+ sqlEdit->setFocus();
+ }
+
     //JOFA TMP some checks
     void on_cellClicked(int row, int col);
     void on_rowSelectChanged();

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-17 12:57:44 EDT (Tue, 17 Apr 2012)
@@ -616,73 +616,80 @@
      <property name="title">
       <string>SQL Query</string>
      </property>
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
+ <widget class="QTextEdit" name="sqlEdit">
+ <property name="geometry">
+ <rect>
+ <x>9</x>
+ <y>9</y>
+ <width>816</width>
+ <height>127</height>
+ </rect>
       </property>
- <property name="margin">
- <number>9</number>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
       </property>
- <item>
- <widget class="QTextEdit" name="sqlEdit">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>18</height>
- </size>
- </property>
- <property name="baseSize">
- <size>
- <width>0</width>
- <height>120</height>
- </size>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>1</number>
- </property>
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="submitButton">
- <property name="text">
- <string>&amp;Submit</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="clearButton">
- <property name="text">
- <string>&amp;Clear</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>18</height>
+ </size>
+ </property>
+ <property name="baseSize">
+ <size>
+ <width>0</width>
+ <height>120</height>
+ </size>
+ </property>
+ </widget>
+ <widget class="QWidget" name="">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>140</y>
+ <width>811</width>
+ <height>29</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="submitButton">
+ <property name="text">
+ <string>&amp;Submit</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="clearButton">
+ <property name="text">
+ <string>&amp;Clear</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="scriptButton">
+ <property name="text">
+ <string>&amp;Run Script</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
     </widget>
    </item>
   </layout>

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/objects1.db
==============================================================================
Binary files. 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