16.10.2015 Views

Getting Startedwith pureQuery

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

256<br />

<strong>Getting</strong> Started with <strong>pureQuery</strong><br />

java.util.Map object or <strong>pureQuery</strong> bean to specify the parameters<br />

so that you can retrieve the updated values of the OUT and INOUT parameters.<br />

// Execute the bonus_increase stored procedure.<br />

@Call(sql = "CALL bonus_increase (?1.bonusFactor,<br />

?1.bonusMaxSumForDepartment, ?1.departmentsWithoutNewBonuses,<br />

?1.countDepartmentsViewed, ?1.countDepartmentsBonusChanged,<br />

?1.errorMessage)")<br />

Iterator callBonusIncrease (Map<br />

parameters);<br />

Listing 12.11 - The annotated method that would need to be added to<br />

hrm.inProgress.pdqMethodStyle.HumanResourcesData<br />

// Screen: "Increase Employee Bonuses"<br />

private void increaseEmployeeBonuses (HumanResourcesData data)<br />

{<br />

// Repeatedly display the "Increase Employee Bonuses" screen until the<br />

// user selects "0". This means that every time the user returns to<br />

this<br />

// screen from another one, this screen will be displayed again.<br />

boolean userSelectedReturnToPreviousScreen = false;<br />

while (!userSelectedReturnToPreviousScreen) {<br />

outputWriter.println ();<br />

outputWriter.println ("--------------- Increase Employee Bonuses ---<br />

------------");<br />

outputWriter.println ();<br />

outputWriter.println ("Increasing bonus sizes for all employees in<br />

the company");<br />

// Ask the user for the bonus factor.<br />

Double bonusFactor = null;<br />

while (null == bonusFactor) {<br />

String bonusFactorString = getLineFromConsole ("\nYou can increase<br />

the size of bonuses by multiplying all the\n"<br />

+ "bonuses by a number between 1 and 2. Please enter the\n"<br />

+ "multiplier that you want the application to use: ");<br />

try {<br />

bonusFactor = Double.parseDouble (bonusFactorString);<br />

}<br />

catch (NumberFormatException e) {<br />

outputWriter.println ("The value \"" + bonusFactor + "\" is not<br />

a valid number.");<br />

}<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!