dependency updates
This commit is contained in:
@ -62,7 +62,7 @@ limitations under the License.
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -95,4 +95,4 @@ limitations under the License.
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@ -42,7 +42,7 @@ public abstract class AbstractController<T extends Serializable> extends CommonA
|
||||
|
||||
private final Class<T> entityClass;
|
||||
|
||||
public AbstractController(Class<T> clazz) {
|
||||
protected AbstractController(Class<T> clazz) {
|
||||
this.entityClass = clazz;
|
||||
}
|
||||
|
||||
@ -68,24 +68,21 @@ public abstract class AbstractController<T extends Serializable> extends CommonA
|
||||
*/
|
||||
@Lock(LockType.READ)
|
||||
public T find(Object id, String... subGraphItems) {
|
||||
EntityGraph graph = this.em.createEntityGraph(entityClass);
|
||||
EntityGraph<T> graph = this.em.createEntityGraph(entityClass);
|
||||
for (String subGraphItem : subGraphItems) {
|
||||
graph.addSubgraph(subGraphItem);
|
||||
}
|
||||
|
||||
Map hints = new HashMap<>();
|
||||
Map<String, Object> hints = new HashMap<>();
|
||||
hints.put("javax.persistence.loadgraph", graph);
|
||||
|
||||
T entity = (T) em.find(entityClass, id, hints);
|
||||
return entity;
|
||||
return em.find(entityClass, id, hints);
|
||||
}
|
||||
|
||||
@Lock(LockType.READ)
|
||||
public List<T> find(String queryName, Map<String, Object> parameterMap) throws ControllerException {
|
||||
public List<T> find(String queryName, Map<String, Object> parameterMap) {
|
||||
Query query = em.createNamedQuery(queryName);
|
||||
parameterMap.entrySet().forEach((entry) -> {
|
||||
query.setParameter(entry.getKey(), entry.getValue());
|
||||
});
|
||||
parameterMap.entrySet().forEach(entry -> query.setParameter(entry.getKey(), entry.getValue()));
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -15,52 +15,50 @@
|
||||
*/
|
||||
package de.muehlencord.shared.db;
|
||||
|
||||
import de.muehlencord.shared.util.DateUtil;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Date;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Does not work, cannot Spring independent inject current username - implemented in AbstractController manually
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class AuditListener {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AuditListener.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(AuditListener.class);
|
||||
|
||||
// @PrePersist
|
||||
public void prePersist(Auditable auditable) {
|
||||
Audit audit = auditable.getAudit();
|
||||
// @PrePersist
|
||||
public void prePersist(Auditable auditable) {
|
||||
Audit audit = auditable.getAudit();
|
||||
|
||||
if (audit == null) {
|
||||
audit = new Audit();
|
||||
auditable.setAudit(audit);
|
||||
}
|
||||
if (audit == null) {
|
||||
audit = new Audit();
|
||||
auditable.setAudit(audit);
|
||||
}
|
||||
|
||||
LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC);
|
||||
audit.setCreatedOn(now);
|
||||
audit.setLastUpdatedOn(now);
|
||||
LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC);
|
||||
audit.setCreatedOn(now);
|
||||
audit.setLastUpdatedOn(now);
|
||||
// audit.setCreatedBy(LoggedUser.get()); // TODO where to get the user from
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("prePersist executed");
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("prePersist executed");
|
||||
}
|
||||
|
||||
// @PreUpdate
|
||||
public void preUpdate(Auditable auditable) {
|
||||
Audit audit = auditable.getAudit();
|
||||
}
|
||||
|
||||
LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC);
|
||||
// Date now = DateUtil.getCurrentTimeInUTC();
|
||||
audit.setLastUpdatedOn(now);
|
||||
// audit.setUpdatedBy(LoggedUser.get()); // TODO where to get the user from
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("preUpdate executed");
|
||||
}
|
||||
// @PreUpdate
|
||||
public void preUpdate(Auditable auditable) {
|
||||
Audit audit = auditable.getAudit();
|
||||
|
||||
// TODO where to get the user from
|
||||
LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC);
|
||||
audit.setLastUpdatedOn(now);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("preUpdate executed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
||||
debug="false">
|
||||
|
||||
<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c] %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<category name="de.muehlencord">
|
||||
<priority value="DEBUG"/>
|
||||
</category>
|
||||
|
||||
<category name="com.sun">
|
||||
<priority value="WARN"/>
|
||||
</category>
|
||||
|
||||
<category name="javax.xml">
|
||||
<priority value="WARN"/>
|
||||
</category>
|
||||
|
||||
<logger name="org.hibernate">
|
||||
<level value="info"/>
|
||||
</logger>
|
||||
|
||||
<root>
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="consoleAppender" />
|
||||
</root>
|
||||
</log4j:configuration>
|
||||
Reference in New Issue
Block a user