From: Dirk H Bartley Date: Sat, 19 May 2007 12:50:14 +0000 (+0000) Subject: Add Fileset column. This is the commit that adds "LEFT OUTER JOIN" sql syntax. X-Git-Tag: Release-7.0.0~6307 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3431f6aeb6ca059d99b08ebc4fb8fd1caaa90448;p=bacula%2Fbacula Add Fileset column. This is the commit that adds "LEFT OUTER JOIN" sql syntax. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4838 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index 13d4b55c6f..ec02dfdf0c 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -111,6 +111,8 @@ void JobList::populateTable() purgedComboBox->addItem("Any"); purgedComboBox->addItems( QStringList() << "0" << "1"); statusComboBox->addItem("Any"); + fileSetComboBox->addItem("Any"); + fileSetComboBox->addItems(m_console->fileset_list); QString statusQuery("SELECT JobStatusLong FROM Status"); QStringList statusResults, statusLongList; if (m_console->sql_cmd(statusQuery, statusResults)) { @@ -135,43 +137,57 @@ void JobList::populateTable() " Job.Level AS BackupLevel, Job.Jobfiles AS FileCount," " Job.JobBytes AS Bytes," " Job.JobStatus AS Status, Status.JobStatusLong AS StatusLong," - " Job.PurgedFiles AS Purged" - " FROM Job,Client,Status"; + " Job.PurgedFiles AS Purged, FileSet.FileSet" + " FROM Job" + " LEFT OUTER JOIN Client ON (Client.ClientId=Job.ClientId)" + " LEFT OUTER JOIN FileSet ON (FileSet.FileSetId=Job.FileSetId)" + " LEFT OUTER JOIN Status ON (Job.JobStatus=Status.JobStatus)" + " LEFT OUTER JOIN JobMedia ON (JobMedia.JobId=Job.JobId)" + " LEFT OUTER JOIN Media ON (JobMedia.MediaId=Media.MediaId)"; + QStringList conditions; if (m_mediaName != "Any") { - query += ",JobMedia,Media"; - } - query += " WHERE Client.ClientId=Job.ClientId AND Job.JobStatus=Status.JobStatus"; - if (m_mediaName != "Any") { - query += " AND JobMedia.JobId=Job.JobId AND JobMedia.MediaId=Media.MediaId" - " AND Media.VolumeName='" + m_mediaName + "'"; + conditions.append("Media.VolumeName='" + m_mediaName + "'"); } int clientIndex = clientsComboBox->currentIndex(); if (clientIndex != -1) m_clientName = clientsComboBox->itemText(clientIndex); if (m_clientName != "Any") { - query += " AND Client.Name='" + m_clientName + "'"; + conditions.append("Client.Name='" + m_clientName + "'"); } int jobIndex = jobComboBox->currentIndex(); if ((jobIndex != -1) && (jobComboBox->itemText(jobIndex) != "Any")) { - query += " AND Job.Name='" + jobComboBox->itemText(jobIndex) + "'"; + conditions.append("Job.Name='" + jobComboBox->itemText(jobIndex) + "'"); } int levelIndex = levelComboBox->currentIndex(); if ((levelIndex != -1) && (levelComboBox->itemText(levelIndex) != "Any")) { - query += " AND Job.Level='" + levelComboBox->itemText(levelIndex) + "'"; + conditions.append("Job.Level='" + levelComboBox->itemText(levelIndex) + "'"); } int statusIndex = statusComboBox->currentIndex(); if ((statusIndex != -1) && (statusComboBox->itemText(statusIndex) != "Any")) { - query += " AND Status.JobStatusLong='" + statusComboBox->itemText(statusIndex) + "'"; + conditions.append("Status.JobStatusLong='" + statusComboBox->itemText(statusIndex) + "'"); } int purgedIndex = purgedComboBox->currentIndex(); if ((purgedIndex != -1) && (purgedComboBox->itemText(purgedIndex) != "Any")) { - query += " AND Job.PurgedFiles='" + purgedComboBox->itemText(purgedIndex) + "'"; + conditions.append("Job.PurgedFiles='" + purgedComboBox->itemText(purgedIndex) + "'"); + } + int fileSetIndex = fileSetComboBox->currentIndex(); + if ((fileSetIndex != -1) && (fileSetComboBox->itemText(fileSetIndex) != "Any")) { + conditions.append("FileSet.FileSet='" + fileSetComboBox->itemText(fileSetIndex) + "'"); } /* If Limit check box For limit by days is checked */ if (daysCheckBox->checkState() == Qt::Checked) { QDateTime stamp = QDateTime::currentDateTime().addDays(-daysSpinBox->value()); QString since = stamp.toString(Qt::ISODate); - query += " AND Job.Starttime>'" + since + "'"; + conditions.append("Job.Starttime>'" + since + "'"); + } + bool first = true; + foreach (QString condition, conditions) { + if (first) { + query += " WHERE " + condition; + first = false; + } else { + query += " AND " + condition; + } } /* Descending */ query += " ORDER BY Job.Starttime DESC, Job.JobId DESC"; @@ -185,7 +201,7 @@ void JobList::populateTable() /* Set up the Header for the table */ QStringList headerlist = (QStringList() << "Job Id" << "Job Name" << "Client" << "Job Starttime" << "Job Type" - << "Job Level" << "Job Files" << "Job Bytes" << "Job Status" << "Purged" ); + << "Job Level" << "Job Files" << "Job Bytes" << "Job Status" << "Purged" << "File Set" ); m_purgedIndex = headerlist.indexOf("Purged"); m_typeIndex = headerlist.indexOf("Job Type"); statusIndex = headerlist.indexOf("Job Status"); @@ -198,7 +214,7 @@ void JobList::populateTable() mp_tableWidget->setHorizontalHeaderLabels(headerlist); /* This could be a user preference debug message?? */ - //printf("Query cmd : %s\n",query.toUtf8().data()); + printf("Query cmd : %s\n",query.toUtf8().data()); if (m_console->sql_cmd(query, results)) { m_resultCount = results.count(); @@ -266,8 +282,8 @@ void JobList::setStatusColor(QTableWidgetItem *item, QString &field) */ void JobList::PgSeltreeWidgetClicked() { - populateTable(); if (!m_populated) { + populateTable(); m_populated=true; } } @@ -278,8 +294,8 @@ void JobList::PgSeltreeWidgetClicked() */ void JobList::currentStackItem() { + populateTable(); if (!m_populated) { - populateTable(); m_contextActions.append(actionRefreshJobList); m_populated=true; } diff --git a/bacula/src/qt-console/joblist/joblist.ui b/bacula/src/qt-console/joblist/joblist.ui index 25a1124ab8..95abf3e00f 100644 --- a/bacula/src/qt-console/joblist/joblist.ui +++ b/bacula/src/qt-console/joblist/joblist.ui @@ -5,8 +5,8 @@ 0 0 - 547 - 361 + 607 + 390 @@ -19,18 +19,15 @@ 6 - - - - + 0 - 0 + 6 - + 0 @@ -47,24 +44,14 @@ 6 - + - Record Limit + Clients - - - 10000 - - - 1 - - - 25 - - + @@ -77,24 +64,20 @@ 6 - + - Days Limit + Volume - - - 10 - - + - + 0 @@ -111,14 +94,24 @@ 6 - + - Clients + Record Limit - + + + 10000 + + + 1 + + + 25 + + @@ -131,20 +124,44 @@ 6 - + - Volume + Days Limit - + + + 10 + + - + + + + 0 + + + 6 + + + + + FileSet + + + + + + + + + 0 @@ -161,14 +178,14 @@ 6 - + - Job + Status - + @@ -181,20 +198,20 @@ 6 - + - Level + Purged - + - + 0 @@ -211,14 +228,14 @@ 6 - + - Status + Job - + @@ -231,38 +248,83 @@ 6 - + - Purged + Level - + - - - - - 65 - 16777215 - + + + + 0 - - Refresh + + 6 - + + + + + 65 + 16777215 + + + + Refresh + + + + + + + Qt::Horizontal + + + QSizePolicy::Ignored + + + + 16 + 20 + + + + + + + + Qt::Vertical + + + QSizePolicy::Ignored + + + + 20 + 16 + + + + + + + + - ../images/run.png + :images/run.png Refresh Job List @@ -273,7 +335,7 @@ - ../images/unmark.png + :images/unmark.png ListJobid @@ -281,7 +343,7 @@ - ../images/unmark.png + :images/unmark.png List Files On Job @@ -289,7 +351,7 @@ - ../images/unmark.png + :images/unmark.png ListJobMedia @@ -297,7 +359,7 @@ - ../images/unmark.png + :images/unmark.png ListVolumes @@ -305,7 +367,7 @@ - ../images/unmark.png + :images/unmark.png LongListJob @@ -313,7 +375,7 @@ - ../images/unmark.png + :images/unmark.png DeleteJob @@ -321,7 +383,7 @@ - ../images/unmark.png + :images/unmark.png PurgeFiles @@ -329,7 +391,7 @@ - ../images/unmark.png + :images/unmark.png Restore From Job @@ -337,7 +399,7 @@ - ../images/unmark.png + :images/unmark.png Restore From Time @@ -345,7 +407,7 @@ - ../images/unmark.png + :images/unmark.png Show Log for Job