@@ -99,7 +99,7 @@ function checkComponents(api, dbConnectionMap, components, callback) {
9999 } , function ( results , cb ) {
100100 if ( ! error ) {
101101 if ( results . length === 0 ) {
102- error = new IllegalArgumentError ( "The componentId " + component . componentId + " does not exist in database." ) ;
102+ error = new IllegalArgumentError ( "The componentId " + component . componentId + " does not exist in database." ) ;
103103 }
104104 }
105105
@@ -300,6 +300,47 @@ var setRoundTerms = function (api, connection, dbConnectionMap, next) {
300300 } ) ;
301301} ;
302302
303+ /**
304+ * Gets round terms.
305+ *
306+ * @param api the api instance.
307+ * @param connection the connection instance
308+ * @param dbConnectionMap the database connection map
309+ * @param next the callback method
310+ */
311+ var getRoundTerms = function ( api , connection , dbConnectionMap , next ) {
312+ var helper = api . helper ,
313+ sqlParams = { } ,
314+ roundId = Number ( connection . params . roundId ) ,
315+ roundTermsContent = '' ;
316+
317+ async . waterfall ( [
318+ function ( cb ) {
319+ cb ( helper . checkAdmin ( connection , 'Authorized information needed.' , 'Admin access only.' ) ) ;
320+ } , function ( cb ) {
321+ cb ( helper . checkIdParameter ( roundId , "roundId" ) ) ;
322+ } , function ( cb ) {
323+ sqlParams . round_id = roundId ;
324+ api . dataAccess . executeQuery ( "get_round_terms" , sqlParams , dbConnectionMap , cb ) ;
325+ } , function ( results , cb ) {
326+ if ( ! results || results . length === 0 ) {
327+ var error = new IllegalArgumentError ( "The round terms can't be found with such roundId = " + roundId ) ;
328+ cb ( error ) ;
329+ } else {
330+ roundTermsContent = results [ 0 ] . terms_content ;
331+ cb ( ) ;
332+ }
333+ }
334+ ] , function ( err ) {
335+ if ( err ) {
336+ helper . handleError ( api , connection , err ) ;
337+ } else {
338+ connection . response = { "roundTermsContent" : roundTermsContent } ;
339+ }
340+ next ( connection , true ) ;
341+ } ) ;
342+ } ;
343+
303344/**
304345 * The API for Set Round Components.
305346 */
@@ -348,4 +389,29 @@ exports.setRoundTerms = {
348389 api . helper . handleNoConnection ( api , connection , next ) ;
349390 }
350391 }
351- } ;
392+ } ;
393+
394+ /**
395+ * The API for Get Round Terms.
396+ */
397+ exports . getRoundTerms = {
398+ name : "getRoundTerms" ,
399+ description : "Get Round Terms" ,
400+ inputs : {
401+ required : [ 'roundId' ] ,
402+ optional : [ ]
403+ } ,
404+ blockedConnectionTypes : [ ] ,
405+ outputExample : { } ,
406+ version : 'v2' ,
407+ transaction : 'read' ,
408+ databases : [ "informixoltp" ] ,
409+ run : function ( api , connection , next ) {
410+ if ( connection . dbConnectionMap ) {
411+ api . log ( "Execute getRoundTerms#run" , 'debug' ) ;
412+ getRoundTerms ( api , connection , connection . dbConnectionMap , next ) ;
413+ } else {
414+ api . helper . handleNoConnection ( api , connection , next ) ;
415+ }
416+ }
417+ } ;
0 commit comments