register already known persons
This commit is contained in:
@@ -38,6 +38,7 @@ public class RegistrationController extends CommonController {
|
||||
model.addAttribute("bean", bean);
|
||||
model.addAttribute("sexes", EnumConverter.getSexes());
|
||||
model.addAttribute("roles", EnumConverter.getRoles());
|
||||
model.addAttribute("wellknown", service.getWellKnownRegistrations(getCurrentUser()));
|
||||
return "/registration/registration";
|
||||
} else {
|
||||
return "/registration/isover";
|
||||
|
||||
@@ -11,6 +11,8 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -27,6 +29,7 @@ import org.jooq.Record1;
|
||||
import org.jooq.Record2;
|
||||
import org.jooq.Record5;
|
||||
import org.jooq.Record7;
|
||||
import org.jooq.Record9;
|
||||
import org.jooq.SelectConditionStep;
|
||||
import org.jooq.UpdateConditionStep;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
@@ -418,4 +421,44 @@ public class RegistrationRepository {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the person information of already registered people
|
||||
*
|
||||
* @param currentUser the user that registered people
|
||||
* @return the list of found registrations, may be an empty list; if currentUser is null, return null.
|
||||
*/
|
||||
public List<RegistrationBean> getRegistrations(String currentUser) {
|
||||
SelectConditionStep<Record9<String, String, String, String, String, String, String, EnumSex, LocalDate>> sql = jooq
|
||||
// @formatter:off
|
||||
.selectDistinct(T_PERSON.FORENAME,
|
||||
T_PERSON.SURNAME,
|
||||
T_PERSON.STREET,
|
||||
T_PERSON.ZIP,
|
||||
T_PERSON.CITY,
|
||||
T_PERSON.PHONE,
|
||||
T_PERSON.EMAIL,
|
||||
T_PERSON.SEX,
|
||||
T_PERSON.BIRTHDATE)
|
||||
.from(T_PERSON)
|
||||
.innerJoin(T_PROFILE).on(T_PROFILE.PK.eq(T_PERSON.FK_PROFILE))
|
||||
.where(DSL.lower(T_PROFILE.USERNAME).eq(currentUser == null ? null : currentUser.toLowerCase()));
|
||||
// @formatter:on
|
||||
LOGGER.trace(sql);
|
||||
List<RegistrationBean> list = new ArrayList<>();
|
||||
for (Record r : sql.fetch()) {
|
||||
RegistrationBean bean = new RegistrationBean();
|
||||
bean.setForename(r.get(T_PERSON.FORENAME));
|
||||
bean.setSurname(r.get(T_PERSON.SURNAME));
|
||||
bean.setStreet(r.get(T_PERSON.STREET));
|
||||
bean.setZip(r.get(T_PERSON.ZIP));
|
||||
bean.setCity(r.get(T_PERSON.CITY));
|
||||
bean.setPhone(r.get(T_PERSON.PHONE));
|
||||
bean.setEmail(r.get(T_PERSON.EMAIL));
|
||||
bean.setSex(r.get(T_PERSON.SEX));
|
||||
bean.setBirthDate(r.get(T_PERSON.BIRTHDATE));
|
||||
list.add(bean);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package de.jottyfan.camporganizer.module.registration;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import de.jottyfan.camporganizer.module.camplist.model.BookingBean;
|
||||
import de.jottyfan.camporganizer.module.registration.model.AlreadyKnownPersonBean;
|
||||
import de.jottyfan.camporganizer.module.registration.model.CampBean;
|
||||
import de.jottyfan.camporganizer.module.registration.model.RegistrationBean;
|
||||
|
||||
@@ -54,7 +59,8 @@ public class RegistrationService {
|
||||
}
|
||||
Boolean result = gateway.register(bean);
|
||||
if (result && bean.getRegisterInKeycloak()) {
|
||||
keycloak.register(bean.getKcForename(), bean.getKcSurname(), bean.getLogin(), bean.getPassword(), bean.getKcEmail());
|
||||
keycloak.register(bean.getKcForename(), bean.getKcSurname(), bean.getLogin(), bean.getPassword(),
|
||||
bean.getKcEmail());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -81,4 +87,31 @@ public class RegistrationService {
|
||||
public void toggleConsent(Integer id) {
|
||||
gateway.toggleConsent(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* get already registered entries from the database
|
||||
*
|
||||
* @param currentUser the name of the current user; may be null
|
||||
* @return the list or null if current user is null
|
||||
*/
|
||||
public List<AlreadyKnownPersonBean> getWellKnownRegistrations(String currentUser) {
|
||||
if (currentUser == null) {
|
||||
return null;
|
||||
} else {
|
||||
List<RegistrationBean> r = gateway.getRegistrations(currentUser);
|
||||
if (r == null) {
|
||||
return null;
|
||||
} else {
|
||||
List<AlreadyKnownPersonBean> list = new ArrayList<>();
|
||||
for (RegistrationBean b : r) {
|
||||
AlreadyKnownPersonBean bean = new AlreadyKnownPersonBean();
|
||||
bean.setSource(b);
|
||||
bean.setOption(String.format("%s %s, %s, %s %s, %s, %s", b.getForename(), b.getSurname(), b.getStreet(),
|
||||
b.getZip(), b.getCity(), b.getEmail(), b.getPhone()));
|
||||
list.add(bean);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user