mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-24 17:37:53 +02:00
2019-04-23 Fred Gleason <fredg@paravelsystems.com>
* Added a 'STACK_SCHED_CODES' table to the database. * Dropped the 'STACK_LINES.SCHED_CODES' field from the database. * Incremented the database version to 308. * Renamed the 'SchedCartList' class to 'RDSchedCartList' and refactored it to be idiomatic Qt. * Renamed the 'SchedRulesList' class to 'RDSchedRulesList'.
This commit is contained in:
parent
9f95fec5e1
commit
5589d3fc97
ChangeLog
docs/tables
lib
Makefile.amdbversion.hrdevent_line.cpprdevent_line.hrdschedcartlist.cpprdschedcartlist.hrdschedruleslist.cpprdschedruleslist.hrdsvc.cppschedcartlist.cppschedruleslist.h
rdlogmanager
edit_clock.cppedit_clock.hedit_schedcoderules.cppedit_schedcoderules.hedit_schedrules.cppedit_schedrules.h
utils
@ -18588,3 +18588,10 @@
|
||||
2019-04-22 Patrick Linstruth <patrick@deltecent.com>
|
||||
* Fixed a bug in rdlogmanager(1) that could corrupt the
|
||||
'CLOCK_LINES' table when renaming an event.
|
||||
2019-04-23 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added a 'STACK_SCHED_CODES' table to the database.
|
||||
* Dropped the 'STACK_LINES.SCHED_CODES' field from the database.
|
||||
* Incremented the database version to 308.
|
||||
* Renamed the 'SchedCartList' class to 'RDSchedCartList' and
|
||||
refactored it to be idiomatic Qt.
|
||||
* Renamed the 'SchedRulesList' class to 'RDSchedRulesList'.
|
||||
|
@ -97,6 +97,7 @@ EXTRA_DIST = audio_cards.txt\
|
||||
services.txt\
|
||||
sources.txt\
|
||||
stack_lines.txt\
|
||||
stack_sched_codes.txt\
|
||||
stations.txt\
|
||||
switcher_nodes.txt\
|
||||
system.txt\
|
||||
|
@ -9,5 +9,4 @@ SCHED_STACK_ID int(10) unsigned
|
||||
SERVICE_NAME varchar(10) From SERVICES.NAME
|
||||
CART int(10) unsigned From CART.NUMBER
|
||||
ARTIST varchar(191) From CART.ARTIST
|
||||
SCHED_CODES varchar(191)
|
||||
SCHEDULED_AT datetime
|
||||
|
11
docs/tables/stack_sched_codes.txt
Normal file
11
docs/tables/stack_sched_codes.txt
Normal file
@ -0,0 +1,11 @@
|
||||
STACK_SCHED_CODES Table Layout for Rivendell
|
||||
|
||||
The STACK_SCHED_CODES table holds the scheduler codes for rows in
|
||||
the 'STACK_LINES' table.
|
||||
|
||||
|
||||
FIELD NAME TYPE REMARKS
|
||||
------------------------------------------------------------------------
|
||||
ID int(10) unsigned Primary key, auto_increment
|
||||
STACK_LINES_ID int(10) unsigned From STACK_LINES.ID
|
||||
SCHED_CODE varchar(10)
|
@ -196,8 +196,10 @@ dist_librd_la_SOURCES = dbversion.h\
|
||||
rdreport.cpp rdreport.h\
|
||||
rdringbuffer.cpp rdringbuffer.h\
|
||||
rdripc.cpp rdripc.h\
|
||||
rdschedcartlist.cpp rdschedcartlist.h\
|
||||
rdschedcode.cpp rdschedcode.h\
|
||||
rdschedcodes_dialog.cpp rdschedcodes_dialog.h\
|
||||
rdschedruleslist.cpp rdschedruleslist.h\
|
||||
rdsegmeter.cpp rdsegmeter.h\
|
||||
rdsettings.cpp rdsettings.h\
|
||||
rdsimpleplayer.cpp rdsimpleplayer.h\
|
||||
@ -237,9 +239,7 @@ dist_librd_la_SOURCES = dbversion.h\
|
||||
rdwavepainter.cpp rdwavepainter.h\
|
||||
rdweb.cpp rdweb.h\
|
||||
rdwebresult.cpp rdwebresult.h\
|
||||
rdxport_interface.h\
|
||||
schedruleslist.cpp schedruleslist.h\
|
||||
schedcartlist.cpp schedcartlist.h
|
||||
rdxport_interface.h
|
||||
|
||||
|
||||
nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\
|
||||
@ -332,8 +332,7 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\
|
||||
moc_rdunixserver.cpp\
|
||||
moc_rdunixsocket.cpp\
|
||||
moc_rdupload.cpp\
|
||||
moc_rdwavedata_dialog.cpp\
|
||||
moc_schedcartlist.cpp
|
||||
moc_rdwavedata_dialog.cpp
|
||||
|
||||
librd_la_LDFLAGS = -release $(VERSION)
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
/*
|
||||
* Current Database Version
|
||||
*/
|
||||
#define RD_VERSION_DATABASE 307
|
||||
#define RD_VERSION_DATABASE 308
|
||||
|
||||
|
||||
#endif // DBVERSION_H
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "rdevent.h"
|
||||
#include "rdevent_line.h"
|
||||
#include "rdeventimportlist.h"
|
||||
#include "schedcartlist.h"
|
||||
#include "rdschedcartlist.h"
|
||||
|
||||
RDEventLine::RDEventLine(RDStation *station)
|
||||
{
|
||||
@ -222,7 +222,7 @@ void RDEventLine::setColor(const QColor &color)
|
||||
}
|
||||
|
||||
|
||||
QString RDEventLine::SchedGroup() const
|
||||
QString RDEventLine::schedGroup() const
|
||||
{
|
||||
return event_sched_group;
|
||||
}
|
||||
@ -633,16 +633,17 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
|
||||
sql=QString("select NUMBER,ARTIST,")+
|
||||
"CONCAT(GROUP_CONCAT(RPAD(SC.SCHED_CODE,11,' ') separator ''),'.') as SCHED_CODES"+
|
||||
" from CART LEFT JOIN CART_SCHED_CODES AS SC on (NUMBER=SC.CART_NUMBER)"+
|
||||
" where GROUP_NAME='"+RDEscapeString(SchedGroup())+"'"+
|
||||
" where GROUP_NAME='"+RDEscapeString(schedGroup())+"'"+
|
||||
" group by NUMBER";
|
||||
RDSchedCartList *schedCL=new RDSchedCartList();
|
||||
q=new RDSqlQuery(sql);
|
||||
int querysize=(int)q->size();
|
||||
SchedCartList *schedCL;
|
||||
schedCL=new SchedCartList(querysize);
|
||||
|
||||
for(counter=0;counter<querysize;counter++) {
|
||||
q->seek(counter);
|
||||
schedCL->insertItem(q->value(0).toUInt(),0,0,q->value(1).toString(),q->value(2).toString());
|
||||
while(q->next()) {
|
||||
QStringList codes=q->value(2).toString().split(" ",QString::SkipEmptyParts);
|
||||
if((codes.size()>0)&&(codes.last()==".")) {
|
||||
codes.removeLast();
|
||||
}
|
||||
schedCL->
|
||||
insertItem(q->value(0).toUInt(),0,0,q->value(1).toString(),codes);
|
||||
}
|
||||
delete q;
|
||||
|
||||
@ -748,10 +749,18 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
|
||||
QString wstr=q->value(0).toString();
|
||||
wstr+=" ";
|
||||
wstr=wstr.left(11);
|
||||
sql=QString("select STACK_LINES.CART ")+
|
||||
"from STACK_LINES left join STACK_SCHED_CODES "+
|
||||
"on STACK_LINES.ID=STACK_SCHED_CODES.STACK_LINES_ID where "+
|
||||
"STACK_LINES.SERVICE_NAME=\""+RDEscapeString(svcname)+"\" && "+
|
||||
QString().sprintf("STACK_LINES.SCHED_STACK_ID > %d && ",stackid-range)+
|
||||
"STACK_SCHED_CODES.SCHED_CODE=\""+RDEscapeString(wstr)+"\"";
|
||||
/*
|
||||
sql=QString("select CART from STACK_LINES where ")+
|
||||
"SERVICE_NAME=\""+RDEscapeString(svcname)+"\" && "+
|
||||
QString().sprintf("SCHED_STACK_ID > %d && ",stackid-range)+
|
||||
"SCHED_CODES like \"%%"+RDEscapeString(wstr)+"%%\"";
|
||||
*/
|
||||
q1=new RDSqlQuery(sql);
|
||||
if(q1->size()>=allowed || allowed==0) {
|
||||
for(counter=0;counter<schedCL->getNumberOfItems();counter++) {
|
||||
@ -774,10 +783,18 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
|
||||
QString wstr=q->value(3).toString();
|
||||
wstr+=" ";
|
||||
wstr=wstr.left(11);
|
||||
sql=QString("select STACK_LINES.CART ")+
|
||||
"from STACK_LINES left join STACK_SCHED_CODES "+
|
||||
"on STACK_LINES.ID=STACK_SCHED_CODES.STACK_LINES_ID where "+
|
||||
"STACK_LINES.SERVICE_NAME=\""+RDEscapeString(svcname)+"\" && "+
|
||||
QString().sprintf("STACK_LINES.SCHED_STACK_ID=%d && ",stackid-1)+
|
||||
"STACK_SCHED_CODES.SCHED_CODE=\""+RDEscapeString(wstr)+"\"";
|
||||
/*
|
||||
sql=QString("select CART from STACK_LINES where ")+
|
||||
"SERVICE_NAME=\""+RDEscapeString(svcname)+"\" && "+
|
||||
QString().sprintf("SCHED_STACK_ID=%d && ",stackid-1)+
|
||||
"SCHED_CODES like \"%"+RDEscapeString(wstr)+"%\"";
|
||||
*/
|
||||
q1=new RDSqlQuery(sql);
|
||||
if(q1->size()>0) {
|
||||
for(counter=0;counter<schedCL->getNumberOfItems();counter++) {
|
||||
@ -801,9 +818,16 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
|
||||
QString wstr=q->value(4).toString();
|
||||
wstr+=" ";
|
||||
wstr=wstr.left(11);
|
||||
sql=QString("select STACK_LINES.CART ")+
|
||||
"from STACK_LINES left join STACK_SCHED_CODES "+
|
||||
"on STACK_LINES.ID=STACK_SCHED_CODES.STACK_LINES_ID where "+
|
||||
QString().sprintf("STACK_LINES.SCHED_STACK_ID=%d && ",stackid-1)+
|
||||
"STACK_SCHED_CODES.SCHED_CODE=\""+RDEscapeString(wstr)+"\"";
|
||||
/*
|
||||
sql=QString("select CART from STACK_LINES where ")+
|
||||
QString().sprintf("SCHED_STACK_ID=%d && ",stackid-1)+
|
||||
"SCHED_CODES like \"%"+RDEscapeString(wstr)+"%\"";
|
||||
*/
|
||||
q1=new RDSqlQuery(sql);
|
||||
if(q1->size()>0) {
|
||||
for(counter=0;counter<schedCL->getNumberOfItems();counter++) {
|
||||
@ -827,9 +851,16 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
|
||||
QString wstr=q->value(5).toString();
|
||||
wstr+=" ";
|
||||
wstr=wstr.left(11);
|
||||
sql=QString("select STACK_LINES.CART ")+
|
||||
"from STACK_LINES left join STACK_SCHED_CODES "+
|
||||
"on STACK_LINES.ID=STACK_SCHED_CODES.STACK_LINES_ID where "+
|
||||
QString().sprintf("STACK_LINES.SCHED_STACK_ID=%d && ",stackid-1)+
|
||||
"STACK_SCHED_CODES.SCHED_CODE=\""+RDEscapeString(wstr)+"\"";
|
||||
/*
|
||||
sql=QString("select CART from STACK_LINES where ")+
|
||||
QString().sprintf("SCHED_STACK_ID=%d && ",stackid-1)+
|
||||
"SCHED_CODES like \"%"+RDEscapeString(wstr)+"%\"";
|
||||
*/
|
||||
q1=new RDSqlQuery(sql);
|
||||
if(q1->size()>0) {
|
||||
for(counter=0;counter<schedCL->getNumberOfItems();counter++) {
|
||||
@ -880,6 +911,21 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
|
||||
|
||||
count++;
|
||||
|
||||
sql=QString("insert into STACK_LINES set ")+
|
||||
"SERVICE_NAME=\""+RDEscapeString(svcname)+"\","+
|
||||
"SCHEDULED_AT=now(),"+
|
||||
QString().sprintf("SCHED_STACK_ID=%u,",stackid)+
|
||||
QString().sprintf("CART=%u,",schedCL->getItemCartNumber(schedpos))+
|
||||
"ARTIST=\""+RDEscapeString(schedCL->getItemArtist(schedpos))+"\"";
|
||||
unsigned line_id=RDSqlQuery::run(sql).toUInt();
|
||||
QStringList codes=schedCL->getItemSchedCodes(schedpos);
|
||||
for(int i=0;i<codes.size();i++) {
|
||||
sql=QString("insert into STACK_SCHED_CODES set ")+
|
||||
QString().sprintf("STACK_LINES_ID=%u,",line_id)+
|
||||
"SCHED_CODE=\""+RDEscapeString(codes.at(i))+"\"";
|
||||
RDSqlQuery::apply(sql);
|
||||
}
|
||||
/*
|
||||
sql=QString("insert into STACK_LINES set ")+
|
||||
"SERVICE_NAME=\""+RDEscapeString(svcname)+"\","+
|
||||
"SCHEDULED_AT=now(),"+
|
||||
@ -890,13 +936,14 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
|
||||
"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
*/
|
||||
|
||||
delete schedCL;
|
||||
}
|
||||
else {
|
||||
// We don't have any carts to work with
|
||||
*report+=time.toString("hh:mm:ss")+
|
||||
" "+QObject::tr("No carts found in group")+" "+SchedGroup();
|
||||
" "+QObject::tr("No carts found in group")+" "+schedGroup();
|
||||
if(!HaveCode().isEmpty()) {
|
||||
*report+=QObject::tr(" with sched code(s): ")+HaveCode()+" "+HaveCode2();
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class RDEventLine
|
||||
void setDefaultTransType(RDLogLine::TransType trans);
|
||||
QColor color() const;
|
||||
void setColor(const QColor &color);
|
||||
QString SchedGroup() const;
|
||||
QString schedGroup() const;
|
||||
void setSchedGroup(QString str);
|
||||
QString HaveCode() const;
|
||||
void setHaveCode(QString str);
|
||||
|
139
lib/rdschedcartlist.cpp
Normal file
139
lib/rdschedcartlist.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
// rdschedcartlist.cpp
|
||||
//
|
||||
// A class for handling carts to be used in scheduler
|
||||
//
|
||||
// Copyright (C) 2005 Stefan Gabriel <stg@st-gabriel.de>
|
||||
// Copyright (C) 2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include "rdschedcartlist.h"
|
||||
|
||||
RDSchedCartList::RDSchedCartList()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RDSchedCartList::insertItem(unsigned cartnumber,int cartlength,int stack_id,
|
||||
const QString &stack_artist,
|
||||
const QStringList &stack_schedcodes)
|
||||
{
|
||||
list_cartnum.push_back(cartnumber);
|
||||
list_cartlen.push_back(cartlength);
|
||||
list_stackid.push_back(stack_id);
|
||||
list_artist.push_back(stack_artist.lower().replace(" ",""));
|
||||
list_schedcodes.push_back(stack_schedcodes);
|
||||
}
|
||||
|
||||
|
||||
void RDSchedCartList::removeItem(int itemnumber)
|
||||
{
|
||||
list_cartnum.removeAt(itemnumber);
|
||||
list_cartlen.removeAt(itemnumber);
|
||||
list_stackid.removeAt(itemnumber);
|
||||
list_artist.removeAt(itemnumber);
|
||||
list_schedcodes.removeAt(itemnumber);
|
||||
}
|
||||
|
||||
bool RDSchedCartList::removeIfCode(int itemnumber,const QString &test_code)
|
||||
{
|
||||
bool matched=false;
|
||||
|
||||
for(int i=list_schedcodes.size()-1;i>=0;i--) {
|
||||
if(list_schedcodes.at(i).contains(test_code)) {
|
||||
list_cartnum.removeAt(i);
|
||||
list_cartlen.removeAt(i);
|
||||
list_stackid.removeAt(i);
|
||||
list_artist.removeAt(i);
|
||||
list_schedcodes.removeAt(i);
|
||||
matched=true;
|
||||
}
|
||||
}
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
||||
bool RDSchedCartList::itemHasCode(int itemnumber,const QString &test_code)
|
||||
{
|
||||
return list_schedcodes.at(itemnumber).contains(test_code);
|
||||
}
|
||||
|
||||
|
||||
bool RDSchedCartList::itemHasCodes(int itemnumber,const QStringList &test_codes)
|
||||
{
|
||||
for(int i=0;i<test_codes.size();i++) {
|
||||
if(itemHasCode(itemnumber,test_codes.at(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void RDSchedCartList::save(void)
|
||||
{
|
||||
list_savecartnum=list_cartnum;
|
||||
list_savecartlen=list_cartlen;
|
||||
list_savestackid=list_stackid;
|
||||
list_saveartist=list_artist;
|
||||
list_saveschedcodes=list_schedcodes;
|
||||
}
|
||||
|
||||
|
||||
void RDSchedCartList::restore(void)
|
||||
{
|
||||
list_cartnum=list_savecartnum;
|
||||
list_cartlen=list_savecartlen;
|
||||
list_stackid=list_savestackid;
|
||||
list_artist=list_saveartist;
|
||||
list_schedcodes=list_saveschedcodes;
|
||||
}
|
||||
|
||||
|
||||
unsigned RDSchedCartList::getItemCartNumber(int itemnumber)
|
||||
{
|
||||
return list_cartnum.at(itemnumber);
|
||||
}
|
||||
|
||||
|
||||
int RDSchedCartList::getItemStackid(int itemnumber)
|
||||
{
|
||||
return list_stackid.at(itemnumber);
|
||||
}
|
||||
|
||||
|
||||
QString RDSchedCartList::getItemArtist(int itemnumber)
|
||||
{
|
||||
return list_artist.at(itemnumber);
|
||||
}
|
||||
|
||||
|
||||
QStringList RDSchedCartList::getItemSchedCodes(int itemnumber)
|
||||
{
|
||||
return list_schedcodes.at(itemnumber);
|
||||
}
|
||||
|
||||
|
||||
int RDSchedCartList::getItemCartLength(int itemnumber)
|
||||
{
|
||||
return list_cartlen.at(itemnumber);
|
||||
}
|
||||
|
||||
|
||||
int RDSchedCartList::getNumberOfItems(void)
|
||||
{
|
||||
return list_cartnum.size();
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
// schedcartlist.h
|
||||
// rdschedcartlist.h
|
||||
//
|
||||
// A class for handling carts to be used in scheduler
|
||||
//
|
||||
// Stefan Gabriel <stg@st-gabriel.de>
|
||||
// Copyright (C) 2005 Stefan Gabriel <stg@st-gabriel.de>
|
||||
// Copyright (C) 2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -18,45 +19,44 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#ifndef SCHEDCARTLIST_H
|
||||
#define SCHEDCARTLIST_H
|
||||
#ifndef RDSCHEDCARTLIST_H
|
||||
#define RDSCHEDCARTLIST_H
|
||||
|
||||
#include <qsqldatabase.h>
|
||||
#include <qlist.h>
|
||||
#include <qstringlist.h>
|
||||
|
||||
class SchedCartList
|
||||
class RDSchedCartList
|
||||
{
|
||||
public:
|
||||
SchedCartList(int listsize);
|
||||
~SchedCartList();
|
||||
void insertItem(unsigned cartnumber,int cartlength,int stack_id,QString stack_artist,QString stack_schedcodes);
|
||||
RDSchedCartList();
|
||||
void insertItem(unsigned cartnumber,int cartlength,int stack_id,
|
||||
const QString &stack_artist,
|
||||
const QStringList &stack_schedcodes);
|
||||
void removeItem(int itemnumber);
|
||||
bool removeIfCode(int itemnumber,QString test_code);
|
||||
bool itemHasCode(int itemnumber,QString test_code);
|
||||
bool itemHasCodes(int itemnumber,QStringList test_codes);
|
||||
bool removeIfCode(int itemnumber,const QString &test_code);
|
||||
bool itemHasCode(int itemnumber,const QString &test_code);
|
||||
bool itemHasCodes(int itemnumber,const QStringList &test_codes);
|
||||
unsigned getItemCartNumber(int itemnumber);
|
||||
int getItemCartLength(int itemnumber);
|
||||
int getItemStackid(int itemnumber);
|
||||
QString getItemArtist(int itemnumber);
|
||||
QString getItemSchedCodes(int itemnumber);
|
||||
QStringList getItemSchedCodes(int itemnumber);
|
||||
int getNumberOfItems(void);
|
||||
void save(void);
|
||||
void restore(void);
|
||||
|
||||
private:
|
||||
int itemcounter;
|
||||
int saveitemcounter;
|
||||
unsigned* cartnum;
|
||||
unsigned* savecartnum;
|
||||
int* cartlen;
|
||||
int* savecartlen;
|
||||
int* stackid;
|
||||
int* savestackid;
|
||||
QString* saveartist;
|
||||
QString* artist;
|
||||
QString* sched_codes;
|
||||
QString* save_sched_codes;
|
||||
QList<unsigned> list_cartnum;
|
||||
QList<unsigned> list_savecartnum;
|
||||
QList<int> list_cartlen;
|
||||
QList<int> list_savecartlen;
|
||||
QList<int> list_stackid;
|
||||
QList<int> list_savestackid;
|
||||
QStringList list_artist;
|
||||
QStringList list_saveartist;
|
||||
QList<QStringList> list_schedcodes;
|
||||
QList<QStringList> list_saveschedcodes;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif // RDSCHEDCARTLIST_H
|
@ -1,8 +1,9 @@
|
||||
// schedruleslist.cpp
|
||||
// rdschedruleslist.cpp
|
||||
//
|
||||
// A class for handling the scheduling rules for rdlogmanager/edit clocks
|
||||
//
|
||||
// Stefan Gabriel <stg@st-gabriel.de>
|
||||
// (C) Copyright 2005 Stefan Gabriel <stg@st-gabriel.de>
|
||||
// (C) Copyright 2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -20,12 +21,12 @@
|
||||
|
||||
#include <qmessagebox.h>
|
||||
|
||||
#include <rdclock.h>
|
||||
#include <rddb.h>
|
||||
#include <rdescape_string.h>
|
||||
#include <schedruleslist.h>
|
||||
#include "rdclock.h"
|
||||
#include "rddb.h"
|
||||
#include "rdescape_string.h"
|
||||
#include "rdschedruleslist.h"
|
||||
|
||||
SchedRulesList::SchedRulesList(QString clockname,RDConfig *config)
|
||||
RDSchedRulesList::RDSchedRulesList(QString clockname,RDConfig *config)
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
@ -77,7 +78,7 @@ SchedRulesList::SchedRulesList(QString clockname,RDConfig *config)
|
||||
delete q;
|
||||
}
|
||||
|
||||
SchedRulesList::~SchedRulesList()
|
||||
RDSchedRulesList::~RDSchedRulesList()
|
||||
{
|
||||
delete []sched_code;
|
||||
delete []max_row;
|
||||
@ -88,7 +89,7 @@ SchedRulesList::~SchedRulesList()
|
||||
delete []description;
|
||||
}
|
||||
|
||||
void SchedRulesList::insertItem(int pos,int maxrow,int minwait,QString notafter,QString orafter,QString orafterii)
|
||||
void RDSchedRulesList::insertItem(int pos,int maxrow,int minwait,QString notafter,QString orafter,QString orafterii)
|
||||
{
|
||||
max_row[pos] = maxrow;
|
||||
min_wait[pos] = minwait;
|
||||
@ -97,47 +98,47 @@ void SchedRulesList::insertItem(int pos,int maxrow,int minwait,QString notafter,
|
||||
or_after_II[pos] = orafterii;
|
||||
}
|
||||
|
||||
QString SchedRulesList::getItemSchedCode(int pos)
|
||||
QString RDSchedRulesList::getItemSchedCode(int pos)
|
||||
{
|
||||
return sched_code[pos];
|
||||
}
|
||||
|
||||
int SchedRulesList::getItemMaxRow(int pos)
|
||||
int RDSchedRulesList::getItemMaxRow(int pos)
|
||||
{
|
||||
return max_row[pos];
|
||||
}
|
||||
|
||||
int SchedRulesList::getItemMinWait(int pos)
|
||||
int RDSchedRulesList::getItemMinWait(int pos)
|
||||
{
|
||||
return min_wait[pos];
|
||||
}
|
||||
|
||||
QString SchedRulesList::getItemNotAfter(int pos)
|
||||
QString RDSchedRulesList::getItemNotAfter(int pos)
|
||||
{
|
||||
return not_after[pos];
|
||||
}
|
||||
|
||||
QString SchedRulesList::getItemOrAfter(int pos)
|
||||
QString RDSchedRulesList::getItemOrAfter(int pos)
|
||||
{
|
||||
return or_after[pos];
|
||||
}
|
||||
|
||||
QString SchedRulesList::getItemOrAfterII(int pos)
|
||||
QString RDSchedRulesList::getItemOrAfterII(int pos)
|
||||
{
|
||||
return or_after_II[pos];
|
||||
}
|
||||
|
||||
QString SchedRulesList::getItemDescription(int pos)
|
||||
QString RDSchedRulesList::getItemDescription(int pos)
|
||||
{
|
||||
return description[pos];
|
||||
}
|
||||
|
||||
int SchedRulesList::getNumberOfItems(void)
|
||||
int RDSchedRulesList::getNumberOfItems(void)
|
||||
{
|
||||
return itemcounter;
|
||||
}
|
||||
|
||||
void SchedRulesList::Save(QString clockname)
|
||||
void RDSchedRulesList::Save(QString clockname)
|
||||
{
|
||||
QString sql;
|
||||
|
56
lib/rdschedruleslist.h
Normal file
56
lib/rdschedruleslist.h
Normal file
@ -0,0 +1,56 @@
|
||||
// rdschedruleslist.h
|
||||
//
|
||||
// A class for handling the scheduling rules for rdlogmanager/edit clocks
|
||||
//
|
||||
// (C) Copyright Stefan Gabriel <stg@st-gabriel.de>
|
||||
// (C) Copyright 2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#ifndef RDSCHEDRULESLIST_H
|
||||
#define RDSCHEDRULESLIST_H
|
||||
|
||||
#include <rdconfig.h>
|
||||
|
||||
class RDSchedRulesList
|
||||
{
|
||||
public:
|
||||
RDSchedRulesList(QString clockname,RDConfig *config);
|
||||
~RDSchedRulesList();
|
||||
void insertItem(int pos,int maxrow,int minwait,QString notafter,
|
||||
QString orafter,QString orafterii);
|
||||
QString getItemSchedCode(int pos);
|
||||
int getItemMaxRow(int pos);
|
||||
int getItemMinWait(int pos);
|
||||
int getNumberOfItems(void);
|
||||
QString getItemNotAfter(int pos);
|
||||
QString getItemOrAfter(int pos);
|
||||
QString getItemOrAfterII(int pos);
|
||||
QString getItemDescription(int pos);
|
||||
void Save(QString clockname);
|
||||
|
||||
private:
|
||||
int itemcounter;
|
||||
QString* sched_code;
|
||||
int* max_row;
|
||||
int* min_wait;
|
||||
QString* not_after;
|
||||
QString* or_after;
|
||||
QString* or_after_II;
|
||||
QString* description;
|
||||
};
|
||||
|
||||
|
||||
#endif // RDSCHEDRULESLIST_H
|
@ -1410,6 +1410,15 @@ void RDSvc::remove(const QString &name)
|
||||
}
|
||||
delete q;
|
||||
|
||||
sql=QString("select ID from STACK_LINES where ")+
|
||||
"SERVICE_NAME=\""+RDEscapeString(name)+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
sql=QString("delete from STACK_SCHED_CODES where ")+
|
||||
QString().sprintf("STACK_LINES_ID=%u",q->value(0).toUInt());
|
||||
RDSqlQuery::apply(sql);
|
||||
}
|
||||
delete q;
|
||||
sql=QString("delete from STACK_LINES where ")+
|
||||
"SERVICE_NAME=\""+RDEscapeString(name)+"\"";
|
||||
RDSqlQuery::apply(sql);
|
||||
|
@ -1,188 +0,0 @@
|
||||
// schedcartlist.cpp
|
||||
//
|
||||
// A class for handling carts to be used in scheduler
|
||||
//
|
||||
// Stefan Gabriel <stg@st-gabriel.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include "schedcartlist.h"
|
||||
|
||||
SchedCartList::SchedCartList(int listsize)
|
||||
{
|
||||
cartnum=new unsigned[listsize];
|
||||
cartlen=new int[listsize];
|
||||
stackid=new int[listsize];
|
||||
artist=new QString[listsize];
|
||||
sched_codes=new QString[listsize];
|
||||
itemcounter=0;
|
||||
}
|
||||
|
||||
SchedCartList::~SchedCartList()
|
||||
{
|
||||
delete []cartnum;
|
||||
delete []cartlen;
|
||||
delete []stackid;
|
||||
delete []artist;
|
||||
delete []sched_codes;
|
||||
}
|
||||
|
||||
void SchedCartList::insertItem(unsigned cartnumber,int cartlength,int stack_id,QString stack_artist,QString stack_schedcodes)
|
||||
{
|
||||
cartnum[itemcounter]=cartnumber;
|
||||
cartlen[itemcounter]=cartlength;
|
||||
stackid[itemcounter]=stack_id;
|
||||
artist[itemcounter]=stack_artist.lower().replace(" ","");
|
||||
if(stack_schedcodes=="") {
|
||||
stack_schedcodes=".";
|
||||
}
|
||||
sched_codes[itemcounter]=stack_schedcodes;
|
||||
itemcounter++;
|
||||
}
|
||||
|
||||
|
||||
void SchedCartList::removeItem(int itemnumber)
|
||||
{
|
||||
for(int i=itemnumber;i<(itemcounter-1);i++) {
|
||||
cartnum[i]=cartnum[i+1];
|
||||
cartlen[i]=cartlen[i+1];
|
||||
stackid[i]=stackid[i+1];
|
||||
artist[i]=artist[i+1];
|
||||
sched_codes[i]=sched_codes[i+1];
|
||||
}
|
||||
itemcounter--;
|
||||
}
|
||||
|
||||
bool SchedCartList::removeIfCode(int itemnumber,QString test_code)
|
||||
{
|
||||
QString test = test_code;
|
||||
test+=" ";
|
||||
test=test.left(11);
|
||||
|
||||
if (sched_codes[itemnumber].find(test)!=-1) {
|
||||
for(int i=itemnumber;i<(itemcounter-1);i++) {
|
||||
cartnum[i]=cartnum[i+1];
|
||||
cartlen[i]=cartlen[i+1];
|
||||
stackid[i]=stackid[i+1];
|
||||
artist[i]=artist[i+1];
|
||||
sched_codes[i]=sched_codes[i+1];
|
||||
}
|
||||
itemcounter--;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SchedCartList::itemHasCode(int itemnumber,QString test_code)
|
||||
{
|
||||
QString test=test_code;
|
||||
test+=" ";
|
||||
test=test.left(11);
|
||||
|
||||
if (sched_codes[itemnumber].find(test)!=-1) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SchedCartList::itemHasCodes(int itemnumber,QStringList test_codes)
|
||||
{
|
||||
for (int i=0;i<test_codes.size();i++) {
|
||||
QString test=test_codes.at(i);
|
||||
test+=" ";
|
||||
test=test.left(11);
|
||||
|
||||
if (sched_codes[itemnumber].find(test)!=-1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SchedCartList::save(void)
|
||||
{
|
||||
savecartnum=new unsigned[itemcounter];
|
||||
savecartlen=new int[itemcounter];
|
||||
savestackid=new int[itemcounter];
|
||||
saveartist=new QString[itemcounter];
|
||||
save_sched_codes=new QString[itemcounter];
|
||||
|
||||
saveitemcounter=itemcounter;
|
||||
for(int i=0;i<saveitemcounter;i++) {
|
||||
savecartnum[i]=cartnum[i];
|
||||
savecartlen[i]=cartlen[i];
|
||||
savestackid[i]=stackid[i];
|
||||
saveartist[i]=artist[i];
|
||||
save_sched_codes[i]=sched_codes[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SchedCartList::restore(void)
|
||||
{
|
||||
if(itemcounter==0) {
|
||||
for(int i=0;i<saveitemcounter;i++) {
|
||||
cartnum[i]=savecartnum[i];
|
||||
cartlen[i]=savecartlen[i];
|
||||
stackid[i]=savestackid[i];
|
||||
artist[i]=saveartist[i];
|
||||
sched_codes[i]=save_sched_codes[i];
|
||||
}
|
||||
itemcounter=saveitemcounter;
|
||||
}
|
||||
delete []savecartnum;
|
||||
delete []savecartlen;
|
||||
delete []savestackid;
|
||||
delete []saveartist;
|
||||
delete []save_sched_codes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned SchedCartList::getItemCartNumber(int itemnumber)
|
||||
{
|
||||
return cartnum[itemnumber];
|
||||
}
|
||||
|
||||
int SchedCartList::getItemStackid(int itemnumber)
|
||||
{
|
||||
return stackid[itemnumber];
|
||||
}
|
||||
|
||||
QString SchedCartList::getItemArtist(int itemnumber)
|
||||
{
|
||||
return artist[itemnumber];
|
||||
}
|
||||
|
||||
QString SchedCartList::getItemSchedCodes(int itemnumber)
|
||||
{
|
||||
return sched_codes[itemnumber];
|
||||
}
|
||||
|
||||
int SchedCartList::getItemCartLength(int itemnumber)
|
||||
{
|
||||
return cartlen[itemnumber];
|
||||
}
|
||||
|
||||
|
||||
int SchedCartList::getNumberOfItems(void)
|
||||
{
|
||||
return itemcounter;
|
||||
}
|
||||
|
@ -1,57 +0,0 @@
|
||||
// schedruleslist.h
|
||||
//
|
||||
// A class for handling the scheduling rules for rdlogmanager/edit clocks
|
||||
//
|
||||
// Stefan Gabriel <stg@st-gabriel.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#ifndef SCHEDRULESLIST_H
|
||||
#define SCHEDRULESLIST_H
|
||||
|
||||
#include <rdconfig.h>
|
||||
|
||||
class SchedRulesList
|
||||
{
|
||||
public:
|
||||
SchedRulesList(QString clockname,RDConfig *config);
|
||||
~SchedRulesList();
|
||||
void insertItem(int pos,int maxrow,int minwait,QString notafter,QString orafter,QString orafterii);
|
||||
QString getItemSchedCode(int pos);
|
||||
int getItemMaxRow(int pos);
|
||||
int getItemMinWait(int pos);
|
||||
int getNumberOfItems(void);
|
||||
QString getItemNotAfter(int pos);
|
||||
QString getItemOrAfter(int pos);
|
||||
QString getItemOrAfterII(int pos);
|
||||
QString getItemDescription(int pos);
|
||||
void Save(QString clockname);
|
||||
|
||||
|
||||
private:
|
||||
int itemcounter;
|
||||
QString* sched_code;
|
||||
int* max_row;
|
||||
int* min_wait;
|
||||
QString* not_after;
|
||||
QString* or_after;
|
||||
QString* or_after_II;
|
||||
QString* description;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -240,7 +240,7 @@ EditClock::EditClock(QString clockname,bool new_clock,
|
||||
//
|
||||
// Populate Data
|
||||
//
|
||||
sched_rules_list = new SchedRulesList(clockname,rda->config());
|
||||
sched_rules_list = new RDSchedRulesList(clockname,rda->config());
|
||||
edit_clock=new RDClock(rda->station());
|
||||
edit_clock->setName(clockname);
|
||||
edit_clock->load();
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <q3textedit.h>
|
||||
|
||||
#include <rdclock.h>
|
||||
#include <schedruleslist.h>
|
||||
#include <rdschedruleslist.h>
|
||||
|
||||
#include "clock_listview.h"
|
||||
|
||||
@ -93,7 +93,7 @@ class EditClock : public QDialog
|
||||
QString edit_name;
|
||||
bool edit_new_clock;
|
||||
std::vector<QString> *edit_new_clocks;
|
||||
SchedRulesList* sched_rules_list;
|
||||
RDSchedRulesList* sched_rules_list;
|
||||
Q3TextEdit *edit_remarks_edit;
|
||||
};
|
||||
|
||||
|
@ -31,12 +31,11 @@
|
||||
#include <qcombobox.h>
|
||||
|
||||
#include <rd.h>
|
||||
#include <schedruleslist.h>
|
||||
|
||||
#include "edit_schedcoderules.h"
|
||||
|
||||
editSchedCodeRules::editSchedCodeRules(Q3ListViewItem *item,
|
||||
SchedRulesList *sched_rules_list,
|
||||
RDSchedRulesList *sched_rules_list,
|
||||
QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Change rules for scheduler codes dialog
|
||||
//
|
||||
// (C) Copyright Stefan Gabriel <stg@st-gabriel.de>
|
||||
// (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -28,7 +28,7 @@
|
||||
#include <qcombobox.h>
|
||||
#include <qvariant.h>
|
||||
|
||||
#include <schedruleslist.h>
|
||||
#include <rdschedruleslist.h>
|
||||
|
||||
#include "clock_listview.h"
|
||||
|
||||
@ -38,7 +38,7 @@ class editSchedCodeRules : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
editSchedCodeRules(Q3ListViewItem *item, SchedRulesList *sched_rules_list,
|
||||
editSchedCodeRules(Q3ListViewItem *item, RDSchedRulesList *sched_rules_list,
|
||||
QWidget *parent=0);
|
||||
~editSchedCodeRules();
|
||||
QSize sizeHint() const;
|
||||
|
@ -37,9 +37,8 @@
|
||||
#include "edit_schedcoderules.h"
|
||||
#include "globals.h"
|
||||
#include "list_clocks.h"
|
||||
#include "schedruleslist.h"
|
||||
|
||||
EditSchedRules::EditSchedRules(QString clock,unsigned *artistsep,SchedRulesList *schedruleslist,bool *rules_modified,QWidget *parent)
|
||||
EditSchedRules::EditSchedRules(QString clock,unsigned *artistsep,RDSchedRulesList *schedruleslist,bool *rules_modified,QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
setModal(true);
|
||||
@ -231,7 +230,7 @@ void EditSchedRules::importData()
|
||||
return;
|
||||
}
|
||||
delete listclocks;
|
||||
SchedRulesList *import_list=new SchedRulesList(clockname,rda->config());
|
||||
RDSchedRulesList *import_list=new RDSchedRulesList(clockname,rda->config());
|
||||
|
||||
list_schedCodes_view->clear();
|
||||
for (int i=0; i<import_list->getNumberOfItems(); i++)
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <qvariant.h>
|
||||
|
||||
#include <rdlistview.h>
|
||||
#include <schedruleslist.h>
|
||||
#include <rdschedruleslist.h>
|
||||
|
||||
class QSpinBox;
|
||||
|
||||
@ -38,7 +38,7 @@ class EditSchedRules : public QDialog
|
||||
Q_OBJECT
|
||||
public:
|
||||
EditSchedRules(QString clock,unsigned *artistsep,
|
||||
SchedRulesList *schedruleslist,bool *rules_modified,
|
||||
RDSchedRulesList *schedruleslist,bool *rules_modified,
|
||||
QWidget *parent=0);
|
||||
~EditSchedRules();
|
||||
QSize sizeHint() const;
|
||||
@ -63,7 +63,7 @@ class EditSchedRules : public QDialog
|
||||
QString clockname;
|
||||
unsigned* edit_artistsep;
|
||||
bool* edit_rules_modified;
|
||||
SchedRulesList* sched_rules_list;
|
||||
RDSchedRulesList* sched_rules_list;
|
||||
bool edit_modified;
|
||||
};
|
||||
|
||||
|
@ -434,6 +434,14 @@ bool MainObject::DropColumn(const QString &tbl_name,const QString &col_name,
|
||||
}
|
||||
|
||||
|
||||
bool MainObject::DropIndex(const QString &tbl_name,const QString &idx_name,
|
||||
QString *err_msg) const
|
||||
{
|
||||
QString sql=QString("alter table `")+tbl_name+"` drop index `"+idx_name+"`";
|
||||
return RDSqlQuery::apply(sql,err_msg);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
QApplication a(argc,argv,false);
|
||||
|
@ -120,6 +120,8 @@ class MainObject : public QObject
|
||||
bool ColumnExists(const QString &tbl_name,const QString &col_name) const;
|
||||
bool DropColumn(const QString &tbl_name,const QString &col_name,
|
||||
QString *err_msg=NULL) const;
|
||||
bool DropIndex(const QString &tbl_name,const QString &idx_name,
|
||||
QString *err_msg=NULL) const;
|
||||
Command db_command;
|
||||
QString db_mysql_hostname;
|
||||
QString db_mysql_loginname;
|
||||
|
@ -40,6 +40,58 @@ bool MainObject::RevertSchema(int cur_schema,int set_schema,QString *err_msg)
|
||||
|
||||
// NEW SCHEMA REVERSIONS GO HERE...
|
||||
|
||||
//
|
||||
// Revert 308
|
||||
//
|
||||
if((cur_schema==308)&&(set_schema<cur_schema)) {
|
||||
sql=QString("alter table STACK_LINES add column ")+
|
||||
"SCHED_CODES varchar(191) not null after ARTIST";
|
||||
if(!RDSqlQuery::apply(sql,err_msg)) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
sql=QString("create index SCHED_STACK_ID_IDX on STACK_LINES ")+
|
||||
"(SERVICE_NAME,SCHED_STACK_ID,SCHED_CODES)";
|
||||
if(!RDSqlQuery::apply(sql,err_msg)) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
QString codes="";
|
||||
sql=QString("select ")+
|
||||
"ID " // 00
|
||||
"from STACK_LINES";
|
||||
q=new RDSqlQuery(sql,false);
|
||||
while(q->next()) {
|
||||
sql=QString("select ")+
|
||||
"SCHED_CODE " // 00
|
||||
"from STACK_SCHED_CODES where "+
|
||||
QString().sprintf("STACK_LINES_ID=%u",q->value(0).toUInt());
|
||||
q1=new RDSqlQuery(sql,false);
|
||||
while(q1->next()) {
|
||||
codes+=q1->value(0).toString();
|
||||
while((codes.length()%10)!=0) {
|
||||
codes+=" ";
|
||||
}
|
||||
}
|
||||
delete q1;
|
||||
codes+=".";
|
||||
sql=QString("update STACK_LINES set ")+
|
||||
"SCHED_CODES=\""+RDEscapeString(codes)+"\" where "+
|
||||
QString().sprintf("ID=%u",q->value(0).toUInt());
|
||||
if(!RDSqlQuery::apply(sql,err_msg)) {
|
||||
return false;
|
||||
}
|
||||
codes="";
|
||||
}
|
||||
delete q;
|
||||
DropTable("STACK_SCHED_CODES",err_msg);
|
||||
|
||||
WriteSchemaVersion(--cur_schema);
|
||||
}
|
||||
|
||||
//
|
||||
// Revert 307
|
||||
//
|
||||
if((cur_schema==307)&&(set_schema<cur_schema)) {
|
||||
DropColumn("EVENTS","ARTIST_SEP");
|
||||
sql="alter table `EVENTS` modify column `TITLE_SEP` int(10) unsigned";
|
||||
|
@ -156,7 +156,7 @@ void MainObject::InitializeSchemaMap() {
|
||||
global_version_map["2.17"]=268;
|
||||
global_version_map["2.18"]=272;
|
||||
global_version_map["2.19"]=275;
|
||||
global_version_map["3.0"]=307;
|
||||
global_version_map["3.0"]=308;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Update Rivendell DB schema.
|
||||
//
|
||||
// (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -9700,6 +9700,40 @@ bool MainObject::UpdateSchema(int cur_schema,int set_schema,QString *err_msg)
|
||||
WriteSchemaVersion(++cur_schema);
|
||||
}
|
||||
|
||||
if((cur_schema<308)&&(set_schema>cur_schema)) {
|
||||
sql=QString("create table if not exists STACK_SCHED_CODES (")+
|
||||
"ID int auto_increment not null primary key,"+
|
||||
"STACK_LINES_ID int unsigned,"+
|
||||
"SCHED_CODE varchar(10),"+
|
||||
"index SCHED_CODE_IDX(SCHED_CODE))"+
|
||||
" charset utf8mb4 collate utf8mb4_general_ci"+
|
||||
db_table_create_postfix;
|
||||
if(!RDSqlQuery::apply(sql,err_msg)) {
|
||||
return false;
|
||||
}
|
||||
sql=QString("select ")+
|
||||
"ID,"+ // 00
|
||||
"SCHED_CODES " // 01
|
||||
"from STACK_LINES";
|
||||
q=new RDSqlQuery(sql,false);
|
||||
while(q->next()) {
|
||||
QStringList f0=q->value(1).toString().split(" ",QString::SkipEmptyParts);
|
||||
for(int i=0;i<f0.size();i++) {
|
||||
if((!f0.at(i).trimmed().isEmpty())&&(f0.at(i).trimmed()!=".")) {
|
||||
sql=QString("insert into STACK_SCHED_CODES set ")+
|
||||
QString().sprintf("STACK_LINES_ID=%u,",q->value(0).toUInt())+
|
||||
"SCHED_CODE=\""+RDEscapeString(f0.at(i).trimmed())+"\"";
|
||||
RDSqlQuery::apply(sql,err_msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete q;
|
||||
DropColumn("STACK_LINES","SCHED_CODES",err_msg);
|
||||
|
||||
WriteSchemaVersion(++cur_schema);
|
||||
}
|
||||
|
||||
|
||||
// NEW SCHEMA UPDATES GO HERE...
|
||||
|
||||
//
|
||||
|
@ -327,6 +327,16 @@ void MainObject::PurgeStacks()
|
||||
if (q1->next()) {
|
||||
stackid=q1->value(0).toUInt();
|
||||
if (stackid-stacksize > 0) {
|
||||
sql=QString("select ID from STACK_LINES where ")+
|
||||
"SERVICE_NAME=\""+RDEscapeString(q->value(0).toString())+"\" && "+
|
||||
QString().sprintf("SCHED_STACK_ID<=%d",stackid-stacksize);
|
||||
q2=new RDSqlQuery(sql);
|
||||
while(q2->next()) {
|
||||
sql=QString("delete from STACK_SCHED_CODES where ")+
|
||||
QString().sprintf("STACK_LINES_ID=%u",q2->value(0).toUInt());
|
||||
RDSqlQuery::apply(sql);
|
||||
}
|
||||
delete q2;
|
||||
sql=QString("delete from STACK_LINES where ")+
|
||||
"SERVICE_NAME=\""+RDEscapeString(q->value(0).toString())+"\" && "+
|
||||
QString().sprintf("SCHED_STACK_ID<=%d",stackid-stacksize);
|
||||
|
Loading…
x
Reference in New Issue
Block a user