-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PRMT-3744] WIP Start working with ebean to connect to postgres db
- Loading branch information
1 parent
9f56ea8
commit ed7d3d4
Showing
18 changed files
with
259 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/main/java/uk/nhs/prm/e2etests/configuration/EBeanConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package uk.nhs.prm.e2etests.configuration; | ||
|
||
import io.ebean.Database; | ||
import io.ebean.DatabaseFactory; | ||
import io.ebean.config.DatabaseConfig; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import uk.nhs.prm.e2etests.property.PostgresDbProperties; | ||
|
||
import java.util.Properties; | ||
|
||
@Configuration | ||
public class EBeanConfiguration { | ||
private final PostgresDbProperties databaseProperties; | ||
|
||
public EBeanConfiguration( | ||
PostgresDbProperties databaseProperties | ||
) { | ||
this.databaseProperties = databaseProperties; | ||
} | ||
|
||
// /** | ||
// * Simple Spring bean factory for creating the EbeanServer. | ||
// */ | ||
// public class MyEbeanServerFactory implements FactoryBean<EbeanServer> { | ||
// | ||
// public EbeanServer getObject() throws Exception { | ||
// | ||
// return createEbeanServer(); | ||
// } | ||
// | ||
// public Class<?> getObjectType() { | ||
// return EbeanServer.class; | ||
// } | ||
// | ||
// public boolean isSingleton() { | ||
// return true; | ||
// } | ||
// | ||
// /** | ||
// * Create a EbeanServer instance. | ||
// */ | ||
// private EbeanServer createEbeanServer() { | ||
// | ||
// ServerConfig config = new ServerConfig(); | ||
// config.setName("pg"); | ||
// | ||
// // load configuration from ebean.properties | ||
// config.loadFromProperties(); | ||
// config.setDefaultServer(true); | ||
// ... | ||
// // other programmatic configuration | ||
// | ||
// return EbeanServerFactory.create(config); | ||
// } | ||
// } | ||
|
||
|
||
|
||
|
||
@Bean | ||
public Database ehrOutDatabase() { | ||
DatabaseConfig configuration = new DatabaseConfig(); | ||
|
||
Properties properties = new Properties(); | ||
properties.put("ebean.db.ddl.generate", "true"); | ||
properties.put("ebean.db.ddl.run", "true"); | ||
properties.put("datasource.db.databaseDriver", "org.postgresql.Driver"); | ||
properties.put("datasource.db.username", databaseProperties.getEhrOutDatabaseUsername()); | ||
properties.put("datasource.db.password", databaseProperties.getEhrOutDatabasePassword()); | ||
properties.put("datasource.db.databaseUrl", String.format("jdbc:postgresql://%s/%s", | ||
databaseProperties.getEhrOutDatabaseHost(), | ||
databaseProperties.getEhrOutDatabaseName())); | ||
|
||
configuration.loadFromProperties(properties); | ||
return DatabaseFactory.create(configuration); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/uk/nhs/prm/e2etests/exception/NotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package uk.nhs.prm.e2etests.exception; | ||
|
||
public class NotFoundException extends RuntimeException { | ||
private static final String MESSAGE = "A record could not be found with ID: %s"; | ||
|
||
public NotFoundException(String id) { | ||
super(String.format(MESSAGE, id)); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/uk/nhs/prm/e2etests/model/database/Acknowledgement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package uk.nhs.prm.e2etests.model.database; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import java.time.LocalDateTime; | ||
import java.util.UUID; | ||
import lombok.Getter; | ||
|
||
@Entity | ||
@Getter | ||
public class Acknowledgement { | ||
@Id | ||
private UUID messageId; | ||
private String acknowledgementTypeCode; | ||
private String acknowledgementDetail; | ||
private String service; | ||
private String referencedMessageId; | ||
private String messageRef; | ||
private LocalDateTime createdAt; | ||
private LocalDateTime updatedAt; | ||
private LocalDateTime deletedAt; | ||
} |
15 changes: 0 additions & 15 deletions
15
src/main/java/uk/nhs/prm/e2etests/property/AbstractSsmRetriever.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.