-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
code refactoring #22
base: master
Are you sure you want to change the base?
code refactoring #22
Conversation
@@ -23,6 +23,109 @@ | |||
@RequestMapping("api/import") | |||
public class ImportCSV { | |||
|
|||
class ParsedEntity { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great idea to create an inner class to ease parsing :)
private int pos; | ||
|
||
/*** | ||
* contructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this comments were not finished because of time reasons...just want to comment that a more meaning full text would help why you added this class
* @param pet | ||
* @return | ||
*/ | ||
public boolean deregisterPetFromOwner(Pet pet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that you kept the indentations small throughout the class :) except maybe in this class, the for-loop and three if-clauses could be eased a bit
HttpHeaders headers = new HttpHeaders(); | ||
if (matchingOwners.size() == 0) { | ||
headers.add("errors", "Owner not found"); | ||
return new ResponseEntity<List<Pet>>(headers, HttpStatus.BAD_REQUEST); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that you return meaningful error messages
@@ -33,106 +136,62 @@ | |||
produces = "application/json") | |||
public ResponseEntity<List<Pet>> importPets(@RequestBody String csv) { | |||
|
|||
int i = 0; | |||
int pos = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method is maybe still a bit long...maybe you could extract some methods to create e.g., the importPets
method only handles the http request, and then you have a new methods that orchestrates the parsing and then you have many small methods that to the parsing of the various fields and updating the database
refactoring from group 4