19 package org.turro.web.funnel;
21 import java.io.IOException;
22 import java.io.PrintWriter;
23 import java.util.List;
25 import javax.servlet.ServletException;
26 import org.turro.elephant.entities.web.WebGoal;
27 import org.turro.elephant.entities.web.WebItem;
28 import org.turro.elephant.impl.abstracts.AbstractElement;
29 import org.turro.elephant.impl.util.Parser;
30 import org.turro.elephant.web.actions.WebLink;
31 import org.turro.elephant.web.tags.SessionTags;
32 import org.turro.elephant.web.tags.TagsServlet;
33 import org.turro.marker.ElephantMarker;
34 import org.turro.marker.construct.Markers;
35 import org.turro.string.Nullable;
36 import org.turro.string.Strings;
37 import org.turro.web.funnel.graph.FunnelVertex;
38 import org.turro.web.funnel.model.FunnelVertices;
47 private List<String> goalActions;
57 goalActions = Strings.csvToList(
getAttributes().getAttributeValue(
"attrib:goals",
null));
59 test =
getAttributes().getAttributeBooleanValue(
"attrib:test",
false);
66 constructVertex(vertex);
70 private void constructTargets() throws IOException, ServletException {
72 if(test) constructTest(
null);
75 private void constructVertex(FunnelVertex vertex)
throws IOException, ServletException {
77 WebItem webItem = vertex.getItem();
78 Parser.processMacros(
constructor, out, Strings.isBlank(webItem.getContent(),
"NO_CONTENT"));
79 if(test) constructTest(vertex);
82 private void constructTest(FunnelVertex vertex)
throws IOException, ServletException {
83 Markers.divider().cssClass(
"hidden").render(
constructor);
85 Markers.header().level(3).cssClass(
"dividing")
86 .caption(Nullable.of(vertex).get(v -> v.getItem().getCaption(), () ->
"[TEST FUNNEL]"))
91 Set<FunnelVertex> nexts = vertices.
nexts();
92 if(nexts !=
null && !nexts.isEmpty()) {
93 Markers.header().level(4).caption(
"Next steps").render(
constructor);
94 processVertices(nexts,
"vlist");
96 constructBackTo(vertices.
previous());
97 Set<WebGoal> goals = vertices.
goals();
98 if(goals !=
null && !goals.isEmpty()) {
99 Markers.header().level(4).caption(
"Goals").render(
constructor);
100 processGoals(goals,
"gsummary");
102 Set<FunnelVertex> siblings = vertices.
siblings();
103 if(siblings !=
null && !siblings.isEmpty()) {
104 Markers.header().level(4).caption(
"Also interesting").render(
constructor);
105 processVertices(siblings,
"vlist");
107 Set<WebLink> externals = vertices.
externals();
108 if(externals !=
null && !externals.isEmpty()) {
109 Markers.header().level(4).caption(
"Learn more").render(
constructor);
110 linkWebLinks(externals);
117 private void constructCleanner() {
118 ElephantMarker marker =
new ElephantMarker(
constructor);
120 marker.put(
"dashboard",
this);
121 marker.process(
"web/funnel",
"cleanner");
124 private void constructBackTo(FunnelVertex vertex)
throws IOException, ServletException {
125 ElephantMarker marker =
new ElephantMarker(
constructor);
126 marker.put(
"vertex", vertex);
128 marker.put(
"dashboard",
this);
129 marker.process(
"web/funnel",
"back");
132 private void processVertices(Set<FunnelVertex> vertices, String
template) {
133 ElephantMarker marker =
new ElephantMarker(
constructor);
134 marker.put(
"vertices", vertices);
135 marker.put(
"dashboard",
this);
136 marker.process(
"web/funnel",
template);
139 private void processGoals(Set<WebGoal> goals, String
template) {
140 ElephantMarker marker =
new ElephantMarker(
constructor);
141 marker.put(
"goals", goals);
142 marker.put(
"dashboard",
this);
143 marker.process(
"web/funnel",
template);
146 private void linkWebLinks(Set<WebLink> links) {
147 ElephantMarker marker =
new ElephantMarker(
constructor);
148 marker.put(
"links", links);
149 marker.put(
"dashboard",
this);
150 marker.process(
"web/funnel",
"webLinks");
155 private void checkClean() {
AttributeSupport getAttributes()
IConstructor getConstructor()
static SessionGoals get()
Set< FunnelVertex > targets()
Set< FunnelVertex > nexts()
static FunnelVertices load(IConstructor constructor)
Set< FunnelVertex > siblings()
FunnelVertices bySelection(boolean value)
Set< WebLink > externals()
ElContext getCurrentContext()
String getParameter(String param)