Skip to content

Commit

Permalink
Merge branch 'release-3.0.0' of https://github.com/LACNIC/elections-o…
Browse files Browse the repository at this point in the history
…pen-source into release-3.0.0

# Conflicts:
#	elections-ejb/src/main/java/net/lacnic/elections/ejb/impl/ElectionsManagerEJBBean.java
  • Loading branch information
RodrigoZambrana committed Dec 26, 2024
2 parents 222da98 + 91fc83d commit 1f1bfc0
Show file tree
Hide file tree
Showing 16 changed files with 122 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,21 @@ public SendEmailStep3Dashboard(final ElectionEmailTemplate template, PageParamet
setOutputMarkupPlaceholderTag(true);
add(new FeedbackPanel("feedback"));

List recipientsList;
List<?> recipientsList;
try {
recipientsList = AppContext.getInstance().getManagerBeanRemote().getRecipientsByRecipientType(template);

quantity = 0;
if (recipientsList != null && !recipientsList.isEmpty()) {
quantity = recipientsList.size();
if (recipientsList.get(0) instanceof UserVoter) {
votersList = recipientsList;
for (Object recipient : recipientsList) {
votersList.add((UserVoter) recipient);
}
} else if (recipientsList.get(0) instanceof Auditor) {
auditorsList = recipientsList;
for (Object recipient : recipientsList) {
auditorsList.add((Auditor) recipient);
}
}
}
String stringQuantity = "quantity";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public String getVoterInformation() {
public String getCompleteVoterInformation() {
String email = (getMail() != null && !getMail().isEmpty()) ? " (" + getMail() + ") " : "";
String orgid = (getOrgID() != null && !getOrgID().isEmpty()) ? " - " + getOrgID() : "";
String country = (getCountry() != null && !getCountry().isEmpty()) ? " - " + getCountry() : "";
return getName().concat(email + orgid + country);
String countryaux = (getCountry() != null && !getCountry().isEmpty()) ? " - " + getCountry() : "";
return getName().concat(email + orgid + countryaux);
}

public String getVoteLink() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import net.lacnic.elections.domain.ElectionEmailTemplate;

public class ElectionEmailTemplateTableReport implements Serializable {

private static final long serialVersionUID = -8753611728318452902L;

private long electionEmailTemplateId;
private String templateType;
private String subjectSP;
Expand All @@ -18,11 +18,12 @@ public class ElectionEmailTemplateTableReport implements Serializable {
private String bodyPT;
private String recipientType;
private Long electionId;

public ElectionEmailTemplateTableReport() { }


public ElectionEmailTemplateTableReport() {
}

public ElectionEmailTemplateTableReport(ElectionEmailTemplate electionEmailTemplate) {
this.electionEmailTemplateId = electionEmailTemplate.getElectionEmailTemplateId();
this.electionEmailTemplateId = electionEmailTemplate.getElectionEmailTemplateId();
this.templateType = electionEmailTemplate.getTemplateType();
this.subjectSP = electionEmailTemplate.getSubjectSP();
this.subjectPT = electionEmailTemplate.getSubjectPT();
Expand All @@ -34,75 +35,92 @@ public ElectionEmailTemplateTableReport(ElectionEmailTemplate electionEmailTempl
this.recipientType = electionEmailTemplate.getRecipientType().getDescription();
} else {
this.recipientType = "";
};
}
if (electionEmailTemplate.getElection() != null) {
this.electionId = electionEmailTemplate.getElection().getElectionId();
} else {
this.electionId = 0L;
};
}
}

public long getElectionEmailTemplateId() {
return electionEmailTemplateId;
}

public void setElectionEmailTemplateId(long electionEmailTemplateId) {
this.electionEmailTemplateId = electionEmailTemplateId;
}

public String getTemplateType() {
return templateType;
}

public void setTemplateType(String templateType) {
this.templateType = templateType;
}

public String getSubjectSP() {
return subjectSP;
}

public void setSubjectSP(String subjectSP) {
this.subjectSP = subjectSP;
}

public String getSubjectPT() {
return subjectPT;
}

public void setSubjectPT(String subjectPT) {
this.subjectPT = subjectPT;
}

public String getSubjectEN() {
return subjectEN;
}

public void setSubjectEN(String subjectEN) {
this.subjectEN = subjectEN;
}

public String getBodySP() {
return bodySP;
}

public void setBodySP(String bodySP) {
this.bodySP = bodySP;
}

public String getBodyEN() {
return bodyEN;
}

public void setBodyEN(String bodyEN) {
this.bodyEN = bodyEN;
}

public String getBodyPT() {
return bodyPT;
}

public void setBodyPT(String bodyPT) {
this.bodyPT = bodyPT;
}

public String getRecipientType() {
return recipientType;
}

public void setRecipientType(String recipientType) {
this.recipientType = recipientType;
}

public Long getElectionId() {
return electionId;
}

public void setElectionId(Long electionId) {
this.electionId = electionId;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public interface ElectionsManagerEJB {

public void removeUserAdmin(String userAdminToDeleteId, String userAdminId, String ip);

public void updateElectionCensus(String contentType, long electionId, byte[] content, String userAdminId, String ip) throws CensusValidationException, Exception;
public void updateElectionCensus(String contentType, long electionId, byte[] content, String userAdminId, String ip) throws CensusValidationException;

public List<Election> getElectionsLightThisYear();

Expand Down Expand Up @@ -124,7 +124,7 @@ public interface ElectionsManagerEJB {

public Integer createMissingEmailTemplates();

public void queueMassiveSending(List users, ElectionEmailTemplate electionEmailTemplate);
public void queueMassiveSending(List<?> users, ElectionEmailTemplate electionEmailTemplate);

public void fixCandidateToTop(long candidateId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import java.util.List;

import net.lacnic.elections.data.ElectionsResultsData;
import net.lacnic.elections.domain.*;
import net.lacnic.elections.domain.Auditor;
import net.lacnic.elections.domain.Candidate;
import net.lacnic.elections.domain.Election;
import net.lacnic.elections.domain.JointElection;
import net.lacnic.elections.domain.UserVoter;
import net.lacnic.elections.domain.Vote;
import net.lacnic.elections.exception.OperationNotPermittedException;

import javax.persistence.OptimisticLockException;

public interface ElectionsVoterEJB {

public List<Object[]> getElectionVotesCandidateAndCode(long electionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
import net.lacnic.elections.domain.UserVoter;
import net.lacnic.elections.domain.Vote;


@Remote
public interface MailsSendingEJB {

void queueMassiveSending(List users, ElectionEmailTemplate templateEleccion);
void queueMassiveSending(List<?> users, ElectionEmailTemplate emailTemplate);

List<Email> getEmailsToSend();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,24 @@ public class MailsSendingEJBBean implements MailsSendingEJB {
*
*/
@Override
public void queueMassiveSending(List users, ElectionEmailTemplate emailTemplate) {
public void queueMassiveSending(List<?> users, ElectionEmailTemplate emailTemplate) {
try {
Election election = emailTemplate.getElection();
List<UserVoter> userVoters = new ArrayList<>();
List<Auditor> userAuditors = new ArrayList<>();

if (users != null && !users.isEmpty()) {
if (users.get(0) instanceof UserVoter) {
userVoters = users;
for (Object user : users) {
userVoters.add((UserVoter) user);
}
} else if (users.get(0) instanceof Auditor) {
userAuditors = users;
for (Object user : users) {
userAuditors.add((Auditor) user);
}
}
}

for (int i = 0; i < userVoters.size(); i++) {
UserVoter userVoter = userVoters.get(i);
Email email = new Email();
Expand All @@ -85,7 +90,6 @@ public void queueMassiveSending(List users, ElectionEmailTemplate emailTemplate)
} else {
templateSubject = emailTemplate.getSubjectPT();
}
;

if (userVoter.getLanguage().equals("SP")) {
templateBody = emailTemplate.getBodySP();
Expand All @@ -94,14 +98,14 @@ public void queueMassiveSending(List users, ElectionEmailTemplate emailTemplate)
} else {
templateBody = emailTemplate.getBodyPT();
}
;

if (templateSubject.contains(CODE_SUMMARY) || templateBody.contains(CODE_SUMMARY))
userVoter.setCodesSummary(addVotes(ElectionsDaoFactory.createVoteDao(em).getElectionUserVoterVotes(userVoter.getUserVoterId(), election.getElectionId())));

Map<String, Object> map = new HashMap<>();
map.put("user", userVoter);
map.put(ELECTION, election);

String processSubject = processTemplate(templateSubject, map);
String processBody = processTemplate(templateBody, map);
email.setSubject(processSubject);
Expand All @@ -118,9 +122,11 @@ public void queueMassiveSending(List users, ElectionEmailTemplate emailTemplate)
Email email = new Email();
String templateSubject = emailTemplate.getSubjectSP();
String templateBody = emailTemplate.getBodySP();

Map<String, Object> map = new HashMap<>();
map.put("auditor", auditor);
map.put(ELECTION, election);

String processSubject = processTemplate(templateSubject, map);
String processBody = processTemplate(templateBody, map);
email.setSubject(processSubject);
Expand Down Expand Up @@ -158,9 +164,11 @@ public void queueSingleSending(ElectionEmailTemplate emailTemplate, UserVoter us
Email email = new Email();
String templateSubject = emailTemplate.getSubjectSP();
String templateBody = emailTemplate.getBodySP();

Map<String, Object> map = new HashMap<>();
map.put("auditor", auditor);
map.put(ELECTION, election);

String processSubject = processTemplate(templateSubject, map);
String processBody = processTemplate(templateBody, map);
email.setSubject(processSubject);
Expand All @@ -178,21 +186,14 @@ public void queueSingleSending(ElectionEmailTemplate emailTemplate, UserVoter us

if (userVoter.getLanguage().equals("SP")) {
templateSubject = emailTemplate.getSubjectSP();
} else if (userVoter.getLanguage().equals("EN")) {
templateSubject = emailTemplate.getSubjectEN();
} else {
templateSubject = emailTemplate.getSubjectPT();
}
;

if (userVoter.getLanguage().equals("SP")) {
templateBody = emailTemplate.getBodySP();
} else if (userVoter.getLanguage().equals("EN")) {
templateSubject = emailTemplate.getSubjectEN();
templateBody = emailTemplate.getBodyEN();
} else {
templateSubject = emailTemplate.getSubjectPT();
templateBody = emailTemplate.getBodyPT();
}
;

Map<String, Object> map = new HashMap<>();
map.put("user", userVoter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ public void removeUserAdmin(String userAdminToDeleteId, String userAdminId, Stri
* purposes
*/
@Override
public void updateElectionCensus(String contentType, long electionId, byte[] content, String userAdminId, String ip) throws CensusValidationException, Exception {
public void updateElectionCensus(String contentType, long electionId, byte[] content, String userAdminId, String ip) throws CensusValidationException {
try {
List<UserVoter> userVoters = ExcelUtils.processCensusExcel(contentType, content);
Election election = em.find(Election.class, electionId);
Expand Down Expand Up @@ -1103,11 +1103,9 @@ public List getRecipientsByRecipientType(ElectionEmailTemplate electionEmailTemp
} else if (recipientType.equals(RecipientType.VOTERS_NOT_VOTED_YET_TWO_ELECTIONS)) {
result = ElectionsDaoFactory.createUserVoterDao(em).getJointElectionUserVotersNotVotedYet(electionEmailTemplate.getElection().getElectionId());
unifiedList = new ArrayList<>();
exists = false;
if (!result.isEmpty())
unifiedList.add(result.get(0));
for (UserVoter userVoter : result) {
exists = false;
for (UserVoter unifiedUserVoter : unifiedList) {
if (unifiedUserVoter.getMail().equalsIgnoreCase(userVoter.getMail())) {
exists = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,7 @@ public List<TablesReportDataLongId> getIpAccessesBasicData(int pageSize, int off
@Override
public IpAccess getIpAccessTableReport(Long ipAccessId) {
try {
IpAccess ipAccess = ElectionsDaoFactory.createIpAccessDao(em).getIpAccess(ipAccessId);
return ipAccess;
return ElectionsDaoFactory.createIpAccessDao(em).getIpAccess(ipAccessId);
} catch (Exception e) {
appLogger.error(e);
}
Expand Down Expand Up @@ -703,8 +702,7 @@ public List<TablesReportDataLongId> getJointElectionsBasicData(int pageSize, int
@Override
public JointElection getJointElectionTableReport(Long jointElectionId) {
try {
JointElection jointelection = ElectionsDaoFactory.createJointElectionDao(em).getJointElection(jointElectionId);
return jointelection;
return ElectionsDaoFactory.createJointElectionDao(em).getJointElection(jointElectionId);
} catch (Exception e) {
appLogger.error(e);
}
Expand Down Expand Up @@ -896,7 +894,7 @@ public VoteTableReport getVoteTableReport(Long voteId) {
public List<ElectionDetailReport> getElectionsDetailReport(int pageSize, int offset) {
try {
List<Election> elections = ElectionsDaoFactory.createElectionDao(em).getElections(pageSize, offset);
List<ElectionDetailReport> electionsDetailList = new ArrayList<ElectionDetailReport>();
List<ElectionDetailReport> electionsDetailList = new ArrayList<>();
for (Election election : elections) {
electionsDetailList.add(new ElectionDetailReport(election));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import java.util.HashMap;

/**
* This class is used to store system constants like template paths, services
* URLs, etc.
* This class is used to store system constants like template paths, services URLs, etc.
*
* @author LACNIC
*
Expand Down Expand Up @@ -82,7 +81,7 @@ public static void clean() {
}

public static void cleanParametersCache() {
setParameters(new HashMap<String, String>());
setParameters(new HashMap<>());
}

public static HashMap<String, String> getParameters() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class EJBFactory {

private static final Logger appLogger = LogManager.getLogger("ejbAppLogger");

private static String JBOSSTEMPURI = System.getProperty("jboss.server.temp.dir");
private static String jbossTempURI = System.getProperty("jboss.server.temp.dir");

private ElectionsManagerEJB electionsManagerEJB;
private ElectionsMonitorEJB electionsMonitorEJB;
Expand Down Expand Up @@ -69,7 +69,7 @@ public static EJBFactory getInstance() {
}

public static String getJbossTempUri() {
return JBOSSTEMPURI.concat("/");
return jbossTempURI.concat("/");
}

public ElectionsManagerEJB getElectionsManagerEJB() {
Expand Down
Loading

0 comments on commit 1f1bfc0

Please sign in to comment.