/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/31 09:26:55*/ /*This class drives: */ package Geneology.core; import java.sql.Date; import Geneology.*; import Geneology.json.*; public class Adoption { //Class datatypes private String dateOfAdoption; //Class association variables private Union adoptiveParents; private Person adoptedChild; //Registry of our system. GeneologyRegistry registry = GeneologyRegistry.getInstance(); //Constructor public Adoption(String aDateOfAdoption) { dateOfAdoption = aDateOfAdoption; } public boolean setDateOfAdoption(String aDateOfAdoption) { dateOfAdoption = aDateOfAdoption; return true; } public String getDateOfAdoption() { return dateOfAdoption; } public Union getAdoptiveParents() { return adoptiveParents; } public Person getAdoptedChild() { return adoptedChild; } /* This class does not drive Union and therefore sets the association unidirectionally.*/ public void setAdoptiveParents(Union aAdoptiveParents) { adoptiveParents = aAdoptiveParents; } /* This class does not drive Person and therefore sets the association unidirectionally.*/ public void setAdoptedChild(Person aAdoptedChild) { adoptedChild = aAdoptedChild; } public void delete() { //Delete all 1 ends. adoptiveParents.deleteAdoption(this); adoptedChild.deleteAdoption(this); } public void deleteAdoptiveParents(Union aUnion) { if (aUnion.equals(adoptiveParents)) { adoptiveParents = null; registry.removeObj(registry.getKey(aUnion)); } else //Throw an UmpleException .. to be implemented. { } } public void deleteAdoptedChild(Person aPerson) { if (aPerson.equals(adoptedChild)) { adoptedChild = null; registry.removeObj(registry.getKey(aPerson)); } 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("dateOfAdoption", getDateOfAdoption()); return obj; } }