19 package org.turro.web.funnel.graph;
22 import java.util.TreeSet;
23 import java.util.function.Predicate;
24 import java.util.stream.Collectors;
25 import org.jgrapht.Graphs;
26 import org.jgrapht.graph.SimpleDirectedGraph;
27 import org.turro.elephant.db.ElephantPU;
28 import org.turro.elephant.entities.web.WebGoal;
29 import org.turro.elephant.entities.web.WebItem;
30 import org.turro.elephant.entities.web.WebItemType;
31 import org.turro.jpa.Dao;
32 import org.turro.sql.SqlClause;
33 import org.turro.util.Cached;
39 public class FunnelGraph extends SimpleDirectedGraph<FunnelVertex, FunnelEdge> {
47 return getItems(vertex -> vertex.isTarget());
51 return getItems(vertex -> vertex.isSolution());
55 return getItems(vertex -> vertex.isService());
59 return getItems(vertex -> vertex.isChain());
62 public Set<FunnelVertex>
getItems(Predicate<FunnelVertex> filter) {
63 return vertexSet().stream()
65 .collect(Collectors.toCollection(TreeSet::new));
69 return vertexSet().stream()
70 .filter(vertex -> vertex.getWebTag().equals(webTag))
71 .findAny().orElse(
null);
75 return vertexSet().stream()
76 .filter(vertex -> vertex.getItem().equals(item))
77 .findAny().orElse(
null);
81 return vertexSet().stream()
82 .flatMap(vertex -> vertex.getItem().getGoals().stream())
83 .filter(goal -> goal.getGoalAction().equals(goalAction))
84 .findAny().orElse(
null);
89 private void addVertices() {
90 SqlClause.select(
"wi").from(
"WebItem wi")
99 private void addEdges() {
100 vertexSet().stream().sorted().forEach(vertex -> {
101 vertex.getItem().getNexts().forEach(item -> {
102 FunnelVertex vitem =
new FunnelVertex(
this, item);
103 if(containsVertex(vitem)) {
104 Graphs.addEdgeWithVertices(
this, vertex, vitem);
FunnelVertex getVertex(WebItem item)
Set< FunnelVertex > getItems(Predicate< FunnelVertex > filter)
static FunnelGraph load()
FunnelVertex getVertex(String webTag)
WebGoal getGoal(String goalAction)
Set< FunnelVertex > getTargets()
WebItemType getBehaviour(WebItem item)
Set< FunnelVertex > getServices()
Set< FunnelVertex > getSolutions()
Set< FunnelVertex > getChains()
static WebItemType behaveAs(WebItem item)
WebItemType getActingType()