BrightSide Workbench Full Report + Source Code
org.turro.usual.UsualUsages Class Reference

Static Public Member Functions

static Usually addUsage (String path)
 
static Usually getUsage (String path)
 
static long getUsageCount (String path)
 
static Usually getMostUsed (String path)
 
static String getMostUsedvalue (String path)
 
static void clearUsuals (String path)
 

Detailed Description

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

Definition at line 31 of file UsualUsages.java.

Member Function Documentation

◆ addUsage()

static Usually org.turro.usual.UsualUsages.addUsage ( String  path)
static

Definition at line 33 of file UsualUsages.java.

33  {
34  if(!Strings.isBlank(path)) {
35  if(path.length() > 255) {
36  path = path.substring(0, 255);
37  }
38  if(path.endsWith(":null")) {
39  path = path.substring(0, path.length() - 4);
40  }
41  Dao dao = new ContactsPU();
42  Usually u = null;
43  try {
44  u = (Usually) dao.getSingleResult(
45  "select u from Usually as u " +
46  "where u.path = ?",
47  new Object[] {
48  path
49  });
50  u.setUsages(u.getUsages() + 1L);
51  u = dao.saveObject(u);
52  } catch(NoResultException ex) {
53  u = new Usually();
54  u.setPath(path);
55  u.setUsages(1L);
56  u = dao.saveObject(u);
57  }
58  return u;
59  }
60  return null;
61  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearUsuals()

static void org.turro.usual.UsualUsages.clearUsuals ( String  path)
static

Definition at line 116 of file UsualUsages.java.

116  {
117  if(!Strings.isBlank(path)) {
118  if(path.length() > 255) {
119  path = path.substring(0, 255);
120  }
121  Dao dao = new ContactsPU();
122  dao.executeUpdate(
123  "delete from Usually " +
124  "where path like ?",
125  new Object[] {
126  path + "%"
127  });
128  }
129  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMostUsed()

static Usually org.turro.usual.UsualUsages.getMostUsed ( String  path)
static

Definition at line 86 of file UsualUsages.java.

86  {
87  if(!Strings.isBlank(path)) {
88  if(path.length() > 255) {
89  path = path.substring(0, 255);
90  }
91  Dao dao = new ContactsPU();
92  try {
93  List<Usually> l = dao.getResultList(
94  "select u from Usually as u " +
95  "where u.path like ? " +
96  "and u.usages = (" +
97  " select max(u2.usages) from Usually as u2 " +
98  " where u2.path like ? " +
99  ")",
100  new Object[] {
101  path + "%", path + "%"
102  });
103  if(!l.isEmpty()) {
104  return l.get(0);
105  }
106  } catch(NoResultException ex) {}
107  }
108  return null;
109  }

◆ getMostUsedvalue()

static String org.turro.usual.UsualUsages.getMostUsedvalue ( String  path)
static

Definition at line 111 of file UsualUsages.java.

111  {
112  Usually u = getMostUsed(path);
113  return u == null ? null : u.getPath().substring(path.length());
114  }
static Usually getMostUsed(String path)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getUsage()

static Usually org.turro.usual.UsualUsages.getUsage ( String  path)
static

Definition at line 63 of file UsualUsages.java.

63  {
64  if(!Strings.isBlank(path)) {
65  if(path.length() > 255) {
66  path = path.substring(0, 255);
67  }
68  Dao dao = new ContactsPU();
69  try {
70  return (Usually) dao.getSingleResult(
71  "select u from Usually as u " +
72  "where u.path = ?",
73  new Object[] {
74  path
75  });
76  } catch(NoResultException ex) {}
77  }
78  return null;
79  }
Here is the call graph for this function:

◆ getUsageCount()

static long org.turro.usual.UsualUsages.getUsageCount ( String  path)
static

Definition at line 81 of file UsualUsages.java.

81  {
82  Usually u = getUsage(path);
83  return u == null ? 0 : u.getUsages();
84  }
static Usually getUsage(String path)
Here is the call graph for this function:
Here is the caller graph for this function:

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