forked from sapmentors/SITreg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xsunit tests for PrintQueue sapmentors#25
- Loading branch information
1 parent
c2f3e54
commit 10163f4
Showing
5 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,96 @@ | ||
function PrintQueueUpdate(param){ | ||
function readParticipant(_ParticipantID) { | ||
var conn; | ||
var participant = {}; | ||
|
||
try { | ||
conn = $.db.getConnection(); | ||
var select = 'SELECT "ID", "EventID", "FirstName", "LastName", "Twitter"' | ||
+ ' FROM "com.sap.sapmentors.sitreg.data::SITreg.Participant"' | ||
+ ' WHERE "ID" = ?'; | ||
var pStmt = conn.prepareStatement(select); | ||
pStmt.setInteger(1, _ParticipantID); | ||
var rs = pStmt.executeQuery(); | ||
if (rs.next()) { | ||
participant.ParticipantID = rs.getInteger(1); | ||
participant.EventID = rs.getInteger(2); | ||
participant.FirstName = rs.getNString(3); | ||
participant.LastName = rs.getNString(4); | ||
participant.Twitter = rs.getNString(5); | ||
} | ||
rs.close(); | ||
pStmt.close(); | ||
conn.close(); | ||
} catch (e) { | ||
participant.error = "Error: exception caught: <br />" + e.toString(); | ||
} | ||
return participant; | ||
} | ||
|
||
function isParticipantInPrintQueue(_ParticipantID) { | ||
var conn; | ||
var count; | ||
try { | ||
conn = $.db.getConnection(); | ||
var select = 'SELECT COUNT("ParticipantID") AS count ' | ||
+ 'FROM "com.sap.sapmentors.sitreg.data::SITreg.PrintQueue" ' | ||
+ 'WHERE "ParticipantID" = ?'; | ||
var pStmt = conn.prepareStatement(select); | ||
pStmt.setInteger(1, _ParticipantID); | ||
var rs = pStmt.executeQuery(); | ||
if (rs.next()) { | ||
count = rs.getInteger(1); | ||
} | ||
pStmt.close(); | ||
} catch (e) { | ||
$.trace.debug("Error: exception caught: <br />" + e.toString()); | ||
} | ||
return count; | ||
} | ||
|
||
function addParticipantToPrintQueue(_participant) { | ||
var conn; | ||
var status = {}; | ||
try { | ||
conn = $.db.getConnection(); | ||
status.count = isParticipantInPrintQueue(_participant.ParticipantID); | ||
if(status.count === 0) { | ||
var select = 'INSERT INTO "com.sap.sapmentors.sitreg.data::SITreg.PrintQueue" ' | ||
+ 'VALUES(?, ?, ?, ?, ?, ?, ' | ||
+ 'CURRENT_USER, CURRENT_TIMESTAMP, CURRENT_USER, CURRENT_TIMESTAMP )'; | ||
var pStmt = conn.prepareStatement(select); | ||
pStmt.setInteger(1, _participant.ParticipantID); | ||
pStmt.setInteger(2, _participant.EventID); | ||
pStmt.setString(3, _participant.FirstName); | ||
pStmt.setString(4, _participant.LastName); | ||
pStmt.setString(5, _participant.Twitter); | ||
pStmt.setString(6, _participant.PrintStatus); | ||
pStmt.executeUpdate(); | ||
conn.commit(); | ||
pStmt.close(); | ||
} else { | ||
status.error = "Entry does already exist"; | ||
} | ||
conn.close(); | ||
} catch (e) { | ||
status.error = "Error: exception caught: <br />" + e.toString(); | ||
} | ||
return status; | ||
} | ||
|
||
function PrintQueueUpdateAfterTicketUpdate(param){ | ||
$.trace.debug('entered function PrintQueueUpdate'); | ||
// let before = param.beforeTableName; | ||
let after = param.afterTableName; | ||
// Update PrintQueue | ||
let pStmt = param.connection.prepareStatement('SELECT * FROM "' + after + '"' ); | ||
let rs = pStmt.executeQuery(); | ||
if (rs.next()) { | ||
var ParticipantID = rs.getNString(1); | ||
var TicketUsed = rs.getNString(4); | ||
} | ||
$.trace.debug('TicketUsed: ' + TicketUsed); | ||
$.trace.debug('ParticipantID:' + ParticipantID + 'TicketUsed: ' + TicketUsed); | ||
// var participant = readParticipant(ParticipantID); | ||
rs.close(); | ||
pStmt.close(); | ||
$.trace.debug('leave function PrintQueueUpdate'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters