|
static void | addVote (Object entity, int vote, IContact contact) |
|
static void | addVote (String path, int vote, IContact contact) |
|
static void | removeVote (Object entity, IContact contact) |
|
static void | removeVote (String path, IContact contact) |
|
static void | changeVote (Object entity, int newVote, IContact contact) |
|
static void | changeVote (String path, int newVote, IContact contact) |
|
static VoteItInfo | info (Object entity, IContact contact) |
|
static VoteItInfo | info (Object entity, String allowed, IContact contact) |
|
static VoteItInfo | info (String path, IContact contact) |
|
static VoteItInfo | info (String path, String allowed, IContact contact) |
|
static MyVote | myVote (String path, IContact contact) |
|
static MyVote | myVote (Dao dao, String path, IContact contact) |
|
static List< VoteIt > | allVotes (String path) |
|
static String | getAllowedString (String allowed) |
|
static Collection< String > | paths (String path, int fromDays) |
|
- Author
- Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g
Definition at line 39 of file VoteItUtil.java.
◆ addVote() [1/2]
static void org.turro.voteit.VoteItUtil.addVote |
( |
Object |
entity, |
|
|
int |
vote, |
|
|
IContact |
contact |
|
) |
| |
|
static |
Definition at line 41 of file VoteItUtil.java.
42 String path = Entities.getController(entity).getPath();
static void addVote(Object entity, int vote, IContact contact)
◆ addVote() [2/2]
static void org.turro.voteit.VoteItUtil.addVote |
( |
String |
path, |
|
|
int |
vote, |
|
|
IContact |
contact |
|
) |
| |
|
static |
Definition at line 48 of file VoteItUtil.java.
49 if(!Strings.isBlank(path) && contact !=
null && contact.isValid()) {
50 Dao dao =
new ContactsPU();
51 if(((Long) dao.getSingleResult(
52 " select count(*) from VoteIt " +
55 new Object[] { path, contact.getContact() }
57 VoteIt voteIt =
new VoteIt();
58 voteIt.setCreator((Contact) contact.getContact());
59 voteIt.setDateCreation(
new Date());
62 dao.saveObject(voteIt);
63 SystemLogger.getInstance().doLog(SystemLogType.LOG_INFO, contact, path,
"vote-it", vote +
"");
static void changeVote(Object entity, int newVote, IContact contact)
◆ allVotes()
static List<VoteIt> org.turro.voteit.VoteItUtil.allVotes |
( |
String |
path | ) |
|
|
static |
Definition at line 183 of file VoteItUtil.java.
184 Dao dao =
new ContactsPU();
185 return dao.getResultList(
186 " select vi from VoteIt as vi " +
187 " where vi.path = ?",
188 new Object[] { path }
◆ changeVote() [1/2]
static void org.turro.voteit.VoteItUtil.changeVote |
( |
Object |
entity, |
|
|
int |
newVote, |
|
|
IContact |
contact |
|
) |
| |
|
static |
Definition at line 90 of file VoteItUtil.java.
91 String path = Entities.getController(entity).getPath();
◆ changeVote() [2/2]
static void org.turro.voteit.VoteItUtil.changeVote |
( |
String |
path, |
|
|
int |
newVote, |
|
|
IContact |
contact |
|
) |
| |
|
static |
Definition at line 97 of file VoteItUtil.java.
98 if(!Strings.isBlank(path) && contact !=
null && contact.isValid()) {
99 Dao dao =
new ContactsPU();
105 new Object[] { newVote, path, contact.getContact() }
107 SystemLogger.getInstance().doLog(SystemLogType.LOG_INFO, contact, path,
"vote-it", newVote +
"");
◆ getAllowedString()
static String org.turro.voteit.VoteItUtil.getAllowedString |
( |
String |
allowed | ) |
|
|
static |
Definition at line 192 of file VoteItUtil.java.
193 if(allowed ==
null) {
196 if(Strings.isBlank(allowed)) {
197 return " and 1 = 2 ";
199 return " and creator.id in (" + allowed +
")";
◆ info() [1/4]
Definition at line 111 of file VoteItUtil.java.
112 return info(entity,
null, contact);
static VoteItInfo info(Object entity, IContact contact)
◆ info() [2/4]
static VoteItInfo org.turro.voteit.VoteItUtil.info |
( |
Object |
entity, |
|
|
String |
allowed, |
|
|
IContact |
contact |
|
) |
| |
|
static |
Definition at line 115 of file VoteItUtil.java.
116 String path = Entities.getController(entity).getPath();
118 return info(path, allowed, contact);
◆ info() [3/4]
◆ info() [4/4]
static VoteItInfo org.turro.voteit.VoteItUtil.info |
( |
String |
path, |
|
|
String |
allowed, |
|
|
IContact |
contact |
|
) |
| |
|
static |
Definition at line 127 of file VoteItUtil.java.
128 VoteItInfo vi =
new VoteItInfo();
129 Dao dao =
new ContactsPU();
130 vi.setPositive((Long) dao.getSingleResult(
131 " select count(vote) from VoteIt " +
132 " where path = ? and vote > 0 " +
134 new Object[] { path }
136 vi.setNocare((Long) dao.getSingleResult(
137 " select count(vote) from VoteIt " +
138 " where path = ? and vote = 0 " +
140 new Object[] { path }
142 vi.setNegative((Long) dao.getSingleResult(
143 " select count(vote) from VoteIt " +
144 " where path = ? and vote < 0 " +
146 new Object[] { path }
148 if(contact !=
null) {
149 vi.setMyVote(
myVote(dao, path, contact));
static String getAllowedString(String allowed)
static MyVote myVote(String path, IContact contact)
◆ myVote() [1/2]
static MyVote org.turro.voteit.VoteItUtil.myVote |
( |
Dao |
dao, |
|
|
String |
path, |
|
|
IContact |
contact |
|
) |
| |
|
static |
Definition at line 169 of file VoteItUtil.java.
170 if(!Strings.isBlank(path) && contact !=
null && contact.isValid()) {
171 VoteIt vi = (VoteIt) dao.getSingleResultOrNull(
172 " select vi from VoteIt as vi " +
173 " where path = ? and creator = ?",
174 new Object[] { path, contact.getContact() }
177 return new MyVote(contact, vi.getVote());
◆ myVote() [2/2]
static MyVote org.turro.voteit.VoteItUtil.myVote |
( |
String |
path, |
|
|
IContact |
contact |
|
) |
| |
|
static |
Definition at line 154 of file VoteItUtil.java.
155 Dao dao =
new ContactsPU();
156 if(!Strings.isBlank(path) && contact !=
null && contact.isValid()) {
157 VoteIt vi = (VoteIt) dao.getSingleResultOrNull(
158 " select vi from VoteIt as vi " +
159 " where path = ? and creator = ?",
160 new Object[] { path, contact.getContact() }
163 return new MyVote(contact, vi.getVote());
◆ paths()
static Collection<String> org.turro.voteit.VoteItUtil.paths |
( |
String |
path, |
|
|
int |
fromDays |
|
) |
| |
|
static |
Definition at line 204 of file VoteItUtil.java.
205 Dao dao =
new ContactsPU();
206 return dao.getResultList(
207 " select g.path from VoteIt g " +
208 " where g.path like ? " +
209 " and g.dateCreation >= ?",
210 new Object[] { path +
"/%",
new CheckDate().addDays(-fromDays).getDate() }
◆ removeVote() [1/2]
static void org.turro.voteit.VoteItUtil.removeVote |
( |
Object |
entity, |
|
|
IContact |
contact |
|
) |
| |
|
static |
Definition at line 70 of file VoteItUtil.java.
71 String path = Entities.getController(entity).getPath();
static void removeVote(Object entity, IContact contact)
◆ removeVote() [2/2]
static void org.turro.voteit.VoteItUtil.removeVote |
( |
String |
path, |
|
|
IContact |
contact |
|
) |
| |
|
static |
Definition at line 77 of file VoteItUtil.java.
78 if(!Strings.isBlank(path) && contact !=
null && contact.isValid()) {
79 Dao dao =
new ContactsPU();
81 " delete from VoteIt " +
84 new Object[] { path, contact.getContact() }
86 SystemLogger.getInstance().doLog(SystemLogType.LOG_INFO, contact, path,
"vote-it",
"deleted");
The documentation for this class was generated from the following file: