Updates, sonar settings

master
Markus Kreth 7 years ago
parent 9426a24d36
commit 2d15c82150
  1. 12
      .classpath
  2. 4
      .project
  3. 2
      .settings/com.vaadin.integration.eclipse.prefs
  4. 1
      .settings/org.eclipse.core.resources.prefs
  5. 3
      .settings/org.eclipse.jdt.core.prefs
  6. 2
      .settings/org.eclipse.wst.common.project.facet.core.xml
  7. 8
      .settings/org.sonarlint.eclipse.core.prefs
  8. 105
      pom.xml
  9. 11
      src/main/java/de/kreth/clubhelperbackend/google/GoogleBaseAdapter.java
  10. 21
      src/main/java/de/kreth/clubhelperbackend/google/calendar/CalendarAdapter.java
  11. 2
      src/main/java/de/kreth/clubhelperbackend/google/calendar/CalendarResource.java
  12. 2
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/CalendarTaskRefresher.java
  13. 33
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusiness.java
  14. 3
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Adress.java
  15. 3
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Attendance.java
  16. 6
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/CalendarComponent.java
  17. 5
      src/main/resources/simplelogger.properties
  18. 2
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDaoTest.java
  19. 56
      src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDataTest.java
  20. 0
      transaction.log

@ -18,18 +18,13 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="target/generated-resources/gwt">
<classpathentry excluding="**" kind="src" output="target/classes" path="target/generated-resources/gwt">
<attributes>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="optional" value="true"/>
@ -42,5 +37,10 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

@ -31,12 +31,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.fusesource.ide.project.RiderProjectBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.fusesource.ide.project.RiderProjectBuilder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>

@ -1,2 +1,2 @@
com.vaadin.integration.eclipse.mavenLatestVersionsUpgrade=["8.4.5","8.5.1"]
com.vaadin.integration.eclipse.mavenLatestVersionsUpgrade=["8.4.5","8.5.2"]
eclipse.preferences.version=1

@ -3,4 +3,5 @@ encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding//target/generated-resources/gwt=UTF-8
encoding/<project>=UTF-8

@ -1,7 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.8"/>
<installed facet="jpt.jpa" version="2.1"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="jst.web" version="3.1"/>
<installed facet="java" version="1.8"/>
</faceted-project>

@ -0,0 +1,8 @@
autoEnabled=true
eclipse.preferences.version=1
extraProperties=
fileExclusions=
idePrefixKey=
projectKey=de.kreth.vaadin.clubhelper\:vaadin-clubhelper
serverId=kreth-development.de
sqPrefixKey=

@ -10,12 +10,12 @@
<packaging>war</packaging>
<name>vaadin-clubhelper</name>
<description>Demo project for Spring Boot</description>
<description>Vaadin Administation Frontend for Clubhelper.</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<version>2.0.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
@ -23,16 +23,19 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<vaadin.version>8.4.4</vaadin.version>
<google-api-version>1.23.0</google-api-version>
<google-api-sheets-version>v4-rev488-1.23.0</google-api-sheets-version>
<google-api-calendar-version>v3-rev271-1.23.0</google-api-calendar-version>
<sonar.login>7af449877bbf41d707e8ae7d322b1d6e9b15a89d</sonar.login>
<sonar.jacoco.reportPaths>target/surefire-reports</sonar.jacoco.reportPaths>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.jacoco.reportPath>${project.basedir}/target/jacoco.exec</sonar.jacoco.reportPath>
</properties>
<dependencies>
@ -70,7 +73,7 @@
<artifactId>calendar-component</artifactId>
<version>2.0-BETA4</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
@ -79,7 +82,7 @@
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-calendar</artifactId>
@ -105,14 +108,23 @@
<artifactId>google-oauth-client-jetty</artifactId>
<version>${google-api-version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>ch.qos.logback</groupId> -->
<!-- <artifactId>logback-classic</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -125,14 +137,19 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
@ -145,8 +162,28 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.4.0-b180830.0438</version>
</dependency>
</dependencies>
@ -168,7 +205,18 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- <plugin> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-compiler-plugin</artifactId> -->
<!-- <version>3.8.0</version> -->
<!-- <dependencies> -->
<!-- <dependency> -->
<!-- <groupId>org.ow2.asm</groupId> -->
<!-- <artifactId>asm</artifactId> -->
<!-- <version>6.2</version> -->
<!-- </dependency> -->
<!-- </dependencies> -->
<!-- </plugin> -->
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
@ -188,7 +236,25 @@
<gwtSdkFirstInClasspath>true</gwtSdkFirstInClasspath>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
-javaagent:${sonar.jacoco.jar}=destfile=${sonar.jacoco.reportPath}
</argLine>
<!-- <test>**/*.java</test> -->
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
@ -223,6 +289,11 @@
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
<repository>
<id>jvnet-nexus-staging</id>
<url>http://maven.java.net/content/repositories/staging/</url>
<layout>default</layout>
</repository>
</repositories>
</project>

@ -60,11 +60,12 @@ public abstract class GoogleBaseAdapter {
}
protected void checkRefreshToken(String serverName) throws IOException {
if (credential == null) {
credential = authorize(serverName);
synchronized (SCOPES) {
if (credential == null) {
credential = authorize(serverName);
}
}
if ((credential.getExpiresInSeconds() != null
&& credential.getExpiresInSeconds() < 3600)) {
@ -87,7 +88,7 @@ public abstract class GoogleBaseAdapter {
* @return an authorized Credential object.
* @throws IOException
*/
private synchronized Credential authorize(String serverName)
private Credential authorize(String serverName)
throws IOException {
if (credential != null && (credential.getExpiresInSeconds() != null
&& credential.getExpiresInSeconds() < 3600)) {

@ -74,8 +74,8 @@ public class CalendarAdapter extends GoogleBaseAdapter {
throw new IllegalStateException(
"Calendar " + calendarSummary + " not found!");
}
Calendar cal = service.calendars().get(calendarId).execute();
return cal;
return service.calendars().get(calendarId).execute();
}
public List<Event> getAllEvents(String serverName)
@ -110,8 +110,8 @@ public class CalendarAdapter extends GoogleBaseAdapter {
oldestCal.add(java.util.Calendar.MONTH, -1);
oldestCal.add(java.util.Calendar.YEAR, -1);
oldestCal.add(java.util.Calendar.HOUR_OF_DAY, -1);
final long oldest = oldestCal.getTimeInMillis();
return oldest;
return oldestCal.getTimeInMillis();
}
List<CalendarListEntry> getCalendarList(String serverName)
@ -154,18 +154,17 @@ public class CalendarAdapter extends GoogleBaseAdapter {
public void run() {
try {
log.debug("Fetching events of calendar \"" + summary + "\"");
log.debug("Fetching events of calendar \"{}\"", summary);
Calendar calendar = getCalendarBySummaryName(items, summary);
DateTime timeMin = new DateTime(oldest);
List<Event> items = service.events().list(calendar.getId())
List<Event> eventItems = service.events().list(calendar.getId())
.setTimeMin(timeMin).execute().getItems();
items.forEach(item -> item.set("colorClass", colorClass));
events.addAll(items);
log.debug("Added " + items.size() + " Events for \"" + summary
+ "\"");
eventItems.forEach(item -> item.set("colorClass", colorClass));
events.addAll(eventItems);
log.debug("Added {} Events for \"{}\"", eventItems.size(), summary);
} catch (IOException e) {
log.error("Unable to fetch Events from " + summary, e);
log.error("Unable to fetch Events from {}", summary, e);
}
}
}

@ -60,7 +60,7 @@ public class CalendarResource {
return new ArrayList<>(configs.values());
}
public class CalendarKonfig {
public static class CalendarKonfig {
private String name;
private String color;

@ -17,7 +17,7 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
@Component
public class CalendarTaskRefresher {
private static final long RATE = 1000 * 60 * 10;
private static final long RATE = 1000L * 60 * 10;
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired

@ -4,6 +4,7 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Collections;
@ -41,7 +42,7 @@ public class EventBusiness {
if (forceRefresh == false) {
List<ClubEvent> list = dao.listAll();
log.trace("Returning events from database: {}");
log.trace("Returning events from database: {}", list);
return list;
}
@ -54,12 +55,11 @@ public class EventBusiness {
List<ClubEvent> list = new ArrayList<>();
try {
if (forceRefresh) {
File f = new File("google_events.json");
f.delete();
out = new BufferedWriter(new FileWriter(f));
}
File f = new File("google_events.json");
Files.delete(f.toPath());
out = new BufferedWriter(new FileWriter(f));
String remoteHost = "localhost";
CalendarAdapter adapter = new CalendarAdapter();
List<com.google.api.services.calendar.model.Event> events = adapter
@ -71,24 +71,25 @@ public class EventBusiness {
out.newLine();
}
if ("cancelled".equals(ev.getStatus()) == false) {
list.add(ClubEvent.parse(ev));
} else {
if ("cancelled".equals(ev.getStatus())) {
log.debug("Cancelled: {}", ev.getSummary());
} else {
list.add(ClubEvent.parse(ev));
}
}
} catch (GeneralSecurityException | IOException
| InterruptedException e) {
log.error("Error loading events from google.", e);
}
if (out != null) {
try {
out.close();
} catch (IOException e) {
log.error("Error writing File", e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
log.error("Error writing File", e);
}
}
}
return Collections.unmodifiableList(list);
}

@ -40,9 +40,6 @@ public class Adress implements Serializable {
@ManyToOne
private Person person;
public Adress() {
}
public int getId() {
return this.id;
}

@ -36,9 +36,6 @@ public class Attendance implements Serializable {
@ManyToOne
private Person person;
public Attendance() {
}
public int getId() {
return this.id;
}

@ -24,7 +24,7 @@ public class CalendarComponent extends CustomComponent {
private static final long serialVersionUID = -9152173211931554059L;
private DateTimeFormatter dfMonth = DateTimeFormatter.ofPattern("MMMM uu");
private transient DateTimeFormatter dfMonth = DateTimeFormatter.ofPattern("MMMM uu");
private Label monthName;
@ -41,8 +41,6 @@ public class CalendarComponent extends CustomComponent {
.withMonth(Month.from(LocalDateTime.now()));
calendar.setCaption("Events");
calendar.setSizeFull();
// calendar.setHandler(this::onNextMonth);
// calendar.setHandler(this::onPrevMonth);
updateMonthText(calendar.getStartDate());
@ -76,7 +74,7 @@ public class CalendarComponent extends CustomComponent {
calendar.markAsDirty();
}
class ClubEventProvider extends BasicItemProvider<ClubEvent> {
static class ClubEventProvider extends BasicItemProvider<ClubEvent> {
private static final long serialVersionUID = -5415397258827236704L;

@ -1,2 +1,3 @@
org.slf4j.simpleLogger.defaultLogLevel = trace
log4j.logger.org.hibernate.type=trace
org.slf4j.simpleLogger.defaultLogLevel = warn
log4j.logger.org.hibernate.type=info
log4j.logger.org.jboss.logging=warn

@ -7,8 +7,8 @@ import java.time.ZonedDateTime;
import java.util.List;
import org.hibernate.query.Query;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;

@ -42,6 +42,27 @@ public class ClubEventDataTest extends AbstractDatabaseTest {
return p;
}
public List<Person> insertPersons(int count) {
List<Person> inserted = new ArrayList<>();
Transaction tx = session.beginTransaction();
for (int i=0; i<count; i++) {
Person p = new Person();
p.setPrename("prename_" + i);
p.setSurname("surname_" + i);
p.setBirth(new Date());
session.save(p);
inserted.add(p);
}
tx.commit();
for (Person p: inserted) {
assertTrue("not saved: " + p , p.getId()>0);
}
return inserted;
}
@Test
public void testInsertEvent() {
ClubEvent ev = creteEvent();
@ -155,6 +176,41 @@ public class ClubEventDataTest extends AbstractDatabaseTest {
assertEquals(2, entries.size());
}
@Test
public void testChangeEventParticipantsRapidly() {
ClubEvent ev = creteEvent();
ev.setPersons(new HashSet<>());
Transaction tx = session.beginTransaction();
session.save(ev);
tx.commit();
ev = session.byId(ClubEvent.class).load(ev.getId());
List<Person> persons = insertPersons(6);
for (Person p: persons) {
ev.getPersons().add(p);
tx = session.beginTransaction();
session.merge(ev);
tx.commit();
}
ev.getPersons().remove(persons.get(2));
tx = session.beginTransaction();
session.merge(ev);
tx.commit();
ev.getPersons().remove(persons.get(4));
tx = session.beginTransaction();
session.merge(ev);
tx.commit();
ev.getPersons().add(persons.get(2));
ev.getPersons().add(persons.get(4));
tx = session.beginTransaction();
session.merge(ev);
tx.commit();
List<ClubeventHasPerson> result = loadEventPersons();
assertEquals(6, result.size());
}
private ClubEvent creteEvent() {
ClubEvent ev = ClubEventBuilder.builder().withId("id").withAllDay(true)
.withCaption("caption").withDescription("description")

Loading…
Cancel
Save