19 package org.turro.sendable;
21 import java.util.Collection;
22 import java.util.Date;
23 import org.turro.string.Strings;
24 import org.turro.action.IAgreements;
25 import org.turro.action.IElephantSendable;
26 import org.turro.action.Plugins;
27 import org.turro.assistant.AssistantSet;
28 import org.turro.elephant.context.IConstructor;
29 import org.turro.elephant.db.ElephantPU;
30 import org.turro.elephant.entities.db.Sendable;
31 import org.turro.elephant.entities.db.SendableAssistant;
32 import org.turro.entities.Entities;
33 import org.turro.jpa.Dao;
34 import org.turro.plugin.contacts.IContact;
47 assignByEntity(entity);
51 assignByPath(entityPath);
56 return sendable.getSchedule();
61 return sendable.isSent();
83 sendable.setSent(
true);
84 getDao().saveObject(sendable);
92 if(!assistants.isEmpty())
doSend(sendable, getEntity(), constructor, assistants,
false);
98 private Sendable assignByEntity(Object entity) {
102 private Sendable assignByPath(String entityPath) {
103 if(!Strings.isBlank(entityPath)) {
106 new Object[] { entityPath });
110 if(sendable ==
null) {
111 sendable =
new Sendable();
112 sendable.setEntityPath(entityPath);
117 private T getEntity() {
119 entity = (T) Entities.getController(sendable.getEntityPath()).getEntity();
128 private Dao getDao() {
130 _dao =
new ElephantPU();
static< T > T loadImplementation(Class< T > jclass)
void addContacts(Collection< IContact > contacts)
void addContact(IContact contact, Object relationEntity)
static IElephantEntity getController(String path)
Object getSingleResultOrNull(SqlClause sc)
void send(IConstructor constructor)
AbstractSendable(String entityPath)
AssistantSet getAssistants()
AbstractSendable(T entity)
void send(IConstructor constructor, Collection< IContact > contacts)
abstract boolean doSend(Sendable sendable, T entity, IConstructor constructor, AssistantSet assistants, boolean checkSent)
abstract void addAssistants(AssistantSet as, T entity)
static Collection< SendableAssistant > getAssistants(String entityPath, boolean all)
void setContact(IContact contact)
boolean declinedNotifications()