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

Public Member Functions

 ServiceIndicator ()
 
double getValue (IndicatorVariable variable, Object entity)
 
- 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, 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 38 of file ServiceIndicator.java.

Constructor & Destructor Documentation

◆ ServiceIndicator()

org.turro.indicator.ServiceIndicator.ServiceIndicator ( )

Definition at line 40 of file ServiceIndicator.java.

40  {
41  root = "service";
42  }

Member Function Documentation

◆ createDao()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 65 of file ServiceIndicator.java.

65  {
66  return new ContactsPU();
67  }

◆ getValue()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 70 of file ServiceIndicator.java.

70  {
71  if((entity instanceof ContactService) && itsMine(variable)) {
72  ContactService service = (ContactService) entity;
73  switch(variable.getName()) {
74  case "daysCreation":
75  return service.getCreation() != null ? Duration.between(service.getCreation().toInstant(), Instant.now()).toDays() : 9999.9;
76  case "daysStart":
77  return service.getStartDate()!= null ? Duration.between(service.getStartDate().toInstant(), Instant.now()).toDays() : 9999.9;
78  case "daysEnd":
79  return service.getEndDate()!= null ? Duration.between(service.getEndDate().toInstant(), Instant.now()).toDays() : 9999.9;
80  case "words":
81  return countWords(service);
82  }
83  }
84  return 0.0;
85  }
Here is the call graph for this function:

◆ initExternalVariables()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 54 of file ServiceIndicator.java.

54  {
55  addExternalVariable("generic", "stars");
56  addExternalVariable("generic", "comments");
57  addExternalVariable("forum", "topics");
58  addExternalVariable("forum", "posts");
59  addExternalVariable("commons", "followed");
60  addExternalVariable("commons", "seen");
61  addExternalVariable("commons", "like");
62  }
void addExternalVariable(String root, String name)
Here is the call graph for this function:

◆ initVariables()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 45 of file ServiceIndicator.java.

45  {
46  addVariable("participation", true, VariableType.MATCHING_VARIABLE);
47  addVariable("daysCreation", VariableType.RANKING_VARIABLE);
48  addVariable("daysStart", VariableType.RANKING_VARIABLE);
49  addVariable("daysEnd", VariableType.RANKING_VARIABLE);
50  addVariable("words", VariableType.RANKING_VARIABLE);
51  }
void addVariable(String name, VariableType type)
Here is the call graph for this function:

◆ processMatchingVariable()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 92 of file ServiceIndicator.java.

92  {
93  WhereClause wc = null;
94  if("contact".equals(relatedRoot)) {
95  switch(variable.getName()) {
96  case "participation":
97  wc = PreprocessClause.load("ContactService")
98  .setRankingRoot(entityRoot)
99  .setMatchingRoot(relatedRoot)
100  .setRankingField("concat('/service/',id)")
101  .setMatchingField("responsible.id")
102  .setVariable(variable)
103  .setAggregate("count(id)")
104  .getClause();
105  break;
106  }
107  }
108  if(wc != null) {
109  try(Stream<GenericMatching> stream = dao.stream(GenericMatching.class, wc, 1000)) {
110  stream.forEach(r -> {
111  preprocessor.poolInstance(r.copyTo((IMatching) preprocessor.createInstance()));
112  });
113  preprocessor.finishPreprocessor();
114  }
115  }
116  }
Here is the call graph for this function:

◆ processRankingVariable()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 88 of file ServiceIndicator.java.

88  {
89  }

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