19 package org.turro.admin;
22 import java.io.IOException;
23 import java.util.List;
24 import java.util.Optional;
25 import java.util.function.BiConsumer;
26 import org.turro.action.IMailSender;
27 import org.turro.action.MailSenders;
28 import org.turro.auth.Authentication;
29 import org.turro.collections.CumulativeList;
30 import org.turro.contacts.BusinessRelation;
31 import org.turro.contacts.Contact;
32 import org.turro.contacts.relation.Business;
33 import org.turro.dossier.db.DossierPU;
34 import org.turro.dossier.entity.Participant;
35 import org.turro.elephant.context.ElephantContext;
36 import org.turro.exporter.FieldsExporter;
37 import org.turro.i18n.I_;
38 import org.turro.log.WebLoggers;
39 import org.turro.message.MessageQueue;
40 import org.turro.plugin.contacts.IContact;
41 import org.turro.sql.SqlClause;
42 import org.turro.string.Strings;
43 import org.turro.tags.Tags;
58 return "Participations in dossiers";
72 private void participationToCSV(
IMailSender sender) {
75 File result = File.createTempFile(
"report",
"_Participation.csv");
76 FieldsExporter.of(getEntries()).export(result);
79 }
catch (IOException ex) {
80 WebLoggers.severe(
this).exception(ex).log();
84 private List<ParticipationEntry> getEntries() {
85 BiConsumer<ParticipationEntry, Participant> consumer = (e, p) -> {
86 e.creation = p.getCreation();
87 e.category = p.getDossier().getCategory().getDescription();
88 e.identifier = p.getDossier().getId();
89 e.dossier = p.getDossier().getDescription();
90 e.project = Optional.ofNullable(p.getDossier().getProject()).map(c -> c.getProjectCode()).orElse(
"");
91 e.participation = Strings.listToCvs(p.getStringRoles());
92 e.email = p.getIContact().getEmail();
93 e.name = p.getIContact().getName();
94 Business business =
new Business((Contact) p.getIContact().getContact());
95 BusinessRelation relation = business.getBusinessRelation(p.getCreation());
96 e.position = Optional.ofNullable(relation).map(r -> r.getFormattedDescription()).orElse(
"");
97 e.company = Optional.ofNullable(relation).map(r -> r.getBusiness()).map(b -> b.getName()).orElse(
"");
98 e.tags = Tags.tagsString(p.getDossier());
100 return CumulativeList.of(ParticipationEntry.class)
101 .forEach(SqlClause.select(
"p").from(
"Participant p")
102 .dao(
new DossierPU())
103 .resultList(Participant.class),
static IMailSender getHeavy()
static boolean isAdministrator()
static IContact getIContact()
static String get(String msg)
static void pushMessage(IContact contact, String msg)
IMailSender onFinish(Consumer command)
IMailSender addAttachment(File file)