/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/30 12:30:07*/ /*This class drives: PersonRole*/ package BankingSystem.core.humanResources; import java.util.*; import BankingSystem.*; import BankingSystem.core.intangableResources.*; import BankingSystem.core.tangableResources.*; import BankingSystem.json.*; public class Person { //Class datatypes private String name; private String address; private String phoneNumber; //Class association variables private List personRoles; //Registry of our system. BankingSystemRegistry registry = BankingSystemRegistry.getInstance(); //Constructor public Person(String aName, String aAddress, String aPhoneNumber) { name = aName; address = aAddress; phoneNumber = aPhoneNumber; personRoles = new ArrayList(); registry.add(personRoles); } public boolean setName(String aName) { name = aName; return true; } public boolean setAddress(String aAddress) { address = aAddress; return true; } public boolean setPhoneNumber(String aPhoneNumber) { phoneNumber = aPhoneNumber; return true; } public String getName() { return name; } public String getAddress() { return address; } public String getPhoneNumber() { return phoneNumber; } public List getPersonRoles() { return personRoles; } public PersonRole addPersonRole() { PersonRole newPersonRole; newPersonRole = new PersonRole(this); if (!personRoles.contains(newPersonRole)) { registry.add(newPersonRole); personRoles.add(newPersonRole); } return newPersonRole; } public PersonRole addPersonRole(PersonRole aPersonRole) { if (!personRoles.contains(aPersonRole)) personRoles.add(aPersonRole); return aPersonRole; } public void delete() { //Delete all many ends first. for (PersonRole aPersonRole : personRoles) { aPersonRole.delete(); } personRoles.clear(); } public void deletePersonRole(PersonRole aPersonRole) { if (personRoles.contains(aPersonRole)) { personRoles.remove(aPersonRole); //registry.removeObj(registry.getKey(aPersonRole)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (personRoles.size() == 0) { return true; } else return false; } /*********************************** * Returns the attribute list along with the * class ID in JSON format. ***********************************/ public JSONObject getAttributes() throws JSONException { JSONObject obj = new JSONObject(); obj.put("CLASS_ID", registry.getKey(this)); obj.put("name", getName()); obj.put("address", getAddress()); obj.put("phoneNumber", getPhoneNumber()); return obj; } }