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

Public Member Functions

 StudentIndicator ()
 
double getValue (IndicatorVariable variable, Object entity)
 
double getValue (IndicatorVariable variable, Object entity, String relatedPath)
 
- 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)
 
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 50 of file StudentIndicator.java.

Constructor & Destructor Documentation

◆ StudentIndicator()

org.turro.indicator.StudentIndicator.StudentIndicator ( )

Definition at line 52 of file StudentIndicator.java.

52  {
53  root = "student";
54  }

Member Function Documentation

◆ createDao()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 73 of file StudentIndicator.java.

73  {
74  return new StudentsPU();
75  }

◆ getValue() [1/2]

double org.turro.indicator.StudentIndicator.getValue ( IndicatorVariable  variable,
Object  entity 
)

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 78 of file StudentIndicator.java.

78  {
79  if((entity instanceof Challenge) && itsMine(variable)) {
80  Challenge challenge = (Challenge) entity;
81  switch(variable.getName()) {
82  case "responses":
83  return getResponsesFor(challenge);
84  case "responsesLike":
85  return getResponsesLikeFor(challenge);
86  case "daysCreation":
87  return challenge.getCreation() != null ? Duration.between(challenge.getCreation().toInstant(), Instant.now()).toDays() : 9999.9;
88  }
89  } else if((entity instanceof Contact) && itsMine(variable)) {
90  Contact contact = (Contact) entity;
91  switch(variable.getName()) {
92  case "responses":
93  return getResponsesFor(contact);
94  case "responsesLike":
95  return getResponsesLikeFor(contact);
96  }
97  } else if((entity instanceof PracticalWork) && itsMine(variable)) {
98  PracticalWork practicalWork = (PracticalWork) entity;
99  switch(variable.getName()) {
100  case "daysCreation":
101  return practicalWork.getCreation() != null ? Duration.between(practicalWork.getCreation().toInstant(), Instant.now()).toDays() : 9999.9;
102  }
103  } else {
104  switch(variable.getName()) {
105  case "responses":
106  return getResponsesFor(entity);
107  case "responsesLike":
108  return getResponsesLikeFor(entity);
109  }
110  }
111  return 0.0;
112  }
Here is the call graph for this function:

◆ getValue() [2/2]

double org.turro.indicator.StudentIndicator.getValue ( IndicatorVariable  variable,
Object  entity,
String  relatedPath 
)

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 115 of file StudentIndicator.java.

115  {
116  if((entity instanceof PracticalWork) && itsMine(variable)) {
117  PracticalWork practicalWork = (PracticalWork) entity;
118  IElephantEntity related = Entities.getController(relatedPath);
119  if("contact".equals(related.getRoot())) {
120  switch(variable.getName()) {
121  case "distance":
122  if(!Strings.isBlank(practicalWork.getZipCode())) {
123  Contact crelated = (Contact) related.getEntity();
124  JobBoard jobBoard = crelated.getJobBoard();
125  if(jobBoard != null && !Strings.isBlank(jobBoard.getZipCode())) {
126  return ZipCodeAPI.distanceOrZero(practicalWork.getZipCode(), jobBoard.getZipCode());
127  }
128  }
129  }
130  }
131  }
132  return 0.0;
133  }
Here is the call graph for this function:

◆ initExternalVariables()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 66 of file StudentIndicator.java.

66  {
67  addExternalVariable("commons", "followed");
68  addExternalVariable("commons", "like");
69  addExternalVariable("commons", "apply");
70  }
void addExternalVariable(String root, String name)
Here is the call graph for this function:

◆ initVariables()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 57 of file StudentIndicator.java.

57  {
58  addVariable("challenges", true, VariableType.RANKING_VARIABLE);
59  addVariable("responses", VariableType.RANKING_VARIABLE);
60  addVariable("responsesLike", VariableType.RANKING_VARIABLE);
61  addVariable("daysCreation", VariableType.RANKING_VARIABLE);
62  addVariable("distance", VariableType.MATCHING_VARIABLE);
63  }
void addVariable(String name, VariableType type)
Here is the call graph for this function:

◆ processMatchingVariable()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 172 of file StudentIndicator.java.

172  {
173  WhereClause wc = null;
174  if("contact".equals(relatedRoot)) {
175  if("contact".equals(entityRoot)) {
176  switch(variable.getName()) {
177  }
178  } else if("praticalwork".equals(entityRoot)) {
179  switch(variable.getName()) {
180  }
181  } else {
182  switch(variable.getName()) {
183  case "challenges":
184  wc = PreprocessClause.load("Challenge")
185  .setRankingRoot(entityRoot)
186  .setMatchingRoot(relatedRoot)
187  .setRankingField("entityPath")
188  .setMatchingField("idChallenger")
189  .setVariable(variable)
190  .setAggregate("count(c.id)")
191  .getClause();
192  break;
193  }
194  }
195  }
196  if(wc != null) {
197  try(Stream<GenericMatching> stream = dao.stream(GenericMatching.class, wc, 1000)) {
198  stream.forEach(r -> {
199  preprocessor.poolInstance(r.copyTo((IMatching) preprocessor.createInstance()));
200  });
201  preprocessor.finishPreprocessor();
202  }
203  }
204  }
Here is the call graph for this function:

◆ processRankingVariable()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 136 of file StudentIndicator.java.

136  {
137  WhereClause wc = null;
138  if("contact".equals(entityRoot)) {
139  switch(variable.getName()) {
140  case "challenges":
141  wc = PreprocessClause.load("Challenge")
142  .setRankingRoot(entityRoot)
143  .setRankingField("concat('/contact/',idChallenger)")
144  .setVariable(variable)
145  .setAggregate("count(id)")
146  .getClause();
147  break;
148  }
149  } else {
150  switch(variable.getName()) {
151  case "challenges":
152  wc = PreprocessClause.load("Challenge")
153  .setRankingRoot(entityRoot)
154  .setRankingField("entityPath")
155  .setVariable(variable)
156  .setAggregate("count(id)")
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: