Initialer commit

This commit is contained in:
2026-03-18 22:00:54 +01:00
commit 7adb3acc8d
426 changed files with 8484 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/main" path="src/main/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/webapp">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/resources">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="/framework">
<attributes>
<attribute name="without_test_code" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin/default"/>
</classpath>

33
aufgaben-service/.project Normal file
View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>aufgaben-service</name>
<comment></comment>
<projects/>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments/>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments/>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments/>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments/>
</buildCommand>
</buildSpec>
<linkedResources/>
<filteredResources/>
</projectDescription>

View File

@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1

View File

@@ -0,0 +1,13 @@
#
#Sat Apr 01 12:17:22 CEST 2023
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.source=17
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.sourceFile=generate

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="aufgaben-service">
<property name="context-root" value="aufgaben-service"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/webapp"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
<wb-resource deploy-path="/" source-path="src/main/webapp"/>
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/framework/framework">
<dependency-type>uses</dependency-type>
</dependent-module>
</wb-module>
</project-modules>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="jst.java"/>
<fixed facet="jst.web"/>
<installed facet="jst.web" version="2.4"/>
<installed facet="jst.java" version="17"/>
</faceted-project>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Validate the database schema on startup -->
<property name="hbm2ddl.auto">validate</property>
</session-factory>
</hibernate-configuration>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0" >
<persistence-unit name="registration"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/Aufgaben</jta-data-source>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?><web-app version="5.0"
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd">
</web-app>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1 @@
<h1>Was machst du hier?</h1>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
<File name="MyFile" fileName="all.log" immediateFlush="false" append="false">
<PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</File>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="Console" />
<AppenderRef ref="MyFile"/>
</Root>
</Loggers>
</Configuration>

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,39 @@
plugins {
id 'java'
id 'war'
id 'eclipse'
}
repositories {
mavenCentral()
}
sourceSets {
main {
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/main/webapp'
// srcDir 'src/main/resources'
}
}
}
dependencies {
implementation project(':framework')
compileOnly 'jakarta.platform:jakarta.jakartaee-web-api:9.0.0'
compileOnly 'jakarta.persistence:jakarta.persistence-api:3.1.0'
compileOnly 'jakarta.resource:jakarta.resource-api:2.1.0'
compileOnly 'org.jboss.ejb3:jboss-ejb3-ext-api:2.3.0.Final'
compileOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.20.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
}
tasks.named('test') {
useJUnitPlatform()
}

Binary file not shown.

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Validate the database schema on startup -->
<property name="hbm2ddl.auto">validate</property>
</session-factory>
</hibernate-configuration>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0" >
<persistence-unit name="registration"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/Aufgaben</jta-data-source>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?><web-app version="5.0"
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd">
</web-app>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1 @@
<h1>Was machst du hier?</h1>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
<File name="MyFile" fileName="all.log" immediateFlush="false" append="false">
<PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</File>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="Console" />
<AppenderRef ref="MyFile"/>
</Root>
</Loggers>
</Configuration>

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,2 @@
Manifest-Version: 1.0

View File

@@ -0,0 +1,98 @@
package de.oaa.xxx.aufgaben;
import java.util.List;
import java.util.UUID;
public class Aufgabe {
private UUID aufgabeId;
private String kurzText;
private String text;
private Integer level;
private Integer sekundenVon;
private Integer sekundenBis;
private UUID gruppeId;
private List<Werkzeug> benoetigtAktiv;
private List<Werkzeug> benoetigtPassiv;
private List<Toy> benoetigteToys;
public UUID getAufgabeId() {
return aufgabeId;
}
public void setAufgabeId(UUID aufgabeId) {
this.aufgabeId = aufgabeId;
}
public String getKurzText() {
return kurzText;
}
public void setKurzText(String kurzText) {
this.kurzText = kurzText;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public Integer getSekundenVon() {
return sekundenVon;
}
public void setSekundenVon(Integer sekundenVon) {
this.sekundenVon = sekundenVon;
}
public Integer getSekundenBis() {
return sekundenBis;
}
public void setSekundenBis(Integer sekundenBis) {
this.sekundenBis = sekundenBis;
}
public List<Werkzeug> getBenoetigtAktiv() {
return benoetigtAktiv;
}
public void setBenoetigtAktiv(List<Werkzeug> benoetigtAktiv) {
this.benoetigtAktiv = benoetigtAktiv;
}
public List<Werkzeug> getBenoetigtPassiv() {
return benoetigtPassiv;
}
public void setBenoetigtPassiv(List<Werkzeug> benoetigtPassiv) {
this.benoetigtPassiv = benoetigtPassiv;
}
public List<Toy> getBenoetigteToys() {
return benoetigteToys;
}
public void setBenoetigteToys(List<Toy> benoetigteToys) {
this.benoetigteToys = benoetigteToys;
}
public UUID getGruppeId() {
return gruppeId;
}
public void setGruppeId(UUID gruppeId) {
this.gruppeId = gruppeId;
}
}

View File

@@ -0,0 +1,11 @@
package de.oaa.xxx.aufgaben;
import de.oaa.xxx.framework.AbstractDAO;
import jakarta.persistence.EntityManager;
public class AufgabeDAO extends AbstractDAO<AufgabeEntity> {
public AufgabeDAO(EntityManager entityManager) {
super(AufgabeEntity.class, entityManager);
}
}

View File

@@ -0,0 +1,161 @@
package de.oaa.xxx.aufgaben;
import java.util.List;
import java.util.UUID;
import de.oaa.xxx.framework.XXXEntity;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
@Entity
@Table(name = "aufgabe")
public class AufgabeEntity implements XXXEntity {
@Id
@Column
private UUID aufgabeId;
@Column
private String kurzText;
@Column
private String text;
@Column
private Integer level;
@Column
private Integer sekundenVon;
@Column
private Integer sekundenBis;
@ManyToOne
@JoinColumn(name = "gruppeId")
private AufgabenGruppeEntity aufgabenGruppe;
@Column
@Enumerated
@ElementCollection(targetClass = Werkzeug.class)
private List<Werkzeug> benoetigtAktiv;
@Column
@Enumerated
@ElementCollection(targetClass = Werkzeug.class)
private List<Werkzeug> benoetigtPassiv;
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "aufgabeToy", joinColumns = { @JoinColumn(name = "aufgabeId") }, inverseJoinColumns = {
@JoinColumn(name = "toyId") })
private List<ToyEntity> benoetigteToys;
public UUID getAufgabeId() {
return aufgabeId;
}
public void setAufgabeId(UUID aufgabeId) {
this.aufgabeId = aufgabeId;
}
public String getKurzText() {
return kurzText;
}
public void setKurzText(String kurzText) {
this.kurzText = kurzText;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public Integer getSekundenVon() {
return sekundenVon;
}
public void setSekundenVon(Integer sekundenVon) {
this.sekundenVon = sekundenVon;
}
public Integer getSekundenBis() {
return sekundenBis;
}
public void setSekundenBis(Integer sekundenBis) {
this.sekundenBis = sekundenBis;
}
public AufgabenGruppeEntity getAufgabenGruppe() {
return aufgabenGruppe;
}
public void setAufgabenGruppe(AufgabenGruppeEntity aufgabenGruppe) {
this.aufgabenGruppe = aufgabenGruppe;
}
public List<Werkzeug> getBenoetigtAktiv() {
return benoetigtAktiv;
}
public void setBenoetigtAktiv(List<Werkzeug> benoetigtAktiv) {
this.benoetigtAktiv = benoetigtAktiv;
}
public List<Werkzeug> getBenoetigtPassiv() {
return benoetigtPassiv;
}
public void setBenoetigtPassiv(List<Werkzeug> benoetigtPassiv) {
this.benoetigtPassiv = benoetigtPassiv;
}
public List<ToyEntity> getBenoetigteToys() {
return benoetigteToys;
}
public void setBenoetigteToys(List<ToyEntity> benoetigteToys) {
this.benoetigteToys = benoetigteToys;
}
public Aufgabe toAufgabe() {
Aufgabe aufgabe = new Aufgabe();
aufgabe.setAufgabeId(aufgabeId);
aufgabe.setBenoetigtAktiv(benoetigtAktiv.stream().map(obj -> obj).toList());
aufgabe.setBenoetigteToys(benoetigteToys.stream().map(obj -> obj.toToy()).toList());
aufgabe.setBenoetigtPassiv(benoetigtPassiv.stream().map(obj -> obj).toList());
aufgabe.setGruppeId(aufgabenGruppe.getGruppenId());
aufgabe.setKurzText(kurzText);
aufgabe.setLevel(level);
aufgabe.setSekundenBis(sekundenBis);
aufgabe.setSekundenVon(sekundenVon);
aufgabe.setText(text);
return aufgabe;
}
public static AufgabeEntity create(Aufgabe aufgabe, AufgabenGruppeEntity aufgabenGruppeEntity) {
AufgabeEntity entity = new AufgabeEntity();
entity.setAufgabeId(UUID.randomUUID());
entity.setAufgabenGruppe(aufgabenGruppeEntity);
entity.setBenoetigtAktiv(aufgabe.getBenoetigtAktiv());
entity.setBenoetigteToys(aufgabe.getBenoetigteToys().stream().map(toy -> ToyEntity.create(toy, aufgabenGruppeEntity)).toList());
entity.setBenoetigtPassiv(aufgabe.getBenoetigtPassiv());
entity.setKurzText(aufgabe.getKurzText());
entity.setLevel(aufgabe.getLevel());
entity.setSekundenBis(aufgabe.getSekundenBis());
entity.setSekundenVon(aufgabe.getSekundenVon());
entity.setText(aufgabe.getText());
return entity;
}
}

View File

@@ -0,0 +1,108 @@
package de.oaa.xxx.aufgaben;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.oaa.xxx.framework.request.RequestChecker;
import jakarta.annotation.Resource;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.transaction.SystemException;
import jakarta.transaction.Transactional;
import jakarta.transaction.UserTransaction;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.Status;
import jakarta.ws.rs.core.UriInfo;
@Transactional
@ApplicationScoped
@Path("aufgabe")
public class AufgabeResource {
private Logger LOGGER = LoggerFactory.getLogger(getClass());
@PersistenceContext(name = "aufgaben")
private EntityManager entityManager;
@Resource
private UserTransaction transaction;
@Path("{aufgabeId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response get(@PathParam("aufgabeId") UUID aufgabeId, @Context HttpServletRequest req) throws IllegalStateException, SecurityException, SystemException {
try {
RequestChecker.checkRequest(req);
transaction.begin();
AufgabeEntity entity = new AufgabeDAO(entityManager).findById(aufgabeId);
if (entity != null) {
Aufgabe aufgabe = entity.toAufgabe();
transaction.commit();
return Response.ok(aufgabe).build();
} else {
transaction.rollback();
return Response.noContent().build();
}
} catch (Exception exception) {
LOGGER.error(exception.getMessage(), exception);
transaction.rollback();
return Response.serverError().build();
}
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response create(Aufgabe aufgabe, @Context UriInfo uriInfo, @Context HttpServletRequest req) throws IllegalStateException, SecurityException, SystemException {
try {
RequestChecker.checkRequest(req);
if (aufgabe.getKurzText() == null || aufgabe.getText() == null || aufgabe.getLevel() == null || aufgabe.getGruppeId() == null) {
return Response.status(Status.BAD_REQUEST).build();
}
transaction.begin();
AufgabenGruppeEntity gruppeEntity = new AufgabenGruppeDAO(entityManager).findById(aufgabe.getGruppeId());
if (gruppeEntity == null || gruppeEntity.getAufgaben().size() > 50) {
transaction.rollback();
return Response.status(Status.BAD_REQUEST).build();
}
AufgabeEntity entity = AufgabeEntity.create(aufgabe, gruppeEntity);
new AufgabeDAO(entityManager).persist(entity);
transaction.commit();
return Response.created(uriInfo.getAbsolutePathBuilder().path(entity.getAufgabeId().toString()).build())
.build();
} catch (Exception exception) {
LOGGER.error(exception.getMessage(), exception);
transaction.rollback();
return Response.serverError().build();
}
}
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
public Response delete(Aufgabe aufgabe, @Context HttpServletRequest req) throws IllegalStateException, SecurityException, SystemException {
try {
RequestChecker.checkRequest(req);
transaction.begin();
AufgabeDAO dao = new AufgabeDAO(entityManager);
AufgabeEntity entity = dao.findById(aufgabe.getAufgabeId());
dao.remove(entity);
transaction.commit();
return Response.accepted().build();
} catch (Exception exception) {
LOGGER.error(exception.getMessage(), exception);
transaction.rollback();
return Response.serverError().build();
}
}
}

Some files were not shown because too many files have changed in this diff Show More