19 package org.turro.indicator;
21 import java.util.List;
22 import java.util.stream.Collectors;
23 import java.util.stream.Stream;
24 import org.amic.util.date.CheckDate;
25 import org.turro.annotation.ElephantIndicator;
26 import org.turro.contacts.Contact;
27 import org.turro.contacts.ContactType;
28 import org.turro.contacts.db.ContactsPU;
29 import org.turro.contacts.relation.FuzzyRelationTypes;
30 import org.turro.elephant.db.WhereClause;
31 import org.turro.entities.Entities;
32 import org.turro.entities.IElephantEntity;
33 import org.turro.jpa.Dao;
34 import org.turro.log.LogCount;
35 import org.turro.log.Logs;
36 import org.turro.matching.GenericMatching;
37 import org.turro.matching.IMatching;
38 import org.turro.math.Zero;
39 import org.turro.ranking.GenericRanking;
40 import org.turro.ranking.IRanking;
41 import org.turro.sql.SqlClause;
42 import org.turro.zipcode.ZipCodeAPI;
84 SqlClause.update(
"Contact").set(
"inactive",
true)
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();
95 try(Stream<Contact> stream = SqlClause.select(
"distinct c").from(
"Contact c")
97 .and().exists(SqlClause.select(
"r").from(
"BusinessRelation r")
98 .where(
"r.business.id = c.id")
99 .and().equal(
"r.contact.inactive",
false))
101 stream.forEach(contact -> {
102 SqlClause.update(
"Contact").
set(
"inactive",
false)
103 .where().equal(
"id", contact.getId())
131 if(
"contact".equals(related.
getRoot())) {
150 if(
"contact".equals(entityRoot)) {
164 try(Stream<GenericRanking> stream = dao.stream(
GenericRanking.class, wc, 1000)) {
165 stream.forEach(r -> {
176 if(
"contact".equals(entityRoot)) {
177 if(
"contact".equals(relatedRoot)) {
183 try(Stream<GenericMatching> stream = dao.stream(
GenericMatching.class, wc, 1000)) {
184 stream.forEach(r -> {
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()) {
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()));
219 private Stream<Contact> getJuridicals() {
221 wc.
addClause(
"select contact from Contact contact");
226 private List<String> getSpringPaths(Contact contact) {
227 return contact.getWorkers().stream().map(c ->
"/contact/" + c.getId()).collect(Collectors.toList());
void addClause(String clause)
static IElephantEntity getController(String path)
void addVariable(String name, VariableType type)
boolean itsMine(String root)
void addExternalVariable(String root, String name)
PostprocessClause setSpringPaths(List< String > springPaths)
WhereClause getRankingClause()
static PostprocessClause load(String table)
PostprocessClause setEntityPath(String entityPath)
PreprocessClause addCondition(String condition)
PreprocessClause setVariable(IndicatorVariable variable)
PreprocessClause setAggregate(String aggregate)
PreprocessClause setRankingRoot(String entityRoot)
static PreprocessClause load(String table)
PreprocessClause setRankingField(String pathField)
static List< LogCount > getGeneratorActivityCount(Date from)
static boolean near(double value, int digits)
void poolInstance(Object value)
void finishPreprocessor()