18 package org.turro.publication.entity;
20 import java.util.Date;
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.GeneratedValue;
24 import javax.persistence.GenerationType;
25 import javax.persistence.Id;
26 import javax.persistence.Lob;
27 import javax.persistence.ManyToOne;
28 import javax.persistence.Temporal;
29 import org.turro.string.Strings;
30 import org.turro.action.Contacts;
31 import org.turro.elephant.context.Application;
32 import org.turro.elephant.impl.util.Parser;
33 import org.turro.elephant.util.DateFormats;
34 import org.turro.html.HTMLEntities;
35 import org.turro.html.HtmlContent;
36 import org.turro.jpa.Dao;
37 import org.turro.jpa.entity.IDaoEntity;
38 import org.turro.parser.wiki.WikiCompiler;
39 import org.turro.plugin.contacts.IContact;
40 import org.turro.reflection.MappingSet;
50 @GeneratedValue(strategy=GenerationType.IDENTITY)
51 @Column(name=
"IDENTIFIER")
54 @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
55 private java.util.Date creation;
57 private String idContact;
59 private boolean accepted, sent;
67 private String author;
69 @Temporal(value = javax.persistence.TemporalType.DATE)
70 @Column(name=
"PUB_DATE")
71 private java.util.Date date;
73 @Temporal(value = javax.persistence.TemporalType.TIMESTAMP)
74 private java.util.Date retainTill;
76 private String title, lang;
78 private String senderId;
80 private long readings;
84 private String summary;
92 private String wikiSummary;
96 private String wikiBody;
103 this.accepted = accepted;
111 this.author = author;
127 this.creation = creation;
147 this.retainTill = retainTill;
163 this.idContact = idContact;
168 return publicationCategory;
172 this.publicationCategory = publicationCategory;
176 return publicationGroup;
180 this.publicationGroup = publicationGroup;
188 this.readings = readings;
204 this.summary = summary;
228 if(Strings.isBlank(wikiSummary) && !Strings.isBlank(summary)) {
229 wikiSummary =
"$no_wiki\n" + summary;
235 this.wikiSummary = wikiSummary;
240 if(Strings.isBlank(wikiBody) && !Strings.isBlank(body)) {
241 wikiBody =
"$no_wiki\n" + body;
247 this.wikiBody = wikiBody;
256 this.senderId = senderId;
263 "update Publication set readings = readings + 1 where id = ? and accepted = TRUE",
264 new Object[] {
id });
276 return publicationCategory ==
null || publicationGroup ==
null || Strings.isBlank(title) ||
277 (Strings.isBlank(summary) && Strings.isBlank(wikiSummary));
283 return (Strings.isBlank(summary) ?
"" : summary) +
284 (Strings.isBlank(body) ?
"" : body);
288 return HtmlContent.truncate(summary, max);
292 return HtmlContent.plain(summary, max);
297 private transient IContact _contact;
300 if(_contact ==
null) {
308 idContact = _contact !=
null ? _contact.
getId() :
null;
309 author = _contact !=
null ? _contact.
getName() :
null;
312 private void resetIContact() {
316 private transient IContact _sender;
319 if(_sender ==
null) {
327 senderId = _sender !=
null ? _sender.
getId() :
null;
333 MappingSet
set =
new MappingSet();
335 new String[] {
"id",
"creation",
"date",
"retainTill",
"idContact",
336 "author",
"senderId",
"accepted",
"sent" },
337 new String[] {
"title",
"lang",
"summary",
"body",
"wikiSummary",
338 "wikiBody",
"publicationGroup",
"publicationCategory" });
340 new String[] {
"id",
"name" },
343 new String[] {
"id",
"name" },
static String escape(String html)
static String unescape(String html)
int executeUpdate(String query)
void setSenderId(String senderId)
void setContactAuthor(IContact contact)
void updateReadings(Dao dao)
MappingSet getSerializerMappings()
void setPublicationGroup(PublicationGroup publicationGroup)
void setTitle(String title)
String getPlainSummary(int max)
void setWikiBody(String wikiBody)
void setWikiSummary(String wikiSummary)
String getSummary(int max)
String getUnescapedTitle()
void setBody(String body)
void setAccepted(boolean accepted)
IContact getContactAuthor()
void setSummary(String summary)
void setSender(IContact contact)
PublicationGroup getPublicationGroup()
void setIdContact(String idContact)
void setAuthor(String author)
PublicationCategory getPublicationCategory()
void setReadings(long readings)
void setLang(String lang)
void setRetainTill(Date retainTill)
void setCreation(Date creation)
void setPublicationCategory(PublicationCategory publicationCategory)
void setSent(boolean sent)