18 package org.turro.publication.entity;
20 import java.util.Collection;
21 import java.util.HashSet;
22 import java.util.List;
24 import java.util.TreeSet;
25 import java.util.stream.Collectors;
26 import javax.persistence.CascadeType;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.FetchType;
30 import javax.persistence.GeneratedValue;
31 import javax.persistence.GenerationType;
32 import javax.persistence.Id;
33 import javax.persistence.Lob;
34 import javax.persistence.OneToMany;
35 import org.turro.action.queue.ConstraintKeys;
36 import org.turro.action.queue.NotificationConstraint;
37 import org.turro.action.queue.NotificationConstraintSet;
38 import org.turro.string.Strings;
39 import org.turro.elephant.db.WhereClause;
40 import org.turro.jpa.Dao;
41 import org.turro.plugin.contacts.IContact;
42 import org.turro.publication.db.PublicationPU;
52 @GeneratedValue(strategy=GenerationType.IDENTITY)
53 @Column(name=
"IDENTIFIER")
56 private boolean publishable;
60 private String conditionedBy;
62 private boolean avoidQueue;
66 private String description;
68 @OneToMany(mappedBy =
"publicationCategory", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval=
true)
69 private Set<PublicationConstraint> constraints =
new TreeSet<PublicationConstraint>();
76 this.description = description;
100 this.publishable = publishable;
104 return conditionedBy;
108 this.conditionedBy = conditionedBy;
116 this.avoidQueue = avoidQueue;
124 this.constraints = constraints;
144 return Strings.isBlank(name);
150 .collect(Collectors.toCollection(HashSet::new)));
155 wc.
addClause(
"select d from Publication d");
156 wc.
addClause(
"where d.publicationCategory = :category");
165 "select ps from PublicationSubscription ps " +
166 "where ps.publicationCategory = ?",
167 new Object[] {
this }
174 "select ps.id from PublicationSubscription ps " +
175 "where ps.publicationCategory = ?",
176 new Object[] {
this }
182 "select ps from PublicationBlogger ps " +
183 "where ps.publicationCategory = ?",
184 new Object[] {
this }
190 "select ps.id from PublicationBlogger ps " +
191 "where ps.publicationCategory = ?",
192 new Object[] {
this }
198 "select ps from PublicationBlogger ps " +
199 "where ps.idContact = ? " +
200 "and ps.publicationCategory = ?",
201 new Object[] { contact.
getId(),
this }
207 "select distinct ps.idContact from PublicationBlogger ps " +
208 "where ps.idContact = ?",
209 new Object[] { contact.
getId() }
boolean wideBond(String... key)
boolean strongBond(String... key)
void addClause(String clause)
void addNamedValue(String name, Object value)
Object getSingleResultOrNull(SqlClause sc)
Collection< PublicationBlogger > getBloggers()
Set< PublicationConstraint > getConstraints()
boolean strongBond(ConstraintKeys keys)
void setPublishable(boolean publishable)
void setName(String name)
boolean isBlogger(IContact contact)
boolean wideBond(ConstraintKeys keys)
void setConditionedBy(String conditionedBy)
void setConstraints(Set< PublicationConstraint > constraints)
void setAvoidQueue(boolean avoidQueue)
List< Publication > getPublications()
Collection< Long > getBloggersId()
static boolean isAnyBlogger(IContact contact)
void setDescription(String description)
NotificationConstraintSet getConstraintSet()
Collection< Long > getSubscriptorsId()
String getConditionedBy()
Collection< PublicationSubscription > getSubscriptors()