Compare commits

...

369 Commits

Author SHA1 Message Date
cf4d8c05a2 Merge pull request 'single group fix' (#54) from single0-group-fix into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/54
2021-01-25 16:25:13 +01:00
Filip Izydorczyk
72f049b478 single group fix 2021-01-25 16:23:28 +01:00
bb7f1b6737 Merge pull request 'fixed' (#53) from capacity-fix into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/53
2021-01-23 17:23:16 +01:00
Filip Izydorczyk
ad4984bdae fixed 2021-01-23 16:45:36 +01:00
63def650c9 Merge pull request 'fix' (#52) from schedule-fix into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/52
2021-01-22 16:50:30 +01:00
Filip Izydorczyk
a201bcc581 fix 2021-01-22 16:46:53 +01:00
e688f8b71d Merge pull request 'gr_nr + sym' (#51) from new-response-fields into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/51
2021-01-22 16:20:34 +01:00
Filip Izydorczyk
389e557674 gr_nr + sym 2021-01-22 12:34:54 +01:00
dd82acc1de Merge pull request 'statistics' (#50) from statistics into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/50
2021-01-21 16:49:37 +01:00
Filip Izydorczyk
bfa8eb6e3e full groups statistics 2021-01-21 16:22:14 +01:00
Filip Izydorczyk
a910709798 partly accepted statistics 2021-01-21 16:15:01 +01:00
Filip Izydorczyk
270e31f120 Fully accepted statistic 2021-01-21 16:08:53 +01:00
Filip Izydorczyk
6a0d425c37 Added non registered statistic 2021-01-21 15:50:20 +01:00
Filip Izydorczyk
676070c8c7 Students registered satistics 2021-01-21 15:41:56 +01:00
Filip Izydorczyk
7045844653 Groups ammounts 2021-01-21 15:05:45 +01:00
cd2665bd08 Merge pull request 'ZPI-277' (#49) from ZPI-277 into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/49
2021-01-20 16:21:04 +01:00
Filip Izydorczyk
0eccbfe9a3 test fix 2021-01-20 16:11:43 +01:00
Filip Izydorczyk
a304e25629 refresh token 2021-01-20 16:05:43 +01:00
Filip Izydorczyk
af29d0a54a Current tour endpoint 2021-01-20 16:00:09 +01:00
Filip Izydorczyk
20a6db61cc Exchange name 2021-01-20 15:53:07 +01:00
Filip Izydorczyk
20f52746b5 schedule accepted 2021-01-20 15:38:42 +01:00
Filip Izydorczyk
cf875889b9 exchanges fixes + accepted in deanery response 2021-01-20 14:36:09 +01:00
filipizydorczyk
08a4bdde06 posiible mistake in course checking 2021-01-19 23:59:30 +01:00
filipizydorczyk
548e39dc63 posiible mistake in course checking 2021-01-19 23:54:17 +01:00
filipizydorczyk
65ea502619 Update 'restservice/src/main/java/com/plannaplan/controllers/ExchangeController.java'
posiible mistake in course checking
2021-01-19 23:45:54 +01:00
c177314419 Merge pull request 'Adding fixes into master' (#48) from fixes into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/48
2021-01-19 15:07:07 +01:00
Filip Izydorczyk
847dd76fc8 test fix 2021-01-19 12:55:58 +01:00
Filip Izydorczyk
265315b874 All developers endpoints 2021-01-19 12:47:14 +01:00
Filip Izydorczyk
d1a54a93d6 Developer exchange endpoint 2021-01-19 12:13:26 +01:00
Filip Izydorczyk
7f647f9b8a Added call perform algorythm enpoint 2021-01-19 12:05:31 +01:00
Filip Izydorczyk
7b9e334328 Group response downgrade 2021-01-19 11:35:47 +01:00
Filip Izydorczyk
d217536f2c Tours endpoint 2021-01-19 11:33:14 +01:00
Filip Izydorczyk
6a4ea45900 brigning down group tpes 2021-01-19 10:44:35 +01:00
Filip Izydorczyk
06fb41b5dd commision controller not deleting fix 2021-01-19 09:32:57 +01:00
filipizydorczyk
5ec41fa5d0 Merge pull request 'Added type into AssignmentDetailedResponse.java' (#47) from fixed-adding-type into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/47
2021-01-19 09:11:24 +01:00
fa59845be8
Added type into AssignmentDetailedResponse.java
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-18 22:09:10 +01:00
c89d629c61 Merge pull request 'exchanges-new-case' (#46) from exchanges-new-case into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/46
2021-01-18 16:28:11 +01:00
Filip Izydorczyk
5ed445449c new tests 2021-01-18 16:21:32 +01:00
Filip Izydorczyk
0103a028b4 tests repair 2021-01-18 16:07:48 +01:00
Filip Izydorczyk
b740562e9d Added cheks for type and course 2021-01-18 15:51:58 +01:00
Filip Izydorczyk
4cf6cb58cb licence fix 2021-01-18 14:41:07 +01:00
27b357fc86 Merge pull request 'Added licence' (#43) from Add-licence into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/43
2021-01-18 14:38:32 +01:00
3269a36239 Merge pull request 'exchanges-fixes' (#45) from exchanges-fixes into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/45
2021-01-18 14:26:03 +01:00
Filip Izydorczyk
2d28abefea test 2021-01-18 14:19:09 +01:00
Filip Izydorczyk
ad3d4e6900 merge 2021-01-18 14:00:09 +01:00
filipizydorczyk
3222faeab2 Merge pull request 'file-saving' (#44) from file-saving into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/44
2021-01-18 13:37:38 +01:00
Filip Izydorczyk
c5f09a91ec last test 2021-01-18 13:38:24 +01:00
Filip Izydorczyk
11ec43911e new endpoint 2021-01-17 20:36:46 +01:00
c762d7fd4b
Added licence
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-17 17:42:00 +01:00
77c3b9e3a5
Added test for exportData
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-17 17:35:11 +01:00
Filip Izydorczyk
d4514affcc Export csv data 2021-01-17 16:32:59 +01:00
c4ec88e691 Merge pull request 'restrictions' (#42) from restrictions into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/42
2021-01-17 12:30:25 +01:00
Filip Izydorczyk
98d6faf555 Worked blocking accepted assignment 2021-01-16 16:29:24 +01:00
Filip Izydorczyk
2cfe0e7551 Added 2nd tour accepting test 2021-01-16 15:32:50 +01:00
Filip Izydorczyk
707e26e082 conrollers docs 2021-01-16 14:40:17 +01:00
Filip Izydorczyk
9372ea5562 controllers docs checkpoint 2021-01-16 13:57:58 +01:00
Filip Izydorczyk
e600e84ae2 responses done 2021-01-15 17:53:13 +01:00
Filip Izydorczyk
f77213a01e Resrservice docs 1st part 2021-01-15 17:45:29 +01:00
Filip Izydorczyk
061c3a24fe Rest service package notes 2021-01-15 16:42:53 +01:00
Filip Izydorczyk
bf7d0c7dbc Buisness logic docs packages 2021-01-15 16:24:29 +01:00
Filip Izydorczyk
21983fe4f7 Buisness logic docs updated 2021-01-15 15:54:17 +01:00
Filip Izydorczyk
8d007c259f blocking accep[ted assignment deletions 2021-01-14 16:13:09 +01:00
Filip Izydorczyk
28e872ce3a 2nd tour looks if assignment is accepted 2021-01-14 15:05:41 +01:00
Filip Izydorczyk
fafd94f469 Added test 2021-01-14 14:51:22 +01:00
Filip Izydorczyk
423c6667a9 Reapaired tetst 2021-01-14 14:46:45 +01:00
Filip Izydorczyk
334129cb70 Tours re s tiction works - tests needs to be done 2021-01-14 11:21:41 +01:00
filipizydorczyk
9c1a148e20 Merge pull request 'Nowa funkcjonalność: wymiana-przedmiotami' (#41) from wymiana-przedmiotami into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/41
2021-01-13 17:00:48 +01:00
Filip Izydorczyk
ab32ad8561 Added emial to exchanges 2021-01-13 16:52:18 +01:00
Filip Izydorczyk
1506270dec Master mergerd 2021-01-13 15:53:29 +01:00
75a3bc46f2
Checkpoint: Added performExchange into cron
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-13 14:42:13 +01:00
986407b8f8
Checkpoint: Removed unused imports
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-13 14:29:01 +01:00
11469e9314
Checkpoint: ExchangeServiceTest
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-13 14:13:26 +01:00
d1641277ac
Checkpoint: ExchangeServiceTest
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-13 13:30:46 +01:00
ed528ad9a0
Checkpoint: ExchangeServiceTest
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-13 12:23:00 +01:00
f9a27abb32
Checkpoint: Added mew test
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-12 18:39:22 +01:00
1e1160736d
Checkpoint: Added ShouldPerformExchange
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-12 14:35:11 +01:00
bc8f7407fc
Checkpoint: added performExchange 2021-01-12 14:10:48 +01:00
1c12a778af
Checkpoint: Added ExchangeServiceTest
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-12 13:04:57 +01:00
3583d30b26
Checkpoint: Added test to ExchangeRepo
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-11 16:56:39 +01:00
76faedc40d
Checkpoint: Added test to ExchangeRepo
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-11 16:21:25 +01:00
5e459ac429
Checkpoint: Added test to ExchangeRepo
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-11 16:20:59 +01:00
b18f9cd50e
Checkpoint: adding docs
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-10 15:59:26 +01:00
6311ecee92
Checkpoint: removed unsed imports
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-10 14:37:03 +01:00
6fe72465b9
Checkpoint: All test good :3
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-10 14:24:39 +01:00
00f639ad55
Removed unused import
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-10 14:16:31 +01:00
81f870eaa1
Checkpoint: 15/1
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-10 14:15:58 +01:00
2e6f373997
Checkpoint: 5/11
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-10 12:45:51 +01:00
c7feb10997
Checkpoint: ownedGroups.contains(groupId) and tests
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-10 10:57:33 +01:00
b0a1d929e4
Fixed problem
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-09 17:35:53 +01:00
3335155cd8
Proba naprawienia]
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-09 17:05:00 +01:00
df90a57715
Proba naprawienia]
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-09 14:17:39 +01:00
2320d66a35
Proba naprawienia
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-09 14:00:29 +01:00
11d21be627
Proba naprawienia
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-09 13:11:10 +01:00
756e854f31
Proba naprawienia
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-08 16:33:02 +01:00
bbf14b0ff9
Proba naprawienia
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-08 16:26:47 +01:00
a25843ebfd
Proba naprawienia
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-08 16:17:24 +01:00
149796c42a
Proba naprawienia
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-08 16:03:35 +01:00
c6c67e7e29
Poprawki 2021-01-08 15:53:15 +01:00
ad0d9e40c1
Proba naprawienia
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-08 15:28:59 +01:00
1682448627
Proba naprawienia
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-08 15:19:45 +01:00
e24938dfce
Checkpoint: return per ID works
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-07 17:02:12 +01:00
842e38898a
Checkpoint: return all exchanges works
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-07 16:51:35 +01:00
56120c4724
Checkpoint: deleting is working
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-07 16:01:25 +01:00
c8c8b62263
gettoken.py, README.md - update
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 17:29:18 +01:00
ebacbe892d
gettoken.py WORKING IN MY GENTOO
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 17:20:49 +01:00
90f154f23b
Checkpoint: Added docs, improved ExchangeEntity 2021-01-06 17:12:20 +01:00
b633d2c2df
Checkpoints: WORKS but not for all
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 16:50:08 +01:00
df7701ebc8
Checkpoints: Part 1 of Added docs
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 16:23:18 +01:00
f24e62a335
Checkpoint: works first try with endpoint
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 14:50:34 +01:00
3bcc35e75b
Checkpoint: dziala sprawdzanie values in the exchanges/exchange
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 14:34:25 +01:00
6e65c26e3c
Checkpoint: szkielet
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 13:40:04 +01:00
cfc1e3eba7
Added changes
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 12:41:49 +01:00
filipizydorczyk
3b80a70921 Merge pull request 'Changing-file-xls' (#40) from Changing-file-xls into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/40
2021-01-06 12:24:54 +01:00
5edec5aa71
Remove unused import
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 11:56:04 +01:00
5b0097e6c7
Added systemout
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 11:47:18 +01:00
fddd5b757d
Changed tests
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 11:39:58 +01:00
7813f148eb
Added new column type with reading it and write groupType into DB
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 11:39:42 +01:00
8c0b880412
Change update function and added new contrutor in the Groups 2021-01-06 11:39:02 +01:00
fe06243bda
Added new enums and desription
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 11:38:16 +01:00
f9fc7fa7bd
Added new data
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-06 11:36:29 +01:00
68dfd2473a Merge pull request 'accept-algorythm' (#39) from accept-algorythm into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/39
2021-01-05 12:20:34 +01:00
Filip Izydorczyk
ddabc1a0b9 Docs fixes 2021-01-05 11:50:25 +01:00
Filip Izydorczyk
463af01dc6 Added tests 2021-01-05 11:44:54 +01:00
Filip Izydorczyk
0b40d3729c 0 0 2021-01-05 11:14:29 +01:00
Filip Izydorczyk
3485dff86f Added performing tours and docs 2021-01-05 11:14:10 +01:00
Filip Izydorczyk
2141f35e3f Chcekpoint - needs docs cleaning and tests 2021-01-04 18:10:14 +01:00
Filip Izydorczyk
a6e6618202 Added structare for tour endindgs 2021-01-03 18:06:25 +01:00
Filip Izydorczyk
44f8c610d9 Tested in big data set 2021-01-03 17:57:32 +01:00
Filip Izydorczyk
95cc34c676 Docs + email sending 2021-01-03 17:10:36 +01:00
Filip Izydorczyk
61d035e342 Code cleaning 2021-01-03 16:30:15 +01:00
Filip Izydorczyk
0f8b4eafb5 Checkpint - algorythm works 2021-01-03 16:21:06 +01:00
Filip Izydorczyk
2c0008afe1 Checkpoint - added many to many user group relations and test cerating users and groups to accept test 2021-01-02 15:26:05 +01:00
Filip Izydorczyk
4b096a50bf Added getting sorted students 2021-01-02 14:35:00 +01:00
Filip Izydorczyk
ff9aa64470 Added accepted status to assignments 2021-01-02 14:01:50 +01:00
Filip Izydorczyk
a41c6f2583 Added points ranking to entity 2021-01-02 13:45:03 +01:00
ef896e9c12
Added
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2021-01-02 13:16:43 +01:00
3bce1f91ec Merge pull request 'api-service' (#38) from api-service into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/38
2020-12-31 14:33:50 +01:00
Filip Izydorczyk
665807240f Adden user data completion and docs correction 2020-12-31 14:24:55 +01:00
Filip Izydorczyk
cd0f4bccd9 Added api service 2020-12-31 13:45:07 +01:00
Filip Izydorczyk
ccb0161609 Checkpoint 2020-12-29 19:01:09 +01:00
9f1e21a29f Merge pull request 'forntend-fixes' (#37) from forntend-fixes into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/37
2020-12-29 16:41:04 +01:00
Filip Izydorczyk
a0570a055f Schedule taken places 2020-12-29 16:36:12 +01:00
Filip Izydorczyk
eecb1a6d36 Added capacioty to course/all 2020-12-29 15:32:09 +01:00
Filip Izydorczyk
389e934035 changed pres 2020-12-27 14:15:52 +01:00
filipizydorczyk
4cec07e369 Merge pull request 'admin-user' (#36) from admin-user into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/36
2020-12-27 14:09:55 +01:00
817350e85e
Added UserRepositoryTest and users/admin users/deanery
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-27 13:54:33 +01:00
da4e683248
Added new /config/tours, tests
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-26 15:33:17 +01:00
09cc994d92
Added new tests
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-26 14:31:09 +01:00
c3d78505c8
Added new test for new columns and update groups
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-26 14:18:47 +01:00
f51979484f
Added new columns into a FileMigrator and etc
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-26 13:17:39 +01:00
038d0b95d2
Added ne xlsx file
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-26 13:01:19 +01:00
4758c505c4
Merge branch 'Dodanie-nowych-kolumn' into admin-user 2020-12-26 12:47:13 +01:00
7a62c8d7d8
Added ne xlsx file
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-26 12:22:00 +01:00
9e6ee6dbb3
Updated
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-26 12:09:55 +01:00
2ba4082373
Added tests
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-23 14:38:36 +01:00
2ec3699978
Added javadocs
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-23 14:26:29 +01:00
507d9fddc0
Method body ready
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-23 14:21:16 +01:00
e647698591
Fix problem with admin test - cleaning database
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-23 14:06:02 +01:00
da46582fc0
Added check for admin user and test it
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-23 13:48:26 +01:00
165dee5bd2
Updated gitlab-ci
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-23 12:56:37 +01:00
76cf5c8e96 Merge pull request 'refresh-token' (#35) from refresh-token into master
Accepted
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/35
2020-12-23 12:41:03 +01:00
Filip Izydorczyk
6eac8e6266 Added tests 2020-12-23 12:12:50 +01:00
Filip Izydorczyk
61c5a43192 Added refresh token endpoint 2020-12-23 11:51:17 +01:00
Filip Izydorczyk
7f630ccdac email date update 2020-12-21 17:58:11 +01:00
Filip Izydorczyk
64447b61c8 email date update 2020-12-21 17:48:27 +01:00
Filip Izydorczyk
7584f3600f email date update 2020-12-21 17:34:03 +01:00
e18f285dd6 Merge pull request 'email' (#34) from email into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/34
2020-12-21 17:11:32 +01:00
Filip Izydorczyk
28c09bea6e Added event service 2020-12-21 17:12:10 +01:00
Filip Izydorczyk
a294ecac37 Servcice mail 2020-12-20 16:44:30 +01:00
0d6ad184bc Merge pull request 'timeto-owner' (#33) from timeto-owner into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/33
2020-12-20 15:15:03 +01:00
Filip Izydorczyk
dfae6d7c78 Added info about commiter to comision entity 2020-12-20 13:04:25 +01:00
Filip Izydorczyk
c62674b9d8 Added time to in group resonse 2020-12-20 12:14:12 +01:00
Filip Izydorczyk
8dc94f84c0 user response fix 2020-12-18 17:43:03 +01:00
48c23ad4f8 Merge pull request 'user-fix' (#32) from user-fix into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/32
2020-12-18 17:28:02 +01:00
Filip Izydorczyk
b93d44346c new endpoint testd 2020-12-18 17:23:41 +01:00
Filip Izydorczyk
4a12dceab6 logs 2020-12-18 16:33:58 +01:00
Filip Izydorczyk
ce0d63d7f9 Added docs 2020-12-18 15:52:05 +01:00
Filip Izydorczyk
300130af7e Checnging endpoints added needs docs 2020-12-18 15:49:46 +01:00
Filip Izydorczyk
5ef7c19ade user nules 2020-12-18 15:24:01 +01:00
ca440a3fd5 Merge pull request 'turs' (#31) from turs into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/31
2020-12-14 15:50:35 +01:00
Filip Izydorczyk
ffc4f4709b Merged with master 2020-12-12 15:38:47 +01:00
Filip Izydorczyk
84d7ed8e65 Added method to getting app states 2020-12-12 15:33:00 +01:00
Filip Izydorczyk
e02523b4f4 Added current config getter 2020-12-12 13:33:11 +01:00
Filip Izydorczyk
5a1108e1bf Added getting newest config 2020-12-11 18:08:23 +01:00
Filip Izydorczyk
15533525af Database timezone fixed 2020-12-11 16:18:43 +01:00
Filip Izydorczyk
d2a679fb22 added dev conig 2020-12-11 15:27:38 +01:00
Filip Izydorczyk
e9927f832d permission problems 2020-12-10 16:58:55 +01:00
filipizydorczyk
98bbc1aac6 Merge pull request 'forntend-fixes' (#30) from forntend-fixes into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/30
2020-12-10 16:55:20 +01:00
Filip Izydorczyk
a6acab932c New endpints tests 2020-12-10 16:50:47 +01:00
Filip Izydorczyk
831358128e endpointsd refactore 2020-12-10 16:35:23 +01:00
Filip Izydorczyk
dfe534a835 endpointsd refactore 2020-12-10 16:34:42 +01:00
Filip Izydorczyk
7c457ce232 Deanery response 2020-12-10 16:19:58 +01:00
Filip Izydorczyk
f31a50aa06 Commision with grouos response 2020-12-10 16:13:03 +01:00
Filip Izydorczyk
52abb281ff commision date fix 2020-12-10 15:17:13 +01:00
Filip Izydorczyk
0b807e355c chckpoint: test to buisnesslogic/src/test/java/com/plannaplan/repositories/AppConfigRepositoryTest.java 2020-12-09 17:43:48 +01:00
Filip Izydorczyk
062b02da6c user docs corrected 2020-12-09 16:57:49 +01:00
Filip Izydorczyk
0cee454356 Added saving conifg to databse 2020-12-09 16:43:29 +01:00
Filip Izydorczyk
f08e7cf1e5 Swagger doscs 2020-12-09 15:10:19 +01:00
Filip Izydorczyk
7c0c22e790 Added required parameters to config 2020-12-09 15:02:06 +01:00
1cdb301adf
Updated .git-ci
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-08 19:09:35 +01:00
c1dce7d3bb Merge pull request 'git-ci' (#29) from git-ci into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/29
2020-12-08 19:01:57 +01:00
2921c98c35
Updated .git-ci
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-08 19:02:02 +01:00
181d93082c
Updated .git-ci
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-08 18:42:18 +01:00
b495fd7f65
Updated .git-ci
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-08 18:41:08 +01:00
086e4be458
Updated .git-ci
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-08 18:37:02 +01:00
0c471162f2
Updated .git-ci
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-08 18:31:58 +01:00
9f3e41e601
Updated .git-ci
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-08 18:31:07 +01:00
d85cdb9b22
Added gitci
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-08 18:26:35 +01:00
Filip Izydorczyk
b1091cd3bc Added tour data model 2020-12-08 18:16:17 +01:00
filipizydorczyk
acf80cc78d Merge pull request 'token-package' (#28) from token-package into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/28
2020-12-07 23:31:59 +01:00
Filip Izydorczyk
c34d53d056 Added taken place in course response (needs refactor later) 2020-12-07 23:32:11 +01:00
Filip Izydorczyk
48394d3583 students endpoint 2020-12-07 22:21:34 +01:00
Filip Izydorczyk
82200acc06 swagger update 2020-12-07 22:01:45 +01:00
Filip Izydorczyk
f9baed5df7 Changed token response in controller 2020-12-07 21:46:47 +01:00
Filip Izydorczyk
3061fb1edf Token response 2020-12-07 21:39:47 +01:00
b412ee2a5b Merge pull request 'new-cas-configuration' (#27) from new-cas-configuration into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/27
2020-12-07 21:10:49 +01:00
2037f0bf07
Added
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-07 21:09:54 +01:00
BuildTools
b4f23aa5d2 Added metadata to plannaplan propterties + we should create sssl bean instead inerting properties 2020-12-05 16:38:22 +01:00
BuildTools
495098eeed Added init test data on dev profile 2020-12-05 16:28:02 +01:00
BuildTools
751d4b1744 Readme update 2020-12-05 15:59:47 +01:00
BuildTools
cbe8f96700 Getch chanmges 2020-12-05 15:10:03 +01:00
2dd1f70eee
Updated 2020-12-04 17:15:08 +01:00
c70cac58b2
Updated
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-04 16:16:10 +01:00
616f782155
Updated
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-04 15:54:49 +01:00
6dfb99f253
Updated
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-04 15:42:28 +01:00
b897fce416
Fixed TokenController
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-03 17:14:39 +01:00
f4db74b899
Added test UserServiceTest - shouldCreateUser shouldReturnExistingUser
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-03 17:07:41 +01:00
453907782a
CAS Part 2
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-03 16:57:53 +01:00
3ebfda5316
CAS Part 1
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-03 16:23:39 +01:00
b6c2e43975
Added cas module + add customuamcasvalidator + test passed
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-03 15:11:23 +01:00
6298bb4765
Updated
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-02 15:00:18 +01:00
c24aa73bb0
CustomUAMCasValidatorTest
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-02 14:37:44 +01:00
20d261635b
Added CustomUAMCasValidator
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-02 13:51:07 +01:00
1e3cccc991
Added CasValidator.java; Update DefaultUAMCasValidator
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-02 13:48:28 +01:00
cd96e74c29
Added folder cas
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-02 13:31:18 +01:00
7d747b60a8
Renamed CasValidator -> DefaultUAMCasValidator
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-02 12:38:17 +01:00
filipizydorczyk
c3fd450499 Merge pull request 'ZPI-163: Dodanie dokumentacji do kodu + javadoc' (#24) from ZPI-163 into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/24
2020-12-02 12:28:38 +01:00
b966b64fdb
Resolved confilics with master
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-02 12:16:31 +01:00
1d15d295e0 Merge pull request 'group-count' (#25) from group-count into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/25
2020-12-02 11:58:42 +01:00
f8b12d831b
Added CourseService into javadoc
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-02 11:14:30 +01:00
20341d5441
Added CommisionService into javadoc
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-02 10:22:50 +01:00
3faa228745
Added AssignmentService into javadoc
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-02 10:14:32 +01:00
e6fffba899
Added FileData into javadocs
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-01 21:31:06 +01:00
708cedf7b4
Added ConfigData into javadocs 2020-12-01 21:16:47 +01:00
96c903ed15
Added javadocs to User
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-01 21:13:05 +01:00
160930c3c3
Added javadocs to Lecturer - fix errors
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-01 21:03:26 +01:00
823f4af218
Added javadocs to Lecturer
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-01 20:59:16 +01:00
BuildTools
b2b9178bc1 Added missing config tests. Ready to pull. Other resposnes to fix in another task 2020-12-01 17:31:55 +01:00
BuildTools
7e45da1306 Not null group response 2020-12-01 17:21:54 +01:00
BuildTools
c2c82b75ba repaired places failing 2020-12-01 17:00:56 +01:00
BuildTools
78ed2f75f3 Vhevkpoint implemented but stiull some errors 2020-11-30 13:22:53 +01:00
BuildTools
082b30133c mapToGetCourseGroupsDefaultResponse overloaded 2020-11-30 13:10:40 +01:00
BuildTools
25e9571a06 Group capacity response places overload 2020-11-30 12:35:35 +01:00
BuildTools
593084aeba Group default response places overload 2020-11-30 12:07:18 +01:00
911f2e54f5
Added Course into javadoc
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-27 17:05:47 +01:00
BuildTools
13eb8dae77 Added service method tests + javadocs 2020-11-27 16:55:15 +01:00
7d5522e413
Added Course into javadoc
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-27 16:53:36 +01:00
9ed4197005
Added Assignment
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-27 16:45:06 +01:00
dc3a554ed1
Added Assignment
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-27 16:40:39 +01:00
f6a8953c17
Added
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-27 16:18:30 +01:00
BuildTools
2545a0e682 Added another repository method + test 2020-11-26 13:58:27 +01:00
BuildTools
0130fb77e1 Works with native query now needst to be hql 2020-11-22 03:51:24 +01:00
BuildTools
9d3500c1fb Added api endpoiunt mapper needs to be rewriteen 2020-11-20 16:20:38 +01:00
BuildTools
b4bb13f2dd Added tests and service 2020-11-20 15:56:43 +01:00
e752ad06cd
mit
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-20 15:31:29 +01:00
6d9c5a8a5d
Added
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-20 14:55:20 +01:00
85052f5728
Check it !!! UserRepository.java
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-20 14:53:45 +01:00
50c1397db2
Added docs into repositories
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-20 14:50:07 +01:00
af8e2ced28
Added docs into services 2020-11-20 13:20:44 +01:00
9ad8db527d
Merge remote-tracking branch 'origin/master' into ZPI-163 2020-11-18 09:05:43 +01:00
bc6c55165e
Added docs into branch
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-18 09:01:45 +01:00
BuildTools
3e7086eab9 Checkopoint added hql 2020-11-17 19:36:56 +01:00
BuildTools
c34ce94fb0 Added flaging assignment. Coumetr froup infor needs to be added 2020-11-14 16:52:22 +01:00
17e5625315
Updated
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-12 17:50:53 +01:00
1ddeb83cb4 Merge pull request 'Token expiration added' (#22) from token-expiration into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/22
2020-11-11 14:08:12 +01:00
filipizydorczyk
b713066a2f Merge pull request 'ZPI-161' (#23) from ZPI-161 into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/23
2020-11-10 17:19:25 +01:00
029300815e
Added auth to swagger-ui
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-09 17:08:51 +01:00
7c7045c0e1
Part3 has been ended. Renamed the test files. The test had status successed.
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-09 16:47:12 +01:00
035de011f2
Part 2 has been ended. The Part 3: chanaged test 2020-11-08 17:20:00 +01:00
BuildTools
1b126c7792 Token expiration fixed 2020-11-08 17:06:08 +01:00
a30c3af09c
Part 1
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-08 16:55:56 +01:00
BuildTools
62bbf148b2 Token expiration added 2020-11-07 16:30:25 +01:00
8ba148617a Merge pull request 'Added empty table' (#21) from ZPI-144 into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/21
2020-11-05 16:14:31 +01:00
48fdeb726f Added empty table
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-11-05 16:14:50 +01:00
bd4591f442 Merge pull request 'refactor-api-endpoints' (#20) from refactor-api-endpoints into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/20
2020-11-05 15:34:26 +01:00
BuildTools
0fbc6d6baa Merge 2020-11-05 15:27:51 +01:00
feff5c4b9c Merge pull request 'user-commisions-list' (#18) from user-commisions-list into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/18
2020-11-05 14:55:55 +01:00
BuildTools
d2343acc2d merge with master 2020-11-05 14:44:09 +01:00
cbd9074a89 Merge pull request 'Made wepAppContex commont' (#19) from tests-refactor into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/19
2020-11-05 14:40:16 +01:00
BuildTools
228969efce Error fix 2020-11-05 14:32:42 +01:00
BuildTools
e0df090a0e update docs 2020-11-04 17:27:20 +01:00
BuildTools
6a7fc03e7c Api params 2020-11-04 17:23:29 +01:00
BuildTools
4818905422 Api operations 2020-11-04 16:58:26 +01:00
BuildTools
b308373062 Added controllers description 2020-11-04 16:40:02 +01:00
BuildTools
ba26d67cd4 Swagger ui works needs refactor to be done 2020-11-04 15:09:44 +01:00
BuildTools
1a30ac3374 Works json endpoint ui dont 2020-11-04 15:06:24 +01:00
BuildTools
b4f51d4382 Added tests 2020-10-31 15:24:17 +01:00
BuildTools
6ab2ec50dd merged wqith master 2020-10-31 14:52:26 +01:00
9bff6460d6 Merge origin/deanery-plan-changing to master: With fixed restservice/.../App.java
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-10-30 17:34:32 +01:00
1571bccb49 Changed api links in the Tests 2020-10-30 17:22:40 +01:00
BuildTools
1327a239e8 Made wepAppContex commont 2020-10-30 16:53:41 +01:00
2b59c181e5 Refactor part 1
{{url}}/api/v1/courses/getCourses =>  {{url}}/api/v1/courses/all
{{url}}/api/v1/groups/getCourseGroups?id=13 => {{url}}/api/v1/groups/course/13
{{url}}/api/v1/courses/getCoursesWithGroups => {{url}}/api/v1/courses/all?groups=true
{{url}}/api/v1/commisions/add => {{url}}/api/v1/commisions/user
{{url}}/api/v1/commisions/getAllCommisions => {{url}}/api/v1/commisions/user
{{url}}/api/v1/assignments/getCurrentAssignments =>{{url}}/api/v1/assignments/user
{{url}}/api/v1/users/searchForStudents => {{url}}/api/v1/users/search

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-10-30 16:42:57 +01:00
BuildTools
ca01b20221 Added endpoint - waiting for other branch to merge to master 2020-10-30 14:53:33 +01:00
BuildTools
956b53439f Tests works 2020-10-30 14:27:13 +01:00
BuildTools
b40acf8919 Added tests to fill 2020-10-29 17:45:15 +01:00
BuildTools
ed00731654 little refactor 2020-10-29 17:38:05 +01:00
BuildTools
3a3e6dc427 Functionality done 2020-10-29 16:25:55 +01:00
4267fadf62 Deleted __pycache__
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-10-29 15:36:14 +01:00
41f37ee9ad Merge pull request 'Added argv to python script' (#16) from python-change into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/16
2020-10-29 15:32:54 +01:00
4ca2837b59 Merge pull request 'Chenged newest plan response' (#14) from endpoint-changes into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/14
2020-10-29 15:32:31 +01:00
953168a452 Added argv to python script
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-10-29 15:22:31 +01:00
filipizydorczyk
d3a2256334 Merge pull request 'token-plugin' (#15) from token-plugin into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/15
2020-10-29 14:29:01 +01:00
BuildTools
933e09172b removed unused plugin 2020-10-28 14:30:51 +01:00
BuildTools
f0eae82d9f Added script to accessing token more efficient way 2020-10-28 14:29:27 +01:00
BuildTools
7073e3b1d8 Chenged newest plan response 2020-10-28 13:44:13 +01:00
BuildTools
bdfed57942 Script to get token - checkpoint 2020-10-27 18:21:45 +01:00
Filip Izydorczyk
db0115280f Windows white spaces 2020-10-24 18:04:59 +02:00
f71715fd6b Merge pull request 'scurity-roles' (#13) from scurity-roles into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/13
LGMT
2020-10-24 18:01:29 +02:00
filipizydorczyk
9dba639674 Merge pull request 'ZPI-139' (#12) from ZPI-139 into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/12
2020-10-24 18:01:17 +02:00
Filip Izydorczyk
4614a11a8b Cors 2020-10-24 17:54:00 +02:00
Filip Izydorczyk
a1f17d271f WE HAVE THE GOD DMAN TEST 2020-10-24 17:51:16 +02:00
Filip Izydorczyk
6384f3d9b9 User Controller Tests 2020-10-24 17:28:10 +02:00
Filip Izydorczyk
7d57157078 Mapper test 2020-10-24 17:08:51 +02:00
Filip Izydorczyk
468b6e6b87 ShearchForStduentsResponseTest.java 2020-10-24 16:49:26 +02:00
Filip Izydorczyk
c003198aa1 Fixed old tests 2020-10-24 16:43:42 +02:00
603dadd9c1 Mapping of getCourseGroups
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-10-20 19:02:18 +02:00
Filip Izydorczyk
4b07793849 Added test to implement and some tests failed rightnow 2020-10-19 12:33:54 +02:00
Filip Izydorczyk
67c8b9bf25 Added response mappers 2020-10-19 12:13:02 +02:00
Filip Izydorczyk
0ad97a8e3f Added auth endpoint 2020-10-19 11:12:24 +02:00
Filip Izydorczyk
5fd688fc7a Added roles 2020-10-16 16:31:10 +02:00
a20bc89fc6 Added GetCourseGroupsResponse(-Test)
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-10-16 16:13:40 +02:00
9c02a0b596 Merge pull request 'refactor' (#11) from refactor into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/11
2020-10-15 18:14:13 +02:00
Filip Izydorczyk
2b067f63fc Commisions respone updatede 2020-10-15 17:29:40 +02:00
Filip Izydorczyk
010f0b4566 Warinings fix 2020-10-15 17:09:23 +02:00
Filip Izydorczyk
cb60b17389 groups by course fix 2020-10-15 16:56:31 +02:00
Filip Izydorczyk
3e8bfe85d6 Checkpoint - group controller needs to be fixed 2020-10-13 18:03:37 +02:00
Filip Izydorczyk
932e1a8830 Little refactor 2020-10-13 17:13:43 +02:00
Filip Izydorczyk
148d7a31c6 Responses up[dated 2020-10-13 17:07:04 +02:00
Filip Izydorczyk
bdd0278880 Moved CoursesResponse To Abstract 2020-10-13 16:19:40 +02:00
Filip Izydorczyk
29851dac0d Courses Controller getCourses Mapping 2020-10-09 14:53:54 +02:00
Filip Izydorczyk
f97e22fa5f Made ASsignm,ents Conmtroller more readable 2020-10-08 16:41:13 +02:00
Filip Izydorczyk
9d97306e5c Added Assignment Response Model 2020-10-08 15:57:42 +02:00
Filip Izydorczyk
f9706e0e01 Tests works 2020-10-08 15:24:23 +02:00
Filip Izydorczyk
f9dd6e38c3 3/4 Commisions test 2020-10-05 17:56:35 +02:00
Filip Izydorczyk
73104850fe Assignments Controller test + authj test fix 2020-10-05 16:52:52 +02:00
Filip Izydorczyk
fe5d2d20c3 lol small diff fix 2020-10-02 18:01:51 +02:00
Filip Izydorczyk
30222d6856 Commision service tests 2020-10-02 17:55:42 +02:00
Filip Izydorczyk
95fcfc4e06 Assignments tests 2020-10-02 17:18:03 +02:00
Filip Izydorczyk
e9ae1a0ed0 Checkpoint: Added tests to impleement 2020-10-02 16:51:49 +02:00
Filip Izydorczyk
bb9ea7529f Added what commision tests needst to be written 2020-10-01 17:08:10 +02:00
Filip Izydorczyk
398a84854f Merge with assign 2020-10-01 16:46:45 +02:00
Filip Izydorczyk
51ea557a06 Small fix 2020-09-30 19:16:15 +02:00
Filip Izydorczyk
fa74965504 Works 2020-09-30 19:15:32 +02:00
Filip Izydorczyk
b503ebcbcc Added commisions endponts 2020-09-30 17:46:04 +02:00
Filip Izydorczyk
b4d1c87461 Checkpoint getting authority works + added new user 2020-09-29 19:06:29 +02:00
Filip Izydorczyk
3ad4d3a84b Checkpoint kinda workls. Ill take a nap and go bacjk to work 2020-09-29 17:21:34 +02:00
Filip Izydorczyk
4efedf7f35 concept for assigmnents 2020-09-28 16:07:10 +02:00
Filip Izydorczyk
917a4e3535 optional to users 2020-09-25 17:01:51 +02:00
Filip Izydorczyk
15a4c526b4 access modifiers and constructors fix 2020-09-25 17:01:38 +02:00
Filip Izydorczyk
44bcc24110 access modifiers and constructors fix 2020-09-25 16:43:24 +02:00
Filip Izydorczyk
ce4a5942d5 Added missing tests 2020-09-25 16:17:52 +02:00
Filip Izydorczyk
9cec5a902c CHECKPOINT: Tests for rest service 2020-09-24 19:12:04 +02:00
Filip Izydorczyk
305b86945d Small test fixc 2020-09-24 17:46:35 +02:00
Filip Izydorczyk
3d1269037b Buisness logic tests 2020-09-24 17:44:23 +02:00
Filip Izydorczyk
694fe74690 CHECKPOINT: Made configuyrator as a service. Test and java access modifier correction needs to be done before pull request 2020-09-23 19:12:25 +02:00
Filip Izydorczyk
9599d58543 Removed unimplemented classes (no longer needed due to coneption changed) 2020-09-23 18:39:43 +02:00
Filip Izydorczyk
bf6e1fc2b1 Maciek refactor works + delete unnecesery interface (conception changed) 2020-09-23 18:17:52 +02:00
Filip Izydorczyk
ec77fa782b Moved to new computer 2020-09-22 18:00:28 +02:00
Maciek Głowacki
c449bc22e1 Major refactor of reading from excel to db 2020-09-21 17:45:52 +02:00
213 changed files with 11738 additions and 1269 deletions

11
.gitignore vendored Normal file → Executable file
View File

@ -29,3 +29,14 @@ build/
### VS Code ###
.vscode/
### Python ###
__pycache__
.pytest_cache
### Parser ###
parser/
envs.sh

42
.gitlab-ci.yml Executable file
View File

@ -0,0 +1,42 @@
stages:
- build
- deploy
build:
stage: build
image: maven
script:
- echo "Start building App"
- echo "spring.profiles.active=prod" > restservice/src/main/resources/application.properties
- mvn clean
- mvn install
- cd restservice
- mvn clean package spring-boot:repackage
- echo "Build successfully!"
artifacts:
expire_in: 1 hour
paths:
- restservice/target/
only:
- master
deploy_production:
stage: deploy
before_script:
- apt-get update
- apt-get --yes --force-yes install rsync
script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- echo "Deploying to server"
- ssh backend@wmi-backend-gc.plannaplan.pl -t "sudo systemctl stop plannaplan-backend"
- ssh backend@wmi-backend-gc.plannaplan.pl -t "rm -rf /opt/plannaplan-backend/backend.jar"
- rsync --progress restservice/target/*.jar backend@wmi-backend-gc.plannaplan.pl:/opt/plannaplan-backend/backend.jar
- sleep 5
- ssh backend@wmi-backend-gc.plannaplan.pl -t "sudo systemctl start plannaplan-backend"
- echo "Deployed"
only:
- master

674
COPYING Executable file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/philosophy/why-not-lgpl.html>.

117
README.md Normal file → Executable file
View File

@ -1,44 +1,94 @@
## Start aplikacji
# Start aplikacji
Zeby wystartowac aplikacje backendu najpierw nalezy postawic testowa baze danych na naszym komputerze za pomoca dockera. Jesli raz juz go odpalimy przy nastepnym razem bardzo mozliwe, ze wlaczy sie sam. AAby sprawdzic czy docker jesty wystartowany mozna uzyc `docker ps`
```
docker-compose -f stack.yml up
```
Nastepnie w `restservice/src/main/resources/application.properties` nalezy podac ip naszego kontenera.
```
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=example
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=create
server.port=1285
docker-compose -f stack.yml up -d
```
Następnym krokiem jest odpalenie poniższych komend w terminalu.
```
cd restservice
mvn spring-boot:run
```
## Packaging
# Token obtaining
Żeby tesotwać API wpełni potrzebny nam jest token który otrzymujemy na podstawie ticketa z systemu autoryzacyjnego **CAS**. Z tego powodu system autoryzacji działa inaczej niż w "książkowych" restowych aplikacjach i np Postman za nas jej nie dokona. Musimy mu podać już uzyskany token. Aby łatwo go uzyskać odpal skrypt
```bash
python gettoken.py
```
Jeżeli chcesz używać skryptu zmiejaniąc gdzie znajduje się backend wpisz:
```bash
python gettoken.py 192.168.0.212
```
Jeżeli chcesz używać skryptu bez uruchamiania przeglądarki wpisz:
```bash
python gettoken.py no-browser
```
Na koniec w przęglądarce dostaniesz w odpowiedzi token. W samym pliku można zmienić porty aplikacji jeśli to potrzebne.
# Profiles
W aplikacji posiadamy dwa profile. `dev` i `prod`. **Dev** używamy do testowania aplikacji lokalnie. **Pord** służy do stworzenia builda na produkcję.
Profil wybieramy w pliku `restservice/src/main/resources/application.properties` wpisując odpowiednią nazwę
```
spring.profiles.active=prod
```
Jeżeli chcemy zmienić jakieś opcję dla pordukcji to robimy to w tym sammym katalogi w pliku `application-prod.properties` i dla dev analogicznie w `application-dev.properties`.
W paczce dla proda w protpertiesach poufne dane odczytywane są ze zmiennych środowiskowych systemu na którym odpalana jest aplikacja. Ustawić trzeba następujące zmienne:
- `PLANNAPLAN_MYSQL_DB_HOST` - host bazy danych np `localhost`
- `PLANNAPLAN_MYSQL_DB_PORT` - port na którym działa baza
- `PLANNAPLAN_MYSQL_DB` - nazwa bazy dancyh. W profilu **dev** jest to np test
- `PLANNAPLAN_MYSQL_DB_USERNAME` - nazwa użytkownika bazy
- `PLANNAPLAN_MYSQL_DB_PASSWORD` - hasło użytkownika bazy
- `PLANNAPLAN_EMAIL_HOST` - host naszego dostawcy maila z którego będziemy wssyłać wiadomości
- `PLANNAPLAN_EMAIL_PORT` - port naszego dostawcy maila
- `PLANNAPLAN_EMAIL_USERNAME` - login naszego maila
- `PLANNAPLAN_EMAIL_PASSWORD` - hasło naszego maila
- `PLANNAPLAN_EMAIL` - nasz adres maila
- `PLANNAPLAN_CONSUMER_KEY` - nasz klucz do usos api
- `PLANNAPLAN_CONSUMER_SECRET` - secret naszego klucza
Należy też pamiętać, że zmienne `PLANNAPLAN_CONSUMER_KEY` oraz `PLANNAPLAN_CONSUMER_SECRET` są potrzebne również w profilu `dev` więc trzeba je dodać w celu tesotowania do zmiennych we własnym systemie
# Packaging
Zeby spakowac apke do `jara` wystarcza dwie komendy zaczynajac z glownego katalogu projektu
```
mvn clean
mvn install
cd restservice
mvn clean package spring-boot:repackage
mvn clean; mvn install; cd restservice; mvn clean package spring-boot:repackage
```
Utworzony zostanie jar w `restservice/target/restservice-1.0-SNAPSHOT.jar`. Oczywiscie zeby jar zadzialal kontenery dockerowe musza byc odpalone (lub baza danych na serwerze jesli zmienialismy propertisy z localhost)
## Troubleshooting
# Generowanie dokumentacji
## Javadocs
```bash
mvn javadoc:javadoc
```
## Api docs
Żeby zobaczyć dokumentację api trzeba wejść w przeglądarce na `http://localhost:1285/swagger-ui.html` po odpaleniu aplikacji.
### Nazewnictwo odpowiedzi
Każdą odpowiedź zaczynamy od modelu, który opisuje np. `Courses` a kończymy na `Response`. Między tymi dwoma członami możemy dodawać modyfikatory opisujące dokładniej odpowiedź np. `Default`. W ten sposób możemy otrzymać nazwę `CoursesDefaultResponse.java`
# Troubleshooting
Spring chyba cacheuje jakies dane dotyczace polaczenia wiec jesli spring wywali Ci blad `Connection Refused`, a wiesz, ze ta baza stoi na podanym ip i porcie to sprobuj
@ -46,3 +96,28 @@ Spring chyba cacheuje jakies dane dotyczace polaczenia wiec jesli spring wywali
mvn clean
mvn install
```
Jeżeli używasz VSCode i testy, które wymagają podanych zmiennych środowiskowych (testy odpytywania usos api) trzeba podać te zmienne w pliku `.vscode/settings.json`
```json
{
"files.exclude": {
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true
},
"java.configuration.updateBuildConfiguration": "disabled",
"java.format.settings.url": "eclipse-formatter.xml",
"java.test.config": [
{
"name": "myConfiguration",
"workingDirectory": "${workspaceFolder}",
"env": {
"PLANNAPLAN_CONSUMER_KEY": "value",
"PLANNAPLAN_CONSUMER_SECRET": "value"
}
}
]
}
```

46
buisnesslogic/pom.xml Normal file → Executable file
View File

@ -16,8 +16,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>14</maven.compiler.source>
<maven.compiler.target>14</maven.compiler.target>
</properties>
<dependencies>
@ -57,7 +57,7 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
<version>4.0.0</version>
</dependency>
<!-- dependency used for XLS older file format
@ -68,6 +68,37 @@
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.social/spring-social-core -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.12</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.github.scribejava</groupId>
<artifactId>scribejava-core</artifactId>
<version>8.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>
</dependencies>
<build>
@ -84,6 +115,15 @@
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>

View File

@ -0,0 +1,24 @@
{
"properties": [
{
"name": "plannaplan.email",
"type": "java.lang.String",
"description": "Email from which app sends message"
},
{
"name": "plannaplan.apiurl",
"type": "java.lang.String",
"description": "Url to usos api endpoints"
},
{
"name": "plannaplan.apikey",
"type": "java.lang.String",
"description": "Api consumer key"
},
{
"name": "plannaplan.apisecret",
"type": "java.lang.String",
"description": "Api consumer secret"
}
]
}

View File

@ -1,9 +0,0 @@
package com.plannaplan;
public class Acceptor {
public Acceptor() {
}
public void run() {
}
}

View File

@ -1,46 +0,0 @@
package com.plannaplan;
import java.util.Date;
import com.plannaplan.types.AppStates;
public class App {
private static App instance;
private Date round1;
private Date round2;
private AppStates state;
private App() {
}
public AppStates getState() {
return state;
}
public void setState(AppStates state) {
this.state = state;
}
public Date getRound2() {
return round2;
}
public void setRound2(Date round2) {
this.round2 = round2;
}
public Date getRound1() {
return round1;
}
public void setRound1(Date round1) {
this.round1 = round1;
}
public App getInstance() {
if (App.instance == null) {
App.instance = new App();
}
return App.instance;
}
}

View File

@ -1,26 +0,0 @@
package com.plannaplan;
import com.plannaplan.interfaces.Historable;
import com.plannaplan.interfaces.ProtectedAction;
public class Assigner implements Historable, ProtectedAction {
public Assigner() {
}
public void assing() {
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
@Override
public void addActionToHistory() {
// TODO Auto-generated method stub
}
}

View File

@ -1,43 +0,0 @@
package com.plannaplan;
import com.plannaplan.interfaces.ProtectedAction;
import com.plannaplan.models.ConfigData;
import com.plannaplan.models.FileData;
import com.plannaplan.services.CourseService;
import com.plannaplan.services.GroupService;
import com.plannaplan.services.LecturerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.plannaplan.configutils.*;
@Component
public class Configurator implements ProtectedAction {
@Autowired
private LecturerService lecturerService;
@Autowired
private CourseService courseService;
@Autowired
private GroupService groupService;
public Configurator() {
}
public void config(ConfigData data) {
FileReader reader = new FileReader(data.getFilestream());
FileData coursesData = reader.read();
FileToDatabaseMigrator mgtr = new FileToDatabaseMigrator(lecturerService, courseService, groupService);
mgtr.migrate(coursesData);
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
}

View File

@ -1,41 +0,0 @@
package com.plannaplan;
import com.plannaplan.models.ConfigData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class Controller {
@Autowired
private Configurator configurator;
public Controller() {
}
public void startApp() {
}
public void assignCourse() {
}
public void addUnavailibility() {
}
public void addGroup() {
}
public void editGroup() {
}
public void getHistoryAtPoint() {
}
public void config(ConfigData data) {
configurator.config(data);
}
public void createTransfer() {
}
}

View File

@ -1,9 +0,0 @@
package com.plannaplan;
public class Emailer {
public Emailer() {
}
public void performAllMails() {
}
}

View File

@ -1,13 +0,0 @@
package com.plannaplan;
import com.plannaplan.interfaces.EventCreator;
public class EventChcker implements EventCreator {
@Override
public void update() {
// TODO Auto-generated method stub
}
}

View File

@ -1,26 +0,0 @@
package com.plannaplan;
import com.plannaplan.interfaces.Historable;
import com.plannaplan.interfaces.ProtectedAction;
public class GroupAdder implements Historable, ProtectedAction {
public GroupAdder() {
}
public void addGroup() {
}
@Override
public void addActionToHistory() {
// TODO Auto-generated method stub
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
}

View File

@ -1,19 +0,0 @@
package com.plannaplan;
import com.plannaplan.interfaces.ProtectedAction;
public class GroupEditor implements ProtectedAction {
public GroupEditor() {
}
public void setNewCapacity(int capaity) {
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
}

View File

@ -1,22 +0,0 @@
package com.plannaplan;
import com.plannaplan.interfaces.ProtectedAction;
public class HistoryResolver implements ProtectedAction {
public HistoryResolver() {
}
public void getHistoryAtPoint() {
}
public void reproduce() {
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
}

View File

@ -1,26 +0,0 @@
package com.plannaplan;
import com.plannaplan.interfaces.Historable;
import com.plannaplan.interfaces.ProtectedAction;
public class TransferCreator implements Historable, ProtectedAction {
public TransferCreator() {
}
public void createTransfer() {
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
@Override
public void addActionToHistory() {
// TODO Auto-generated method stub
}
}

View File

@ -1,19 +0,0 @@
package com.plannaplan;
import com.plannaplan.interfaces.Historable;
public class TransferValidator implements Historable {
public TransferValidator() {
}
public void performAllTransfers() {
}
@Override
public void addActionToHistory() {
// TODO Auto-generated method stub
}
}

View File

@ -1,26 +0,0 @@
package com.plannaplan;
import com.plannaplan.interfaces.Historable;
import com.plannaplan.interfaces.ProtectedAction;
public class UnavailabilityAdder implements Historable, ProtectedAction {
public UnavailabilityAdder() {
}
public void add() {
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
@Override
public void addActionToHistory() {
// TODO Auto-generated method stub
}
}

View File

@ -1,26 +0,0 @@
package com.plannaplan.abstracts;
import java.util.ArrayList;
import java.util.List;
import com.plannaplan.interfaces.EventCreator;
public abstract class EventWatcher {
protected List<EventCreator> creators;
public EventWatcher() {
this.creators = new ArrayList<>();
}
public void attach(EventCreator creator) {
this.creators.add(creator);
}
public void detach(EventCreator creator) {
this.creators.remove(creator);
}
public void update() {
}
}

View File

@ -0,0 +1,61 @@
package com.plannaplan.api;
import com.github.scribejava.core.builder.api.DefaultApi10a;
/**
* singleton class to sign usos api requests with oauth
*/
public class UsosOauth1Service extends DefaultApi10a {
private static final String AUTHORIZE_URL = "https://usosapidemo.amu.edu.pl/services/oauth/authorize";
private static final String REQUEST_TOKEN_URL = "https://usosapidemo.amu.edu.pl/services/oauth/request_token";
private final String scopesAsString;
protected UsosOauth1Service() {
scopesAsString = null;
}
protected UsosOauth1Service(String... scopes) {
final StringBuilder builder = new StringBuilder();
for (String scope : scopes) {
builder.append('+').append(scope);
}
scopesAsString = "?scope=" + builder.substring(1);
}
private static class InstanceHolder {
private static final UsosOauth1Service INSTANCE = new UsosOauth1Service();
}
public static UsosOauth1Service instance() {
return InstanceHolder.INSTANCE;
}
/**
* get instance withj scopes
*
* @param scopes to get instance with
* @return UsosOauth1Service instance
*/
public static UsosOauth1Service instance(String... scopes) {
return scopes == null || scopes.length == 0 ? instance() : new UsosOauth1Service(scopes);
}
@Override
public String getRequestTokenEndpoint() {
return scopesAsString == null ? REQUEST_TOKEN_URL : REQUEST_TOKEN_URL + scopesAsString;
}
@Override
public String getAccessTokenEndpoint() {
return "https://usosapidemo.amu.edu.pl/services/oauth/access_token";
}
@Override
protected String getAuthorizationBaseUrl() {
return AUTHORIZE_URL;
}
}

View File

@ -0,0 +1,6 @@
/**
* Provides the classes necessary to obtain usos authentication with Oauth1
*
* @since 1.0
*/
package com.plannaplan.api;

View File

@ -2,7 +2,7 @@ package com.plannaplan.configutils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Iterator;
import org.apache.poi.xssf.usermodel.XSSFSheet;
@ -11,14 +11,30 @@ import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import com.plannaplan.models.FileData;
/**
* FileReader is used for reading xls file from input stream.
*/
public class FileReader {
private InputStream fileInputStream;
/**
* @param fileInputStream stream of stadarized file contains courses and gropups
* to import. File needs to be .xlsx file that has
* fields: zaj_cyk_id, typ, sym, nazwa, gr_nr, Mc, dzien,
* godz_od, sala, tytul, nazwisko, imie. Order doesn't
* have impact on import. Any change name of given field
* can be performed in FileToDatabaseMigrator class
*/
public FileReader(InputStream fileInputStream) {
this.fileInputStream = fileInputStream;
}
/**
* read data rom file
*
* @return instance of class FileData
*/
public FileData read() {
FileData result = null;
@ -33,7 +49,7 @@ public class FileReader {
Row row = rowIt.next();
Iterator<Cell> cellIt = row.cellIterator();
Hashtable<String, Integer> keys = new Hashtable<>();
HashMap<String, Integer> keys = new HashMap<>();
int index = 0;
while (cellIt.hasNext()) {
Cell c = cellIt.next();

View File

@ -1,7 +1,6 @@
package com.plannaplan.configutils;
import java.util.Iterator;
import com.plannaplan.entities.Course;
import com.plannaplan.entities.Groups;
import com.plannaplan.entities.Lecturer;
@ -12,137 +11,124 @@ import com.plannaplan.services.LecturerService;
import com.plannaplan.types.GroupType;
import com.plannaplan.types.WeekDay;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* FileToDatabaseMigrator is used for migrate data from file (it reads line by
* line) and push it into database
*/
@Component
public class FileToDatabaseMigrator {
public static String LECTURER_NAME_STRING = "imie";
public static String LECTURER_SURNAME_STRING = "nazwisko";
public static String LECTURER_TITLE_STRING = "tytul";
public static String COURSE_SYMBOL_STRING = "sym";
public static String COURSE_NAME_STRING = "nazwa";
private static final String LECTURER_NAME_STRING = "imie";
private static final String LECTURER_SURNAME_STRING = "nazwisko";
private static final String LECTURER_TITLE_STRING = "tytul";
public static String GROUP_DAY_STRING = "dzien";
public static String GROUP_TIME_STRING = "godz_od";
public static String ROOM_STRING = "sala";
public static String CAPACITY_STRING = "Mc";
private static final String COURSE_SYMBOL_STRING = "sym";
private static final String COURSE_NAME_STRING = "nazwa";
LecturerService lecturerService;
CourseService courseService;
GroupService groupService;
private static final String groupDay_STRING = "dzien";
private static final String GROUP_TIME_STRING = "godz_od";
private static final String ROOM_STRING = "sala";
private static final String CAPACITY_STRING = "Mc";
private static final String TYPE_GROUP = "typ";
public FileToDatabaseMigrator(LecturerService lecturerService, CourseService courseService,
GroupService groupService) {
this.lecturerService = lecturerService;
this.groupService = groupService;
this.courseService = courseService;
private static final String ZAJ_CYK_ID = "zaj_cyk_id";
private static final String GR_NR = "gr_nr";
@Autowired
private LecturerService lecturerService;
@Autowired
private CourseService courseService;
@Autowired
private GroupService groupService;
public FileToDatabaseMigrator() {
}
/**
* insert data to database
*
* @param data FileData imported from file
*/
public void migrate(FileData data) {
Iterator<Row> rows = data.getRows();
int courseNameIndex = data.getIndexOf(FileToDatabaseMigrator.COURSE_NAME_STRING);
int symbolIndex = data.getIndexOf(FileToDatabaseMigrator.COURSE_SYMBOL_STRING);
int course_name_index = data.getIndexOf(FileToDatabaseMigrator.COURSE_NAME_STRING);
int sym_index = data.getIndexOf(FileToDatabaseMigrator.COURSE_SYMBOL_STRING);
int titleIndex = data.getIndexOf(FileToDatabaseMigrator.LECTURER_TITLE_STRING);
int surnameIndex = data.getIndexOf(FileToDatabaseMigrator.LECTURER_SURNAME_STRING);
int nameIndex = data.getIndexOf(FileToDatabaseMigrator.LECTURER_NAME_STRING);
int title_index = data.getIndexOf(FileToDatabaseMigrator.LECTURER_TITLE_STRING);
int surname_index = data.getIndexOf(FileToDatabaseMigrator.LECTURER_SURNAME_STRING);
int name_index = data.getIndexOf(FileToDatabaseMigrator.LECTURER_NAME_STRING);
int dayIndex = data.getIndexOf(FileToDatabaseMigrator.groupDay_STRING);
int timeIndex = data.getIndexOf(FileToDatabaseMigrator.GROUP_TIME_STRING);
int roomIndex = data.getIndexOf(FileToDatabaseMigrator.ROOM_STRING);
int capacityIndex = data.getIndexOf(FileToDatabaseMigrator.CAPACITY_STRING);
int typeGroupIndex = data.getIndexOf(FileToDatabaseMigrator.TYPE_GROUP);
int day_index = data.getIndexOf(FileToDatabaseMigrator.GROUP_DAY_STRING);
int time_index = data.getIndexOf(FileToDatabaseMigrator.GROUP_TIME_STRING);
int room_index = data.getIndexOf(FileToDatabaseMigrator.ROOM_STRING);
int capacity_index = data.getIndexOf(FileToDatabaseMigrator.CAPACITY_STRING);
int zajCykIdIndex = data.getIndexOf(FileToDatabaseMigrator.ZAJ_CYK_ID);
int grNrIndex = data.getIndexOf(FileToDatabaseMigrator.GR_NR);
while (rows.hasNext()) {
Row row = rows.next();
Cell course_name_cell = row.getCell(course_name_index);
Cell sym = row.getCell(sym_index);
String courseName = row.getCell(courseNameIndex).toString().trim();
String symbol = row.getCell(symbolIndex).toString().trim();
Cell title_cell = row.getCell(title_index);
Cell name_cell = row.getCell(name_index);
Cell surname_cell = row.getCell(surname_index);
String lecturerTitle = row.getCell(titleIndex) != null
? row.getCell(titleIndex).toString().trim()
: "";
String lecturerName = row.getCell(nameIndex) != null ? row.getCell(nameIndex).toString().trim()
: "";
String lecturerSurname = row.getCell(surnameIndex) != null
? row.getCell(surnameIndex).toString().trim()
: "";
Cell day_cell = row.getCell(day_index);
Cell time_cell = row.getCell(time_index);
Cell room_cell = row.getCell(room_index);
Cell capacity_cell = row.getCell(capacity_index);
Integer zajCykId = row.getCell(zajCykIdIndex) != null
? (int) Double.parseDouble(row.getCell(zajCykIdIndex).toString().trim())
: null;
String lecturer_title = "";
String lecturer_surname = "";
String lecturer_name = "";
Integer grNr = row.getCell(grNrIndex) != null
? (int) Double.parseDouble(row.getCell(grNrIndex).toString().trim())
: null;
String course_name = course_name_cell.toString().trim();
String sym_str = sym.toString().trim();
int day = row.getCell(dayIndex) != null
? (int) Double.parseDouble(row.getCell(dayIndex).toString())
: 0;
WeekDay groupDay = WeekDay.getDay(day - 1);
int time = parseTimeToInt(row.getCell(timeIndex).toString());
String room = row.getCell(roomIndex).toString().trim();
int capacity = (int) Double.parseDouble(row.getCell(capacityIndex).toString());
GroupType typeGroup = GroupType.getType(row.getCell(typeGroupIndex).toString());
int day = (int) Double.parseDouble(day_cell.toString());
WeekDay group_day = WeekDay.getDay(day - 1);
String room = room_cell.toString().trim();
int time = this.parseTimeToInt(time_cell.toString());
Course course = this.courseService.getCourseByName(courseName)
.orElseGet(() -> this.courseService.save(new Course(courseName, symbol)));
int capacity = (int) Double.parseDouble(capacity_cell.toString());
Lecturer lecturer = this.lecturerService
.getLecturer(lecturerTitle, lecturerName, lecturerSurname)
.orElseGet(() -> this.lecturerService.save(
new Lecturer(lecturerTitle, lecturerName, lecturerSurname)));
Groups group = groupService.find(time, capacity, room);
Groups group = this.groupService.find(zajCykId, grNr).orElseGet(() -> new Groups(capacity, room,
course, time, groupDay, lecturer, zajCykId, grNr, typeGroup));
group.update(capacity, room, course, time, null, groupDay, lecturer, typeGroup);
Course course = this.courseService.getCourseByName(course_name);
if (course == null) {
course = new Course();
course.setName(course_name);
course.setSymbol(sym_str);
}
courseService.save(course);
if (title_cell != null) {
lecturer_title = title_cell.toString().trim();
}
if (name_cell != null) {
lecturer_name = name_cell.toString().trim();
}
if (surname_cell != null) {
lecturer_surname = surname_cell.toString().trim();
}
Lecturer lecturer = lecturerService.getLecturer(lecturer_title, lecturer_name, lecturer_surname);
if (lecturer == null) {
lecturer = new Lecturer(lecturer_title, lecturer_name, lecturer_surname);
lecturerService.save(lecturer);
}
if (group == null) {
group = new Groups();
group.setCapacity(capacity);
group.setRoom(room);
group.setCourseId(course);
group.setTime(time);
if (capacity >= 50) {
group.setType(GroupType.LECTURE);
} else {
group.setType(GroupType.CLASS);
}
group.setDay(group_day);
group.setLecturer(lecturer);
groupService.save(group);
}
this.groupService.save(group);
}
}
private Integer parseTimeToInt(String time) {
String times[] = time.split("\\.");
if (times.length == 2) {
return Integer.parseInt(times[0]) * 60 + Integer.parseInt(times[1]);
}
times = time.split("\\:");
if (times.length == 2) {
return Integer.parseInt(times[0]) * 60 + Integer.parseInt(times[1]);
}
/**
*
* @param time time string in formaT hh:mm or hh.mm
* @return int time witch is minutes from 00:00
*/
private static int parseTimeToInt(String time) {
String times[] = time.split("\\.|\\:");
return times.length == 2 ? Integer.parseInt(times[0]) * 60 + Integer.parseInt(times[1]) : 0;
return 0;
}
}

View File

@ -0,0 +1,7 @@
/**
* Provides the classes necessary to to config and import related operations in
* the app
*
* @since 1.0
*/
package com.plannaplan.configutils;

View File

@ -0,0 +1,171 @@
package com.plannaplan.entities;
import java.sql.Date;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.util.TimeZone;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import com.plannaplan.models.TourData;
import com.plannaplan.types.AppState;
import org.springframework.scheduling.support.CronTrigger;
/**
* entity that keeps app configurations
*/
@Entity
public class AppConfig {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private Date firstTourStart;
private Date firstTourEnd;
private Date secondTourStart;
private Date secondTourEnd;
private Timestamp configDate;
/**
* no parameter construcotor
*/
public AppConfig() {
}
/**
* constructor
*
* @param firstTour first TourData instacne
* @param scondTour second TourData instacne
*/
public AppConfig(TourData firstTour, TourData scondTour) {
this.firstTourStart = firstTour.getStart();
this.firstTourEnd = firstTour.getEnd();
this.secondTourStart = scondTour.getStart();
this.secondTourEnd = scondTour.getEnd();
this.configDate = new Timestamp(System.currentTimeMillis());
}
/**
*
* second tour end getter
*
* @return Date inforamtion when second tour ends
*/
public Date getSecondTourEnd() {
return secondTourEnd;
}
/**
* first second start getter
*
* @return Date inforamtion when second tour start
*/
public Date getSecondTourStart() {
return secondTourStart;
}
/**
* first tour end getter
*
* @return Date inforamtion when first tour end
*/
public Date getFirstTourEnd() {
return firstTourEnd;
}
/**
* first tour start getter
*
* @return Date inforamtion when first tour start
*/
public Date getFirstTourStart() {
return firstTourStart;
}
/**
* config date getter
*
* @return Timestamp when configuration took place
*/
public Timestamp getConfigDate() {
return configDate;
}
/**
* current state getter
*
* @return AppState of app at the moment of calling method
*/
public AppState getCurrentState() {
final Date now = new Date(System.currentTimeMillis());
if (this.secondTourEnd.before(now)) {
return AppState.NO_TOUR;
}
if (this.secondTourStart.before(now)) {
return AppState.SECOND_TOUR;
}
if (this.firstTourEnd.before(now)) {
return AppState.NO_TOUR;
}
if (this.firstTourStart.before(now)) {
return AppState.FIRST_TOUR;
}
return AppState.NO_TOUR;
}
/**
* get cron expression of first tour end
*
* @return spring cron expression
*/
public CronTrigger getFirstTourEndCron() {
return getCron(this.firstTourEnd);
}
/**
* get cron expression of second tour end
*
* @return spring cron expression
*/
public CronTrigger getSecondTourEndCron() {
return getCron(this.secondTourEnd);
}
/**
* get cron expression of first tour start
*
* @return spring cron expression
*/
public CronTrigger getFirstTourStartCron() {
return getCron(this.firstTourStart);
}
/**
* get cron expression of second tour start
*
* @return spring cron expression
*/
public CronTrigger getSecondTourStartCron() {
return getCron(this.secondTourStart);
}
/**
* create spring cron expression
*
* @param date date to create cron exp from
* @return spring cron expression. Remember that spring's cron deosn't contain
* year in it.
*/
private CronTrigger getCron(Date date) {
final LocalDate tourEnd = date.toLocalDate();
return new CronTrigger("0 0 0 " + tourEnd.getDayOfMonth() + " " + tourEnd.getMonthValue() + " ?",
TimeZone.getTimeZone(TimeZone.getDefault().getID()));
}
}

View File

@ -7,6 +7,12 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
/**
* Entity of Assignment grouping of state associated about group_id and
* commision_id
*
*/
@Entity
public class Assignment {
@Id
@ -16,9 +22,103 @@ public class Assignment {
@JoinColumn(name = "group_id")
private Groups group;
@ManyToOne
@JoinColumn(name = "user_id")
private User user;
@JoinColumn(name = "commision_id")
private Commision commision;
private boolean isPastAssignment;
/**
* Assignment
*
* @param group group we would like to assign
* @param commision commision that assignment belongs to
* @param isPastAssignment is assignment past or no
*/
public Assignment(Groups group, Commision commision, boolean isPastAssignment) {
this.commision = commision;
this.group = group;
}
/**
*
* @param oldAssignment old assignment that we want to move to new commision
* @param newCommision commsion to move assiongment
*/
public static Assignment getNewFromAssignment(Assignment oldAssignment, Commision newCommision) {
return new Assignment(oldAssignment.getGroup(), newCommision);
}
/**
* If it returns trues it mesans u are assigned to group accepted by algorythm
*
* @return boolean isAccepted
*/
public boolean isAccepted() {
return this.group.getRegisteredStudents().contains(this.commision.getCommisionOwner());
}
/**
* Getter of commision
*
* @return Commision Commision of given assignments
*/
public Commision getCommision() {
return this.commision;
}
/**
* Assignment
*
* @param group group we would like to assign
* @param commision commision that assignment belongs to
*/
public Assignment(Groups group, Commision commision) {
this(group, commision, false);
}
public Assignment() {
}
/**
* @param commision commision to set
*/
public void setCommision(Commision commision) {
this.commision = commision;
}
/**
* Id getter
*
* @return id id of assignment
*/
public Long getId() {
return this.id;
}
/**
* getGroup
*
* @return group
*/
public Groups getGroup() {
return this.group;
}
/**
* isPastAssignment getter
*
* @return isPastAssignment
*/
public boolean isPastAssignment() {
return isPastAssignment;
}
/**
* setter isPastAssignment
*
* @param isPastAssignment is assignment past or not
*/
public void setPastAssignment(boolean isPastAssignment) {
this.isPastAssignment = isPastAssignment;
}
}

View File

@ -0,0 +1,105 @@
package com.plannaplan.entities;
import java.sql.Timestamp;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
/**
* Entity of Commision grouping of state associated about commison and owner_id
*/
@Entity
public class Commision {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne
@JoinColumn(name = "owner_id")
private User commisionOwner;
@OneToOne
@JoinColumn(name = "commiter_id")
private User commisionCommiter;
private Timestamp commisionDate;
@OneToMany(mappedBy = "commision", fetch = FetchType.EAGER)
private List<Assignment> assignments;
/**
*
* @param user owner of commission. Can not be null otherwise saving commision
* will fail.
*/
public Commision(User user) {
this.commisionDate = new Timestamp(System.currentTimeMillis());
this.commisionOwner = user;
this.commisionCommiter = user;
}
/**
*
* @param user user whose shedule is being commited
* @param commiter user that commited new schedule
*/
public Commision(User user, User commiter) {
this(user);
this.commisionCommiter = commiter;
}
public Commision() {
}
/**
* Id getter
*
* @return id id of commision
*/
public Long getId() {
return this.id;
}
/**
* CommisionDate getter
*
* @return commisionDate
*/
public Timestamp getCommisionDate() {
return commisionDate;
}
/**
* User of given commision getter
*
* @return User commisionOwner
*/
public User getCommisionOwner() {
return commisionOwner;
}
/**
* @return User entity that created commision (can be owner or deanery user)
*/
public User getCommisionCommiter() {
if (commisionCommiter == null) {
return commisionOwner;
}
return commisionCommiter;
}
/**
* Assigments getter
*
* @return List of assignments
*/
public List<Assignment> getAssignments() {
return this.assignments;
}
}

View File

@ -10,6 +10,10 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
/**
* Entity of Course grouping of state of course
*/
@Entity
public class Course {
@Id
@ -17,32 +21,67 @@ public class Course {
private Long id;
private String name;
private String symbol;
@OneToMany(mappedBy = "courseId", fetch = FetchType.EAGER)
@OneToMany(mappedBy = "course", fetch = FetchType.EAGER)
private List<Groups> groups = new ArrayList<>();
public Course() {
}
/**
* Course
*
* @param name name given to the course
* @param symbol symbol given to the course
*/
public Course(String name, String symbol) {
this.name = name;
this.symbol = symbol;
}
/**
* getId
* @return id
*/
public Long getId() {
return this.id;
}
/**
* getName
* @return name
*/
public String getName() {
return name;
}
/**
* getSymbol
* @return symbol
*/
public String getSymbol() {
return symbol;
}
/**
* setSymbol
* @param symbol set symbol in the course
*/
public void setSymbol(String symbol) {
this.symbol = symbol;
}
/**
* setName
* @param name set name in the course
*/
public void setName(String name) {
this.name = name;
}
/**
* getGroups
* @return groups return list groups
*/
public List<Groups> getGroups() {
return this.groups;
}

View File

@ -1,32 +0,0 @@
package com.plannaplan.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import com.plannaplan.types.EventTypes;
@Entity
public class Event {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private EventTypes type;
@ManyToOne
@JoinColumn(name = "user_id")
private User user;
public Event() {
}
public EventTypes getType() {
return type;
}
public void setType(EventTypes type) {
this.type = type;
}
}

View File

@ -0,0 +1,102 @@
package com.plannaplan.entities;
import java.sql.Timestamp;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
/**
* Entity that keeps user exchange offer.
*/
@Entity
public class Exchange {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne
@JoinColumn(name = "owned_id")
private Assignment ownedAssignment;
@OneToOne
@JoinColumn(name = "desired_id")
private Groups desiredAssignment;
private Long ownerId;
private Timestamp dateExchange;
public Exchange(){
}
/**
* @return Long ID of exchange trader
*/
public Long getOwnerId() {
return ownerId;
}
/**
* @param ownerId ID of exchange trader
*/
public void setOwnerId(Long ownerId) {
this.ownerId = ownerId;
}
public Timestamp getDataExchange() {
return this.dateExchange;
}
/**
*
* @param ownedAssignment Assignment which owner would like to trade
* @param desiredAssignment Groups instance that trader wants
*/
public Exchange(Assignment ownedAssignment, Groups desiredAssignment) {
this.ownedAssignment = ownedAssignment;
this.desiredAssignment = desiredAssignment;
this.ownerId = this.ownedAssignment != null ? this.ownedAssignment.getCommision().getCommisionOwner().getId() : null;
this.dateExchange = new Timestamp(System.currentTimeMillis());
}
/**
* @return Long ID in database
*/
public Long getId(){
return this.id;
}
/**
* @return Groups Target group
*/
public Groups getDesiredAssignment() {
return desiredAssignment;
}
/**
* @param desiredAssignment Target group
*/
public void setDesiredAssignment(Groups desiredAssignment) {
this.desiredAssignment = desiredAssignment;
}
/**
* @return Assignment Owned assignment
*/
public Assignment getOwnedAssignment() {
return ownedAssignment;
}
/**
* @param ownedAssignment Owned assignment
*/
public void setOwnedAssignment(Assignment ownedAssignment) {
this.ownedAssignment = ownedAssignment;
}
}

View File

@ -1,24 +1,37 @@
package com.plannaplan.entities;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import com.plannaplan.types.GroupType;
import com.plannaplan.types.WeekDay;
/**
* Entity of Groups grouping of state ssociated about
* course,time,room,capacity,type,day
*/
@Entity
public class Groups {
private static final int DEFAULT_CLASS_TIME = 90;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name = "course_id")
private Course courseId;
private Course course;
private int time;
private int endTime;
private String room;
private int capacity;
private GroupType type;
@ -26,70 +39,351 @@ public class Groups {
@ManyToOne
@JoinColumn(name = "lecturer_id")
private Lecturer lecturer;
private Integer zajCykId;
private Integer grNr;
@ManyToMany(mappedBy = "studentRegisteredGrups", fetch = FetchType.EAGER)
private Set<User> registeredStudents;
public Set<User> getRegisteredStudents() {
return this.registeredStudents;
}
public void assignUser(User user) {
if (this.registeredStudents == null) {
this.registeredStudents = new HashSet<>();
}
this.registeredStudents.add(user);
}
public Groups() {
}
public Integer getGrNr() {
return grNr;
}
public void setGrNr(Integer grNr) {
this.grNr = grNr;
}
public Integer getZajCykId() {
return zajCykId;
}
public void setZajCykId(Integer zajCykId) {
this.zajCykId = zajCykId;
}
/**
* Groups
*
* @param capacity capacity given to the groups
* @param room room given to the groups
* @param course course given to the groups
* @param time time given to the groups
* @param endTime end time of class in minutes
* @param day day given to the groups
* @param lecturer lecturer given to the groups
*/
public Groups(int capacity, String room, Course course, int time, int endTime, WeekDay day, Lecturer lecturer) {
this.capacity = capacity;
this.room = room;
this.course = course;
this.time = time;
this.endTime = endTime;
this.day = day;
this.lecturer = lecturer;
this.type = capacity >= 50 ? GroupType.LECTURE : GroupType.CLASS;
}
/**
* Groups
*
* @param capacity capacity given to the groups
* @param room room given to the groups
* @param course course given to the groups
* @param time time given to the groups
* @param endTime end time of class in minutes
* @param day day given to the groups
* @param lecturer lecturer given to the groups
* @param zajCykId number of class in the term
* @param grNr Number of class/course
* @param type type of class/cource
*/
public Groups(int capacity, String room, Course course, int time, int endTime, WeekDay day, Lecturer lecturer,
Integer zajCykId, Integer grNr, GroupType type) {
this(capacity, room, course, time, endTime, day, lecturer, zajCykId, grNr);
this.type = type;
}
/**
* Groups
*
* @param capacity capacity given to the groups
* @param room room given to the groups
* @param course course given to the groups
* @param time time given to the groups
* @param day day given to the groups
* @param lecturer lecturer given to the groups
* @param zajCykId number of class in the term
* @param grNr Number of class/course
* @param type type of class/cource
*/
public Groups(int capacity, String room, Course course, int time, WeekDay day, Lecturer lecturer,
Integer zajCykId, Integer grNr, GroupType type) {
this(capacity, room, course, time, time + DEFAULT_CLASS_TIME, day, lecturer, zajCykId, grNr);
this.type = type;
}
/**
* Groups
*
* @param capacity capacity given to the groups
* @param room room given to the groups
* @param course course given to the groups
* @param time time given to the groups
* @param endTime end time of class in minutes
* @param day day given to the groups
* @param lecturer lecturer given to the groups
* @param zajCykId number of class in the term
* @param grNr Number of class/course
*/
public Groups(int capacity, String room, Course course, int time, int endTime, WeekDay day, Lecturer lecturer,
Integer zajCykId, Integer grNr) {
this(capacity, room, course, time, endTime, day, lecturer);
this.zajCykId = zajCykId;
this.grNr = grNr;
}
/**
* Groups
*
* @param capacity capacity given to the groups
* @param room room given to the groups
* @param course course given to the groups
* @param time time given to the groups
* @param day day given to the groups
* @param lecturer lecturer given to the groups
* @param zajCykId number of class in the term
* @param grNr Number of class/course
*/
public Groups(int capacity, String room, Course course, int time, WeekDay day, Lecturer lecturer, Integer zajCykId,
Integer grNr) {
this(capacity, room, course, time, time + DEFAULT_CLASS_TIME, day, lecturer);
this.zajCykId = zajCykId;
this.grNr = grNr;
}
/**
* Create groups with default class duration
*
* @param capacity capacity given to the groups
* @param room room given to the groups
* @param course course given to the groups
* @param time time given to the groups
* @param day day given to the groups
* @param lecturer lecturer given to the groups
*/
public Groups(int capacity, String room, Course course, int time, WeekDay day, Lecturer lecturer) {
this(capacity, room, course, time, time + DEFAULT_CLASS_TIME, day, lecturer);
}
/**
* Updates given values other that are not null
*
* @param capacity capacity given to the groups
* @param room room given to the groups
* @param course course given to the groups
* @param time time given to the groups
* @param endTime end time of class in minutes
* @param day day given to the groups
* @param lecturer lecturer given to the groups
* @param type type given to the groups
*/
public void update(Integer capacity, String room, Course course, Integer time, Integer endTime, WeekDay day,
Lecturer lecturer, GroupType type) {
if (capacity != null) {
this.capacity = capacity;
}
if (room != null) {
this.room = room;
}
if (course != null) {
this.course = course;
}
if (time != null) {
this.time = time;
}
if (endTime != null) {
this.endTime = endTime;
}
if (day != null) {
this.day = day;
}
if (lecturer != null) {
this.lecturer = lecturer;
}
if (type != null) {
this.type = type;
}
}
/**
* get time of class end
*
* @return hour of class finish time in minutes
*/
public int getEndTime() {
return endTime;
}
/**
* getId
*
* @return id
*/
public Long getId() {
return this.id;
}
/**
* getLecturer
*
* @return lecturer
*/
public Lecturer getLecturer() {
return lecturer;
}
/**
* setLecturer
*
* @param lecturer set lecturer into groups
*/
public void setLecturer(Lecturer lecturer) {
this.lecturer = lecturer;
}
/**
* WeekDay
*
* @return day
*/
public WeekDay getDay() {
return day;
}
/**
* setLecturer
*
* @param day set day into groups
*/
public void setDay(WeekDay day) {
this.day = day;
}
/**
* GroupType
*
* @return type
*/
public GroupType getType() {
return type;
}
/**
* setType
*
* @param type set type into groups
*/
public void setType(GroupType type) {
this.type = type;
}
/**
* getCapacity
*
* @return capacity
*/
public int getCapacity() {
return capacity;
}
/**
* setCapacity
*
* @param capacity set capacity into groups
*/
public void setCapacity(int capacity) {
this.capacity = capacity;
}
/**
* getRoom
*
* @return room
*/
public String getRoom() {
return room;
}
/**
* setRoom
*
* @param room set room into groups
*/
public void setRoom(String room) {
this.room = room;
}
/**
* getTime
*
* @return time
*/
public int getTime() {
return time;
}
/**
* setTime
*
* @param time set time into groups
*/
public void setTime(int time) {
this.time = time;
}
/**
* getCourseId
*
* @return course
*/
public Course getCourseId() {
return courseId;
return course;
}
/**
* setCourseId
*
* @param courseId set courseId into groups
*/
public void setCourseId(Course courseId) {
this.courseId = courseId;
this.course = courseId;
}
/**
* getTimeString
*
* @return time as formated String
*/
public String getTimeString() {
int minutes = this.getTime() % 60;
String hoursString = Integer.toString(this.getTime() / 60);
@ -99,4 +393,19 @@ public class Groups {
}
return String.format("%s.%s", hoursString, minutesString);
}
/**
* gets end time formated strins
*
* @return end time as formated String
*/
public String getEndTimeString() {
int minutes = this.getEndTime() % 60;
String hoursString = Integer.toString(this.getEndTime() / 60);
String minutesString = Integer.toString(minutes);
if (minutes < 10) {
minutesString = "0" + minutesString;
}
return String.format("%s.%s", hoursString, minutesString);
}
}

View File

@ -1,25 +0,0 @@
package com.plannaplan.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Entity
public class HistoryElement {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name = "user_id")
private User user;
@ManyToOne
@JoinColumn(name = "incoming_id")
private Groups incoming;
@ManyToOne
@JoinColumn(name = "outcoming_id")
private Groups outcoming;
}

View File

@ -5,6 +5,10 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
* Entity of Lecturer grouping of state ssociated about id,title,name,surname
*/
@Entity
public class Lecturer {
@Id
@ -14,30 +18,14 @@ public class Lecturer {
private String name;
private String surname;
public String getTitle() {
return title;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setTitle(String title) {
this.title = title;
}
/**
* Lecturer
*
* @param title title given to the lecturer
* @param name name given to the lecturer
* @param surname surname given to the lecturer
*/
public Lecturer(String title, String name, String surname) {
this.title = title;
this.name = name;
@ -47,6 +35,60 @@ public class Lecturer {
public Lecturer() {
}
/**
* getTitle
* @return title
*
*/
public String getTitle() {
return title;
}
/**
* getSurname
* @return surname
*
*/
public String getSurname() {
return surname;
}
/**
* setSurname
* @param surname set surname to the lecturer
*
*/
public void setSurname(String surname) {
this.surname = surname;
}
/**
* getName
* @return name
*
*/
public String getName() {
return name;
}
/**
* setName
* @param name set name to the lecturer
*
*/
public void setName(String name) {
this.name = name;
}
/**
* setTitle
* @param title set title to the lecturer
*
*/
public void setTitle(String title) {
this.title = title;
}
@Override
public String toString() {
return String.format("%s %s %s", this.title, this.name, this.surname);

View File

@ -1,28 +0,0 @@
package com.plannaplan.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Entity
public class Transfer {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name = "owner_id")
private User ownerUser;
@ManyToOne
@JoinColumn(name = "group_id")
private Groups ownerGroup;
@ManyToOne
@JoinColumn(name = "target_id")
private Groups targetGroup;
public Transfer() {
}
}

View File

@ -1,30 +0,0 @@
package com.plannaplan.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Entity
public class Unavailability {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name = "user_id")
private User lecturer;
private int time;
public Unavailability() {
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
}

View File

@ -1,71 +1,283 @@
package com.plannaplan.entities;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import com.plannaplan.models.UserApiResponse;
import com.plannaplan.types.UserRoles;
/**
* Entity of User grouping of state ssociated about
* id,name,surname,email,role,token,tokenCreatedDate
*/
@Entity
public class User {
private static final float TOKEN_EXPIRE_MINUTES = 15;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String surname;
private String email;
private String usosId;
private UserRoles role;
private String token;
private Date tokenCreatedDate;
private String refreshToken;
private Timestamp tokenUsageDate;
private Integer ranking;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable
private Set<Groups> studentRegisteredGrups;
public Set<Groups> getStudentRegisteredGrups() {
return this.studentRegisteredGrups;
}
public void removeGroup(Long id) {
final Groups groupToDelete = this.studentRegisteredGrups.stream().filter(e -> e.getId().equals(id)).findFirst()
.get();
this.studentRegisteredGrups.remove(groupToDelete);
}
public void claimGroup(Groups group) {
if (this.studentRegisteredGrups == null) {
this.studentRegisteredGrups = new HashSet<>();
}
this.studentRegisteredGrups.add(group);
}
public User() {
}
/**
*
* @param name name given to the user
* @param surname surname given to the user
* @param mail mail given to the user
* @param role user's role
*/
public User(String name, String surname, String mail, UserRoles role) {
this.name = name;
this.surname = surname;
this.email = mail;
this.role = role;
}
/**
*
* @param name name given to the user
* @param surname surname given to the user
* @param mail mail given to the user
* @param usosId id in the USOS system
* @param role user's role
*/
public User(String name, String surname, String mail, String usosId, UserRoles role) {
this(name, surname, mail, role);
this.usosId = usosId;
}
/**
*
* @param name name given to the user
* @param surname surname given to the user
* @param mail mail given to the user
* @param usosId id in the USOS system
* @param role user's role
* @param ranking ranking points [100;500]. It's calculated by
* gradesAvg*100*studiesYear
*/
public User(String name, String surname, String mail, String usosId, UserRoles role, Integer ranking) {
this(name, surname, mail, usosId, role);
this.ranking = ranking;
}
/**
* usos id getter
*
* @return usosid
*/
public String getUsosId() {
return usosId;
}
/**
* email getter
*
* @return mailof user
*/
public String getEmail() {
return email;
}
/**
* email setter
*
* @param email user email
*/
public void setEmail(String email) {
this.email = email;
}
public Date getTokenCreatedDate() {
return tokenCreatedDate;
/**
* token usage getter
*
* @return Timestamp when token was used
*/
public Timestamp getTokenUsageDate() {
return tokenUsageDate;
}
/**
* token getter
*
* @return user token
*/
public String getToken() {
return token;
}
public void setToken(String token) {
this.tokenCreatedDate = new Date(System.currentTimeMillis());
this.token = token;
/**
* @return token needed to call refresh token after it expired
*/
public String getRefreshToken() {
return refreshToken;
}
/**
* token seter. Sets token and automaticly set time when was set
*
* @param token token to set
*/
public void setToken(String token) {
this.tokenUsageDate = new Timestamp(System.currentTimeMillis());
this.token = token;
this.refreshToken = this.refreshToken == null ? UUID.randomUUID().toString() : this.refreshToken;
}
/**
* name setter
*
* @return String user name
*/
public String getName() {
return name;
}
/**
* user rolse getter
*
* @return UserRoles of user
*/
public UserRoles getRole() {
return role;
}
/**
* user role setter
*
* @param role to be set
*/
public void setRole(UserRoles role) {
this.role = role;
}
/**
* surname getter
*
* @return string surname
*/
public String getSurname() {
return surname;
}
/**
* surname setter
*
* @param surname string to be set as surnames
*/
public void setSurname(String surname) {
this.surname = surname;
}
/**
* name stter
*
* @param name stirng to be set as name
*/
public void setName(String name) {
this.name = name;
}
/**
* id getter
*
* @return id in database
*/
public Long getId() {
return this.id;
}
/**
* Ranking points are [100;500]. It's calculated by gradesAvg*100*studiesYear
*
* @return ranking points [100;500]
*/
public Integer getRanking() {
if (ranking == null) {
return 100;
}
return ranking;
}
/**
* Ranking points setter. Ranking points are [100;500]. It's calculated by
* gradesAvg*100*studiesYear
*
* @param ranking ranking points [100;500]
*/
public void setRanking(Integer ranking) {
this.ranking = ranking;
}
/**
* updates user entity with data got by UsosApiService::getUserData
*
* @param usosData UserApiResponse model with needed data
*/
public void updateWithUsosData(UserApiResponse usosData) {
this.name = usosData.getName();
this.surname = usosData.getSurname();
}
/**
* it checks if given ammount of time passed since last token usage. If not
* retunr true and reset time otherwise return false and token won work anymore
*
* @return boolena if credentials (token) is expired or not
*/
public boolean isCredentialsNonExpired() {
final long diffInMilliseconds = Math
.abs(this.tokenUsageDate.getTime() - new Timestamp(System.currentTimeMillis()).getTime());
final long minutes = TimeUnit.MILLISECONDS.toMinutes(diffInMilliseconds);
if (minutes > TOKEN_EXPIRE_MINUTES) {
return false;
}
this.tokenUsageDate = new Timestamp(System.currentTimeMillis());
return true;
}
}

View File

@ -0,0 +1,6 @@
/**
* Provides all entieites that are created in database by Hibernate
*
* @since 1.0
*/
package com.plannaplan.entities;

View File

@ -0,0 +1,13 @@
package com.plannaplan.exceptions;
/**
* Excepction to be thrown when provided token is expired
*/
public class TokenExpiredException extends RuntimeException {
private static final long serialVersionUID = 1L;
public TokenExpiredException(String message) {
super(message);
}
}

View File

@ -1,9 +1,9 @@
package com.plannaplan.exceptions;
public class UserNotFoundException extends Exception {
/**
*
* Exception to be thrown when provided user does not exist in database
*/
public class UserNotFoundException extends Exception {
private static final long serialVersionUID = 1L;
public UserNotFoundException(String message) {

View File

@ -0,0 +1,6 @@
/**
* Provides custom for our app exceptions to get more accutrate errors info
*
* @since 1.0
*/
package com.plannaplan.exceptions;

View File

@ -1,5 +0,0 @@
package com.plannaplan.interfaces;
public interface EventCreator {
void update();
}

View File

@ -1,5 +0,0 @@
package com.plannaplan.interfaces;
public interface Historable {
void addActionToHistory();
}

View File

@ -1,5 +0,0 @@
package com.plannaplan.interfaces;
public interface ProtectedAction {
void validateAction();
}

View File

@ -1,29 +1,53 @@
package com.plannaplan.models;
import java.util.Date;
import java.io.InputStream;
/**
* Config data copntainer to keep tours dates and stream of dasta to import
*/
public class ConfigData {
private Date start;
private Date end;
private TourData firstTour;
private TourData secondTour;
private InputStream filestream;
public ConfigData(Date start, Date end, InputStream filestream) {
this.start = start;
this.end = end;
/**
* constructor
*
* @param firstTour date of first tours
* @param secondTour date of second tours
* @param filestream filestram with data to import
*/
public ConfigData(TourData firstTour, TourData secondTour, InputStream filestream) {
this.firstTour = firstTour;
this.secondTour = secondTour;
this.filestream = filestream;
}
/**
* second tour getter
*
* @return TourData second tour
*/
public TourData getSecondTour() {
return secondTour;
}
/**
* first tour getter
*
* @return TourData first tour
*/
public TourData getFirstTour() {
return firstTour;
}
/**
* filestream getter
*
* @return InputStream with data to import
*/
public InputStream getFilestream() {
return filestream;
}
public Date getEnd() {
return end;
}
public Date getStart() {
return start;
}
}

View File

@ -0,0 +1,97 @@
package com.plannaplan.models;
import java.util.Iterator;
import java.util.List;
import com.plannaplan.entities.Groups;
/**
* Instance to keep data to send in mail about accepted courses results
*/
public class EmailAcceptedData {
private List<Groups> accepted;
private List<Groups> removed;
public EmailAcceptedData() {
}
/**
* creates instance of class
*
* @param accepted list of groups that user joined to
* @param removed lsit of groups that user failed to join
*/
public EmailAcceptedData(List<Groups> accepted, List<Groups> removed) {
this.accepted = accepted;
this.removed = removed;
}
/**
* get list of removed assignments
*
* @return removed assingments
*/
public List<Groups> getRemoved() {
return removed;
}
/**
* set list of removed assignments
*
* @param removed list of removed assignments
*/
public void setRemoved(List<Groups> removed) {
this.removed = removed;
}
/**
* get list of accepted assignments
*
* @return accepted assingments
*/
public List<Groups> getAccepted() {
return accepted;
}
/**
* set list of accepted assignments
*
* @param accepted list of accepted assignments
*/
public void setAccepted(List<Groups> accepted) {
this.accepted = accepted;
}
/**
* it creates and return email message body
*
* @return string with emiale massage
*/
public String getEmailMessage() {
String response = "Akceptacja Twoich przedmiotów właśnie dobiegła końca.\n\n";
if (this.accepted != null && this.accepted.size() > 0) {
response += "Zatwierdzone grupy: \n";
Iterator<Groups> iterator = accepted.iterator();
while (iterator.hasNext()) {
final Groups gorup = iterator.next();
final String courseName = gorup.getCourseId() != null ? gorup.getCourseId().getName()
: "Nieznana grupa";
response += (" - " + courseName + " - " + gorup.getType() + "\n");
}
}
if (this.removed != null && this.removed.size() > 0) {
response += "Usunięte grupy: \n";
Iterator<Groups> iterator = removed.iterator();
while (iterator.hasNext()) {
final Groups gorup = iterator.next();
final String courseName = gorup.getCourseId() != null ? gorup.getCourseId().getName()
: "Nieznana grupa";
response += (" - " + courseName + " - " + gorup.getType() + "\n");
}
}
return response;
}
}

View File

@ -0,0 +1,45 @@
package com.plannaplan.models;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.plannaplan.entities.Exchange;
import com.plannaplan.entities.User;
/**
* Class to keepm data to be send after exchanges being accept
*/
public class EmailExchangesData {
private Map<Long, List<Exchange>> data;
public EmailExchangesData() {
this.data = new HashMap<>();
}
/**
* method to add user and his event to data to be send
*
* @param user owner of exchange being performed
* @param data exchange that was executed
*/
public void addExchange(User user, Exchange data) {
final Long id = user.getId();
if (this.data.get(id) == null) {
this.data.put(id, new ArrayList<>());
}
this.data.get(id).add(data);
}
/**
* get datas entry set
*
* @return set with entries that contains Long that is user id and list of hiss
* performed Exchanges
*/
public Set<Map.Entry<Long, List<Exchange>>> getDataEntry() {
return this.data.entrySet();
}
}

View File

@ -0,0 +1,86 @@
package com.plannaplan.models;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Container to keep data to export
*/
public class ExportData {
private static final String GROUP_FIELD = "gr_nr";
private static final String USER_FIELD = "user_id";
private static final String CYKL_FIELD = "zaj_cykl_id";
private String userId;
private String zajCyklId;
private String grNr;
/**
* @param userId usosid
* @param zajCyklId course cycle
* @param grNr group number
*/
public ExportData(String userId, String zajCyklId, String grNr) {
this.setUserId(userId);
this.setZajCyklId(zajCyklId);
this.setGrNr(grNr);
}
/**
* @return group number
*/
public String getGrNr() {
return grNr;
}
/**
* @param grNr group number
*/
public void setGrNr(String grNr) {
this.grNr = grNr;
}
/**
* @return course cycle
*/
public String getZajCyklId() {
return zajCyklId;
}
/**
* @param zajCyklId course cycle
*/
public void setZajCyklId(String zajCyklId) {
this.zajCyklId = zajCyklId;
}
/**
* @return usosid
*/
public String getUserId() {
return userId;
}
/**
* @param userId usosid
*/
public void setUserId(String userId) {
this.userId = userId;
}
/**
* @return csv fromated line
*/
public String convertToCSVRecord() {
return Stream.of(this.userId, this.zajCyklId, this.grNr).collect(Collectors.joining(","));
}
/**
* @return csv formated first line
*/
public static String getCSVHeader() {
return USER_FIELD + ", " + CYKL_FIELD + ", " + GROUP_FIELD;
}
}

View File

@ -1,36 +1,70 @@
package com.plannaplan.models;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Iterator;
import org.apache.poi.ss.usermodel.Row;
/**
* Wrapper for data readed from file
*/
public class FileData {
private Dictionary<String, Integer> keys;
private HashMap<String, Integer> keys;
private Iterator<Row> rows;
public FileData(Dictionary<String, Integer> keys, Iterator<Row> rows) {
this.setKeys(keys);
this.setRows(rows);
/*
* FileData
*
* @param keys this is a hashmap of String and Integer
*
* @param rows this is a iterator of rows.
*/
public FileData(HashMap<String, Integer> keys, Iterator<Row> rows) {
this.keys = keys;
this.rows = rows;
}
/*
* getRows
*
* @return rows
*/
public Iterator<Row> getRows() {
return rows;
}
/*
* setRows
*
* @param rows set the rows to given function
*/
public void setRows(Iterator<Row> rows) {
this.rows = rows;
}
public Dictionary<String, Integer> getKeys() {
/*
* getKeys
*
* @return keys
*/
public HashMap<String, Integer> getKeys() {
return keys;
}
public void setKeys(Dictionary<String, Integer> keys) {
/*
* setKeys
*
* @param keys set the key is being a struck of hashmap (String, Integer)
*/
public void setKeys(HashMap<String, Integer> keys) {
this.keys = keys;
}
/*
* getIndexOf
*
* @return index
*/
public int getIndexOf(String key) {
int index = this.keys.get(key);
return index;

View File

@ -0,0 +1,95 @@
package com.plannaplan.models;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Exchange;
/**
* Match of users Exchange's to be performed
*/
public class MatchData {
private Exchange exchangeOne;
private Exchange exchangeTwo;
/**
* create MatchData
*
* @param exchangeOne first Exchange of found match
* @param exchangeTwo second Exchange of found match
*/
public MatchData(Exchange exchangeOne, Exchange exchangeTwo) {
this.exchangeOne = exchangeOne;
this.exchangeTwo = exchangeTwo;
}
/**
* @return first Exchange
*/
public Exchange getExchangeOne() {
return this.exchangeOne;
}
/**
* @return second Exchange
*/
public Exchange getExchangeTwo() {
return this.exchangeTwo;
}
/**
* @return second Exchange's owned assignmetn
*/
public Assignment getAssignmentTwo() {
return this.exchangeTwo.getOwnedAssignment();
}
/**
* @return first Exchange's owned assignmetn
*/
public Assignment getAssignmentOne() {
return this.exchangeOne.getOwnedAssignment();
}
@Override
public int hashCode() {
return this.getAssignmentOne().hashCode() + this.getAssignmentTwo().hashCode();
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof MatchData)) {
return false;
}
MatchData c = (MatchData) o;
return (this.getAssignmentOne().equals(c.getAssignmentOne())
&& this.getAssignmentTwo().equals(c.getAssignmentTwo()))
|| (this.getAssignmentOne().equals(c.getAssignmentTwo())
&& this.getAssignmentTwo().equals(c.getAssignmentOne()));
}
/**
* comparator for MatchData. It compare it by sum of both exchange's times. For
* example MatchData with Exchanges 11:00 and 12:00 will be less than with
* Exchanges 12:00 and 12:00
*
* @param m1 MatchData instance to compare to
* @return int less than 0 if m1 is "less than", 0 if it's equal and more than 0
* otherwise
*/
public int compare(MatchData m1) {
return Long.compare(m1.getExchangesMsValue(), this.getExchangesMsValue());
}
/**
* @return sum of both exchanges java.sql.Timestanp::getTime"
*/
public long getExchangesMsValue() {
return this.exchangeOne.getDataExchange().getTime() + this.exchangeTwo.getDataExchange().getTime();
}
}

View File

@ -0,0 +1,52 @@
package com.plannaplan.models;
import java.sql.Date;
/**
* Container for Tours dates
*/
public class TourData {
private Date start;
private Date end;
/**
* construcotr for java.sql.Date
*
* @param start Date when tour start
* @param end Date when tour end
*/
public TourData(Date start, Date end) {
this.start = start;
this.end = end;
}
/**
* constructor construcotr for java.util.Date
*
* @param start Date when tour start
* @param end Date when tour end
*/
public TourData(java.util.Date start, java.util.Date end) {
this.start = new Date(start.getTime());
this.end = new Date(end.getTime());
}
/**
* tour end getter
*
* @return Date end of tour
*/
public Date getEnd() {
return end;
}
/**
* tour start getter
*
* @return Date beginning of tour
*/
public Date getStart() {
return start;
}
}

View File

@ -0,0 +1,47 @@
package com.plannaplan.models;
/**
* Model to keep data from /services/users/user response called in
* UsosApiService
*/
public class UserApiResponse {
private String name;
private String surname;
public UserApiResponse() {
}
/**
* @return user's Surname
*/
public String getSurname() {
return surname;
}
/**
* setter for name. Reson to have setters for this class is for case if there
* would be name and no surname or otherwise
*
* @param surname name to set that was obtained by api request
*/
public void setSurname(String surname) {
this.surname = surname;
}
/**
* @return user's Name
*/
public String getName() {
return name;
}
/**
* setter for surname. Reson to have setters for this class is for case if there
* would be name and no surname or otherwise
*
* @param name name to set that was obtained by api request
*/
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,6 @@
/**
* Provides readonly (mostly) classes to keep data for diffrent pourposes
*
* @since 1.0
*/
package com.plannaplan.models;

View File

@ -0,0 +1,11 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.AppConfig;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* Repository for app config
*/
public interface AppConfigRepository extends JpaRepository<AppConfig, Long> {
}

View File

@ -1,11 +1,25 @@
package com.plannaplan.repositories;
import java.util.List;
import com.plannaplan.entities.Assignment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
/**
* AssignmentRepository.getByCommision:
* Return list of:
* SELECT * FROM Assignment WHERE commision_id = i .
*
* Where i, ?1 are equale to variables.
*/
@Repository
public interface AssignmentRepository extends JpaRepository<Assignment, Long> {
@Query("FROM Assignment WHERE commision_id = ?1")
List<Assignment> getByCommision(@Param("commision_id") Long id);
}

View File

@ -0,0 +1,37 @@
package com.plannaplan.repositories;
import java.util.List;
import com.plannaplan.entities.Commision;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
/**
* CommisionRepository.getUsers: Return list of: SELECT * FROM Commision WHERE
* owner_id = i .
*
* Where i, ?1 are equale to variables.
*
* CommisionRepository.getNewestCommision Return list of: SELECT * FROM
* Commision WHERE owner_id = i Order by commisionDate desc.
*
* Where i, ?1 are equale to variables.
*/
@Repository
public interface CommisionRepository extends JpaRepository<Commision, Long> {
@Query("FROM Commision WHERE owner_id = ?1")
List<Commision> getUsers(@Param("owner_id") Long id);
@Query("FROM Commision WHERE owner_id = ?1 order by commisionDate desc")
List<Commision> getNewestCommision(@Param("owner_id") Long id);
/**
* @return ammount of uniqe users that have a commision placed on first array
* element
*/
@Query("SELECT COUNT(DISTINCT owner_id) AS count FROM Commision")
Object[] getUsersAssigned();
}

View File

@ -1,5 +1,7 @@
package com.plannaplan.repositories;
import java.util.Optional;
import com.plannaplan.entities.Course;
import org.springframework.data.jpa.repository.JpaRepository;
@ -7,8 +9,15 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
/**
* CourseRepository.findByName:
* Return list of:
* SELECT * FROM Course WHERE name = i .
*
* Where i, ?1 are equale to variables.
*/
@Repository
public interface CourseRepository extends JpaRepository<Course, Long> {
@Query("FROM Course WHERE name = ?1")
Course findByName(@Param("name") String name);
Optional<Course> findByName(@Param("name") String name);
}

View File

@ -1,11 +0,0 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.Event;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface EventRepository extends JpaRepository<Event, Long> {
}

View File

@ -0,0 +1,26 @@
package com.plannaplan.repositories;
import java.util.List;
import java.util.Optional;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Exchange;
import com.plannaplan.entities.Groups;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface ExchangeRepository extends JpaRepository<Exchange, Long>{
@Query("FROM Exchange WHERE owned_id = ?1 AND desired_id = ?2")
Optional<Exchange> checkForExchange(@Param("owned_id") Assignment assignment, @Param("desired_id") Groups group);
@Query("FROM Exchange WHERE ownerId = ?1")
List<Exchange> getByUserId(@Param("id") Long id);
@Query("Select e1,e2 FROM Exchange e1, Exchange e2 WHERE e1.ownedAssignment.group.id = e2.desiredAssignment.id")
List<Object[]> getMatches();
}

View File

@ -1,6 +1,7 @@
package com.plannaplan.repositories;
import java.util.List;
import java.util.Optional;
import com.plannaplan.entities.Groups;
@ -9,12 +10,42 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
/**
* GroupRepository.find:
* Return list of:
* SELECT * FROM Groups WHERE time = i AND room = j AND capacity = k .
*
* Where i, j, k, ?1, ?2, ?3 are equale to variables.
*
* GroupRepository.getByCourse:
* Return list of:
* SELECT * FROM Groups WHERE course_id = i .
*
* Where i, ?1 are equale to variables.
*/
@Repository
public interface GroupRepository extends JpaRepository<Groups, Long> {
@Query("FROM Groups WHERE time = ?1 AND room = ?2 AND capacity = ?3")
Groups find(@Param("time") int time, @Param("room") String room, @Param("capacity") int capacity);
Optional<Groups> find(@Param("time") int time, @Param("room") String room, @Param("capacity") int capacity);
@Query("FROM Groups WHERE zajCykId = ?1 AND grNr = ?2")
Optional<Groups> find(@Param("zajCykId") Integer zaj_cyk_id, @Param("grNr") Integer gr_nr);
@Query("FROM Groups WHERE course_id = ?1")
List<Groups> getByCourse(@Param("id") Long id);
@Query("SELECT COUNT(*) AS assinged_times FROM Assignment WHERE isPastAssignment=false GROUP BY group HAVING group_id=?1")
Optional<Number> getAssignedAmount(Long groupId);
/**
* PLAIN SQL QUERY: SELECT group_id, COUNT(*) assinged_times FROM assignment
* WHERE is_past_assignment=0 GROUP BY group_id HAVING group_id IN (:ids)")
*
* @param groupIds list of groups ids
* @return list of objects arrays where first object is Groups instance and
* second is Long that is taken places value
*/
@Query("SELECT group, COUNT(*) AS assinged_times FROM Assignment a WHERE a.isPastAssignment=false GROUP BY a.group HAVING group_id IN (:ids)")
List<Object[]> getAssignedAmounts(@Param("ids") List<Long> groupIds);
}

View File

@ -1,11 +0,0 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.HistoryElement;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface HistoryRepository extends JpaRepository<HistoryElement, Long> {
}

View File

@ -1,5 +1,7 @@
package com.plannaplan.repositories;
import java.util.Optional;
import com.plannaplan.entities.Lecturer;
import org.springframework.data.jpa.repository.JpaRepository;
@ -7,8 +9,15 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
/**
* LecturerRepository.find:
* Return list of:
* SELECT * FROM Lecturer WHERE title = i AND name = j AND surname = k.
*
* Where i, j, k, ?1, ?2, ?3 are equale to variables.
*/
@Repository
public interface LecturerRepository extends JpaRepository<Lecturer, Long> {
@Query("FROM Lecturer WHERE title = ?1 AND name = ?2 AND surname = ?3")
Lecturer find(@Param("title") String title, @Param("name") String name, @Param("surname") String surname);
Optional<Lecturer> find(@Param("title") String title, @Param("name") String name, @Param("surname") String surname);
}

View File

@ -1,11 +0,0 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.Transfer;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface TransferRepository extends JpaRepository<Transfer, Long> {
}

View File

@ -1,11 +0,0 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.Unavailability;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface UnavailabilityRepository extends JpaRepository<Unavailability, Long> {
}

View File

@ -1,17 +1,74 @@
package com.plannaplan.repositories;
import java.util.List;
import java.util.Optional;
import com.plannaplan.entities.User;
import com.plannaplan.types.UserRoles;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
/**
* UserRepository.getByAuthority: Return list of: SELECT * FROM User WHERE email
* = i.
*
* Where i, ?1 are equale to variables.
*
* UserRepository.getByToken: Return list of: SELECT * FROM User WHERE token =
* i.
*
* Where i, ?1 are equale to variables.
*
* UserRepository.searchForUsers: Return list of: SELECT * FROM User WHERE (name
* LIKE %?1% OR surname LIKE %?1%).
*
* Where i, ?1 are equale to variables.
*
* UserRepository.searchForUsers with role: Return list of: SELECT * FROM User
* WHERE (name LIKE %?1% OR surname LIKE %?1%) AND role=?2").
*
* Where i, ?1 are equale to variables.
*/
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
/**
* return user by given authority
*
* @param authority user usosId or email
* @return optional with user if found
*/
@Query("FROM User WHERE email = ?1 OR usosId = ?1")
Optional<User> getByAuthority(@Param("authority") String authority);
@Query("FROM User WHERE email = ?1")
User getByAuthority(@Param("authority") String authority);
Optional<User> getByEmail(@Param("authority") String authority);
@Query("FROM User WHERE refreshToken = ?1")
Optional<User> getByRefreshToken(@Param("refreshToken") String refreshToken);
@Query("FROM User WHERE token = ?1")
User getByToken(@Param("token") String token);
Optional<User> getByToken(@Param("token") String token);
@Query("FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%)")
List<User> searchForUsers(@Param("query") String query);
/**
* search for user with given query
*
* @param query string that will be matched to users name and surname
* @param role limits results by role
* @return list opf results
*/
@Query("FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%) AND role=?2")
List<User> searchForUsers(@Param("query") String query, @Param("role") UserRoles role);
@Query("FROM User WHERE role=?1")
List<User> getAllByRole(@Param("role") UserRoles role);
@Query("FROM User WHERE usosId = ?1")
Optional<User> getByUsosId(@Param("usosId") String usosId);
}

View File

@ -0,0 +1,7 @@
/**
* Provides jpa repositories interfaces to comunicate with database. These are
* used exclusively in services
*
* @since 1.0
*/
package com.plannaplan.repositories;

View File

@ -1,17 +1,117 @@
package com.plannaplan.services;
import com.plannaplan.abstracts.EventWatcher;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Commision;
import com.plannaplan.entities.Groups;
import com.plannaplan.entities.User;
import com.plannaplan.models.EmailAcceptedData;
import com.plannaplan.repositories.AssignmentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service of Assignment which can save assignments, diplay assignments, get
* ammount of assigments.
*/
@Service
public class AssignmentService extends EventWatcher {
public class AssignmentService {
@Autowired
private AssignmentRepository repo;
@Autowired
private CommisionService service;
@Autowired
private UserService userService;
@Autowired
private EmailService emailService;
public AssignmentService() {
super();
}
/**
* Save given assignment
*
* @param assignment assignment to save
* @return assignment saved assignment with database id
*/
public Assignment save(Assignment assignment) {
return this.repo.save(assignment);
}
/**
* gets list of assignments of given commision
*
* @param com Commision to get assinments from
* @return list of assignments
*/
public List<Assignment> getCommisionAssignments(Commision com) {
return this.repo.getByCommision(com.getId());
}
/**
* get ammount of all assignments (not only for selected commision)
*
* @return long - ammount of assingments
*/
public long getAssignmentsAmmount() {
return this.repo.count();
}
/**
* Get assigmnent by id
*
* @param id id of assigmnent
* @return Optional of assignment
*/
public Optional<Assignment> getById(Long id) {
return this.repo.findById(id);
}
/**
* this method will activate accept algorythm for all students. Algorythm is
* takeing each student in order defined by ranking and accept for him groups
* that are joinable for him
*/
public void callAcceptAlgorythm() {
final List<User> students = this.userService.getStudentsSortedByRanking();
students.forEach(e -> {
final Optional<Commision> com = this.service.getNewestCommision(e);
final List<Groups> accepted = new ArrayList<>();
final List<Groups> removed = new ArrayList<>();
if (com.isPresent()) {
final List<Assignment> assignments = this.getCommisionAssignments(com.get());
assignments.forEach(a -> {
if (a.isAccepted() == false) {
final Groups group = a.getGroup();
if (group.getCapacity() > group.getRegisteredStudents().size()) {
e.claimGroup(group);
accepted.add(group);
} else {
removed.add(group);
}
}
});
}
this.userService.save(e);
this.emailService.sendAcceptationResult(e, new EmailAcceptedData(accepted, removed));
});
}
/**
* @param toSave list of entites to save to db
* @return list of assignments entities with ids from db
*/
public List<Assignment> saveAll(List<Assignment> toSave) {
return this.repo.saveAll(toSave);
}
}

View File

@ -0,0 +1,101 @@
package com.plannaplan.services;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import com.plannaplan.entities.Commision;
import com.plannaplan.entities.User;
import com.plannaplan.models.ExportData;
import com.plannaplan.repositories.AssignmentRepository;
import com.plannaplan.repositories.CommisionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service of CommisionService which can save commision, get user's commisions,
* get newest user's commision, get ammount of commisions.
*/
@Service
public class CommisionService {
@Autowired
private CommisionRepository repo;
@Autowired
private AssignmentRepository aRepository;
@Autowired
private UserService userService;
public CommisionService() {
}
/**
* save to database commision. It also checks for missing assignments from
* previous commision (you can not get rid of accepted assignment)
*
* @param commision to save to db
* @return Commision instance with id from database
*/
public Commision save(Commision commision) {
Optional<Commision> lastCommision = this.getNewestCommision(commision.getCommisionOwner());
if (lastCommision.isPresent()) {
final Commision lastCom = lastCommision.get();
lastCom.getAssignments().forEach(assignment -> {
assignment.setPastAssignment(true);
this.aRepository.save(assignment);
});
}
this.repo.save(commision);
return commision;
}
/**
* gets user commisions
*
* @param user owner of commisions
* @return list of user commisions
*/
public List<Commision> getUsersCommisions(User user) {
return this.repo.getUsers(user.getId());
}
/**
* get newest commision ov given user
*
* @param user owener of commision we attemp to get
* @return optional if commition was found
*/
public Optional<Commision> getNewestCommision(User user) {
return this.repo.getNewestCommision(user.getId()).stream().findFirst();
}
/**
* get ammpounts of commisions
*
* @return long - ammounts of commisions (all even from history, not only
* cutrrent one)
*/
public long getCommisionsAmmount() {
return this.repo.count();
}
/**
* @return list of ExportData inmstancces keeping data to exprt to file
*/
public List<ExportData> getExportData() {
final List<ExportData> response = new ArrayList<>();
this.userService.getAllStudents().forEach(student -> {
student.getStudentRegisteredGrups().forEach(group -> {
response.add(new ExportData(student.getUsosId(), Integer.toString(group.getZajCykId()),
Integer.toString(group.getGrNr())));
});
});
return response;
}
}

View File

@ -0,0 +1,137 @@
package com.plannaplan.services;
import com.plannaplan.models.ConfigData;
import com.plannaplan.models.FileData;
import com.plannaplan.models.TourData;
import com.plannaplan.repositories.AppConfigRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.InputStream;
import java.sql.Date;
import java.time.LocalDate;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import com.plannaplan.configutils.*;
import com.plannaplan.entities.AppConfig;
/**
* FileReader is used for reading xls file from input stream.
*/
@Component
public class ConfiguratorService {
@Autowired
private FileToDatabaseMigrator migrator;
@Autowired
private AppConfigRepository configRepo;
@Autowired
private EventService eventService;
@Autowired
private AssignmentService assignmentService;
public ConfiguratorService() {
}
/**
* methoid to config system. it shedules PerformAcceptAlgorythmTask as a side
* effect
*
* @param data ConfigData containng system configs
*/
public void config(ConfigData data) {
FileReader reader = new FileReader(data.getFilestream());
FileData coursesData = reader.read();
final AppConfig config = new AppConfig(data.getFirstTour(), data.getSecondTour());
this.configRepo.save(config);
migrator.migrate(coursesData);
this.shceduleTaskAfterToursDateChange(config);
}
/**
* Save tours to DataBase and shedule PerformAcceptAlgorythmTask as a side
* effect
*
* @param firstTour First tour period.
* @param secondTour Second tour period.
*/
public void saveTours(TourData firstTour, TourData secondTour) {
final AppConfig config = new AppConfig(firstTour, secondTour);
this.configRepo.save(config);
this.shceduleTaskAfterToursDateChange(config);
}
/**
* current config getter
*
* @return AppConfig with newest config_date
*/
public AppConfig getCurrentConfig() {
final List<AppConfig> repsonse = this.configRepo.findAll().stream().sorted(new Comparator<AppConfig>() {
@Override
public int compare(AppConfig i1, AppConfig i2) {
if (i1.getConfigDate().after(i2.getConfigDate())) {
return -1;
}
if (i1.getConfigDate().before(i2.getConfigDate())) {
return 1;
}
return 0;
}
}).collect(Collectors.toList());
return repsonse.get(0);
}
/**
*
* @param inputStream This input stream contains new courses to import.
*/
public void importCoursesStream(InputStream inputStream) {
FileReader reader = new FileReader(inputStream);
FileData coursesData = reader.read();
migrator.migrate(coursesData);
}
private void shceduleTaskAfterToursDateChange(AppConfig config) {
this.eventService.scheduleTask(EventService.FIRST_TOUR_SCHEDULE,
new AlgorythmAcceptTask(config.getFirstTourEnd()), config.getFirstTourEndCron());
this.eventService.scheduleTask(EventService.SECOND_TOUR_SCHEDULE,
new AlgorythmAcceptTask(config.getSecondTourEnd()), config.getSecondTourEndCron());
}
/**
* It's local class to perform accept Task. It's needed to be here due to have
* acces to AssignmentService.
*/
private class AlgorythmAcceptTask implements Runnable {
private LocalDate localDate;
/**
* create instance of AlgorythmAcceptTask
*
* @param date date of algorythm perform. Needed to check if ti's being called
* in correct year
*/
public AlgorythmAcceptTask(Date date) {
this.localDate = date.toLocalDate();
}
@Override
public void run() {
System.out.println("Performing event");
if (localDate.getYear() == LocalDate.now().getYear()) {
assignmentService.callAcceptAlgorythm();
}
}
}
}

View File

@ -1,6 +1,7 @@
package com.plannaplan.services;
import java.util.List;
import java.util.Optional;
import com.plannaplan.entities.Course;
import com.plannaplan.repositories.CourseRepository;
@ -8,27 +9,57 @@ import com.plannaplan.repositories.CourseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service of CourseService which can get(Course By Name, All Courses, Courses
* Ammount ), save, delete course.
*/
@Service
public class CourseService {
@Autowired
private CourseRepository repo;
public Course getCourseByName(String name) {
/**
* getCourseByName
*
* @param name name of course to be found
* @return Course By Name
*/
public Optional<Course> getCourseByName(String name) {
return this.repo.findByName(name);
}
/**
*
* @return all courses from db
*/
public List<Course> getAllCourses() {
return this.repo.findAll();
}
public void save(Course course) {
/**
* save to db
*
* @param course which course you would like to save
* @return Course instance with id from db
*/
public Course save(Course course) {
this.repo.save(course);
return course;
}
/**
* delete course from db
*
* @param course which course you would like to delete
*/
public void delete(Course course) {
this.repo.delete(course);
}
/**
* @return ammount of courses in db
*/
public int getCoursesAmmount() {
return (int) this.repo.count();
}

View File

@ -0,0 +1,101 @@
package com.plannaplan.services;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.plannaplan.entities.Exchange;
import com.plannaplan.entities.User;
import com.plannaplan.models.EmailAcceptedData;
import com.plannaplan.models.EmailExchangesData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
/**
* Service to send emails
*/
@Service
public class EmailService {
@Autowired
private JavaMailSender emailSender;
@Autowired
private UserService userService;
@Value("${plannaplan.email}")
private String appEmail;
public EmailService() {
}
/**
* send simple text email
*
* @param destination destitnaion mail
* @param message text to be send
*/
public void sendMail(String destination, String message) {
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setFrom(appEmail);
mailMessage.setTo(destination);
mailMessage.setSubject("[Plan na plan] INFO");
mailMessage.setText(message);
emailSender.send(mailMessage);
}
/**
* sends email with infromation about accepted groups
*
* @param user user to send a mail
* @param data EmailAcceptedData instance containing informations about accepted
* and removed groups
*/
public void sendAcceptationResult(User user, EmailAcceptedData data) {
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setFrom(appEmail);
mailMessage.setTo(user.getEmail());
mailMessage.setSubject("[PlanNaPlan] Akceptacja przedmiotów");
mailMessage.setText(data.getEmailMessage());
emailSender.send(mailMessage);
}
/**
* method to send email for students whose groups were swaped
*
* @param data EmailExchangesData instance that contains pair of datas user and
* list of performed exhanges
*/
public void sendExchangesResults(EmailExchangesData data) {
for (Map.Entry<Long, List<Exchange>> entry : data.getDataEntry()) {
final User user = this.userService.getById(entry.getKey()).get();
String response = "Znaleźliśmy dla Ciebie osobę, która zamieniła się z Tobą przedmiotami!!!\n Zamienione przedmioty: \n";
final Iterator<Exchange> interator = entry.getValue().iterator();
while (interator.hasNext()) {
final Exchange exchange = interator.next();
final String courseFrom = exchange.getDesiredAssignment().getCourseId() != null
? exchange.getDesiredAssignment().getCourseId().getName()
: "Nieznane zajęcie";
final String courseTo = exchange.getOwnedAssignment().getGroup().getCourseId() != null
? exchange.getOwnedAssignment().getGroup().getCourseId().getName()
: "Nieznane zajęcie";
response += (" - " + courseFrom + " za " + courseTo.toLowerCase());
}
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setFrom(appEmail);
mailMessage.setTo(user.getEmail());
mailMessage.setSubject("[PlanNaPlan] Zamiana przedmiotów");
mailMessage.setText(response);
emailSender.send(mailMessage);
}
}
}

View File

@ -1,12 +1,71 @@
package com.plannaplan.services;
import com.plannaplan.repositories.EventRepository;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ScheduledFuture;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Service;
/**
* Service to manage app events
*/
@Service
public class EventService {
@Autowired
private EventRepository repo;
private ExchangeService exchangeService;
public static final int FIRST_TOUR_SCHEDULE = 0;
public static final int SECOND_TOUR_SCHEDULE = 1;
private ThreadPoolTaskScheduler scheduler;
private Map<Integer, ScheduledFuture<?>> jobsMap = new HashMap<>();
@Scheduled(cron = "0 24 17 * * *")
public void collectGroupLosses() {
System.out.println("Checking for groups");
}
/**
* perfroms checks for matching exchanges daily
*/
@Scheduled(cron = "0 0 0 * * *")
public void performExchangeService() {
System.out.println("Performing Exchange");
this.exchangeService.performExchange();
}
/**
* Schedule provided task to perform
*
* @param taskId static filed of this class that represents to what event
* we want to assign task
* @param task runnable class that perform task in implemented run method
* @param cronTrigger CronTrigger instance with date to perform
*/
public void scheduleTask(int taskId, Runnable task, CronTrigger cronTrigger) {
ScheduledFuture<?> scheduledTask = jobsMap.get(taskId);
if (scheduledTask != null) {
scheduledTask.cancel(true);
jobsMap.put(taskId, null);
}
scheduledTask = this.scheduler.schedule(task, cronTrigger);
jobsMap.put(taskId, scheduledTask);
}
/**
* init resources needed for dynamicly creating new tasks (needed to set tours
* end events)
*/
@PostConstruct
public void initialize() {
this.scheduler = new ThreadPoolTaskScheduler();
this.scheduler.initialize();
}
}

View File

@ -0,0 +1,158 @@
package com.plannaplan.services;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Commision;
import com.plannaplan.entities.Exchange;
import com.plannaplan.entities.Groups;
import com.plannaplan.entities.User;
import com.plannaplan.models.EmailExchangesData;
import com.plannaplan.models.MatchData;
import com.plannaplan.repositories.ExchangeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service to manage Exchanges
*/
@Service
public class ExchangeService {
@Autowired
private ExchangeRepository repo;
@Autowired
private AssignmentService assignmentService;
@Autowired
private UserService userService;
@Autowired
private EmailService emailService;
/**
* @param exchange Instance to save in database
* @return Exchange Instance contains database id
*/
public Exchange save(Exchange exchange) {
return this.repo.save(exchange);
}
/**
* @param id Id of exchange in database
* @return Optional Exchange if found
*/
public Optional<Exchange> getById(Long id) {
return this.repo.findById(id);
}
/**
* @return list of all exchanges in database
*/
public List<Exchange> getAllExchanges() {
return this.repo.findAll();
}
/**
* @param id Id of user
* @return List of exchanges that belong to user
*/
public List<Exchange> getByUserId(Long id) {
return this.repo.getByUserId(id);
}
/**
* @param entity Exchange entity which we would like to delete
*/
public void deleteExchange(Exchange entity) {
this.repo.delete(entity);
}
/**
* @param assignment Assignment to trade for
* @param group Desired group
* @return Optional with Exchange if exist
*/
public Optional<Exchange> checkForExchange(Assignment assignment, Groups group) {
return this.repo.checkForExchange(assignment, group);
}
/**
* method to perform Exchange algorythm. It search for matches and swap
* assignments between latests user commisions if it can be performed. After
* swap we block users matches that contains switched groups. After algorythm
* email is being sent to all users with information about performed exchanges
*/
public void performExchange() {
final List<MatchData> matchData = this.getMatches();
final List<Long> performedAssignmentExchanges = new ArrayList<>();
final EmailExchangesData emailData = new EmailExchangesData();
final List<Exchange> exchangesToDelete = new ArrayList<>();
matchData.forEach(m -> {
final Assignment assignmentOne = m.getAssignmentOne();
final Assignment assignmentTwo = m.getAssignmentTwo();
final Exchange exchange1 = m.getExchangeOne();
final Exchange exchange2 = m.getExchangeTwo();
if (!(performedAssignmentExchanges.contains(assignmentOne.getId())
|| performedAssignmentExchanges.contains(assignmentTwo.getId()))) {
final Commision commisionOne = assignmentOne.getCommision();
final User userOne = commisionOne.getCommisionOwner();
final Commision commisionTwo = assignmentTwo.getCommision();
final User userTwo = commisionTwo.getCommisionOwner();
assignmentOne.setCommision(commisionTwo);
assignmentTwo.setCommision(commisionOne);
userOne.removeGroup(assignmentOne.getGroup().getId());
userTwo.removeGroup(assignmentTwo.getGroup().getId());
userOne.claimGroup(assignmentTwo.getGroup());
userTwo.claimGroup(assignmentOne.getGroup());
this.assignmentService.save(assignmentOne);
this.assignmentService.save(assignmentTwo);
this.userService.save(userOne);
this.userService.save(userTwo);
performedAssignmentExchanges.add(assignmentOne.getId());
performedAssignmentExchanges.add(assignmentTwo.getId());
emailData.addExchange(exchange1.getOwnedAssignment().getCommision().getCommisionOwner(), exchange1);
emailData.addExchange(exchange2.getOwnedAssignment().getCommision().getCommisionOwner(), exchange2);
}
exchangesToDelete.add(exchange1);
exchangesToDelete.add(exchange2);
});
this.emailService.sendExchangesResults(emailData);
this.repo.deleteAll(exchangesToDelete);
}
/**
* @return list of matches found in database
*/
public List<MatchData> getMatches() {
final List<MatchData> matches = this.repo.getMatches().stream().map(m -> {
final Exchange exchangeOne = (Exchange) m[0];
final Exchange exchangeTwo = (Exchange) m[1];
return new MatchData(exchangeOne, exchangeTwo);
}).collect(Collectors.toList());
final Set<MatchData> uniqData = new HashSet<>(matches);
final List<MatchData> matchDataListSorted = uniqData.stream().sorted((m1, m2) -> -1 * m1.compare(m2))
.collect(Collectors.toList());
return matchDataListSorted;
}
}

View File

@ -1,13 +1,24 @@
package com.plannaplan.services;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.function.Function;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Groups;
import com.plannaplan.repositories.GroupRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service of GroupService which can find(optional), get(By Course, Groups
* Ammount, Group By Id, find Not Existing Group), save, delete group.
*/
@Service
public class GroupService {
@Autowired
@ -16,23 +27,149 @@ public class GroupService {
public GroupService() {
}
public Groups find(int time, int capacity, String room) {
/**
* find group with given properties
*
* @param time scheduled time for group as int of minutes passed from 00:00
* @param capacity capacity of group
* @param room class room
* @return optional with Groups instance if found
*/
public Optional<Groups> find(int time, int capacity, String room) {
return this.repo.find(time, room, capacity);
}
/**
* find group with given properties
*
* @param zajCykId proteprty from usos
* @param nrGr group number
* @return optional with Groups instance if found
*/
public Optional<Groups> find(Integer zajCykId, Integer nrGr) {
return this.repo.find(zajCykId, nrGr);
}
/**
* find group with given properties
*
* @param id course id of groups belogns to
* @return list of found groups
*/
public List<Groups> getGroupsByCourse(Long id) {
return this.repo.getByCourse(id);
}
public void save(Groups group) {
this.repo.save(group);
/**
* save group to database
*
* @param group insatnce to be saved
* @return new instance that has id form database
*/
public Groups save(Groups group) {
return this.repo.save(group);
}
/**
* delete from database
*
* @param groups isntance to delete
*/
public void delete(Groups groups) {
this.repo.delete(groups);
}
/**
* get hom manyh groups are in database in general
*
* @return int - groups ammount
*/
public int getGroupsAmmount() {
return (int) this.repo.count();
}
/**
* find group with given properties
*
* @param id group id
* @return optional with group if found
*/
public Optional<Groups> getGroupById(Long id) {
return this.repo.findById(id);
}
/**
* get wich of provided id is not existind groups
*
* @param ids list of ids to check
* @return optional with id that is not group if found. If there is multiple
* will be returned first found
*/
public Optional<Long> findNotExistingGroup(List<Long> ids) {
for (Long oneId : ids) {
if (this.repo.existsById(oneId) == false) {
return Optional.of(oneId);
}
}
return Optional.empty();
}
/**
*
* @param assignments list of assignments you want to get taken places ammount
* @return HashMap of Long to Integer where Long is group id and Integer is how
* many places in gorup is already taken
*/
public HashMap<Long, Integer> getTakenPlacesOfAssignments(List<Assignment> assignments) {
return getTakenPlaces(assignments.stream().map(Assignment::getGroup).collect(Collectors.toList()));
}
/**
*
* @param groups list of groups you want to get taken places ammount
* @return HashMap of Long to Integer where Long is group id and Integer is how
* many places in gorup is already taken
*/
public HashMap<Long, Integer> getTakenPlaces(List<Groups> groups) {
HashMap<Long, Integer> response = new HashMap<>();
if (groups.size() == 0) {
return response;
}
List<Object[]> respoonses = this.repo
.getAssignedAmounts(groups.stream().filter(Objects::nonNull).map(new Function<Groups, Long>() {
@Override
public Long apply(Groups p) {
final Long id = p.getId();
response.put(id, 0);
return id;
}
}).collect(Collectors.toList()));
for (Object[] element : respoonses) {
response.put(((Groups) element[0]).getId(), ((Long) element[1]).intValue());
}
return response;
}
/**
* @return amount of groups with full capacity taken
*/
public Integer getFullgroupsAmmount() {
Integer response = 0;
final Iterator<Groups> groups = this.repo.findAll().iterator();
while (groups.hasNext()) {
final Groups group = groups.next();
if (group.getCapacity() <= group.getRegisteredStudents().size()) {
response += 1;
}
}
return response;
}
}

View File

@ -1,12 +0,0 @@
package com.plannaplan.services;
import com.plannaplan.repositories.HistoryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class HistoryService {
@Autowired
private HistoryRepository repo;
}

View File

@ -1,22 +1,28 @@
package com.plannaplan.services;
import java.util.Optional;
import com.plannaplan.entities.Lecturer;
import com.plannaplan.repositories.LecturerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service of LecturerService which can get(Lecturer, Lecturers Ammount), save, delete lecturers.
*/
@Service
public class LecturerService {
@Autowired
private LecturerRepository repo;
public Lecturer getLecturer(String title, String name, String surname) {
public Optional<Lecturer> getLecturer(String title, String name, String surname) {
return repo.find(title, name, surname);
}
public void save(Lecturer lecturer) {
public Lecturer save(Lecturer lecturer) {
repo.save(lecturer);
return lecturer;
}
public void delete(Lecturer lecturer) {

View File

@ -1,17 +0,0 @@
package com.plannaplan.services;
import com.plannaplan.abstracts.EventWatcher;
import com.plannaplan.repositories.TransferRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class TransferService extends EventWatcher {
@Autowired
private TransferRepository repo;
public TransferService() {
super();
}
}

View File

@ -1,12 +0,0 @@
package com.plannaplan.services;
import com.plannaplan.repositories.UnavailabilityRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class UnavailabilityService {
@Autowired
private UnavailabilityRepository repos;
}

View File

@ -1,45 +1,229 @@
package com.plannaplan.services;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import com.plannaplan.abstracts.EventWatcher;
import com.plannaplan.entities.Commision;
import com.plannaplan.entities.User;
import com.plannaplan.exceptions.UserNotFoundException;
import com.plannaplan.models.UserApiResponse;
import com.plannaplan.repositories.CommisionRepository;
import com.plannaplan.repositories.UserRepository;
import com.plannaplan.types.UserRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service of UserService which can get(By Email), login, save user.
*/
@Service
public class UserService extends EventWatcher {
public class UserService {
@Autowired
private UserRepository repo;
@Autowired
private UsosApiService service;
@Autowired
private CommisionRepository comRepo;
@Autowired
private CommisionService comService;
public UserService() {
super();
}
public String login(String authority) throws UserNotFoundException {
User user = this.repo.getByAuthority(authority.replace("\n", "").trim());
if (user == null) {
throw new UserNotFoundException("Can not find user with given authority");
}
String token = UUID.randomUUID().toString();
user.setToken(token);
this.repo.save(user);
return token;
/**
* checks if user exist and return him or creates new one with student role
* otherwise
*
* @param email user email in usos
* @param usosId user id in usos
* @return user entity instace containing changes saved in database
*/
public User checkForUser(String email, String usosId) {
return this.checkForUser(email, usosId, UserRoles.STUDENT);
}
public void save(User user) {
this.repo.save(user);
/**
* checks if user exist and creates new one if doesn't
*
* @param email user email in usos
* @param usosId user id in usos
* @param roleIfNotExist role to be set in case user is not in database yet
* @return user entity instace containing changes saved in database
*/
public User checkForUser(String email, String usosId, UserRoles roleIfNotExist) {
if (usosId == null) {
Optional<User> user = this.repo.getByEmail(email.replace("\n", "").trim());
if (user.isPresent()) {
return user.get();
} else {
final User newUser = new User(null, null, email.replace("\n", "").trim(), roleIfNotExist);
return this.repo.save(newUser);
}
} else {
Optional<User> user = this.repo.getByUsosId(usosId.replace("\n", "").trim());
if (user.isPresent()) {
return user.get();
} else {
final User newUser = new User(null, null, email.replace("\n", "").trim(), usosId, roleIfNotExist);
return this.repo.save(newUser);
}
}
}
public User getUserByEmail(String email) {
return this.repo.getByAuthority(email.replace("\n", "").trim());
/**
* generates token for user and if user don't have name in database it will
* attemp to obtain these from usos api and saves changes in database
*
* @param authority user we want to login
* @return user with changed values after save in db
* @throws UserNotFoundException throwed if user doesn't exist
*/
public User login(User authority) throws UserNotFoundException {
final String token = UUID.randomUUID().toString();
if ((authority.getName() == null || authority.getSurname() == null) && authority.getUsosId() != null) {
final UserApiResponse resp = this.service.getUserData(authority.getUsosId());
authority.updateWithUsosData(resp);
}
try {
authority.setToken(token);
this.repo.save(authority);
} catch (Exception e) {
throw new UserNotFoundException(e.getMessage());
}
return authority;
}
public User getByToken(String token) {
/**
* sacves user to databse and return instatnce with id
*
* @param user to be saved
* @return instatnce with bd id
*/
public User save(User user) {
return this.repo.save(user);
}
/**
*
* @param email of user to be find
* @return user with given mail
* @throws UserNotFoundException throwed if user doesn't exist
*/
public User getUserByEmail(String email) throws UserNotFoundException {
return this.repo.getByEmail(email.replace("\n", "").trim())
.orElseThrow(() -> new UserNotFoundException("Cannot find user with given authority"));
}
/**
* return user by given authority
*
* @param authority user usosId or email
* @return optional with user if found
*/
public Optional<User> getByAuthority(String authority) {
return this.repo.getByAuthority(authority);
}
public Optional<User> getByToken(String token) {
return this.repo.getByToken(token);
}
/**
* search for user with given query
*
* @param query string that will be matched to users name and surname
* @return list opf results
*/
public List<User> searchForStudents(String query) {
return this.repo.searchForUsers(query, UserRoles.STUDENT);
}
public Optional<User> getById(Long userId) {
return this.repo.findById(userId);
}
public List<User> getAllStudents() {
return this.repo.getAllByRole(UserRoles.STUDENT);
}
public Optional<User> getUserByRefreshToken(String refreshToken) {
return this.repo.getByRefreshToken(refreshToken);
}
public boolean adminExists() {
return this.repo.getAllByRole(UserRoles.ADMIN).size() > 0;
}
public void saveAll(List<User> users) {
this.repo.saveAll(users);
}
/**
* get students sorted by their ranking
*
* @return list of students
*/
public List<User> getStudentsSortedByRanking() {
return this.repo.getAllByRole(UserRoles.STUDENT).stream().sorted((u1, u2) -> {
return -1 * u1.getRanking().compareTo(u2.getRanking());
}).collect(Collectors.toList());
}
/**
* @return ammount of how many users created an assignment
*/
public int getAmmountOfUsersWithAssignedGroups() {
int response = 0;
final Object dbResponse = this.comRepo.getUsersAssigned()[0];
if (dbResponse != null) {
response = ((Long) dbResponse).intValue();
}
return response;
}
/**
* @return ammount of how many users haven't created an assignment yet
*/
public Integer getAmmountOfUsersWithNoAssignedGroups() {
return this.getAllStudents().size() - this.getAmmountOfUsersWithAssignedGroups();
}
/**
* @return ammount of how many users have full schedule accepted
*/
public Integer getAmmountOfUsersWithAcceptedSchedules() {
final List<User> students = this.getAllStudents();
Integer accepted = 0;
final Iterator<User> it = students.iterator();
while (it.hasNext()) {
final User user = it.next();
final Optional<Commision> com = this.comService.getNewestCommision(user);
if (com.isPresent() && user.getStudentRegisteredGrups().size() == com.get().getAssignments().size()) {
accepted += 1;
}
}
return accepted;
}
/**
* @return ammount of how many users have partly or none schedule accepted
*/
public Integer getAmmountOfUsersWithNoAcceptedSchedules() {
return this.getAllStudents().size() - this.getAmmountOfUsersWithAcceptedSchedules();
}
}

View File

@ -0,0 +1,75 @@
package com.plannaplan.services;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.type.TypeReference;
import com.github.scribejava.core.builder.ServiceBuilder;
import com.github.scribejava.core.model.OAuth1AccessToken;
import com.github.scribejava.core.model.OAuthRequest;
import com.github.scribejava.core.model.Response;
import com.github.scribejava.core.model.Verb;
import com.github.scribejava.core.oauth.OAuth10aService;
import com.plannaplan.api.UsosOauth1Service;
import com.plannaplan.models.UserApiResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
* service to call usos api endpoints
*/
@Service
public class UsosApiService {
private static final String NAME_FIELD = "first_name";
private static final String SURNAME_FIELD = "last_name";
@Value("${plannaplan.apiurl}")
private String apiUrl;
@Value("${plannaplan.apikey}")
private String apikey;
@Value("${plannaplan.apisecret}")
private String apisecret;
public UsosApiService() {
}
/**
* /services/users/user
*
* @param usosId user id in usos
* @return UserApiResponse modle contatining desired values
*/
public UserApiResponse getUserData(String usosId) {
final UserApiResponse apiResponse = new UserApiResponse();
try {
final OAuth10aService service = new ServiceBuilder(apikey).apiSecret(apisecret)
.build(UsosOauth1Service.instance());
final OAuthRequest request = new OAuthRequest(Verb.GET, apiUrl + "/services/users/user?user_id=" + usosId);
service.signRequest(new OAuth1AccessToken("", ""), request);
try (Response response = service.execute(request)) {
final String json = response.getBody();
if (!json.equals("null")){
final ObjectMapper mapper = new ObjectMapper();
Map<String, String> map = mapper.readValue(json, new TypeReference<Map<String, String>>() {
});
apiResponse.setName(map.get(NAME_FIELD));
apiResponse.setSurname(map.get(SURNAME_FIELD));
}
}
} catch (IOException | InterruptedException | ExecutionException e) {
e.printStackTrace();
}
return apiResponse;
}
}

View File

@ -0,0 +1,7 @@
/**
* Provides service classes to make operations with entities or comunicate with
* external systems.
*
* @since 1.0
*/
package com.plannaplan.services;

View File

@ -1,10 +0,0 @@
package com.plannaplan.statisticutils;
public class Statistics {
public Statistics() {
}
public void getAll() {
}
}

View File

@ -1,9 +0,0 @@
package com.plannaplan.transferutils;
public class TransferMatcher {
public TransferMatcher() {
}
public void findMatches() {
}
}

View File

@ -1,9 +0,0 @@
package com.plannaplan.transferutils;
public class TransfersExecuter {
public TransfersExecuter() {
}
public void execute() {
}
}

View File

@ -1,5 +0,0 @@
package com.plannaplan.types;
public enum ActionTypes {
ADD, DELETE, REPLACE
}

View File

@ -0,0 +1,5 @@
package com.plannaplan.types;
public enum AppState {
FIRST_TOUR, SECOND_TOUR, NO_TOUR
}

View File

@ -1,5 +0,0 @@
package com.plannaplan.types;
public enum AppStates {
STOPPED, RUNNING, PAUSED
}

View File

@ -1,5 +0,0 @@
package com.plannaplan.types;
public enum EventTypes {
DROPPED_OUT, TOUR_STARTED, TRANSFER_FOUND, TOUR_FINISHED, COURSES_ACCEPTED
}

View File

@ -1,5 +1,39 @@
package com.plannaplan.types;
/**
* GroupType contains types: LECTURE, CLASS, LAB, SEMINAR, CONSERVATORY, PRATICE
*/
public enum GroupType {
LECTURE, CLASS
LECTURE("Wykład"), CLASS("Ćwiczenia"), LAB("Laboratorium"), SEMINAR("Seminarium"), CONSERVATORY("Konwersatorium"),
PRATICE("Praktyka");
public final String type;
private GroupType(String type) {
this.type = type;
}
/**
* @param type as string
* @return Enum converted from provided string
*/
public final static GroupType getType(String type) {
for (GroupType d : values()) {
if (d.type.equals(type)) {
return d;
}
}
return null;
}
/**
* @param type group type to check
* @return general convertion to bring down tours to two generals LECTURE and
* CLASS. To class are included: CLASS, LAB, SEMINAR, CONSERVATORY,
* PRATICE.
*/
public final static GroupType isLectureOrClass(GroupType type) {
return type == GroupType.LECTURE ? GroupType.LECTURE : GroupType.CLASS;
}
}

View File

@ -1,5 +1,9 @@
package com.plannaplan.types;
/**
* UserRoles contains types: STUDENT, DEANERY, ADMIN, TEST_USER
*/
public enum UserRoles {
STUDENT, DEANERY, ADMIN, TEST_USER
STUDENT, DEANERY, ADMIN, TEST_USER, DEVELOPER
}

View File

@ -1,5 +1,9 @@
package com.plannaplan.types;
/**
* WeekDay contains types: MONDAY(0), TUESDAY(1), WEDNESDAY(2), THURSDAY(3), FRIDAY(4), SATURDAY(5), SUNDAY(6).
*/
public enum WeekDay {
MONDAY(0), TUESDAY(1), WEDNESDAY(2), THURSDAY(3), FRIDAY(4), SATURDAY(5), SUNDAY(6);

View File

@ -0,0 +1,6 @@
/**
* Provides enums for different goals.
*
* @since 1.0
*/
package com.plannaplan.types;

View File

@ -4,5 +4,5 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class TestApplication {
public final static String TEST_CONFIG_FILE = "Zajecia.xlsx";
}

View File

@ -10,12 +10,11 @@ import org.junit.Test;
public class FileReaderTest {
@Test
public void shoulReturnNull() {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx");
FileReader r = new FileReader(inputStream);
FileData d = r.read();
assertTrue(d.getRows().next().getCell(0).toString().equals("1.0"));
assertTrue(d.getKeys().size() == 22);
public void shouldNotReturnNull() {
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx");
final FileReader r = new FileReader(inputStream);
final FileData d = r.read();
assertTrue(d.getKeys().size() == 12);
assertTrue(d != null);
}
}

View File

@ -9,8 +9,7 @@ import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import com.plannaplan.Configurator;
import com.plannaplan.models.ConfigData;
import com.plannaplan.TestApplication;
import com.plannaplan.services.CourseService;
import com.plannaplan.services.GroupService;
import com.plannaplan.services.LecturerService;
@ -18,16 +17,13 @@ import com.plannaplan.services.LecturerService;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration
public class FileToDatabaseMigratorTest {
private static String FILE_NAME = "Zajecia.xlsx";
@Autowired
private Configurator restTemplate;
private FileToDatabaseMigrator migrator;
@Autowired
private CourseService courseService;
@ -40,9 +36,10 @@ public class FileToDatabaseMigratorTest {
@Test
public void shouldImportDataFromFileToDatabase() throws Exception {
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
final ConfigData data = new ConfigData(null, null, inputStream);
this.restTemplate.config(data);
final InputStream inputStream = getClass().getClassLoader()
.getResourceAsStream(TestApplication.TEST_CONFIG_FILE);
final FileReader reader = new FileReader(inputStream);
this.migrator.migrate(reader.read());
int courses_ammount = this.courseService.getCoursesAmmount();
int groups_ammount = this.groupService.getGroupsAmmount();
int lecturers_ammount = this.lecturerService.getLecturersAmmount();

View File

@ -0,0 +1,189 @@
package com.plannaplan.entities;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.sql.Date;
import com.plannaplan.models.TourData;
import com.plannaplan.types.AppState;
import org.junit.Test;
public class AppConfigTest {
private static long ONE_DAY = 86400000;
@Test
public void shouldReturnNoTourDueToTooEarly() {
final Date firtstTourStart = new Date(System.currentTimeMillis() + ONE_DAY);
final Date firtstTourEnd = new Date(System.currentTimeMillis() + 2 * ONE_DAY);
final Date secondTourStart = new Date(System.currentTimeMillis() + 3 * ONE_DAY);
final Date secondTourEnd = new Date(System.currentTimeMillis() + 4 * ONE_DAY);
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
assertTrue(config.getCurrentState() == AppState.NO_TOUR);
}
@Test
public void shouldReturnFirstTourDueToStart() throws InterruptedException {
final Date firtstTourStart = new Date(System.currentTimeMillis());
final Date firtstTourEnd = new Date(System.currentTimeMillis() + 2 * ONE_DAY);
final Date secondTourStart = new Date(System.currentTimeMillis() + 3 * ONE_DAY);
final Date secondTourEnd = new Date(System.currentTimeMillis() + 4 * ONE_DAY);
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
Thread.sleep(1000);
assertTrue(config.getCurrentState() == AppState.FIRST_TOUR);
}
@Test
public void shouldReturnFirstTourDueToInBetween() {
final Date firtstTourStart = new Date(System.currentTimeMillis() - ONE_DAY);
final Date firtstTourEnd = new Date(System.currentTimeMillis() + 2 * ONE_DAY);
final Date secondTourStart = new Date(System.currentTimeMillis() + 3 * ONE_DAY);
final Date secondTourEnd = new Date(System.currentTimeMillis() + 4 * ONE_DAY);
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
assertTrue(config.getCurrentState() == AppState.FIRST_TOUR);
}
@Test
public void shouldReturnNoTourInLastDay() throws InterruptedException {
final Date firtstTourStart = new Date(System.currentTimeMillis() - ONE_DAY);
final Date firtstTourEnd = new Date(System.currentTimeMillis());
final Date secondTourStart = new Date(System.currentTimeMillis() + 3 * ONE_DAY);
final Date secondTourEnd = new Date(System.currentTimeMillis() + 4 * ONE_DAY);
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
Thread.sleep(1000);
assertTrue(config.getCurrentState() == AppState.NO_TOUR);
}
@Test
public void shouldReturnNoTourInBetween() {
final Date firtstTourStart = new Date(System.currentTimeMillis() - 2 * ONE_DAY);
final Date firtstTourEnd = new Date(System.currentTimeMillis() - ONE_DAY);
final Date secondTourStart = new Date(System.currentTimeMillis() + 3 * ONE_DAY);
final Date secondTourEnd = new Date(System.currentTimeMillis() + 4 * ONE_DAY);
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
assertTrue(config.getCurrentState() == AppState.NO_TOUR);
}
@Test
public void shouldReturnSecondTourInStart() throws InterruptedException {
final Date firtstTourStart = new Date(System.currentTimeMillis() - 2 * ONE_DAY);
final Date firtstTourEnd = new Date(System.currentTimeMillis() - ONE_DAY);
final Date secondTourStart = new Date(System.currentTimeMillis());
final Date secondTourEnd = new Date(System.currentTimeMillis() + 4 * ONE_DAY);
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
Thread.sleep(1000);
assertTrue(config.getCurrentState() == AppState.SECOND_TOUR);
}
@Test
public void shouldReturnSecondTourInBetween() {
final Date firtstTourStart = new Date(System.currentTimeMillis() - 3 * ONE_DAY);
final Date firtstTourEnd = new Date(System.currentTimeMillis() - 2 * ONE_DAY);
final Date secondTourStart = new Date(System.currentTimeMillis() - ONE_DAY);
final Date secondTourEnd = new Date(System.currentTimeMillis() + 4 * ONE_DAY);
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
assertTrue(config.getCurrentState() == AppState.SECOND_TOUR);
}
@Test
public void shouldReturnNoTourDueToEndSecond() throws InterruptedException {
final Date firtstTourStart = new Date(System.currentTimeMillis() - 3 * ONE_DAY);
final Date firtstTourEnd = new Date(System.currentTimeMillis() - 2 * ONE_DAY);
final Date secondTourStart = new Date(System.currentTimeMillis() - ONE_DAY);
final Date secondTourEnd = new Date(System.currentTimeMillis());
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
Thread.sleep(1000);
assertTrue(config.getCurrentState() == AppState.NO_TOUR);
}
@Test
public void shouldReturnNoTourAfterSecondEnd() {
final Date firtstTourStart = new Date(System.currentTimeMillis() - 4 * ONE_DAY);
final Date firtstTourEnd = new Date(System.currentTimeMillis() - 3 * ONE_DAY);
final Date secondTourStart = new Date(System.currentTimeMillis() - 2 * ONE_DAY);
final Date secondTourEnd = new Date(System.currentTimeMillis() - ONE_DAY);
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
assertTrue(config.getCurrentState() == AppState.NO_TOUR);
}
@Test
public void shouldReturnSecondTourWhereThereIsABrake() throws InterruptedException {
final Date firtstTourStart = new Date(System.currentTimeMillis() - 4 * ONE_DAY);
final Date firtstTourEnd = new Date(System.currentTimeMillis());
final Date secondTourStart = new Date(System.currentTimeMillis());
final Date secondTourEnd = new Date(System.currentTimeMillis() + ONE_DAY);
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
Thread.sleep(1000);
assertTrue(config.getCurrentState() == AppState.SECOND_TOUR);
}
@Test
public void shouldReturnFirstStartDatesCorns() {
final Date firtstTourStart = Date.valueOf("2020-11-12");
final Date firtstTourEnd = Date.valueOf("2020-11-13");
final Date secondTourStart = Date.valueOf("2020-11-14");
final Date secondTourEnd = Date.valueOf("2020-11-15");
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
assertTrue(config.getFirstTourStartCron().getExpression().equals("0 0 0 12 11 ?"));
}
@Test
public void shouldReturnSecondStartDatesCorns() {
final Date firtstTourStart = Date.valueOf("2020-11-12");
final Date firtstTourEnd = Date.valueOf("2020-11-13");
final Date secondTourStart = Date.valueOf("2020-11-14");
final Date secondTourEnd = Date.valueOf("2020-11-15");
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
assertTrue(config.getSecondTourStartCron().getExpression().equals("0 0 0 14 11 ?"));
}
@Test
public void shouldReturnFirstEndDatesCorns() {
final Date firtstTourStart = Date.valueOf("2020-11-12");
final Date firtstTourEnd = Date.valueOf("2020-11-13");
final Date secondTourStart = Date.valueOf("2020-11-14");
final Date secondTourEnd = Date.valueOf("2020-11-15");
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
assertTrue(config.getFirstTourEndCron().getExpression().equals("0 0 0 13 11 ?"));
}
@Test
public void shouldReturnSecondEndDatesCorns() {
final Date firtstTourStart = Date.valueOf("2020-11-12");
final Date firtstTourEnd = Date.valueOf("2020-11-13");
final Date secondTourStart = Date.valueOf("2020-11-14");
final Date secondTourEnd = Date.valueOf("2020-11-15");
final AppConfig config = new AppConfig(new TourData(firtstTourStart, firtstTourEnd),
new TourData(secondTourStart, secondTourEnd));
assertTrue(config.getSecondTourEndCron().getExpression().equals("0 0 0 15 11 ?"));
}
}

View File

@ -0,0 +1,71 @@
package com.plannaplan.entities;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.lang.reflect.Field;
import java.sql.Timestamp;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
public class UserTest {
@Test
public void shouldResturnTokenIsNotExpired() {
final User user = new User();
user.setToken("testowy-bezpieczny-token");
assertTrue(user.isCredentialsNonExpired(), "Credential shouldnt expire yet");
long minutes = this.getMinutesDiff(user.getTokenUsageDate());
assertTrue(minutes == 0, "Should update last token usage");
}
@Test
public void shouldResturnTokenIsNotExpiredWithLessThan15minutes()
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
final User user = new User();
user.setToken("testowy-bezpieczny-token");
this.setLastTokenUsage(user, new Timestamp(System.currentTimeMillis() - (6 * 60 * 1000)));
assertTrue(user.isCredentialsNonExpired(), "Credential shouldnt expire yet");
final long minutes = this.getMinutesDiff(user.getTokenUsageDate());
assertTrue(minutes == 0, "Should update last token usage");
}
@Test
public void shouldResturnTokenIsExpired()
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
final User user = new User();
user.setToken("testowy-bezpieczny-token");
this.setLastTokenUsage(user, new Timestamp(System.currentTimeMillis() - (25 * 60 * 1000)));
assertFalse(user.isCredentialsNonExpired(), "Credential should expire");
final long diffInMilliseconds = Math
.abs(user.getTokenUsageDate().getTime() - new Timestamp(System.currentTimeMillis()).getTime());
final long minutes = TimeUnit.MILLISECONDS.toMinutes(diffInMilliseconds);
assertTrue(minutes > 0, "Shouldn't update last token usage");
}
private long getMinutesDiff(Timestamp timestamp) {
final long diffInMilliseconds = Math
.abs(timestamp.getTime() - new Timestamp(System.currentTimeMillis()).getTime());
final long minutes = TimeUnit.MILLISECONDS.toMinutes(diffInMilliseconds);
return minutes;
}
private void setLastTokenUsage(User user, Timestamp timestampToSet)
throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
Field reader = User.class.getDeclaredField("tokenUsageDate");
reader.setAccessible(true);
reader.set(user, timestampToSet);
}
}

View File

@ -0,0 +1,14 @@
package com.plannaplan.models;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Test;
public class ExportDataTest {
@Test
public void shouldConvertDataToCSVRecord() {
final ExportData data = new ExportData("4234", "242352", "12");
assertTrue(data.convertToCSVRecord().equals("4234,242352,12"));
}
}

View File

@ -0,0 +1,69 @@
package com.plannaplan.repositories;
import static org.junit.Assert.assertTrue;
import java.util.List;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Commision;
import com.plannaplan.entities.Exchange;
import com.plannaplan.entities.Groups;
import com.plannaplan.entities.User;
import com.plannaplan.services.AssignmentService;
import com.plannaplan.services.GroupService;
import com.plannaplan.services.UserService;
import com.plannaplan.types.UserRoles;
import com.plannaplan.types.WeekDay;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.MethodMode;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration
public class ExchangeRepositoryTest{
@Autowired
private ExchangeRepository exchangeRepository;
@Autowired
private AssignmentService assignmentService;
@Autowired
private GroupService groupService;
@Autowired
private UserService userService;
@Autowired
private CommisionRepository commisionRepository;
@Test
@DirtiesContext(methodMode = MethodMode.BEFORE_METHOD)
public void shouldReturnMatches() {
final User user1 = this.userService.save(
new User(null, null, "shouldReturnMatches@ExchangeRepository.test", "123454", UserRoles.STUDENT, 451));
final Groups group1 = this.groupService.save(new Groups(123, "A2-3", null, 430, WeekDay.MONDAY, null));
final Commision commision1 = this.commisionRepository.save(new Commision(user1));
final User user2 = this.userService.save(
new User(null, null, "shouldReturnMatches@ExchangeRepository.test", "123454", UserRoles.STUDENT, 451));
final Groups group2 = this.groupService.save(new Groups(123, "A2-3", null, 430, WeekDay.MONDAY, null));
final Commision commision2 = this.commisionRepository.save(new Commision(user2));
final Assignment assignmentUser1 = this.assignmentService.save(new Assignment(group1, commision1));
final Assignment assignmentUser2 = this.assignmentService.save(new Assignment(group2, commision2));
this.assignmentService.callAcceptAlgorythm();
this.exchangeRepository.save(new Exchange(assignmentUser1, group2));
this.exchangeRepository.save(new Exchange(assignmentUser2, group1));
final List<Object[]> exchangeRepoMatches = this.exchangeRepository.getMatches();
assertTrue(exchangeRepoMatches.size() == 2);
}
}

View File

@ -0,0 +1,106 @@
package com.plannaplan.repositories;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertTrue;
import java.util.List;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Commision;
import com.plannaplan.entities.Groups;
import com.plannaplan.entities.User;
import com.plannaplan.services.AssignmentService;
import com.plannaplan.services.CommisionService;
import com.plannaplan.services.GroupService;
import com.plannaplan.services.UserService;
import com.plannaplan.types.UserRoles;
import com.plannaplan.types.WeekDay;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration
public class GroupRepositoryTest {
@Autowired
private GroupRepository repository;
@Autowired
private AssignmentService assignmentService;
@Autowired
private GroupService groupService;
@Autowired
private UserService userService;
@Autowired
private CommisionService commisionService;
@Test
public void shouldReturnGroupAssignmentTimes() throws InterruptedException {
final Groups testGroup = groupService.save(new Groups(43, "A-41", null, 235, WeekDay.MONDAY, null));
int startGroupAmmount = this.repository.getAssignedAmount(testGroup.getId()).orElse(Integer.valueOf(0))
.intValue();
final User user = this.userService.save(new User("Luis", "Vita",
"shouldReturnGroupAssignmentTimes@grouprepository.test", UserRoles.STUDENT));
final Commision commision = this.commisionService.save(new Commision(user));
this.assignmentService.save(new Assignment(testGroup, commision));
Thread.sleep(1000);
int afterAssignedGroupAmmount = this.repository.getAssignedAmount(testGroup.getId())
.orElse(Integer.valueOf(0)).intValue();
assertTrue(afterAssignedGroupAmmount > startGroupAmmount);
final Commision recommision = this.commisionService.save(new Commision(user));
this.assignmentService.save(new Assignment(testGroup, recommision));
Thread.sleep(1000);
int afterreAssignedGroupAmmount = this.repository.getAssignedAmount(testGroup.getId())
.orElse(Integer.valueOf(0)).intValue();
assertTrue(afterAssignedGroupAmmount == afterreAssignedGroupAmmount);
this.commisionService.save(new Commision(user));
Thread.sleep(1000);
int afterdeAssignedGroupAmmount = this.repository.getAssignedAmount(testGroup.getId())
.orElse(Integer.valueOf(0)).intValue();
assertTrue(afterdeAssignedGroupAmmount < afterreAssignedGroupAmmount);
}
@Test
public void shouldReturnGroupAssignmentTimesList() throws InterruptedException {
final Groups testGroup = groupService.save(new Groups(43, "A-41", null, 645, WeekDay.MONDAY, null));
final Groups testGroup2 = groupService.save(new Groups(433, "A-41", null, 235, WeekDay.TUESDAY, null));
final Groups testGroup3 = groupService.save(new Groups(23, "A-41", null, 340, WeekDay.MONDAY, null));
final User user = this.userService.save(new User("Dare", "Oc",
"shouldReturnGroupAssignmentTimesList@grouprepository.test", UserRoles.STUDENT));
final Commision commision = this.commisionService.save(new Commision(user));
this.assignmentService.save(new Assignment(testGroup, commision));
this.assignmentService.save(new Assignment(testGroup2, commision));
this.assignmentService.save(new Assignment(testGroup3, commision));
Thread.sleep(1000);
List<Object[]> response = this.repository
.getAssignedAmounts(List.of(testGroup.getId(), testGroup2.getId(), testGroup3.getId()));
assertTrue("Response should have size 3", response.size() == 3);
assertTrue("Instance of firest element should be Group", response.get(0)[0] instanceof Groups);
assertTrue("Instance of firest element should be Long", response.get(0)[1] instanceof Long);
}
}

Some files were not shown because too many files have changed in this diff Show More