2022-03-04 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in rdimport(1) that could create duplicate
	Scheduler Code entries when using the '--to-cart' and
	'--add-scheduler-code' switches simultaneously.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2022-03-04 13:15:42 -05:00
parent dc1cd4a748
commit 5afcd7e7af
3 changed files with 19 additions and 9 deletions

View File

@ -20849,3 +20849,7 @@
target. target.
2022-02-22 Fred Gleason <fredg@paravelsystems.com> 2022-02-22 Fred Gleason <fredg@paravelsystems.com>
* Incremented the package version to 3.6.4. * Incremented the package version to 3.6.4.
2022-03-04 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in rdimport(1) that could create duplicate
Scheduler Code entries when using the '--to-cart' and
'--add-scheduler-code' switches simultaneously.

View File

@ -2,7 +2,7 @@
// //
// Abstract a Rivendell Cart. // Abstract a Rivendell Cart.
// //
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@ -306,20 +306,18 @@ QStringList RDCart::schedCodesList() const
} }
void RDCart::setSchedCodesList(const QStringList &codes) const void RDCart::setSchedCodesList(QStringList codes) const
{ {
RDSqlQuery *q;
QString sql; QString sql;
QString sched_codes=""; QString sched_codes="";
sql=QString().sprintf("delete from CART_SCHED_CODES where CART_NUMBER=%u",cart_number); sql=QString().sprintf("delete from CART_SCHED_CODES where CART_NUMBER=%u",cart_number);
q=new RDSqlQuery(sql); RDSqlQuery::apply(sql);
delete q;
codes.removeDuplicates();
for(int i=0;i<codes.size();i++) { for(int i=0;i<codes.size();i++) {
sql=QString().sprintf("insert into CART_SCHED_CODES set CART_NUMBER=%u,SCHED_CODE='%s'",cart_number,(const char *)codes.at(i)); sql=QString().sprintf("insert into CART_SCHED_CODES set CART_NUMBER=%u,SCHED_CODE='%s'",cart_number,(const char *)codes.at(i));
q=new RDSqlQuery(sql); RDSqlQuery::apply(sql);
delete q;
} }
} }
@ -329,6 +327,14 @@ void RDCart::addSchedCode(const QString &code) const
QStringList codes=schedCodesList(); QStringList codes=schedCodesList();
codes.push_back(code); codes.push_back(code);
setSchedCodesList(codes); setSchedCodesList(codes);
/*
QStringList codes=schedCodesList();
if(!codes.contains(code)) {
codes.push_back(code);
setSchedCodesList(codes);
}
*/
} }

View File

@ -2,7 +2,7 @@
// //
// Abstract a Rivendell Cart // Abstract a Rivendell Cart
// //
// (C) Copyright 2002-2020 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@ -65,7 +65,7 @@ class RDCart
QString schedCodes() const; QString schedCodes() const;
void setSchedCodes(const QString &sched_codes) const; void setSchedCodes(const QString &sched_codes) const;
QStringList schedCodesList() const; QStringList schedCodesList() const;
void setSchedCodesList(const QStringList &codes) const; void setSchedCodesList(QStringList codes) const;
void addSchedCode(const QString &code) const; void addSchedCode(const QString &code) const;
void removeSchedCode(const QString &code) const; void removeSchedCode(const QString &code) const;
void updateSchedCodes(const QString &add_codes, void updateSchedCodes(const QString &add_codes,