19 package org.turro.elephant.entities.web;
21 import java.io.Serializable;
22 import java.util.HashSet;
23 import java.util.Objects;
25 import java.util.TreeSet;
26 import java.util.stream.Collectors;
27 import javax.persistence.AttributeOverride;
28 import javax.persistence.AttributeOverrides;
29 import javax.persistence.Column;
30 import javax.persistence.ElementCollection;
31 import javax.persistence.Embedded;
32 import javax.persistence.Entity;
33 import javax.persistence.FetchType;
34 import javax.persistence.Id;
35 import javax.persistence.ManyToMany;
36 import javax.persistence.OrderBy;
37 import org.turro.elephant.context.Application;
38 import org.turro.elephant.context.IConstructor;
39 import org.turro.elephant.web.actions.WebActions;
40 import org.turro.elephant.web.actions.WebLink;
41 import org.turro.html.HtmlContent;
42 import org.turro.icon.Icons;
43 import org.turro.jpa.embeddables.Wiki;
44 import org.turro.jpa.entity.IDaoEntity;
45 import org.turro.string.Phrases;
46 import org.turro.string.Strings;
55 @Id
private String webTag;
59 private String caption, image;
64 @AttributeOverride( name =
"text", column = @Column(name =
"summary")),
65 @AttributeOverride( name =
"wiki", column = @Column(name =
"wsummary"))
71 @AttributeOverride( name =
"text", column = @Column(name =
"description")),
72 @AttributeOverride( name =
"wiki", column = @Column(name =
"wdescription"))
74 private Wiki description;
76 @ManyToMany(fetch = FetchType.EAGER)
78 private Set<WebGoal> goals =
new TreeSet<>();
80 @ManyToMany(fetch = FetchType.EAGER)
82 private Set<WebItem> nexts =
new TreeSet<>();
84 @ElementCollection(fetch=FetchType.EAGER)
85 private Set<String> externals =
new HashSet<>();
108 this.caption = caption;
124 this.ordering = ordering;
128 if(summary ==
null) summary =
new Wiki();
133 this.summary = summary;
137 if(description ==
null) description =
new Wiki();
142 this.description = description;
166 this.externals = externals;
172 return summary ==
null ?
"" : HtmlContent.plain(summary.
getText(), 100);
176 return summary ==
null ?
"" : summary.
getText();
180 return description ==
null ?
"" : description.
getText();
184 return !Strings.isBlank(image) && !image.endsWith(
".png");
188 return webTag.matches(
"[A-Za-z0-9_-]+");
192 return Icons.from(image);
196 return Phrases.start(caption).add(webTag,
"()").add(type.toString()).toString();
201 if(constructor !=
null) {
209 .filter(wl -> !wl.isEmpty()).collect(Collectors.toSet());
215 hash = 71 * hash + Objects.hashCode(this.webTag);
227 if (getClass() != obj.getClass()) {
231 return Objects.
equals(this.webTag, other.webTag);
243 return Strings.isBlank(webTag) || Strings.isBlank(caption);
IConstructor getConstructor()
static Application getApplication()
void setCaption(String caption)
void setWebTag(String webTag)
void setOrdering(int ordering)
String getPlainCompendium()
Set< WebItem > getNexts()
Set< WebGoal > getGoals()
Set< String > getExternals()
void setNexts(Set< WebItem > nexts)
void setGoals(Set< WebGoal > goals)
void setDescription(Wiki description)
Set< WebLink > getExternalLinks()
void setType(WebItemType type)
void setSummary(Wiki summary)
boolean equals(Object obj)
void setExternals(Set< String > externals)
void setImage(String image)
static WebActions of(String action)
void compose(IConstructor constructor)