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

Public Member Functions

 CommonsIndicator ()
 
- 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)
 
Stream< String > getEntityPaths (String root)
 
Stream< GenericSiblingsgetSiblingPaths (String entityPath)
 
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 37 of file CommonsIndicator.java.

Constructor & Destructor Documentation

◆ CommonsIndicator()

org.turro.indicator.CommonsIndicator.CommonsIndicator ( )

Definition at line 39 of file CommonsIndicator.java.

39  {
40  root = "commons";
41  }

Member Function Documentation

◆ createDao()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 57 of file CommonsIndicator.java.

57  {
58  return new ElephantPU();
59  }

◆ initExternalVariables()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 53 of file CommonsIndicator.java.

53  {
54  }

◆ initVariables()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 44 of file CommonsIndicator.java.

44  {
45  addVariable("following", true, VariableType.BOTH_VARIABLE);
46  addVariable("followed", true, VariableType.BOTH_VARIABLE);
47  addVariable("seen", true, VariableType.BOTH_VARIABLE);
48  addVariable("like", true, VariableType.BOTH_VARIABLE);
49  addVariable("apply", true, VariableType.BOTH_VARIABLE);
50  }
void addVariable(String name, VariableType type)
Here is the call graph for this function:

◆ processMatchingVariable()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 172 of file CommonsIndicator.java.

172  {
173  WhereClause wc = null;
174  if("contact".equals(relatedRoot)) {
175  switch(variable.getName()) {
176  case "following":
177  wc = PreprocessClause.load("EntityParticipation")
178  .addCondition("and reason = :reason")
179  .addNamedValue("reason", ParticipationReason.REASON_FOLLOW)
180  .setRankingRoot(entityRoot)
181  .setMatchingRoot(relatedRoot)
182  .setRankingField("entityPath")
183  .setMatchingField("participatorPath")
184  .setMatchingIsPath()
185  .setVariable(variable)
186  .setAggregate("count(entityPath)")
187  .getClause();
188  break;
189  case "followed":
190  wc = PreprocessClause.load("EntityParticipation")
191  .addCondition("and reason = :reason")
192  .addNamedValue("reason", ParticipationReason.REASON_FOLLOW)
193  .setRankingRoot(relatedRoot)
194  .setMatchingRoot(entityRoot)
195  .setRankingField("participatorPath")
196  .setMatchingField("entityPath")
197  .setMatchingIsPath()
198  .setVariable(variable)
199  .setAggregate("count(participatorPath)")
200  .getClause();
201  break;
202  case "seen":
203  wc = PreprocessClause.load("EntityParticipation")
204  .addCondition("and reason = :reason")
205  .addNamedValue("reason", ParticipationReason.REASON_SEEN)
206  .setRankingRoot(entityRoot)
207  .setMatchingRoot(relatedRoot)
208  .setRankingField("entityPath")
209  .setMatchingField("participatorPath")
210  .setMatchingIsPath()
211  .setVariable(variable)
212  .setAggregate("count(entityPath)")
213  .getClause();
214  break;
215  case "like":
216  wc = PreprocessClause.load("EntityParticipation")
217  .addCondition("and reason = :reason")
218  .addNamedValue("reason", ParticipationReason.REASON_LIKE)
219  .setRankingRoot(entityRoot)
220  .setMatchingRoot(relatedRoot)
221  .setRankingField("entityPath")
222  .setMatchingField("participatorPath")
223  .setMatchingIsPath()
224  .setVariable(variable)
225  .setAggregate("count(entityPath)")
226  .getClause();
227  break;
228  case "apply":
229  wc = PreprocessClause.load("EntityParticipation")
230  .addCondition("and reason = :reason")
231  .addNamedValue("reason", ParticipationReason.REASON_APPLY)
232  .setRankingRoot(entityRoot)
233  .setMatchingRoot(relatedRoot)
234  .setRankingField("entityPath")
235  .setMatchingField("participatorPath")
236  .setMatchingIsPath()
237  .setVariable(variable)
238  .setAggregate("count(entityPath)")
239  .getClause();
240  break;
241  }
242  }
243  if(wc != null) {
244  try(Stream<GenericMatching> stream = dao.stream(GenericMatching.class, wc, 1000)) {
245  stream.forEach(r -> {
246  preprocessor.poolInstance(r.copyTo((IMatching) preprocessor.createInstance()));
247  });
248  preprocessor.finishPreprocessor();
249  }
250  }
251  }
Here is the call graph for this function:

◆ processRankingVariable()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 62 of file CommonsIndicator.java.

62  {
63  WhereClause wc = null;
64  if("contact".equals(entityRoot)) {
65  switch(variable.getName()) {
66  case "following":
67  wc = PreprocessClause.load("EntityParticipation")
68  .addCondition("and reason = :reason")
69  .addNamedValue("reason", ParticipationReason.REASON_FOLLOW)
70  .setRankingRoot(entityRoot)
71  .setRankingField("participatorPath")
72  .setVariable(variable)
73  .setAggregate("count(entityPath)")
74  .getClause();
75  break;
76  case "followed":
77  wc = PreprocessClause.load("EntityParticipation")
78  .addCondition("and reason = :reason")
79  .addNamedValue("reason", ParticipationReason.REASON_FOLLOW)
80  .setRankingRoot(entityRoot)
81  .setRankingField("entityPath")
82  .setVariable(variable)
83  .setAggregate("count(participatorPath)")
84  .getClause();
85  break;
86  case "seen":
87  wc = PreprocessClause.load("EntityParticipation")
88  .addCondition("and reason = :reason")
89  .addNamedValue("reason", ParticipationReason.REASON_SEEN)
90  .setRankingRoot(entityRoot)
91  .setRankingField("participatorPath")
92  .setVariable(variable)
93  .setAggregate("count(entityPath)")
94  .getClause();
95  break;
96  case "like":
97  wc = PreprocessClause.load("EntityParticipation")
98  .addCondition("and reason = :reason")
99  .addNamedValue("reason", ParticipationReason.REASON_LIKE)
100  .setRankingRoot(entityRoot)
101  .setRankingField("participatorPath")
102  .setVariable(variable)
103  .setAggregate("count(entityPath)")
104  .getClause();
105  break;
106  case "apply":
107  wc = PreprocessClause.load("EntityParticipation")
108  .addCondition("and reason = :reason")
109  .addNamedValue("reason", ParticipationReason.REASON_APPLY)
110  .setRankingRoot(entityRoot)
111  .setRankingField("participatorPath")
112  .setVariable(variable)
113  .setAggregate("count(entityPath)")
114  .getClause();
115  break;
116  }
117  } else {
118  switch(variable.getName()) {
119  case "followed":
120  wc = PreprocessClause.load("EntityParticipation")
121  .addCondition("and reason = :reason")
122  .addNamedValue("reason", ParticipationReason.REASON_FOLLOW)
123  .setRankingRoot(entityRoot)
124  .setRankingField("entityPath")
125  .setVariable(variable)
126  .setAggregate("count(entityPath)")
127  .getClause();
128  break;
129  case "seen":
130  wc = PreprocessClause.load("EntityParticipation")
131  .addCondition("and reason = :reason")
132  .addNamedValue("reason", ParticipationReason.REASON_SEEN)
133  .setRankingRoot(entityRoot)
134  .setRankingField("entityPath")
135  .setVariable(variable)
136  .setAggregate("count(entityPath)")
137  .getClause();
138  break;
139  case "like":
140  wc = PreprocessClause.load("EntityParticipation")
141  .addCondition("and reason = :reason")
142  .addNamedValue("reason", ParticipationReason.REASON_LIKE)
143  .setRankingRoot(entityRoot)
144  .setRankingField("entityPath")
145  .setVariable(variable)
146  .setAggregate("count(entityPath)")
147  .getClause();
148  break;
149  case "apply":
150  wc = PreprocessClause.load("EntityParticipation")
151  .addCondition("and reason = :reason")
152  .addNamedValue("reason", ParticipationReason.REASON_APPLY)
153  .setRankingRoot(entityRoot)
154  .setRankingField("entityPath")
155  .setVariable(variable)
156  .setAggregate("count(entityPath)")
157  .getClause();
158  break;
159  }
160  }
161  if(wc != null) {
162  try(Stream<GenericRanking> stream = dao.stream(GenericRanking.class, wc, 1000)) {
163  stream.forEach(r -> {
164  preprocessor.poolInstance(r.copyTo((IRanking) preprocessor.createInstance()));
165  });
166  preprocessor.finishPreprocessor();
167  }
168  }
169  }
Here is the call graph for this function:

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