BrightSide Workbench Full Report + Source Code
org.turro.indicator.GenericIndicator Class Reference
Inheritance diagram for org.turro.indicator.GenericIndicator:
Collaboration diagram for org.turro.indicator.GenericIndicator:

Public Member Functions

 GenericIndicator ()
 
Stream< GenericSiblingsgetSiblingPaths (String entityPath)
 
Stream< String > getEntityPaths (String entityRoot)
 
- Public Member Functions inherited from org.turro.indicator.AbstractIndicator
void initIndicator ()
 
void prepareIndicator ()
 
void generateSiblings ()
 
String getRoot ()
 
List< IndicatorVariablegetVariables ()
 
List< IndicatorVariablegetAllVariables ()
 
IndicatorVariable getVariable (String name)
 
List< IndicatorVariablegetAllRankingVariables (String root)
 
List< IndicatorVariablegetAllMatchingVariables (String root)
 
double getValue (IndicatorVariable variable, Object entity)
 
double getValue (IndicatorVariable variable, Object entity, String relatedPath)
 
IndicatorResult readIndicator (String storeClass, String indicator)
 
void preprocess (IndicatorVariable variable, IPreprocessor preprocessor, String entityRoot, String relatedRoot)
 
void postprocess (IndicatorVariable variable, IPreprocessor postprocessor, String entityRoot, String relatedRoot)
 
Dao getDao ()
 
boolean itsMine (String root)
 
boolean itsMine (IndicatorVariable variable)
 

Protected Member Functions

void initVariables ()
 
void initExternalVariables ()
 
Dao createDao ()
 
void processRankingVariable (Dao dao, IPreprocessor preprocessor, IndicatorVariable variable, String entityRoot)
 
void processMatchingVariable (Dao dao, IPreprocessor preprocessor, IndicatorVariable variable, String entityRoot, String relatedRoot)
 
- Protected Member Functions inherited from org.turro.indicator.AbstractIndicator
void addVariable (String name, VariableType type)
 
void addVariable (String name, VariableType type, boolean reversed)
 
void addVariable (String name, VariableType type, String avoid)
 
void addVariable (String name, boolean preprocess, VariableType type)
 
void addVariable (String name, boolean preprocess, VariableType type, boolean reversed)
 
void addVariable (String name, boolean preprocess, VariableType type, String avoid)
 
void addExternalVariable (String root, String name)
 
String getPath (Object entity)
 
void postprocessRankingVariable (Dao dao, IPreprocessor postprocessor, IndicatorVariable variable, String entityRoot)
 
void postprocessMatchingVariable (Dao dao, IPreprocessor postprocessor, IndicatorVariable variable, String entityRoot, String relatedRoot)
 

Additional Inherited Members

- Protected Attributes inherited from org.turro.indicator.AbstractIndicator
List< IndicatorVariablevariables = new ArrayList<>()
 
String root
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 38 of file GenericIndicator.java.

Constructor & Destructor Documentation

◆ GenericIndicator()

org.turro.indicator.GenericIndicator.GenericIndicator ( )

Definition at line 40 of file GenericIndicator.java.

40  {
41  root = "generic";
42  }

Member Function Documentation

◆ createDao()

Dao org.turro.indicator.GenericIndicator.createDao ( )
protected

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 55 of file GenericIndicator.java.

55  {
56  return new ContactsPU();
57  }
Here is the caller graph for this function:

◆ getEntityPaths()

Stream<String> org.turro.indicator.GenericIndicator.getEntityPaths ( String  entityRoot)

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 143 of file GenericIndicator.java.

143  {
144  Path path = new Path(entityRoot);
145  if("contact".equals(path.getRoot())) {
146  return createDao().stream(String.class, "select concat('/contact/', id) from Contact");
147  }
148  return null;
149  }
Here is the call graph for this function:

◆ getSiblingPaths()

Stream<GenericSiblings> org.turro.indicator.GenericIndicator.getSiblingPaths ( String  entityPath)

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 128 of file GenericIndicator.java.

128  {
129  Path path = new Path(entityPath);
130  if("contact".equals(path.getRoot())) {
131  WhereClause wc = new WhereClause();
132  wc.addClause("select new org.turro.matching.GenericSiblings(concat('/contact/', br.contact.id), concat('/contact/', br2.contact.id))");
133  wc.addClause("from BusinessRelation br, BusinessRelation br2");
134  wc.addClause("where br.business.id = br2.business.id");
135  wc.addClause("and br.business.inactive = false");
136  wc.addClause("and br.business.deactivated = false");
137  return createDao().stream(GenericSiblings.class, wc);
138  }
139  return null;
140  }
Here is the call graph for this function:

◆ initExternalVariables()

void org.turro.indicator.GenericIndicator.initExternalVariables ( )
protected

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 51 of file GenericIndicator.java.

51  {
52  }

◆ initVariables()

void org.turro.indicator.GenericIndicator.initVariables ( )
protected

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 45 of file GenericIndicator.java.

45  {
46  addVariable("stars", true, VariableType.BOTH_VARIABLE);
47  addVariable("comments", true, VariableType.BOTH_VARIABLE);
48  }
void addVariable(String name, VariableType type)
Here is the call graph for this function:

◆ processMatchingVariable()

void org.turro.indicator.GenericIndicator.processMatchingVariable ( Dao  dao,
IPreprocessor  preprocessor,
IndicatorVariable  variable,
String  entityRoot,
String  relatedRoot 
)
protected

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 91 of file GenericIndicator.java.

91  {
92  WhereClause wc = null;
93  if("contact".equals(relatedRoot)) {
94  switch(variable.getName()) {
95  case "stars":
96  wc = PreprocessClause.load("StarIt")
97  .setRankingRoot(entityRoot)
98  .setMatchingRoot(relatedRoot)
99  .setRankingField("path")
100  .setMatchingField("creator.id")
101  .setVariable(variable)
102  .setAggregate("avg(stars)")
103  .getClause();
104  break;
105  case "comments":
106  wc = PreprocessClause.load("CommentIt")
107  .setRankingRoot(entityRoot)
108  .setMatchingRoot(relatedRoot)
109  .setRankingField("path")
110  .setMatchingField("creator.id")
111  .setVariable(variable)
112  .setAggregate("count(id)")
113  .getClause();
114  break;
115  }
116  }
117  if(wc != null) {
118  try(Stream<GenericMatching> stream = dao.stream(GenericMatching.class, wc, 1000)) {
119  stream.forEach(r -> {
120  preprocessor.poolInstance(r.copyTo((IMatching) preprocessor.createInstance()));
121  });
122  preprocessor.finishPreprocessor();
123  }
124  }
125  }
Here is the call graph for this function:

◆ processRankingVariable()

void org.turro.indicator.GenericIndicator.processRankingVariable ( Dao  dao,
IPreprocessor  preprocessor,
IndicatorVariable  variable,
String  entityRoot 
)
protected

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 60 of file GenericIndicator.java.

60  {
61  WhereClause wc = null;
62  switch(variable.getName()) {
63  case "stars":
64  wc = PreprocessClause.load("StarIt")
65  .setRankingRoot(entityRoot)
66  .setRankingField("path")
67  .setVariable(variable)
68  .setAggregate("avg(stars)")
69  .getClause();
70  break;
71  case "comments":
72  wc = PreprocessClause.load("CommentIt")
73  .setRankingRoot(entityRoot)
74  .setRankingField("path")
75  .setVariable(variable)
76  .setAggregate("count(id)")
77  .getClause();
78  break;
79  }
80  if(wc != null) {
81  try(Stream<GenericRanking> stream = dao.stream(GenericRanking.class, wc, 1000)) {
82  stream.forEach(r -> {
83  preprocessor.poolInstance(r.copyTo((IRanking) preprocessor.createInstance()));
84  });
85  preprocessor.finishPreprocessor();
86  }
87  }
88  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: