46 lines
2.9 KiB
Markdown
46 lines
2.9 KiB
Markdown
# Lunatech COVID Assessment
|
|
|
|
Please use this readme as your projects readme. You can find instructions for
|
|
the assignment in the [`INSTRUCTIONS.md`](INSTRUCTIONS.md) file.
|
|
|
|
Overview
|
|
========
|
|
|
|
This project is a simple command-line application that communicates with a PostgreSQL database to retrieve data and generate reports based on that data. It's composed of several classes and packages that work together to accomplish this task.
|
|
|
|
Classes and packages
|
|
--------------------
|
|
|
|
The application's main class is `Main` class, it runs the entire application. It's composed of three services: `AppConfigService`, `DatabaseService`, and `ReportGenerationService`.
|
|
|
|
### AppConfigService
|
|
|
|
`AppConfigService` is a service class that prompts and stores the configuration that the app needs to be run with. It prompts the user for input for the country name and date, and stores them as class members.
|
|
|
|
### DatabaseService
|
|
|
|
`DatabaseService` class is responsible for maintaining the active connection between the app and the SQL Server. It also communicates with the `DatabaseApi` class to perform final CRUD operations and return any results.
|
|
|
|
### ReportGenerationService
|
|
|
|
`ReportGenerationService` generates a report from results. Since only a std-out is the only strategy, composition is preferred. It provides a single method `reportBaseResults(QueryResultsRepository queryResultsRepository)` that takes a `QueryResultsRepository` object as input and prints the results to the console. The method prints the `toString()` representation of the `QueryResultsRepository` object. It provides a basic printer and more members can be added in the future to use different strategies for printing out the received results.
|
|
|
|
### data.dtos
|
|
|
|
`data.dtos` package contains the `QueryDTO` class. This class serves as a container for storing SQL statements to be executed, along with their arguments.
|
|
|
|
### data.enums
|
|
|
|
`data.enums` package contains the `CustomPreparedStatementsRead` enum. This enum contains all the read-only prepared statements that are used throughout the application.
|
|
|
|
### data.repos
|
|
|
|
`data.repos` package contains the `QueryResultsRepository` class. This class stores the results of the executed queries, and can be used to generate a report.
|
|
|
|
### data.models
|
|
|
|
`data.models` package contains the `PersistentResultSetModel` class. This class adapts a given `ResultSet` to a `PersistentResultModel`.
|
|
|
|
### apis
|
|
|
|
`apis` package contains the `DatabaseApi` class. This class communicates with the database to perform final CRUD operations, returning any results. This class is responsible for executing SQL statements, which are passed to it in the form of a QueryDTO class. It receives a QueryDTO object and a JDBC connection, then it processes the query and returns a PreparedStatement object. This class is designed to handle any exception that may occur during the execution of the query and it can be extended in the future to handle other types of queries if needed.
|