BrightSide Workbench Full Report + Source Code
org.turro.jpa.DaoUtil Class Reference

Static Public Member Functions

static boolean isEmpty (Dao dao, String table)
 
static boolean isEmpty (Dao dao, String table, String condition)
 
static boolean isEmpty (Dao dao, String table, String condition, Object... pars)
 
static Long count (Dao dao, String table)
 
static Long count (Dao dao, String table, String condition)
 
static Long count (Dao dao, String table, String condition, Object... pars)
 
static Long count (Dao dao, WhereClause wc)
 
static String getInClauseFromPaths (Collection< String > paths, boolean quoted)
 
static String getCommaSeparatedValues (Collection< String > values, boolean quoted)
 
static String getIdentifierFromPath (String e)
 
static String getJson (Dao dao, Class javaClass, Object identifier, final JSONSerializer json)
 

Detailed Description

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

Definition at line 33 of file DaoUtil.java.

Member Function Documentation

◆ count() [1/4]

static Long org.turro.jpa.DaoUtil.count ( Dao  dao,
String  table 
)
static

Definition at line 50 of file DaoUtil.java.

50  {
51  Long count = (Long) dao.getSingleResultOrNull("select count(x) from " + table + " x");
52  return count;
53  }
static Long count(Dao dao, String table)
Definition: DaoUtil.java:50
Here is the call graph for this function:
Here is the caller graph for this function:

◆ count() [2/4]

static Long org.turro.jpa.DaoUtil.count ( Dao  dao,
String  table,
String  condition 
)
static

Definition at line 55 of file DaoUtil.java.

55  {
56  Long count = (Long) dao.getSingleResultOrNull("select count(x) from " + table + " x " + condition);
57  return count;
58  }
Here is the call graph for this function:

◆ count() [3/4]

static Long org.turro.jpa.DaoUtil.count ( Dao  dao,
String  table,
String  condition,
Object...  pars 
)
static

Definition at line 60 of file DaoUtil.java.

60  {
61  Long count = (Long) dao.getSingleResultOrNull("select count(x) from " + table + " x " + condition, pars);
62  return count;
63  }
Here is the call graph for this function:

◆ count() [4/4]

static Long org.turro.jpa.DaoUtil.count ( Dao  dao,
WhereClause  wc 
)
static

Definition at line 65 of file DaoUtil.java.

65  {
66  Long count = (Long) dao.getSingleResultOrNull(wc);
67  return count;
68  }
Here is the call graph for this function:

◆ getCommaSeparatedValues()

static String org.turro.jpa.DaoUtil.getCommaSeparatedValues ( Collection< String >  values,
boolean  quoted 
)
static

Definition at line 79 of file DaoUtil.java.

79  {
80  String result = "";
81  for(String s : values) {
82  if(quoted) s = "\"" + s + "\"";
83  result += (String) (Strings.isBlank(result) ? s : "," + s);
84  }
85  return result;
86  }
Here is the caller graph for this function:

◆ getIdentifierFromPath()

static String org.turro.jpa.DaoUtil.getIdentifierFromPath ( String  e)
static

Definition at line 88 of file DaoUtil.java.

88  {
89  return new Path(e).getNode(1);
90  }
Here is the caller graph for this function:

◆ getInClauseFromPaths()

static String org.turro.jpa.DaoUtil.getInClauseFromPaths ( Collection< String >  paths,
boolean  quoted 
)
static

Definition at line 70 of file DaoUtil.java.

70  {
71  return getCommaSeparatedValues(new SetOf<String, String>(paths, new ItemOf<String, String>() {
72  @Override
73  public String getFrom(String e) {
74  return getIdentifierFromPath(e);
75  }
76  }), quoted);
77  }
static String getCommaSeparatedValues(Collection< String > values, boolean quoted)
Definition: DaoUtil.java:79
static String getIdentifierFromPath(String e)
Definition: DaoUtil.java:88
Here is the call graph for this function:

◆ getJson()

static String org.turro.jpa.DaoUtil.getJson ( Dao  dao,
Class  javaClass,
Object  identifier,
final JSONSerializer  json 
)
static

Definition at line 92 of file DaoUtil.java.

92  {
93  final StringBuilder sb = new StringBuilder();
94  dao.find(javaClass, identifier, new DaoCallback() {
95  @Override
96  public void before(Object value) {
97  }
98  @Override
99  public void after(Object oldValue, Object newValue) {
100  json.setObject(newValue);
101  sb.append(json.toJson());
102  }
103  });
104  return sb.length() > 0 ? sb.toString() : null;
105  }

◆ isEmpty() [1/3]

static boolean org.turro.jpa.DaoUtil.isEmpty ( Dao  dao,
String  table 
)
static

Definition at line 35 of file DaoUtil.java.

35  {
36  Long count = count(dao, table);
37  return count == null || count == 0L;
38  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEmpty() [2/3]

static boolean org.turro.jpa.DaoUtil.isEmpty ( Dao  dao,
String  table,
String  condition 
)
static

Definition at line 40 of file DaoUtil.java.

40  {
41  Long count = count(dao, table, condition);
42  return count == null || count == 0L;
43  }
Here is the call graph for this function:

◆ isEmpty() [3/3]

static boolean org.turro.jpa.DaoUtil.isEmpty ( Dao  dao,
String  table,
String  condition,
Object...  pars 
)
static

Definition at line 45 of file DaoUtil.java.

45  {
46  Long count = count(dao, table, condition, pars);
47  return count == null || count == 0L;
48  }
Here is the call graph for this function:

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