BrightSide Workbench Full Report + Source Code
org.turro.starit.StarItUtil Class Reference

Static Public Member Functions

static void addStars (Object entity, int stars, SoftContact contact)
 
static void addStars (String path, int stars, SoftContact contact)
 
static void removeStars (Object entity, SoftContact contact)
 
static void removeStars (String path, SoftContact contact)
 
static void changeStars (Object entity, int newStars, SoftContact contact)
 
static void changeStars (String path, int newStars, SoftContact contact)
 
static StarsInfo stars (Object entity)
 
static StarsInfo stars (String path)
 
static List< StarItallStars (Object entity)
 
static List< StarItallStars (String path)
 
static Collection< String > paths (String path, int fromDays)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 37 of file StarItUtil.java.

Member Function Documentation

◆ addStars() [1/2]

static void org.turro.starit.StarItUtil.addStars ( Object  entity,
int  stars,
SoftContact  contact 
)
static

Definition at line 39 of file StarItUtil.java.

39  {
40  String path = Entities.getController(entity).getPath();
41  if(path != null) {
42  addStars(path, stars, contact);
43  }
44  }
static void addStars(Object entity, int stars, SoftContact contact)
Definition: StarItUtil.java:39
static StarsInfo stars(Object entity)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addStars() [2/2]

static void org.turro.starit.StarItUtil.addStars ( String  path,
int  stars,
SoftContact  contact 
)
static

Definition at line 46 of file StarItUtil.java.

46  {
47  if(!Strings.isBlank(path) && contact != null && contact.isValid()) {
48  Dao dao = new ContactsPU();
49  if(((Long) dao.getSingleResult(
50  " select count(*) from StarIt " +
51  " where path = ? " +
52  " and (creator = ? or author_ip = ?)",
53  new Object[] { path, contact.getContact(), contact.author_ip }
54  )) == 0) {
55  StarIt starIt = new StarIt();
56  starIt.setCreator((Contact) contact.getContact());
57  starIt.setAuthor_ip(contact.author_ip);
58  starIt.setDateCreation(new Date());
59  starIt.setStars(stars);
60  starIt.setPath(path);
61  dao.saveObject(starIt);
62  } else {
63  changeStars(path, stars, contact);
64  }
65  }
66  }
static void changeStars(Object entity, int newStars, SoftContact contact)
Definition: StarItUtil.java:96
Here is the call graph for this function:

◆ allStars() [1/2]

static List<StarIt> org.turro.starit.StarItUtil.allStars ( Object  entity)
static

Definition at line 150 of file StarItUtil.java.

150  {
151  String path = Entities.getController(entity).getPath();
152  if(path != null) {
153  return allStars(path);
154  }
155  return null;
156  }
static List< StarIt > allStars(Object entity)
Here is the call graph for this function:

◆ allStars() [2/2]

static List<StarIt> org.turro.starit.StarItUtil.allStars ( String  path)
static

Definition at line 158 of file StarItUtil.java.

158  {
159  Dao dao = new ContactsPU();
160  return dao.getResultList(
161  " select s from StarIt as s " +
162  " where s.path = ?",
163  new Object[] { path }
164  );
165  }

◆ changeStars() [1/2]

static void org.turro.starit.StarItUtil.changeStars ( Object  entity,
int  newStars,
SoftContact  contact 
)
static

Definition at line 96 of file StarItUtil.java.

96  {
97  String path = Entities.getController(entity).getPath();
98  if(path != null) {
99  changeStars(path, newStars, contact);
100  }
101  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ changeStars() [2/2]

static void org.turro.starit.StarItUtil.changeStars ( String  path,
int  newStars,
SoftContact  contact 
)
static

Definition at line 103 of file StarItUtil.java.

103  {
104  if(!Strings.isBlank(path) && contact != null && contact.isValid()) {
105  Dao dao = new ContactsPU();
106  if(contact.getContact() != null) {
107  dao.executeUpdate(
108  " update StarIt " +
109  " set stars = ? " +
110  " where path = ? " +
111  " and creator = ?",
112  new Object[] { newStars, path, contact.getContact() }
113  );
114  } else {
115  dao.executeUpdate(
116  " update StarIt " +
117  " set stars = ? " +
118  " where path = ? " +
119  " and creator is null and author_ip = ?",
120  new Object[] { newStars, path, contact.author_ip }
121  );
122  }
123  }
124  }
Here is the call graph for this function:

◆ paths()

static Collection<String> org.turro.starit.StarItUtil.paths ( String  path,
int  fromDays 
)
static

Definition at line 167 of file StarItUtil.java.

167  {
168  Dao dao = new ContactsPU();
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() }
174  );
175  }

◆ removeStars() [1/2]

static void org.turro.starit.StarItUtil.removeStars ( Object  entity,
SoftContact  contact 
)
static

Definition at line 68 of file StarItUtil.java.

68  {
69  String path = Entities.getController(entity).getPath();
70  if(path != null) {
71  removeStars(path, contact);
72  }
73  }
static void removeStars(Object entity, SoftContact contact)
Definition: StarItUtil.java:68
Here is the call graph for this function:

◆ removeStars() [2/2]

static void org.turro.starit.StarItUtil.removeStars ( String  path,
SoftContact  contact 
)
static

Definition at line 75 of file StarItUtil.java.

75  {
76  if(!Strings.isBlank(path) && contact != null && contact.isValid()) {
77  Dao dao = new ContactsPU();
78  if(contact.getContact() != null) {
79  dao.executeUpdate(
80  " delete from StarIt " +
81  " where path = ? " +
82  " and creator = ?",
83  new Object[] { path, contact.getContact() }
84  );
85  } else {
86  dao.executeUpdate(
87  " delete from StarIt " +
88  " where path = ? " +
89  " and (creator is null and author_ip = ?)",
90  new Object[] { path, contact.author_ip }
91  );
92  }
93  }
94  }
Here is the call graph for this function:

◆ stars() [1/2]

static StarsInfo org.turro.starit.StarItUtil.stars ( Object  entity)
static

Definition at line 126 of file StarItUtil.java.

126  {
127  String path = Entities.getController(entity).getPath();
128  if(path != null) {
129  return stars(path);
130  }
131  return null;
132  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stars() [2/2]

static StarsInfo org.turro.starit.StarItUtil.stars ( String  path)
static

Definition at line 134 of file StarItUtil.java.

134  {
135  Dao dao = new ContactsPU();
136  Object o[] = (Object[]) dao.getSingleResult(
137  " select sum(stars), count(stars) from StarIt " +
138  " where path = ?",
139  new Object[] { path }
140  );
141  if(o != null) {
142  StarsInfo si = new StarsInfo();
143  si.stars = o[0] == null ? 0 : (Long) o[0];
144  si.count = o[1] == null ? 0 : (Long) o[1];
145  return si;
146  }
147  return null;
148  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: