19 package org.turro.sendable;
21 import java.util.Collection;
22 import java.util.Date;
23 import java.util.concurrent.locks.ReentrantLock;
24 import org.turro.action.IElephantSendable;
25 import org.turro.elephant.context.IConstructor;
26 import org.turro.elephant.db.ElephantPU;
27 import org.turro.elephant.db.WhereClause;
28 import org.turro.elephant.entities.db.Sendable;
29 import org.turro.elephant.entities.db.SendableAssistant;
30 import org.turro.entities.Entities;
31 import org.turro.entities.IElephantEntity;
32 import org.turro.jpa.Dao;
41 boolean lockAcquired = SENDABLE_LOCK.tryLock();
52 SENDABLE_LOCK.unlock();
64 return dao.getResultList(wc);
71 wc.
addClause(
"where s.entityPath = :path");
76 public static Collection<SendableAssistant>
getAssistants(String entityPath,
boolean all) {
79 wc.
addClause(
"select sa from SendableAssistant sa");
80 wc.
addClause(
"where sa.entityPath = :path");
85 return dao.getResultList(wc);
91 wc.
addClause(
"delete from SendableAssistant");
94 wc.
addClause(
"where s.entityPath = entityPath");
99 public static void delete(String entityPath) {
102 wc.
addClause(
"delete from SendableAssistant");
103 wc.
addClause(
"where entityPath = :path");
108 wc.
addClause(
"where entityPath = :path");
113 public static void delivered(String entityPath, String contactId) {
116 wc.
addClause(
"update SendableAssistant");
118 wc.
addClause(
"where entityPath = :path");
120 wc.
addClause(
"and contactId = :contact");
125 public static void sent(String entityPath) {
130 wc.
addClause(
"where entityPath = :path");
140 private static final ReentrantLock SENDABLE_LOCK =
new ReentrantLock();
void addClause(String clause)
void addNamedValue(String name, Object value)
static IElephantEntity getController(String path)
int executeUpdate(String query)
Object getSingleResultOrNull(SqlClause sc)
static void send(IConstructor constructor)
static void sent(String entityPath)
static Collection< SendableAssistant > getAssistants(String entityPath, boolean all)
static Sendable getSendable(String entityPath)
static Collection< Sendable > getSendables()
static void delivered(String entityPath, String contactId)
static void cleanOrphans()
void send(IConstructor constructor)
IElephantSendable getSendable()