19 package org.turro.entities;
22 import java.text.DateFormat;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.Collection;
26 import java.util.Collections;
27 import java.util.List;
28 import org.amic.util.date.DateFormats;
29 import org.turro.action.LinkType;
30 import org.turro.string.Strings;
31 import org.turro.annotation.ElephantEntity;
32 import org.turro.collections.KeyValueMap;
33 import org.turro.elephant.db.ElephantPU;
34 import org.turro.elephant.db.WhereClause;
35 import org.turro.elephant.entities.db.EntityParticipation;
36 import org.turro.elephant.entities.db.EntityParticipationPK;
37 import org.turro.elephant.entities.db.Poll;
38 import org.turro.elephant.entities.db.Post;
39 import org.turro.elephant.entities.db.Sendable;
40 import org.turro.elephant.entities.db.Topic;
41 import org.turro.i18n.I_;
42 import org.turro.jpa.Dao;
43 import org.turro.path.Path;
44 import org.turro.plugin.contacts.IContact;
68 if(
path.getSize() == 2) {
69 if(
null !=
path.getRoot())
switch (
path.getRoot()) {
105 DateFormat.SHORT, DateFormat.SHORT,
121 String root =
path.getRoot();
122 if(
null != root)
switch (root) {
124 return I_.
get(
"Sendable");
126 return I_.
get(
"Poll");
128 return I_.
get(
"Topic");
130 return I_.
get(
"Post");
151 String root =
path.getRoot();
152 if(
null != root)
switch (root) {
154 return "/_zul/images/mail_queue.png";
156 return "/_zul/images/poll.png";
158 return "/_zul/images/topic.png";
160 return "/_zul/images/topic.png";
213 return Collections.EMPTY_LIST;
245 return ((
Poll)
entity).isParticipant(contact);
252 public Collection
getEntitites(String search,
int maxResults, KeyValueMap kvm) {
253 ArrayList<Object> list =
new ArrayList<>();
254 list.addAll(searchPolls(search, maxResults, kvm));
259 public Collection
getEntitites(String root, String search,
int maxResults, KeyValueMap kvm) {
260 ArrayList<Object> list =
new ArrayList<>();
261 if(
null != root)
switch (root) {
263 list.addAll(searchPolls(search, maxResults, kvm));
286 return "/" + poll.
getId() +
287 "/" + Strings.unpunctuate(poll.
getTitle()).toLowerCase();
296 if(
path.getRoot().equals(
"poll")) {
297 return "/user/mypolls";
299 if(
path.getRoot().equals(
"topic")) {
300 return "/user/forums";
318 return Arrays.asList(
"sendable",
"poll",
"topic",
"post");
344 private List<Object> searchPolls(String search,
int maxResults, KeyValueMap kvm) {
347 wc.
addClause(
"where p.title like :search");
350 return getDao().getResultList(wc, maxResults);
358 return super.getEntityUrl(type, contextPath);
static String getObjectPath(Object object)
void addClause(String clause)
void addNamedValue(String name, Object value)
static EntityParticipationPK from(String id)
boolean isValidLongEntity()
boolean equals(Object obj)
Collection getEntitites(String root, String search, int maxResults, KeyValueMap kvm)
IElephantEntity createInstance(Object entity)
boolean canShowInContext(IContact contact, Object relatedEntity)
ElephantEntities(Object entity)
Object getObject(Path entityPath)
String getHierarchicalPath()
Collection getEntitites(String search, int maxResults, KeyValueMap kvm)
Collection< String > getAllowedRoots()
ElephantEntities(String entityPath)
String getExtendedWebPath()
Object configureCtrl(Object ctrl, IContact contact)
List< IElephantEntity > getChildren()
boolean itsMine(Object entity)
boolean canEdit(IContact contact)
IElephantEntity createInstance(String entityPath)
boolean canPublish(IContact contact)
String getEntityUrl(LinkType type, String contextPath)
IElephantEntity getParent()
static IElephantEntity getController(String path)
static String get(String msg)
static I18nApiWrapper api()
static final String PATH_SEPARATOR
String getHierarchicalPath()