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

Public Member Functions

 ContactIndicator ()
 
void generateSiblings ()
 
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 ()
 
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)
 
void postprocessRankingVariable (Dao dao, IPreprocessor preprocessor, IndicatorVariable variable, String entityRoot)
 
- 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 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 49 of file ContactIndicator.java.

Constructor & Destructor Documentation

◆ ContactIndicator()

org.turro.indicator.ContactIndicator.ContactIndicator ( )

Definition at line 51 of file ContactIndicator.java.

51  {
52  root = "contact";
53  }

Member Function Documentation

◆ createDao()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 110 of file ContactIndicator.java.

110  {
111  return new ContactsPU();
112  }
Here is the caller graph for this function:

◆ generateSiblings()

void org.turro.indicator.ContactIndicator.generateSiblings ( )

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 82 of file ContactIndicator.java.

82  {
83  List<LogCount> genact = Logs.getGeneratorActivityCount(new CheckDate().addYears(-2).getDate());
84  SqlClause.update("Contact").set("inactive", true)
85  .dao(getDao()).execute();
86  try(Stream<Contact> stream = createDao().stream(Contact.class, "select c from Contact c")) {
87  stream.forEach(contact -> {
88  if(genact.contains(new LogCount("/contact/" + contact.getId(), 0))) {
89  SqlClause.update("Contact").set("inactive", false)
90  .where().equal("id", contact.getId())
91  .dao(getDao()).execute();
92  }
93  });
94  }
95  try(Stream<Contact> stream = SqlClause.select("distinct c").from("Contact c")
96  .where().in("c.type", List.copyOf(ContactType.juridicals()))
97  .and().exists(SqlClause.select("r").from("BusinessRelation r")
98  .where("r.business.id = c.id")
99  .and().equal("r.contact.inactive", false))
100  .dao(createDao()).stream(Contact.class)) {
101  stream.forEach(contact -> {
102  SqlClause.update("Contact").set("inactive", false)
103  .where().equal("id", contact.getId())
104  .dao(getDao()).execute();
105  });
106  }
107  }
Here is the call graph for this function:

◆ getValue() [1/2]

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 115 of file ContactIndicator.java.

115  {
116  if((entity instanceof Contact) && itsMine(variable)) {
117  Contact contact = (Contact) entity;
118  switch(variable.getName()) {
119  case "profile":
120  return contact.getProfile().getCompletion().getPercent();
121  }
122  }
123  return 0.0;
124  }
Here is the call graph for this function:

◆ getValue() [2/2]

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 127 of file ContactIndicator.java.

127  {
128  if((entity instanceof Contact) && itsMine(variable)) {
129  Contact contact = (Contact) entity;
130  IElephantEntity related = Entities.getController(relatedPath);
131  if("contact".equals(related.getRoot())) {
132  switch(variable.getName()) {
133  case "distance":
134  if(contact.hasLocation()) {
135  Contact crelated = (Contact) related.getEntity();
136  if(crelated.hasLocation()) {
137  return ZipCodeAPI.distanceOrZero(contact.getLatitude(), crelated.getLatitude(),
138  contact.getLongitude(), crelated.getLongitude());
139  }
140  }
141  }
142  }
143  }
144  return 0.0;
145  }
Here is the call graph for this function:

◆ initExternalVariables()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 63 of file ContactIndicator.java.

63  {
64  addExternalVariable("dossier", "participation");
65  addExternalVariable("dossier", "categoryParticipation");
66  addExternalVariable("dossier", "issueResponsible");
67  addExternalVariable("dossier", "issueReporter");
68  addExternalVariable("dossier", "issueQA");
69  addExternalVariable("dossier", "issueAssistant");
70  addExternalVariable("student", "challenges");
71  addExternalVariable("student", "responses");
72  addExternalVariable("student", "responsesLike");
73  addExternalVariable("forum", "topics");
74  addExternalVariable("forum", "posts");
75  addExternalVariable("commons", "following");
76  addExternalVariable("commons", "followed");
77  addExternalVariable("commons", "seen");
78  addExternalVariable("commons", "like");
79  }
void addExternalVariable(String root, String name)
Here is the call graph for this function:

◆ initVariables()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 56 of file ContactIndicator.java.

56  {
57  addVariable("available", true, VariableType.RANKING_VARIABLE);
58  addVariable("profile", VariableType.RANKING_VARIABLE);
59  addVariable("distance", VariableType.MATCHING_VARIABLE, true);
60  }
void addVariable(String name, VariableType type)
Here is the call graph for this function:

◆ postprocessRankingVariable()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 193 of file ContactIndicator.java.

193  {
194  if("contact".equals(entityRoot)) {
195  try(Stream<Contact> stream = getJuridicals()) {
196  stream.forEach(juridical -> {
197  List<String> springPaths = getSpringPaths(juridical);
198  if(!springPaths.isEmpty()) {
199  WhereClause wc = PostprocessClause.load(preprocessor.tableName())
200  .setEntityPath(ContactsPU.getObjectPath(juridical))
201  .setSpringPaths(springPaths)
202  .getRankingClause();
203  if(wc != null) {
204  try(Stream<GenericRanking> istream = dao.stream(GenericRanking.class, wc, 1000)) {
205  istream.forEach(r -> {
206  if(r != null && !Zero.near(r.getRanking(), 2)) {
207  preprocessor.poolInstance(r.copyTo((IRanking) preprocessor.createInstance()));
208  }
209  });
210  }
211  }
212  }
213  });
214  preprocessor.finishPreprocessor();
215  }
216  }
217  }
Here is the call graph for this function:

◆ processMatchingVariable()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 174 of file ContactIndicator.java.

174  {
175  WhereClause wc = null;
176  if("contact".equals(entityRoot)) {
177  if("contact".equals(relatedRoot)) {
178  switch(variable.getName()) {
179  }
180  }
181  }
182  if(wc != null) {
183  try(Stream<GenericMatching> stream = dao.stream(GenericMatching.class, wc, 1000)) {
184  stream.forEach(r -> {
185  preprocessor.poolInstance(r.copyTo((IMatching) preprocessor.createInstance()));
186  });
187  preprocessor.finishPreprocessor();
188  }
189  }
190  }
Here is the call graph for this function:

◆ processRankingVariable()

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

Reimplemented from org.turro.indicator.AbstractIndicator.

Definition at line 148 of file ContactIndicator.java.

148  {
149  WhereClause wc = null;
150  if("contact".equals(entityRoot)) {
151  switch(variable.getName()) {
152  case "available":
153  wc = PreprocessClause.load("JobBoard")
154  .addCondition("and available = TRUE")
155  .setRankingRoot(entityRoot)
156  .setRankingField("concat('/contact/',contact.id)")
157  .setVariable(variable)
158  .setAggregate("count(id)")
159  .getClause();
160  break;
161  }
162  }
163  if(wc != null) {
164  try(Stream<GenericRanking> stream = dao.stream(GenericRanking.class, wc, 1000)) {
165  stream.forEach(r -> {
166  preprocessor.poolInstance(r.copyTo((IRanking) preprocessor.createInstance()));
167  });
168  preprocessor.finishPreprocessor();
169  }
170  }
171  }
Here is the call graph for this function:

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