angular-to-react-redux
angular-to-react-redux copied to clipboard
Setup Java REST API
This is a task for @ericarao to put all of the concepts that she and I have been overviewing to action. This API will be used by the Angular and React/Redux applications to edit/read basic patient information as well as edit/add/delete/get contact information.
Tasks
- [x] Create a Postgres database with the tables and their relations
- [x] Select/setup a Java REST web framework (Spark, Spring Boot, Play, etc)
- [x] Create entities and repositories using an ORM
- [x] Set up the /api/patient/{pid}/basic and /api/patient/{pid}/contact endpoints
- [ ] Set up controllers
- [ ] Set up services
- [ ] Write unit tests
- [x] Enhance Maven to check for style issues
- [ ] Enhance Maven to generate unit test coverage reports
- [ ] Add application logging
- [ ] Add comment documentation as needed
- [ ] Introduce an /api/auth endpoint with token based sessions (can make more fancy later)
- [ ] Deploy to Heroku
- [ ] Create tickets for the Angular and React/Redux applications to use the REST api
@ericarao feel free to create a server
folder in this repo where you can put your code.
@ question#3: By entities and repositories, is it only applicable to Spring MVC/Boot? Dropwizard uses dao and abstract resource design, I think.
Yeah, you're an owner on this repo so feel free to edit the task list to whatever the terms are for Dropwizard. I've heard Entity, Resource, and Model for what I call Entity. I've heard DAO and Repository for what I call Repository. It's all the same conceptually.
Need any help with anything BTW? Things going smoothly?
@MatthewVita Mostly. I want to try doing it with both but am definitely less familiar with Spring. The documentation on the Spring website is pretty good. Although the internet seems to think the bug is a maven issue, I'm inclined to think that since part of the errors I'm getting is talking about missing beans, I'm supposed to define the beans with the @Bean
annotation.
@ericarao don't worry about Spring... you're making great progress with DropWizard! Great job!
Some questions:
-
SELECT * FROM expenses WHERE id = :id
(what is expenses... copy/paste issue?) - What is
Egg
? - Have you looked into Flywheel? It's a bit lighter weight than liquidbase for our use case. Doesn't matter to me... research both and see which is the easiest.
Yuuup. Copypaste issue. Was being lazy. WHOOPS.
Egg is some vernacular thing I picked up from Kevin, it just means an incomplete object (minus ID) so it's an "egg" that hatches into the full object.
We should follow Domain-driven design (DDD) as much as possible. Stolen from Wikipedia:
Entity
An object that is not defined by its attributes, but rather by a thread of continuity and its identity. Example: Most airlines distinguish each seat uniquely on every flight. Each seat is an entity in this context. However, Southwest Airlines, EasyJet and Ryanair do not distinguish between every seat; all seats are the same. In this context, a seat is actually a value object.
Value Object
An object that contains attributes but has no conceptual identity. They should be treated as immutable. Example: When people exchange business cards, they generally do not distinguish between each unique card; they only are concerned about the information printed on the card. In this context, business cards are value objects.
Aggregate
A collection of objects that are bound together by a root entity, otherwise known as an aggregate root. The aggregate root guarantees the consistency of changes being made within the aggregate by forbidding external objects from holding references to its members. Example: When you drive a car, you do not have to worry about moving the wheels forward, making the engine combust with spark and fuel, etc.; you are simply driving the car. In this context, the car is an aggregate of several other objects and serves as the aggregate root to all of the other systems.
Domain Event
A domain object that defines an event (something that happens). A domain event is an event that domain experts care about.
Service
When an operation does not conceptually belong to any object. Following the natural contours of the problem, you can implement these operations in services. See also Service (systems architecture).
Repository
Methods for retrieving domain objects should delegate to a specialized Repository object such that alternative storage implementations may be easily interchanged.
Factory
Methods for creating domain objects should delegate to a specialized Factory object such that alternative implementations may be easily interchanged.
I'm having issues where basically I'm registering that I need the naming strategy to be set to snakecase or something similar because postgres is case-insensitive (would prefer not to have to do a workaround where I put everything in "quotations") so my camelcase stuff would just be like postCode -> postcode, so I changed it to snakecase, but I'm having an issue where Jackson doesn't seem to register it as "oh serialize and deserialize using the snakecase rule". So it just bricks because it's doing camelcase still.
At the moment I'm kinda staring at all the things Jackson is doing under the hood, trying to figure out if this is a Jackson issue or a configuration issue on my end.
Please ignore, problem fixed.
@ericarao Things are looking good!
It looks like the "egg" concept is a https://en.wikipedia.org/wiki/Data_transfer_object I'm a big fan of consistency, so let's use this in the relevant class names. Server-side folks should, in theory, be able to switch from codebase to codebase without much confusion with names, concepts, etc.
Moving this to 1.0.1 release because it probably won't be done in time for 1.0.0