19 package org.turro.starit;
21 import java.util.Collection;
22 import java.util.Date;
23 import java.util.List;
24 import org.amic.util.date.CheckDate;
25 import org.turro.string.Strings;
26 import org.turro.contacts.Contact;
27 import org.turro.contacts.StarIt;
28 import org.turro.contacts.db.ContactsPU;
29 import org.turro.entities.Entities;
30 import org.turro.jpa.Dao;
31 import org.turro.plugin.contacts.SoftContact;
47 if(!Strings.isBlank(path) && contact !=
null && contact.
isValid()) {
50 " select count(*) from StarIt " +
52 " and (creator = ? or author_ip = ?)",
53 new Object[] { path, contact.getContact(), contact.author_ip }
61 dao.saveObject(starIt);
76 if(!Strings.isBlank(path) && contact !=
null && contact.
isValid()) {
80 " delete from StarIt " +
87 " delete from StarIt " +
89 " and (creator is null and author_ip = ?)",
104 if(!Strings.isBlank(path) && contact !=
null && contact.
isValid()) {
112 new Object[] { newStars, path, contact.
getContact() }
119 " and creator is null and author_ip = ?",
120 new Object[] { newStars, path, contact.
author_ip }
137 " select sum(stars), count(stars) from StarIt " +
139 new Object[] { path }
143 si.
stars = o[0] ==
null ? 0 : (Long) o[0];
144 si.count = o[1] ==
null ? 0 : (Long) o[1];
150 public static List<StarIt>
allStars(Object entity) {
153 return allStars(path);
160 return dao.getResultList(
161 " select s from StarIt as s " +
163 new Object[] { path }
167 public static Collection<String>
paths(String path,
int fromDays) {
169 return dao.getResultList(
170 " select g.path from StarIt g " +
171 " where g.path like ? " +
172 " and g.dateCreation >= ?",
173 new Object[] { path +
"/%",
new CheckDate().addDays(-fromDays).getDate() }
static IElephantEntity getController(String path)
int executeUpdate(String query)
Object getSingleResult(WhereClause wc)
static void addStars(Object entity, int stars, SoftContact contact)
static StarsInfo stars(String path)
static void removeStars(String path, SoftContact contact)
static List< StarIt > allStars(String path)
static void addStars(String path, int stars, SoftContact contact)
static Collection< String > paths(String path, int fromDays)
static void changeStars(Object entity, int newStars, SoftContact contact)
static List< StarIt > allStars(Object entity)
static void changeStars(String path, int newStars, SoftContact contact)
static StarsInfo stars(Object entity)
static void removeStars(Object entity, SoftContact contact)