19 package org.turro.describeit;
21 import java.util.Collection;
22 import java.util.Date;
23 import org.turro.string.Strings;
24 import org.turro.callback.ChangedValue;
25 import org.turro.contacts.Contact;
26 import org.turro.contacts.DescribeIt;
27 import org.turro.contacts.db.ContactsPU;
28 import org.turro.entities.Entities;
29 import org.turro.jpa.Dao;
30 import org.turro.parser.wiki.WikiCompiler;
38 public static final String
DEFAULT_ID =
"Default", DEFAULT_KEY =
"Default";
48 if(Strings.isBlank(
id)) {
51 if(!Strings.isBlank(path) && !Strings.isBlank(
description) && contact !=
null) {
54 if(describeIt !=
null) {
84 dao.saveObject(describeIt);
88 public static void remove(String id) {
91 " delete from DescribeIt c " +
92 " where c.id = '" +
id +
"'"
96 public static void remove(String path, String id) {
99 " delete from DescribeIt c" +
100 " where c.describeId = '" +
id +
"'" +
101 " and c.path = '" + path +
"'"
115 return dao.getResultList(
116 " select c from DescribeIt c " +
118 " order by dateCreation ",
119 new Object[] { path }
123 public static Collection<DescribeIt>
descriptions(String
id, Object entity) {
131 public static Collection<DescribeIt>
descriptions(String
id, String path) {
133 return dao.getResultList(
134 " select c from DescribeIt c " +
136 " and describeId = ? " +
137 " order by dateCreation ",
138 new Object[] { path,
id }
144 if(list !=
null && !list.isEmpty()) {
145 return list.iterator().next();
152 if(list !=
null && !list.isEmpty()) {
153 return list.iterator().next();
160 return di !=
null ? di.
getBody() :
null;
165 return di !=
null ? di.
getBody() :
null;
168 public static Collection<DescribeIt>
pending() {
170 return dao.getResultList(
171 " select c from DescribeIt c " +
172 " where accepted = FALSE " +
173 " order by dateCreation "
180 " select count(c) from DescribeIt c " +
181 " where accepted = FALSE "
188 " select count(c) from DescribeIt c "
192 public static long count(Object entity) {
200 public static long count(String path) {
203 " select count(c) from DescribeIt c " +
205 " order by dateCreation desc ",
206 new Object[] { path }
214 private DescribeItUtil() {
static Collection< DescribeIt > descriptions(String id, Object entity)
static Collection< DescribeIt > descriptions(String id, String path)
static Collection< DescribeIt > descriptions(Object entity)
static String descriptionString(String id, Object entity)
static Collection< DescribeIt > descriptions(String path)
static DescribeIt description(String id, String path)
static final String DEFAULT_ID
static void addDescription(String path, String id, String description, Contact contact, ChangedValue changed)
static DescribeIt description(String id, Object entity)
static Collection< DescribeIt > pending()
static String descriptionString(String id, String path)
static long count(String path)
static long countPending()
static long count(Object entity)
static void addDescription(Object entity, String id, String description, Contact contact, ChangedValue changed)
static IElephantEntity getController(String path)
int executeUpdate(String query)
Object getSingleResultOrNull(SqlClause sc)