- Author
- Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g
Definition at line 40 of file PollsUtil.java.
◆ PollsUtil() [1/2]
org.turro.polls.PollsUtil.PollsUtil |
( |
IContact |
contact | ) |
|
◆ PollsUtil() [2/2]
org.turro.polls.PollsUtil.PollsUtil |
( |
String |
idContact | ) |
|
Definition at line 48 of file PollsUtil.java.
49 this.contact = Contacts.getContactById(idContact);
◆ getContact()
IContact org.turro.polls.PollsUtil.getContact |
( |
| ) |
|
◆ getMyPolls()
static Set<Poll> org.turro.polls.PollsUtil.getMyPolls |
( |
IContact |
contact | ) |
|
|
static |
Definition at line 211 of file PollsUtil.java.
212 return getPolls(contact,
false,
true, 0);
static List< Poll > getPolls(String entityPath)
◆ getPollOption()
PollOption org.turro.polls.PollsUtil.getPollOption |
( |
Long |
pollId, |
|
|
String |
pollData |
|
) |
| |
Definition at line 117 of file PollsUtil.java.
118 PollOptionPK pk =
new PollOptionPK();
119 pk.setIdPoll(pollId);
120 pk.setPollData(pollData);
121 return getDao().find(PollOption.class, pk);
◆ getPollOptionCount()
long org.turro.polls.PollsUtil.getPollOptionCount |
( |
PollOption |
pollOption, |
|
|
int |
vote |
|
) |
| |
Definition at line 136 of file PollsUtil.java.
137 WhereClause wc =
new WhereClause();
138 wc.addClause(
"select count(vote) from PollVote vote");
139 wc.addClause(
"where vote.idPoll = :idPoll");
140 wc.addNamedValue(
"idPoll", pollOption.getIdPoll());
141 wc.addClause(
"and vote.pollData = :pollData");
142 wc.addNamedValue(
"pollData", pollOption.getPollData());
143 wc.addClause(
"and vote.vote = :vote");
144 wc.addNamedValue(
"vote",
vote);
Object getSingleResultOrNull(SqlClause sc)
boolean vote(Long pollId, String pollData, Integer vote)
◆ getPolls() [1/2]
static Set<Poll> org.turro.polls.PollsUtil.getPolls |
( |
IContact |
contact, |
|
|
boolean |
active, |
|
|
boolean |
restricted, |
|
|
int |
maxResults |
|
) |
| |
|
static |
Definition at line 215 of file PollsUtil.java.
216 Dao dao =
new ElephantPU();
217 TreeSet<Poll> polls =
new TreeSet<>();
219 WhereClause wc =
new WhereClause();
220 wc.addClause(
"select distinct poll from Poll poll");
222 wc.addClause(
"join PollVote vote on vote.idPoll = poll.id");
223 wc.addClause(
"where vote.idContact = :contact");
224 wc.addNamedValue(
"contact", contact.
getId());
226 wc.addClause(
"order by poll.deadline desc");
227 polls.addAll(dao.getResultList(wc, maxResults));
229 WhereClause wc =
new WhereClause();
230 wc.addClause(
"select poll from Poll poll");
231 wc.addClause(
"where poll.deadline >= current_date");
233 for(Poll poll : (List<Poll>) dao.getResultList(wc)) {
234 if(poll.isParticipant(contact)) {
◆ getPolls() [2/2]
static List<Poll> org.turro.polls.PollsUtil.getPolls |
( |
String |
entityPath | ) |
|
|
static |
Definition at line 148 of file PollsUtil.java.
149 Dao dao =
new ElephantPU();
150 WhereClause wc =
new WhereClause();
151 wc.addClause(
"select poll from Poll as poll");
152 wc.addClause(
"where poll.entityPath = :path");
153 wc.addNamedValue(
"path", entityPath);
154 return dao.getResultList(wc);
◆ getPollVote() [1/2]
Definition at line 124 of file PollsUtil.java.
PollVote getPollVote(PollOption pollOption)
◆ getPollVote() [2/2]
Definition at line 128 of file PollsUtil.java.
129 PollVotePK pk =
new PollVotePK();
130 pk.setIdPoll(pollOption.getIdPoll());
131 pk.setPollData(pollOption.getPollData());
132 pk.setIdContact(contact.
getId());
133 return getDao().find(PollVote.class, pk,
null);
◆ isAllowedToVote()
boolean org.turro.polls.PollsUtil.isAllowedToVote |
( |
PollOption |
pollOption | ) |
|
Definition at line 86 of file PollsUtil.java.
87 if(pollOption !=
null) {
88 return getPollVote(pollOption) !=
null || canVote(pollOption);
◆ removeOption()
static void org.turro.polls.PollsUtil.removeOption |
( |
PollOption |
po | ) |
|
|
static |
Definition at line 190 of file PollsUtil.java.
191 if(po ==
null)
return;
192 Dao dao =
new ElephantPU();
193 WhereClause wc =
new WhereClause();
194 wc.addClause(
"delete from PollOption");
195 wc.addClause(
"where idPoll = :idPoll");
196 wc.addNamedValue(
"idPoll", po.getIdPoll());
197 wc.addClause(
"and pollData = :pollData");
198 wc.addNamedValue(
"pollData", po.getPollData());
199 dao.executeUpdate(wc);
200 wc =
new WhereClause();
201 wc.addClause(
"delete from PollVote");
202 wc.addClause(
"where idPoll = :idPoll");
203 wc.addNamedValue(
"idPoll", po.getIdPoll());
204 wc.addClause(
"and pollData = :pollData");
205 wc.addNamedValue(
"pollData", po.getPollData());
206 dao.executeUpdate(wc);
◆ removePoll()
static void org.turro.polls.PollsUtil.removePoll |
( |
Poll |
poll | ) |
|
|
static |
Definition at line 170 of file PollsUtil.java.
171 if(poll ==
null)
return;
172 Dao dao =
new ElephantPU();
173 WhereClause wc =
new WhereClause();
174 wc.addClause(
"delete from Poll");
175 wc.addClause(
"where id = :idPoll");
176 wc.addNamedValue(
"idPoll", poll.getId());
177 dao.executeUpdate(wc);
178 wc =
new WhereClause();
179 wc.addClause(
"delete from PollOption");
180 wc.addClause(
"where idPoll = :idPoll");
181 wc.addNamedValue(
"idPoll", poll.getId());
182 dao.executeUpdate(wc);
183 wc =
new WhereClause();
184 wc.addClause(
"delete from PollVote");
185 wc.addClause(
"where idPoll = :idPoll");
186 wc.addNamedValue(
"idPoll", poll.getId());
187 dao.executeUpdate(wc);
◆ savePoll()
Definition at line 157 of file PollsUtil.java.
158 Dao dao =
new ElephantPU();
159 if(!poll.isEmpty()) {
160 poll = dao.saveObject(poll);
161 for(PollOption po : pos) {
◆ vote() [1/2]
boolean org.turro.polls.PollsUtil.vote |
( |
Long |
pollId, |
|
|
String |
pollData, |
|
|
Integer |
vote |
|
) |
| |
Definition at line 56 of file PollsUtil.java.
PollOption getPollOption(Long pollId, String pollData)
◆ vote() [2/2]
synchronized boolean org.turro.polls.PollsUtil.vote |
( |
PollOption |
pollOption, |
|
|
Integer |
vote |
|
) |
| |
Definition at line 60 of file PollsUtil.java.
61 if(pollOption !=
null) {
63 if(pollVote !=
null && pollVote.getVote() ==
vote) {
68 if(pollVote ==
null) {
69 if(canVote(pollOption)) {
70 pollVote =
new PollVote();
71 pollVote.setIdContact(contact.
getId());
72 pollVote.setIdPoll(pollOption.getIdPoll());
73 pollVote.setPollData(pollOption.getPollData());
76 if(pollVote !=
null) {
77 pollVote.setVoteDate(
new Date());
78 pollVote.setVote(
vote);
79 getDao().saveObject(pollVote);
void deleteObject(Object obj)
The documentation for this class was generated from the following file: