/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/31 09:22:21*/ /*This class drives: */ package Geneology.core; import java.util.*; import java.sql.Date; import Geneology.*; import Geneology.json.*; public class Person { //Class datatypes private String name; private String sex; private String placeOfBirth; private String dateOfBirth; private String placeOfDeath; private String dateOfDeath; //Class association variables private List unions; private Union parents; //Registry of our system. GeneologyRegistry registry = GeneologyRegistry.getInstance(); //Constructor public Person(String aName, String aSex, String aPlaceOfBirth, String aDateOfBirth, String aPlaceOfDeath, String aDateOfDeath) throws Exception { name = aName; sex = aSex; placeOfBirth = aPlaceOfBirth; dateOfBirth = aDateOfBirth; placeOfDeath = aPlaceOfDeath; dateOfDeath = aDateOfDeath; unions = new ArrayList(); registry.add(unions); } public boolean setName(String aName) { name = aName; return true; } public boolean setSex(String aSex) { sex = aSex; return true; } public boolean setPlaceOfBirth(String aPlaceOfBirth) { placeOfBirth = aPlaceOfBirth; return true; } public boolean setDateOfBirth(String aDateOfBirth) { dateOfBirth = aDateOfBirth; return true; } public boolean setPlaceOfDeath(String aPlaceOfDeath) { placeOfDeath = aPlaceOfDeath; return true; } public boolean setDateOfDeath(String aDateOfDeath) { dateOfDeath = aDateOfDeath; return true; } public String getName() { return name; } public String getSex() { return sex; } public String getPlaceOfBirth() { return placeOfBirth; } public String getDateOfBirth() { return dateOfBirth; } public String getPlaceOfDeath() { return placeOfDeath; } public String getDateOfDeath() { return dateOfDeath; } public List getUnions() { return unions; } public Union getParents() { return parents; } public Union addUnion(String aPlaceOfMarriage, String aDateOfMarriage, String aDateOfDivorce) { Union newUnion; newUnion = new Union(aPlaceOfMarriage, aDateOfMarriage, aDateOfDivorce); if (!unions.contains(newUnion)) { registry.add(newUnion); unions.add(newUnion); } return newUnion; } public Union addUnion(Union aUnion) { if (!unions.contains(aUnion)) unions.add(aUnion); return aUnion; } /* This class does not drive Union and therefore sets the association unidirectionally.*/ public void setParents(Union aParents) { parents = aParents; } public void delete() { //Delete all 1 ends. parents.deletePartner(this); } public void deleteUnion(Union aUnion) { if (unions.contains(aUnion)) { unions.remove(aUnion); //registry.removeObj(registry.getKey(aUnion)); } else //Throw an UmpleException .. to be implemented. { } } public void deleteParents(Union aUnion) { if (aUnion.equals(parents)) { parents = null; registry.removeObj(registry.getKey(aUnion)); } 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("name", getName()); obj.put("sex", getSex()); obj.put("placeOfBirth", getPlaceOfBirth()); obj.put("dateOfBirth", getDateOfBirth()); obj.put("placeOfDeath", getPlaceOfDeath()); obj.put("dateOfDeath", getDateOfDeath()); return obj; } }