/*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 ChargeOccurrence { //Class datatypes private String dateEntered; private String disposition; private String penalty; //Class association variables private OffenseType offenseType; private List crimeOccurrences; private Suspect suspect; //Registry of our system. PoliceRegistry registry = PoliceRegistry.getInstance(); //Constructor public ChargeOccurrence(String aDateEntered, String aDisposition, String aPenalty, OffenseType aOffenseType, Suspect aSuspect) { dateEntered = aDateEntered; disposition = aDisposition; penalty = aPenalty; offenseType = aOffenseType; offenseType.addChargeOccurrence(this); crimeOccurrences = new ArrayList(); registry.add(crimeOccurrences); suspect = aSuspect; suspect.addChargeOccurrence(this); } public boolean setDateEntered(String aDateEntered) { dateEntered = aDateEntered; return true; } public boolean setDisposition(String aDisposition) { disposition = aDisposition; return true; } public boolean setPenalty(String aPenalty) { penalty = aPenalty; return true; } public String getDateEntered() { return dateEntered; } public String getDisposition() { return disposition; } public String getPenalty() { return penalty; } public OffenseType getOffenseType() { return offenseType; } public List getCrimeOccurrences() { return crimeOccurrences; } public Suspect getSuspect() { return suspect; } 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 OffenseType and therefore sets the association unidirectionally.*/ public void setOffenseType(OffenseType aOffenseType) { offenseType = aOffenseType; } /* This class does not drive Suspect and therefore sets the association unidirectionally.*/ public void setSuspect(Suspect aSuspect) { suspect = aSuspect; } public void delete() { //Delete all 1 ends. offenseType.deleteChargeOccurrence(this); suspect.deleteChargeOccurrence(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)); obj.put("dateEntered", getDateEntered()); obj.put("disposition", getDisposition()); obj.put("penalty", getPenalty()); return obj; } }