19 package org.turro.indicator;
21 import java.time.Duration;
22 import java.time.Instant;
23 import java.util.Date;
24 import java.util.stream.Stream;
25 import org.turro.string.Strings;
26 import org.turro.annotation.ElephantIndicator;
27 import org.turro.dossier.db.DossierPU;
28 import org.turro.dossier.entity.DescriptorValue;
29 import org.turro.dossier.entity.Dossier;
30 import org.turro.dossier.entity.IssueParticipantRole;
31 import org.turro.elephant.db.WhereClause;
32 import org.turro.jpa.Dao;
33 import org.turro.matching.ContactSiblings;
34 import org.turro.matching.GenericMatching;
35 import org.turro.matching.GenericSiblings;
36 import org.turro.matching.IMatching;
37 import org.turro.ranking.GenericRanking;
38 import org.turro.ranking.IRanking;
102 return dossier.
getCreation() !=
null ? Duration.between(dossier.
getCreation().toInstant(), Instant.now()).toDays() : 9999.9;
104 return getDaysLastActivity(dossier);
106 return countWords(dossier);
115 if(
"dossier".equals(entityRoot)) {
117 case "participation":
125 case "categoryParticipation":
127 .
addCondition(
"and d.category.fullDescription like concat(cp.category.fullDescription, '%')")
142 case "issueActivity":
151 }
else if(
"contact".equals(entityRoot)) {
153 case "participation":
161 case "categoryParticipation":
169 case "issueResponsible":
179 case "issueReporter":
199 case "issueAssistant":
212 try(Stream<GenericRanking> stream = dao.stream(
GenericRanking.class, wc, 1000)) {
213 stream.forEach(r -> {
224 if(
"dossier".equals(entityRoot)) {
225 if(
"contact".equals(relatedRoot)) {
227 case "participation":
237 case "categoryParticipation":
239 .
addCondition(
"and d.category.fullDescription like concat(cp.category.fullDescription, '%')")
258 case "issueActivity":
270 .
addJoin(
"join ContactSiblings cs on cs.entityPath = concat('/contact/', p.idContact)")
280 case "siblingsCategory":
282 .
addCondition(
"and d.category.fullDescription like concat(cp.category.fullDescription, '%')")
283 .
addCondition(
"and concat('/contact/', cp.idContact) = cs.entityPath")
297 try(Stream<GenericMatching> stream = dao.stream(
GenericMatching.class, wc, 1000)) {
298 stream.forEach(r -> {
306 private double countWords(
Dossier dossier) {
312 count += Strings.countWords(dv.getWiki());
317 private double getDaysLastActivity(Dossier dossier) {
318 Date last = dossier.getLastActivity();
319 return last !=
null ? Duration.between(last.toInstant(), Instant.now()).toDays() : 0.0;
Set< DescriptorValue > getDescriptors()
void addVariable(String name, VariableType type)
boolean itsMine(String root)
void addExternalVariable(String root, String name)
void processMatchingVariable(Dao dao, IPreprocessor preprocessor, IndicatorVariable variable, String entityRoot, String relatedRoot)
double getValue(IndicatorVariable variable, Object entity)
void initExternalVariables()
void processRankingVariable(Dao dao, IPreprocessor preprocessor, IndicatorVariable variable, String entityRoot)
static IElephantIndicator getIndicator(String root)
PreprocessClause setMatchingField(String pathField)
PreprocessClause addCondition(String condition)
PreprocessClause setVariable(IndicatorVariable variable)
PreprocessClause setMatchingIsPath()
PreprocessClause addJoin(String join)
PreprocessClause setMatchingRoot(String entityRoot)
PreprocessClause addNamedValue(String name, Object value)
PreprocessClause setAggregate(String aggregate)
PreprocessClause setRankingRoot(String entityRoot)
static PreprocessClause load(String table)
PreprocessClause setRankingField(String pathField)
int executeNativeUpdate(SqlClause sc, Object... pars)
Stream< GenericSiblings > getSiblingPaths(String entityPath)
void poolInstance(Object value)
void finishPreprocessor()