/*This code was generated using the UMPLE modeling language!*/ package PoliticalEntities; import java.sql.Time; import java.sql.Date; import java.util.ArrayList; import java.util.Iterator; import PoliticalEntities.json.*; import PoliticalEntities.core.*; public class PoliticalEntitiesFacade { // Singleton instance. private static PoliticalEntitiesFacade theInstance; //System registry. PoliticalEntitiesRegistry registry = PoliticalEntitiesRegistry.getInstance(); /** * Dummy constructor */ private PoliticalEntitiesFacade() { } /** * Returns the only instance of the Facade. * * @return */ public static PoliticalEntitiesFacade getInstance() { if (theInstance == null) theInstance = new PoliticalEntitiesFacade(); return theInstance; } public int constructInterGovernmentalOrganization(String aName) { return registry.add(new InterGovernmentalOrganization(aName)); } public JSONObject constructInterGovernmentalOrganizationJSON(String aName) throws JSONException { InterGovernmentalOrganization contextObj = new InterGovernmentalOrganization(aName); registry.add(contextObj); return contextObj.getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getTerritorysFromInterGovernmentalOrganization(int context) { ArrayList listOfIDs = new ArrayList(); for (Territory obj : ((InterGovernmentalOrganization) registry .getValue(context)).getTerritorys()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addTerritoryToInterGovernmentalOrganization(int context, String aName) throws Exception { return registry.getKey(((InterGovernmentalOrganization) registry .getValue(context)).addTerritory(aName)); } public JSONObject addTerritoryToInterGovernmentalOrganizationJSON( int context, String aName) throws JSONException, Exception { return ((InterGovernmentalOrganization) registry.getValue(context)) .addTerritory(aName).getAttributes(); } public int addTerritoryToInterGovernmentalOrganizationOnly(int context, int aTerritory) throws Exception { return registry.getKey(((InterGovernmentalOrganization) registry .getValue(context)).addTerritory((Territory) registry .getValue(aTerritory))); } public JSONObject addTerritoryToInterGovernmentalOrganizationOnlyJSON( int context, int aTerritory) throws JSONException, Exception { return ((InterGovernmentalOrganization) registry.getValue(context)) .addTerritory((Territory) registry.getValue(aTerritory)).getAttributes(); } public void deleteInterGovernmentalOrganization(int context) { ((InterGovernmentalOrganization) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteTerritoryFromInterGovernmentalOrganization(int context, int aTerritory) { ((InterGovernmentalOrganization) registry.getValue(context)) .deleteTerritory((Territory) registry.getValue(aTerritory)); } public JSONObject getAttributesOfInterGovernmentalOrganization(int context) throws JSONException { return ((InterGovernmentalOrganization) registry.getValue(context)) .getAttributes(); } public int constructTerritory(String aName) { return registry.add(new Territory(aName)); } public JSONObject constructTerritoryJSON(String aName) throws JSONException { Territory contextObj = new Territory(aName); registry.add(contextObj); return contextObj.getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getBorderssFromTerritory(int context) { ArrayList listOfIDs = new ArrayList(); for (Territory obj : ((Territory) registry.getValue(context)).getBorderss()) { 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 getTerritorysFromTerritory(int context) { ArrayList listOfIDs = new ArrayList(); for (Territory obj : ((Territory) registry.getValue(context)) .getTerritorys()) { 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 getInterGovernmentalOrganizationsFromTerritory(int context) { ArrayList listOfIDs = new ArrayList(); for (InterGovernmentalOrganization obj : ((Territory) registry .getValue(context)).getInterGovernmentalOrganizations()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addBordersToTerritory(int context, String aName) throws Exception { return registry.getKey(((Territory) registry.getValue(context)) .addBorders(aName)); } public JSONObject addBordersToTerritoryJSON(int context, String aName) throws JSONException, Exception { return ((Territory) registry.getValue(context)).addBorders(aName) .getAttributes(); } public int addBordersToTerritoryOnly(int context, int aBorders) throws Exception { return registry.getKey(((Territory) registry.getValue(context)) .addBorders((Territory) registry.getValue(aBorders))); } public JSONObject addBordersToTerritoryOnlyJSON(int context, int aBorders) throws JSONException, Exception { return ((Territory) registry.getValue(context)).addBorders( (Territory) registry.getValue(aBorders)).getAttributes(); } public int addTerritoryToTerritory(int context, String aName) throws Exception { return registry.getKey(((Territory) registry.getValue(context)) .addTerritory(aName)); } public JSONObject addTerritoryToTerritoryJSON(int context, String aName) throws JSONException, Exception { return ((Territory) registry.getValue(context)).addTerritory(aName) .getAttributes(); } public int addTerritoryToTerritoryOnly(int context, int aTerritory) throws Exception { return registry.getKey(((Territory) registry.getValue(context)) .addTerritory((Territory) registry.getValue(aTerritory))); } public JSONObject addTerritoryToTerritoryOnlyJSON(int context, int aTerritory) throws JSONException, Exception { return ((Territory) registry.getValue(context)).addTerritory( (Territory) registry.getValue(aTerritory)).getAttributes(); } public int addInterGovernmentalOrganizationToTerritory(int context, String aName) throws Exception { return registry.getKey(((Territory) registry.getValue(context)) .addInterGovernmentalOrganization(aName)); } public JSONObject addInterGovernmentalOrganizationToTerritoryJSON( int context, String aName) throws JSONException, Exception { return ((Territory) registry.getValue(context)) .addInterGovernmentalOrganization(aName).getAttributes(); } public int addInterGovernmentalOrganizationToTerritoryOnly(int context, int aInterGovernmentalOrganization) throws Exception { return registry .getKey(((Territory) registry.getValue(context)) .addInterGovernmentalOrganization((InterGovernmentalOrganization) registry .getValue(aInterGovernmentalOrganization))); } public JSONObject addInterGovernmentalOrganizationToTerritoryOnlyJSON( int context, int aInterGovernmentalOrganization) throws JSONException, Exception { return ((Territory) registry.getValue(context)) .addInterGovernmentalOrganization( (InterGovernmentalOrganization) registry .getValue(aInterGovernmentalOrganization)).getAttributes(); } public void deleteTerritory(int context) { ((Territory) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteBordersFromTerritory(int context, int aTerritory) { ((Territory) registry.getValue(context)).deleteBorders((Territory) registry .getValue(aTerritory)); } public void deleteTerritoryFromTerritory(int context, int aTerritory) { ((Territory) registry.getValue(context)) .deleteTerritory((Territory) registry.getValue(aTerritory)); } public void deleteInterGovernmentalOrganizationFromTerritory(int context, int aInterGovernmentalOrganization) { ((Territory) registry.getValue(context)) .deleteInterGovernmentalOrganization((InterGovernmentalOrganization) registry .getValue(aInterGovernmentalOrganization)); } public JSONObject getAttributesOfTerritory(int context) throws JSONException { return ((Territory) registry.getValue(context)).getAttributes(); } public int constructCountry(String aName) { return registry.add(new Country(aName)); } public JSONObject constructCountryJSON(String aName) throws JSONException { Country contextObj = new Country(aName); registry.add(contextObj); return contextObj.getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getStateOrProvincesFromCountry(int context) { ArrayList listOfIDs = new ArrayList(); for (StateOrProvince obj : ((Country) registry.getValue(context)) .getStateOrProvinces()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addStateOrProvinceToCountry(int context, String aName) throws Exception { return registry.getKey(((Country) registry.getValue(context)) .addStateOrProvince(aName)); } public JSONObject addStateOrProvinceToCountryJSON(int context, String aName) throws JSONException, Exception { return ((Country) registry.getValue(context)).addStateOrProvince(aName) .getAttributes(); } public int addStateOrProvinceToCountryOnly(int context, int aStateOrProvince) throws Exception { return registry .getKey(((Country) registry.getValue(context)) .addStateOrProvince((StateOrProvince) registry .getValue(aStateOrProvince))); } public JSONObject addStateOrProvinceToCountryOnlyJSON(int context, int aStateOrProvince) throws JSONException, Exception { return ((Country) registry.getValue(context)).addStateOrProvince( (StateOrProvince) registry.getValue(aStateOrProvince)).getAttributes(); } public void deleteCountry(int context) { ((Country) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteStateOrProvinceFromCountry(int context, int aStateOrProvince) { ((Country) registry.getValue(context)) .deleteStateOrProvince((StateOrProvince) registry .getValue(aStateOrProvince)); } public JSONObject getAttributesOfCountry(int context) throws JSONException { return ((Country) registry.getValue(context)).getAttributes(); } public int constructStateOrProvince(String aName, int aCountry) { return registry.add(new StateOrProvince(aName, (Country) registry .getValue(aCountry))); } public JSONObject constructStateOrProvinceJSON(String aName, int aCountry) throws JSONException { StateOrProvince contextObj = new StateOrProvince(aName, (Country) registry.getValue(aCountry)); registry.add(contextObj); return contextObj.getAttributes(); } public int getCountryFromStateOrProvince(int context) { return registry.getKey(((StateOrProvince) registry.getValue(context)) .getCountry()); } public JSONObject getCountryFromStateOrProvinceJSON(int context) throws JSONException { return ((StateOrProvince) registry.getValue(context)).getCountry() .getAttributes(); } public void setCountryInStateOrProvince(int context, int aCountry) throws Exception { ((StateOrProvince) registry.getValue(context)) .setCountry((Country) registry.getValue(aCountry)); } public void deleteStateOrProvince(int context) { ((StateOrProvince) registry.getValue(context)).delete(); registry.removeObj(context); } public JSONObject getAttributesOfStateOrProvince(int context) throws JSONException { return ((StateOrProvince) registry.getValue(context)).getAttributes(); } public int constructPoliticalEntity(String aName) { return registry.add(new PoliticalEntity(aName)); } public JSONObject constructPoliticalEntityJSON(String aName) throws JSONException { PoliticalEntity contextObj = new PoliticalEntity(aName); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setNameInPoliticalEntity(int context, String aName) { return ((PoliticalEntity) registry.getValue(context)).setName(aName); } public String getNameFromPoliticalEntity(int context) { return ((PoliticalEntity) registry.getValue(context)).getName(); } public void deletePoliticalEntity(int context) { ((PoliticalEntity) registry.getValue(context)).delete(); registry.removeObj(context); } public JSONObject getAttributesOfPoliticalEntity(int context) throws JSONException { return ((PoliticalEntity) registry.getValue(context)).getAttributes(); } }