KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > samples > loanbroker > DefaultCreditAgencyService


1 /*
2  * $Id: DefaultCreditAgencyService.java 3982 2006-11-22 14:28:01Z lajos $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.samples.loanbroker;
12
13 import org.mule.samples.loanbroker.service.CreditAgencyService;
14
15 /**
16  * <code>DefaultCreditAgencyService</code> the service that provides a credit score
17  * for a customer
18  */

19 public class DefaultCreditAgencyService implements CreditAgencyService
20 {
21
22     public int getCreditScore(int ssn)
23     {
24         int credit_score;
25
26         credit_score = (int)(Math.random() * 600 + 300);
27
28         return credit_score;
29     }
30
31     public int getCreditHistoryLength(int ssn)
32     {
33         int credit_history_length;
34
35         credit_history_length = (int)(Math.random() * 19 + 1);
36
37         return credit_history_length;
38     }
39
40     // public CreditProfile getCreditProfile(Customer customer)
41
// {
42
// CreditProfile cp = new CreditProfile();
43
// cp.setCreditHistoryLength(getCreditHistoryLength(customer.getSsn()));
44
// cp.setCreditScore(getCreditScore(customer.getSsn()));
45
//
46
// return cp;
47
// }
48

49     public BankQuoteRequest getCreditProfile(BankQuoteRequest request)
50     {
51         CreditProfile cp = new CreditProfile();
52         Customer customer = request.getLoanRequest().getCustomer();
53         cp.setCreditHistoryLength(getCreditHistoryLength(customer.getSsn()));
54         cp.setCreditScore(getCreditScore(customer.getSsn()));
55         request.getLoanRequest().setCreditProfile(cp);
56         return request;
57     }
58 }
59
Popular Tags