From 1c6a127e171155f7a8b584a1648f0b5449adccc3 Mon Sep 17 00:00:00 2001
From: Jan Reher <jreher@ep1.rub.de>
Date: Fri, 27 Mar 2020 10:13:36 +0100
Subject: [PATCH] Extension of apdUnitCreator

---
 apdUnitCreator.cpp | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/apdUnitCreator.cpp b/apdUnitCreator.cpp
index e2274b8..735e553 100644
--- a/apdUnitCreator.cpp
+++ b/apdUnitCreator.cpp
@@ -30,24 +30,29 @@ void processArgumentsAndQueryMissing(int m_argc, char* m_argv[]);
 void loadSerialsFromFileName(string m_fileName, bool m_debug = false);
 
 int main(int argc, char* argv[]) {
-    ProductionDatabaseClient *proddb = new ProductionDatabaseClient();
     processArgumentsAndQueryMissing(argc, argv);
+    ProductionDatabaseClient *proddb = new ProductionDatabaseClient();
 
     if (debug) cout << "Intitialized apdBoxSetter with version " << proddb->getVersion() << " of the database access libraries." << endl << endl
                     << "Now trying to set Batch number " << boxNo << " for ADPs from serial file " << fileName << endl;
 
     loadSerialsFromFileName(fileName);
 
-//    if (username == "" || password == "") proddb->queryCredentials();
-//    else proddb->setCredentials(username, password);
-//    DatabaseClientResponse response = proddb->checkConnectivityAndCredentials();
-//    if (response != Successful ) {
-//        cerr << "Connection to database failed because of error: " << response << endl;
-//        return response;
-//    }
-//    if (debug) cout << "Connection successful!" << endl;
-
+    if (username == "" || password == "") proddb->queryCredentials();
+    else proddb->setCredentials(username, password);
+    DatabaseClientResponse response = proddb->checkConnectivityAndCredentials();
+    if (response != Successful ) {
+        cerr << "Connection to database failed because of error: " << response << endl;
+        return response;
+    }
+    if (debug) cout << "Connection successful!" << endl;
 
+    for (auto newUnit = newUnits.begin(); newUnit < newUnits.end(); newUnit++) {
+        //proddb->createApdCapsule(newUnit->redSerial, newUnit->blueSerial);
+        std::string capsuleSerial = newUnit->redSerial + "/" + newUnit->blueSerial;
+        std::cerr << "Capsule serial should be " << capsuleSerial << std::endl;
+        //proddb->createApdUnit(capsuleSerial, newUnit->crystalSerial, newUnit->barCode);
+    }
 
 //    cout << "\nBox " << boxNo << " was successfully assigned to APDs from serial file " << fileName << ". At least I hope so. In any case, something happened for " << apdSerials.size() << " APDs."
 //         << "\nThank you for using apdBoxSetter! :)" << endl << endl;
-- 
GitLab