/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/29 14:36:59*/ /*This class drives: InvestigatingOfficer*/ package Police.core; import java.util.*; import java.sql.Time; import Police.*; import Police.json.*; public class Jurisdiction { //Class datatypes private String name; private String phone; private String address; //Class association variables private List crimeOccurrences; private List investigatingOfficers; //Registry of our system. PoliceRegistry registry = PoliceRegistry.getInstance(); //Constructor public Jurisdiction(String aName, String aPhone, String aAddress) { name = aName; phone = aPhone; address = aAddress; crimeOccurrences = new ArrayList(); registry.add(crimeOccurrences); investigatingOfficers = new ArrayList(); registry.add(investigatingOfficers); } public boolean setName(String aName) { name = aName; return true; } public boolean setPhone(String aPhone) { phone = aPhone; return true; } public boolean setAddress(String aAddress) { address = aAddress; return true; } public String getName() { return name; } public String getPhone() { return phone; } public String getAddress() { return address; } public List getCrimeOccurrences() { return crimeOccurrences; } public List getInvestigatingOfficers() { return investigatingOfficers; } public CrimeOccurrence addCrimeOccurrence(String aLocation, String aDate, String aTime, String aDescription) { CrimeOccurrence newCrimeOccurrence; newCrimeOccurrence = new CrimeOccurrence(aLocation, aDate, aTime, aDescription); if (!crimeOccurrences.contains(newCrimeOccurrence)) { registry.add(newCrimeOccurrence); crimeOccurrences.add(newCrimeOccurrence); } return newCrimeOccurrence; } public CrimeOccurrence addCrimeOccurrence(CrimeOccurrence aCrimeOccurrence) { if (!crimeOccurrences.contains(aCrimeOccurrence)) crimeOccurrences.add(aCrimeOccurrence); return aCrimeOccurrence; } public InvestigatingOfficer addInvestigatingOfficer(String aName, String aPhone, String aSex, String aAddress, String aAge) { InvestigatingOfficer newInvestigatingOfficer; newInvestigatingOfficer = new InvestigatingOfficer(aName, aPhone, aSex, aAddress, aAge, this); if (!investigatingOfficers.contains(newInvestigatingOfficer)) { registry.add(newInvestigatingOfficer); investigatingOfficers.add(newInvestigatingOfficer); } return newInvestigatingOfficer; } public InvestigatingOfficer addInvestigatingOfficer( InvestigatingOfficer aInvestigatingOfficer) { if (!investigatingOfficers.contains(aInvestigatingOfficer)) investigatingOfficers.add(aInvestigatingOfficer); return aInvestigatingOfficer; } public void delete() { //Delete all many ends first. for (InvestigatingOfficer aInvestigatingOfficer : investigatingOfficers) { aInvestigatingOfficer.delete(); } investigatingOfficers.clear(); } public void deleteCrimeOccurrence(CrimeOccurrence aCrimeOccurrence) { if (crimeOccurrences.contains(aCrimeOccurrence)) { crimeOccurrences.remove(aCrimeOccurrence); //registry.removeObj(registry.getKey(aCrimeOccurrence)); } else //Throw an UmpleException .. to be implemented. { } } public void deleteInvestigatingOfficer( InvestigatingOfficer aInvestigatingOfficer) { if (investigatingOfficers.contains(aInvestigatingOfficer)) { investigatingOfficers.remove(aInvestigatingOfficer); //registry.removeObj(registry.getKey(aInvestigatingOfficer)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (investigatingOfficers.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("phone", getPhone()); obj.put("address", getAddress()); return obj; } }