doublicated controller and data from original ClubhelperBackend.

REL-BRANCH-ClubhelperModel-0.0.1
kre6513 5 years ago
parent 8bb9156ac5
commit 4c07bc2b90
  1. 5
      pom.xml
  2. 11
      src/main/java/de/kreth/clubhelper/model/controller/AttendanceController.java
  3. 11
      src/main/java/de/kreth/clubhelper/model/controller/ContactController.java
  4. 4
      src/main/java/de/kreth/clubhelper/model/controller/GroupContoller.java
  5. 4
      src/main/java/de/kreth/clubhelper/model/controller/PersonController.java
  6. 4
      src/main/java/de/kreth/clubhelper/model/dao/AdressDao.java
  7. 5
      src/main/java/de/kreth/clubhelper/model/dao/AttendanceDao.java
  8. 14
      src/main/java/de/kreth/clubhelper/model/dao/ClubhelperDao.java
  9. 7
      src/main/java/de/kreth/clubhelper/model/dao/DeletedEntriesDao.java
  10. 4
      src/main/java/de/kreth/clubhelper/model/dao/GroupDao.java
  11. 3
      src/main/java/de/kreth/clubhelper/model/dao/PersonDao.java
  12. 29
      src/main/java/de/kreth/clubhelper/model/data/Attendance.java
  13. 12
      src/main/java/de/kreth/clubhelper/model/data/BaseEntity.java
  14. 47
      src/main/java/de/kreth/clubhelper/model/data/Contact.java
  15. 35
      src/main/java/de/kreth/clubhelper/model/data/DeletedEntry.java
  16. 3
      src/main/java/de/kreth/clubhelper/model/data/GroupDef.java
  17. 4
      src/main/java/de/kreth/clubhelper/model/data/Person.java
  18. 70
      src/main/java/de/kreth/clubhelper/model/data/Relative.java
  19. 99
      src/main/java/de/kreth/clubhelperbackend/aspects/AbstractLoggerAspect.java
  20. 56
      src/main/java/de/kreth/clubhelperbackend/aspects/ControllerLoggerAspect.java
  21. 66
      src/main/java/de/kreth/clubhelperbackend/aspects/DeletedStorageAspect.java
  22. 27
      src/main/java/de/kreth/clubhelperbackend/controller/AdressController.java
  23. 63
      src/main/java/de/kreth/clubhelperbackend/controller/AttendanceController.java
  24. 19
      src/main/java/de/kreth/clubhelperbackend/controller/ContactController.java
  25. 26
      src/main/java/de/kreth/clubhelperbackend/controller/DeletedEntriesController.java
  26. 19
      src/main/java/de/kreth/clubhelperbackend/controller/GroupController.java
  27. 49
      src/main/java/de/kreth/clubhelperbackend/controller/HomeController.java
  28. 104
      src/main/java/de/kreth/clubhelperbackend/controller/PersonController.java
  29. 27
      src/main/java/de/kreth/clubhelperbackend/controller/RelativeController.java
  30. 27
      src/main/java/de/kreth/clubhelperbackend/controller/StartpassController.java
  31. 144
      src/main/java/de/kreth/clubhelperbackend/controller/abstr/AbstractController.java
  32. 101
      src/main/java/de/kreth/clubhelperbackend/controller/abstr/ClubController.java
  33. 5
      src/main/java/de/kreth/clubhelperbackend/controller/abstr/package-info.java
  34. 11
      src/main/java/de/kreth/clubhelperbackend/utils/BoolUtils.java
  35. 18
      src/main/java/de/kreth/clubhelperbackend/utils/EmailUtils.java
  36. 52
      src/main/java/de/kreth/clubhelperbackend/utils/ThreadPoolErrors.java
  37. 7
      src/main/java/de/kreth/clubhelperbackend/utils/TimeProvider.java
  38. 15
      src/main/java/de/kreth/clubhelperbackend/utils/TimeProviderImpl.java
  39. 123
      src/main/resources/schema.sql
  40. 282
      src/main/resources/schema_postgres.sql

@ -105,6 +105,11 @@
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.libphonenumber</groupId>
<artifactId>libphonenumber</artifactId>
<version>8.11.0</version>
</dependency>
</dependencies>
<dependencyManagement>

@ -4,9 +4,12 @@ import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -30,9 +33,9 @@ public class AttendanceController
@Autowired
private PersonDao personDao;
@PostMapping(value = "/on")
@GetMapping(value = "/on")
@ResponseBody
public List<Attendance> getAttendencesOn(@RequestBody(required = false) Date date)
public List<Attendance> getAttendencesOn(@RequestBody @DateTimeFormat(iso=ISO.DATE) Date date)
{
if (date == null) {
date = new Date();
@ -42,7 +45,7 @@ public class AttendanceController
@PostMapping(value = "/for/{id}")
@ResponseBody
public Attendance post(@PathVariable("id") Integer id)
public Attendance post(@PathVariable("id") Long id)
{
Attendance att = new Attendance();
att.setOnDate(new Date());
@ -52,7 +55,7 @@ public class AttendanceController
}
@DeleteMapping("/{id}")
public Attendance delete(@PathVariable("id") int personId, @RequestBody(required = true) Date onDate) {
public Attendance delete(@PathVariable("id") Long personId, @RequestBody(required = true) Date onDate) {
Person person = personDao.findById(personId).orElseThrow(() -> new RuntimeException("Person not found by id=" + personId));
Attendance attendance = attendanceDao.findByPersonAndOnDate(person, onDate);
attendanceDao.delete(attendance);

@ -15,18 +15,19 @@ import de.kreth.clubhelper.model.data.Person;
@Controller
@RequestMapping("/contact")
@PreAuthorize("isAuthenticated()")
public class ContactController {
public class ContactController
{
@Autowired
private ContactDao contactDao;
public List<Contact> getByParent(Person person) {
public List<Contact> getByParent(Person person)
{
return contactDao.findByPerson(person);
}
public void delete(Contact c) {
public void delete(Contact c)
{
c.setDeleted(new Date());
contactDao.save(c);
}
}

@ -34,12 +34,12 @@ public class GroupContoller
}
@GetMapping("/{id}")
public GroupDef getById(@PathVariable("id") int id) {
public GroupDef getById(@PathVariable("id") long id) {
Supplier<HttpClientErrorException> supplier = () -> createNotFoundForId(id);
return groupDao.findById(id).orElseThrow(supplier);
}
private HttpClientErrorException createNotFoundForId(Integer id)
private HttpClientErrorException createNotFoundForId(long id)
{
HttpHeaders headers = new HttpHeaders();
byte[] body = new byte[0];

@ -41,13 +41,13 @@ public class PersonController
}
@GetMapping(value = "/{id}")
public @ResponseBody Optional<Person> getById(@PathVariable("id") final int id)
public @ResponseBody Optional<Person> getById(@PathVariable("id") final long id)
{
return personDao.findById(id);
}
@DeleteMapping(value = "/{id}")
public @ResponseBody Person delete(@PathVariable("id") final int id)
public @ResponseBody Person delete(@PathVariable("id") final long id)
{
Optional<Person> optional = personDao.findById(id);
if (optional.isPresent()) {

@ -2,12 +2,10 @@ package de.kreth.clubhelper.model.dao;
import java.util.List;
import org.springframework.data.repository.CrudRepository;
import de.kreth.clubhelper.model.data.Adress;
import de.kreth.clubhelper.model.data.Person;
public interface AdressDao extends CrudRepository<Adress, Integer> {
public interface AdressDao extends ClubhelperDao<Adress> {
List<Adress> findByPerson(Person person);

@ -3,16 +3,15 @@ package de.kreth.clubhelper.model.dao;
import java.util.Date;
import java.util.List;
import org.springframework.data.repository.CrudRepository;
import de.kreth.clubhelper.model.data.Attendance;
import de.kreth.clubhelper.model.data.Person;
public interface AttendanceDao extends CrudRepository<Attendance, Integer> {
public interface AttendanceDao extends ClubhelperDao<Attendance> {
List<Attendance> findByOnDate(Date onDate);
List<Attendance> findByPerson(Person person);
Attendance findByPersonAndOnDate(Person person, Date onDate);
}

@ -0,0 +1,14 @@
package de.kreth.clubhelper.model.dao;
import java.util.Date;
import java.util.List;
import org.springframework.data.repository.CrudRepository;
public interface ClubhelperDao<T> extends CrudRepository<T, Long>
{
List<T> findByPersonId(long personId);
List<T> findByChangedGreaterThan(Date date);
}

@ -0,0 +1,7 @@
package de.kreth.clubhelper.model.dao;
import de.kreth.clubhelper.model.data.DeletedEntry;
public interface DeletedEntriesDao extends ClubhelperDao<DeletedEntry>
{
}

@ -1,9 +1,7 @@
package de.kreth.clubhelper.model.dao;
import org.springframework.data.repository.CrudRepository;
import de.kreth.clubhelper.model.data.GroupDef;
public interface GroupDao extends CrudRepository<GroupDef, Integer> {
public interface GroupDao extends ClubhelperDao<GroupDef> {
}

@ -1,11 +1,10 @@
package de.kreth.clubhelper.model.dao;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import de.kreth.clubhelper.model.data.Person;
@Repository
public interface PersonDao extends CrudRepository<Person, Integer> {
public interface PersonDao extends ClubhelperDao<Person> {
}

@ -15,42 +15,44 @@ import javax.persistence.TemporalType;
/**
* The persistent class for the attendance database table.
*
*/
@Entity
@Table(name = "attendance")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@NamedQuery(name = "Attendance.findAll", query = "SELECT a FROM Attendance a")
public class Attendance extends BaseEntity implements Serializable {
public class Attendance extends BaseEntity implements Serializable
{
private static final long serialVersionUID = 2385033161272078335L;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "on_date")
private Date onDate;
// bi-directional many-to-one association to Person
@ManyToOne
private Person person;
public Date getOnDate() {
public Date getOnDate()
{
return new Date(this.onDate.getTime());
}
public Person getPerson() {
public Person getPerson()
{
return person;
}
public void setPerson(Person person) {
public void setPerson(Person person)
{
this.person = person;
}
public void setOnDate(Date onDate) {
public void setOnDate(Date onDate)
{
this.onDate = onDate;
}
@Override
public int hashCode() {
public int hashCode()
{
final int prime = 103;
int result = super.hashCode();
result = prime * result;
@ -58,15 +60,16 @@ public class Attendance extends BaseEntity implements Serializable {
}
@Override
public boolean equals(Object obj) {
public boolean equals(Object obj)
{
if (this == obj)
return true;
return super.equals(obj);
}
@Override
public String toString() {
public String toString()
{
return "Attendance [person=" + person + ", onDate=" + onDate + "]";
}
}

@ -14,7 +14,7 @@ public abstract class BaseEntity implements EntityAccessor
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private long id;
@Temporal(TemporalType.TIMESTAMP)
private Date changed;
@Temporal(TemporalType.TIMESTAMP)
@ -63,13 +63,17 @@ public abstract class BaseEntity implements EntityAccessor
this.deleted = new Date(deleted.getTime());
}
public boolean isDeleted() {
return getDeleted() != null;
}
@Override
public Integer getId()
public Long getId()
{
return id;
}
public void setId(int id)
public void setId(long id)
{
this.id = id;
}
@ -88,7 +92,7 @@ public abstract class BaseEntity implements EntityAccessor
result = prime * result + ((changed == null) ? 0 : changed.hashCode());
result = prime * result + ((created == null) ? 0 : created.hashCode());
result = prime * result + ((deleted == null) ? 0 : deleted.hashCode());
result = prime * result + id;
result = (int) (prime * result + id);
return result;
}

@ -6,71 +6,75 @@ import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
/**
* The persistent class for the contact database table.
*
*/
@Entity
@Table(name = "contact")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@NamedQuery(name = "Contact.findAll", query = "SELECT c FROM Contact c WHERE c.deleted is not null")
public class Contact extends BaseEntity implements Serializable {
public class Contact extends BaseEntity implements Serializable
{
private static final long serialVersionUID = -7631864028095077913L;
public static enum Type {
public enum Type
{
PHONE("Telefon"),
MOBILE("Mobile"),
EMAIL("Email");
private final String name;
private Type(String name) {
private Type(String name)
{
this.name = name;
}
public String getName() {
public String getName()
{
return name;
}
}
private String type;
private String value;
// bi-directional many-to-one association to Person
@ManyToOne
private Person person;
public String getType() {
public String getType()
{
return type;
}
public void setType(String type) {
public void setType(String type)
{
this.type = type;
}
public String getValue() {
public String getValue()
{
return value;
}
public void setValue(String value) {
public void setValue(String value)
{
this.value = value;
}
public Person getPerson() {
public Person getPerson()
{
return person;
}
public void setPerson(Person person) {
public void setPerson(Person person)
{
this.person = person;
}
@Override
public int hashCode() {
public int hashCode()
{
final int prime = 37;
int result = super.hashCode();
result = prime * result;
@ -78,15 +82,16 @@ public class Contact extends BaseEntity implements Serializable {
}
@Override
public boolean equals(Object obj) {
public boolean equals(Object obj)
{
if (this == obj)
return true;
return super.equals(obj);
}
@Override
public String toString() {
public String toString()
{
return "Contact [type=" + type + ", value=" + value + "]";
}
}

@ -5,60 +5,61 @@ import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
/**
* The persistent class for the deleted_entries database table.
*
*/
@Entity
@Table(name = "deleted_entries")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@NamedQuery(name = "DeletedEntry.findAll", query = "SELECT d FROM DeletedEntry d")
public class DeletedEntry extends BaseEntity implements Serializable {
public class DeletedEntry extends BaseEntity implements Serializable
{
private static final long serialVersionUID = -4271189592258131845L;
private int entryId;
private long entryId;
private String tablename;
public int getEntryId() {
public long getEntryId()
{
return entryId;
}
public void setEntryId(int entryId) {
public void setEntryId(long entryId)
{
this.entryId = entryId;
}
public String getTablename() {
public String getTablename()
{
return tablename;
}
public void setTablename(String tablename) {
public void setTablename(String tablename)
{
this.tablename = tablename;
}
@Override
public int hashCode() {
public int hashCode()
{
final int prime = 47;
int result = super.hashCode();
result = prime * result + entryId;
result = (int) (prime * result + entryId);
result = prime * result + ((tablename == null) ? 0 : tablename.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
public boolean equals(Object obj)
{
if (this == obj)
return true;
return super.equals(obj);
}
@Override
public String toString() {
public String toString()
{
return "DeletedEntry [entryId=" + entryId + ", tablename=" + tablename + "]";
}
}

@ -5,7 +5,6 @@ import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
/**
@ -14,11 +13,9 @@ import javax.persistence.Table;
@Entity
@Table(name = "groupdef")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@NamedQuery(name = GroupDef.QUERY_FINDALL, query = "SELECT g FROM GroupDef g")
public class GroupDef extends BaseEntity implements Serializable
{
private static final long serialVersionUID = 1L;
public final static String QUERY_FINDALL = "GroupDef.findAll";
private String name;

@ -11,7 +11,6 @@ import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
/**
@ -21,9 +20,6 @@ import javax.persistence.Table;
@Entity
@Table(name = "person")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@NamedQuery(name = Person.QUERY_FINDALL, query = "SELECT p FROM Person p WHERE p.deleted is null")
@NamedQuery(name = Person.QUERY_FINDLOGIN, query = "FROM Person WHERE username = :username AND password = :password AND deleted is"
+ " null")
public class Person extends BaseEntity implements Serializable {
public static final String SESSION_LOGIN = "SESSION_LOGIN_USER";

@ -13,79 +13,101 @@ import javax.persistence.Table;
/**
* The persistent class for the relative database table.
*
*/
@Entity
@Table(name = "relative")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@NamedQuery(name = Relative.QUERY_FINDALL, query = "SELECT r FROM Relative r")
public class Relative extends BaseEntity implements Serializable {
public class Relative extends BaseEntity implements Serializable
{
public static final String QUERY_FINDALL = "Relative.findAll";
@Column(name = "TO_PERSON1_RELATION")
private String toPerson1Relation;
@Column(name = "TO_PERSON2_RELATION")
private String toPerson2Relation;
// bi-directional many-to-one association to Person
@ManyToOne
@JoinColumn(name = "person1")
private Person person1Bean;
// bi-directional many-to-one association to Person
@ManyToOne
@JoinColumn(name = "person2")
private Person person2Bean;
public String getToPerson1Relation() {
public Relative()
{
}
public Relative(long id, String toPerson1Relation, String toPerson2Relation, Person person1Bean, Person person2Bean)
{
super();
setId(id);
this.toPerson1Relation = toPerson1Relation;
this.toPerson2Relation = toPerson2Relation;
this.person1Bean = person1Bean;
this.person2Bean = person2Bean;
}
public String getToPerson1Relation()
{
return toPerson1Relation;
}
public void setToPerson1Relation(String toPerson1Relation) {
public void setToPerson1Relation(String toPerson1Relation)
{
this.toPerson1Relation = toPerson1Relation;
}
public String getToPerson2Relation() {
public String getToPerson2Relation()
{
return toPerson2Relation;
}
public void setToPerson2Relation(String toPerson2Relation) {
public void setToPerson2Relation(String toPerson2Relation)
{
this.toPerson2Relation = toPerson2Relation;
}
public Person getPerson1Bean() {
public Person getPerson1Bean()
{
return person1Bean;
}
public void setPerson1Bean(Person person1Bean) {
public void setPerson1Bean(Person person1Bean)
{
this.person1Bean = person1Bean;
}
public Person getPerson2Bean() {
public Person getPerson2Bean()
{
return person2Bean;
}
public void setPerson2Bean(Person person2Bean) {
public void setPerson2Bean(Person person2Bean)
{
this.person2Bean = person2Bean;
}
public Relation getRelationTo(Person person) {
public Relation getRelationTo(Person person)
{
if (person == null) {
return null;
}
if (person.equals(person1Bean)) {
return new Relation(person2Bean, toPerson2Relation);
} else if (person.equals(person2Bean)) {
}
else if (person.equals(person2Bean)) {
return new Relation(person1Bean, toPerson1Relation);
} else {
}
else {
return null;
}
}
@Override
public int hashCode() {
public int hashCode()
{
final int prime = 73;
int result = super.hashCode();
result = prime * result;
@ -93,16 +115,16 @@ public class Relative extends BaseEntity implements Serializable {
}
@Override
public boolean equals(Object obj) {
public boolean equals(Object obj)
{
if (this == obj)
return true;
return super.equals(obj);
}
@Override
public String toString() {
return "Relative [person1Bean=" + person1Bean + ", toPerson2Relation=" + toPerson2Relation + ", person2Bean="
+ person2Bean + "]";
public String toString()
{
return "Relative [person1Bean=" + person1Bean + ", toPerson2Relation=" + toPerson2Relation + ", person2Bean=" + person2Bean + "]";
}
}

@ -0,0 +1,99 @@
package de.kreth.clubhelperbackend.aspects;
import org.aspectj.lang.JoinPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AbstractLoggerAspect {
protected Logger logger = LoggerFactory.getLogger(getClass());
public enum LogLevel {
WARN, DEBUG, INFO;
boolean enabled(Logger logger) {
switch (this) {
case WARN :
return logger.isWarnEnabled();
case DEBUG :
return logger.isDebugEnabled();
case INFO :
return logger.isInfoEnabled();
default :
return true;
}
}
}
protected void log(LogLevel level, JoinPoint joinPoint) {
log(level, joinPoint, null);
}
protected void log(LogLevel level, JoinPoint joinPoint, Object result) {
if (level.enabled(logger)) {
StringBuffer msg = generateLogMessage(joinPoint);
Exception exception = null;
if (result != null) {
if (result instanceof Exception) {
exception = (Exception) result;
} else {
msg.append(" ==> ").append(result);
}
}
switch (level) {
case WARN :
if (exception == null) {
logger.warn(msg.toString());
} else {
logger.warn(msg.toString(), exception);
}
break;
case DEBUG :
if (exception == null) {
logger.debug(msg.toString());
} else {
logger.debug(msg.toString(), exception);
}
break;
case INFO :
if (exception == null) {
logger.info(msg.toString());
} else {
logger.info(msg.toString(), exception);
}
break;
default :
if (exception == null) {
logger.trace(msg.toString());
} else {
logger.trace(msg.toString(), exception);
}
}
}
}
protected StringBuffer generateLogMessage(JoinPoint joinPoint) {
StringBuffer logMessage = new StringBuffer();
logMessage.append(joinPoint.getTarget().getClass().getName());
logMessage.append(".");
logMessage.append(joinPoint.getSignature().getName());
logMessage.append("(");
// append args
Object[] args = joinPoint.getArgs();
for (int i = 0; i < args.length; i++) {
logMessage.append(args[i]).append(",");
}
if (args.length > 0) {
logMessage.deleteCharAt(logMessage.length() - 1);
}
logMessage.append(")");
return logMessage;
}
}

@ -0,0 +1,56 @@
package de.kreth.clubhelperbackend.aspects;
import static de.kreth.clubhelperbackend.aspects.AbstractLoggerAspect.LogLevel.DEBUG;
import static de.kreth.clubhelperbackend.aspects.AbstractLoggerAspect.LogLevel.INFO;
import static de.kreth.clubhelperbackend.aspects.AbstractLoggerAspect.LogLevel.WARN;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
@Component
@Aspect
public class ControllerLoggerAspect extends AbstractLoggerAspect {
@Pointcut("execution (public * de.kreth.clubhelperbackend.controller..*.delete(..))")
private void deleteItem() {
}
@Pointcut("execution (public * de.kreth.clubhelperbackend.controller..*(..))")
private void callAny() {
}
@Pointcut("callAny() && (!deleteItem())")
private void invocation() {
}
@Before("invocation()")
public void logDao(JoinPoint joinPoint) throws Throwable {
log(INFO, joinPoint);
}
@AfterThrowing(pointcut = "invocation()", throwing = "ex")
public void logCall(JoinPoint joinPoint, Exception ex) throws Throwable {
logger.error(generateLogMessage(joinPoint).toString(), ex);
}
@AfterReturning(pointcut = "invocation()", returning = "result")
public void logCall(JoinPoint joinPoint, Object result) throws Throwable {
log(DEBUG, joinPoint, result);
}
@AfterReturning(pointcut = "deleteItem()", returning = "result")
public void logDeleteSuccess(JoinPoint joinPoint, Object result)
throws Throwable {
log(WARN, joinPoint, result);
}
@Before("deleteItem()")
public void logDeleteInvocation(JoinPoint joinPoint) throws Throwable {
log(DEBUG, joinPoint);
}
}

@ -0,0 +1,66 @@
package de.kreth.clubhelperbackend.aspects;
import java.lang.reflect.Modifier;
import java.util.Date;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import de.kreth.clubhelper.model.dao.DeletedEntriesDao;
import de.kreth.clubhelper.model.data.BaseEntity;
import de.kreth.clubhelper.model.data.DeletedEntry;
import de.kreth.clubhelperbackend.utils.TimeProvider;
@Aspect
@Component
public class DeletedStorageAspect {
private Logger logger = LoggerFactory.getLogger(getClass());
private DeletedEntriesDao deletedEntriesDao;
private TimeProvider time;
@Autowired
public void setTime(TimeProvider time) {
this.time = time;
}
@Autowired
public DeletedStorageAspect(DeletedEntriesDao deletedEntriesDao) {
super();
this.deletedEntriesDao = deletedEntriesDao;
}
@Pointcut("execution (public * de.kreth.clubhelperbackend.controller.abstr.AbstractController.delete(..))")
private void invocation() {
}
@AfterReturning(pointcut = "invocation()", returning = "deleted")
public void storeDeleted(JoinPoint joinPoint, BaseEntity deleted) {
logger.debug("Deleted: " + deleted);
Class<?> class1 = deleted.getClass();
while (!class1.getSuperclass().equals(Object.class) && !Modifier.isAbstract(class1.getSuperclass().getModifiers()))
class1 = class1.getSuperclass();
String tableName = class1.getSimpleName();
long id = deleted.getId();
Date now = time.getNow();
DeletedEntry entry = new DeletedEntry();
entry.setTablename(tableName);
entry.setEntryId(id);
entry.setChanged(now);
entry.setCreated(now);
logger.info("Inserted Deleteentry: {}", entry);
deletedEntriesDao.save(entry);
}
}

@ -0,0 +1,27 @@
package de.kreth.clubhelperbackend.controller;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import de.kreth.clubhelper.model.data.Adress;
import de.kreth.clubhelperbackend.controller.abstr.AbstractController;
@RestController
@RequestMapping("/adress")
public class AdressController extends AbstractController<Adress> {
@Autowired
public AdressController() {
super(Adress.class);
}
@Override
public List<Adress> getByParentId(long id) {
return new ArrayList<Adress>();
}
}

@ -0,0 +1,63 @@
package de.kreth.clubhelperbackend.controller;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import de.kreth.clubhelper.model.dao.AttendanceDao;
import de.kreth.clubhelper.model.dao.PersonDao;
import de.kreth.clubhelper.model.data.Attendance;
import de.kreth.clubhelperbackend.controller.abstr.AbstractController;
@RestController
@RequestMapping("/attendance")
public class AttendanceController extends AbstractController<Attendance> {
@Autowired
private PersonDao personDao;
public AttendanceController() {
super(Attendance.class);
}
@RequestMapping(value = "/on", method = RequestMethod.POST, produces = "application/json")
public List<Attendance> postListAttendencesOn(@RequestBody(required=false) Date date)
throws SQLException {
if(date == null) {
date = new Date();
}
AttendanceDao tmpDao = (AttendanceDao)dao;
return tmpDao.findByOnDate(date);
}
@RequestMapping(value = "/on/{date}", method = RequestMethod.GET, produces = "application/json")
public List<Attendance> getAttendencesOn(@PathVariable("date") @DateTimeFormat(iso=ISO.DATE) Date date)
throws SQLException {
AttendanceDao tmpDao = (AttendanceDao)dao;
return tmpDao.findByOnDate(date);
}
@RequestMapping(value = "/for/{id}", method = RequestMethod.POST, produces = "application/json")
public Attendance post(@PathVariable("id") Long id) {
Attendance att = new Attendance();
att.setPerson(personDao.findById(id).get());
att.setOnDate(new Date());
return post(att);
}
}

@ -0,0 +1,19 @@
package de.kreth.clubhelperbackend.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import de.kreth.clubhelper.model.data.Contact;
import de.kreth.clubhelperbackend.controller.abstr.AbstractController;
@RestController
@RequestMapping("/contact")
public class ContactController extends AbstractController<Contact> {
@Autowired
public ContactController() {
super(Contact.class);
}
}

@ -0,0 +1,26 @@
package de.kreth.clubhelperbackend.controller;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import de.kreth.clubhelper.model.data.DeletedEntry;
import de.kreth.clubhelperbackend.controller.abstr.AbstractController;
@RestController
@RequestMapping("/deletedentries")
public class DeletedEntriesController extends AbstractController<DeletedEntry> {
@Autowired
public DeletedEntriesController() {
super(DeletedEntry.class);
}
@Override
public List<DeletedEntry> getByParentId(long id) {
return Collections.emptyList();
}
}

@ -0,0 +1,19 @@
package de.kreth.clubhelperbackend.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import de.kreth.clubhelper.model.data.GroupDef;
import de.kreth.clubhelperbackend.controller.abstr.AbstractController;
@RestController
@RequestMapping("/group")
public class GroupController extends AbstractController<GroupDef> {
@Autowired()
public GroupController() {
super(GroupDef.class);
}
}

@ -0,0 +1,49 @@
package de.kreth.clubhelperbackend.controller;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Handles requests for the application home page.
*/
@RestController
@RequestMapping("/")
public class HomeController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
/**
* Simply selects the home view to render by returning its name.
*
* @param response
* response Object for redirection.
* @param device
* device Type to decide redirection target.
* @param locale
* locale for language
* @param model
* model to set response data
* @return Name of View
*/
@GetMapping(value = "/")
public String home(HttpServletResponse response, Locale locale) {
logger.info("Welcome home! The client locale is {}.", locale);
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formattedDate = dateFormat.format(date);
return "This is Clubhelper Backend at " + formattedDate;
}
}

@ -0,0 +1,104 @@
package de.kreth.clubhelperbackend.controller;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import de.kreth.clubhelper.model.data.Adress;
import de.kreth.clubhelper.model.data.Contact;
import de.kreth.clubhelper.model.data.Person;
import de.kreth.clubhelper.model.data.Relative;
import de.kreth.clubhelperbackend.controller.abstr.AbstractController;
import de.kreth.clubhelperbackend.controller.abstr.ClubController;
@RestController
@RequestMapping("/person")
public class PersonController extends AbstractController<Person> {
@Autowired
private ClubController<Contact> contactController;
@Autowired
private ClubController<Relative> relativeController;
@Autowired
private ClubController<Adress> adressController;
public PersonController() {
super(Person.class);
}
// private static ClubhelperDao<Person> doCast(PersonDao dao) {
// Object anonymous = dao;
// return (ClubhelperDao<Person>) anonymous;
// }
@Override
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "application/json")
public ResponseEntity<Person> delete(@PathVariable("id") final long id) {
for (Contact c : contactController.getByParentId(id)) {
contactController.delete(c.getId());
}
for (Adress a : adressController.getByParentId(id)) {
adressController.delete(a.getId());
}
for (Relative r : relativeController.getByParentId(id)) {
relativeController.delete(r.getId());
}
return super.delete(id);
}
/**
* Delivers list with one Person with id.
*/
@Override
public List<Person> getByParentId(long id) {
List<Person> all = new ArrayList<Person>();
all.add(getById(id));
return all;
}
/**
*
* @author markus
*
*/
public class PersonRelative extends Relative {
private static final long serialVersionUID = 4828690343464403867L;
private Person toPerson;
private String relation;
public PersonRelative(Relative r) {
super(r.getId(),
r.getToPerson2Relation(), r.getToPerson1Relation(), r.getPerson1Bean(), r.getPerson2Bean());
setChanged(r.getChanged());
setCreated(r.getCreated());
toPerson = r.getPerson1Bean();
relation = r.getToPerson1Relation();
}
public Person getToPerson() {
return toPerson;
}
public String getRelation() {
return relation;
}
@Override
public String toString() {
StringBuilder bld = new StringBuilder();
bld.append(relation).append(" ").append(toPerson.getId())
.append(": ").append(toPerson.getPrename()).append(" ")
.append(toPerson.getSurname());
return bld.toString();
}
}
}

@ -0,0 +1,27 @@
package de.kreth.clubhelperbackend.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import de.kreth.clubhelper.model.data.Relative;
import de.kreth.clubhelperbackend.controller.abstr.AbstractController;
@RestController
@RequestMapping("/relative")
public class RelativeController extends AbstractController<Relative> {
@Autowired
public RelativeController() {
super(Relative.class);
}
//
// @Override
// @RequestMapping(value = "/for/{id}", method = RequestMethod.GET)
// public List<Relative> getByParentId(@PathVariable("id") long id) {
// StringBuilder whereClause = new StringBuilder("person1=");
// whereClause.append(id).append(" OR person2=").append(id);
// return dao.getByWhere(whereClause.toString());
// }
}

@ -0,0 +1,27 @@
package de.kreth.clubhelperbackend.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import de.kreth.clubhelper.model.data.Startpass;
import de.kreth.clubhelperbackend.controller.abstr.AbstractController;
@RestController
@RequestMapping("/startpass")
public class StartpassController extends AbstractController<Startpass> {
@Autowired
public StartpassController() {
super(Startpass.class);
}
@Override
// @RequestMapping(value = "/for/{id}", method = RequestMethod.GET, produces = "application/json")
public List<Startpass> getByParentId(@PathVariable("id") long id) {
return dao.findByPersonId(id);
}
}

@ -0,0 +1,144 @@
package de.kreth.clubhelperbackend.controller.abstr;
import static de.kreth.clubhelperbackend.utils.BoolUtils.not;
import static java.time.temporal.ChronoUnit.MINUTES;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import de.kreth.clubhelper.model.dao.ClubhelperDao;
import de.kreth.clubhelper.model.data.BaseEntity;
/**
* Default Controller implementing all functionality for all {@link Data} types.
*
* @param <T>
* Data type
*/
//@PreAuthorize("hasAnyRole('ROLE_ADMIN', 'STAFF')")
public abstract class AbstractController<T extends BaseEntity>
implements
ClubController<T> {
@Autowired
protected ClubhelperDao<T> dao;
private Class<T> elementClass;
public AbstractController(Class<T> element) {
super();
this.elementClass = element;
}
@Override
@GetMapping(value = "/{id}", produces = "application/json")
public T getById(@PathVariable("id") long id) {
return dao.findById(id).orElseThrow(() -> new IllegalArgumentException(elementClass.getName() + " with id=" + id + " not found"));
}
protected List<T> iterableToList(Iterable<T> in) {
List<T> result = new ArrayList<>();
in.forEach(result::add);
return result;
}
@Override
@GetMapping(value = {"/",
""}, produces = "application/json")
public List<T> getAll() {
Iterable<T> findAll = dao.findAll();
List<T> result = new ArrayList<>();
findAll.forEach(result::add);
return result;
}
@Override
@GetMapping(value = "/for/{id}", produces = "application/json")
public List<T> getByParentId(@PathVariable("id") long id) {
return dao.findByPersonId(id);
}
@Override
@GetMapping(value = "/changed/{changed}", produces = "application/json")
public List<T> getChangedSince(@PathVariable("changed") long changed) {
return dao.findByChangedGreaterThan(new Date(changed));
}
@Override
@PutMapping(value = "/{id}", produces = "application/json")
public T put(@PathVariable("id") long id, @RequestBody T toUpdate) {
Date now = new Date();
Date created = toUpdate.getCreated();
Date changed = null;
if (toUpdate.getChanged() != null) {
changed = toUpdate.getChanged();
long minutes = MINUTES.between(created.toInstant(), changed.toInstant());
if (minutes < 1) {
toUpdate.setChanged(now);
}
} else {
toUpdate.setChanged(now);
}
dao.save(toUpdate);
return toUpdate;
}
@Override
@DeleteMapping(value = "/{id}", produces = "application/json")
public ResponseEntity<T> delete(@PathVariable("id") long id) {
T byId = getById(id);
if (not(byId.isDeleted())) {
dao.delete(byId);
}
return ResponseEntity.ok(getById(id));
}
@Override
@PostMapping(value = "/", produces = "application/json")
public T post(@RequestBody T toCreate) {
return post(-1L, toCreate);
}
@Override
@PostMapping(value = "/{id}", produces = "application/json")
public T post(@PathVariable("id") Long id, @RequestBody T toCreate) {
if (id == null) {
id = -1L;
}
toCreate.setId(id);
Date now = new Date();
toCreate.setChanged(now);
if (toCreate.getCreated() == null
|| toCreate.getCreated().getTime() == 0) {
toCreate.setCreated(now);
}
if (toCreate.getId() < 0) {
return dao.save(toCreate);
} else {
T byId = getById(toCreate.getId());
if (byId != null) {
toCreate.setDeleted(null);
return dao.save(toCreate);
} else {
return dao.save(toCreate);
}
}
}
}

@ -0,0 +1,101 @@
package de.kreth.clubhelperbackend.controller.abstr;
import java.util.List;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
public interface ClubController<T> {
/*
* ************* REST Methoden ************
*/
/**
* Rest: PUT - Change object (update)
* <p>
* Mapping: /{id}
*
* @param id
* Id of updated object
* @param toUpdate
* Object with updated data.
* @return updated object
*/
T put(@PathVariable("id") long id, @RequestBody T toUpdate);
/**
* Rest: POST - Create Object without Id.
*
* @param toCreate
* object with data to insert.
* @return created and corrected object
*/
T post(@RequestBody T toCreate);
/**
* Rest: POST - Create Object with or without Id.
*
* @param id
* -1 for new Id
* @param toCreate
* Object to create.
* @return created object with updated id and dates.
*/
T post(@PathVariable("id") Long id, @RequestBody T toCreate);
/**
* Rest: GET - return object
* <p>
* Mapping: /{id}
*
* @param id
* id to find object for.
* @return Object for matching id
*/
T getById(@PathVariable("id") long id);
/**
* Rest: GET - return List of all objects
* <p>
* Mapping: /
*
* @return List of all Objects - sorted if configured.
*/
List<T> getAll();
/**
* Rest: GET - return List of object having the (parent object) id as
* property. <br>
* Which property is meant is implementation dependant. Most likely its
* personId
* <p>
* Mapping: /for/{id}
*
* @param id
* Id matching all objects property.
* @return List of object with certain property matching id.
*/
List<T> getByParentId(@PathVariable("id") long id);
/**
* Rest: DELETE - deletes object with the Id.
* <p>
* Mapping: /{id}
*
* @param id
* Id of the object to delete.
* @return deleted object.
*/
ResponseEntity<T> delete(@PathVariable("id") long id);
/**
*
* @param changed
* date of last change included
* @return list of objects changed since changed date.
*/
List<T> getChangedSince(long changed);
}

@ -0,0 +1,5 @@
/**
* @author markus
*
*/
package de.kreth.clubhelperbackend.controller.abstr;

@ -0,0 +1,11 @@
package de.kreth.clubhelperbackend.utils;
public class BoolUtils {
private BoolUtils() {
// Static Methods only.
}
public static final boolean not(boolean value) {
return !value;
}
}

@ -0,0 +1,18 @@
package de.kreth.clubhelperbackend.utils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class EmailUtils {
private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
private static final Pattern pattern = Pattern.compile(EMAIL_PATTERN);
public static boolean isValidEmailadress(String email) {
Matcher matcher = pattern.matcher(email);
return matcher.matches();
}
}

@ -0,0 +1,52 @@
package de.kreth.clubhelperbackend.utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class ThreadPoolErrors extends ThreadPoolExecutor {
public final List<Throwable> exceptions = Collections
.synchronizedList(new ArrayList<>());
public ThreadPoolErrors(int threadCount) {
super(Math.min(3, threadCount), // core threads
threadCount, // max threads
30, // timeout
TimeUnit.SECONDS, // timeout units
new LinkedBlockingQueue<Runnable>() // work queue
);
}
protected void afterExecute(Runnable r, Throwable t) {
super.afterExecute(r, t);
if (t != null) {
exceptions.add(t);
}
}
public Throwable myAwaitTermination() {
while (isRunningWithoutException()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
shutdownNow();
return e;
}
}
if (exceptions.isEmpty() == false) {
return exceptions.get(0);
}
return null;
}
private boolean isRunningWithoutException() {
return isTerminated() == false && getActiveCount() > 0
&& exceptions.isEmpty();
}
}

@ -0,0 +1,7 @@
package de.kreth.clubhelperbackend.utils;
import java.util.Date;
public interface TimeProvider {
Date getNow();
}

@ -0,0 +1,15 @@
package de.kreth.clubhelperbackend.utils;
import java.util.Date;
import org.springframework.stereotype.Component;
@Component
public class TimeProviderImpl implements TimeProvider {
@Override
public Date getNow() {
return new Date();
}
}

@ -7,13 +7,12 @@
--
-- DROP TABLE IF EXISTS groupdef;
CREATE TABLE groupdef (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
name varchar(255) NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created datetime DEFAULT CURRENT_TIMESTAMP,
deleted datetime DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY groupname_UNIQUE (name)
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT groupname_UNIQUE UNIQUE (name)
);
--
@ -21,17 +20,16 @@ CREATE TABLE groupdef (
--
-- DROP TABLE IF EXISTS person;
CREATE TABLE person (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
prename varchar(255) NOT NULL,
surname varchar(255) DEFAULT NULL,
birth datetime DEFAULT NULL,
birth timestamp DEFAULT NULL,
gender smallint DEFAULT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created datetime DEFAULT CURRENT_TIMESTAMP,
deleted datetime DEFAULT NULL,
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
username varchar(255) DEFAULT NULL,
password varchar(255) DEFAULT NULL,
PRIMARY KEY (id)
password varchar(255) DEFAULT NULL
);
@ -41,14 +39,13 @@ CREATE TABLE person (
-- DROP TABLE IF EXISTS contact;
CREATE TABLE contact (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
type varchar(255) NOT NULL,
value varchar(255) DEFAULT NULL,
person_id int NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created datetime DEFAULT CURRENT_TIMESTAMP,
deleted datetime DEFAULT NULL,
PRIMARY KEY (id),
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT contact_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id) ON DELETE RESTRICT ON UPDATE RESTRICT
);
@ -64,8 +61,8 @@ CREATE TABLE clubevent (
organizerDisplayName varchar(150) DEFAULT NULL,
caption varchar(150) DEFAULT NULL,
description varchar(500) DEFAULT NULL,
start datetime DEFAULT NULL,
end datetime DEFAULT NULL,
start timestamp DEFAULT NULL,
ende timestamp DEFAULT NULL,
allDay smallint DEFAULT NULL,
deleted smallint NOT NULL DEFAULT 0,
PRIMARY KEY (id)
@ -76,16 +73,15 @@ CREATE TABLE clubevent (
--
-- DROP TABLE IF EXISTS pflichten;
CREATE TABLE pflichten (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
name varchar(45) NOT NULL,
fixed tinyint DEFAULT NULL,
fixed smallint DEFAULT NULL,
ordered int NOT NULL,
comment varchar(500) DEFAULT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created datetime DEFAULT CURRENT_TIMESTAMP,
deleted datetime DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY name_UNIQUE (name)
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT name_UNIQUE UNIQUE (name)
);
--
@ -93,16 +89,15 @@ CREATE TABLE pflichten (
--
-- DROP TABLE IF EXISTS adress;
CREATE TABLE adress (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
adress1 varchar(255) DEFAULT NULL,
adress2 varchar(255) DEFAULT NULL,
plz varchar(255) DEFAULT NULL,
city varchar(255) DEFAULT NULL,
person_id int NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created datetime DEFAULT CURRENT_TIMESTAMP,
deleted datetime DEFAULT NULL,
PRIMARY KEY (id),
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT adress_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id)
);
@ -111,16 +106,15 @@ CREATE TABLE adress (
--
-- DROP TABLE IF EXISTS altersgruppe;
CREATE TABLE altersgruppe (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
event_id varchar(250) NOT NULL,
pflicht_id int DEFAULT NULL,
bezeichnung varchar(100) NOT NULL,
start int DEFAULT NULL,
end varchar(45) DEFAULT NULL,
ende varchar(45) DEFAULT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created datetime DEFAULT CURRENT_TIMESTAMP,
deleted datetime DEFAULT NULL,
PRIMARY KEY (id),
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT fk_altersgruppe_event FOREIGN KEY (event_id) REFERENCES clubevent (id),
CONSTRAINT fk_altersgruppe_pflicht FOREIGN KEY (pflicht_id) REFERENCES pflichten (id)
);
@ -130,14 +124,13 @@ CREATE TABLE altersgruppe (
--
-- DROP TABLE IF EXISTS attendance;
CREATE TABLE attendance (
id int NOT NULL AUTO_INCREMENT,
on_date datetime DEFAULT NULL,
id SERIAL PRIMARY KEY,
on_date timestamp DEFAULT NULL,
person_id int NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created datetime DEFAULT CURRENT_TIMESTAMP,
deleted datetime DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY UNIQUE_person_id_on_date (person_id,on_date),
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT UNIQUE_person_id_on_date UNIQUE (person_id,on_date),
CONSTRAINT attendance_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id)
);
@ -173,13 +166,12 @@ CREATE TABLE clubevent_has_person (
-- DROP TABLE IF EXISTS deleted_entries;
CREATE TABLE deleted_entries (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
tablename varchar(25) NOT NULL,
entryId int NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created datetime DEFAULT CURRENT_TIMESTAMP,
deleted datetime DEFAULT NULL,
PRIMARY KEY (id)
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL
);
--
@ -188,10 +180,9 @@ CREATE TABLE deleted_entries (
-- DROP TABLE IF EXISTS event_has_altersgruppe;
CREATE TABLE event_has_altersgruppe (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
event_id varchar(250) NOT NULL,
altersgruppe_id int NOT NULL,
PRIMARY KEY (id),
CONSTRAINT fk_event_has_altersgruppe_altersgruppe FOREIGN KEY (altersgruppe_id) REFERENCES altersgruppe (id),
CONSTRAINT fk_event_has_altersgruppe_event FOREIGN KEY (event_id) REFERENCES clubevent (id)
);
@ -202,11 +193,10 @@ CREATE TABLE event_has_altersgruppe (
-- DROP TABLE IF EXISTS notes;
CREATE TABLE notes (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
person_id int NOT NULL,
notekey varchar(25) DEFAULT NULL,
notetext varchar(2000) DEFAULT NULL,
PRIMARY KEY (id),
CONSTRAINT fk_notes_person FOREIGN KEY (person_id) REFERENCES person (id)
);
@ -216,14 +206,13 @@ CREATE TABLE notes (
-- DROP TABLE IF EXISTS persongroup;
CREATE TABLE persongroup (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
person_id int NOT NULL,
group_id int NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created datetime DEFAULT CURRENT_TIMESTAMP,
deleted datetime DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY unique_person_group (person_id,group_id),
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT unique_person_group UNIQUE (person_id,group_id),
CONSTRAINT persongroup_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id),
CONSTRAINT persongroup_ibfk_2 FOREIGN KEY (group_id) REFERENCES groupdef (id)
);
@ -234,15 +223,14 @@ CREATE TABLE persongroup (
-- DROP TABLE IF EXISTS relative;
CREATE TABLE relative (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
person1 int NOT NULL,
person2 int NOT NULL,
TO_PERSON1_RELATION varchar(255) DEFAULT NULL,
TO_PERSON2_RELATION varchar(255) DEFAULT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created datetime DEFAULT CURRENT_TIMESTAMP,
deleted datetime DEFAULT NULL,
PRIMARY KEY (id),
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT relative_ibfk_1 FOREIGN KEY (person1) REFERENCES person (id),
CONSTRAINT relative_ibfk_2 FOREIGN KEY (person2) REFERENCES person (id)
);
@ -253,14 +241,13 @@ CREATE TABLE relative (
-- DROP TABLE IF EXISTS startpaesse;
CREATE TABLE startpaesse (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
person_id int NOT NULL,
startpass_nr varchar(25) NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created datetime DEFAULT CURRENT_TIMESTAMP,
deleted datetime DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY startpass_nr (startpass_nr),
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT startpass_nr UNIQUE (startpass_nr),
CONSTRAINT startpaesse_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id)
);
@ -270,16 +257,15 @@ CREATE TABLE startpaesse (
-- DROP TABLE IF EXISTS startpass_startrechte;
CREATE TABLE startpass_startrechte (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
startpass_id int NOT NULL,
verein_name varchar(100) NOT NULL,
fachgebiet varchar(25) NOT NULL,
startrecht_beginn datetime NOT NULL,
startrecht_ende datetime NOT NULL,
startrecht_beginn timestamp NOT NULL,
startrecht_ende timestamp NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created datetime DEFAULT CURRENT_TIMESTAMP,
deleted datetime DEFAULT NULL,
PRIMARY KEY (id),
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT startpass_startrechte_ibfk_1 FOREIGN KEY (startpass_id) REFERENCES startpaesse (id)
);
@ -288,10 +274,9 @@ CREATE TABLE startpass_startrechte (
--
-- DROP TABLE IF EXISTS version;
CREATE TABLE version (
id int NOT NULL AUTO_INCREMENT,
id SERIAL PRIMARY KEY,
version int NOT NULL,
deleted datetime DEFAULT NULL,
PRIMARY KEY (id)
deleted timestamp DEFAULT NULL
);
-- Dump completed

@ -0,0 +1,282 @@
-- MySQL dump 10.13 Distrib 8.0.20, for Win64 (x86_64)
--
-- ------------------------------------------------------
--
-- Table structure for table groupdef
--
-- DROP TABLE IF EXISTS groupdef;
CREATE TABLE groupdef (
id SERIAL PRIMARY KEY,
name varchar(255) NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT groupname_UNIQUE UNIQUE (name)
);
--
-- Table structure for table person
--
-- DROP TABLE IF EXISTS person;
CREATE TABLE person (
id SERIAL PRIMARY KEY,
prename varchar(255) NOT NULL,
surname varchar(255) DEFAULT NULL,
birth timestamp DEFAULT NULL,
gender smallint DEFAULT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
username varchar(255) DEFAULT NULL,
password varchar(255) DEFAULT NULL
);
--
-- Table structure for table `contact`
--
-- DROP TABLE IF EXISTS contact;
CREATE TABLE contact (
id SERIAL PRIMARY KEY,
type varchar(255) NOT NULL,
value varchar(255) DEFAULT NULL,
person_id int NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT contact_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id) ON DELETE RESTRICT ON UPDATE RESTRICT
);
--
-- Table structure for table clubevent
--
-- DROP TABLE IF EXISTS clubevent;
CREATE TABLE clubevent (
id varchar(250) NOT NULL,
location varchar(255) DEFAULT NULL,
ICALUID varchar(150) DEFAULT NULL,
organizerDisplayName varchar(150) DEFAULT NULL,
caption varchar(150) DEFAULT NULL,
description varchar(500) DEFAULT NULL,
start timestamp DEFAULT NULL,
ende timestamp DEFAULT NULL,
allDay smallint DEFAULT NULL,
deleted smallint NOT NULL DEFAULT 0,
PRIMARY KEY (id)
);
--
-- Table structure for table pflichten
--
-- DROP TABLE IF EXISTS pflichten;
CREATE TABLE pflichten (
id SERIAL PRIMARY KEY,
name varchar(45) NOT NULL,
fixed smallint DEFAULT NULL,
ordered int NOT NULL,
comment varchar(500) DEFAULT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT name_UNIQUE UNIQUE (name)
);
--
-- Table structure for table adress
--
-- DROP TABLE IF EXISTS adress;
CREATE TABLE adress (
id SERIAL PRIMARY KEY,
adress1 varchar(255) DEFAULT NULL,
adress2 varchar(255) DEFAULT NULL,
plz varchar(255) DEFAULT NULL,
city varchar(255) DEFAULT NULL,
person_id int NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT adress_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id)
);
--
-- Table structure for table altersgruppe
--
-- DROP TABLE IF EXISTS altersgruppe;
CREATE TABLE altersgruppe (
id SERIAL PRIMARY KEY,
event_id varchar(250) NOT NULL,
pflicht_id int DEFAULT NULL,
bezeichnung varchar(100) NOT NULL,
start int DEFAULT NULL,
ende varchar(45) DEFAULT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT fk_altersgruppe_event FOREIGN KEY (event_id) REFERENCES clubevent (id),
CONSTRAINT fk_altersgruppe_pflicht FOREIGN KEY (pflicht_id) REFERENCES pflichten (id)
);
--
-- Table structure for table attendance
--
-- DROP TABLE IF EXISTS attendance;
CREATE TABLE attendance (
id SERIAL PRIMARY KEY,
on_date timestamp DEFAULT NULL,
person_id int NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT UNIQUE_person_id_on_date UNIQUE (person_id,on_date),
CONSTRAINT attendance_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id)
);
--
-- Table structure for table clubevent_addon
--
-- DROP TABLE IF EXISTS clubevent_addon;
CREATE TABLE clubevent_addon (
id varchar(250) NOT NULL,
competition_type varchar(45) NOT NULL,
PRIMARY KEY (id),
CONSTRAINT fk_event_addon_id FOREIGN KEY (id) REFERENCES clubevent (id)
);
--
-- Table structure for table clubevent_has_person
--
-- DROP TABLE IF EXISTS clubevent_has_person;
CREATE TABLE clubevent_has_person (
clubevent_id varchar(250) NOT NULL,
person_id int NOT NULL,
comment varchar(250) NOT NULL,
PRIMARY KEY (clubevent_id,person_id),
CONSTRAINT fk_clubevent_has_person_clubevent1 FOREIGN KEY (clubevent_id) REFERENCES clubevent (id),
CONSTRAINT fk_clubevent_has_person_person1 FOREIGN KEY (person_id) REFERENCES person (id)
);
--
-- Table structure for table deleted_entries
--
-- DROP TABLE IF EXISTS deleted_entries;
CREATE TABLE deleted_entries (
id SERIAL PRIMARY KEY,
tablename varchar(25) NOT NULL,
entryId int NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL
);
--
-- Table structure for table event_has_altersgruppe
--
-- DROP TABLE IF EXISTS event_has_altersgruppe;
CREATE TABLE event_has_altersgruppe (
id SERIAL PRIMARY KEY,
event_id varchar(250) NOT NULL,
altersgruppe_id int NOT NULL,
CONSTRAINT fk_event_has_altersgruppe_altersgruppe FOREIGN KEY (altersgruppe_id) REFERENCES altersgruppe (id),
CONSTRAINT fk_event_has_altersgruppe_event FOREIGN KEY (event_id) REFERENCES clubevent (id)
);
--
-- Table structure for table notes
--
-- DROP TABLE IF EXISTS notes;
CREATE TABLE notes (
id SERIAL PRIMARY KEY,
person_id int NOT NULL,
notekey varchar(25) DEFAULT NULL,
notetext varchar(2000) DEFAULT NULL,
CONSTRAINT fk_notes_person FOREIGN KEY (person_id) REFERENCES person (id)
);
--
-- Table structure for table persongroup
--
-- DROP TABLE IF EXISTS persongroup;
CREATE TABLE persongroup (
id SERIAL PRIMARY KEY,
person_id int NOT NULL,
group_id int NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT unique_person_group UNIQUE (person_id,group_id),
CONSTRAINT persongroup_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id),
CONSTRAINT persongroup_ibfk_2 FOREIGN KEY (group_id) REFERENCES groupdef (id)
);
--
-- Table structure for table relative
--
-- DROP TABLE IF EXISTS relative;
CREATE TABLE relative (
id SERIAL PRIMARY KEY,
person1 int NOT NULL,
person2 int NOT NULL,
TO_PERSON1_RELATION varchar(255) DEFAULT NULL,
TO_PERSON2_RELATION varchar(255) DEFAULT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT relative_ibfk_1 FOREIGN KEY (person1) REFERENCES person (id),
CONSTRAINT relative_ibfk_2 FOREIGN KEY (person2) REFERENCES person (id)
);
--
-- Table structure for table startpaesse
--
-- DROP TABLE IF EXISTS startpaesse;
CREATE TABLE startpaesse (
id SERIAL PRIMARY KEY,
person_id int NOT NULL,
startpass_nr varchar(25) NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT startpass_nr UNIQUE (startpass_nr),
CONSTRAINT startpaesse_ibfk_1 FOREIGN KEY (person_id) REFERENCES person (id)
);
--
-- Table structure for table startpass_startrechte
--
-- DROP TABLE IF EXISTS startpass_startrechte;
CREATE TABLE startpass_startrechte (
id SERIAL PRIMARY KEY,
startpass_id int NOT NULL,
verein_name varchar(100) NOT NULL,
fachgebiet varchar(25) NOT NULL,
startrecht_beginn timestamp NOT NULL,
startrecht_ende timestamp NOT NULL,
changed timestamp NULL DEFAULT CURRENT_TIMESTAMP,
created timestamp DEFAULT CURRENT_TIMESTAMP,
deleted timestamp DEFAULT NULL,
CONSTRAINT startpass_startrechte_ibfk_1 FOREIGN KEY (startpass_id) REFERENCES startpaesse (id)
);
--
-- Table structure for table version
--
-- DROP TABLE IF EXISTS version;
CREATE TABLE version (
id SERIAL PRIMARY KEY,
version int NOT NULL,
deleted timestamp DEFAULT NULL
);
-- Dump completed
Loading…
Cancel
Save