/*This code was generated using the UMPLE modeling language!*/ package Geneology; import java.sql.Time; import java.sql.Date; import java.util.ArrayList; import java.util.Iterator; import Geneology.json.*; import Geneology.core.*; public class GeneologyFacade { // Singleton instance. private static GeneologyFacade theInstance; //System registry. GeneologyRegistry registry = GeneologyRegistry.getInstance(); /** * Dummy constructor */ private GeneologyFacade() { } /** * Returns the only instance of the Facade. * * @return */ public static GeneologyFacade getInstance() { if (theInstance == null) theInstance = new GeneologyFacade(); return theInstance; } public int constructUnion(String aPlaceOfMarriage, String aDateOfMarriage, String aDateOfDivorce) { return registry.add(new Union(aPlaceOfMarriage, aDateOfMarriage, aDateOfDivorce)); } public JSONObject constructUnionJSON(String aPlaceOfMarriage, String aDateOfMarriage, String aDateOfDivorce) throws JSONException { Union contextObj = new Union(aPlaceOfMarriage, aDateOfMarriage, aDateOfDivorce); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setPlaceOfMarriageInUnion(int context, String aPlaceOfMarriage) { return ((Union) registry.getValue(context)) .setPlaceOfMarriage(aPlaceOfMarriage); } public boolean setDateOfMarriageInUnion(int context, String aDateOfMarriage) { return ((Union) registry.getValue(context)) .setDateOfMarriage(aDateOfMarriage); } public boolean setDateOfDivorceInUnion(int context, String aDateOfDivorce) { return ((Union) registry.getValue(context)) .setDateOfDivorce(aDateOfDivorce); } public String getPlaceOfMarriageFromUnion(int context) { return ((Union) registry.getValue(context)).getPlaceOfMarriage(); } public String getDateOfMarriageFromUnion(int context) { return ((Union) registry.getValue(context)).getDateOfMarriage(); } public String getDateOfDivorceFromUnion(int context) { return ((Union) registry.getValue(context)).getDateOfDivorce(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getPartnersFromUnion(int context) { ArrayList listOfIDs = new ArrayList(); for (Person obj : ((Union) registry.getValue(context)).getPartners()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getChildsFromUnion(int context) { ArrayList listOfIDs = new ArrayList(); for (Person obj : ((Union) registry.getValue(context)).getChilds()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addPartnerToUnion(int context, String aName, String aSex, String aPlaceOfBirth, String aDateOfBirth, String aPlaceOfDeath, String aDateOfDeath) throws Exception { return registry.getKey(((Union) registry.getValue(context)).addPartner( aName, aSex, aPlaceOfBirth, aDateOfBirth, aPlaceOfDeath, aDateOfDeath)); } public JSONObject addPartnerToUnionJSON(int context, String aName, String aSex, String aPlaceOfBirth, String aDateOfBirth, String aPlaceOfDeath, String aDateOfDeath) throws JSONException, Exception { return ((Union) registry.getValue(context)).addPartner(aName, aSex, aPlaceOfBirth, aDateOfBirth, aPlaceOfDeath, aDateOfDeath).getAttributes(); } public int addPartnerToUnionOnly(int context, int aPartner) throws Exception { return registry.getKey(((Union) registry.getValue(context)) .addPartner((Person) registry.getValue(aPartner))); } public JSONObject addPartnerToUnionOnlyJSON(int context, int aPartner) throws JSONException, Exception { return ((Union) registry.getValue(context)).addPartner( (Person) registry.getValue(aPartner)).getAttributes(); } public int addChildToUnion(int context, String aName, String aSex, String aPlaceOfBirth, String aDateOfBirth, String aPlaceOfDeath, String aDateOfDeath) throws Exception { return registry.getKey(((Union) registry.getValue(context)).addChild(aName, aSex, aPlaceOfBirth, aDateOfBirth, aPlaceOfDeath, aDateOfDeath)); } public JSONObject addChildToUnionJSON(int context, String aName, String aSex, String aPlaceOfBirth, String aDateOfBirth, String aPlaceOfDeath, String aDateOfDeath) throws JSONException, Exception { return ((Union) registry.getValue(context)).addChild(aName, aSex, aPlaceOfBirth, aDateOfBirth, aPlaceOfDeath, aDateOfDeath).getAttributes(); } public int addChildToUnionOnly(int context, int aChild) throws Exception { return registry.getKey(((Union) registry.getValue(context)) .addChild((Person) registry.getValue(aChild))); } public JSONObject addChildToUnionOnlyJSON(int context, int aChild) throws JSONException, Exception { return ((Union) registry.getValue(context)).addChild( (Person) registry.getValue(aChild)).getAttributes(); } public void deleteUnion(int context) { ((Union) registry.getValue(context)).delete(); registry.removeObj(context); } public void deletePartnerFromUnion(int context, int aPerson) { ((Union) registry.getValue(context)).deletePartner((Person) registry .getValue(aPerson)); } public void deleteChildFromUnion(int context, int aPerson) { ((Union) registry.getValue(context)).deleteChild((Person) registry .getValue(aPerson)); } public JSONObject getAttributesOfUnion(int context) throws JSONException { return ((Union) registry.getValue(context)).getAttributes(); } public int constructPerson(String aName, String aSex, String aPlaceOfBirth, String aDateOfBirth, String aPlaceOfDeath, String aDateOfDeath) throws Exception { return registry.add(new Person(aName, aSex, aPlaceOfBirth, aDateOfBirth, aPlaceOfDeath, aDateOfDeath)); } public JSONObject constructPersonJSON(String aName, String aSex, String aPlaceOfBirth, String aDateOfBirth, String aPlaceOfDeath, String aDateOfDeath) throws JSONException, Exception { Person contextObj = new Person(aName, aSex, aPlaceOfBirth, aDateOfBirth, aPlaceOfDeath, aDateOfDeath); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setNameInPerson(int context, String aName) { return ((Person) registry.getValue(context)).setName(aName); } public boolean setSexInPerson(int context, String aSex) { return ((Person) registry.getValue(context)).setSex(aSex); } public boolean setPlaceOfBirthInPerson(int context, String aPlaceOfBirth) { return ((Person) registry.getValue(context)).setPlaceOfBirth(aPlaceOfBirth); } public boolean setDateOfBirthInPerson(int context, String aDateOfBirth) { return ((Person) registry.getValue(context)).setDateOfBirth(aDateOfBirth); } public boolean setPlaceOfDeathInPerson(int context, String aPlaceOfDeath) { return ((Person) registry.getValue(context)).setPlaceOfDeath(aPlaceOfDeath); } public boolean setDateOfDeathInPerson(int context, String aDateOfDeath) { return ((Person) registry.getValue(context)).setDateOfDeath(aDateOfDeath); } public String getNameFromPerson(int context) { return ((Person) registry.getValue(context)).getName(); } public String getSexFromPerson(int context) { return ((Person) registry.getValue(context)).getSex(); } public String getPlaceOfBirthFromPerson(int context) { return ((Person) registry.getValue(context)).getPlaceOfBirth(); } public String getDateOfBirthFromPerson(int context) { return ((Person) registry.getValue(context)).getDateOfBirth(); } public String getPlaceOfDeathFromPerson(int context) { return ((Person) registry.getValue(context)).getPlaceOfDeath(); } public String getDateOfDeathFromPerson(int context) { return ((Person) registry.getValue(context)).getDateOfDeath(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getUnionsFromPerson(int context) { ArrayList listOfIDs = new ArrayList(); for (Union obj : ((Person) registry.getValue(context)).getUnions()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int getParentsFromPerson(int context) { return registry.getKey(((Person) registry.getValue(context)).getParents()); } public JSONObject getParentsFromPersonJSON(int context) throws JSONException { return ((Person) registry.getValue(context)).getParents().getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getAdoptiveParentssFromPerson(int context) { ArrayList listOfIDs = new ArrayList(); for (Person obj : ((Person) registry.getValue(context)) .getAdoptiveParentss()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getAdoptedChildsFromPerson(int context) { ArrayList listOfIDs = new ArrayList(); for (Person obj : ((Person) registry.getValue(context)).getAdoptedChilds()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addUnionToPerson(int context, String aPlaceOfMarriage, String aDateOfMarriage, String aDateOfDivorce) throws Exception { return registry.getKey(((Person) registry.getValue(context)).addUnion( aPlaceOfMarriage, aDateOfMarriage, aDateOfDivorce)); } public JSONObject addUnionToPersonJSON(int context, String aPlaceOfMarriage, String aDateOfMarriage, String aDateOfDivorce) throws JSONException, Exception { return ((Person) registry.getValue(context)).addUnion(aPlaceOfMarriage, aDateOfMarriage, aDateOfDivorce).getAttributes(); } public int addUnionToPersonOnly(int context, int aUnion) throws Exception { return registry.getKey(((Person) registry.getValue(context)) .addUnion((Union) registry.getValue(aUnion))); } public JSONObject addUnionToPersonOnlyJSON(int context, int aUnion) throws JSONException, Exception { return ((Person) registry.getValue(context)).addUnion( (Union) registry.getValue(aUnion)).getAttributes(); } public int addAdoptiveParentsToPerson(int context, String aName, String aSex, String aPlaceOfBirth, String aDateOfBirth, String aPlaceOfDeath, String aDateOfDeath) throws Exception { return registry.getKey(((Person) registry.getValue(context)) .addAdoptiveParents(aName, aSex, aPlaceOfBirth, aDateOfBirth, aPlaceOfDeath, aDateOfDeath)); } public JSONObject addAdoptiveParentsToPersonJSON(int context, String aName, String aSex, String aPlaceOfBirth, String aDateOfBirth, String aPlaceOfDeath, String aDateOfDeath) throws JSONException, Exception { return ((Person) registry.getValue(context)).addAdoptiveParents(aName, aSex, aPlaceOfBirth, aDateOfBirth, aPlaceOfDeath, aDateOfDeath) .getAttributes(); } public int addAdoptiveParentsToPersonOnly(int context, int aAdoptiveParents) throws Exception { return registry.getKey(((Person) registry.getValue(context)) .addAdoptiveParents((Person) registry.getValue(aAdoptiveParents))); } public JSONObject addAdoptiveParentsToPersonOnlyJSON(int context, int aAdoptiveParents) throws JSONException, Exception { return ((Person) registry.getValue(context)).addAdoptiveParents( (Person) registry.getValue(aAdoptiveParents)).getAttributes(); } public int addAdoptedChildToPerson(int context, String aName, String aSex, String aPlaceOfBirth, String aDateOfBirth, String aPlaceOfDeath, String aDateOfDeath) throws Exception { return registry.getKey(((Person) registry.getValue(context)) .addAdoptedChild(aName, aSex, aPlaceOfBirth, aDateOfBirth, aPlaceOfDeath, aDateOfDeath)); } public JSONObject addAdoptedChildToPersonJSON(int context, String aName, String aSex, String aPlaceOfBirth, String aDateOfBirth, String aPlaceOfDeath, String aDateOfDeath) throws JSONException, Exception { return ((Person) registry.getValue(context)).addAdoptedChild(aName, aSex, aPlaceOfBirth, aDateOfBirth, aPlaceOfDeath, aDateOfDeath).getAttributes(); } public int addAdoptedChildToPersonOnly(int context, int aAdoptedChild) throws Exception { return registry.getKey(((Person) registry.getValue(context)) .addAdoptedChild((Person) registry.getValue(aAdoptedChild))); } public JSONObject addAdoptedChildToPersonOnlyJSON(int context, int aAdoptedChild) throws JSONException, Exception { return ((Person) registry.getValue(context)).addAdoptedChild( (Person) registry.getValue(aAdoptedChild)).getAttributes(); } public void setParentsInPerson(int context, int aParents) throws Exception { ((Person) registry.getValue(context)).setParents((Union) registry .getValue(aParents)); } public void deletePerson(int context) { ((Person) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteUnionFromPerson(int context, int aUnion) { ((Person) registry.getValue(context)).deleteUnion((Union) registry .getValue(aUnion)); } public void deleteParentsFromPerson(int context, int aUnion) { ((Person) registry.getValue(context)).deleteParents((Union) registry .getValue(aUnion)); } public void deleteAdoptiveParentsFromPerson(int context, int aPerson) { ((Person) registry.getValue(context)) .deleteAdoptiveParents((Person) registry.getValue(aPerson)); } public void deleteAdoptedChildFromPerson(int context, int aPerson) { ((Person) registry.getValue(context)).deleteAdoptedChild((Person) registry .getValue(aPerson)); } public JSONObject getAttributesOfPerson(int context) throws JSONException { return ((Person) registry.getValue(context)).getAttributes(); } }