Commit 201450f1a8b5379e63f6d55a9c2e2fe61f4067af
1 parent
0649065c
add entity manager for user
Showing
6 changed files
with
32 additions
and
36 deletions
docker/docker-compose.yml
| @@ -33,18 +33,16 @@ services: | @@ -33,18 +33,16 @@ services: | ||
| 33 | container_name: chatbot-postgres | 33 | container_name: chatbot-postgres |
| 34 | image: postgres | 34 | image: postgres |
| 35 | restart: always | 35 | restart: always |
| 36 | - expose: | ||
| 37 | - - "5432" | 36 | + ports: |
| 37 | + - "5432:5432" | ||
| 38 | environment: | 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 | adminer: | 43 | adminer: |
| 46 | container_name: adminer_dbmanagement | 44 | container_name: adminer_dbmanagement |
| 47 | image: adminer | 45 | image: adminer |
| 48 | restart: always | 46 | restart: always |
| 49 | ports: | 47 | ports: |
| 50 | - - "8081:8080" | 48 | - - "8081:8080" |
| 49 | + - "8081:8080" | ||
| 51 | \ No newline at end of file | 50 | \ No newline at end of file |
docker/wildfly/standalone.xml
| @@ -417,32 +417,6 @@ | @@ -417,32 +417,6 @@ | ||
| 417 | <client-config name="Standard-Client-Config"/> | 417 | <client-config name="Standard-Client-Config"/> |
| 418 | </subsystem> | 418 | </subsystem> |
| 419 | <subsystem xmlns="urn:jboss:domain:weld:3.0"/> | 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 | </profile> | 420 | </profile> |
| 447 | 421 | ||
| 448 | <interfaces> | 422 | <interfaces> |
services/Global/src/main/java/de/bht/beuthbot/entities/EntityBase.java
| @@ -29,7 +29,7 @@ public class EntityBase implements Entity { | @@ -29,7 +29,7 @@ public class EntityBase implements Entity { | ||
| 29 | 29 | ||
| 30 | @PreUpdate | 30 | @PreUpdate |
| 31 | protected void onUpdate() { | 31 | protected void onUpdate() { |
| 32 | - updateDate = new Date(); | 32 | + this.updateDate = new Date(); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | @Override | 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,6 +38,6 @@ public class User extends EntityBase implements de.bht.beuthbot.model.entities.U | ||
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | public void setVegetarian(boolean vegetarian) { | 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,7 +10,7 @@ | ||
| 10 | 10 | ||
| 11 | <properties> | 11 | <properties> |
| 12 | <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /> <!-- DB Driver --> | 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 | <property name="javax.persistence.jdbc.user" value="beuthbot_app" /> <!-- DB User --> | 14 | <property name="javax.persistence.jdbc.user" value="beuthbot_app" /> <!-- DB User --> |
| 15 | <property name="javax.persistence.jdbc.password" value="VhS7WPVpdYEHYLpf" /> <!-- DB Password --> | 15 | <property name="javax.persistence.jdbc.password" value="VhS7WPVpdYEHYLpf" /> <!-- DB Password --> |
| 16 | 16 |