/*This code was generated using the UMPLE modeling language!*/ package ElectorialSystem; import java.sql.Time; import java.sql.Date; import java.util.ArrayList; import java.util.Iterator; import ElectorialSystem.json.*; import ElectorialSystem.core.*; public class ElectorialSystemFacade { // Singleton instance. private static ElectorialSystemFacade theInstance; //System registry. ElectorialSystemRegistry registry = ElectorialSystemRegistry.getInstance(); /** * Dummy constructor */ private ElectorialSystemFacade() { } /** * Returns the only instance of the Facade. * * @return */ public static ElectorialSystemFacade getInstance() { if (theInstance == null) theInstance = new ElectorialSystemFacade(); return theInstance; } public int constructVoter(String aName, String aAddress, int aPollInElection, int aElectoralDistrict) { return registry.add(new Voter(aName, aAddress, (PollInElection) registry .getValue(aPollInElection), (ElectoralDistrict) registry .getValue(aElectoralDistrict))); } public JSONObject constructVoterJSON(String aName, String aAddress, int aPollInElection, int aElectoralDistrict) throws JSONException { Voter contextObj = new Voter(aName, aAddress, (PollInElection) registry .getValue(aPollInElection), (ElectoralDistrict) registry .getValue(aElectoralDistrict)); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setNameInVoter(int context, String aName) { return ((Voter) registry.getValue(context)).setName(aName); } public boolean setAddressInVoter(int context, String aAddress) { return ((Voter) registry.getValue(context)).setAddress(aAddress); } public String getNameFromVoter(int context) { return ((Voter) registry.getValue(context)).getName(); } public String getAddressFromVoter(int context) { return ((Voter) registry.getValue(context)).getAddress(); } public int getPollInElectionFromVoter(int context) { return registry.getKey(((Voter) registry.getValue(context)) .getPollInElection()); } public JSONObject getPollInElectionFromVoterJSON(int context) throws JSONException { return ((Voter) registry.getValue(context)).getPollInElection() .getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getCandidaturesFromVoter(int context) { ArrayList listOfIDs = new ArrayList(); for (Candidature obj : ((Voter) registry.getValue(context)) .getCandidatures()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int getElectoralDistrictFromVoter(int context) { return registry.getKey(((Voter) registry.getValue(context)) .getElectoralDistrict()); } public JSONObject getElectoralDistrictFromVoterJSON(int context) throws JSONException { return ((Voter) registry.getValue(context)).getElectoralDistrict() .getAttributes(); } public int addCandidatureToVoter(int context, String aIsIncumbent, int aElectionForPosition, int aCandidate) throws Exception { return registry.getKey(((Voter) registry.getValue(context)).addCandidature( aIsIncumbent, (ElectionForPosition) registry .getValue(aElectionForPosition), (Candidate) registry .getValue(aCandidate))); } public JSONObject addCandidatureToVoterJSON(int context, String aIsIncumbent, int aElectionForPosition, int aCandidate) throws JSONException, Exception { return ((Voter) registry.getValue(context)).addCandidature(aIsIncumbent, (ElectionForPosition) registry.getValue(aElectionForPosition), (Candidate) registry.getValue(aCandidate)).getAttributes(); } public int addCandidatureToVoterOnly(int context, int aCandidature) throws Exception { return registry.getKey(((Voter) registry.getValue(context)) .addCandidature((Candidature) registry.getValue(aCandidature))); } public JSONObject addCandidatureToVoterOnlyJSON(int context, int aCandidature) throws JSONException, Exception { return ((Voter) registry.getValue(context)).addCandidature( (Candidature) registry.getValue(aCandidature)).getAttributes(); } public void setPollInElectionInVoter(int context, int aPollInElection) throws Exception { ((Voter) registry.getValue(context)) .setPollInElection((PollInElection) registry.getValue(aPollInElection)); } public void setElectoralDistrictInVoter(int context, int aElectoralDistrict) throws Exception { ((Voter) registry.getValue(context)) .setElectoralDistrict((ElectoralDistrict) registry .getValue(aElectoralDistrict)); } public void deleteVoter(int context) { ((Voter) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteCandidatureFromVoter(int context, int aCandidature) { ((Voter) registry.getValue(context)) .deleteCandidature((Candidature) registry.getValue(aCandidature)); } public JSONObject getAttributesOfVoter(int context) throws JSONException { return ((Voter) registry.getValue(context)).getAttributes(); } public int constructCandidate(String aName, int aPhoneNumber, String aAddress) { return registry.add(new Candidate(aName, aPhoneNumber, aAddress)); } public JSONObject constructCandidateJSON(String aName, int aPhoneNumber, String aAddress) throws JSONException { Candidate contextObj = new Candidate(aName, aPhoneNumber, aAddress); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setNameInCandidate(int context, String aName) { return ((Candidate) registry.getValue(context)).setName(aName); } public boolean setPhoneNumberInCandidate(int context, int aPhoneNumber) { return ((Candidate) registry.getValue(context)) .setPhoneNumber(aPhoneNumber); } public boolean setAddressInCandidate(int context, String aAddress) { return ((Candidate) registry.getValue(context)).setAddress(aAddress); } public String getNameFromCandidate(int context) { return ((Candidate) registry.getValue(context)).getName(); } public int getPhoneNumberFromCandidate(int context) { return ((Candidate) registry.getValue(context)).getPhoneNumber(); } public String getAddressFromCandidate(int context) { return ((Candidate) registry.getValue(context)).getAddress(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getCandidaturesFromCandidate(int context) { ArrayList listOfIDs = new ArrayList(); for (Candidature obj : ((Candidate) registry.getValue(context)) .getCandidatures()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addCandidatureToCandidate(int context, String aIsIncumbent, int aElectionForPosition, int aCandidate) throws Exception { return registry.getKey(((Candidate) registry.getValue(context)) .addCandidature(aIsIncumbent, (ElectionForPosition) registry .getValue(aElectionForPosition), (Candidate) registry .getValue(aCandidate))); } public JSONObject addCandidatureToCandidateJSON(int context, String aIsIncumbent, int aElectionForPosition, int aCandidate) throws JSONException, Exception { return ((Candidate) registry.getValue(context)).addCandidature( aIsIncumbent, (ElectionForPosition) registry.getValue(aElectionForPosition), (Candidate) registry.getValue(aCandidate)).getAttributes(); } public int addCandidatureToCandidateOnly(int context, int aCandidature) throws Exception { return registry.getKey(((Candidate) registry.getValue(context)) .addCandidature((Candidature) registry.getValue(aCandidature))); } public JSONObject addCandidatureToCandidateOnlyJSON(int context, int aCandidature) throws JSONException, Exception { return ((Candidate) registry.getValue(context)).addCandidature( (Candidature) registry.getValue(aCandidature)).getAttributes(); } public void deleteCandidate(int context) { ((Candidate) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteCandidatureFromCandidate(int context, int aCandidature) { ((Candidate) registry.getValue(context)) .deleteCandidature((Candidature) registry.getValue(aCandidature)); } public JSONObject getAttributesOfCandidate(int context) throws JSONException { return ((Candidate) registry.getValue(context)).getAttributes(); } public int constructElection(Date aDate) { return registry.add(new Election(aDate)); } public JSONObject constructElectionJSON(Date aDate) throws JSONException { Election contextObj = new Election(aDate); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setDateInElection(int context, Date aDate) { return ((Election) registry.getValue(context)).setDate(aDate); } public Date getDateFromElection(int context) { return ((Election) registry.getValue(context)).getDate(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getPollInElectionsFromElection(int context) { ArrayList listOfIDs = new ArrayList(); for (PollInElection obj : ((Election) registry.getValue(context)) .getPollInElections()) { 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 getElectionForPositionsFromElection(int context) { ArrayList listOfIDs = new ArrayList(); for (ElectionForPosition obj : ((Election) registry.getValue(context)) .getElectionForPositions()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addPollInElectionToElection(int context, int aNumber, int aElection) throws Exception { return registry.getKey(((Election) registry.getValue(context)) .addPollInElection(aNumber, (Election) registry.getValue(aElection))); } public JSONObject addPollInElectionToElectionJSON(int context, int aNumber, int aElection) throws JSONException, Exception { return ((Election) registry.getValue(context)).addPollInElection(aNumber, (Election) registry.getValue(aElection)).getAttributes(); } public int addPollInElectionToElectionOnly(int context, int aPollInElection) throws Exception { return registry.getKey(((Election) registry.getValue(context)) .addPollInElection((PollInElection) registry.getValue(aPollInElection))); } public JSONObject addPollInElectionToElectionOnlyJSON(int context, int aPollInElection) throws JSONException, Exception { return ((Election) registry.getValue(context)).addPollInElection( (PollInElection) registry.getValue(aPollInElection)).getAttributes(); } public int addElectionForPositionToElection(int context, int aPosition) throws Exception { return registry.getKey(((Election) registry.getValue(context)) .addElectionForPosition((Position) registry.getValue(aPosition))); } public JSONObject addElectionForPositionToElectionJSON(int context, int aPosition) throws JSONException, Exception { return ((Election) registry.getValue(context)).addElectionForPosition( (Position) registry.getValue(aPosition)).getAttributes(); } public int addElectionForPositionToElectionOnly(int context, int aElectionForPosition) throws Exception { return registry.getKey(((Election) registry.getValue(context)) .addElectionForPosition((ElectionForPosition) registry .getValue(aElectionForPosition))); } public JSONObject addElectionForPositionToElectionOnlyJSON(int context, int aElectionForPosition) throws JSONException, Exception { return ((Election) registry.getValue(context)).addElectionForPosition( (ElectionForPosition) registry.getValue(aElectionForPosition)) .getAttributes(); } public void deleteElection(int context) { ((Election) registry.getValue(context)).delete(); registry.removeObj(context); } public void deletePollInElectionFromElection(int context, int aPollInElection) { ((Election) registry.getValue(context)) .deletePollInElection((PollInElection) registry.getValue(aPollInElection)); } public void deleteElectionForPositionFromElection(int context, int aElectionForPosition) { ((Election) registry.getValue(context)) .deleteElectionForPosition((ElectionForPosition) registry .getValue(aElectionForPosition)); } public JSONObject getAttributesOfElection(int context) throws JSONException { return ((Election) registry.getValue(context)).getAttributes(); } public int constructElectionForPosition(int aElection, int aPosition) { return registry.add(new ElectionForPosition((Election) registry .getValue(aElection), (Position) registry.getValue(aPosition))); } public JSONObject constructElectionForPositionJSON(int aElection, int aPosition) throws JSONException { ElectionForPosition contextObj = new ElectionForPosition((Election) registry.getValue(aElection), (Position) registry.getValue(aPosition)); registry.add(contextObj); return contextObj.getAttributes(); } public int getElectionFromElectionForPosition(int context) { return registry.getKey(((ElectionForPosition) registry.getValue(context)) .getElection()); } public JSONObject getElectionFromElectionForPositionJSON(int context) throws JSONException { return ((ElectionForPosition) registry.getValue(context)).getElection() .getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getCandidaturesFromElectionForPosition(int context) { ArrayList listOfIDs = new ArrayList(); for (Candidature obj : ((ElectionForPosition) registry.getValue(context)) .getCandidatures()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int getPositionFromElectionForPosition(int context) { return registry.getKey(((ElectionForPosition) registry.getValue(context)) .getPosition()); } public JSONObject getPositionFromElectionForPositionJSON(int context) throws JSONException { return ((ElectionForPosition) registry.getValue(context)).getPosition() .getAttributes(); } public int addCandidatureToElectionForPosition(int context, String aIsIncumbent, int aElectionForPosition, int aCandidate) throws Exception { return registry.getKey(((ElectionForPosition) registry.getValue(context)) .addCandidature(aIsIncumbent, (ElectionForPosition) registry .getValue(aElectionForPosition), (Candidate) registry .getValue(aCandidate))); } public JSONObject addCandidatureToElectionForPositionJSON(int context, String aIsIncumbent, int aElectionForPosition, int aCandidate) throws JSONException, Exception { return ((ElectionForPosition) registry.getValue(context)).addCandidature( aIsIncumbent, (ElectionForPosition) registry.getValue(aElectionForPosition), (Candidate) registry.getValue(aCandidate)).getAttributes(); } public int addCandidatureToElectionForPositionOnly(int context, int aCandidature) throws Exception { return registry.getKey(((ElectionForPosition) registry.getValue(context)) .addCandidature((Candidature) registry.getValue(aCandidature))); } public JSONObject addCandidatureToElectionForPositionOnlyJSON(int context, int aCandidature) throws JSONException, Exception { return ((ElectionForPosition) registry.getValue(context)).addCandidature( (Candidature) registry.getValue(aCandidature)).getAttributes(); } public void setElectionInElectionForPosition(int context, int aElection) throws Exception { ((ElectionForPosition) registry.getValue(context)) .setElection((Election) registry.getValue(aElection)); } public void setPositionInElectionForPosition(int context, int aPosition) throws Exception { ((ElectionForPosition) registry.getValue(context)) .setPosition((Position) registry.getValue(aPosition)); } public void deleteElectionForPosition(int context) { ((ElectionForPosition) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteCandidatureFromElectionForPosition(int context, int aCandidature) { ((ElectionForPosition) registry.getValue(context)) .deleteCandidature((Candidature) registry.getValue(aCandidature)); } public JSONObject getAttributesOfElectionForPosition(int context) throws JSONException { return ((ElectionForPosition) registry.getValue(context)).getAttributes(); } public int constructElectedBody(String aDescription) { return registry.add(new ElectedBody(aDescription)); } public JSONObject constructElectedBodyJSON(String aDescription) throws JSONException { ElectedBody contextObj = new ElectedBody(aDescription); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setDescriptionInElectedBody(int context, String aDescription) { return ((ElectedBody) registry.getValue(context)) .setDescription(aDescription); } public String getDescriptionFromElectedBody(int context) { return ((ElectedBody) registry.getValue(context)).getDescription(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getPositionsFromElectedBody(int context) { ArrayList listOfIDs = new ArrayList(); for (Position obj : ((ElectedBody) registry.getValue(context)) .getPositions()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addPositionToElectedBody(int context, String aDescription, int aElectedBody) throws Exception { return registry .getKey(((ElectedBody) registry.getValue(context)).addPosition( aDescription, (ElectedBody) registry.getValue(aElectedBody))); } public JSONObject addPositionToElectedBodyJSON(int context, String aDescription, int aElectedBody) throws JSONException, Exception { return ((ElectedBody) registry.getValue(context)).addPosition(aDescription, (ElectedBody) registry.getValue(aElectedBody)).getAttributes(); } public int addPositionToElectedBodyOnly(int context, int aPosition) throws Exception { return registry.getKey(((ElectedBody) registry.getValue(context)) .addPosition((Position) registry.getValue(aPosition))); } public JSONObject addPositionToElectedBodyOnlyJSON(int context, int aPosition) throws JSONException, Exception { return ((ElectedBody) registry.getValue(context)).addPosition( (Position) registry.getValue(aPosition)).getAttributes(); } public void deleteElectedBody(int context) { ((ElectedBody) registry.getValue(context)).delete(); registry.removeObj(context); } public void deletePositionFromElectedBody(int context, int aPosition) { ((ElectedBody) registry.getValue(context)) .deletePosition((Position) registry.getValue(aPosition)); } public JSONObject getAttributesOfElectedBody(int context) throws JSONException { return ((ElectedBody) registry.getValue(context)).getAttributes(); } public int constructElectoralDistrict(int aElectoralDistrict) { return registry.add(new ElectoralDistrict((ElectoralDistrict) registry .getValue(aElectoralDistrict))); } public JSONObject constructElectoralDistrictJSON(int aElectoralDistrict) throws JSONException { ElectoralDistrict contextObj = new ElectoralDistrict((ElectoralDistrict) registry .getValue(aElectoralDistrict)); 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 getVotersFromElectoralDistrict(int context) { ArrayList listOfIDs = new ArrayList(); for (Voter obj : ((ElectoralDistrict) registry.getValue(context)) .getVoters()) { 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 getPositionsFromElectoralDistrict(int context) { ArrayList listOfIDs = new ArrayList(); for (Position obj : ((ElectoralDistrict) registry.getValue(context)) .getPositions()) { 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 getSubDistrictsFromElectoralDistrict(int context) { ArrayList listOfIDs = new ArrayList(); for (ElectoralDistrict obj : ((ElectoralDistrict) registry .getValue(context)).getSubDistricts()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int getElectoralDistrictFromElectoralDistrict(int context) { return registry.getKey(((ElectoralDistrict) registry.getValue(context)) .getElectoralDistrict()); } public JSONObject getElectoralDistrictFromElectoralDistrictJSON(int context) throws JSONException { return ((ElectoralDistrict) registry.getValue(context)) .getElectoralDistrict().getAttributes(); } public int addVoterToElectoralDistrict(int context, String aName, String aAddress, int aPollInElection, int aElectoralDistrict) throws Exception { return registry.getKey(((ElectoralDistrict) registry.getValue(context)) .addVoter(aName, aAddress, (PollInElection) registry .getValue(aPollInElection), (ElectoralDistrict) registry .getValue(aElectoralDistrict))); } public JSONObject addVoterToElectoralDistrictJSON(int context, String aName, String aAddress, int aPollInElection, int aElectoralDistrict) throws JSONException, Exception { return ((ElectoralDistrict) registry.getValue(context)).addVoter(aName, aAddress, (PollInElection) registry.getValue(aPollInElection), (ElectoralDistrict) registry.getValue(aElectoralDistrict)) .getAttributes(); } public int addVoterToElectoralDistrictOnly(int context, int aVoter) throws Exception { return registry.getKey(((ElectoralDistrict) registry.getValue(context)) .addVoter((Voter) registry.getValue(aVoter))); } public JSONObject addVoterToElectoralDistrictOnlyJSON(int context, int aVoter) throws JSONException, Exception { return ((ElectoralDistrict) registry.getValue(context)).addVoter( (Voter) registry.getValue(aVoter)).getAttributes(); } public int addPositionToElectoralDistrict(int context, String aDescription, int aElectedBody) throws Exception { return registry .getKey(((ElectoralDistrict) registry.getValue(context)).addPosition( aDescription, (ElectedBody) registry.getValue(aElectedBody))); } public JSONObject addPositionToElectoralDistrictJSON(int context, String aDescription, int aElectedBody) throws JSONException, Exception { return ((ElectoralDistrict) registry.getValue(context)).addPosition( aDescription, (ElectedBody) registry.getValue(aElectedBody)) .getAttributes(); } public int addPositionToElectoralDistrictOnly(int context, int aPosition) throws Exception { return registry.getKey(((ElectoralDistrict) registry.getValue(context)) .addPosition((Position) registry.getValue(aPosition))); } public JSONObject addPositionToElectoralDistrictOnlyJSON(int context, int aPosition) throws JSONException, Exception { return ((ElectoralDistrict) registry.getValue(context)).addPosition( (Position) registry.getValue(aPosition)).getAttributes(); } public int addSubDistrictToElectoralDistrict(int context) throws Exception { return registry.getKey(((ElectoralDistrict) registry.getValue(context)) .addSubDistrict()); } public JSONObject addSubDistrictToElectoralDistrictJSON(int context) throws JSONException, Exception { return ((ElectoralDistrict) registry.getValue(context)).addSubDistrict() .getAttributes(); } public int addSubDistrictToElectoralDistrictOnly(int context, int aSubDistrict) throws Exception { return registry.getKey(((ElectoralDistrict) registry.getValue(context)) .addSubDistrict((ElectoralDistrict) registry.getValue(aSubDistrict))); } public JSONObject addSubDistrictToElectoralDistrictOnlyJSON(int context, int aSubDistrict) throws JSONException, Exception { return ((ElectoralDistrict) registry.getValue(context)).addSubDistrict( (ElectoralDistrict) registry.getValue(aSubDistrict)).getAttributes(); } public void setElectoralDistrictInElectoralDistrict(int context, int aElectoralDistrict) throws Exception { ((ElectoralDistrict) registry.getValue(context)) .setElectoralDistrict((ElectoralDistrict) registry .getValue(aElectoralDistrict)); } public void deleteElectoralDistrict(int context) { ((ElectoralDistrict) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteVoterFromElectoralDistrict(int context, int aVoter) { ((ElectoralDistrict) registry.getValue(context)) .deleteVoter((Voter) registry.getValue(aVoter)); } public void deletePositionFromElectoralDistrict(int context, int aPosition) { ((ElectoralDistrict) registry.getValue(context)) .deletePosition((Position) registry.getValue(aPosition)); } public void deleteSubDistrictFromElectoralDistrict(int context, int aElectoralDistrict) { ((ElectoralDistrict) registry.getValue(context)) .deleteSubDistrict((ElectoralDistrict) registry .getValue(aElectoralDistrict)); } public JSONObject getAttributesOfElectoralDistrict(int context) throws JSONException { return ((ElectoralDistrict) registry.getValue(context)).getAttributes(); } public int constructCandidature(String aIsIncumbent, int aElectionForPosition, int aCandidate) { return registry.add(new Candidature(aIsIncumbent, (ElectionForPosition) registry.getValue(aElectionForPosition), (Candidate) registry.getValue(aCandidate))); } public JSONObject constructCandidatureJSON(String aIsIncumbent, int aElectionForPosition, int aCandidate) throws JSONException { Candidature contextObj = new Candidature(aIsIncumbent, (ElectionForPosition) registry .getValue(aElectionForPosition), (Candidate) registry .getValue(aCandidate)); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setIsIncumbentInCandidature(int context, String aIsIncumbent) { return ((Candidature) registry.getValue(context)) .setIsIncumbent(aIsIncumbent); } public String getIsIncumbentFromCandidature(int context) { return ((Candidature) registry.getValue(context)).getIsIncumbent(); } public int getElectionForPositionFromCandidature(int context) { return registry.getKey(((Candidature) registry.getValue(context)) .getElectionForPosition()); } public JSONObject getElectionForPositionFromCandidatureJSON(int context) throws JSONException { return ((Candidature) registry.getValue(context)).getElectionForPosition() .getAttributes(); } public int getCandidateFromCandidature(int context) { return registry.getKey(((Candidature) registry.getValue(context)) .getCandidate()); } public JSONObject getCandidateFromCandidatureJSON(int context) throws JSONException { return ((Candidature) registry.getValue(context)).getCandidate() .getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getVotersFromCandidature(int context) { ArrayList listOfIDs = new ArrayList(); for (Voter obj : ((Candidature) registry.getValue(context)).getVoters()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addVoterToCandidature(int context, String aName, String aAddress, int aPollInElection, int aElectoralDistrict) throws Exception { return registry.getKey(((Candidature) registry.getValue(context)).addVoter( aName, aAddress, (PollInElection) registry.getValue(aPollInElection), (ElectoralDistrict) registry.getValue(aElectoralDistrict))); } public JSONObject addVoterToCandidatureJSON(int context, String aName, String aAddress, int aPollInElection, int aElectoralDistrict) throws JSONException, Exception { return ((Candidature) registry.getValue(context)).addVoter(aName, aAddress, (PollInElection) registry.getValue(aPollInElection), (ElectoralDistrict) registry.getValue(aElectoralDistrict)) .getAttributes(); } public int addVoterToCandidatureOnly(int context, int aVoter) throws Exception { return registry.getKey(((Candidature) registry.getValue(context)) .addVoter((Voter) registry.getValue(aVoter))); } public JSONObject addVoterToCandidatureOnlyJSON(int context, int aVoter) throws JSONException, Exception { return ((Candidature) registry.getValue(context)).addVoter( (Voter) registry.getValue(aVoter)).getAttributes(); } public void setElectionForPositionInCandidature(int context, int aElectionForPosition) throws Exception { ((Candidature) registry.getValue(context)) .setElectionForPosition((ElectionForPosition) registry .getValue(aElectionForPosition)); } public void setCandidateInCandidature(int context, int aCandidate) throws Exception { ((Candidature) registry.getValue(context)) .setCandidate((Candidate) registry.getValue(aCandidate)); } public void deleteCandidature(int context) { ((Candidature) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteVoterFromCandidature(int context, int aVoter) { ((Candidature) registry.getValue(context)).deleteVoter((Voter) registry .getValue(aVoter)); } public JSONObject getAttributesOfCandidature(int context) throws JSONException { return ((Candidature) registry.getValue(context)).getAttributes(); } public int constructPosition(String aDescription, int aElectedBody) { return registry.add(new Position(aDescription, (ElectedBody) registry .getValue(aElectedBody))); } public JSONObject constructPositionJSON(String aDescription, int aElectedBody) throws JSONException { Position contextObj = new Position(aDescription, (ElectedBody) registry.getValue(aElectedBody)); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setDescriptionInPosition(int context, String aDescription) { return ((Position) registry.getValue(context)).setDescription(aDescription); } public String getDescriptionFromPosition(int context) { return ((Position) registry.getValue(context)).getDescription(); } public int getElectedBodyFromPosition(int context) { return registry.getKey(((Position) registry.getValue(context)) .getElectedBody()); } public JSONObject getElectedBodyFromPositionJSON(int context) throws JSONException { return ((Position) registry.getValue(context)).getElectedBody() .getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getElectionForPositionsFromPosition(int context) { ArrayList listOfIDs = new ArrayList(); for (ElectionForPosition obj : ((Position) registry.getValue(context)) .getElectionForPositions()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int getElectoralDistrictFromPosition(int context) { return registry.getKey(((Position) registry.getValue(context)) .getElectoralDistrict()); } public JSONObject getElectoralDistrictFromPositionJSON(int context) throws JSONException { return ((Position) registry.getValue(context)).getElectoralDistrict() .getAttributes(); } public int addElectionForPositionToPosition(int context, int aElection, int aPosition) throws Exception { return registry.getKey(((Position) registry.getValue(context)) .addElectionForPosition((Election) registry.getValue(aElection), (Position) registry.getValue(aPosition))); } public JSONObject addElectionForPositionToPositionJSON(int context, int aElection, int aPosition) throws JSONException, Exception { return ((Position) registry.getValue(context)).addElectionForPosition( (Election) registry.getValue(aElection), (Position) registry.getValue(aPosition)).getAttributes(); } public int addElectionForPositionToPositionOnly(int context, int aElectionForPosition) throws Exception { return registry.getKey(((Position) registry.getValue(context)) .addElectionForPosition((ElectionForPosition) registry .getValue(aElectionForPosition))); } public JSONObject addElectionForPositionToPositionOnlyJSON(int context, int aElectionForPosition) throws JSONException, Exception { return ((Position) registry.getValue(context)).addElectionForPosition( (ElectionForPosition) registry.getValue(aElectionForPosition)) .getAttributes(); } public void setElectedBodyInPosition(int context, int aElectedBody) throws Exception { ((Position) registry.getValue(context)) .setElectedBody((ElectedBody) registry.getValue(aElectedBody)); } public void setElectoralDistrictInPosition(int context, int aElectoralDistrict) throws Exception { ((Position) registry.getValue(context)) .setElectoralDistrict((ElectoralDistrict) registry .getValue(aElectoralDistrict)); } public void deletePosition(int context) { ((Position) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteElectionForPositionFromPosition(int context, int aElectionForPosition) { ((Position) registry.getValue(context)) .deleteElectionForPosition((ElectionForPosition) registry .getValue(aElectionForPosition)); } public void deleteElectoralDistrictFromPosition(int context, int aElectoralDistrict) { ((Position) registry.getValue(context)) .deleteElectoralDistrict((ElectoralDistrict) registry .getValue(aElectoralDistrict)); } public JSONObject getAttributesOfPosition(int context) throws JSONException { return ((Position) registry.getValue(context)).getAttributes(); } public int constructPollingStation(int aNumber, String aAddress) { return registry.add(new PollingStation(aNumber, aAddress)); } public JSONObject constructPollingStationJSON(int aNumber, String aAddress) throws JSONException { PollingStation contextObj = new PollingStation(aNumber, aAddress); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setNumberInPollingStation(int context, int aNumber) { return ((PollingStation) registry.getValue(context)).setNumber(aNumber); } public boolean setAddressInPollingStation(int context, String aAddress) { return ((PollingStation) registry.getValue(context)).setAddress(aAddress); } public int getNumberFromPollingStation(int context) { return ((PollingStation) registry.getValue(context)).getNumber(); } public String getAddressFromPollingStation(int context) { return ((PollingStation) registry.getValue(context)).getAddress(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getPollInElectionsFromPollingStation(int context) { ArrayList listOfIDs = new ArrayList(); for (PollInElection obj : ((PollingStation) registry.getValue(context)) .getPollInElections()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addPollInElectionToPollingStation(int context, int aNumber, int aElection) throws Exception { return registry.getKey(((PollingStation) registry.getValue(context)) .addPollInElection(aNumber, (Election) registry.getValue(aElection))); } public JSONObject addPollInElectionToPollingStationJSON(int context, int aNumber, int aElection) throws JSONException, Exception { return ((PollingStation) registry.getValue(context)).addPollInElection( aNumber, (Election) registry.getValue(aElection)).getAttributes(); } public int addPollInElectionToPollingStationOnly(int context, int aPollInElection) throws Exception { return registry.getKey(((PollingStation) registry.getValue(context)) .addPollInElection((PollInElection) registry.getValue(aPollInElection))); } public JSONObject addPollInElectionToPollingStationOnlyJSON(int context, int aPollInElection) throws JSONException, Exception { return ((PollingStation) registry.getValue(context)).addPollInElection( (PollInElection) registry.getValue(aPollInElection)).getAttributes(); } public void deletePollingStation(int context) { ((PollingStation) registry.getValue(context)).delete(); registry.removeObj(context); } public void deletePollInElectionFromPollingStation(int context, int aPollInElection) { ((PollingStation) registry.getValue(context)) .deletePollInElection((PollInElection) registry.getValue(aPollInElection)); } public JSONObject getAttributesOfPollingStation(int context) throws JSONException { return ((PollingStation) registry.getValue(context)).getAttributes(); } public int constructPollInElection(int aNumber, int aElection) { return registry.add(new PollInElection(aNumber, (Election) registry .getValue(aElection))); } public JSONObject constructPollInElectionJSON(int aNumber, int aElection) throws JSONException { PollInElection contextObj = new PollInElection(aNumber, (Election) registry.getValue(aElection)); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setNumberInPollInElection(int context, int aNumber) { return ((PollInElection) registry.getValue(context)).setNumber(aNumber); } public int getNumberFromPollInElection(int context) { return ((PollInElection) registry.getValue(context)).getNumber(); } public int getElectionFromPollInElection(int context) { return registry.getKey(((PollInElection) registry.getValue(context)) .getElection()); } public JSONObject getElectionFromPollInElectionJSON(int context) throws JSONException { return ((PollInElection) registry.getValue(context)).getElection() .getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getVotersFromPollInElection(int context) { ArrayList listOfIDs = new ArrayList(); for (Voter obj : ((PollInElection) registry.getValue(context)).getVoters()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addVoterToPollInElection(int context, String aName, String aAddress, int aPollInElection, int aElectoralDistrict) throws Exception { return registry.getKey(((PollInElection) registry.getValue(context)) .addVoter(aName, aAddress, (PollInElection) registry .getValue(aPollInElection), (ElectoralDistrict) registry .getValue(aElectoralDistrict))); } public JSONObject addVoterToPollInElectionJSON(int context, String aName, String aAddress, int aPollInElection, int aElectoralDistrict) throws JSONException, Exception { return ((PollInElection) registry.getValue(context)).addVoter(aName, aAddress, (PollInElection) registry.getValue(aPollInElection), (ElectoralDistrict) registry.getValue(aElectoralDistrict)) .getAttributes(); } public int addVoterToPollInElectionOnly(int context, int aVoter) throws Exception { return registry.getKey(((PollInElection) registry.getValue(context)) .addVoter((Voter) registry.getValue(aVoter))); } public JSONObject addVoterToPollInElectionOnlyJSON(int context, int aVoter) throws JSONException, Exception { return ((PollInElection) registry.getValue(context)).addVoter( (Voter) registry.getValue(aVoter)).getAttributes(); } public void setElectionInPollInElection(int context, int aElection) throws Exception { ((PollInElection) registry.getValue(context)) .setElection((Election) registry.getValue(aElection)); } public void deletePollInElection(int context) { ((PollInElection) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteVoterFromPollInElection(int context, int aVoter) { ((PollInElection) registry.getValue(context)).deleteVoter((Voter) registry .getValue(aVoter)); } public JSONObject getAttributesOfPollInElection(int context) throws JSONException { return ((PollInElection) registry.getValue(context)).getAttributes(); } }