/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/29 14:36:59*/ /*This class drives: */ package Police.core; import java.util.*; import java.sql.Time; import Police.*; import Police.json.*; public class InvestigatingOfficer extends Person { //Class datatypes //Class association variables private List crimeOccurrences; private Jurisdiction jurisdiction; //Registry of our system. PoliceRegistry registry = PoliceRegistry.getInstance(); //Constructor public InvestigatingOfficer(String aName, String aPhone, String aSex, String aAddress, String aAge, Jurisdiction aJurisdiction) { super(aName, aPhone, aSex, aAddress, aAge); crimeOccurrences = new ArrayList(); registry.add(crimeOccurrences); jurisdiction = aJurisdiction; jurisdiction.addInvestigatingOfficer(this); } public List getCrimeOccurrences() { return crimeOccurrences; } public Jurisdiction getJurisdiction() { return jurisdiction; } 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; } /* This class does not drive Jurisdiction and therefore sets the association unidirectionally.*/ public void setJurisdiction(Jurisdiction aJurisdiction) { jurisdiction = aJurisdiction; } public void delete() { //Delete all 1 ends. jurisdiction.deleteInvestigatingOfficer(this); } 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 boolean areManyEndsNull() { return true; } /*********************************** * 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)); return obj; } }