diff --git a/odatareceptionist/procedures/PrintQueue.xsjslib b/odatareceptionist/procedures/PrintQueue.xsjslib
index 53c0d77..e7198a5 100644
--- a/odatareceptionist/procedures/PrintQueue.xsjslib
+++ b/odatareceptionist/procedures/PrintQueue.xsjslib
@@ -43,17 +43,42 @@ function isParticipantInPrintQueue(_ParticipantID) {
pStmt.close();
} catch (e) {
$.trace.debug("Error: exception caught:
" + e.toString());
- }
- return count;
+ }
+ if(count === 0) {
+ return false;
+ } else {
+ return true;
+ }
+}
+
+function getDevicesForEvent(_EventID) {
+ var conn;
+ var devices = [];
+ try {
+ conn = $.db.getConnection();
+ var select = 'SELECT "DeviceID" '
+ + 'FROM "com.sap.sapmentors.sitreg.data::SITreg.Device" '
+ + 'WHERE "EventID" = ?';
+ var pStmt = conn.prepareStatement(select);
+ pStmt.setInteger(1, _EventID);
+ var rs = pStmt.executeQuery();
+ if (rs.next()) {
+ devices.push(rs.getString(1));
+ }
+ pStmt.close();
+ } catch (e) {
+ $.trace.debug("Error: exception caught:
" + e.toString());
+ }
+ return devices;
}
function addParticipantToPrintQueue(_participant) {
var conn;
var status = {};
try {
- conn = $.db.getConnection();
- status.count = isParticipantInPrintQueue(_participant.ParticipantID);
- if(status.count === 0) {
+ var devices = getDevicesForEvent(_participant.EventID);
+ if(!isParticipantInPrintQueue(_participant.EventID)) {
+ conn = $.db.getConnection();
var select = 'INSERT INTO "com.sap.sapmentors.sitreg.data::SITreg.PrintQueue" '
+ 'VALUES(?, ?, ?, ?, ?, ?, '
+ 'CURRENT_USER, CURRENT_TIMESTAMP, CURRENT_USER, CURRENT_TIMESTAMP )';
@@ -62,6 +87,9 @@ function addParticipantToPrintQueue(_participant) {
pStmt.setInteger(2, _participant.EventID);
pStmt.setString(3, _participant.FirstName);
pStmt.setString(4, _participant.LastName);
+ if(!_participant.Twitter) {
+ _participant.Twitter = "";
+ }
pStmt.setString(5, _participant.Twitter);
pStmt.setString(6, _participant.PrintStatus);
pStmt.executeUpdate();
diff --git a/odatareceptionist/procedures/PrintQueue.xsunit.xsjslib b/odatareceptionist/procedures/PrintQueue.xsunit.xsjslib
index 7d64a12..9344138 100644
--- a/odatareceptionist/procedures/PrintQueue.xsunit.xsjslib
+++ b/odatareceptionist/procedures/PrintQueue.xsunit.xsjslib
@@ -1 +1 @@
-describe("Print Queue Tests", function() {
var cut = $.import("com.sap.sapmentors.sitreg.odatareceptionist.procedures", "PrintQueue");
var participant;
var ParticipantID;
var EventID;
beforeOnce(function() {
var select = 'SELECT TOP 1 "ID", "Participant"."EventID" '
+ 'FROM "com.sap.sapmentors.sitreg.data::SITreg.Participant" AS "Participant" '
+ 'LEFT JOIN "com.sap.sapmentors.sitreg.data::SITreg.Device" AS "Device" '
+ 'ON "Device"."EventID" = "Participant"."EventID" ';
var pStmt = jasmine.dbConnection.prepareStatement(select);
var rs = pStmt.executeQuery();
if (rs.next()) {
ParticipantID = rs.getInteger(1);
EventID = rs.getInteger(1);
}
pStmt.close();
});
it('should read participant details', function() {
participant = cut.readParticipant(ParticipantID);
expect(participant.ParticipantID).toBe(ParticipantID);
});
it('should fill print queue', function() {
participant.PrintStatus = 'P';
var status = cut.addParticipantToPrintQueue(participant);
expect(status.error).toBe(undefined);
expect(status.count).toBe(0);
});
it('check if participant was inserted', function() {
var count = cut.isParticipantInPrintQueue(ParticipantID);
expect(count).toBe(1);
});
afterOnce(function() {
var select = 'DELETE FROM "com.sap.sapmentors.sitreg.data::SITreg.PrintQueue" '
+ 'WHERE "ParticipantID" = ?';
var pStmt = jasmine.dbConnection.prepareStatement(select);
pStmt.setInteger(1, participant.ParticipantID);
pStmt.execute();
jasmine.dbConnection.commit();
pStmt.close();
});
});
\ No newline at end of file
+describe("Print Queue Tests", function() {
var cut = $.import("com.sap.sapmentors.sitreg.odatareceptionist.procedures", "PrintQueue");
var participant;
var ParticipantID;
var EventID;
beforeOnce(function() {
var select = 'SELECT TOP 1 "ID", "Participant"."EventID" '
+ 'FROM "com.sap.sapmentors.sitreg.data::SITreg.Participant" AS "Participant" '
+ 'LEFT JOIN "com.sap.sapmentors.sitreg.data::SITreg.Device" AS "Device" '
+ 'ON "Device"."EventID" = "Participant"."EventID" '
+ 'WHERE "Device"."DeviceID" IS NOT NULL';
var pStmt = jasmine.dbConnection.prepareStatement(select);
var rs = pStmt.executeQuery();
if (rs.next()) {
ParticipantID = rs.getInteger(1);
EventID = rs.getInteger(2);
}
pStmt.close();
});
it('should read participant details', function() {
participant = cut.readParticipant(ParticipantID);
expect(participant.ParticipantID).toBe(ParticipantID);
expect(participant.EventID).toBe(EventID);
});
it('should read devices for event', function() {
var devices = cut.getDevicesForEvent(EventID);
expect(devices.length).toBe(1);
});
it('should fill print queue', function() {
participant.PrintStatus = 'P';
var status = cut.addParticipantToPrintQueue(participant);
expect(status.error).toBe(undefined);
});
it('check if participant was inserted', function() {
var count = cut.isParticipantInPrintQueue(ParticipantID);
expect(count).toBe(true);
});
afterOnce(function() {
var select = 'DELETE FROM "com.sap.sapmentors.sitreg.data::SITreg.PrintQueue" '
+ 'WHERE "ParticipantID" = ?';
var pStmt = jasmine.dbConnection.prepareStatement(select);
pStmt.setInteger(1, participant.ParticipantID);
pStmt.execute();
jasmine.dbConnection.commit();
pStmt.close();
});
});
\ No newline at end of file