|
@@ -28,14 +28,117 @@
|
|
|
*/
|
|
|
void dbFlight::verifyInput(flight object)
|
|
|
{
|
|
|
- object.print();
|
|
|
- //to do
|
|
|
+
|
|
|
+ if (object.doft.isValid()){
|
|
|
+ object.invalidItems.removeOne("doft");
|
|
|
+ qDebug() << "doft verified.";
|
|
|
+ }else{
|
|
|
+ qWarning() << "Invalid entry: doft";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(dbAirport::checkICAOValid(object.dept)){
|
|
|
+ object.invalidItems.removeOne("dept");
|
|
|
+ qDebug() << "dept verified.";
|
|
|
+ }else{
|
|
|
+ qWarning() << "Invalid entry: dept";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(dbAirport::checkICAOValid(object.dest)){
|
|
|
+ object.invalidItems.removeOne("dest");
|
|
|
+ qDebug() << "dest verified.";
|
|
|
+ }else{
|
|
|
+ qWarning() << "Invalid entry: dest";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(object.tofb.isValid()){
|
|
|
+ object.invalidItems.removeOne("tofb");
|
|
|
+ qDebug() << "tofb verified.";
|
|
|
+ }else{
|
|
|
+ qWarning() << "Invalid entry: tofb";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(object.tonb.isValid()){
|
|
|
+ object.invalidItems.removeOne("tonb");
|
|
|
+ qDebug() << "tonb verified.";
|
|
|
+ }else{
|
|
|
+ qWarning() << "Invalid entry: tonb";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(dbPilots::verifyPilotExists(object.pic.split(QLatin1Char(',')))){
|
|
|
+ object.invalidItems.removeOne("pic");
|
|
|
+ qDebug() << "pic verified.";
|
|
|
+ }else{
|
|
|
+ qWarning() << "Invalid entry: pic";
|
|
|
+ }
|
|
|
+
|
|
|
+ //acft
|
|
|
+
|
|
|
+ QTime tblkcheck = calc::blocktime(object.tofb, object.tonb);
|
|
|
+ if(object.tblk.isValid() && !object.tblk.isNull() && tblkcheck == object.tblk){
|
|
|
+ object.invalidItems.removeOne("tblk");
|
|
|
+ qDebug() << "tblk verified.";
|
|
|
+ }else{
|
|
|
+ qWarning() << "Invalid entry: tblk";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!dbAircraft::retreiveTailId(object.acft).isEmpty()){
|
|
|
+ object.invalidItems.removeOne("acft");
|
|
|
+ qDebug() << "acft verified.";
|
|
|
+ }else{
|
|
|
+ qWarning() << "Invalid entry: acft";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(object.invalidItems.isEmpty()){
|
|
|
+ object.isValid = true;
|
|
|
+ qDebug() << "All checks passed. Object is now verified.";
|
|
|
+ }else{
|
|
|
+ qDebug() << "Not all checks have been passed.";
|
|
|
+ qDebug() << "Invalid items: " << object.invalidItems;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* To Do: Checks on internal logic, i.e. times <= tblk,
|
|
|
+ * restrict what strings are allowed in remarks etc.
|
|
|
+
|
|
|
+ object.pic = details[7];
|
|
|
+ object.acft = details[8];
|
|
|
+ object.tblk = QTime::fromString(details[9],"hh:mm");*/
|
|
|
+
|
|
|
+ /*object.tSPSE = QTime::fromString(details[10],"hh:mm");
|
|
|
+ object.tSPME = QTime::fromString(details[11],"hh:mm");
|
|
|
+ object.tMP = QTime::fromString(details[12],"hh:mm");
|
|
|
+ object.tNIGHT = QTime::fromString(details[13],"hh:mm");
|
|
|
+ object.tIFR = QTime::fromString(details[14],"hh:mm");
|
|
|
+
|
|
|
+ object.tPIC = QTime::fromString(details[15],"hh:mm");
|
|
|
+ object.tPICUS = QTime::fromString(details[16],"hh:mm");
|
|
|
+ object.tSIC = QTime::fromString(details[17],"hh:mm");
|
|
|
+ object.tDUAL = QTime::fromString(details[18],"hh:mm");
|
|
|
+ object.tFI = QTime::fromString(details[19],"hh:mm");
|
|
|
+ object.tSIM = QTime::fromString(details[20],"hh:mm");
|
|
|
+
|
|
|
+ object.pilotFlying = details[21].toInt();
|
|
|
+ object.toDay = details[22].toInt();
|
|
|
+ object.toNight = details[23].toInt();
|
|
|
+ object.ldgDay = details[24].toInt();
|
|
|
+ object.ldgNight = details[25].toInt();
|
|
|
+ object.autoland = details[26].toInt();
|
|
|
+
|
|
|
+ object.secondPilot = details[27];
|
|
|
+ object.thirdPilot = details[28];
|
|
|
+ object.approachType = details[29];
|
|
|
+ object.flightNumber = details[30];
|
|
|
+ object.remarks = details[31];*/
|
|
|
}
|
|
|
|
|
|
+/*!
|
|
|
+ * \brief dbFlight::retreiveFlight Runs a select statement on the database
|
|
|
+ * for a given flight_id and returns a flight object containing the details
|
|
|
+ * for the given ID. If no matching ID is found, an empty flight object is
|
|
|
+ * returned
|
|
|
+ * \param flight_id Primary Key of flight database
|
|
|
+ */
|
|
|
flight dbFlight::retreiveFlight(QString flight_id)
|
|
|
{
|
|
|
- //To Do
|
|
|
-
|
|
|
QSqlQuery query;
|
|
|
query.prepare("SELECT * FROM flights WHERE id = ?");
|
|
|
query.addBindValue(flight_id);
|
|
@@ -116,7 +219,7 @@ flight dbFlight::retreiveFlight(QString flight_id)
|
|
|
object.remarks = query.value(30).toString();
|
|
|
|
|
|
//Database entries are assumed to be valid
|
|
|
- object.isValid = true;
|
|
|
+ object.isValid = true;
|
|
|
object.invalidItems.clear();
|
|
|
|
|
|
return object;
|