-
Notifications
You must be signed in to change notification settings - Fork 0
Home work #1
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
base: master
Are you sure you want to change the base?
Conversation
… and PetController classes.
|
|
||
| if (doctor.getId() == null) { | ||
| synchronized (DoctorController.class) { | ||
| Integer index = doctorMap.size(); |
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 solution works but:
- Use
classas monitor is not good idea. - Better to usage: with
thisas monitor (it is default monitor forsynchronized { ... }) - Even more better: avoid synchronization using non-blocking data types (Atomic....)
- And the best solution: avoid any state and any counters
… and PetController classes. Avoid synchronization using non-blocking data type AtomicInteger.
…orController class into Doctor, Controller, Service and Repository classes.
…YAML config file and create methods getSpecializations and getSpecieList(in DoctorController class) for returning list of available specializations from application.yml file.
|
|
||
| private List<String> specializations = new ArrayList<>(); | ||
|
|
||
| public List<String> getSpecializations() { |
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.
use lombok
| public class DoctorRepository { | ||
|
|
||
| @Autowired | ||
| private DoctorConfig doctorConfig = new DoctorConfig(); |
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.
use constructor injection
|
|
||
| private final UUID uuid1 = UUID.randomUUID(); | ||
| private final UUID uuid2 = UUID.randomUUID(); | ||
| private final UUID uuid3 = UUID.randomUUID(); |
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.
inline these fields
| }}; | ||
|
|
||
| Integer counter = 2; | ||
| private Map<Integer, Pet> synPets = Collections.synchronizedMap(pets); |
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 collection is thread-safe, but it is blocking. better choice: ConcurrentHashMap
…ig class. Add annotation @requiredargsconstructor for using constructor injection in DoctorRepository class. Instead synchronizedMap added ConcurrentHashMap in PetController class. Don't inline UUID fields in DoctorRepository class, because we use Map.
… PostgreSQL DB. Remove class DoctorRepository and implement JpaRepository for working with DB. Change some methods in DoctorController and DoctorService classes for correct working with JPA.
…again - Remove class DoctorRepository and implement JpaRepository for working with DB. Change some methods in DoctorController and DoctorService classes for correct working with JPA.
…ization, for searching name of doctor ignoring case.
…octor schedule. Add date converter. Some changes in config files.
… for find method in JpaDoctorRepository interface. Change SpreengeeConfig.
…tor' in DoctorController class and update query in JpaDoctorRepository.
…tory, Service and Controller classes for Schedule. Refactor all classes in package 'doctor', for separating Doctor and Schedule entities.
… classes and methods with operations of validating from entities classes. Create 'dto' package and PetIdInputDto class for correct working with 'pet id' in Request Body.
| SortedMap<Integer, Integer> sortedSchedule = new TreeMap<>(); | ||
| for (Schedule schedule: set) { | ||
| if(schedule.getDate().equals(date)) { | ||
| sortedSchedule.put(schedule.getTime(), schedule.getPetId()); |
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.
all schedule manipulation (especially modifications) must be done in ScheduleService
| SortedMap<Integer, Integer> sortedSchedule = new TreeMap<>(); | ||
| for (Schedule schedule: set) { | ||
| if(schedule.getDate().equals(date)) { | ||
| sortedSchedule.put(schedule.getTime(), schedule.getPetId()); |
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.
try to rework it using Stream API
…ntroller class, removed logic for getting schedule in concrete day to ScheduleService class and rework it using Stream API.
HW from Lesson 5, CRUD for DoctorController class