01: package de.schlund.pfixcore.example.bank.ihandler;
02:
03: import de.schlund.pfixcore.example.bank.context.ContextAccount;
04: import de.schlund.pfixcore.example.bank.context.ContextCustomer;
05: import de.schlund.pfixcore.example.bank.iwrapper.SelectAccount;
06: import de.schlund.pfixcore.example.bank.model.Account;
07: import de.schlund.pfixcore.example.bank.model.Customer;
08: import de.schlund.pfixcore.generator.IHandler;
09: import de.schlund.pfixcore.generator.IWrapper;
10: import de.schlund.pfixcore.workflow.Context;
11:
12: public class SelectAccountHandler implements IHandler {
13:
14: public void handleSubmittedData(Context context, IWrapper wrapper)
15: throws Exception {
16: SelectAccount selAccount = (SelectAccount) wrapper;
17: ContextCustomer contextCustomer = context
18: .getContextResourceManager().getResource(
19: ContextCustomer.class);
20: Customer customer = contextCustomer.getCustomer();
21: Account account = customer.getAccountByNo(selAccount
22: .getAccountNo());
23: if (account == null)
24: throw new IllegalArgumentException(
25: "Customer hasn't account: "
26: + selAccount.getAccountNo());
27: else {
28: ContextAccount contextAccount = context
29: .getContextResourceManager().getResource(
30: ContextAccount.class);
31: contextAccount.setAccount(account);
32: }
33: }
34:
35: public boolean isActive(Context context) throws Exception {
36: return true;
37: }
38:
39: public boolean prerequisitesMet(Context context) throws Exception {
40: return true;
41: }
42:
43: public boolean needsData(Context context) throws Exception {
44: ContextAccount contextAccount = context
45: .getContextResourceManager().getResource(
46: ContextAccount.class);
47: return contextAccount.getAccount() == null;
48: }
49:
50: public void retrieveCurrentStatus(Context context, IWrapper wrapper)
51: throws Exception {
52:
53: }
54:
55: }
|