rebase conflicts

This commit is contained in:
LahaLuhem 2023-01-13 21:27:44 +01:00
parent d5730455e6
commit a8687095c2
9 changed files with 30 additions and 24 deletions

BIN
.DS_Store vendored

Binary file not shown.

3
.idea/.gitignore vendored
View File

@ -1,3 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="19" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" project-jdk-name="19" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -3,11 +3,34 @@
Please use this readme as your projects readme. You can find instructions for
the assignment in the [`INSTRUCTIONS.md`](INSTRUCTIONS.md) file.
# Table of contents
- [Setup instructions](#setup-instructions)
- [Overview](#overview)
* [Classes and packages](#classes-and-packages)
+ [Services](#services)
- [AppConfigService](#appconfigservice)
- [DatabaseService](#databaseservice)
- [ReportGenerationService](#reportgenerationservice)
+ [Data](#data)
- [DTOs](#dtos)
- [Enums](#enums)
- [Repos](#repos)
- [Models](#models)
+ [APIs](#apis)
- [Improvements](#improvements)
# Setup instructions
1. Add the [postgresql-42.5.1.jar](libs/postgresql-42.5.1.jar) as a library dependency in your IDE.
+ Instructions for specific IDEs: [IntelliJ](https://stackoverflow.com/questions/1051640/correct-way-to-add-external-jars-lib-jar-to-an-intellij-idea-project), [Eclipse](https://www.edureka.co/community/4028/how-to-import-a-jar-file-in-eclipse)
+ Per build-tool, for different version etc. [Maven](https://mvnrepository.com/artifact/mysql/mysql-connector-java), [Gradle](https://stackoverflow.com/a/50484781/11981966), [Ant](https://ant.apache.org/manual/api/org/apache/tools/ant/taskdefs/JDBCTask.html).
2. Follow the Docker-setup instruction in [INSTRUCTIONS.md](INSTRUCTIONS.md#setup).
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.
![Class UML](docs/ClassUML.png)
Classes and packages
--------------------
@ -41,16 +64,18 @@ The application's main class is `Main` class, it runs the entire application. It
### 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.
### Improvements
# Improvements
Here are some points that I could have improved upon, but did not go through with it because of either time constraints, or because it might be too much for the scope of this assignment.
+ Ideally all the services, and inner services and APIs being used, should be injected in by dependency injection. In Dart, [get_it](https://pub.dev/packages/get_it), is makes this very easy with a Locator file. But for Java, I was not able to find something that was as easy.
+ Ideally the AppConfigService should be more generalized to acecpt N number of user inputs, for the scalability.
+ That would have also helped with making the pipeline in `run()` better, as the list of config vars could be supplied directly, instead of manually specifying.
+ The DatabaseService class is tightly coupling the DatabaseApi class. It's better to make the DatabaseApi class a singleton and inject it into the DatabaseService class.
+ The DatabaseApi class is doing more than just communicating with the database, it's also handling error handling. It would be better to extract the error handling logic into a separate class.
+ Could be rectified by using lots of custom Exceptions in general, but overkill for this scope.
+ The QueryResultsRepository class is tightly coupled to the PersistentResultSetModel class. It would be better to extract the PersistentResultSetModel class into a separate package, and use a factory pattern to create instances of it.
+ The App class is doing too much. It would be better to extract the logic for each endpoint into separate classes, and use a factory pattern to create instances of them.
+ But then again, too much inheritance.
+ But then till it is needed, composition was preferred over inheritance.
+ The Main class should be refactored to use dependency injection, so that the dependencies can be easily swapped out for testing.
+ The AppConfigService class should be refactored to use a more robust input validation library, to handle more edge cases.
+ The ReportGenerationService class should be refactored to support more output formats, such as HTML, CSV and PDF.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 830 KiB

After

Width:  |  Height:  |  Size: 826 KiB

View File

@ -93,8 +93,6 @@ class App {
resultsRepository = databaseService.getReadReportsEndpoint(new QueryDTO(query, new Object[]{appConfigService.getCountryName(), appConfigService.getDate(),}));
reportGenerationService.reportBaseResults(resultsRepository);
}
} catch (SQLException e) {
throw new RuntimeException(e);
}

View File

@ -1,7 +0,0 @@
package constants;
import java.text.SimpleDateFormat;
public class Formatters {
final public static SimpleDateFormat APPLICATION_DATE_FORMATTER = new SimpleDateFormat("dd-MM-yyyy");
}

View File

@ -1,7 +0,0 @@
package constants;
public class ConstValues {
//I
final public static String inputCountryName = "Enter country: ";
final public static String inputDate = "Enter date: ";
}