19 package org.turro.admin;
22 import java.io.IOException;
23 import java.util.List;
24 import java.util.function.BiConsumer;
25 import org.turro.action.IMailSender;
26 import org.turro.action.MailSenders;
27 import org.turro.auth.Authentication;
28 import org.turro.collections.CumulativeList;
29 import org.turro.contacts.BusinessRelation;
30 import org.turro.contacts.ContactType;
31 import org.turro.contacts.db.ContactsPU;
32 import org.turro.elephant.context.ElephantContext;
33 import org.turro.exporter.FieldsExporter;
34 import org.turro.i18n.I_;
35 import org.turro.log.WebLoggers;
36 import org.turro.message.MessageQueue;
37 import org.turro.plugin.contacts.IContact;
38 import org.turro.sql.SqlClause;
53 return "Students by center";
70 File result = File.createTempFile(
"report",
"_Students.csv");
71 FieldsExporter.of(getEntries()).export(result);
74 }
catch (IOException ex) {
75 WebLoggers.severe(
this).exception(ex).log();
79 private List<StudentsEntry> getEntries() {
80 BiConsumer<StudentsEntry, BusinessRelation> consumer = (e, p) -> {
81 e.name = p.getContact().getName();
82 e.position = p.getFormattedDescription();
83 e.center = p.getBusiness().getName();
85 return CumulativeList.of(StudentsEntry.class)
86 .forEach(SqlClause.select(
"br").from(
"BusinessRelation br")
87 .where().equal(
"br.business.type", ContactType.CONTACT_LEARNINGCENTER)
88 .dao(
new ContactsPU())
89 .resultList(BusinessRelation.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)