/*This code was generated using the UMPLE modeling language!*/ package BankingSystem; import java.sql.Time; import java.sql.Date; import java.util.ArrayList; import java.util.Iterator; import BankingSystem.json.*; import BankingSystem.core.humanResources.*; import BankingSystem.core.intangableResources.*; import BankingSystem.core.tangableResources.*; public class BankingSystemFacade { // Singleton instance. private static BankingSystemFacade theInstance; //System registry. BankingSystemRegistry registry = BankingSystemRegistry.getInstance(); /** * Dummy constructor */ private BankingSystemFacade() { } /** * Returns the only instance of the Facade. * * @return */ public static BankingSystemFacade getInstance() { if (theInstance == null) theInstance = new BankingSystemFacade(); return theInstance; } public int constructBranch(String aName, String aAddress, String aBranchNumber) { return registry.add(new Branch(aName, aAddress, aBranchNumber)); } public JSONObject constructBranchJSON(String aName, String aAddress, String aBranchNumber) throws JSONException { Branch contextObj = new Branch(aName, aAddress, aBranchNumber); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setAddressInBranch(int context, String aAddress) { return ((Branch) registry.getValue(context)).setAddress(aAddress); } public boolean setBranchNumberInBranch(int context, String aBranchNumber) { return ((Branch) registry.getValue(context)).setBranchNumber(aBranchNumber); } public String getAddressFromBranch(int context) { return ((Branch) registry.getValue(context)).getAddress(); } public String getBranchNumberFromBranch(int context) { return ((Branch) registry.getValue(context)).getBranchNumber(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getAccountsFromBranch(int context) { ArrayList listOfIDs = new ArrayList(); for (Account obj : ((Branch) registry.getValue(context)).getAccounts()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addAccountToBranch(int context, int aAccountNumber, Float aBalance, Float aCreditLimit, ArrayList clients, int aAccountType, int aBranch) throws Exception { return registry.getKey(((Branch) registry.getValue(context)).addAccount( aAccountNumber, aBalance, aCreditLimit, clients, (AccountType) registry .getValue(aAccountType), (Branch) registry.getValue(aBranch))); } public JSONObject addAccountToBranchJSON(int context, int aAccountNumber, Float aBalance, Float aCreditLimit, ArrayList clients, int aAccountType, int aBranch) throws JSONException, Exception { return ((Branch) registry.getValue(context)).addAccount(aAccountNumber, aBalance, aCreditLimit, clients, (AccountType) registry.getValue(aAccountType), (Branch) registry.getValue(aBranch)).getAttributes(); } public int addAccountToBranchOnly(int context, int aAccount) throws Exception { return registry.getKey(((Branch) registry.getValue(context)) .addAccount((Account) registry.getValue(aAccount))); } public JSONObject addAccountToBranchOnlyJSON(int context, int aAccount) throws JSONException, Exception { return ((Branch) registry.getValue(context)).addAccount( (Account) registry.getValue(aAccount)).getAttributes(); } public void deleteBranch(int context) { ((Branch) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteAccountFromBranch(int context, int aAccount) { ((Branch) registry.getValue(context)).deleteAccount((Account) registry .getValue(aAccount)); } public JSONObject getAttributesOfBranch(int context) throws JSONException { return ((Branch) registry.getValue(context)).getAttributes(); } public int constructCreditCardAccount(int aAccountNumber, Float aBalance, Float aCreditLimit, ArrayList clients, int aAccountType, int aBranch, Date aExpiryDate, ArrayList cards) { return registry.add(new CreditCardAccount(aAccountNumber, aBalance, aCreditLimit, clients, (AccountType) registry.getValue(aAccountType), (Branch) registry.getValue(aBranch), aExpiryDate, cards)); } public JSONObject constructCreditCardAccountJSON(int aAccountNumber, Float aBalance, Float aCreditLimit, ArrayList clients, int aAccountType, int aBranch, Date aExpiryDate, ArrayList cards) throws JSONException { CreditCardAccount contextObj = new CreditCardAccount(aAccountNumber, aBalance, aCreditLimit, clients, (AccountType) registry.getValue(aAccountType), (Branch) registry .getValue(aBranch), aExpiryDate, cards); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setExpiryDateInCreditCardAccount(int context, Date aExpiryDate) { return ((CreditCardAccount) registry.getValue(context)) .setExpiryDate(aExpiryDate); } public Date getExpiryDateFromCreditCardAccount(int context) { return ((CreditCardAccount) registry.getValue(context)).getExpiryDate(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getCardsFromCreditCardAccount(int context) { ArrayList listOfIDs = new ArrayList(); for (Card obj : ((CreditCardAccount) registry.getValue(context)).getCards()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addCardToCreditCardAccount(int context, String aHolderName, int aCreditCardAccount) throws Exception { return registry.getKey(((CreditCardAccount) registry.getValue(context)) .addCard(aHolderName, (CreditCardAccount) registry .getValue(aCreditCardAccount))); } public JSONObject addCardToCreditCardAccountJSON(int context, String aHolderName, int aCreditCardAccount) throws JSONException, Exception { return ((CreditCardAccount) registry.getValue(context)).addCard( aHolderName, (CreditCardAccount) registry.getValue(aCreditCardAccount)) .getAttributes(); } public int addCardToCreditCardAccountOnly(int context, int aCard) throws Exception { return registry.getKey(((CreditCardAccount) registry.getValue(context)) .addCard((Card) registry.getValue(aCard))); } public JSONObject addCardToCreditCardAccountOnlyJSON(int context, int aCard) throws JSONException, Exception { return ((CreditCardAccount) registry.getValue(context)).addCard( (Card) registry.getValue(aCard)).getAttributes(); } public void deleteCreditCardAccount(int context) { ((CreditCardAccount) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteCardFromCreditCardAccount(int context, int aCard) { ((CreditCardAccount) registry.getValue(context)).deleteCard((Card) registry .getValue(aCard)); } public JSONObject getAttributesOfCreditCardAccount(int context) throws JSONException { return ((CreditCardAccount) registry.getValue(context)).getAttributes(); } public int constructAccount(int aAccountNumber, Float aBalance, Float aCreditLimit, ArrayList clients, int aAccountType, int aBranch) { return registry.add(new Account(aAccountNumber, aBalance, aCreditLimit, clients, (AccountType) registry.getValue(aAccountType), (Branch) registry .getValue(aBranch))); } public JSONObject constructAccountJSON(int aAccountNumber, Float aBalance, Float aCreditLimit, ArrayList clients, int aAccountType, int aBranch) throws JSONException { Account contextObj = new Account(aAccountNumber, aBalance, aCreditLimit, clients, (AccountType) registry.getValue(aAccountType), (Branch) registry .getValue(aBranch)); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setAccountNumberInAccount(int context, int aAccountNumber) { return ((Account) registry.getValue(context)) .setAccountNumber(aAccountNumber); } public boolean setBalanceInAccount(int context, Float aBalance) { return ((Account) registry.getValue(context)).setBalance(aBalance); } public boolean setCreditLimitInAccount(int context, Float aCreditLimit) { return ((Account) registry.getValue(context)).setCreditLimit(aCreditLimit); } public int getAccountNumberFromAccount(int context) { return ((Account) registry.getValue(context)).getAccountNumber(); } public Float getBalanceFromAccount(int context) { return ((Account) registry.getValue(context)).getBalance(); } public Float getCreditLimitFromAccount(int context) { return ((Account) registry.getValue(context)).getCreditLimit(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getClientsFromAccount(int context) { ArrayList listOfIDs = new ArrayList(); for (Client obj : ((Account) registry.getValue(context)).getClients()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int getAccountTypeFromAccount(int context) { return registry.getKey(((Account) registry.getValue(context)) .getAccountType()); } public JSONObject getAccountTypeFromAccountJSON(int context) throws JSONException { return ((Account) registry.getValue(context)).getAccountType() .getAttributes(); } public int getBranchFromAccount(int context) { return registry.getKey(((Account) registry.getValue(context)).getBranch()); } public JSONObject getBranchFromAccountJSON(int context) throws JSONException { return ((Account) registry.getValue(context)).getBranch().getAttributes(); } public int addClientToAccount(int context, int aPerson, String aName, String aAddress, String aPhoneNumber, ArrayList accounts) throws Exception { return registry.getKey(((Account) registry.getValue(context)).addClient( (Person) registry.getValue(aPerson), aName, aAddress, aPhoneNumber, accounts)); } public JSONObject addClientToAccountJSON(int context, int aPerson, String aName, String aAddress, String aPhoneNumber, ArrayList accounts) throws JSONException, Exception { return ((Account) registry.getValue(context)).addClient( (Person) registry.getValue(aPerson), aName, aAddress, aPhoneNumber, accounts).getAttributes(); } public int addClientToAccountOnly(int context, int aClient) throws Exception { return registry.getKey(((Account) registry.getValue(context)) .addClient((Client) registry.getValue(aClient))); } public JSONObject addClientToAccountOnlyJSON(int context, int aClient) throws JSONException, Exception { return ((Account) registry.getValue(context)).addClient( (Client) registry.getValue(aClient)).getAttributes(); } public void setAccountTypeInAccount(int context, int aAccountType) throws Exception { ((Account) registry.getValue(context)) .setAccountType((AccountType) registry.getValue(aAccountType)); } public void setBranchInAccount(int context, int aBranch) throws Exception { ((Account) registry.getValue(context)).setBranch((Branch) registry .getValue(aBranch)); } public void deleteAccount(int context) { ((Account) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteClientFromAccount(int context, int aClient) { ((Account) registry.getValue(context)).deleteClient((Client) registry .getValue(aClient)); } public JSONObject getAttributesOfAccount(int context) throws JSONException { return ((Account) registry.getValue(context)).getAttributes(); } public int constructPrivilege(String aDescription) { return registry.add(new Privilege(aDescription)); } public JSONObject constructPrivilegeJSON(String aDescription) throws JSONException { Privilege contextObj = new Privilege(aDescription); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setDescriptionInPrivilege(int context, String aDescription) { return ((Privilege) registry.getValue(context)) .setDescription(aDescription); } public String getDescriptionFromPrivilege(int context) { return ((Privilege) registry.getValue(context)).getDescription(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getAccountTypesFromPrivilege(int context) { ArrayList listOfIDs = new ArrayList(); for (AccountType obj : ((Privilege) registry.getValue(context)) .getAccountTypes()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addAccountTypeToPrivilege(int context, Float aMonthlyFee, Float aInterestRate) throws Exception { return registry.getKey(((Privilege) registry.getValue(context)) .addAccountType(aMonthlyFee, aInterestRate)); } public JSONObject addAccountTypeToPrivilegeJSON(int context, Float aMonthlyFee, Float aInterestRate) throws JSONException, Exception { return ((Privilege) registry.getValue(context)).addAccountType(aMonthlyFee, aInterestRate).getAttributes(); } public int addAccountTypeToPrivilegeOnly(int context, int aAccountType) throws Exception { return registry.getKey(((Privilege) registry.getValue(context)) .addAccountType((AccountType) registry.getValue(aAccountType))); } public JSONObject addAccountTypeToPrivilegeOnlyJSON(int context, int aAccountType) throws JSONException, Exception { return ((Privilege) registry.getValue(context)).addAccountType( (AccountType) registry.getValue(aAccountType)).getAttributes(); } public void deletePrivilege(int context) { ((Privilege) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteAccountTypeFromPrivilege(int context, int aAccountType) { ((Privilege) registry.getValue(context)) .deleteAccountType((AccountType) registry.getValue(aAccountType)); } public JSONObject getAttributesOfPrivilege(int context) throws JSONException { return ((Privilege) registry.getValue(context)).getAttributes(); } public int constructEmployee(int aPerson, int aDivision) { return registry.add(new Employee((Person) registry.getValue(aPerson), (Division) registry.getValue(aDivision))); } public JSONObject constructEmployeeJSON(int aPerson, int aDivision) throws JSONException { Employee contextObj = new Employee((Person) registry.getValue(aPerson), (Division) registry .getValue(aDivision)); registry.add(contextObj); return contextObj.getAttributes(); } public int getManagerFromEmployee(int context) { return registry .getKey(((Employee) registry.getValue(context)).getManager()); } public JSONObject getManagerFromEmployeeJSON(int context) throws JSONException { return ((Employee) registry.getValue(context)).getManager().getAttributes(); } public int getDivisionFromEmployee(int context) { return registry.getKey(((Employee) registry.getValue(context)) .getDivision()); } public JSONObject getDivisionFromEmployeeJSON(int context) throws JSONException { return ((Employee) registry.getValue(context)).getDivision() .getAttributes(); } public void setManagerInEmployee(int context, int aManager) throws Exception { ((Employee) registry.getValue(context)).setManager((Manager) registry .getValue(aManager)); } public void setDivisionInEmployee(int context, int aDivision) throws Exception { ((Employee) registry.getValue(context)).setDivision((Division) registry .getValue(aDivision)); } public void deleteEmployee(int context) { ((Employee) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteManagerFromEmployee(int context, int aManager) { ((Employee) registry.getValue(context)).deleteManager((Manager) registry .getValue(aManager)); } public JSONObject getAttributesOfEmployee(int context) throws JSONException { return ((Employee) registry.getValue(context)).getAttributes(); } public int constructMortgageAccount(int aAccountNumber, Float aBalance, Float aCreditLimit, ArrayList clients, int aAccountType, int aBranch, String aCollateral) { return registry.add(new MortgageAccount(aAccountNumber, aBalance, aCreditLimit, clients, (AccountType) registry.getValue(aAccountType), (Branch) registry.getValue(aBranch), aCollateral)); } public JSONObject constructMortgageAccountJSON(int aAccountNumber, Float aBalance, Float aCreditLimit, ArrayList clients, int aAccountType, int aBranch, String aCollateral) throws JSONException { MortgageAccount contextObj = new MortgageAccount(aAccountNumber, aBalance, aCreditLimit, clients, (AccountType) registry.getValue(aAccountType), (Branch) registry .getValue(aBranch), aCollateral); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setCollateralInMortgageAccount(int context, String aCollateral) { return ((MortgageAccount) registry.getValue(context)) .setCollateral(aCollateral); } public String getCollateralFromMortgageAccount(int context) { return ((MortgageAccount) registry.getValue(context)).getCollateral(); } public void deleteMortgageAccount(int context) { ((MortgageAccount) registry.getValue(context)).delete(); registry.removeObj(context); } public JSONObject getAttributesOfMortgageAccount(int context) throws JSONException { return ((MortgageAccount) registry.getValue(context)).getAttributes(); } public int constructManager(int aPerson, int aDivision) { return registry.add(new Manager((Person) registry.getValue(aPerson), (Division) registry.getValue(aDivision))); } public JSONObject constructManagerJSON(int aPerson, int aDivision) throws JSONException { Manager contextObj = new Manager((Person) registry.getValue(aPerson), (Division) registry .getValue(aDivision)); registry.add(contextObj); return contextObj.getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getEmployeesFromManager(int context) { ArrayList listOfIDs = new ArrayList(); for (Employee obj : ((Manager) registry.getValue(context)).getEmployees()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addEmployeeToManager(int context, int aPerson, int aDivision) throws Exception { return registry.getKey(((Manager) registry.getValue(context)).addEmployee( (Person) registry.getValue(aPerson), (Division) registry .getValue(aDivision))); } public JSONObject addEmployeeToManagerJSON(int context, int aPerson, int aDivision) throws JSONException, Exception { return ((Manager) registry.getValue(context)).addEmployee( (Person) registry.getValue(aPerson), (Division) registry.getValue(aDivision)).getAttributes(); } public int addEmployeeToManagerOnly(int context, int aEmployee) throws Exception { return registry.getKey(((Manager) registry.getValue(context)) .addEmployee((Employee) registry.getValue(aEmployee))); } public JSONObject addEmployeeToManagerOnlyJSON(int context, int aEmployee) throws JSONException, Exception { return ((Manager) registry.getValue(context)).addEmployee( (Employee) registry.getValue(aEmployee)).getAttributes(); } public void deleteManager(int context) { ((Manager) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteEmployeeFromManager(int context, int aEmployee) { ((Manager) registry.getValue(context)).deleteEmployee((Employee) registry .getValue(aEmployee)); } public JSONObject getAttributesOfManager(int context) throws JSONException { return ((Manager) registry.getValue(context)).getAttributes(); } public int constructDivision(String aName) { return registry.add(new Division(aName)); } public JSONObject constructDivisionJSON(String aName) throws JSONException { Division contextObj = new Division(aName); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setNameInDivision(int context, String aName) { return ((Division) registry.getValue(context)).setName(aName); } public String getNameFromDivision(int context) { return ((Division) registry.getValue(context)).getName(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getEmployeesFromDivision(int context) { ArrayList listOfIDs = new ArrayList(); for (Employee obj : ((Division) registry.getValue(context)).getEmployees()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getSubDivisionsFromDivision(int context) { ArrayList listOfIDs = new ArrayList(); for (Division obj : ((Division) registry.getValue(context)) .getSubDivisions()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int getDivisionFromDivision(int context) { return registry.getKey(((Division) registry.getValue(context)) .getDivision()); } public JSONObject getDivisionFromDivisionJSON(int context) throws JSONException { return ((Division) registry.getValue(context)).getDivision() .getAttributes(); } public int addEmployeeToDivision(int context, int aPerson, int aDivision) throws Exception { return registry.getKey(((Division) registry.getValue(context)).addEmployee( (Person) registry.getValue(aPerson), (Division) registry .getValue(aDivision))); } public JSONObject addEmployeeToDivisionJSON(int context, int aPerson, int aDivision) throws JSONException, Exception { return ((Division) registry.getValue(context)).addEmployee( (Person) registry.getValue(aPerson), (Division) registry.getValue(aDivision)).getAttributes(); } public int addEmployeeToDivisionOnly(int context, int aEmployee) throws Exception { return registry.getKey(((Division) registry.getValue(context)) .addEmployee((Employee) registry.getValue(aEmployee))); } public JSONObject addEmployeeToDivisionOnlyJSON(int context, int aEmployee) throws JSONException, Exception { return ((Division) registry.getValue(context)).addEmployee( (Employee) registry.getValue(aEmployee)).getAttributes(); } public int addSubDivisionToDivision(int context, String aName) throws Exception { return registry.getKey(((Division) registry.getValue(context)) .addSubDivision(aName)); } public JSONObject addSubDivisionToDivisionJSON(int context, String aName) throws JSONException, Exception { return ((Division) registry.getValue(context)).addSubDivision(aName) .getAttributes(); } public int addSubDivisionToDivisionOnly(int context, int aSubDivision) throws Exception { return registry.getKey(((Division) registry.getValue(context)) .addSubDivision((Division) registry.getValue(aSubDivision))); } public JSONObject addSubDivisionToDivisionOnlyJSON(int context, int aSubDivision) throws JSONException, Exception { return ((Division) registry.getValue(context)).addSubDivision( (Division) registry.getValue(aSubDivision)).getAttributes(); } public void setDivisionInDivision(int context, int aDivision) throws Exception { ((Division) registry.getValue(context)).setDivision((Division) registry .getValue(aDivision)); } public void deleteDivision(int context) { ((Division) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteEmployeeFromDivision(int context, int aEmployee) { ((Division) registry.getValue(context)).deleteEmployee((Employee) registry .getValue(aEmployee)); } public void deleteSubDivisionFromDivision(int context, int aDivision) { ((Division) registry.getValue(context)) .deleteSubDivision((Division) registry.getValue(aDivision)); } public void deleteDivisionFromDivision(int context, int aDivision) { ((Division) registry.getValue(context)).deleteDivision((Division) registry .getValue(aDivision)); } public JSONObject getAttributesOfDivision(int context) throws JSONException { return ((Division) registry.getValue(context)).getAttributes(); } public int constructPerson(String aName, String aAddress, String aPhoneNumber) { return registry.add(new Person(aName, aAddress, aPhoneNumber)); } public JSONObject constructPersonJSON(String aName, String aAddress, String aPhoneNumber) throws JSONException { Person contextObj = new Person(aName, aAddress, aPhoneNumber); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setNameInPerson(int context, String aName) { return ((Person) registry.getValue(context)).setName(aName); } public boolean setAddressInPerson(int context, String aAddress) { return ((Person) registry.getValue(context)).setAddress(aAddress); } public boolean setPhoneNumberInPerson(int context, String aPhoneNumber) { return ((Person) registry.getValue(context)).setPhoneNumber(aPhoneNumber); } public String getNameFromPerson(int context) { return ((Person) registry.getValue(context)).getName(); } public String getAddressFromPerson(int context) { return ((Person) registry.getValue(context)).getAddress(); } public String getPhoneNumberFromPerson(int context) { return ((Person) registry.getValue(context)).getPhoneNumber(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getPersonRolesFromPerson(int context) { ArrayList listOfIDs = new ArrayList(); for (PersonRole obj : ((Person) registry.getValue(context)) .getPersonRoles()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addPersonRoleToPerson(int context) throws Exception { return registry.getKey(((Person) registry.getValue(context)) .addPersonRole()); } public JSONObject addPersonRoleToPersonJSON(int context) throws JSONException, Exception { return ((Person) registry.getValue(context)).addPersonRole() .getAttributes(); } public int addPersonRoleToPersonOnly(int context, int aPersonRole) throws Exception { return registry.getKey(((Person) registry.getValue(context)) .addPersonRole((PersonRole) registry.getValue(aPersonRole))); } public JSONObject addPersonRoleToPersonOnlyJSON(int context, int aPersonRole) throws JSONException, Exception { return ((Person) registry.getValue(context)).addPersonRole( (PersonRole) registry.getValue(aPersonRole)).getAttributes(); } public void deletePerson(int context) { ((Person) registry.getValue(context)).delete(); registry.removeObj(context); } public void deletePersonRoleFromPerson(int context, int aPersonRole) { ((Person) registry.getValue(context)) .deletePersonRole((PersonRole) registry.getValue(aPersonRole)); } public JSONObject getAttributesOfPerson(int context) throws JSONException { return ((Person) registry.getValue(context)).getAttributes(); } public int constructClient(int aPerson, String aName, String aAddress, String aPhoneNumber, ArrayList accounts) throws Exception { return registry.add(new Client((Person) registry.getValue(aPerson), aName, aAddress, aPhoneNumber, accounts)); } public JSONObject constructClientJSON(int aPerson, String aName, String aAddress, String aPhoneNumber, ArrayList accounts) throws JSONException, Exception { Client contextObj = new Client((Person) registry.getValue(aPerson), aName, aAddress, aPhoneNumber, accounts); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setNameInClient(int context, String aName) { return ((Client) registry.getValue(context)).setName(aName); } public boolean setAddressInClient(int context, String aAddress) { return ((Client) registry.getValue(context)).setAddress(aAddress); } public boolean setPhoneNumberInClient(int context, String aPhoneNumber) { return ((Client) registry.getValue(context)).setPhoneNumber(aPhoneNumber); } public String getNameFromClient(int context) { return ((Client) registry.getValue(context)).getName(); } public String getAddressFromClient(int context) { return ((Client) registry.getValue(context)).getAddress(); } public String getPhoneNumberFromClient(int context) { return ((Client) registry.getValue(context)).getPhoneNumber(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getAccountsFromClient(int context) { ArrayList listOfIDs = new ArrayList(); for (Account obj : ((Client) registry.getValue(context)).getAccounts()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addAccountToClient(int context, int aAccountNumber, Float aBalance, Float aCreditLimit, ArrayList clients, int aAccountType, int aBranch) throws Exception { return registry.getKey(((Client) registry.getValue(context)).addAccount( aAccountNumber, aBalance, aCreditLimit, clients, (AccountType) registry .getValue(aAccountType), (Branch) registry.getValue(aBranch))); } public JSONObject addAccountToClientJSON(int context, int aAccountNumber, Float aBalance, Float aCreditLimit, ArrayList clients, int aAccountType, int aBranch) throws JSONException, Exception { return ((Client) registry.getValue(context)).addAccount(aAccountNumber, aBalance, aCreditLimit, clients, (AccountType) registry.getValue(aAccountType), (Branch) registry.getValue(aBranch)).getAttributes(); } public int addAccountToClientOnly(int context, int aAccount) throws Exception { return registry.getKey(((Client) registry.getValue(context)) .addAccount((Account) registry.getValue(aAccount))); } public JSONObject addAccountToClientOnlyJSON(int context, int aAccount) throws JSONException, Exception { return ((Client) registry.getValue(context)).addAccount( (Account) registry.getValue(aAccount)).getAttributes(); } public void deleteClient(int context) { ((Client) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteAccountFromClient(int context, int aAccount) { ((Client) registry.getValue(context)).deleteAccount((Account) registry .getValue(aAccount)); } public JSONObject getAttributesOfClient(int context) throws JSONException { return ((Client) registry.getValue(context)).getAttributes(); } public int constructCard(String aHolderName, int aCreditCardAccount) { return registry.add(new Card(aHolderName, (CreditCardAccount) registry .getValue(aCreditCardAccount))); } public JSONObject constructCardJSON(String aHolderName, int aCreditCardAccount) throws JSONException { Card contextObj = new Card(aHolderName, (CreditCardAccount) registry .getValue(aCreditCardAccount)); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setHolderNameInCard(int context, String aHolderName) { return ((Card) registry.getValue(context)).setHolderName(aHolderName); } public String getHolderNameFromCard(int context) { return ((Card) registry.getValue(context)).getHolderName(); } public int getCreditCardAccountFromCard(int context) { return registry.getKey(((Card) registry.getValue(context)) .getCreditCardAccount()); } public JSONObject getCreditCardAccountFromCardJSON(int context) throws JSONException { return ((Card) registry.getValue(context)).getCreditCardAccount() .getAttributes(); } public void setCreditCardAccountInCard(int context, int aCreditCardAccount) throws Exception { ((Card) registry.getValue(context)) .setCreditCardAccount((CreditCardAccount) registry .getValue(aCreditCardAccount)); } public void deleteCard(int context) { ((Card) registry.getValue(context)).delete(); registry.removeObj(context); } public JSONObject getAttributesOfCard(int context) throws JSONException { return ((Card) registry.getValue(context)).getAttributes(); } public int constructPersonRole(int aPerson) { return registry.add(new PersonRole((Person) registry.getValue(aPerson))); } public JSONObject constructPersonRoleJSON(int aPerson) throws JSONException { PersonRole contextObj = new PersonRole((Person) registry.getValue(aPerson)); registry.add(contextObj); return contextObj.getAttributes(); } public int getPersonFromPersonRole(int context) { return registry.getKey(((PersonRole) registry.getValue(context)) .getPerson()); } public JSONObject getPersonFromPersonRoleJSON(int context) throws JSONException { return ((PersonRole) registry.getValue(context)).getPerson() .getAttributes(); } public void setPersonInPersonRole(int context, int aPerson) throws Exception { ((PersonRole) registry.getValue(context)).setPerson((Person) registry .getValue(aPerson)); } public void deletePersonRole(int context) { ((PersonRole) registry.getValue(context)).delete(); registry.removeObj(context); } public JSONObject getAttributesOfPersonRole(int context) throws JSONException { return ((PersonRole) registry.getValue(context)).getAttributes(); } public int constructAccountType(Float aMonthlyFee, Float aInterestRate) { return registry.add(new AccountType(aMonthlyFee, aInterestRate)); } public JSONObject constructAccountTypeJSON(Float aMonthlyFee, Float aInterestRate) throws JSONException { AccountType contextObj = new AccountType(aMonthlyFee, aInterestRate); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setMonthlyFeeInAccountType(int context, Float aMonthlyFee) { return ((AccountType) registry.getValue(context)) .setMonthlyFee(aMonthlyFee); } public boolean setInterestRateInAccountType(int context, Float aInterestRate) { return ((AccountType) registry.getValue(context)) .setInterestRate(aInterestRate); } public Float getMonthlyFeeFromAccountType(int context) { return ((AccountType) registry.getValue(context)).getMonthlyFee(); } public Float getInterestRateFromAccountType(int context) { return ((AccountType) registry.getValue(context)).getInterestRate(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getPrivilegesFromAccountType(int context) { ArrayList listOfIDs = new ArrayList(); for (Privilege obj : ((AccountType) registry.getValue(context)) .getPrivileges()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addPrivilegeToAccountType(int context, String aDescription) throws Exception { return registry.getKey(((AccountType) registry.getValue(context)) .addPrivilege(aDescription)); } public JSONObject addPrivilegeToAccountTypeJSON(int context, String aDescription) throws JSONException, Exception { return ((AccountType) registry.getValue(context)) .addPrivilege(aDescription).getAttributes(); } public int addPrivilegeToAccountTypeOnly(int context, int aPrivilege) throws Exception { return registry.getKey(((AccountType) registry.getValue(context)) .addPrivilege((Privilege) registry.getValue(aPrivilege))); } public JSONObject addPrivilegeToAccountTypeOnlyJSON(int context, int aPrivilege) throws JSONException, Exception { return ((AccountType) registry.getValue(context)).addPrivilege( (Privilege) registry.getValue(aPrivilege)).getAttributes(); } public void deleteAccountType(int context) { ((AccountType) registry.getValue(context)).delete(); registry.removeObj(context); } public void deletePrivilegeFromAccountType(int context, int aPrivilege) { ((AccountType) registry.getValue(context)) .deletePrivilege((Privilege) registry.getValue(aPrivilege)); } public JSONObject getAttributesOfAccountType(int context) throws JSONException { return ((AccountType) registry.getValue(context)).getAttributes(); } }