Commit 201450f1a8b5379e63f6d55a9c2e2fe61f4067af

Authored by hausdoerfer
1 parent 0649065c

add entity manager for user

docker/docker-compose.yml
... ... @@ -33,18 +33,16 @@ services:
33 33 container_name: chatbot-postgres
34 34 image: postgres
35 35 restart: always
36   - expose:
37   - - "5432"
  36 + ports:
  37 + - "5432:5432"
38 38 environment:
39   - POSTGRES_USER: 'beuthbot_app'
40   - POSTGRES_PASSWORD: 'VhS7WPVpdYEHYLpf'
41   - POSTGRES_DB: 'beuthbot'
42   - volumes:
43   - - ./postgres/volumes/:/var/lib/postgresql
  39 + POSTGRES_USER: beuthbot_app
  40 + POSTGRES_PASSWORD: VhS7WPVpdYEHYLpf
  41 + POSTGRES_DB: beuthbot
44 42  
45 43 adminer:
46 44 container_name: adminer_dbmanagement
47 45 image: adminer
48 46 restart: always
49 47 ports:
50 48 - - "8081:8080"
  49 + - "8081:8080"
51 50 \ No newline at end of file
... ...
docker/wildfly/standalone.xml
... ... @@ -417,32 +417,6 @@
417 417 <client-config name="Standard-Client-Config"/>
418 418 </subsystem>
419 419 <subsystem xmlns="urn:jboss:domain:weld:3.0"/>
420   - <subsystem xmlns="urn:jboss:domain:datasources:1.0">
421   - <datasources>
422   - <datasource jndi-name="java:/PostgreSqlDS" pool-name="PostgreSqlDS_Pool" enabled="true" jta="false" use-ccm="false">
423   - <connection-url>
424   - jdbc:postgresql://postgres-db:5432/beuthbot
425   - </connection-url>
426   - <driver-class>
427   - org.postgresql.Driver
428   - </driver-class>
429   - <driver>
430   - postgresql
431   - </driver>
432   - <security>
433   - <user-name>beuthbot_app</user-name>
434   - <password>VhS7WPVpdYEHYLpf</password>
435   - </security>
436   - </datasource>
437   - <drivers>
438   - <driver name="postgresql" module="org.postgresql">
439   - <xa-datasource-class>
440   - org.postgresql.xa.PGXADataSource
441   - </xa-datasource-class>
442   - </driver>
443   - </drivers>
444   - </datasources>
445   - </subsystem>
446 420 </profile>
447 421  
448 422 <interfaces>
... ...
services/Global/src/main/java/de/bht/beuthbot/entities/EntityBase.java
... ... @@ -29,7 +29,7 @@ public class EntityBase implements Entity {
29 29  
30 30 @PreUpdate
31 31 protected void onUpdate() {
32   - updateDate = new Date();
  32 + this.updateDate = new Date();
33 33 }
34 34  
35 35 @Override
... ...
services/Global/src/main/java/de/bht/beuthbot/entities/User.java
... ... @@ -38,6 +38,6 @@ public class User extends EntityBase implements de.bht.beuthbot.model.entities.U
38 38 }
39 39  
40 40 public void setVegetarian(boolean vegetarian) {
41   - isVegetarian = vegetarian;
  41 + this.isVegetarian = vegetarian;
42 42 }
43 43 }
... ...
services/Global/src/main/java/de/bht/beuthbot/persistence/UserManager.java 0 → 100644
  1 +package de.bht.beuthbot.persistence;
  2 +
  3 +import de.bht.beuthbot.entities.User;
  4 +
  5 +import javax.ejb.Stateless;
  6 +import javax.persistence.EntityManager;
  7 +import javax.persistence.PersistenceContext;
  8 +
  9 +@Stateless
  10 +public class UserManager {
  11 +
  12 + @PersistenceContext(unitName="de.bht.beuthbot.jpa")
  13 + protected EntityManager entityManager;
  14 +
  15 + public void createUser() {
  16 + User user = new User();
  17 + user.setFacebookUserId("FacebookUserId");
  18 + user.setTelegramUserId("TelegramUserId");
  19 + user.setVegetarian(true);
  20 +
  21 + entityManager.persist(user);
  22 + }
  23 +}
... ...
services/Global/src/main/webapp/META-INF/persistence.xml
... ... @@ -10,7 +10,7 @@
10 10  
11 11 <properties>
12 12 <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /> <!-- DB Driver -->
13   - <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://postgres-server:5432/beuthbot" /> <!-- BD Name -->
  13 + <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/beuthbot" /> <!-- BD Name -->
14 14 <property name="javax.persistence.jdbc.user" value="beuthbot_app" /> <!-- DB User -->
15 15 <property name="javax.persistence.jdbc.password" value="VhS7WPVpdYEHYLpf" /> <!-- DB Password -->
16 16  
... ...