134 Commits

Author SHA1 Message Date
pepa c72ab99dc1 Povýšení verze. 2018-10-07 20:53:42 +02:00
pepa 4dbe7c47f8 Přidány sestavy pro přehledy o vyúčtovaných a nevyúčtovaných cestovních příkazech. 2018-10-07 20:50:49 +02:00
pepa 1aeff7f587 Do gridů v cestovních příkazech byly přidány sloupce "Počátek sl. cesty", "Spolucestující" a "Datum schválení". 2018-09-15 20:52:09 +02:00
pepa 70a2e01fae Opravena chyba výpočtu stravného u celodenního cesťáku.
closes #279
2017-03-04 21:28:33 +01:00
franta fcb8db25fa Upraven styl vybraného záznamu nebo HOVER záznamu.
closes #273
2016-11-29 12:18:39 +01:00
franta 740847e865 Implementováno filtrování datového typu BigDecimal do gridů požadavků.
closes #272
2016-11-28 15:16:00 +01:00
pepa 093d359df7 Po refreshi gridu se obnovi puvodni trideni a filtr nastaveny pred editaci/schvalenim zaznamu.
closes #271
2016-06-28 10:09:57 +02:00
pepa ea2708f303 Opraveno rušení schválení vyúčtování SC z agendy požadavků
closes #270
2016-06-27 21:14:31 +02:00
pepa 9b2e2b3641 Oprava predesloho commitu.
refs #269
2016-06-27 16:36:25 +02:00
pepa a8dc7f1306 Opravena chyba zacyklani requestu pri trideni gridu s vybranym zaznamem.
Nasazani cache entit.
closes #269
2016-06-27 16:32:26 +02:00
pepa 7d4d693b2e Opraveno mazani zaznamu s neexistujicim pripojenym dokumentem. 2016-05-06 10:39:09 +02:00
pepa e4013f44ab Úprava sestavy vyúčtování služební cesty.
closes #268
2016-03-06 22:05:45 +01:00
pepa b95cac9ef1 U gridů ve fakturaci bylo nastaveno stránkování.
Oprava buildu.
closes #267
2016-02-29 15:36:10 +01:00
pepa 5079d6d55a Merge branch 'master' of https://git.bukova.info/repos/git/isspst 2016-02-29 15:20:31 +01:00
pepa a93c515bc0 Přidány nové tiskové sestavy "Protokol předběžné kontroly" do agend Fakturace požadavků a Požadavky na služební cesty. 2016-02-29 15:20:03 +01:00
pepa 1475babaa1 Vylepšeno logování chyb při generování sestav.
Sestavám se nastavuje locales pro formátování čísel z nastavení prohlížeče.
2016-02-29 15:10:20 +01:00
pepa b0fb32825b Opravena chyba při vytváření vyúčtování služební cesty a požadavku na schválení cesťáku- na záznamech se nenastavovalo období.
Opraveno filtrování nabízených středisek.
2016-02-29 15:08:05 +01:00
franta 9d59b34900 Merge remote-tracking branch 'origin/master' 2016-02-29 13:13:37 +01:00
franta 47e90b4287 Do podepsaných dokumentů implementována záložka pro archivaci souborů do ZIP.
closes #265
2016-02-29 13:13:00 +01:00
pepa b276746bac Změněn popisek pole "Zpráva o výsledku pracovní cesty"
closes #260
2016-02-22 21:24:45 +01:00
pepa f938403cea Byl omezen výběr středisek u nového požadavku, aby bylo zamezeno schvalování sobě samému.
closes #266
2016-02-22 15:18:34 +01:00
pepa b321b3e25f Opraven start na prázdné databázi. 2016-02-13 20:41:57 +01:00
pepa cbb81657c8 Přidaná agenda pro nastavení limitů komisí. Změněn způsob hlídání limitů při zadávání nového požadavku- limit se bere z nové agendy.
closes #263
closes #264
2016-02-06 23:43:31 +01:00
pepa cd6b8c01dc Merge branch 'master' of https://git.bukova.info/repos/git/isspst 2016-01-22 14:25:29 +01:00
pepa 012ad06358 Implementovano prepinani ciselnych rad podle obdobi.
closes #262
2016-01-22 14:24:58 +01:00
franta 88e9711154 Implementován obecný export prvků Listbox do excelu.
closes #261
2016-01-14 12:50:07 +01:00
pepa d2aa1cbd9a Opraveno vyhodnocení sestavy pro podpis, pokud je v agendě více sestav s podpisem. 2016-01-06 11:55:28 +01:00
pepa 52cf63414b Oprevena sestava Žádost o SC- tisk z agend Cestovní příkazy a Požadavky na SC odkazuje na stejnou sestavu.
Byla přidána možnost použít property hlavní entity jako zdroje dat pro sestavu- rozšířen constructor třídy Report o parametr property.
2015-11-27 15:11:23 +01:00
pepa f904e89946 Opraveno filtrování podle čísla požadavku v agendě Cestovní příkazy. 2015-11-27 14:22:05 +01:00
pepa 5cae516cb6 Na sestavě Vyúčtování SC bylo odstraněno pole pro podpis "S provedením pracovní cesty souhlasí".
closes #259
2015-11-27 13:57:25 +01:00
pepa 6ac6d783fb - Opravena kontrola práv při ružení schválení vyúčtování SC.
- Opraven refresh gridů při mazání záznamů.
- Zrušeno výchozí třídění v agendě Cestovní příkazy.
- Opraven pom.xml.
2015-10-19 10:24:53 +02:00
pepa 67ff54d3f1 Merge branch 'master' of https://git.bukova.info/repos/git/isspst 2015-10-18 16:28:30 +02:00
pepa 275e120021 Opraveno ukládání záznamu v agendě Fakturace požadavků. Příznak Fakturováno se již ukládá správně. 2015-10-16 10:03:34 +02:00
franta d20a72b336 Kvůli přechodu na IntelliJ IDEA upravena konfigurace Maven.
Fakturace rozděleny na fakturace materiálu a služeb.

closes #249
2015-10-14 10:06:41 +02:00
pepa e24684bbd0 Přesunut podpis příkazce operace na vyúčtování služební cesty.
closes #258
2015-10-12 15:26:25 +02:00
pepa 21bf006c19 Aktualizace podepisovací komponenty. 2015-10-11 22:08:30 +02:00
pepa 970928bb4e Merge branch 'master' of https://git.bukova.info/repos/git/isspst 2015-10-11 21:53:33 +02:00
pepa 369184940b Do agendy Cestovní příkazy byly přidány záložky "Má střediska", "Mé komise" a "Vše", kde se zobrazují vyúčtování služebních ke schválení. V záložkách lze vyúčtování označit jako proplacené. Do e-mailu se generuje odkaz do těchto záložek.
closes #253
closes #250
2015-10-11 21:52:50 +02:00
franta cc374a3bf1 Podepsané dokumenty se nyní zobrazují ve dvou záložkách - Aktuální
dokumenty a Archiv.
V Archivu se zobrazují dokumenty starší než rok.

closes #225
2015-10-05 13:09:20 +02:00
franta 66e0c427ac Popisek změněn na "Zajistím sám", případně ve sloupci na "Zaj. sám"
closes #247
2015-10-05 08:57:26 +02:00
franta 095089d020 U požadavků na nákup je nyní pole Popis povinné.
closes #248
2015-10-05 08:32:42 +02:00
pepa 84154ccbff Neaktivní uživatelé se nenabízí v seznamech pro výběr uživatele (spolucestující...). V agendě Uživatelé a Střediska/komise jsou barevně odlišeni.
closes #239
2015-10-02 14:58:51 +02:00
pepa 1230959854 Opraveno duplikování vyúčtování SC, když se na požadavku provede úprava a znovu se schválí.
closes #255
2015-10-02 13:27:24 +02:00
pepa 96154a6b98 Opraveno mazání záznamů z požadavků
closes #257
2015-10-02 09:41:16 +02:00
pepa 14242fa41a Vyúčtování služebních cest u spolucestujících lze nyní zrušit u každého zvlášť. Lze tak provést dodatečnou opravu vyúčtování.
closes #251
2015-10-02 09:32:09 +02:00
pepa 67a99d8d78 Na sestavách se pro viditelný dig. podpis vytváří klasické read only formulářové pole, které se podpisem nahradí za obrázek podpisu.
Změna podepisovací komponenty- na windows se spouští stejná jak na linuxu, macos...
closes #244
2015-10-01 16:00:49 +02:00
pepa 768d3ee874 Opraveno duplicitní vkládání záznamů do agendy Fakturace požadavků, v případě, že se požadavek upraví a znovu schválí.
closes #252
2015-09-08 22:22:23 +02:00
pepa cd6a6cf5a6 Přidaná sestava "Protokol o kontrole" - digitální podpis při schvalování nákupů. 2015-09-07 22:08:21 +02:00
pepa d1ccaf530d Při napojování uživatele z AD se login převede na malá písmena. Opravena chyba při mazání uživatele.
closes #237
2015-08-18 22:21:05 +02:00
pepa 10439b5001 Merge branch 'master' of https://git.bukova.info/repos/git/isspst 2015-08-08 22:53:15 +02:00
pepa b33f9f2e8a Pokud se upraví požadavek, u kterého je podepsaný dokument, tak se dokument smaže a požadavek se nastaví jako nový.
closes #227
2015-08-08 22:52:10 +02:00
franta 07d0949bea Merge branch 'master' of https://git.bukova.info/repos/git/isspst 2015-07-14 20:21:10 +02:00
franta 2819cc125c Implementován validátor pro Globální nastavení.
closes #236
2015-07-14 20:17:32 +02:00
pepa c0922921c5 V agendě Procesy schválení lze u jednotlivých schvalovacích rolí nastavit, jestli bude vyžadován při schválení elektronický podpis.
closes #242
2015-07-11 01:05:41 +02:00
pepa b70041bfff Změněn způsob ukládání PDF dokumentu. Data se předávájí ve ViewModelu, tak nemůže dojít k tomu, že by se schválením jiného záznamu v druhém okně prohlížeče uložilo jiné PDF.
refs #243
2015-07-10 15:29:44 +02:00
pepa b5ffa07644 Aktualizace podepisovací aplikace- opraveno náhodné zatuhnutí po startu.
refs #224
2015-07-09 08:22:32 +02:00
pepa cccd8177fa Implementace uložiště podepsaných dokumentů. Při prvním podpisu se uloží podepsané PDF a vytvoří se záznam v agendě podepsaných dokumentů.
closes #243
2015-07-08 12:55:41 +02:00
pepa 6db416dd04 Vyřešeno generování PDF pro podpis na základě entity, která se schvaluje.
closes #240
2015-07-03 13:36:23 +02:00
pepa 05faa87071 Digitální podpis se zobrazí v PDF viditelně. Server předá podepisovací aplikaci ID fieldu, kde se podpis zobrazí. ID je zadáno v reportu jaku parametr pole signature.
refs #224
2015-07-02 14:12:26 +02:00
pepa 11e3a48b28 Ve windows se spustí podepisovací aplikace, která si bere certifikáty ze systémového uložiště.
refs #224
2015-06-25 13:08:06 +02:00
pepa d7999e78ca Merge remote-tracking branch 'origin/master' 2015-06-24 12:54:57 +02:00
pepa d6cff454fd Základní implementace podepisování PDF dokumentů. Podpis implementován pouze pro sestavu schválení služební cesty (natvrdo v kódu). Spouští se univerzální podepisovací aplikace, která čte certifikát ze souboru.
closes #224
2015-06-24 12:54:31 +02:00
franta 1d30f0d0c7 Merge branch 'master' of https://git.bukova.info/repos/git/isspst 2015-06-24 10:16:36 +02:00
franta 9fb1ef7601 Přidána základní funkčnost zobrazování dat agendy.
refs #225
2015-06-24 10:14:21 +02:00
pepa 312b62af7b Merge branch 'Verze_2.0' 2015-06-21 00:36:08 +02:00
pepa b0fedfa3f3 Opraveny datumy na vyúčtování služební cesty.
closes #232
2015-06-21 00:31:33 +02:00
pepa dc0607c072 Vytvořením požadavku na služební cestu se odešle e-mail spolucestujícím.
closes #235
2015-06-20 23:49:49 +02:00
pepa 162cea6001 Merge branch 'Verze_2.0' 2015-06-15 21:18:14 +02:00
pepa 4d74b0a3fe Opraven binding formuláře vyúčtování služební cesty.
closes #231
2015-06-15 21:17:17 +02:00
pepa 3b3e4b38e6 Vyúčtování služební cesty nelze odeslat ke schválení, pokud nejsou vyplněné časy odjezdu a příjezdu.
closes #230
2015-06-14 20:45:36 +02:00
pepa 1164e11107 Merge branch 'master' of https://git.bukova.info/repos/git/isspst 2015-06-13 00:07:05 +02:00
pepa c2ca2e45ec Opraveno generovani vyuctovani sluzebni cesty spolucestujicich, pokud je pozadovana zaloha- zaloha se nyni neprenese.
closes #229
Po schvaleni pozadavku na sluzebni cestu se spolucestujicimi se posle mail o schvaleni i spolucestujicim.
closes #228
2015-06-13 00:00:00 +02:00
franta c9a56887dc Připraveny podklady pro novou agendu "Podepsané dokumenty"
Vzhled agendy (grid/strom/...) zatím není znám.

closes #222
2015-06-04 14:19:54 +02:00
franta aaa89a2653 Workaround pro zápis číselné řady.
Vznikaly duplicity nad unikátním indexem.
Nyní se číslo nezapisuje a načítá se z vazby na požadavku na cesťák.

closes #221
2015-05-22 12:10:00 +02:00
franta fbc7a02161 Zpráva z pracovní cesty prodloužena na 8kB
closes #220
2015-05-20 07:51:47 +02:00
pepa e5a8e0f0d9 Po otevření dialogu pro zobrazení vyúčtování SC se přepne na první záložku, kterou může schválit aktuálně přihlášený uživatel.
closes #217
2015-05-17 21:52:46 +02:00
pepa 0f169f8be9 Na formuláři vyúčtování služební cesty se automaticky předvyplní datum v poli "Zpráva z pracovní cesty podána dne", pokud je pole prázdné.
closes #216
2015-05-17 21:06:26 +02:00
pepa b6d0546b48 Na formulář vyúčtování služební cesty bylo přidáno tlačítko "Uložit a odeslat ke schválení"
closes #218
2015-05-17 20:52:38 +02:00
pepa a6799064f7 Opraveno generování e-mailu po odeslání vyúčtování služební cesty ke schválení. Text a URL se nyní vygeneruje správně.
closes #219
2015-05-13 13:36:51 +02:00
pepa 933f5e784b V dialogu pro zobrazení vyúčtování služební cesty se po otevření přepne záložka na první neschválené vyúčtování.
refs #212
2015-05-06 15:22:07 +02:00
franta 04dc8a5587 Metodou pokus-omyl je správně width="100%" a vflex="1"
refs #215
2015-04-28 09:01:40 +02:00
franta b63a2c3944 Upraveno zobrazování seznamu souborů...
closes #214
2015-04-28 08:17:19 +02:00
franta 67629cf312 IFrame v náhledu na sestavy upraven z width a height na vflex a hflex.
closes #215
2015-04-28 08:15:16 +02:00
pepa cdd2f81cad Oprava sestavy.
refs #213
2015-04-27 14:46:39 +02:00
pepa c292c3bcde Na sestavě "žádost o služební cestu" byl opraven seznam spolucestujících- nyní se generuje vedle sebe a bylo přidáno pole pro cizí osobu.
closes #213
2015-04-27 12:02:03 +02:00
pepa 9d202192ee Změněn způsob přenosu vyúčtování ke spolucestujícím: výúčtování se přenese pouze v případě, když ho ještě spolucestující needitoval. Do zeditovaného vyúčtování se vyúčtování žadatele už nepřenáší.
Vyúčtování spolucestujících se schvalují každé zvlášť.
refs #212
2015-04-24 14:00:36 +02:00
pepa 93a463db69 Upraveno třídění výsledku fulltextového vyhledávání- niní se třídí podle relevancve výsledku.
refs #211
2015-04-13 09:56:04 +02:00
pepa 3a5da06c48 Merge branch 'master' of https://git.bukova.info/repos/git/isspst 2015-04-12 18:54:09 +02:00
pepa 76969a2baf - Přidán fulltext index na číslo požadavku.
- Opravena velikost písmen v SQL dotazu pro úklid tabulek s přiloženými soubory.
- Informativní číslo verze zvýšeno na 2.0
2015-04-12 18:53:43 +02:00
franta 4e6af2ceed Upraveny data a razítka na sestavách služební cesty.
closes #205
2015-04-09 12:14:37 +02:00
franta ef431867e1 V globálním nastavení umožněn upload loga školy.
Upraveny tiskových sestav vloženo logo a název organizace.

closes #199
2015-04-08 11:35:41 +02:00
franta 25c8405f03 Ag. Služební cesty / Cestovní příkazy
• přidáno povinné pole Zpráva z pracovní cesty
• u existujících záznamů přidán text "Zpráva z pracovní cesty"
• upraveno rozdělení formuláře

closes #203
2015-03-23 07:41:23 +01:00
franta ac90b0a2e3 Formulář ag. Služební cesty / Aktuální požadavky
• přidáno textové pole "Cizí osoby"
• upraven popisek formuláře
• upraven vzhled a zarovnání prvků
• přidána kontrola ukazatele při promazávání souborů na disku i v
databázi
• sjednocena maska pro formátování data v <datebox>
closes #197
2015-03-19 10:12:18 +01:00
pepa 9c5679af2c Implementováno schvalování vyúčtování služebních cest.
closes #202
2015-03-17 10:20:59 +01:00
franta ceac59c8d3 Agenda Fakturace požadavků
• grid rozdělen na 2 záložky [Nevyřízené] a [Archive]
• na formuláři přidán checkbox [Vyřízeno]

closes #207
2015-03-09 09:37:58 +01:00
pepa 5d9e6226d3 Merge branch 'Verze_1.0' 2015-03-08 20:16:34 +01:00
pepa b470559cb7 Opraveno přegenerování vyúčtování služební cesty spolucestujících.
refs #195
2015-03-08 20:16:05 +01:00
pepa 9b8bfe2228 Na formulář požadavku na služební byl přidán checkbox pro vygenerování vyúčtování služební cesty i pro spolucestující. Spolucestující nemůžou vyúčtování měnit.
closes #212
2015-03-08 19:33:15 +01:00
pepa 42deec695a Oprava merge. 2015-03-08 10:39:17 +01:00
pepa e01e32f10c Merge branch 'Verze_1.0'
Conflicts:
	src/main/java/info/bukova/isspst/services/requirement/TripRequirementService.java
	src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java
	src/main/java/info/bukova/isspst/ui/requirement/TripRequirementForm.java
	src/main/webapp/WEB-INF/locales/zk-label.properties
2015-03-07 19:00:00 +01:00
pepa f13bc6e5c4 Změnou schváleného požadavku na služební cestu se přegeneruje vyúčtování.
closes #195
2015-03-07 18:53:06 +01:00
pepa 021d73bf48 Merge branch 'master' of https://git.bukova.info/repos/git/isspst 2015-03-06 14:51:01 +01:00
pepa 340abb5269 Vypnuto debug-js v zk.xml. 2015-03-06 14:48:42 +01:00
franta 724f6b3559 Implementováno třístavové vyhledávání boolean hodnot.
Agendu Schválené položky požadavků lze nyní filtrovat podle materiálu a
služeb.

#closes 206
2015-03-06 10:27:37 +01:00
pepa ecd3cf426b Umožněn upload souborů k požadavkům na služební cesty a k vyúčtování služební cesty.
closes #131
2015-03-03 14:46:21 +01:00
pepa c6ebf8959b Umožněna změna data schválení požadavku.
closes #209
2015-03-01 19:28:49 +01:00
pepa 48d2c75d7b Merge remote-tracking branch 'origin/master'
Conflicts:
	src/main/webapp/app/mainMenu.zul
2015-02-23 22:28:14 +01:00
pepa 1d2810f78d Obsah přiložených dokumentů ve formátech ODF - OpenOffice, openxml - MS Office a PDF se extrahuje do čistého textu a indexuje pro fulltextové vyhledávání.
closes #211
2015-02-23 22:21:25 +01:00
franta c4f5671327 Přepracováno vykreslování dialogu Faturace požadavků.
Vyhledávací edit dostane focus po otevření okna.
Opraveno Main menu.


closes #210
2015-02-23 21:06:41 +01:00
pepa 860c7227cd Opraven merge mainMenu.zul 2015-02-17 21:19:33 +01:00
pepa f94afbc3ed Merge branch 'master' of https://git.bukova.info/repos/git/isspst 2015-02-15 19:15:32 +01:00
pepa 1df90a41c4 Do agendy požadavků na služební cesty byla přidána možnost prohlížení vyúčtování služební cesty.
closes #200
2015-02-15 19:14:03 +01:00
franta 93e1ef1fd3 Merge branch 'master' of https://git.bukova.info/repos/git/isspst
Conflicts:
	src/main/webapp/app/mainMenu.zul
2015-02-09 13:35:35 +01:00
franta 277ea0f993 Merge branch 'Verze_1.0'
Conflicts:
	src/main/webapp/WEB-INF/locales/zk-label.properties
	src/main/webapp/app/mainMenu.zul
2015-02-09 13:31:48 +01:00
pepa 678c140a94 Třídy pro práci se soubory a přílohami záznamů.
refs #131
2015-02-02 22:18:38 +01:00
pepa 566b408ddd Reindaxece fulltextu se spouští asynchronně- rychlejší start aplikace 2015-01-29 13:56:55 +01:00
pepa 9ec15943ed Merge branch 'Verze_1.0' 2015-01-21 10:59:48 +01:00
pepa 024f1321ad Merge branch 'Verze_1.0'
Conflicts:
	src/main/webapp/WEB-INF/locales/zk-label.properties
2015-01-20 15:21:55 +01:00
pepa ea64e5a888 Merge branch 'master' of https://git.bukova.info/repos/git/isspst 2015-01-20 10:35:59 +01:00
pepa 08532dcd02 Merge branch 'Verze_1.0'
Conflicts:
	src/main/webapp/WEB-INF/locales/zk-label.properties
	src/main/webapp/app/mainMenu.zul
2015-01-20 10:35:38 +01:00
franta c04f74c5a2 Merge branch 'Verze_1.0' 2015-01-20 10:13:19 +01:00
franta eed31fe6da Merge branch 'Verze_1.0' 2015-01-20 09:02:47 +01:00
franta 61a4b3ba82 Merge branch 'Verze_1.0'
Conflicts:
	src/main/java/info/bukova/isspst/AppInitListener.java
	src/main/java/info/bukova/isspst/Constants.java
	src/main/java/info/bukova/isspst/data/Order.java
	src/main/java/info/bukova/isspst/data/OrderItem.java
	src/main/java/info/bukova/isspst/data/RequirementBase.java
	src/main/java/info/bukova/isspst/data/RequirementItem.java
	src/main/java/info/bukova/isspst/ui/settings/NumberSeriesVM.java
2015-01-19 13:29:41 +01:00
pepa ee2539000c Merge branch 'Verze_1.0' 2015-01-18 21:04:30 +01:00
pepa 0f02efbec3 Merge branch 'Verze_1.0' 2015-01-15 15:45:39 +01:00
pepa b357d0a7ef Merge branch 'Verze_1.0' of https://git.bukova.info/repos/git/isspst 2015-01-15 10:48:24 +01:00
pepa 100889d44a Merge branch 'master' of https://git.bukova.info/repos/git/isspst 2015-01-15 10:47:32 +01:00
pepa 765c56f250 Merge branch 'Verze_1.0'
Conflicts:
	src/main/java/info/bukova/isspst/Constants.java
2015-01-15 10:46:02 +01:00
franta f5e69ce80d Merge branch 'Verze_1.0' 2015-01-13 14:12:44 +01:00
pepa e9cd08c249 Implementováno fulltextové vyhledávání přes všechny záznamy. Nutno
dořešit konfiguraci adresáře pro ukládání fulltextového indexu.
2015-01-09 14:00:27 +01:00
pepa 34f1bb86de Merge branch 'master' into fulltext 2015-01-07 17:07:53 +01:00
pepa ad2a861a7b Vyhledávání - index.zul 2015-01-07 17:07:46 +01:00
pepa cf6c523698 Umožněna deaktivace modulu prostřednictvím nastavení objektu modulu ve
třídě Constants. Položku neaktivního modulu v menu lze skrýt funkcí
isActive definovanou v module.tld (viz mainMenu.zul).
2015-01-07 17:03:58 +01:00
pepa 02311ae5dd Rozdělané fulltextové vyhledávání 2015-01-06 09:08:36 +01:00
335 changed files with 16017 additions and 2075 deletions
+79
View File
@@ -0,0 +1,79 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 16464111046498525641 (0xe47c45c4252121c9)
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=CZ, ST=Vysocina, O=bukova.info, CN=Josef Rokos/emailAddress=rokos@bukova.info
Validity
Not Before: Jun 24 09:59:50 2015 GMT
Not After : Jun 21 09:59:50 2025 GMT
Subject: C=CZ, ST=Vysocina, O=bukova.info, CN=Josef Rokos/emailAddress=rokos@bukova.info
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
00:bc:fb:64:50:5b:58:03:8c:20:1c:77:d3:50:31:
94:55:78:d6:05:bb:bc:88:9d:cb:20:b1:8c:ff:ac:
fc:97:1a:b1:9c:29:c4:ac:af:ed:3b:de:93:d5:cf:
75:3e:d0:05:41:32:bf:12:25:53:60:28:af:ff:3e:
3c:3a:4c:52:78:3f:b2:78:b9:c6:2f:fc:0e:44:eb:
65:c3:7f:38:2b:ab:88:37:8c:68:55:69:e3:3d:5e:
9b:99:25:11:55:06:ab:e8:c1:fa:54:da:5b:e7:9b:
3e:3f:39:4f:cf:b3:cb:48:cf:96:02:89:0b:7e:24:
c7:00:e9:ce:8d:ea:07:cf:21:f2:89:51:c8:cc:7a:
04:e4:68:6f:1c:a8:e0:76:18:40:62:ee:2f:bd:13:
64:b7:1e:2e:18:bb:b1:d4:17:d5:fb:1f:07:59:65:
46:f0:c4:51:dc:ac:62:ff:31:a8:72:26:a6:1a:88:
37:23:82:49:9a:02:d2:39:74:98:71:7f:a4:77:52:
3a:ed:22:2e:99:9c:81:2c:48:16:3c:82:7b:af:2c:
0d:4b:28:4d:e0:46:7d:b5:b8:ea:3f:e7:5a:5b:4f:
d8:06:b2:a3:86:2f:8b:5b:9c:bc:04:2e:64:b6:e1:
09:c9:14:6d:54:7e:86:40:7b:66:33:27:33:4a:3d:
7c:97
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Subject Key Identifier:
EF:9B:88:5C:07:27:79:EA:60:90:5C:7A:28:45:FB:7F:35:E6:CB:3F
X509v3 Authority Key Identifier:
keyid:EF:9B:88:5C:07:27:79:EA:60:90:5C:7A:28:45:FB:7F:35:E6:CB:3F
X509v3 Basic Constraints:
CA:TRUE
Signature Algorithm: sha1WithRSAEncryption
08:e9:a4:32:cc:35:7c:66:5a:ea:f2:bd:e6:75:78:81:52:11:
22:27:32:c9:ec:91:6e:51:8a:f1:1e:0f:25:8a:e1:64:ba:e4:
85:1c:e4:fd:75:f0:26:3d:65:62:16:29:20:4f:5f:d2:66:36:
de:2b:bd:7b:96:71:f6:2c:d1:c5:54:69:89:dd:52:20:49:49:
b1:ac:09:b4:1e:33:59:0d:89:fd:a4:28:7a:70:96:e5:cb:58:
7e:b9:1d:02:7a:33:ee:ad:6a:ad:2c:3c:5e:7d:cc:f5:72:69:
51:fd:77:b4:0f:10:fd:9e:c2:1a:04:c5:a9:56:6e:fd:66:9f:
b6:1c:f9:d3:68:f4:4f:8c:6c:67:af:f5:e0:a5:30:67:a6:a7:
9b:6e:16:89:8a:e5:b4:20:f4:f7:74:f4:9c:ca:5d:c7:2f:e6:
30:9d:6b:2e:95:29:c1:e7:aa:d7:d6:59:dc:a9:f0:10:40:02:
66:3f:58:a2:38:8c:89:1a:0b:94:1a:e5:80:49:14:44:f4:06:
b1:11:1a:cd:ef:76:6a:bf:f8:6f:58:9d:af:a3:6b:9a:8e:bb:
6c:10:d6:d8:4e:73:58:20:0b:99:38:41:d4:22:d4:80:0b:09:
0d:25:40:3e:66:15:a0:44:4e:d6:59:5a:58:07:e5:4b:62:f1:
e9:ae:b6:7c
-----BEGIN CERTIFICATE-----
MIIDrzCCApegAwIBAgIJAOR8RcQlISHJMA0GCSqGSIb3DQEBBQUAMG4xCzAJBgNV
BAYTAkNaMREwDwYDVQQIDAhWeXNvY2luYTEUMBIGA1UECgwLYnVrb3ZhLmluZm8x
FDASBgNVBAMMC0pvc2VmIFJva29zMSAwHgYJKoZIhvcNAQkBFhFyb2tvc0BidWtv
dmEuaW5mbzAeFw0xNTA2MjQwOTU5NTBaFw0yNTA2MjEwOTU5NTBaMG4xCzAJBgNV
BAYTAkNaMREwDwYDVQQIDAhWeXNvY2luYTEUMBIGA1UECgwLYnVrb3ZhLmluZm8x
FDASBgNVBAMMC0pvc2VmIFJva29zMSAwHgYJKoZIhvcNAQkBFhFyb2tvc0BidWtv
dmEuaW5mbzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALz7ZFBbWAOM
IBx301AxlFV41gW7vIidyyCxjP+s/JcasZwpxKyv7Tvek9XPdT7QBUEyvxIlU2Ao
r/8+PDpMUng/sni5xi/8DkTrZcN/OCuriDeMaFVp4z1em5klEVUGq+jB+lTaW+eb
Pj85T8+zy0jPlgKJC34kxwDpzo3qB88h8olRyMx6BORobxyo4HYYQGLuL70TZLce
Lhi7sdQX1fsfB1llRvDEUdysYv8xqHImphqINyOCSZoC0jl0mHF/pHdSOu0iLpmc
gSxIFjyCe68sDUsoTeBGfbW46j/nWltP2Aayo4Yvi1ucvAQuZLbhCckUbVR+hkB7
ZjMnM0o9fJcCAwEAAaNQME4wHQYDVR0OBBYEFO+biFwHJ3nqYJBceihF+3815ss/
MB8GA1UdIwQYMBaAFO+biFwHJ3nqYJBceihF+3815ss/MAwGA1UdEwQFMAMBAf8w
DQYJKoZIhvcNAQEFBQADggEBAAjppDLMNXxmWuryveZ1eIFSESInMsnskW5RivEe
DyWK4WS65IUc5P118CY9ZWIWKSBPX9JmNt4rvXuWcfYs0cVUaYndUiBJSbGsCbQe
M1kNif2kKHpwluXLWH65HQJ6M+6taq0sPF59zPVyaVH9d7QPEP2ewhoExalWbv1m
n7Yc+dNo9E+MbGev9eClMGemp5tuFomK5bQg9Pd09JzKXccv5jCday6VKcHnqtfW
Wdyp8BBAAmY/WKI4jIkaC5Qa5YBJFET0BrERGs3vdmq/+G9Yna+ja5qOu2wQ1thO
c1ggC5k4QdQi1IALCQ0lQD5mFaBETtZZWlgH5Uti8emutnw=
-----END CERTIFICATE-----
+50 -11
View File
@@ -24,7 +24,7 @@
<repository> <repository>
<id>fdvsolution.public</id> <id>fdvsolution.public</id>
<name>Dynamic Jasper</name> <name>Dynamic Jasper</name>
<url>http://archiva.fdvs.com.ar/repository/public1/</url> <url>http://nexus.fdvs.com.ar/content/groups/public/</url>
</repository> </repository>
</repositories> </repositories>
@@ -215,17 +215,26 @@
<!-- Hibernate --> <!-- Hibernate -->
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId> <artifactId>hibernate-core</artifactId>
<version>4.2.8.Final</version> <version>4.2.8.Final</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId> <artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version> <version>4.3.0.Final</version>
</dependency> </dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
<version>4.4.6.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>4.2.8.Final</version>
</dependency>
<!-- ZK --> <!-- ZK -->
<dependency> <dependency>
<groupId>org.zkoss.zk</groupId> <groupId>org.zkoss.zk</groupId>
@@ -344,7 +353,20 @@
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
<version>2.4</version> <version>2.4</version>
</dependency> </dependency>
<!-- Text extractors -->
<dependency>
<groupId>org.apache.odftoolkit</groupId>
<artifactId>simple-odf</artifactId>
<version>0.7-incubating</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>
<!-- Test --> <!-- Test -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@@ -390,6 +412,23 @@
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.js</include>
<include>**/*.wpd</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build> </build>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
@@ -6,32 +6,35 @@ import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.data.Permission; import info.bukova.isspst.data.Permission;
import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.data.RequirementType;
import info.bukova.isspst.data.Role; import info.bukova.isspst.data.Role;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.data.SettingsData; import info.bukova.isspst.data.SettingsData;
import info.bukova.isspst.data.User; import info.bukova.isspst.data.User;
import info.bukova.isspst.reporting.Report; import info.bukova.isspst.reporting.Report;
import info.bukova.isspst.reporting.ReportMapping; import info.bukova.isspst.reporting.ReportMapping;
import info.bukova.isspst.reporting.ReportType; import info.bukova.isspst.reporting.ReportType;
import info.bukova.isspst.services.dbinfo.DbInfoService; import info.bukova.isspst.services.dbinfo.DbInfoService;
import info.bukova.isspst.services.fulltext.FullTextService;
import info.bukova.isspst.services.munits.MUnitService; import info.bukova.isspst.services.munits.MUnitService;
import info.bukova.isspst.services.numberseries.NumberSeriesService; import info.bukova.isspst.services.numberseries.NumberSeriesService;
import info.bukova.isspst.services.requirement.RequirementTypeService; import info.bukova.isspst.services.requirement.RequirementTypeService;
import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.settings.GlobalSettingsService;
import info.bukova.isspst.services.settings.SeasonException;
import info.bukova.isspst.services.settings.SeasonService;
import info.bukova.isspst.services.users.PermissionService; import info.bukova.isspst.services.users.PermissionService;
import info.bukova.isspst.services.users.RoleService; import info.bukova.isspst.services.users.RoleService;
import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.users.UserService;
import java.math.BigDecimal;
import java.util.List;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils; import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List;
public class AppInitListener implements ServletContextListener { public class AppInitListener implements ServletContextListener {
@@ -43,7 +46,9 @@ public class AppInitListener implements ServletContextListener {
private NumberSeriesService nsService; private NumberSeriesService nsService;
private RequirementTypeService reqTypeService; private RequirementTypeService reqTypeService;
private GlobalSettingsService gSettingsService; private GlobalSettingsService gSettingsService;
private FullTextService ftService;
private SeasonService seasonService;
@Override @Override
public void contextDestroyed(ServletContextEvent arg0) { public void contextDestroyed(ServletContextEvent arg0) {
@@ -63,6 +68,8 @@ public class AppInitListener implements ServletContextListener {
nsService =ctx.getBean(NumberSeriesService.class); nsService =ctx.getBean(NumberSeriesService.class);
gSettingsService = ctx.getBean(GlobalSettingsService.class); gSettingsService = ctx.getBean(GlobalSettingsService.class);
reqTypeService = ctx.getBean(RequirementTypeService.class); reqTypeService = ctx.getBean(RequirementTypeService.class);
ftService = ctx.getBean(FullTextService.class);
seasonService = ctx.getBean(SeasonService.class);
userService.grantAdmin(); userService.grantAdmin();
this.checkDbInfo(); this.checkDbInfo();
@@ -74,11 +81,15 @@ public class AppInitListener implements ServletContextListener {
this.checkNumberSeries(); this.checkNumberSeries();
checkReqTypes(); checkReqTypes();
this.checkGlobalSettings(); this.checkGlobalSettings();
buildFulltext();
userService.removeAccess(); userService.removeAccess();
loadModuleReports(); loadModuleReports();
} }
private void buildFulltext() {
ftService.reindex();
}
private void checkDbInfo() private void checkDbInfo()
{ {
List<User> userList = userService.getAll(); List<User> userList = userService.getAll();
@@ -223,6 +234,9 @@ public class AppInitListener implements ServletContextListener {
private void checkPermissions() { private void checkPermissions() {
for (Module m : Constants.MODULES) { for (Module m : Constants.MODULES) {
if (!m.isDefaultPermissions()) {
continue;
}
for (Permission p : Constants.DEF_PERMISSIONS) { for (Permission p : Constants.DEF_PERMISSIONS) {
if (permService.getPermissionByModule(m.getId(), p.getAuthority()) == null) { if (permService.getPermissionByModule(m.getId(), p.getAuthority()) == null) {
p.setModule(m.getId()); p.setModule(m.getId());
@@ -277,29 +291,41 @@ public class AppInitListener implements ServletContextListener {
} }
} }
} }
private void checkNumberSeriesForSeason(Season season) {
for (String modId : Constants.NUM_SERIES_PREFIX.keySet()) {
NumberSeries ns = nsService.getNumberSerieForSeason(modId, season);
if (ns == null) {
ns = new NumberSeries();
ns.setModule(modId);
ns.setPrefix(Constants.NUM_SERIES_PREFIX.get(modId));
ns.setNumber(1);
ns.setSeason(season);
nsService.add(ns);
}
}
}
private void checkNumberSeries() private void checkNumberSeries()
{ {
NumberSeries ns = nsService.getNumberSerie(Constants.MOD_REQUIREMENTS); Season season;
try {
if (ns == null) season = seasonService.getActive();
{ } catch (SeasonException e) {
ns = new NumberSeries(); season = null;
ns.setModule(Constants.MOD_REQUIREMENTS);
ns.setPrefix("");
ns.setNumber(1);
nsService.add(ns);
} }
ns = nsService.getNumberSerie(Constants.MOD_ORDER); if (season == null) {
season = new Season();
if (ns == null) Calendar cal = Calendar.getInstance();
{ season.setDescription(String.valueOf(cal.get(Calendar.YEAR)));
ns = new NumberSeries(); season.setValidFrom(cal.getTime());
ns.setModule(Constants.MOD_ORDER); season.setActive(true);
ns.setPrefix(""); seasonService.add(season);
ns.setNumber(1); }
nsService.add(ns);
for (Season s : seasonService.getAllSeasons()) {
checkNumberSeriesForSeason(s);
} }
} }
@@ -4,6 +4,7 @@ import java.math.BigDecimal;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import static org.apache.commons.lang.StringUtils.strip;
public class BigDecimalUtils public class BigDecimalUtils
{ {
@@ -23,6 +24,17 @@ public class BigDecimalUtils
String valueS = value.toPlainString(); String valueS = value.toPlainString();
String searchS = search.toPlainString(); String searchS = search.toPlainString();
if (valueS.contains(".") || valueS.contains(",")) {
valueS = strip(valueS, "0");
valueS = strip(valueS, ".,");
}
if (searchS.contains(".") || searchS.contains(",")) {
searchS = strip(searchS, "0");
searchS = strip(searchS, ".,");
}
boolean result = (valueS.compareTo(searchS) == 0); boolean result = (valueS.compareTo(searchS) == 0);
String s = "search='" + searchS + "', value='" + valueS + "', equal=" + (result ? "true" : "false"); String s = "search='" + searchS + "', value='" + valueS + "', equal=" + (result ? "true" : "false");
@@ -1,13 +1,48 @@
package info.bukova.isspst; package info.bukova.isspst;
import org.jfree.util.Log;
public class BooleanUtils public class BooleanUtils
{ {
public static boolean isEqualByBoolean(Boolean b1, Boolean b2) private static final String TAG = BooleanUtils.class.getSimpleName();
public static boolean isEqualByBooleanValue(Boolean b1, Boolean b2)
{ {
boolean bool1 = ((b1 == null) ? false : b1.booleanValue()); boolean bool1 = ((b1 == null) ? false : b1.booleanValue());
boolean bool2 = ((b2 == null) ? false : b2.booleanValue()); boolean bool2 = ((b2 == null) ? false : b2.booleanValue());
boolean equals = (bool1 == bool2); boolean equals = (bool1 == bool2);
return equals; return equals;
} }
public static boolean isEqualByBoolean(Boolean b1, Boolean b2)
{
if ((b1 == null) && (b2 == null))
{
return true;
}
else if ((b1 != null) && (b2 != null))
{
return (b1.booleanValue() == b2.booleanValue());
}
return false;
}
public static boolean isEqualFilterByBoolean(Boolean value, Boolean filterValue)
{
if (filterValue == null)
{
// Show all records
return true;
}
if (value == null)
{
// Fuck!!! Tri-state data (null, false, true)... We need new solution for selecting ALL data
Log.warn(TAG + "\nVelky Boolean v databazi... Pozor na filtrovani.");
return true;
}
return (value.booleanValue() == filterValue.booleanValue());
}
} }
@@ -1,16 +1,21 @@
package info.bukova.isspst; package info.bukova.isspst;
import info.bukova.isspst.data.Order;
import info.bukova.isspst.data.Permission; import info.bukova.isspst.data.Permission;
import info.bukova.isspst.data.PermissionType; import info.bukova.isspst.data.PermissionType;
import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.data.RequirementType;
import info.bukova.isspst.data.Role; import info.bukova.isspst.data.Role;
import info.bukova.isspst.data.TripBill;
import info.bukova.isspst.data.TripBillApproval;
import info.bukova.isspst.data.TripRequirement; import info.bukova.isspst.data.TripRequirement;
import info.bukova.isspst.reporting.Report; import info.bukova.isspst.reporting.Report;
import info.bukova.isspst.reporting.ReportMapping; import info.bukova.isspst.reporting.ReportMapping;
import info.bukova.isspst.services.addressbook.AdbService; import info.bukova.isspst.services.addressbook.AdbService;
import info.bukova.isspst.services.buildings.BuildingService; import info.bukova.isspst.services.buildings.BuildingService;
import info.bukova.isspst.services.fulltext.FullTextService;
import info.bukova.isspst.services.invoicing.InvoicingService; import info.bukova.isspst.services.invoicing.InvoicingService;
import info.bukova.isspst.services.limits.LimitService;
import info.bukova.isspst.services.munits.MUnitService; import info.bukova.isspst.services.munits.MUnitService;
import info.bukova.isspst.services.orders.ApprovedService; import info.bukova.isspst.services.orders.ApprovedService;
import info.bukova.isspst.services.orders.OrderService; import info.bukova.isspst.services.orders.OrderService;
@@ -19,6 +24,7 @@ import info.bukova.isspst.services.reqsubjects.ServiceItemService;
import info.bukova.isspst.services.requirement.RequirementService; import info.bukova.isspst.services.requirement.RequirementService;
import info.bukova.isspst.services.requirement.RequirementTypeService; import info.bukova.isspst.services.requirement.RequirementTypeService;
import info.bukova.isspst.services.requirement.TripRequirementService; import info.bukova.isspst.services.requirement.TripRequirementService;
import info.bukova.isspst.services.signeddocs.SignedDocumentService;
import info.bukova.isspst.services.tripbill.TripBillService; import info.bukova.isspst.services.tripbill.TripBillService;
import info.bukova.isspst.services.users.RoleService; import info.bukova.isspst.services.users.RoleService;
import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.users.UserService;
@@ -30,7 +36,7 @@ import java.util.Map;
public class Constants { public class Constants {
public final static long DB_VERSION = 2; public final static long DB_VERSION = 6;
public final static String DEF_ADMIN = "admin"; public final static String DEF_ADMIN = "admin";
public final static String DEF_ADMIN_PASSWD = "admin"; public final static String DEF_ADMIN_PASSWD = "admin";
@@ -81,6 +87,9 @@ public class Constants {
public final static String MOD_APPROVED = "APPROVED"; public final static String MOD_APPROVED = "APPROVED";
public final static String MOD_ORDER = "ORDER"; public final static String MOD_ORDER = "ORDER";
public final static String MOD_INVOICING = "INVOICING"; public final static String MOD_INVOICING = "INVOICING";
public final static String MOD_SEARCH = "SEARCH";
public final static String MOD_SIGNEDDOCS = "SIGNEDDOCS";
public final static String MOD_LIMITS = "LIMITS";
public final static Module MODULES[] = { public final static Module MODULES[] = {
new Module(MOD_USERS, "Uživatelé", UserService.class), new Module(MOD_USERS, "Uživatelé", UserService.class),
new Module(MOD_PERMISSIONS, "Práva", RoleService.class), new Module(MOD_PERMISSIONS, "Práva", RoleService.class),
@@ -96,7 +105,11 @@ public class Constants {
new Module(MOD_TRIPBILL, "Cestovní příkazy", TripBillService.class), new Module(MOD_TRIPBILL, "Cestovní příkazy", TripBillService.class),
new Module(MOD_APPROVED, "Schválené položky požadavků", ApprovedService.class), new Module(MOD_APPROVED, "Schválené položky požadavků", ApprovedService.class),
new Module(MOD_ORDER, "Objednávky", OrderService.class), new Module(MOD_ORDER, "Objednávky", OrderService.class),
new Module(MOD_INVOICING, "Fakturace požadavků", InvoicingService.class) }; new Module(MOD_INVOICING, "Fakturace požadavků", InvoicingService.class),
new Module(MOD_SEARCH, "Fulltextové vyhledávání", FullTextService.class, true, false),
new Module(MOD_SIGNEDDOCS, "Podepsané dokumenty", SignedDocumentService.class, true, false),
new Module(MOD_LIMITS, "Limity komisi", LimitService.class),
};
public final static String PERM_APPROVE = "PERM_APPROVE"; public final static String PERM_APPROVE = "PERM_APPROVE";
public final static String PERM_SHOW_WORKGROUP_REQ = "PERM_SHOW_WORKGROUP_REQ"; public final static String PERM_SHOW_WORKGROUP_REQ = "PERM_SHOW_WORKGROUP_REQ";
@@ -105,6 +118,8 @@ public class Constants {
public final static String PERM_EDIT_NEW = "PERM_EDIT_NEW"; public final static String PERM_EDIT_NEW = "PERM_EDIT_NEW";
public final static String PERM_EDIT_OWN = "PERM_EDIT_OWN"; public final static String PERM_EDIT_OWN = "PERM_EDIT_OWN";
public final static String PERM_DELETE_NEW = "PERM_DELETE_NEW"; public final static String PERM_DELETE_NEW = "PERM_DELETE_NEW";
public final static String PERM_SEARCH = "PERM_SEARCH";
public final static String PERM_PAY_BILL = "PERM_PAY_BILL";
public final static Permission SPECIAL_PERMISSIONS[] = { public final static Permission SPECIAL_PERMISSIONS[] = {
new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_REQUIREMENTS, PermissionType.GLOBAL), new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_REQUIREMENTS, PermissionType.GLOBAL),
@@ -120,17 +135,41 @@ public class Constants {
new Permission(PERM_SHOW_CENTRE_REQ, "Zobrazení požadavků střediska", MOD_TRIPREQUIREMENTS, PermissionType.CENTRE), new Permission(PERM_SHOW_CENTRE_REQ, "Zobrazení požadavků střediska", MOD_TRIPREQUIREMENTS, PermissionType.CENTRE),
new Permission(PERM_SHOW_ALL_REQ, "Zobrazení všech požadavků", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL), new Permission(PERM_SHOW_ALL_REQ, "Zobrazení všech požadavků", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL),
new Permission(PERM_APPROVE, "Schválení", MOD_TRIPREQUIREMENTS, PermissionType.WORKGROUP), new Permission(PERM_APPROVE, "Schválení", MOD_TRIPREQUIREMENTS, PermissionType.WORKGROUP),
new Permission(PERM_SEARCH, "Vyhledávat", MOD_SEARCH, PermissionType.GLOBAL),
new Permission(PERM_READ, "Číst", MOD_SIGNEDDOCS, PermissionType.GLOBAL),
new Permission(PERM_PAY_BILL, "Vyplacení SC", MOD_TRIPBILL, PermissionType.GLOBAL)
}; };
public final static String DYNAMIC_REPORT_NAME = "Tabulková sestava"; public final static String DYNAMIC_REPORT_NAME = "Tabulková sestava";
public final static ReportMapping REPORTS[] = { public final static ReportMapping REPORTS[] = {
new ReportMapping(MOD_ADDRESSBOOK, new Report("Adresní karty", "address")), new ReportMapping(MOD_ADDRESSBOOK, new Report(1, false, "Adresní karty", "address")),
new ReportMapping(MOD_ADDRESSBOOK, new Report("Adresa", "address", false, true)), new ReportMapping(MOD_ADDRESSBOOK, new Report(2, false, "Adresa", "address", false, true)),
new ReportMapping(MOD_TRIPBILL, new Report("Žádost", "tripRequirement", false, true)), new ReportMapping(MOD_TRIPBILL, new Report(7, true, "Žádost o SC", "tripRequirementApp", false, true, "requirement")),
new ReportMapping(MOD_TRIPBILL, new Report("Vyúčtování", "tripBill", false, true)), new ReportMapping(MOD_TRIPBILL, new Report(4, true, "Vyúčtování", "tripBill", false, true, true)),
new ReportMapping(MOD_ORDER, new Report("Objednávka", "order", true, true)), new ReportMapping(MOD_ORDER, new Report(5, false, "Objednávka", "order", true, true)),
new ReportMapping(MOD_REQUIREMENTS, new Report("Požadavky", "requirements")) new ReportMapping(MOD_REQUIREMENTS, new Report(6, false, "Požadavky", "requirements")),
new ReportMapping(MOD_TRIPREQUIREMENTS, new Report(7, true, "Žádost o SC", "tripRequirementApp", false, true)),
new ReportMapping(MOD_REQUIREMENTS, new Report(8, true, "Protokol o kontrole", "orderRequirement", false, true)),
new ReportMapping(MOD_INVOICING, new Report(9, false, "Přehled o protokolech předběžné kontroly", "requirementProtocol")),
new ReportMapping(MOD_TRIPREQUIREMENTS, new Report(10, true, "Přehled o protokolech předběžné kontroly", "tripRequirementProtocol"))
}; };
public final static long TRIB_BILLS_REP_ID = 100;
public final static long TRIB_BILLS_NP_REP_ID = 101;
// pokud je v agnde vic nez jedena podepisovaci sestava, musi se definovat ktera sestava nalezi jake entite
public final static Map<Class<?>, Integer> SIGN_REPORT_MAP = Collections.unmodifiableMap(new HashMap<Class<?>, Integer>() {{
put(TripBillApproval.class, 4);
put(TripRequirement.class, 7);
}});
// vychozi prefixy ciselnych rad. Pokud se prida agenda s vlastni ciselnou radou, je potreba zadefinovat vychozi prefix
public final static Map<String, String> NUM_SERIES_PREFIX = Collections.unmodifiableMap(new HashMap<String, String>() {{
put(MOD_REQUIREMENTS, "P");
put(MOD_ORDER, "O");
}});
public final static String REQTYPE_ORDER = "ORDER"; public final static String REQTYPE_ORDER = "ORDER";
public final static String REQTYPE_BUSINESSTRIP = "BUSINESSTRIP"; public final static String REQTYPE_BUSINESSTRIP = "BUSINESSTRIP";
@@ -146,8 +185,17 @@ public class Constants {
public final static Map<Class<?>, String> URL_MAP = Collections.unmodifiableMap(new HashMap<Class<?>, String>() {{ public final static Map<Class<?>, String> URL_MAP = Collections.unmodifiableMap(new HashMap<Class<?>, String>() {{
put(Requirement.class, "/main/orders/"); put(Requirement.class, "/main/orders/");
put(TripRequirement.class, "/main/trips/requirements/"); put(TripRequirement.class, "/main/trips/requirements/");
put(TripBillApproval.class, "/main/trips/bill/");
put(Order.class, "/main/orders/created/");
put(TripBill.class, "/main/trips/bill/");
}} ); }} );
public final static int LEN_TEXT = 255; public final static int LEN_TEXT = 255;
public final static int LEN_DESCRIPTION = 8192; public final static int LEN_DESCRIPTION = 8192;
public final static int LEN_RESULT_MESSAGE = 8192;
public final static String MAIL_URL_KEYWORD = "-url-";
public final static String KEY_SIGN_DATA = "SIGN_DATA";
public final static String KEY_SIGN_GUID = "SIGN_GUID";
} }
@@ -1,57 +1,135 @@
package info.bukova.isspst; package info.bukova.isspst;
import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar;
import org.apache.commons.lang.time.DateUtils; import org.apache.commons.lang.time.DateUtils;
public class DateTimeUtils public class DateTimeUtils {
{ public static Date getDate(Date value) {
public static Date getDate(Date value) if (value == null) {
{ return value;
if (value == null) }
{
return value;
}
// Keep date - truncate time
return DateUtils.truncate(value, Calendar.DAY_OF_MONTH);
}
public static boolean isEqualByDate(Date d1, Date d2)
{
if (d1 != null && d2 != null)
{
d1 = DateTimeUtils.getDate(d1);
d2 = DateTimeUtils.getDate(d2);
boolean equals = (d1.compareTo(d2) == 0);
return equals;
}
return false;
}
public static boolean isEqualByDateForFilter(Date value, Date search)
{
if (search == null)
{
return true;
}
else if (value != null)
{
return DateTimeUtils.isEqualByDate(value, search);
}
return false;
}
public static Date getCurrDateTime() // Keep date - truncate time
{ return DateUtils.truncate(value, Calendar.DAY_OF_MONTH);
return new Date(); }
}
public static Date getCurrDate() public static int getYear(Date value) {
{ if (value == null) {
return DateTimeUtils.getDate(DateTimeUtils.getCurrDateTime()); return 0;
} }
Calendar cal =Calendar.getInstance();
cal.setTime(value);
return cal.get(Calendar.YEAR);
}
public static boolean isEqualByDate(Date d1, Date d2) {
if (d1 != null && d2 != null) {
d1 = DateTimeUtils.getDate(d1);
d2 = DateTimeUtils.getDate(d2);
boolean equals = (d1.compareTo(d2) == 0);
return equals;
}
return false;
}
public static boolean isEqualByYear(Date d1, Date d2) {
if (d1 != null && d2 != null) {
int year1 = DateTimeUtils.getYear(d1);
int year2 = DateTimeUtils.getYear(d2);
boolean equals = (year1 == year2);
return equals;
}
return false;
}
public static boolean isEqualByDateForFilter(Date value, Date search) {
if (search == null) {
return true;
} else if (value != null) {
return DateTimeUtils.isEqualByDate(value, search);
}
return false;
}
public static String getFormatedDate(Date value) {
if (value == null) {
return "";
}
SimpleDateFormat sdf = new SimpleDateFormat(StringUtils.localize("DateFormat"));
String result = sdf.format(value);
return result;
}
public static String getFormatedDirDate(Date value) {
if (value == null) {
return "";
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String result = sdf.format(value);
return result;
}
public static String getFormatedDirDateDDMM(Date value) {
if (value == null) {
return "";
}
SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
String result = sdf.format(value);
return result;
}
public static String getFormatedYear(Date value) {
if (value == null) {
return "";
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
String result = sdf.format(value);
return result;
}
public static Date getCurrDateTime() {
return new Date();
}
public static Date getCurrDate() {
return DateTimeUtils.getDate(DateTimeUtils.getCurrDateTime());
}
public static Calendar getCalendarDelta(Date value, int calendarType, int delta) {
if (value == null) {
value = DateTimeUtils.getCurrDate();
}
Calendar calendar = new GregorianCalendar();
calendar.setTime(value);
int deltaValue = calendar.get(calendarType);
calendar.set(calendarType, deltaValue + delta);
return calendar;
}
public static Calendar getCalendar(Date value) {
if (value == null) {
value = DateTimeUtils.getCurrDate();
}
Calendar calendar = new GregorianCalendar();
calendar.setTime(value);
return calendar;
}
public static Date getDateDelta(Date value, int calendarType, int delta) {
Calendar calendar = DateTimeUtils.getCalendarDelta(value, calendarType, delta);
return calendar.getTime();
}
} }
@@ -1,16 +1,26 @@
package info.bukova.isspst; package info.bukova.isspst;
import info.bukova.isspst.reporting.Report; import info.bukova.isspst.reporting.Report;
import info.bukova.isspst.services.AbstractService;
import info.bukova.isspst.services.ModuleNotActiveException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* @author Pepa Rokos
*
* Třída reprezentuje informace o modulu (agendě).
*
*/
public class Module { public class Module {
private String id; private String id;
private String name; private String name;
private Class<?> serviceClass; private Class<?> serviceClass;
private List<Report> reports; private List<Report> reports;
private boolean defaultPermissions;
private boolean active;
public Class<?> getServiceClass() { public Class<?> getServiceClass() {
return serviceClass; return serviceClass;
@@ -20,11 +30,42 @@ public class Module {
this.serviceClass = serviceClass; this.serviceClass = serviceClass;
} }
/**
*
* @param id identifikátor modulu
* @param name jméno zobrazované v aplikaci
* @param serviceClass servisní třída
*/
public Module(String id, String name, Class<?> serviceClass) { public Module(String id, String name, Class<?> serviceClass) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.serviceClass = serviceClass; this.serviceClass = serviceClass;
reports = new ArrayList<Report>(); reports = new ArrayList<Report>();
defaultPermissions = true;
active = true;
}
/**
* @param id identifikátor modulu
* @param name jméno zobrazované v aplikaci
* @param serviceClass servisní třída
* @param active příznak, jestli je modul aktivní
*/
public Module(String id, String name, Class<?> serviceClass, boolean active) {
this(id, name, serviceClass);
this.active = active;
}
/**
* @param id identifikátor modulu
* @param name jméno zobrazované v aplikaci
* @param serviceClass servisní třída
* @param active příznak, jestli je modul aktivní.
* @param defaultPermissions příznak určující jestli modul kontroluje výchozí práva (čtení, zápis, modifikace, mazání)
*/
public Module(String id, String name, Class<?> serviceClass, boolean active, boolean defaultPermissions) {
this(id, name, serviceClass, active);
this.defaultPermissions = defaultPermissions;
} }
public String getId() { public String getId() {
@@ -51,4 +92,33 @@ public class Module {
this.reports.add(report); this.reports.add(report);
} }
/**
* Pokud je true, modul kontroluje výchozí práva (čtení, zápis, modifikace, mazání). Má vliv
* na generování formulářů v nastavení práv.
*
* @return výchozí práva. Default true
*/
public boolean isDefaultPermissions() {
return defaultPermissions;
}
public void setDefaultPermissions(boolean defaultPermissions) {
this.defaultPermissions = defaultPermissions;
}
/**
* Určuje, zda je modul aktivní. Neaktivní moduly nejsou viditelné v UI. Při pokusu o přístup přímo přes URL
* se generuje výjimka {@link ModuleNotActiveException}. Pokud servisní třída modulu nedědí z {@link AbstractService},
* musí se implementovat kontrola aktivity do příslušné třídy.
*
* @return aktivita. Default true
*/
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
} }
@@ -0,0 +1,94 @@
package info.bukova.isspst;
import info.bukova.isspst.data.DataModel;
import info.bukova.isspst.services.Service;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.ServletContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ModuleUtils {
public static List<Module> getActiveModules() {
List<Module> modules = new ArrayList<Module>();
for (Module m : Arrays.asList(Constants.MODULES)) {
if (m.isActive()) {
modules.add(m);
}
}
return modules;
}
public static Module getModule(Class<?> serviceClass) {
for (Module m : Constants.MODULES) {
if (Arrays.asList(serviceClass.getInterfaces()).contains(m.getServiceClass())) {
return m;
}
}
return null;
}
public static Module getModule(String id) {
for (Module m : Constants.MODULES) {
if (m.getId().equals(id)) {
return m;
}
}
return null;
}
public static Module getModule(DataModel entity, ServletContext sc) {
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
for (Module m : Constants.MODULES) {
Service<?> service;
try {
service = (Service<?>) ctx.getBean(m.getServiceClass());
} catch (NoSuchBeanDefinitionException e) {
String[] beans = ctx.getBeanNamesForType(m.getServiceClass());
for (String s : beans) {
service = (Service<?>) ctx.getBean(s);
if (service.getEntityClasses().contains(entity.getClass())) {
return m;
}
}
continue;
} catch (ClassCastException e) { //nestandardní moduly neřeší...
continue;
}
if (service.getEntityClasses().contains(entity.getClass())) {
return m;
}
}
return null;
}
public static Service<?> getServiceInstance(Module m, ServletContext sc) {
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
try {
return (Service<?>) ctx.getBean(m.getServiceClass());
} catch (NoSuchBeanDefinitionException e) {
String[] beans = ctx.getBeanNamesForType(m.getServiceClass());
return (Service<?>) ctx.getBean(beans[0]);
}
}
public static boolean isActive(String id) {
return getModule(id).isActive();
}
}
@@ -0,0 +1,31 @@
package info.bukova.isspst;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegExUtils {
public static List<String> getMatches(String input, String regEx, int group) {
List<String> list = new ArrayList<String>();
if (!StringUtils.isNullOrEmpty(input) && !StringUtils.isNullOrEmpty(regEx)) {
Pattern pattern = Pattern.compile(regEx);
Matcher matcher = pattern.matcher(input);
int groupCount = matcher.groupCount() + 1;
if ((groupCount >= 0) && (group < groupCount)) {
while (matcher.find()) {
String item = matcher.group(group);
list.add(item);
}
}
}
return list;
}
public static List<String> getMatches(String input, String regEx) {
return RegExUtils.getMatches(input, regEx, 0);
}
}
@@ -29,7 +29,7 @@ public class RequirementUrlResolver implements EntityUrlResolver {
Requirement req = (Requirement)entity; Requirement req = (Requirement)entity;
if (req.getKind() == Constants.REQ_TYPE_MATERIAL) { if (req.getKind() != null && req.getKind() == Constants.REQ_TYPE_MATERIAL) {
return defaultUrl + Constants.URL_MAP.get(req.getClass()) + "material/?select=" + String.valueOf(req.getId()); return defaultUrl + Constants.URL_MAP.get(req.getClass()) + "material/?select=" + String.valueOf(req.getId());
} else { } else {
return defaultUrl + Constants.URL_MAP.get(req.getClass()) + "services/?select=" + String.valueOf(req.getId()); return defaultUrl + Constants.URL_MAP.get(req.getClass()) + "services/?select=" + String.valueOf(req.getId());
@@ -5,6 +5,7 @@ import info.bukova.isspst.data.User;
import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.data.Workgroup;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -13,16 +14,19 @@ public class SessionData implements Serializable {
/** /**
* *
*/ */
private static final long serialVersionUID = -764426911263559758L; private static final long serialVersionUID = -764426911263559759L;
private List<Workgroup> userCentres; private List<Workgroup> userCentres;
private List<Workgroup> userOnlyCentres;
private List<Workgroup> userWorkgroups; private List<Workgroup> userWorkgroups;
private User currentUser; private User currentUser;
private Map<Integer, List<Role>> workgroupRoles; private Map<Integer, List<Role>> workgroupRoles;
private boolean loginFailed; private boolean loginFailed;
private Map<String, Object> properties;
public SessionData() { public SessionData() {
loginFailed = false; loginFailed = false;
properties = new HashMap<String, Object>();
} }
public List<Workgroup> getUserCentres() { public List<Workgroup> getUserCentres() {
@@ -65,4 +69,19 @@ public class SessionData implements Serializable {
this.loginFailed = loginFailed; this.loginFailed = loginFailed;
} }
public void setProperty(String key, Object value) {
properties.put(key, value);
}
public Object getProperty(String key) {
return properties.get(key);
}
public List<Workgroup> getUserOnlyCentres() {
return userOnlyCentres;
}
public void setUserOnlyCentres(List<Workgroup> userOnlyCentres) {
this.userOnlyCentres = userOnlyCentres;
}
} }
@@ -0,0 +1,25 @@
package info.bukova.isspst;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.ServletContext;
/**
* @author Pepa Rokos
*/
public class SpringUtils {
private static WebApplicationContext webCtx(ServletContext sc) {
return WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
}
public static Object getBean(String name, ServletContext sc) {
return webCtx(sc).getBean(name);
}
public static <T> T getBean(Class<T> clazz, ServletContext sc) {
return webCtx(sc).getBean(clazz);
}
}
@@ -7,6 +7,15 @@ import org.zkoss.util.resource.Labels;
public class StringUtils public class StringUtils
{ {
public static boolean isNullOrEmpty(String str)
{
return ((str == null) || (str.isEmpty()));
}
public static boolean isNullOrTrimmedEmpty(String str)
{
return ((str == null) || (str.trim().isEmpty()));
}
public static String nullToEmptyString(String str) public static String nullToEmptyString(String str)
{ {
@@ -0,0 +1,29 @@
package info.bukova.isspst;
import info.bukova.isspst.data.TripBillApproval;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
/**
* @author Pepa Rokos
*/
public class TripBillAprovalUrlResolver implements EntityUrlResolver {
@Autowired
private HttpServletRequest request;
@Override
public String entityUrl(Object entity) {
String defUrl = request.getRequestURL().toString();
defUrl = defUrl.substring(0, defUrl.indexOf(request.getServletPath()));
if (entity instanceof TripBillApproval) {
String url = Constants.URL_MAP.get(entity.getClass());
return defUrl + url + "?select=" + String.valueOf(((TripBillApproval)entity).getId());
}
return defUrl + "/app";
}
}
@@ -0,0 +1,10 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.Limit;
/**
* @author Pepa Rokos
*/
public interface LimitDao extends BaseDao<Limit> {
}
@@ -0,0 +1,10 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.Season;
/**
* @author Pepa Rokos
*/
public interface SeasonDao extends BaseDao<Season> {
}
@@ -0,0 +1,7 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.SignedDocument;
public interface SignedDocumentDao extends BaseDao<SignedDocument> {
}
@@ -0,0 +1,9 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.TripBillApproval;
/**
* @author Pepa Rokos
*/
public interface TripBillApprovalDao extends BaseDao<TripBillApproval> {
}
@@ -0,0 +1,11 @@
package info.bukova.isspst.dao.jpa;
import info.bukova.isspst.dao.LimitDao;
import info.bukova.isspst.data.Limit;
/**
* @author Pepa Rokos
*/
public class LimitDaoJPA extends BaseDaoJPA<Limit> implements LimitDao {
}
@@ -0,0 +1,11 @@
package info.bukova.isspst.dao.jpa;
import info.bukova.isspst.dao.SeasonDao;
import info.bukova.isspst.data.Season;
/**
* @author Pepa Rokos
*/
public class SeasonDaoJPA extends BaseDaoJPA<Season> implements SeasonDao {
}
@@ -0,0 +1,9 @@
package info.bukova.isspst.dao.jpa;
import info.bukova.isspst.dao.SignedDocumentDao;
import info.bukova.isspst.data.SignedDocument;
public class SignedDocumentDaoJPA extends BaseDaoJPA<SignedDocument> implements SignedDocumentDao {
}
@@ -0,0 +1,11 @@
package info.bukova.isspst.dao.jpa;
import info.bukova.isspst.dao.TripBillApprovalDao;
import info.bukova.isspst.data.TripBillApproval;
/**
* @author Pepa Rokos
*/
public class TripBillApprovalDaoJPA extends BaseDaoJPA<TripBillApproval> implements TripBillApprovalDao {
}
@@ -7,11 +7,18 @@ import java.util.List;
import javax.persistence.Embeddable; import javax.persistence.Embeddable;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
@Embeddable @Embeddable
@Indexed
public class AddressEmb public class AddressEmb
{ {
private int id; private int id;
@Field(index = Index.YES, analyze = Analyze.YES)
private String company; private String company;
private String department; private String department;
private String contactName; private String contactName;
@@ -1,6 +1,9 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import java.util.Date; import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.FetchType; import javax.persistence.FetchType;
@@ -10,8 +13,10 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.persistence.Transient; import javax.persistence.Transient;
import java.util.Date;
@MappedSuperclass @MappedSuperclass
@Indexed
public abstract class BaseData implements OwnedDataModel { public abstract class BaseData implements OwnedDataModel {
@Id @Id
@@ -24,9 +29,13 @@ public abstract class BaseData implements OwnedDataModel {
private Date modified; private Date modified;
@ManyToOne(fetch=FetchType.LAZY) @ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="OWNED_BY_ID") @JoinColumn(name="OWNED_BY_ID")
@IndexedEmbedded
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private User ownedBy; private User ownedBy;
@ManyToOne(fetch=FetchType.LAZY) @ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="MODIFIED_BY_ID") @JoinColumn(name="MODIFIED_BY_ID")
@IndexedEmbedded
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private User modifiedBy; private User modifiedBy;
@Transient @Transient
private boolean valid; private boolean valid;
@@ -0,0 +1,97 @@
package info.bukova.isspst.data;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author Pepa Rokos
*/
@Entity
@Table(name = "FILE_CONTENTS")
@Indexed
public class FileContent {
@Id
@Column(name = "ID")
@GeneratedValue
private int id;
@Column(name = "CONTENT")
@Type(type = "text")
@Field(index = Index.YES, analyze = Analyze.YES)
private String plainText;
@Column(name = "CONTENT_TYPE")
private String contentType;
@Column(name = "PATH_IN_FILESYSTEM")
private String pathInFilesystem;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPlainText() {
return plainText;
}
public void setPlainText(String content) {
this.plainText = content;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getPathInFilesystem() {
return pathInFilesystem;
}
public void setPathInFilesystem(String pathInFilesystem) {
this.pathInFilesystem = pathInFilesystem;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof FileContent)) return false;
FileContent that = (FileContent) o;
if (id != that.id) return false;
if (plainText != null ? !plainText.equals(that.plainText) : that.plainText != null) return false;
if (contentType != null ? !contentType.equals(that.contentType) : that.contentType != null) return false;
if (pathInFilesystem != null ? !pathInFilesystem.equals(that.pathInFilesystem) : that.pathInFilesystem != null)
return false;
return true;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + (plainText != null ? plainText.hashCode() : 0);
result = 31 * result + (contentType != null ? contentType.hashCode() : 0);
result = 31 * result + (pathInFilesystem != null ? pathInFilesystem.hashCode() : 0);
return result;
}
}
@@ -0,0 +1,152 @@
package info.bukova.isspst.data;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "FILE_METAINFO")
@Indexed
public class FileMetainfo extends BaseData {
@Column(name = "FILE_NAME")
@Field(index = Index.YES, analyze = Analyze.YES)
private String fileName;
@Column(name = "MODULE_ID")
private String moduleId;
@Column(name = "RECORD_ID")
private int recordId;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "CONTENT_ID")
@Cascade(CascadeType.SAVE_UPDATE)
@IndexedEmbedded
private FileContent content;
@Column(name = "MD5")
private String md5;
@Column(name = "DESCRIPTION")
@Field(index = Index.YES, analyze = Analyze.YES)
private String description;
private void ensureContentExists() {
if (content == null) {
content = new FileContent();
}
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getPathInFilesystem() {
if (content != null) {
return content.getPathInFilesystem();
}
return null;
}
public void setPathInFilesystem(String pathInFilesystem) {
ensureContentExists();
content.setPathInFilesystem(pathInFilesystem);
}
public String getModuleId() {
return moduleId;
}
public void setModuleId(String moduleId) {
this.moduleId = moduleId;
}
public int getRecordId() {
return recordId;
}
public void setRecordId(int recordId) {
this.recordId = recordId;
}
public FileContent getContent() {
return content;
}
public void setContent(FileContent content) {
this.content = content;
}
public String getMd5() {
return md5;
}
public void setMd5(String md5) {
this.md5 = md5;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getContentType() {
if (content != null) {
return content.getContentType();
}
return null;
}
public void setContentType(String contentType) {
ensureContentExists();
content.setContentType(contentType);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof FileMetainfo)) return false;
FileMetainfo that = (FileMetainfo) o;
if (recordId != that.recordId) return false;
if (content != null ? !content.equals(that.content) : that.content != null) return false;
if (description != null ? !description.equals(that.description) : that.description != null) return false;
if (fileName != null ? !fileName.equals(that.fileName) : that.fileName != null) return false;
if (md5 != null ? !md5.equals(that.md5) : that.md5 != null) return false;
if (moduleId != null ? !moduleId.equals(that.moduleId) : that.moduleId != null) return false;
return true;
}
@Override
public int hashCode() {
int result = fileName != null ? fileName.hashCode() : 0;
result = 31 * result + (moduleId != null ? moduleId.hashCode() : 0);
result = 31 * result + recordId;
result = 31 * result + (content != null ? content.hashCode() : 0);
result = 31 * result + (md5 != null ? md5.hashCode() : 0);
result = 31 * result + (description != null ? description.hashCode() : 0);
return result;
}
}
@@ -1,7 +1,8 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import java.math.BigDecimal; import org.hibernate.annotations.Cascade;
import java.util.List; import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
@@ -11,16 +12,17 @@ import javax.persistence.JoinColumn;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import java.math.BigDecimal;
import org.hibernate.annotations.LazyCollection; import java.util.List;
import org.hibernate.annotations.LazyCollectionOption;
@Entity @Entity
@Table(name = "INVOICING") @Table(name = "INVOICING")
public class Invoicing extends BaseData { public class Invoicing extends BaseData implements Cloneable
{
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "REQUIREMENT_ID") @JoinColumn(name = "REQUIREMENT_ID")
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
private Requirement requirement; private Requirement requirement;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@@ -31,6 +33,9 @@ public class Invoicing extends BaseData {
@Column(name = "TOTAL_INVOICED", precision = 15, scale = 4) @Column(name = "TOTAL_INVOICED", precision = 15, scale = 4)
private BigDecimal totalInvoiced; private BigDecimal totalInvoiced;
@Column(name = "COMPLETED")
private boolean completed;
public Requirement getRequirement() { public Requirement getRequirement() {
return requirement; return requirement;
} }
@@ -55,4 +60,32 @@ public class Invoicing extends BaseData {
this.totalInvoiced = totalInvoiced; this.totalInvoiced = totalInvoiced;
} }
public boolean isCompleted()
{
return completed;
}
public void setCompleted(boolean completed)
{
this.completed = completed;
}
public String getInvoiceNumbers() {
String ret = "";
for (InvoicingItem invNum : items) {
if (!ret.isEmpty()) {
ret += ", ";
}
ret += invNum.getInvoiceNumber();
}
return ret;
}
@Override
public Object clone() throws CloneNotSupportedException
{
Invoicing cloned = (Invoicing) super.clone();
return cloned;
}
} }
@@ -1,5 +1,8 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
@@ -11,6 +14,7 @@ import javax.persistence.Table;
@Entity @Entity
@Table(name = "JOBMAPPING") @Table(name = "JOBMAPPING")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class JobMapping { public class JobMapping {
@Id @Id
@@ -19,9 +23,11 @@ public class JobMapping {
private int id; private int id;
@ManyToOne(fetch = FetchType.EAGER) @ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "MEMBER_ID") @JoinColumn(name = "MEMBER_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Member member; private Member member;
@ManyToOne(fetch = FetchType.EAGER) @ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "ROLE_ID") @JoinColumn(name = "ROLE_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Role role; private Role role;
public JobMapping() { public JobMapping() {
@@ -1,5 +1,7 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@@ -220,6 +222,23 @@ public class JoinedItem implements DataModel, FilterableRequirement
this.ownedBy = owner; this.ownedBy = owner;
} }
protected Boolean itemMaterial;
public boolean isItemMaterialReal()
{
return ((this.requirement != null) && (this.requirement.getKind() == Constants.REQ_TYPE_MATERIAL));
}
public Boolean getItemMaterial()
{
return this.itemMaterial;
}
public void setItemMaterial(Boolean value)
{
this.itemMaterial = value;
}
@Override @Override
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
@@ -0,0 +1,50 @@
package info.bukova.isspst.data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.math.BigDecimal;
/**
* @author Pepa Rokos
*/
@Entity
@Table(name = "LIMITS")
public class Limit extends BaseData implements SeasonsAware {
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "WORKGROUP_ID")
private Workgroup workgroup;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
private Season season;
@Column(name = "REQ_LIMIT", precision = 15, scale = 4)
private BigDecimal limit;
public Workgroup getWorkgroup() {
return workgroup;
}
public void setWorkgroup(Workgroup workgroup) {
this.workgroup = workgroup;
}
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
public BigDecimal getLimit() {
return limit;
}
public void setLimit(BigDecimal limit) {
this.limit = limit;
}
}
@@ -1,8 +1,9 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import java.util.ArrayList; import org.hibernate.annotations.Cache;
import java.util.Date; import org.hibernate.annotations.CacheConcurrencyStrategy;
import java.util.List; import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
@@ -15,12 +16,13 @@ import javax.persistence.JoinColumn;
import javax.persistence.JoinTable; import javax.persistence.JoinTable;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.persistence.Transient; import javax.persistence.Transient;
import java.util.ArrayList;
import org.hibernate.annotations.LazyCollection; import java.util.Date;
import org.hibernate.annotations.LazyCollectionOption; import java.util.List;
@Entity @Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public abstract class Member implements DataModel { public abstract class Member implements DataModel {
@Id @Id
@@ -33,6 +35,7 @@ public abstract class Member implements DataModel {
@ManyToMany @ManyToMany
@LazyCollection(LazyCollectionOption.TRUE) @LazyCollection(LazyCollectionOption.TRUE)
@JoinTable(name="MEMBER_PARENT", joinColumns={@JoinColumn(name="MEMBER_ID")}, inverseJoinColumns={@JoinColumn(name="PARENT_ID")}) @JoinTable(name="MEMBER_PARENT", joinColumns={@JoinColumn(name="MEMBER_ID")}, inverseJoinColumns={@JoinColumn(name="PARENT_ID")})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<Workgroup> parents; private List<Workgroup> parents;
@Transient @Transient
private boolean valid; private boolean valid;
@@ -2,6 +2,8 @@ package info.bukova.isspst.data;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
@Entity @Entity
@@ -17,6 +19,10 @@ public class NumberSeries extends BaseSimpleData
@Column(name = "NUMBER") @Column(name = "NUMBER")
private int number; private int number;
@OneToOne
@JoinColumn(name = "SEASON_ID")
private Season season;
public String getCurrentNumber() public String getCurrentNumber()
{ {
return String.format("%s%06d", this.getPrefix(), this.getNumber()); return String.format("%s%06d", this.getPrefix(), this.getNumber());
@@ -51,4 +57,12 @@ public class NumberSeries extends BaseSimpleData
{ {
this.number = number; this.number = number;
} }
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
} }
@@ -1,11 +1,13 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.Constants; import info.bukova.isspst.Constants;
import org.hibernate.annotations.LazyCollection;
import java.math.BigDecimal; import org.hibernate.annotations.LazyCollectionOption;
import java.util.ArrayList; import org.hibernate.search.annotations.Analyze;
import java.util.Date; import org.hibernate.search.annotations.Field;
import java.util.List; import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides; import javax.persistence.AttributeOverrides;
@@ -13,15 +15,20 @@ import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embedded; import javax.persistence.Embedded;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import java.math.BigDecimal;
import org.hibernate.annotations.LazyCollection; import java.util.ArrayList;
import org.hibernate.annotations.LazyCollectionOption; import java.util.Date;
import java.util.List;
@Entity @Entity
@Table(name = "ORDERS") @Table(name = "ORDERS")
public class Order extends BaseData implements Cloneable @Indexed
public class Order extends BaseData implements Cloneable, SeasonsAware
{ {
@Column(name = "NUMSER") @Column(name = "NUMSER")
@@ -47,6 +54,7 @@ public class Order extends BaseData implements Cloneable
@AttributeOverride(name = "street", column = @Column(name = "SUPPLIER_STREET")), @AttributeOverride(name = "street", column = @Column(name = "SUPPLIER_STREET")),
@AttributeOverride(name = "web", column = @Column(name = "SUPPLIER_WEB")), @AttributeOverride(name = "web", column = @Column(name = "SUPPLIER_WEB")),
@AttributeOverride(name = "zipCode", column = @Column(name = "SUPPLIER_ZIP_CODE")) }) @AttributeOverride(name = "zipCode", column = @Column(name = "SUPPLIER_ZIP_CODE")) })
@IndexedEmbedded
private AddressEmb suplier; private AddressEmb suplier;
@Embedded @Embedded
@@ -97,10 +105,12 @@ public class Order extends BaseData implements Cloneable
private String deliveryType; private String deliveryType;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Field(index = Index.YES, analyze = Analyze.YES)
private String description; private String description;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "order", orphanRemoval = true) @OneToMany(cascade = CascadeType.ALL, mappedBy = "order", orphanRemoval = true)
@LazyCollection(LazyCollectionOption.TRUE) @LazyCollection(LazyCollectionOption.TRUE)
@IndexedEmbedded
private List<OrderItem> items; private List<OrderItem> items;
@Column(name = "TOTAL", precision = 15, scale = 4) @Column(name = "TOTAL", precision = 15, scale = 4)
@@ -112,6 +122,10 @@ public class Order extends BaseData implements Cloneable
@Column(name = "DELIVERED") @Column(name = "DELIVERED")
private boolean delivered; private boolean delivered;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
private Season season;
public Order() public Order()
{ {
this.items = new ArrayList<OrderItem>(); this.items = new ArrayList<OrderItem>();
@@ -279,4 +293,12 @@ public class Order extends BaseData implements Cloneable
cloned.setTotal(new BigDecimal(this.getTotal().toString())); cloned.setTotal(new BigDecimal(this.getTotal().toString()));
return cloned; return cloned;
} }
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
} }
@@ -14,8 +14,14 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
@Entity @Entity
@Table(name = "ORDER_ITEM") @Table(name = "ORDER_ITEM")
@Indexed
public class OrderItem public class OrderItem
{ {
@@ -28,9 +34,11 @@ public class OrderItem
private String code; private String code;
@Column(name = "NAME") @Column(name = "NAME")
@Field(index = Index.YES, analyze = Analyze.YES)
private String name; private String name;
@Column(name = "TEXTITEM") @Column(name = "TEXTITEM")
@Field(index = Index.YES, analyze = Analyze.YES)
private String textItem; private String textItem;
@Column(name = "QUANTITY", precision = 15, scale = 4) @Column(name = "QUANTITY", precision = 15, scale = 4)
@@ -46,6 +54,7 @@ public class OrderItem
private BigDecimal total; private BigDecimal total;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Field(index = Index.YES, analyze = Analyze.YES)
private String description; private String description;
@ManyToOne(fetch = FetchType.EAGER) @ManyToOne(fetch = FetchType.EAGER)
@@ -1,6 +1,9 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.Constants; import info.bukova.isspst.Constants;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.security.core.GrantedAuthority;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
@@ -8,10 +11,9 @@ import javax.persistence.EnumType;
import javax.persistence.Enumerated; import javax.persistence.Enumerated;
import javax.persistence.Table; import javax.persistence.Table;
import org.springframework.security.core.GrantedAuthority;
@Entity @Entity
@Table(name="PERMISSION") @Table(name="PERMISSION")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Permission extends BaseSimpleData implements GrantedAuthority { public class Permission extends BaseSimpleData implements GrantedAuthority {
/** /**
@@ -1,9 +1,7 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import java.math.BigDecimal; import org.hibernate.search.annotations.Indexed;
import java.util.ArrayList; import org.hibernate.search.annotations.IndexedEmbedded;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
@@ -11,12 +9,18 @@ import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Entity @Entity
@Table(name = "REQUIREMENT") @Table(name = "REQUIREMENT")
@Indexed
public class Requirement extends RequirementBase public class Requirement extends RequirementBase
{ {
@OneToMany(fetch = FetchType.LAZY, mappedBy = "requirement", cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(fetch = FetchType.LAZY, mappedBy = "requirement", cascade = CascadeType.ALL, orphanRemoval = true)
@IndexedEmbedded
private List<RequirementItem> items; private List<RequirementItem> items;
@Column(name = "DELIVERYDATE") @Column(name = "DELIVERYDATE")
@@ -1,10 +1,14 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.Constants; import info.bukova.isspst.Constants;
import org.hibernate.annotations.Cache;
import java.util.ArrayList; import org.hibernate.annotations.CacheConcurrencyStrategy;
import java.util.Date; import org.hibernate.annotations.LazyCollection;
import java.util.List; import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
@@ -16,12 +20,14 @@ import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OrderBy; import javax.persistence.OrderBy;
import java.util.ArrayList;
import org.hibernate.annotations.LazyCollection; import java.util.Date;
import org.hibernate.annotations.LazyCollectionOption; import java.util.List;
@MappedSuperclass @MappedSuperclass
public class RequirementBase extends BaseData implements FilterableRequirement { @Indexed
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class RequirementBase extends BaseData implements FilterableRequirement, SeasonsAware {
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TYPE_ID") @JoinColumn(name = "TYPE_ID")
@@ -31,16 +37,20 @@ public class RequirementBase extends BaseData implements FilterableRequirement {
@OrderBy("CENTRE, WORDER") @OrderBy("CENTRE, WORDER")
private List<Workflow> workflow; private List<Workflow> workflow;
@Column(name = "NUMSER", unique = true) @Column(name = "NUMSER", unique = true)
@Field(index = Index.YES, analyze = Analyze.YES)
private String numser; private String numser;
@Column(name = "REQ_DATE") @Column(name = "REQ_DATE")
private Date reqDate; private Date reqDate;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Field(index = Index.YES, analyze = Analyze.YES)
private String description; private String description;
@ManyToOne(fetch = FetchType.EAGER) @ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "CENTRE_ID") @JoinColumn(name = "CENTRE_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Workgroup centre; private Workgroup centre;
@ManyToOne(fetch = FetchType.EAGER) @ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "WORKGROUP_ID") @JoinColumn(name = "WORKGROUP_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Workgroup workgroup; private Workgroup workgroup;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@LazyCollection(LazyCollectionOption.TRUE) @LazyCollection(LazyCollectionOption.TRUE)
@@ -49,6 +59,10 @@ public class RequirementBase extends BaseData implements FilterableRequirement {
@Column(name = "STATE") @Column(name = "STATE")
@Enumerated(EnumType.ORDINAL) @Enumerated(EnumType.ORDINAL)
private RequirementState state; private RequirementState state;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Season season;
public RequirementBase() { public RequirementBase() {
authorization = new ArrayList<AuthItem>(); authorization = new ArrayList<AuthItem>();
@@ -145,4 +159,11 @@ public class RequirementBase extends BaseData implements FilterableRequirement {
return authorization.get(authorization.size() - 1).getAuthDate(); return authorization.get(authorization.size() - 1).getAuthDate();
} }
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
} }
@@ -14,8 +14,15 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
@Entity @Entity
@Table(name = "REQUIREMENT_ITEMS") @Table(name = "REQUIREMENT_ITEMS")
@Indexed
public class RequirementItem public class RequirementItem
{ {
@Id @Id
@@ -35,9 +42,11 @@ public class RequirementItem
private String code; private String code;
@Column(name = "NAME") @Column(name = "NAME")
@Field(index = Index.YES, analyze = Analyze.YES)
private String name; private String name;
@Column(name = "TEXTITEM") @Column(name = "TEXTITEM")
@Field(index = Index.YES, analyze = Analyze.YES)
private String textItem; private String textItem;
@Column(name = "QUANTITY", precision=15, scale=4) @Column(name = "QUANTITY", precision=15, scale=4)
@@ -53,6 +62,7 @@ public class RequirementItem
private BigDecimal total; private BigDecimal total;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Field(index = Index.YES, analyze = Analyze.YES)
private String description; private String description;
@Column(name = "DELIVERED") @Column(name = "DELIVERED")
@@ -1,9 +1,11 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.Constants; import info.bukova.isspst.Constants;
import org.hibernate.annotations.Cache;
import java.util.ArrayList; import org.hibernate.annotations.CacheConcurrencyStrategy;
import java.util.List; import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.springframework.security.core.GrantedAuthority;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
@@ -11,13 +13,12 @@ import javax.persistence.JoinColumn;
import javax.persistence.JoinTable; import javax.persistence.JoinTable;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.persistence.Table; import javax.persistence.Table;
import java.util.ArrayList;
import org.hibernate.annotations.LazyCollection; import java.util.List;
import org.hibernate.annotations.LazyCollectionOption;
import org.springframework.security.core.GrantedAuthority;
@Entity @Entity
@Table(name="ROLE") @Table(name="ROLE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Role extends BaseSimpleData implements GrantedAuthority, DataModel { public class Role extends BaseSimpleData implements GrantedAuthority, DataModel {
/** /**
@@ -32,6 +33,7 @@ public class Role extends BaseSimpleData implements GrantedAuthority, DataModel
@ManyToMany @ManyToMany
@LazyCollection(LazyCollectionOption.FALSE) @LazyCollection(LazyCollectionOption.FALSE)
@JoinTable(name="ROLE_PERMISSION", joinColumns={@JoinColumn(name="ROLE_ID")}, inverseJoinColumns={@JoinColumn(name="PERMISSION_ID")}) @JoinTable(name="ROLE_PERMISSION", joinColumns={@JoinColumn(name="ROLE_ID")}, inverseJoinColumns={@JoinColumn(name="PERMISSION_ID")})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<Permission> permissions; private List<Permission> permissions;
@Column(name = "WORKGROUP") @Column(name = "WORKGROUP")
private boolean workgroup; private boolean workgroup;
@@ -0,0 +1,83 @@
package info.bukova.isspst.data;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
* @author Pepa Rokos
*/
@Entity
@Table(name = "SEASON")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Season extends BaseData {
@Column(name = "DESCRIPTION")
private String description;
@Column(name = "VALID_FROM")
private Date validFrom;
@Column(name = "VALID_TO")
private Date validTo;
@Column(name = "ACTIVE")
private boolean active;
public String getDescription() {
return description;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Season)) return false;
Season season = (Season) o;
if (getId() != season.getId()) return false;
if (active != season.active) return false;
if (description != null ? !description.equals(season.description) : season.description != null) return false;
if (validFrom != null ? !validFrom.equals(season.validFrom) : season.validFrom != null) return false;
if (validTo != null ? !validTo.equals(season.validTo) : season.validTo != null) return false;
return true;
}
@Override
public int hashCode() {
int result = description != null ? description.hashCode() : 0;
result = 31 * result + (validFrom != null ? validFrom.hashCode() : 0);
result = 31 * result + (validTo != null ? validTo.hashCode() : 0);
result = 31 * result + (active ? 1 : 0);
return result;
}
public void setDescription(String description) {
this.description = description;
}
public Date getValidFrom() {
return validFrom;
}
public void setValidFrom(Date validFrom) {
this.validFrom = validFrom;
}
public Date getValidTo() {
return validTo;
}
public void setValidTo(Date validTo) {
this.validTo = validTo;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
}
@@ -0,0 +1,8 @@
package info.bukova.isspst.data;
/**
* @author Pepa Rokos
*/
public interface SeasonsAware {
public Season getSeason();
}
@@ -14,6 +14,8 @@ public class SettingsData {
private MailMessage newReqTemplate; private MailMessage newReqTemplate;
private MailMessage authReqTemplate; private MailMessage authReqTemplate;
private MailMessage confReqTemplate; private MailMessage confReqTemplate;
private MailMessage confReqTripPassenger;
private MailMessage reqPassenger;
private Address mainAddress; private Address mainAddress;
private List<Address> shippingAddrs; private List<Address> shippingAddrs;
private String bankName; private String bankName;
@@ -22,11 +24,14 @@ public class SettingsData {
private List<Vehicle> vehicles; private List<Vehicle> vehicles;
private Map<Integer, BigDecimal[]> refunds; private Map<Integer, BigDecimal[]> refunds;
private String stampFile; private String stampFile;
private String logoFile;
public SettingsData() { public SettingsData() {
newReqTemplate = new MailMessage(); newReqTemplate = new MailMessage();
authReqTemplate = new MailMessage(); authReqTemplate = new MailMessage();
confReqTemplate = new MailMessage(); confReqTemplate = new MailMessage();
confReqTripPassenger = new MailMessage();
reqPassenger = new MailMessage();
mainAddress = new Address(); mainAddress = new Address();
shippingAddrs = new ArrayList<Address>(); shippingAddrs = new ArrayList<Address>();
vehicles = new ArrayList<Vehicle>(); vehicles = new ArrayList<Vehicle>();
@@ -140,4 +145,29 @@ public class SettingsData {
this.stampFile = stampFile; this.stampFile = stampFile;
} }
public String getLogoFile()
{
return logoFile;
}
public void setLogoFile(String logoFile)
{
this.logoFile = logoFile;
}
public MailMessage getConfReqTripPassenger() {
return confReqTripPassenger;
}
public void setConfReqTripPassenger(MailMessage confReqTripPassenger) {
this.confReqTripPassenger = confReqTripPassenger;
}
public MailMessage getReqPassenger() {
return reqPassenger;
}
public void setReqPassenger(MailMessage reqPassenger) {
this.reqPassenger = reqPassenger;
}
} }
@@ -0,0 +1,123 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import info.bukova.isspst.Module;
import info.bukova.isspst.StringUtils;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.annotations.IndexedEmbedded;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Entity
@Table(name = "SIGNED_DOCUMENTS")
public class SignedDocument extends BaseData {
@Transient
private String agendaName;
@Column(name = "MODULE_NAME", length = Constants.LEN_TEXT)
private String moduleName;
@Column(name = "RECORD_ID")
private int recordId;
@Column(name = "NUMSER", length = Constants.LEN_TEXT)
private String numser;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
private String description;
@Column(name = "SIGN_DATE")
private Date signDate;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "signedDocument", orphanRemoval = true)
@LazyCollection(LazyCollectionOption.TRUE)
@IndexedEmbedded
private List<SignedDocumentItem> items;
public SignedDocument() {
}
public String getModuleName() {
return moduleName;
}
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}
public int getRecordId() {
return recordId;
}
public void setRecordId(int recordId) {
this.recordId = recordId;
}
public String getNumser() {
return numser;
}
public void setNumser(String numser) {
this.numser = numser;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getSignDate() {
return signDate;
}
public void setSignDate(Date signDate) {
this.signDate = signDate;
}
public String getAgendaName() {
if (!StringUtils.isNullOrEmpty(this.agendaName)) {
return this.agendaName;
}
if (StringUtils.isNullOrEmpty(this.moduleName)) {
return "";
}
for (Module m : Constants.MODULES) {
if (this.moduleName.equals(m.getId())) {
return m.getName();
}
}
return "";
}
public void setAgendaName(String agendaName) {
this.agendaName = agendaName;
}
public List<SignedDocumentItem> getItems() {
return items;
}
public void setItems(List<SignedDocumentItem> items) {
this.items = items;
}
public void addItem(SignedDocumentItem item) {
if (items == null) {
items = new ArrayList<SignedDocumentItem>();
}
item.setSignedDocument(this);
this.items.add(item);
}
}
@@ -0,0 +1,88 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import info.bukova.isspst.reporting.Report;
import info.bukova.isspst.reporting.ReportMapping;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "SIGNED_DOCUMENTS_ITEMS")
public class SignedDocumentItem {
@Id
@Column(name = "ID")
@GeneratedValue
private int id;
@Column(name = "REPORT_ID")
private long reportId;
@Column(name = "REPORT_NAME", length = Constants.LEN_TEXT)
private String reportName;
@Column(name = "FILENAME", length = Constants.LEN_TEXT)
private String fileName;
@ManyToOne
@JoinColumn(name = "SIGNED_DOCUMENT_ID")
private SignedDocument signedDocument;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public long getReportId() {
return reportId;
}
public void setReportId(long reportId) {
this.reportId = reportId;
}
public String getReportName() {
return reportName;
}
public void setReportName(String reportName) {
this.reportName = reportName;
}
public String getActualReportName() {
for (ReportMapping rm : Constants.REPORTS) {
Report rep = rm.getReport();
if (this.reportId == rep.getReportId()) {
return rep.getName();
}
}
return reportName;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public SignedDocument getSignedDocument() {
return signedDocument;
}
public void setSignedDocument(SignedDocument signedDocument) {
this.signedDocument = signedDocument;
}
}
@@ -1,33 +1,49 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import java.math.BigDecimal; import info.bukova.isspst.Constants;
import java.util.ArrayList; import info.bukova.isspst.storage.EntityWithAttachment;
import java.util.Date; import org.hibernate.annotations.Cache;
import java.util.List; import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import java.math.BigDecimal;
import org.hibernate.annotations.LazyCollection; import java.util.ArrayList;
import org.hibernate.annotations.LazyCollectionOption; import java.util.Date;
import java.util.List;
@Entity @Entity
@Table(name = "TRIP_BILL") @Table(name = "TRIP_BILL")
public class TripBill extends BaseData { @Indexed
public class TripBill extends BaseData implements EntityWithAttachment, SeasonsAware {
@OneToOne(fetch = FetchType.EAGER) @OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "REQUIREMENT_ID") @JoinColumn(name = "REQUIREMENT_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private TripRequirement requirement; private TripRequirement requirement;
@Column(name = "RESULT_MESSAGE_DATE") @Column(name = "RESULT_MESSAGE_DATE")
private Date resultMessageDate; private Date resultMessageDate;
@Column(name = "SIGN_DATE") @Column(name = "SIGN_DATE")
private Date signDate; private Date signDate;
@Column(name = "RESULT_MESSAGE", length = Constants.LEN_RESULT_MESSAGE)
@Field(index = Index.YES, analyze = Analyze.YES)
private String resultMessage;
@Column(name = "FREE_MEALS") @Column(name = "FREE_MEALS")
private boolean freeMeals; private boolean freeMeals;
@Column(name = "FREE_HOUSING") @Column(name = "FREE_HOUSING")
@@ -44,9 +60,27 @@ public class TripBill extends BaseData {
private BigDecimal downPayment; private BigDecimal downPayment;
@Column(name = "TOTAL", precision = 15, scale = 4) @Column(name = "TOTAL", precision = 15, scale = 4)
private BigDecimal total; private BigDecimal total;
@OneToMany(cascade = CascadeType.ALL)
@LazyCollection(LazyCollectionOption.TRUE)
@IndexedEmbedded
private List<FileMetainfo> attachedFiles;
@OneToOne(fetch = FetchType.EAGER, orphanRemoval = true)
@JoinColumn(name = "APPROVAL_ID")
private TripBillApproval approval;
@Column(name = "SAVED")
private Boolean saved; // Nastaveno na true, pokud uživatel udělá změnu- nepřenáší se pak částky od žadatele
@Column(name = "PAID")
private Boolean paid;
@Column(name = "PAID_DATE")
private Date paidDate;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Season season;
public TripBill() { public TripBill() {
billItems = new ArrayList<TripBillItem>(); billItems = new ArrayList<TripBillItem>();
attachedFiles = new ArrayList<FileMetainfo>();
} }
public TripRequirement getRequirement() { public TripRequirement getRequirement() {
@@ -73,6 +107,16 @@ public class TripBill extends BaseData {
this.signDate = signDate; this.signDate = signDate;
} }
public String getResultMessage()
{
return resultMessage;
}
public void setResultMessage(String resultMessage)
{
this.resultMessage = resultMessage;
}
public boolean isFreeMeals() { public boolean isFreeMeals() {
return freeMeals; return freeMeals;
} }
@@ -121,4 +165,62 @@ public class TripBill extends BaseData {
this.total = total; this.total = total;
} }
public List<FileMetainfo> getAttachedFiles() {
return attachedFiles;
}
@Override
public void addAttachment(FileMetainfo metaInfo) {
attachedFiles.add(metaInfo);
}
@Override
public void removeAttachment(FileMetainfo metainfo) {
attachedFiles.remove(metainfo);
}
public void setAttachedFiles(List<FileMetainfo> attachedFiles) {
this.attachedFiles = attachedFiles;
}
public TripBillApproval getApproval() {
return approval;
}
public void setApproval(TripBillApproval approval) {
this.approval = approval;
}
public Boolean getSaved() {
return saved;
}
public void setSaved(Boolean saved) {
this.saved = saved;
}
public Boolean getPaid() {
return paid;
}
public void setPaid(Boolean paid) {
this.paid = paid;
}
public Date getPaidDate() {
return paidDate;
}
public void setPaidDate(Date paidDate) {
this.paidDate = paidDate;
}
@Override
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
} }
@@ -0,0 +1,76 @@
package info.bukova.isspst.data;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
* @author Pepa Rokos
*/
@Entity
@Table(name = "TRIP_BILL_APPROVAL")
public class TripBillApproval extends RequirementBase {
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "TRIPBILL_ID")
private TripBill bill;
@Transient
private boolean billForPassenger;
@Transient
private Date approveDate;
@Transient
private Date tripDate;
public boolean isBillForPassenger() {
return billForPassenger;
}
public void setBillForPassenger(boolean billForPassenger) {
this.billForPassenger = billForPassenger;
}
public Date getTripDate() {
return tripDate;
}
public void setTripDate(Date tripDate) {
this.tripDate = tripDate;
}
public Date getApproveDate() {
return approveDate;
}
public void setApproveDate(Date approveDate) {
this.approveDate = approveDate;
}
@Override
public String getNumser() {
if (bill == null) {
return "";
}
TripRequirement tr = bill.getRequirement();
if (tr == null) {
return "";
}
return tr.getNumser();
}
public TripBill getBill() {
return bill;
}
public void setBill(TripBill bill) {
this.bill = bill;
}
}
@@ -2,15 +2,14 @@ package info.bukova.isspst.data;
import info.bukova.isspst.Constants; import info.bukova.isspst.Constants;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides; import javax.persistence.AttributeOverrides;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embedded; import javax.persistence.Embedded;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;
@Entity @Entity
@Table(name = "TRIP_BILL_ITEMS") @Table(name = "TRIP_BILL_ITEMS")
@@ -65,6 +64,35 @@ public class TripBillItem extends BaseData {
@Column(name = "ADJUSTED_TOTAL", precision = 15, scale = 4) @Column(name = "ADJUSTED_TOTAL", precision = 15, scale = 4)
private BigDecimal adjustedTotal; private BigDecimal adjustedTotal;
public TripBillItem() {
}
public TripBillItem(TripBillItem src) {
date = src.getDate();
to = src.getTo();
back = src.getBack();
toDeparture = src.getToDeparture();
toArrival = src.getToArrival();
backDeparture = src.getBackDeparture();
backArrival = src.getBackArrival();
toVehicle = src.getToVehicle();
backVehicle = src.getBackVehicle();
beginWork = src.getBeginWork();
endWork = src.getEndWork();
freeMealsCount = src.getFreeMealsCount();
distance = src.getDistance();
fuelConsumption = src.getFuelConsumption();
distanceAmount = src.getDistanceAmount();
fuelAmount = src.getFuelAmount();
carefare = src.getCarefare();
housing = src.getHousing();
meals = src.getMeals();
otherExpenses = src.getOtherExpenses();
total = src.getTotal();
adjustedTotal = src.getAdjustedTotal();
}
public Date getDate() { public Date getDate() {
return date; return date;
} }
@@ -1,28 +1,38 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import java.math.BigDecimal; import info.bukova.isspst.storage.EntityWithAttachment;
import java.util.ArrayList; import org.hibernate.annotations.LazyCollection;
import java.util.Date; import org.hibernate.annotations.LazyCollectionOption;
import java.util.List; import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embedded; import javax.persistence.Embedded;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinTable; import javax.persistence.JoinTable;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import java.math.BigDecimal;
import org.hibernate.annotations.LazyCollection; import java.util.ArrayList;
import org.hibernate.annotations.LazyCollectionOption; import java.util.Date;
import java.util.List;
@Entity @Entity
@Table(name = "TRIPREQUIREMENT") @Table(name = "TRIPREQUIREMENT")
public class TripRequirement extends RequirementBase { @Indexed
public class TripRequirement extends RequirementBase implements EntityWithAttachment {
@Column(name = "TRIP_FROM") @Column(name = "TRIP_FROM")
@Field(index = Index.YES, analyze = Analyze.YES)
private String from; private String from;
@Column(name = "TRIP_TO") @Column(name = "TRIP_TO")
@Field(index = Index.YES, analyze = Analyze.YES)
private String to; private String to;
@Column(name = "TRIP_DATE") @Column(name = "TRIP_DATE")
private Date tripDate; private Date tripDate;
@@ -34,16 +44,28 @@ public class TripRequirement extends RequirementBase {
@LazyCollection(LazyCollectionOption.TRUE) @LazyCollection(LazyCollectionOption.TRUE)
@JoinTable(name="TRIPREQUIREMENT_PASSANGER", joinColumns={@JoinColumn(name="TRIPREQUIREMENT_ID")}, inverseJoinColumns={@JoinColumn(name="USER_ID")}) @JoinTable(name="TRIPREQUIREMENT_PASSANGER", joinColumns={@JoinColumn(name="TRIPREQUIREMENT_ID")}, inverseJoinColumns={@JoinColumn(name="USER_ID")})
private List<User> passengers; private List<User> passengers;
@Column(name = "FOREIGN_PERSONS")
@Field(index = Index.YES, analyze = Analyze.YES)
private String foreignPersons;
@Embedded @Embedded
private Vehicle vehicle; private Vehicle vehicle;
@Column(name = "REQUIRE_DOWN_PAYMENT") @Column(name = "REQUIRE_DOWN_PAYMENT")
private Boolean requireDownPayment; private Boolean requireDownPayment;
@Column(name = "DOWN_PAYMENT", precision = 15, scale = 4) @Column(name = "DOWN_PAYMENT", precision = 15, scale = 4)
private BigDecimal downPayment; private BigDecimal downPayment;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@LazyCollection(LazyCollectionOption.TRUE)
@IndexedEmbedded
private List<FileMetainfo> attachedFiles;
@Column(name = "BILL_FOR_PASSENGERS")
private Boolean billForPassengers;
public TripRequirement() { public TripRequirement() {
this.setOwnedBy(new User()); this.setOwnedBy(new User());
passengers = new ArrayList<User>(); passengers = new ArrayList<User>();
attachedFiles = new ArrayList<FileMetainfo>();
} }
public String getFrom() { public String getFrom() {
@@ -94,6 +116,16 @@ public class TripRequirement extends RequirementBase {
this.passengers = passengers; this.passengers = passengers;
} }
public String getForeignPersons()
{
return foreignPersons;
}
public void setForeignPersons(String foreignPersons)
{
this.foreignPersons = foreignPersons;
}
public Vehicle getVehicle() { public Vehicle getVehicle() {
return vehicle; return vehicle;
} }
@@ -118,4 +150,30 @@ public class TripRequirement extends RequirementBase {
this.downPayment = downPayment; this.downPayment = downPayment;
} }
@Override
public List<FileMetainfo> getAttachedFiles() {
return attachedFiles;
}
public void setAttachedFiles(List<FileMetainfo> attachedFiles) {
this.attachedFiles = attachedFiles;
}
@Override
public void addAttachment(FileMetainfo metaInfo) {
attachedFiles.add(metaInfo);
}
@Override
public void removeAttachment(FileMetainfo metainfo) {
attachedFiles.remove(metainfo);
}
public Boolean getBillForPassengers() {
return billForPassengers;
}
public void setBillForPassengers(Boolean billForPassengers) {
this.billForPassengers = billForPassengers;
}
} }
@@ -1,9 +1,13 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.StringUtils; import info.bukova.isspst.StringUtils;
import org.hibernate.annotations.Cache;
import java.util.ArrayList; import org.hibernate.annotations.CacheConcurrencyStrategy;
import java.util.List; import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.springframework.security.core.userdetails.UserDetails;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embedded; import javax.persistence.Embedded;
@@ -13,11 +17,13 @@ import javax.persistence.JoinColumn;
import javax.persistence.JoinTable; import javax.persistence.JoinTable;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.persistence.Table; import javax.persistence.Table;
import java.util.ArrayList;
import org.springframework.security.core.userdetails.UserDetails; import java.util.List;
@Entity @Entity
@Table(name="USER") @Table(name="USER")
@Indexed
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class User extends Member implements UserDetails, DataModel { public class User extends Member implements UserDetails, DataModel {
/** /**
@@ -32,8 +38,10 @@ public class User extends Member implements UserDetails, DataModel {
@Column(name="ENABLED") @Column(name="ENABLED")
private boolean enabled; private boolean enabled;
@Column(name="FIRST_NAME") @Column(name="FIRST_NAME")
@Field(index = Index.YES, analyze = Analyze.YES)
private String firstName; private String firstName;
@Column(name="LAST_NAME") @Column(name="LAST_NAME")
@Field(index = Index.YES, analyze = Analyze.YES)
private String lastName; private String lastName;
@Column(name="PERSONAL_NUMBER") @Column(name="PERSONAL_NUMBER")
private String personalNumber; private String personalNumber;
@@ -43,6 +51,7 @@ public class User extends Member implements UserDetails, DataModel {
private boolean notify; private boolean notify;
@ManyToMany(fetch=FetchType.EAGER) @ManyToMany(fetch=FetchType.EAGER)
@JoinTable(name="USER_ROLE", joinColumns={@JoinColumn(name="USER_ID")}, inverseJoinColumns={@JoinColumn(name="ROLE_ID")}) @JoinTable(name="USER_ROLE", joinColumns={@JoinColumn(name="USER_ID")}, inverseJoinColumns={@JoinColumn(name="ROLE_ID")})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<Role> authorities; private List<Role> authorities;
@Column(name="SETTINGS", length=1048576) @Column(name="SETTINGS", length=1048576)
private String settings; private String settings;
@@ -1,5 +1,10 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.StringUtils;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embeddable; import javax.persistence.Embeddable;
@@ -47,4 +52,22 @@ public class UsersAddress {
this.city = city; this.city = city;
} }
public String toString() {
List<String> list = new ArrayList<String>();
list.add(this.street);
list.add(this.houseNumber);
final String s1 = StringUtils.joinNotEmpty(list, " ");
list.clear();
list.add(this.zipCode);
list.add(this.city);
final String s2 = StringUtils.joinNotEmpty(list, " ");
list.clear();
list.add(s1);
list.add(s2);
final String s = StringUtils.joinNotEmpty(list, ", ");
return s;
}
} }
@@ -1,15 +1,14 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import java.math.BigDecimal; import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import java.math.BigDecimal;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
@Entity @Entity
@Table(name = "WORKFLOW") @Table(name = "WORKFLOW")
@@ -24,7 +23,9 @@ public class Workflow extends BaseData {
@Column(name = "WORDER") @Column(name = "WORDER")
private Integer wOrder; private Integer wOrder;
@Column(name = "WLIMIT", precision=15, scale=4) @Column(name = "WLIMIT", precision=15, scale=4)
private BigDecimal limit; private BigDecimal limit;
@Column(name = "SIGNATURE")
private Boolean signature;
public Boolean getCentre() { public Boolean getCentre() {
return centre; return centre;
@@ -68,4 +69,11 @@ public class Workflow extends BaseData {
this.limit = limit; this.limit = limit;
} }
public Boolean getSignature() {
return signature;
}
public void setSignature(Boolean signature) {
this.signature = signature;
}
} }
@@ -1,11 +1,10 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.StringUtils; import info.bukova.isspst.StringUtils;
import org.hibernate.annotations.Cache;
import java.io.Serializable; import org.hibernate.annotations.CacheConcurrencyStrategy;
import java.math.BigDecimal; import org.hibernate.annotations.LazyCollection;
import java.util.ArrayList; import org.hibernate.annotations.LazyCollectionOption;
import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
@@ -17,12 +16,14 @@ import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import java.io.Serializable;
import org.hibernate.annotations.LazyCollection; import java.math.BigDecimal;
import org.hibernate.annotations.LazyCollectionOption; import java.util.ArrayList;
import java.util.List;
@Entity @Entity
@Table(name = "WORKGROUP") @Table(name = "WORKGROUP")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Workgroup extends Member implements OwnedDataModel, Serializable { public class Workgroup extends Member implements OwnedDataModel, Serializable {
/** /**
@@ -37,6 +38,7 @@ public class Workgroup extends Member implements OwnedDataModel, Serializable {
@ManyToMany(cascade = {CascadeType.ALL}) @ManyToMany(cascade = {CascadeType.ALL})
@LazyCollection(LazyCollectionOption.TRUE) @LazyCollection(LazyCollectionOption.TRUE)
@JoinTable(name="WORKGROUP_MEMBER", joinColumns={@JoinColumn(name="WORKGROUP_ID")}, inverseJoinColumns={@JoinColumn(name="JOBMAPPING_ID")}) @JoinTable(name="WORKGROUP_MEMBER", joinColumns={@JoinColumn(name="WORKGROUP_ID")}, inverseJoinColumns={@JoinColumn(name="JOBMAPPING_ID")})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<JobMapping> members; private List<JobMapping> members;
@Column(name = "CENTRE") @Column(name = "CENTRE")
private boolean centre; private boolean centre;
@@ -0,0 +1,57 @@
package info.bukova.isspst.filters;
import info.bukova.isspst.StringUtils;
import java.util.ArrayList;
import java.util.List;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listitem;
@SuppressWarnings("serial")
public class BooleanFilterListbox extends Listbox
{
class TristateBooleanListItem extends TristateBoolean
{
public TristateBooleanListItem(String text, int value)
{
this.setText(text);
this.setValue(value);
}
private String text;
public String getText()
{
return text;
}
public void setText(String text)
{
this.text = text;
}
}
public BooleanFilterListbox()
{
super();
List<TristateBooleanListItem> list = new ArrayList<TristateBooleanListItem>();
list.add(new TristateBooleanListItem(StringUtils.localize("LabelAll"), TristateBoolean.NULL));
list.add(new TristateBooleanListItem(StringUtils.localize("LabelNo"), TristateBoolean.FALSE));
list.add(new TristateBooleanListItem(StringUtils.localize("LabelYes"), TristateBoolean.TRUE));
for (int i = 0; i < list.size(); i++)
{
TristateBooleanListItem triStateItem = (TristateBooleanListItem) list.get(i);
this.appendItem(triStateItem.getText(), "");
Listitem item = this.getItemAtIndex(i);
item.setValue((TristateBoolean) triStateItem);
}
this.setSelectedIndex(0);
// this.setHflex("1");
this.setMold("select");
}
}
@@ -1,5 +1,6 @@
package info.bukova.isspst.filters; package info.bukova.isspst.filters;
import info.bukova.isspst.BooleanUtils;
import info.bukova.isspst.StringUtils; import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.JoinedItem; import info.bukova.isspst.data.JoinedItem;
import info.bukova.isspst.data.MUnitEmb; import info.bukova.isspst.data.MUnitEmb;
@@ -42,6 +43,7 @@ public class JoinedItemFilter implements Filter<JoinedItem>
@Override @Override
public boolean matchesSafely(JoinedItem item) public boolean matchesSafely(JoinedItem item)
{ {
boolean foundItemMaterial = BooleanUtils.isEqualFilterByBoolean(item.isItemMaterialReal(), condition.getItemMaterial());
boolean foundCode = StringUtils.isEqualForFilter(item.getCode(), condition.getCode()); boolean foundCode = StringUtils.isEqualForFilter(item.getCode(), condition.getCode());
boolean foundName = StringUtils.isEqualForFilter(item.getName(), condition.getName()); boolean foundName = StringUtils.isEqualForFilter(item.getName(), condition.getName());
boolean foundTextItem = StringUtils.isEqualForFilter(item.getTextItem(), condition.getTextItem()); boolean foundTextItem = StringUtils.isEqualForFilter(item.getTextItem(), condition.getTextItem());
@@ -56,7 +58,18 @@ public class JoinedItemFilter implements Filter<JoinedItem>
boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getCentre(), condition.getCentre()); boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getCentre(), condition.getCentre());
boolean foundOwner = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy()); boolean foundOwner = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription()); boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
return (foundCode && foundName && foundTextItem && foundDescription && foundQuantity && foundUnitPrice && foundMUnit && foundTotal && foundWorkgroup && foundCenter && foundOwner && foundDescription); return (foundItemMaterial
&& foundCode
&& foundName
&& foundTextItem
&& foundDescription
&& foundQuantity
&& foundUnitPrice
&& foundMUnit
&& foundTotal
&& foundWorkgroup
&& foundCenter
&& foundOwner && foundDescription);
} }
@Factory @Factory
@@ -1,5 +1,6 @@
package info.bukova.isspst.filters; package info.bukova.isspst.filters;
import info.bukova.isspst.BigDecimalUtils;
import info.bukova.isspst.BooleanUtils; import info.bukova.isspst.BooleanUtils;
import info.bukova.isspst.DateTimeUtils; import info.bukova.isspst.DateTimeUtils;
import info.bukova.isspst.StringUtils; import info.bukova.isspst.StringUtils;
@@ -47,8 +48,9 @@ public class RequirementFilter implements Filter<Requirement>
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription()); boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate()); boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate());
boolean foundUser = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy()); boolean foundUser = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
boolean foundProject = BooleanUtils.isEqualByBoolean(item.getProject(), condition.getProject()); boolean foundProject = BooleanUtils.isEqualByBooleanValue(item.getProject(), condition.getProject());
return (foundNumser && foundReqDate && foundCenter && foundDescription && foundDeliveryDate && foundUser && foundProject); boolean foundSumTotal = BigDecimalUtils.isEqualByDecimalForFilter(item.getSumTotal(), condition.getSumTotal());
return (foundNumser && foundReqDate && foundCenter && foundDescription && foundDeliveryDate && foundUser && foundProject && foundSumTotal);
} }
@Factory @Factory
@@ -0,0 +1,64 @@
package info.bukova.isspst.filters;
import info.bukova.isspst.DateTimeUtils;
import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.SignedDocument;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
public class SignedDocumentFilter implements Filter<SignedDocument>
{
private SignedDocument condition;
public SignedDocumentFilter(SignedDocument cond)
{
this.condition = cond;
}
private static class SignedDocumentMatcher extends TypeSafeMatcher<SignedDocument>
{
private SignedDocument condition;
public SignedDocumentMatcher(SignedDocument cond)
{
this.condition = cond;
}
@Override
public void describeTo(Description desc)
{
desc.appendText("SignedDocument matches");
}
@Override
public boolean matchesSafely(SignedDocument item)
{
boolean foundAgendaName = StringUtils.isEqualForFilter(item.getAgendaName(), condition.getAgendaName());
boolean foundNumSer = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser());
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
boolean foundSignDate = DateTimeUtils.isEqualByDateForFilter(item.getSignDate(), condition.getSignDate());
return (foundAgendaName && foundNumSer && foundDescription && foundSignDate);
}
@Factory
public static Matcher<SignedDocument> matchBuilding(SignedDocument item)
{
return new SignedDocumentMatcher(item);
}
}
@Override
public SignedDocumentMatcher matcher()
{
return new SignedDocumentMatcher(condition);
}
@Override
public String queryString()
{
return "";
}
}
@@ -0,0 +1,82 @@
package info.bukova.isspst.filters;
import info.bukova.isspst.BooleanUtils;
import info.bukova.isspst.DateTimeUtils;
import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.TripBillApproval;
import info.bukova.isspst.data.User;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
public class TripBillApprovalFilter implements Filter<TripBillApproval>
{
private TripBillApproval condition;
public TripBillApprovalFilter(TripBillApproval cond)
{
this.condition = cond;
}
private static class TripBillApprovalMatcher extends TypeSafeMatcher<TripBillApproval>
{
private TripBillApproval condition;
public TripBillApprovalMatcher(TripBillApproval cond)
{
this.condition = cond;
}
@Override
public void describeTo(Description desc)
{
desc.appendText("requirement matches");
}
@Override
public boolean matchesSafely(TripBillApproval item)
{
if (item.getBill() == null) {
return false;
}
boolean foundNumser = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser());
boolean foundReqDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getRequirement().getReqDate(), condition.getBill().getRequirement().getReqDate());
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
boolean foundFrom = StringUtils.isEqualForFilter(item.getBill().getRequirement().getFrom(), condition.getBill().getRequirement().getFrom());
boolean foundTo = StringUtils.isEqualForFilter(item.getBill().getRequirement().getTo(), condition.getBill().getRequirement().getTo());
boolean foundWorkgroup = (condition.getWorkgroup() == null ||(item.getWorkgroup() != null && item.getWorkgroup().equals(condition.getWorkgroup())));
boolean foundCentre = (condition.getCentre() == null || (item.getCentre() != null && item.getCentre().equals(condition.getCentre())));
boolean foundOwner = User.isEqualByUserForFilter(item.getBill().getOwnedBy(), condition.getBill().getOwnedBy());
boolean foundPaid = BooleanUtils.isEqualByBooleanValue(item.getBill().getPaid(), condition.getBill().getPaid());
boolean foundPaidDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getPaidDate(), condition.getBill().getPaidDate());
boolean foundPassenger = (item.getBill().getOwnedBy() != item.getBill().getRequirement().getOwnedBy()) == condition.isBillForPassenger();
boolean foundApproveDate = DateTimeUtils.isEqualByDateForFilter(item.getLastApproveDate(), condition.getApproveDate());
boolean foundTripDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getRequirement().getTripDate(), condition.getTripDate());
return foundNumser && foundReqDate && foundDescription && foundFrom && foundTo && foundWorkgroup && foundCentre && foundOwner && foundPaid
&& foundPaidDate && foundPassenger && foundApproveDate && foundTripDate;
}
@Factory
public static Matcher<TripBillApproval> matchTripRequirement(TripBillApproval building)
{
return new TripBillApprovalMatcher(building);
}
}
@Override
public TripBillApprovalMatcher matcher()
{
return new TripBillApprovalMatcher(condition);
}
@Override
public String queryString()
{
return "";
}
}
@@ -0,0 +1,87 @@
package info.bukova.isspst.filters;
import org.jfree.util.Log;
public class TristateBoolean
{
private static final String TAG = TristateBoolean.class.getSimpleName();
public static final int NULL = -1;
public static final int FALSE = 0;
public static final int TRUE = 1;
public static final int getValidValue(final int value)
{
if ((value != TristateBoolean.NULL) && (value != TristateBoolean.FALSE) && (value != TristateBoolean.TRUE))
{
Log.warn(TAG + "\nBad tristate boolean value.");
return TristateBoolean.NULL;
}
return value;
}
public TristateBoolean()
{
this.setValue(TristateBoolean.NULL);
}
public TristateBoolean(boolean value)
{
this.setValue(value ? TristateBoolean.TRUE : TristateBoolean.FALSE);
}
public TristateBoolean(int value)
{
this.setValue(value);
}
protected int value;
public int getValue()
{
return value;
}
public void setValue(int value)
{
this.value = TristateBoolean.getValidValue(value);
}
public Boolean getBoolean()
{
switch (this.value)
{
case TristateBoolean.FALSE:
return new Boolean(false);
case TristateBoolean.TRUE:
return new Boolean(true);
default:
return null;
}
}
@Override
public boolean equals(Object obj)
{
if (obj != null)
{
if (obj instanceof TristateBoolean)
{
TristateBoolean item = (TristateBoolean) obj;
int thisValue = this.getValue();
int itemValue = item.getValue();
return (thisValue == itemValue);
}
}
return false;
}
public boolean equals(int value)
{
return (this.getValue() == value);
}
}
@@ -1,5 +1,6 @@
package info.bukova.isspst.mail; package info.bukova.isspst.mail;
import info.bukova.isspst.Constants;
import info.bukova.isspst.EntityUrlResolver; import info.bukova.isspst.EntityUrlResolver;
import info.bukova.isspst.UrlResolverHolder; import info.bukova.isspst.UrlResolverHolder;
@@ -57,7 +58,7 @@ public class EntityMessageBuilder implements MessageBuilder {
for (String p : properties) { for (String p : properties) {
try { try {
if (p.equals("-url-")) { if (p.equals(Constants.MAIL_URL_KEYWORD)) {
ret = ret.replaceAll("\\[" + p + "\\]", getUrl(data)); ret = ret.replaceAll("\\[" + p + "\\]", getUrl(data));
} else { } else {
ret = ret.replaceAll("\\[" + p + "\\]", BeanUtils.getProperty(data, p)); ret = ret.replaceAll("\\[" + p + "\\]", BeanUtils.getProperty(data, p));
@@ -1,8 +1,7 @@
package info.bukova.isspst.reporting; package info.bukova.isspst.reporting;
import java.util.HashMap; import com.mysql.jdbc.StringUtils;
import java.util.Map; import info.bukova.isspst.data.Address;
import info.bukova.isspst.data.AuthItem; import info.bukova.isspst.data.AuthItem;
import info.bukova.isspst.data.Order; import info.bukova.isspst.data.Order;
import info.bukova.isspst.data.TripBill; import info.bukova.isspst.data.TripBill;
@@ -10,11 +9,16 @@ import info.bukova.isspst.data.User;
import info.bukova.isspst.data.UserSettingsData; import info.bukova.isspst.data.UserSettingsData;
import info.bukova.isspst.services.requirement.TripRequirementService; import info.bukova.isspst.services.requirement.TripRequirementService;
import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.settings.GlobalSettingsService;
import info.bukova.isspst.services.tripbill.TripBillApprovalService;
import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.storage.FileStorage; import info.bukova.isspst.storage.FileStorage;
import net.sf.jasperreports.engine.JRParameter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
public class ParamFiller { public class ParamFiller {
@Autowired @Autowired
@@ -27,6 +31,10 @@ public class ParamFiller {
private TripRequirementService tripReqService; private TripRequirementService tripReqService;
@Autowired @Autowired
private GlobalSettingsService settingService; private GlobalSettingsService settingService;
@Autowired
private TripBillApprovalService tripBillApprovalService;
@Autowired
private HttpServletRequest req;
public void fill() { public void fill() {
if (definition.getDataSet() == null || definition.getDataSet().isEmpty()) { if (definition.getDataSet() == null || definition.getDataSet().isEmpty()) {
@@ -45,6 +53,7 @@ public class ParamFiller {
if ((definition.getDataSet().get(0) instanceof TripBill) if ((definition.getDataSet().get(0) instanceof TripBill)
&& definition.getReport().isSingleRecord()) { && definition.getReport().isSingleRecord()) {
if (userService.getUserSettings().getSignatureFile() != null if (userService.getUserSettings().getSignatureFile() != null
&& !userService.getUserSettings().getSignatureFile().isEmpty()) { && !userService.getUserSettings().getSignatureFile().isEmpty()) {
definition.setParam("P_USER_SIGNATURE", storage.serverPath(userService.getUserSettings().getSignatureFile())); definition.setParam("P_USER_SIGNATURE", storage.serverPath(userService.getUserSettings().getSignatureFile()));
@@ -52,18 +61,32 @@ public class ParamFiller {
TripBill tb = (TripBill)definition.getDataSet().get(0); TripBill tb = (TripBill)definition.getDataSet().get(0);
tripReqService.loadAuthItems(tb.getRequirement()); tripReqService.loadAuthItems(tb.getRequirement());
AuthItem lastAuth = tb.getRequirement().getAuthorization().get(tb.getRequirement().getAuthorization().size() - 1);
if (tb.getApproval() != null) {
definition.setParam("P_APPROVE_DATE", lastAuth.getAuthDate()); tripBillApprovalService.loadAuthItems(tb.getApproval());
}
User u = lastAuth.getApprover();
if (tb.getApproval() != null && tb.getApproval().getAuthorization() != null && !tb.getApproval().getAuthorization().isEmpty()) {
UserSettingsData approverSettings = userService.getUserSettings(u);
AuthItem lastButOneAuth = tb.getApproval().getAuthorization().get(0);
if (approverSettings != null definition.setParam("P_PREV_APPROVE_DATE", lastButOneAuth.getAuthDate());
&& approverSettings.getSignatureFile() != null
&& !approverSettings.getSignatureFile().isEmpty()) { User lastButOneUser = lastButOneAuth.getApprover();
definition.setParam("P_APPROVER_SIGNATURE", storage.serverPath(approverSettings.getSignatureFile())); UserSettingsData prevApproverSettings = userService.getUserSettings(lastButOneUser);
if (prevApproverSettings != null && !StringUtils.isNullOrEmpty(prevApproverSettings.getSignatureFile())) {
definition.setParam("P_PREV_APPROVER_SIGNATURE", storage.serverPath(prevApproverSettings.getSignatureFile()));
}
AuthItem lastAuth = tb.getApproval().getAuthorization().get(tb.getApproval().getAuthorization().size() - 1);
definition.setParam("P_APPROVE_DATE", lastAuth.getAuthDate());
User u = lastAuth.getApprover();
UserSettingsData approverSettings = userService.getUserSettings(u);
if (approverSettings != null && !StringUtils.isNullOrEmpty(approverSettings.getSignatureFile())) {
definition.setParam("P_APPROVER_SIGNATURE", storage.serverPath(approverSettings.getSignatureFile()));
}
} }
} }
@@ -74,6 +97,16 @@ public class ParamFiller {
definition.setParam("P_STAMP", storage.serverPath(settingService.getSettings().getStampFile())); definition.setParam("P_STAMP", storage.serverPath(settingService.getSettings().getStampFile()));
} }
} }
definition.setParam("P_LOGO", storage.serverPath(settingService.getSettings().getLogoFile()));
definition.setParam(JRParameter.REPORT_LOCALE, req.getLocale());
Address mainAddress = settingService.getSettings().getMainAddress();
if (mainAddress != null) {
String addr = (StringUtils.isNullOrEmpty(mainAddress.getCompany()) ? "" : mainAddress.getCompany());
definition.setParam("P_MAIN_ADDRESS", addr);
}
} }
} }
@@ -1,18 +1,21 @@
package info.bukova.isspst.reporting; package info.bukova.isspst.reporting;
import java.io.File; import info.bukova.isspst.SpringUtils;
import info.bukova.isspst.data.DataModel;
import javax.servlet.ServletContext; import info.bukova.isspst.data.SignedDocumentItem;
import info.bukova.isspst.services.signeddocs.SignedDocumentService;
import org.slf4j.Logger; import info.bukova.isspst.storage.ReportFileStorage;
import org.slf4j.LoggerFactory;
import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperReport; import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.JasperRunManager; import net.sf.jasperreports.engine.JasperRunManager;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.util.JRLoader; import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.engine.util.JRProperties; import net.sf.jasperreports.engine.util.JRProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletContext;
import java.io.File;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class PredefinedGenerator implements Generator { public class PredefinedGenerator implements Generator {
@@ -20,7 +23,7 @@ public class PredefinedGenerator implements Generator {
private ReportDefinition definition; private ReportDefinition definition;
private ServletContext ctx; private ServletContext ctx;
private final static Logger logger = LoggerFactory.getLogger(PredefinedGenerator.class); private final static Logger logger = LoggerFactory.getLogger(PredefinedGenerator.class);
public PredefinedGenerator(ReportDefinition definition, ServletContext ctx) { public PredefinedGenerator(ReportDefinition definition, ServletContext ctx) {
this.definition = definition; this.definition = definition;
this.ctx = ctx; this.ctx = ctx;
@@ -29,7 +32,12 @@ public class PredefinedGenerator implements Generator {
@Override @Override
public byte[] generate() { public byte[] generate() {
byte[] bytes = null; byte[] bytes = null;
SignedDocumentItem signedItem = getSignedDocument();
if (signedItem != null) {
return fromStorage(signedItem);
}
try { try {
JasperReport report = (JasperReport) JRLoader.loadObject(getReportFile()); JasperReport report = (JasperReport) JRLoader.loadObject(getReportFile());
JRProperties.setProperty("net.sf.jasperreports.default.pdf.encoding", "Cp1250"); JRProperties.setProperty("net.sf.jasperreports.default.pdf.encoding", "Cp1250");
@@ -43,6 +51,18 @@ public class PredefinedGenerator implements Generator {
return bytes; return bytes;
} }
private byte[] fromStorage(SignedDocumentItem sdItem) {
ReportFileStorage reportStorage = SpringUtils.getBean(ReportFileStorage.class, ctx);
return reportStorage.fileData(sdItem);
}
private SignedDocumentItem getSignedDocument() {
SignedDocumentService sdService = SpringUtils.getBean(SignedDocumentService.class, ctx);
SignedDocumentItem sdItem = sdService.getItem((DataModel) definition.getDataSet().get(0), definition.getReport().getReportId());
return sdItem;
}
protected File getReportFile() { protected File getReportFile() {
return new File(ctx.getRealPath("WEB-INF/reports") + "/" + definition.getReport().getJasperFile() + ".jasper"); return new File(ctx.getRealPath("WEB-INF/reports") + "/" + definition.getReport().getJasperFile() + ".jasper");
@@ -4,48 +4,83 @@ package info.bukova.isspst.reporting;
public class Report { public class Report {
private ReportType type; private ReportType type;
private long reportId;
private boolean signable;
private String name; private String name;
private String jasperFile; private String jasperFile;
private boolean hasSettings; private boolean hasSettings;
private boolean singleRecord; private boolean singleRecord;
private boolean hasCondition;
private String property;
public Report() { public Report() {
this.reportId = 0;
this.signable = false;
hasSettings = false; hasSettings = false;
singleRecord = false; singleRecord = false;
hasCondition = false;
} }
/** /**
* @param reportId
* @param signable
* @param name * @param name
* @param jasperFile * @param jasperFile
*/ */
public Report(String name, String jasperFile) { public Report(long reportId, boolean signable, String name, String jasperFile) {
this(); this();
this.type = ReportType.DEFINED; this.type = ReportType.DEFINED;
this.reportId = reportId;
this.signable = signable;
this.name = name; this.name = name;
this.jasperFile = jasperFile; this.jasperFile = jasperFile;
} }
/** /**
* @param reportId
* @param signable
* @param name * @param name
* @param jasperFile * @param jasperFile
* @param hasSettings * @param hasSettings
*/ */
public Report(String name, String jasperFile, boolean hasSettings) { public Report(long reportId, boolean signable, String name, String jasperFile, boolean hasSettings) {
this(name, jasperFile); this(reportId, signable, name, jasperFile);
this.hasSettings = hasSettings; this.hasSettings = hasSettings;
} }
/** /**
* @param reportId
* @param signable
* @param name * @param name
* @param jasperFile * @param jasperFile
* @param hasSettings * @param hasSettings
* @param singleRecord * @param singleRecord
*/ */
public Report(String name, String jasperFile, boolean hasSettings, boolean singleRecord) { public Report(long reportId, boolean signable, String name, String jasperFile, boolean hasSettings, boolean singleRecord) {
this(name, jasperFile, hasSettings); this(reportId, signable, name, jasperFile, hasSettings);
this.singleRecord = singleRecord; this.singleRecord = singleRecord;
} }
public Report(long reportId, boolean signable, String name, String jasperFile, boolean hasSettings, boolean singleRecord, String property) {
this(reportId, signable, name, jasperFile, hasSettings, singleRecord);
this.property = property;
}
/**
*
* @param reportId
* @param signable
* @param name
* @param jasperFile
* @param hasSettings
* @param singleRecord
* @param hasCondition
*/
public Report(long reportId, boolean signable, String name, String jasperFile, boolean hasSettings, boolean singleRecord, boolean hasCondition) {
this(reportId, signable, name, jasperFile, hasSettings, singleRecord);
this.hasCondition = hasCondition;
}
public ReportType getType() { public ReportType getType() {
return type; return type;
} }
@@ -86,4 +121,35 @@ public class Report {
this.singleRecord = singleRecord; this.singleRecord = singleRecord;
} }
public boolean isHasCondition() {
return hasCondition;
}
public void setHasCondition(boolean hasCondition) {
this.hasCondition = hasCondition;
}
public long getReportId() {
return reportId;
}
public void setReportId(long reportId) {
this.reportId = reportId;
}
public boolean isSignable() {
return signable;
}
public void setSignable(boolean signable) {
this.signable = signable;
}
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
} }
@@ -1,17 +1,17 @@
package info.bukova.isspst.reporting; package info.bukova.isspst.reporting;
import java.io.IOException; import info.bukova.isspst.storage.ReportFileStorage;
import java.io.OutputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
@Controller @Controller
public class ReportController { public class ReportController {
@@ -21,6 +21,8 @@ public class ReportController {
private GeneratorFactory factory; private GeneratorFactory factory;
@Autowired @Autowired
private ParamFiller paramFiller; private ParamFiller paramFiller;
@Autowired
private ReportFileStorage reportFileStorage;
private static final String ERROR_MESSAGE = "<html><body><b>Generator returned no data!</b><br/>%s</body></html>"; private static final String ERROR_MESSAGE = "<html><body><b>Generator returned no data!</b><br/>%s</body></html>";
private final static Logger logger = LoggerFactory.getLogger(ReportController.class); private final static Logger logger = LoggerFactory.getLogger(ReportController.class);
@@ -46,13 +48,20 @@ public class ReportController {
try { try {
os = response.getOutputStream(); os = response.getOutputStream();
if (reportDefinition.getReport() == null || reportDefinition.getDataSet() == null) { if ((reportDefinition.getReport() == null || reportDefinition.getDataSet() == null) && reportDefinition.getSignedDocItem() == null) {
throw new ReportException("Definition is null"); throw new ReportException("Definition is null");
} }
paramFiller.fill(); byte[] data;
Generator gen = factory.createGenerator(reportDefinition);
byte[] data = gen.generate(); if (reportDefinition.getSignedDocItem() == null) {
paramFiller.fill();
Generator gen = factory.createGenerator(reportDefinition);
data = gen.generate();
} else {
data = reportFileStorage.fileData(reportDefinition.getSignedDocItem());
}
response.setContentType(contentType); response.setContentType(contentType);
response.setContentLength(data.length); response.setContentLength(data.length);
@@ -64,6 +73,9 @@ public class ReportController {
} catch (ReportException e) { } catch (ReportException e) {
logger.error("Report generation error: " + e.getMessage()); logger.error("Report generation error: " + e.getMessage());
writeError(os, e); writeError(os, e);
} catch (Exception e) {
logger.error("Report generation error: " + e.getMessage());
writeError(os, e);
} finally { } finally {
if (os != null) { if (os != null) {
try { try {
@@ -1,5 +1,6 @@
package info.bukova.isspst.reporting; package info.bukova.isspst.reporting;
import info.bukova.isspst.data.SignedDocumentItem;
import info.bukova.isspst.services.Service; import info.bukova.isspst.services.Service;
import java.io.Serializable; import java.io.Serializable;
@@ -20,6 +21,7 @@ public class ReportDefinition implements Serializable {
private List<String> fieldsToPrint; private List<String> fieldsToPrint;
private String reportTitle; private String reportTitle;
private Service<Object> service; private Service<Object> service;
private SignedDocumentItem signedDocItem;
public ReportDefinition() { public ReportDefinition() {
params = new HashMap<String, Object>(); params = new HashMap<String, Object>();
@@ -92,6 +94,7 @@ public class ReportDefinition implements Serializable {
reportTitle = ""; reportTitle = "";
service = null; service = null;
params.clear(); params.clear();
signedDocItem = null;
} }
public String getReportTitle() { public String getReportTitle() {
@@ -110,4 +113,11 @@ public class ReportDefinition implements Serializable {
this.service = service; this.service = service;
} }
public SignedDocumentItem getSignedDocItem() {
return signedDocItem;
}
public void setSignedDocItem(SignedDocumentItem signedDocItem) {
this.signedDocItem = signedDocItem;
}
} }
@@ -0,0 +1,68 @@
package info.bukova.isspst.reporting;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfFormField;
import com.lowagie.text.pdf.PdfName;
import net.sf.jasperreports.engine.JRGenericPrintElement;
import net.sf.jasperreports.engine.JRPropertiesMap;
import net.sf.jasperreports.engine.export.GenericElementHandler;
import net.sf.jasperreports.engine.export.GenericElementHandlerBundle;
import net.sf.jasperreports.engine.export.GenericElementPdfHandler;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.export.JRPdfExporterContext;
import net.sf.jasperreports.extensions.ExtensionsRegistry;
import net.sf.jasperreports.extensions.ExtensionsRegistryFactory;
import net.sf.jasperreports.extensions.SingletonExtensionRegistry;
/**
* @author Pepa Rokos
*/
public class SignaturePdfHandler implements GenericElementPdfHandler, GenericElementHandlerBundle, ExtensionsRegistryFactory {
@Override
public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) {
return new SingletonExtensionRegistry<GenericElementHandlerBundle>(GenericElementHandlerBundle.class, this);
}
@Override
public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element) {
//PdfFormField field = PdfFormField.createSignature(exporterContext.getPdfWriter());
PdfFormField field = PdfFormField.createTextField(exporterContext.getPdfWriter(), true, false, 255);
Object param = element.getParameterValue("index");
String index = param != null ? String.valueOf(param) : null;
if (index != null) {
field.setFieldName("signature-" + index);
} else {
field.setFieldName("signature");
}
field.put(PdfName.V, exporterContext.getPdfWriter().getPdfIndirectReference());
field.setFieldFlags(PdfFormField.FF_READ_ONLY);
field.setWidget(new Rectangle(element.getX(),
exporterContext.getExportedReport().getPageHeight() - element.getY(),
element.getX() + element.getWidth(),
exporterContext.getExportedReport().getPageHeight() - element.getY() - element.getHeight()), PdfName.HIGHLIGHT);
exporterContext.getPdfWriter().addAnnotation(field);
}
@Override
public boolean toExport(JRGenericPrintElement element) {
return true;
}
@Override
public String getNamespace() {
return "urn:sig:sig";
}
@Override
public GenericElementHandler getHandler(String elementName, String exporterKey) {
if (elementName.equals("signature") && exporterKey.equals(JRPdfExporter.PDF_EXPORTER_KEY)) {
return this;
}
return null;
}
}
@@ -24,14 +24,16 @@ public abstract class AbstractRequirementEvaluator extends AbstractModuleEvaluat
return false; return false;
} }
RequirementBase req = (RequirementBase) targetDomainObject; if (targetDomainObject instanceof RequirementBase) {
RequirementBase req = (RequirementBase) targetDomainObject;
if (permission.equals(Constants.PERM_EDIT_NEW)) {
return req.getState() == RequirementState.NEW; if (permission.equals(Constants.PERM_EDIT_NEW)) {
} return req.getState() == RequirementState.NEW;
}
if (permission.equals(Constants.PERM_DELETE_NEW)) {
return req.getState() == RequirementState.NEW; if (permission.equals(Constants.PERM_DELETE_NEW)) {
return req.getState() == RequirementState.NEW;
}
} }
return true; return true;
@@ -5,9 +5,6 @@ import info.bukova.isspst.data.User;
import info.bukova.isspst.services.users.LdapUserImporter; import info.bukova.isspst.services.users.LdapUserImporter;
import info.bukova.isspst.services.users.RoleService; import info.bukova.isspst.services.users.RoleService;
import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.users.UserService;
import java.util.Collection;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.ldap.core.DirContextOperations; import org.springframework.ldap.core.DirContextOperations;
@@ -15,6 +12,8 @@ import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.ldap.userdetails.LdapAuthoritiesPopulator; import org.springframework.security.ldap.userdetails.LdapAuthoritiesPopulator;
import java.util.Collection;
public class AuthPopulator implements LdapAuthoritiesPopulator { public class AuthPopulator implements LdapAuthoritiesPopulator {
private UserService userService; private UserService userService;
@@ -30,7 +29,8 @@ public class AuthPopulator implements LdapAuthoritiesPopulator {
public Collection<? extends GrantedAuthority> getGrantedAuthorities( public Collection<? extends GrantedAuthority> getGrantedAuthorities(
DirContextOperations userData, String login) { DirContextOperations userData, String login) {
User user = null; User user;
try { try {
user = (User) userService.loadUserByUsername(login); user = (User) userService.loadUserByUsername(login);
} catch (UsernameNotFoundException e) { } catch (UsernameNotFoundException e) {
@@ -7,16 +7,6 @@ import info.bukova.isspst.data.UserSettingsData;
import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -24,6 +14,14 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler; import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class LoginSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler implements AuthenticationSuccessHandler { public class LoginSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
@Autowired @Autowired
@@ -45,6 +43,7 @@ public class LoginSuccessHandler extends SavedRequestAwareAuthenticationSuccessH
logger.info("User " + u.getUsername() + " logged in"); logger.info("User " + u.getUsername() + " logged in");
sessionData.setUserCentres(workgroupService.getUserCentres((User) auth.getPrincipal())); sessionData.setUserCentres(workgroupService.getUserCentres((User) auth.getPrincipal()));
sessionData.setUserOnlyCentres(workgroupService.getUserCentres((User) auth.getPrincipal(), true));
sessionData.setUserWorkgroups(workgroupService.getUserWorkgroups((User) auth.getPrincipal())); sessionData.setUserWorkgroups(workgroupService.getUserWorkgroups((User) auth.getPrincipal()));
workgroupService.loadParents(u); workgroupService.loadParents(u);
sessionData.setCurrentUser(u); sessionData.setCurrentUser(u);
@@ -1,7 +1,7 @@
package info.bukova.isspst.services; package info.bukova.isspst.services;
import java.util.Date; import info.bukova.isspst.data.OwnedDataModel;
import info.bukova.isspst.data.User;
import org.hibernate.NonUniqueResultException; import org.hibernate.NonUniqueResultException;
import org.hibernate.Query; import org.hibernate.Query;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@@ -9,8 +9,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import info.bukova.isspst.data.OwnedDataModel; import java.util.Date;
import info.bukova.isspst.data.User;
public class AbstractOwnedService<T extends OwnedDataModel> extends AbstractService<T> { public class AbstractOwnedService<T extends OwnedDataModel> extends AbstractService<T> {
@@ -32,6 +31,7 @@ public class AbstractOwnedService<T extends OwnedDataModel> extends AbstractServ
entity.setModifiedBy(getLoggedInUser()); entity.setModifiedBy(getLoggedInUser());
entity.setModified(new Date()); entity.setModified(new Date());
dao.modify(entity); dao.modify(entity);
maintainStorrage();
} }
@Transactional @Transactional
@@ -1,8 +1,7 @@
package info.bukova.isspst.services; package info.bukova.isspst.services;
import static ch.lambdaj.Lambda.filter;
import info.bukova.isspst.Constants;
import info.bukova.isspst.Module; import info.bukova.isspst.Module;
import info.bukova.isspst.ModuleUtils;
import info.bukova.isspst.SessionData; import info.bukova.isspst.SessionData;
import info.bukova.isspst.dao.BaseDao; import info.bukova.isspst.dao.BaseDao;
import info.bukova.isspst.dao.QueryDao; import info.bukova.isspst.dao.QueryDao;
@@ -11,23 +10,26 @@ import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.filters.Filter; import info.bukova.isspst.filters.Filter;
import info.bukova.isspst.reporting.Report; import info.bukova.isspst.reporting.Report;
import info.bukova.isspst.services.numberseries.NumberSeriesService; import info.bukova.isspst.services.numberseries.NumberSeriesService;
import info.bukova.isspst.storage.DocumentFileStorage;
import org.hibernate.NonUniqueResultException;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.GenericTypeResolver;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.validation.ConstraintViolation; import static ch.lambdaj.Lambda.filter;
import javax.validation.Validator;
import org.hibernate.NonUniqueResultException;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
public abstract class AbstractService<T extends DataModel> implements Service<T> { public abstract class AbstractService<T extends DataModel> implements Service<T> {
@@ -36,10 +38,29 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
@Autowired @Autowired
protected SessionData sessionData; protected SessionData sessionData;
@Autowired @Autowired
protected HqlDataFilter hqlFilter;
@Autowired
protected QueryDao queryDao; protected QueryDao queryDao;
private DocumentFileStorage documentFileStorage;
private NumberSeriesService numberSeriesService; private NumberSeriesService numberSeriesService;
private Class<T> entityClass;
public AbstractService() {
entityClass = (Class<T>) GenericTypeResolver.resolveTypeArgument(getClass(), AbstractService.class);
}
@Override
public List<Class<?>> getEntityClasses() {
List<Class<?>> classes = new ArrayList<Class<?>>();
classes.add(entityClass);
return classes;
}
public void setDocumentFileStorage(DocumentFileStorage storage) {
this.documentFileStorage = storage;
}
public NumberSeriesService getNumberSeriesService() public NumberSeriesService getNumberSeriesService()
{ {
@@ -62,6 +83,56 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
public String getDeleteEntityPermission() { public String getDeleteEntityPermission() {
return ""; return "";
} }
protected void maintainStorrage() {
if (documentFileStorage != null) {
documentFileStorage.purge();
}
}
protected Query filterQuery(Query q) {
return filterQuery(q, null);
}
protected Query filterQuery(Query q, HqlDataFilter aditFilter) {
HqlDataFilter f = hqlFilter;
try {
if (((f.getWhere() == null || f.getWhere().isEmpty())
&& (f.getOrderBy() == null || f.getOrderBy().isEmpty()))
&& ((aditFilter.getWhere() == null || aditFilter.getWhere().isEmpty())
&& (aditFilter.getOrderBy() == null || aditFilter.getOrderBy().isEmpty()))) {
return q;
}
} catch (Exception e) {
f = new HqlDataFilter(); // pri volani mimo web request filtr z requestu neresime
}
boolean isAplicable = false;
if (f.getDataClass() != null) {
for (Class<?> clazz : getEntityClasses()) {
if (f.getDataClass().isAssignableFrom(clazz)) {
isAplicable = true;
}
}
}
String hql;
if (isAplicable) {
hql = HqlUtils.buildHql(q.getQueryString(), f);
} else {
hql = q.getQueryString();
}
hql = HqlUtils.addOrderBy(HqlUtils.addAndWhere(hql, aditFilter), aditFilter);
Query newQuery = dao.getQuery(hql);
if (isAplicable) {
HqlUtils.addParameters(newQuery, f);
}
HqlUtils.addParameters(newQuery, aditFilter);
return newQuery;
}
@Override @Override
@PreAuthorize("hasPermission(this, 'PERM_ADD')") @PreAuthorize("hasPermission(this, 'PERM_ADD')")
@@ -77,6 +148,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new IsspstException("DAO is null"); throw new IsspstException("DAO is null");
} }
if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
validate(entity); validate(entity);
entity.setCreated(new Date()); entity.setCreated(new Date());
dao.add(entity); dao.add(entity);
@@ -90,9 +165,14 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new IsspstException("DAO is null"); throw new IsspstException("DAO is null");
} }
if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
validate(entity); validate(entity);
entity.setModified(new Date()); entity.setModified(new Date());
dao.modify(entity); dao.modify(entity);
maintainStorrage();
} }
@Override @Override
@@ -103,7 +183,13 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new IsspstException("DAO is null"); throw new IsspstException("DAO is null");
} }
if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
dao.delete(entity); dao.delete(entity);
maintainStorrage(); // poklidit přiložené soubory
} }
@Override @Override
@@ -141,6 +227,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new IsspstException("DAO is null"); throw new IsspstException("DAO is null");
} }
if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
return dao.getById(id); return dao.getById(id);
} }
@@ -152,7 +242,13 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new IsspstException("DAO is null"); throw new IsspstException("DAO is null");
} }
return dao.getAll(); if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
Query q = dao.getQuery("from " + dao.getEntityName());
return filterQuery(q).list();
} }
@Override @Override
@@ -163,6 +259,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new IsspstException("DAO is null"); throw new IsspstException("DAO is null");
} }
if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
return dao.execQuery(query); return dao.execQuery(query);
} }
@@ -175,6 +275,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new IsspstException("DAO is null"); throw new IsspstException("DAO is null");
} }
if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
try { try {
Query q = dao.getQuery(query); Query q = dao.getQuery(query);
return (T) q.uniqueResult(); return (T) q.uniqueResult();
@@ -193,13 +297,7 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
@Override @Override
public Module getModule() { public Module getModule() {
for (Module m : Constants.MODULES) { return ModuleUtils.getModule(this.getClass());
if (Arrays.asList(this.getClass().getInterfaces()).contains(m.getServiceClass())) {
return m;
}
}
return null;
} }
public List<Report> getReports() { public List<Report> getReports() {
@@ -238,6 +336,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
@Override @Override
@Transactional @Transactional
public void loadLazyData(String group, T entity) { public void loadLazyData(String group, T entity) {
if (entity == null) {
return;
}
Method[] methods = this.getClass().getMethods(); Method[] methods = this.getClass().getMethods();
for (Method m : methods) { for (Method m : methods) {
@@ -260,4 +362,9 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
} }
} }
} }
@Override
public boolean canPrintRecord(T entity) {
return true;
}
} }
@@ -0,0 +1,87 @@
package info.bukova.isspst.services;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* @author Pepa Rokos
*/
public class HqlDataFilter {
private String where;
private String orderBy;
private Map<String, Object> params;
private Class<?> dataClass;
public HqlDataFilter() {
params = new HashMap<String, Object>();
}
public HqlDataFilter(String where) {
this();
this.where = where;
}
public HqlDataFilter(String where, String orderBy) {
this(where);
this.orderBy = orderBy;
}
public String getWhere() {
return where;
}
public void setWhere(String where) {
this.where = where;
}
public String getOrderBy() {
return orderBy;
}
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
public void setParam(String key, Object value) {
params.put(key, value);
}
public Object getParam(String key) {
return params.get(key);
}
public Set<String> getParamKeys() {
return params.keySet();
}
public void andFilter(String filter) {
if (where == null || where.isEmpty()) {
where = filter;
} else {
where += " and (" + filter + ")";
}
}
public void orFilter(String filter) {
if (where == null ||where.isEmpty()) {
where = filter;
} else {
where += " or (" + filter + ")";
}
}
public void reset() {
where = "";
orderBy = "";
params.clear();
}
public Class<?> getDataClass() {
return dataClass;
}
public void setDataClass(Class<?> dataClass) {
this.dataClass = dataClass;
}
}
@@ -0,0 +1,90 @@
package info.bukova.isspst.services;
import org.hibernate.Query;
import java.util.Collection;
/**
* @author Pepa Rokos
*/
public class HqlUtils {
public static String buildHql(String select, HqlDataFilter filter) {
if (select.toLowerCase().contains("where")
|| select.toLowerCase().contains("order by")) {
throw new IsspstException("Use add*() methods instead.");
}
String hql = addWhere(select, filter, "");
return addOrderBy(hql, filter);
}
public static String addAndWhere(String hql, HqlDataFilter filter) {
if (!checkWhere(filter)) {
return hql;
}
return addWhere(hql, filter, "and");
}
public static String addOrWhere(String hql, HqlDataFilter filter) {
if (!checkWhere(filter)) {
return hql;
}
return addWhere(hql, filter, "or");
}
public static String addOrderBy(String hql, HqlDataFilter filter) {
if (filter == null || filter.getOrderBy() == null || filter.getOrderBy().isEmpty()) {
return hql;
}
if (!hql.contains("order by")) {
hql += " order by ";
}
hql += filter.getOrderBy();
return hql;
}
public static void addParameters(Query query, HqlDataFilter filter) {
if (filter == null) {
return;
}
for (String key : filter.getParamKeys()) {
if (filter.getParam(key) instanceof Collection<?>) {
query.setParameterList(key, (Collection) filter.getParam(key));
} else {
query.setParameter(key, filter.getParam(key));
}
}
}
private static boolean checkWhere(HqlDataFilter filter) {
return filter != null && filter.getWhere() != null && !filter.getWhere().isEmpty();
}
private static String addWhere(String hql, HqlDataFilter filter, String operator) {
if (hql.toLowerCase().contains("where") && hql.toLowerCase().contains("order by")) {
String[] split = hql.split("order by");
hql = split[0] + " " + operator + " (" + filter.getWhere() + ") order by " + split[1];
return hql;
}
if (hql.toLowerCase().contains("where")) {
hql += " " + operator + " (" + filter.getWhere() + ")";
return hql;
}
if (hql.toLowerCase().contains("order by")) {
String[] split = hql.split("order by");
hql = split[0] + " where (" + filter.getWhere() + ") order by " + split[1];
return hql;
}
hql += " where (" + filter.getWhere() + ")";
return hql;
}
}
@@ -0,0 +1,14 @@
package info.bukova.isspst.services;
public class ModuleNotActiveException extends IsspstException {
/**
*
*/
private static final long serialVersionUID = -1219763294556500698L;
public ModuleNotActiveException() {
super("Module deactivated");
}
}
@@ -22,5 +22,7 @@ public interface Service<T> {
public List<T> filterList(List<T> sourceList, Filter<T> filter); public List<T> filterList(List<T> sourceList, Filter<T> filter);
public Module getModule(); public Module getModule();
public List<Report> getReports(); public List<Report> getReports();
public boolean canPrintRecord(T entity);
public List<Class<?>> getEntityClasses();
} }
@@ -3,13 +3,12 @@ package info.bukova.isspst.services.dbinfo;
import info.bukova.isspst.Constants; import info.bukova.isspst.Constants;
import info.bukova.isspst.data.DbInfo; import info.bukova.isspst.data.DbInfo;
import info.bukova.isspst.services.AbstractService; import info.bukova.isspst.services.AbstractService;
import org.hibernate.SQLQuery;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.hibernate.SQLQuery;
import org.springframework.transaction.annotation.Transactional;
public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfoService public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfoService
{ {
private DbInfo getDbInfo() private DbInfo getDbInfo()
@@ -60,6 +59,9 @@ public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfo
} }
} }
// String source = UserCountUtils.encryptUserCount(1000);
// long users = UserCountUtils.decryptUserCount(source);
long dbVersion = this.getDbInfo().getVersion(); long dbVersion = this.getDbInfo().getVersion();
if (Constants.DB_VERSION > dbVersion) if (Constants.DB_VERSION > dbVersion)
@@ -71,29 +73,29 @@ public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfo
{ {
List<Str2Str> tables = new ArrayList<Str2Str>(); List<Str2Str> tables = new ArrayList<Str2Str>();
tables.add(new Str2Str("address", "DESCRIPTION")); tables.add(new Str2Str("ADDRESS", "DESCRIPTION"));
tables.add(new Str2Str("building", "DESCRIPTION")); tables.add(new Str2Str("BUILDING", "DESCRIPTION"));
tables.add(new Str2Str("material", "DESCRIPTION")); tables.add(new Str2Str("MATERIAL", "DESCRIPTION"));
tables.add(new Str2Str("munit", "DESCRIPTION")); tables.add(new Str2Str("MUNIT", "DESCRIPTION"));
tables.add(new Str2Str("orders", "DESCRIPTION")); tables.add(new Str2Str("ORDERS", "DESCRIPTION"));
tables.add(new Str2Str("order_item", "DESCRIPTION")); tables.add(new Str2Str("ORDER_ITEM", "DESCRIPTION"));
tables.add(new Str2Str("permission", "DESCRIPTION")); tables.add(new Str2Str("PERMISSION", "DESCRIPTION"));
tables.add(new Str2Str("requirement", "DESCRIPTION")); tables.add(new Str2Str("REQUIREMENT", "DESCRIPTION"));
tables.add(new Str2Str("requirementtype", "DESCRIPTION")); tables.add(new Str2Str("REQUIREMENTTYPE", "DESCRIPTION"));
tables.add(new Str2Str("requirement_items", "DESCRIPTION")); tables.add(new Str2Str("REQUIREMENT_ITEMS", "DESCRIPTION"));
tables.add(new Str2Str("role", "DESCRIPTION")); tables.add(new Str2Str("ROLE", "DESCRIPTION"));
tables.add(new Str2Str("service", "DESCRIPTION")); tables.add(new Str2Str("SERVICE", "DESCRIPTION"));
tables.add(new Str2Str("triprequirement", "DESCRIPTION")); tables.add(new Str2Str("TRIPREQUIREMENT", "DESCRIPTION"));
tables.add(new Str2Str("material", "MUNIT_DESCRIPTION")); tables.add(new Str2Str("MATERIAL", "MUNIT_DESCRIPTION"));
tables.add(new Str2Str("orders", "INVOICE_DESCRIPTION")); tables.add(new Str2Str("ORDERS", "INVOICE_DESCRIPTION"));
tables.add(new Str2Str("orders", "DELIVERY_DESCRIPTION")); tables.add(new Str2Str("ORDERS", "DELIVERY_DESCRIPTION"));
tables.add(new Str2Str("orders", "SUPPLIER_DESCRIPTION")); tables.add(new Str2Str("ORDERS", "SUPPLIER_DESCRIPTION"));
tables.add(new Str2Str("order_item", "MUNIT_DESCRIPTION")); tables.add(new Str2Str("ORDER_ITEM", "MUNIT_DESCRIPTION"));
tables.add(new Str2Str("requirement_items", "MUNIT_DESCRIPTION")); tables.add(new Str2Str("REQUIREMENT_ITEMS", "MUNIT_DESCRIPTION"));
tables.add(new Str2Str("triprequirement", "VEHICLE_DESCRIPTION")); tables.add(new Str2Str("TRIPREQUIREMENT", "VEHICLE_DESCRIPTION"));
tables.add(new Str2Str("trip_bill_items", "BACK_VEHICLE_DESCRIPTION")); tables.add(new Str2Str("TRIP_BILL_ITEMS", "BACK_VEHICLE_DESCRIPTION"));
tables.add(new Str2Str("trip_bill_items", "VEHICLE_DESCRIPTION")); tables.add(new Str2Str("TRIP_BILL_ITEMS", "VEHICLE_DESCRIPTION"));
for (Str2Str item : tables) for (Str2Str item : tables)
{ {
@@ -107,9 +109,9 @@ public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfo
{ {
List<String> tables = new ArrayList<String>(); List<String> tables = new ArrayList<String>();
tables.add("material"); tables.add("MATERIAL");
tables.add("order_item"); tables.add("ORDER_ITEM");
tables.add("requirement_items"); tables.add("REQUIREMENT_ITEMS");
for (String item : tables) for (String item : tables)
{ {
@@ -119,6 +121,96 @@ public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfo
} }
} }
if (dbVersion < 3)
{
sql = "UPDATE INVOICING SET COMPLETED = false WHERE (COMPLETED Is NULL) ";
sq = this.dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
}
if (dbVersion < 4)
{
sql = "UPDATE TRIP_BILL SET RESULT_MESSAGE = 'Zpráva z pracovní cesty' WHERE (RESULT_MESSAGE Is NULL) ";
sq = this.dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
}
if (dbVersion < 5) {
sql = "ALTER TABLE TRIP_BILL MODIFY RESULT_MESSAGE VARCHAR(" + String.valueOf(Constants.LEN_RESULT_MESSAGE) + ")";
sq = this.dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
}
if (dbVersion > 0 && dbVersion < 6) {
sql = "INSERT INTO SEASON(DESCRIPTION, VALID_FROM, VALID_TO, ACTIVE) " +
"VALUES ('2015', '2015-01-01', '2015-12-31', 0)";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "INSERT INTO SEASON(DESCRIPTION, VALID_FROM, VALID_TO, ACTIVE) " +
"VALUES ('2016', '2016-01-01', NULL, 1)";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE NUMBERSERIES SET SEASON_ID = 2";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "INSERT INTO NUMBERSERIES(MODULE, PREFIX, NUMBER, SEASON_ID) " +
"VALUES ('REQUIREMENTS', 'P', 2528, 1)";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "INSERT INTO NUMBERSERIES(MODULE, PREFIX, NUMBER, SEASON_ID) " +
"VALUES ('ORDER', 'OBJ', 55, 1)";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
// rozdeleni dat do sezon
sql = "UPDATE REQUIREMENT SET SEASON_ID = 2 WHERE NUMSER LIKE 'P16%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE REQUIREMENT SET SEASON_ID = 1 WHERE NUMSER LIKE 'P0%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE TRIPREQUIREMENT SET SEASON_ID = 2 WHERE NUMSER LIKE 'P16%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE TRIPREQUIREMENT SET SEASON_ID = 1 WHERE NUMSER LIKE 'P0%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE ORDERS SET SEASON_ID = 2 WHERE NUMSER LIKE 'OBJ16%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE ORDERS SET SEASON_ID = 1 WHERE NUMSER LIKE 'OBJ0%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE TRIP_BILL_APPROVAL SET SEASON_ID = 2 " +
" WHERE TRIPBILL_ID in " +
" (SELECT tb.ID FROM TRIP_BILL AS tb " +
" JOIN TRIPREQUIREMENT ON TRIPREQUIREMENT.ID = tb.REQUIREMENT_ID WHERE NUMSER LIKE 'P16%')";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE TRIP_BILL_APPROVAL SET SEASON_ID = 1 " +
"WHERE TRIPBILL_ID in " +
"(SELECT tb.ID FROM TRIP_BILL AS tb " +
"JOIN TRIPREQUIREMENT ON TRIPREQUIREMENT.ID = tb.REQUIREMENT_ID WHERE NUMSER LIKE 'P0%')";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE TRIP_BILL tb JOIN TRIPREQUIREMENT ON TRIPREQUIREMENT.ID = tb.REQUIREMENT_ID " +
"SET tb.SEASON_ID = 2 WHERE NUMSER LIKE 'P16%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE TRIP_BILL tb JOIN TRIPREQUIREMENT ON TRIPREQUIREMENT.ID = tb.REQUIREMENT_ID " +
"SET tb.SEASON_ID = 1 WHERE NUMSER LIKE 'P0%'";;
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
}
this.updateDatabaseVersion(); this.updateDatabaseVersion();
} }
} }
@@ -0,0 +1,14 @@
package info.bukova.isspst.services.fulltext;
import java.io.ByteArrayInputStream;
/**
* @author Pepa Rokos
*/
public abstract class AbstractExtractor implements Extractor {
public String extract(byte[] data) {
return extract(new ByteArrayInputStream(data));
}
}
@@ -0,0 +1,25 @@
package info.bukova.isspst.services.fulltext;
import org.apache.poi.POIXMLTextExtractor;
import java.io.IOException;
import java.io.InputStream;
/**
* @author Pepa Rokos
*/
public abstract class AbstractOfficeExtractor extends AbstractExtractor {
@Override
public String extract(InputStream is) throws ExtractorException {
try {
POIXMLTextExtractor extractor = createExtractor(is);
return extractor.getText();
} catch (IOException e) {
throw new ExtractorException(e);
}
}
protected abstract POIXMLTextExtractor createExtractor(InputStream is) throws IOException;
}
@@ -0,0 +1,19 @@
package info.bukova.isspst.services.fulltext;
import org.apache.poi.POIXMLTextExtractor;
import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.IOException;
import java.io.InputStream;
/**
* @author Pepa Rokos
*/
public class ExcelExtractor extends AbstractOfficeExtractor implements Extractor {
@Override
protected POIXMLTextExtractor createExtractor(InputStream is) throws IOException {
return new XSSFExcelExtractor(new XSSFWorkbook(is));
}
}
@@ -0,0 +1,30 @@
package info.bukova.isspst.services.fulltext;
import java.io.InputStream;
/**
* @author Pepa Rokos
*
* Rozhraní extractoru čistého textu z formátů Office a PDF
*/
public interface Extractor {
/**
* Extrahuje text z předaného pole bytů
*
* @param data zdrajová data
* @return čistý text
* @throws ExtractorException
*/
public String extract(byte[] data) throws ExtractorException;
/**
* Extrahuje text z předaného InputStream objektu
*
* @param is zdrojový InputStream
* @return čistý text
* @throws ExtractorException
*/
public String extract(InputStream is) throws ExtractorException;
}
@@ -0,0 +1,16 @@
package info.bukova.isspst.services.fulltext;
import info.bukova.isspst.services.IsspstException;
/**
* @author Pepa Rokos
*
* Výjimka extrakce textu
*/
public class ExtractorException extends IsspstException {
public ExtractorException(Throwable cause) {
super("Extractor exception: ", cause);
}
}
@@ -0,0 +1,42 @@
package info.bukova.isspst.services.fulltext;
/**
* @author Pepa Rokos
*
* Factory pro konkrétní extractor
*/
public class ExtractorFactory {
/**
* Vytvoří extractor podle předaného content typu
*
* @param contentType
* @return Extractor
*/
public static Extractor createExtractor(String contentType) {
if (contentType.equals("application/vnd.oasis.opendocument.text")
|| contentType.equals("application/vnd.oasis.opendocument.spreadsheet")
|| contentType.equals("application/vnd.oasis.opendocument.presentation")) {
return new OdfExtractor();
}
if (contentType.equals("application/vnd.openxmlformats-officedocument.wordprocessingml.document")) {
return new WordExtractor();
}
if (contentType.equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) {
return new ExcelExtractor();
}
if (contentType.equals("application/vnd.openxmlformats-officedocument.presentationml.slideshow")) {
return new PowerPointExtractor();
}
if (contentType.equals("application/pdf")) {
return new PdfExtractor();
}
return null;
}
}
@@ -0,0 +1,42 @@
package info.bukova.isspst.services.fulltext;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import java.util.List;
/**
* @author Pepa Rokos
*
* Rozhraní služby fulltextového vyhledávání
*
*/
public interface FullTextService {
/**
* Přegeneruje fulltextový index.
*/
public void reindex();
/**
* Vyhledává entity zadané třídy. Třída entity musí být anotovaná {@link Indexed}
*
* @param entityClass třída entity k vyhledání
* @param fields property entity kde se bude vyhledávat. Musí být anotované {@link Field}
* @param word vyhledávaný výraz
* @return list odpovídajících entit
*/
public List<?> search(Class<?> entityClass, String[] fields, String word);
/**
* Globální vyhledávání ve všech entitách, jejichš třídy jsou anotované {@link Indexed} a
* property {@link Field}
*
* @param word vyhledávaný výraz
* @return list odpovídajících entit
*/
public List<?> globalSearch(String word);
}
@@ -0,0 +1,154 @@
package info.bukova.isspst.services.fulltext;
import info.bukova.isspst.ModuleUtils;
import info.bukova.isspst.dao.QueryDao;
import info.bukova.isspst.data.BaseData;
import info.bukova.isspst.data.User;
import info.bukova.isspst.services.ModuleNotActiveException;
import info.bukova.isspst.sort.ReflectionTools;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
import org.hibernate.Hibernate;
import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.query.dsl.QueryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FullTextServiceImpl implements FullTextService {
@Autowired
private QueryDao queryDao;
private List<Class<?>> classesForSearch;
private Map<Class<?>, String[]> fields;
private List<Class<?>> nestedClasses;
public FullTextServiceImpl() {
nestedClasses = new ArrayList<Class<?>>();
nestedClasses.add(User.class);
nestedClasses.add(BaseData.class);
}
@Override
@Transactional
public void reindex() {
Logger logger = LoggerFactory.getLogger(FullTextServiceImpl.class);
logger.info("Indexing database for fulltext search");
FullTextSession ftSession = Search.getFullTextSession(queryDao.getSession());
ftSession.createIndexer().start();
}
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_SEARCH')")
public List<?> search(Class<?> entityClass, String[] fields, String word) {
checkActivity();
FullTextSession session = Search.getFullTextSession(queryDao.getSession());
QueryBuilder qb = session.getSearchFactory().buildQueryBuilder().forEntity(entityClass).get();
Query luceneQuery = qb.keyword().onFields(fields).matching(word).createQuery();
FullTextQuery hiberQuery = session.createFullTextQuery(luceneQuery, entityClass);
hiberQuery.setSort(Sort.RELEVANCE);
return hiberQuery.list();
}
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_SEARCH')")
public List<?> globalSearch(String word) {
checkActivity();
List<Object> result = new ArrayList<Object>();
for (Class<?> clazz : classesForSearch()) {
result.addAll(search(clazz, fields.get(clazz), word));
}
for (Object o : result) {
BaseData data = (BaseData) o;
Hibernate.initialize(data.getModifiedBy());
Hibernate.initialize(data.getOwnedBy());
}
return result;
}
private void checkActivity() {
if (!ModuleUtils.getModule(this.getClass()).isActive()) {
throw new ModuleNotActiveException();
}
}
private List<Class<?>> classesForSearch() {
if (classesForSearch != null) {
return classesForSearch;
}
classesForSearch = new ArrayList<Class<?>>();
fields = new HashMap<Class<?>, String[]>();
FullTextSession session = Search.getFullTextSession(queryDao.getSession());
for (Class<?> clazz : session.getSearchFactory().getIndexedTypes()) {
if (nestedClasses.contains(clazz)) {
continue;
}
classesForSearch.add(clazz);
fields.put(clazz, fields(clazz, ""));
}
return classesForSearch;
}
private String[] fields(Class<?> clazz, String prefix) {
List<String> res = new ArrayList<String>();
for (Field field : ReflectionTools.getFields(clazz)) {
for (Annotation a : field.getDeclaredAnnotations()) {
if (a instanceof org.hibernate.search.annotations.Field) {
res.add(prefix + field.getName());
}
if (a instanceof IndexedEmbedded) {
Class<?> fieldClass;
fieldClass = field.getType();
if (fieldClass.isAssignableFrom(List.class)) {
ParameterizedType type = (ParameterizedType) field.getGenericType();
Type[] types = type.getActualTypeArguments();
if (types.length == 1) {
fieldClass = (Class<?>)types[0];
}
}
classesForSearch.remove(fieldClass);
fields.remove(fieldClass);
nestedClasses.add(fieldClass);
String nestedPrefix = prefix + field.getName() + ".";
res.addAll(Arrays.asList(fields(fieldClass, nestedPrefix)));
}
}
}
String resArray[] = new String[res.size()];
resArray = res.toArray(resArray);
return resArray;
}
}
@@ -0,0 +1,24 @@
package info.bukova.isspst.services.fulltext;
import org.odftoolkit.simple.Document;
import org.odftoolkit.simple.common.TextExtractor;
import java.io.InputStream;
/**
* @author Pepa Rokos
*/
public class OdfExtractor extends AbstractExtractor implements Extractor {
@Override
public String extract(InputStream is) throws ExtractorException {
try {
Document odfDocument = Document.loadDocument(is);
TextExtractor extractor = TextExtractor.newOdfTextExtractor(odfDocument.getContentRoot());
return extractor.getText();
} catch (Exception e) {
throw new ExtractorException(e);
}
}
}
@@ -0,0 +1,32 @@
package info.bukova.isspst.services.fulltext;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.parser.PdfTextExtractor;
import java.io.IOException;
import java.io.InputStream;
/**
* @author Pepa Rokos
*/
public class PdfExtractor extends AbstractExtractor implements Extractor {
@Override
public String extract(InputStream is) throws ExtractorException {
try {
PdfReader reader = new PdfReader(is);
PdfTextExtractor extractor = new PdfTextExtractor(reader);
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= reader.getNumberOfPages(); i++) {
sb.append(extractor.getTextFromPage(i));
}
return sb.toString();
} catch (IOException e) {
throw new ExtractorException(e);
}
}
}
@@ -0,0 +1,20 @@
package info.bukova.isspst.services.fulltext;
import org.apache.poi.POIXMLTextExtractor;
import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import java.io.IOException;
import java.io.InputStream;
/**
* @author Pepa Rokos
*/
public class PowerPointExtractor extends AbstractOfficeExtractor implements Extractor {
@Override
protected POIXMLTextExtractor createExtractor(InputStream is) throws IOException {
return new XSLFPowerPointExtractor(new XMLSlideShow(is));
}
}
@@ -0,0 +1,19 @@
package info.bukova.isspst.services.fulltext;
import org.apache.poi.POIXMLTextExtractor;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import java.io.IOException;
import java.io.InputStream;
/**
* @author Pepa Rokos
*/
public class WordExtractor extends AbstractOfficeExtractor implements Extractor {
@Override
protected POIXMLTextExtractor createExtractor(InputStream is) throws IOException {
return new XWPFWordExtractor(new XWPFDocument(is));
}
}
@@ -1,14 +1,19 @@
package info.bukova.isspst.services.invoicing; package info.bukova.isspst.services.invoicing;
import java.math.BigDecimal;
import info.bukova.isspst.data.Invoicing; import info.bukova.isspst.data.Invoicing;
import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.Service; import info.bukova.isspst.services.Service;
import java.math.BigDecimal;
import java.util.List;
public interface InvoicingService extends Service<Invoicing> { public interface InvoicingService extends Service<Invoicing> {
public BigDecimal totalInvoicedForWorkgroup(Workgroup workgroup); public BigDecimal totalInvoicedForWorkgroup(Workgroup workgroup);
public BigDecimal totalInvoicedForWorkgroupAndSeason(Workgroup workgroup, Season season);
public void loadReqItems(Invoicing invoicing); public void loadReqItems(Invoicing invoicing);
@@ -16,4 +21,17 @@ public interface InvoicingService extends Service<Invoicing> {
public void calculate(Invoicing invoicing); public void calculate(Invoicing invoicing);
public List<Invoicing> getPendingList();
public List<Invoicing> getArchiveList();
public Invoicing getForRequirement(Requirement req);
public List<Invoicing> getMaterialPendingList();
public List<Invoicing> getMaterialArchiveList();
public List<Invoicing> getServicesPendingList();
public List<Invoicing> getServicesArchiveList();
} }
@@ -1,29 +1,43 @@
package info.bukova.isspst.services.invoicing; package info.bukova.isspst.services.invoicing;
import info.bukova.isspst.Constants;
import info.bukova.isspst.data.Invoicing; import info.bukova.isspst.data.Invoicing;
import info.bukova.isspst.data.InvoicingItem; import info.bukova.isspst.data.InvoicingItem;
import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.settings.SeasonService;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
public class InvoicingServiceImpl extends AbstractOwnedService<Invoicing> implements public class InvoicingServiceImpl extends AbstractOwnedService<Invoicing> implements
InvoicingService { InvoicingService {
@Autowired
private SeasonService seasonService;
@Override @Override
@Transactional @Transactional
public BigDecimal totalInvoicedForWorkgroup(Workgroup workgroup) { public BigDecimal totalInvoicedForWorkgroup(Workgroup workgroup) {
return totalInvoicedForWorkgroupAndSeason(workgroup, seasonService.getActive());
}
@Override
@Transactional
public BigDecimal totalInvoicedForWorkgroupAndSeason(Workgroup workgroup, Season season) {
Query q = dao.getQuery("select sum(inv.totalInvoiced) " Query q = dao.getQuery("select sum(inv.totalInvoiced) "
+ "from Invoicing inv join inv.requirement rq join rq.workgroup w " + "from Invoicing inv join inv.requirement rq join rq.workgroup w "
+ "where w = :workgroup "); + "where w = :workgroup and rq.season = :season");
q.setParameter("workgroup", workgroup); q.setParameter("workgroup", workgroup);
q.setParameter("season", season);
return (BigDecimal) q.uniqueResult(); return (BigDecimal) q.uniqueResult();
} }
@@ -45,6 +59,14 @@ public class InvoicingServiceImpl extends AbstractOwnedService<Invoicing> implem
invoicing.setItems(inv.getItems()); invoicing.setItems(inv.getItems());
} }
@Transactional
@LazyLoader
public void loadReqAuth(Invoicing invoicing) {
Invoicing inv = getById(invoicing.getId());
Hibernate.initialize(inv.getRequirement().getAuthorization());
invoicing.getRequirement().setAuthorization(inv.getRequirement().getAuthorization());
}
@Override @Override
public void calculate(Invoicing invoicing) { public void calculate(Invoicing invoicing) {
BigDecimal total = BigDecimal.ZERO; BigDecimal total = BigDecimal.ZERO;
@@ -73,4 +95,72 @@ public class InvoicingServiceImpl extends AbstractOwnedService<Invoicing> implem
invoice.getRequirement().setOwnedBy(inv.getRequirement().getOwnedBy()); invoice.getRequirement().setOwnedBy(inv.getRequirement().getOwnedBy());
} }
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<Invoicing> getPendingList()
{
Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed Is Null or inv.completed = false) order by rq.numser");
return q.list();
}
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<Invoicing> getArchiveList()
{
Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where inv.completed = true order by rq.numser");
return q.list();
}
@Override
@Transactional
public Invoicing getForRequirement(Requirement req) {
Query query = dao.getQuery("select invoice from Invoicing invoice join invoice.requirement rq where rq.id = :reqId");
query.setParameter("reqId", req.getId());
return (Invoicing) query.uniqueResult();
}
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<Invoicing> getMaterialPendingList() {
Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed Is Null or inv.completed = false) and (rq.kind = :kind) order by rq.numser desc");
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
return q.list();
}
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<Invoicing> getMaterialArchiveList() {
Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed = true) and (rq.kind = :kind) order by rq.numser desc");
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
return q.list();
}
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<Invoicing> getServicesPendingList() {
Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed Is Null or inv.completed = false) and (rq.kind = :kind) order by rq.numser desc");
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
return q.list();
}
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<Invoicing> getServicesArchiveList() {
Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed = true) and (rq.kind = :kind) order by rq.numser desc");
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
return q.list();
}
} }
@@ -0,0 +1,14 @@
package info.bukova.isspst.services.limits;
import info.bukova.isspst.services.IsspstException;
/**
* @author Pepa Rokos
*/
public class LimitException extends IsspstException {
public LimitException(String reason) {
setReason(reason);
}
}
@@ -0,0 +1,17 @@
package info.bukova.isspst.services.limits;
import info.bukova.isspst.data.Limit;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.Service;
import java.util.List;
/**
* @author Pepa Rokos
*/
public interface LimitService extends Service<Limit> {
List<Limit> getForSeason(Season season);
Limit getForWorkgroupAndSeason(Workgroup wg, Season season);
Limit getForWorkgroup(Workgroup wg);
}
@@ -0,0 +1,62 @@
package info.bukova.isspst.services.limits;
import info.bukova.isspst.data.Limit;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.settings.SeasonService;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @author Pepa Rokos
*/
public class LimitServiceImpl extends AbstractOwnedService<Limit> implements LimitService {
@Autowired
private SeasonService seasonService;
@Override
@Transactional
public List<Limit> getForSeason(Season season) {
Query q = dao.getQuery("from Limit where season = :season");
q.setParameter("season", season);
return q.list();
}
@Override
@Transactional
public Limit getForWorkgroupAndSeason(Workgroup wg, Season season) {
Query q = dao.getQuery("from Limit where workgroup = :wg and season = :season");
q.setParameter("wg", wg);
q.setParameter("season", season);
return (Limit) q.uniqueResult();
}
@Override
@Transactional
public Limit getForWorkgroup(Workgroup wg) {
return getForWorkgroupAndSeason(wg, seasonService.getActive());
}
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
public void add(Limit entity) {
if (getForWorkgroupAndSeason(entity.getWorkgroup(),entity.getSeason()) != null) {
throw new LimitException("LimitExists");
}
super.add(entity);
}
@Override
protected Limit createEntity() {
Limit limit = new Limit();
limit.setSeason(seasonService.getActive());
return limit;
}
}
@@ -1,11 +1,18 @@
package info.bukova.isspst.services.numberseries; package info.bukova.isspst.services.numberseries;
import info.bukova.isspst.data.NumberSeries; import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.services.Service; import info.bukova.isspst.services.Service;
import java.util.List;
public interface NumberSeriesService extends Service<NumberSeries> public interface NumberSeriesService extends Service<NumberSeries>
{ {
public NumberSeries getNumberSerie(String module); public NumberSeries getNumberSerie(String module);
public NumberSeries getNumberSerieForSeason(String module, Season season);
public void increase(NumberSeries ns); public void increase(NumberSeries ns);
public List<NumberSeries> getSeriesForSeason(Season season);
} }
@@ -1,24 +1,48 @@
package info.bukova.isspst.services.numberseries; package info.bukova.isspst.services.numberseries;
import info.bukova.isspst.data.NumberSeries; import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.services.AbstractService; import info.bukova.isspst.services.AbstractService;
import info.bukova.isspst.services.settings.SeasonService;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
public class NumberSeriesServiceImpl extends AbstractService<NumberSeries> implements NumberSeriesService public class NumberSeriesServiceImpl extends AbstractService<NumberSeries> implements NumberSeriesService
{ {
@Autowired
private SeasonService seasonService;
@Transactional @Transactional
@Override @Override
public NumberSeries getNumberSerie(String module) public NumberSeries getNumberSerie(String module) {
{ return getNumberSerieForSeason(module, seasonService.getActive());
return this.selectSingle("from NumberSeries where MODULE = '" + module + "'");
} }
@Transactional @Transactional
@Override @Override
public void increase(NumberSeries ns) public NumberSeries getNumberSerieForSeason(String module, Season season) {
{ Query q = dao.getQuery("from NumberSeries where module = :m and season = :s");
q.setParameter("m", module);
q.setParameter("s", season);
return (NumberSeries) q.uniqueResult();
}
@Transactional
@Override
public void increase(NumberSeries ns) {
ns.setNumber(ns.getNumber() + 1); ns.setNumber(ns.getNumber() + 1);
this.update(ns); this.update(ns);
} }
@Transactional
@Override
public List<NumberSeries> getSeriesForSeason(Season season) {
Query q = dao.getQuery("from NumberSeries where season = :s");
q.setParameter("s", season);
return q.list();
}
} }
@@ -10,16 +10,16 @@ import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.settings.GlobalSettingsService;
import info.bukova.isspst.services.settings.SeasonService;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Query; import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
public class OrderServiceImpl extends AbstractOwnedService<Order> implements public class OrderServiceImpl extends AbstractOwnedService<Order> implements
OrderService { OrderService {
@@ -29,6 +29,9 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
@Autowired @Autowired
private RequirementItemDao requirementItemDao; private RequirementItemDao requirementItemDao;
@Autowired
private SeasonService seasonService;
@Override @Override
@PreAuthorize("hasPermission(this, 'PERM_ADD')") @PreAuthorize("hasPermission(this, 'PERM_ADD')")
public Order createOrder(List<JoinedItem> items) { public Order createOrder(List<JoinedItem> items) {
@@ -46,6 +49,7 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
} }
order.setTotal(total); order.setTotal(total);
order.setSeason(seasonService.getActive());
return order; return order;
} }
@@ -76,7 +80,7 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
public List<Order> getAll() public List<Order> getAll()
{ {
Query q = dao.getQuery("select o from Order o join fetch o.ownedBy"); Query q = dao.getQuery("select o from Order o join fetch o.ownedBy");
return q.list(); return filterQuery(q).list();
} }
@LazyLoader("form") @LazyLoader("form")
@@ -0,0 +1,24 @@
package info.bukova.isspst.services.requirement;
import info.bukova.isspst.services.IsspstException;
/**
* @author Pepa Rokos
*/
public class ApproveException extends IsspstException {
/**
*
*/
private static final long serialVersionUID = -3794779381621324848L;
public ApproveException() {
super();
}
public ApproveException(String message) {
super(message);
this.setReason(message);
}
}
@@ -3,17 +3,14 @@ package info.bukova.isspst.services.requirement;
import info.bukova.isspst.Constants; import info.bukova.isspst.Constants;
import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.RequirementState; import info.bukova.isspst.data.RequirementState;
import info.bukova.isspst.data.Workgroup;
import java.util.Date;
import java.util.List;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostFilter; import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
public class ReqMaterialServiceImpl extends RequirementServiceImpl implements RequirementService, RequirementBaseService<Requirement> public class ReqMaterialServiceImpl extends RequirementServiceImpl implements RequirementService, RequirementBaseService<Requirement>
{ {
@Autowired @Autowired
@@ -38,10 +35,10 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
@PreAuthorize("hasPermission(this, 'PERM_READ')") @PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<Requirement> getMy() public List<Requirement> getMy()
{ {
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner and kind = :kind"); hqlFilter.setDataClass(Requirement.class);
q.setParameter("owner", getLoggedInUser()); hqlFilter.andFilter("kind = :kind");
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL); hqlFilter.setParam("kind", Constants.REQ_TYPE_MATERIAL);
return q.list(); return super.getMy();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -51,11 +48,10 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_CENTRE_REQ')") @PostFilter("hasPermission(filterObject, 'PERM_SHOW_CENTRE_REQ')")
public List<Requirement> getCentreReq() public List<Requirement> getCentreReq()
{ {
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser()); hqlFilter.setDataClass(Requirement.class);
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c where c in (:wgList) and kind = :kind order by tr.numser"); hqlFilter.andFilter("kind = :kind");
q.setParameterList("wgList", wgList); hqlFilter.setParam("kind", Constants.REQ_TYPE_MATERIAL);
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL); return super.getCentreReq();
return q.list();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -65,13 +61,10 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_WORKGROUP_REQ')") @PostFilter("hasPermission(filterObject, 'PERM_SHOW_WORKGROUP_REQ')")
public List<Requirement> getWorkgroupReq() public List<Requirement> getWorkgroupReq()
{ {
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser()); hqlFilter.setDataClass(Requirement.class);
Query q = dao.getQuery("select tr from " hqlFilter.andFilter("kind = :kind");
+ dao.getEntityName() hqlFilter.setParam("kind", Constants.REQ_TYPE_MATERIAL);
+ " tr join fetch tr.ownedBy join tr.workgroup w where w in (:wgList) and kind = :kind order by tr.numser"); return super.getWorkgroupReq();
q.setParameterList("wgList", wgList);
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
return q.list();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -80,8 +73,9 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
@PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')") @PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')")
public List<Requirement> getAll() public List<Requirement> getAll()
{ {
Query q = dao.getQuery("from " + dao.getEntityName() + " as tr join fetch tr.ownedBy where kind = :kind order by tr.numser"); hqlFilter.setDataClass(Requirement.class);
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL); hqlFilter.andFilter("kind = :kind");
return q.list(); hqlFilter.setParam("kind", Constants.REQ_TYPE_MATERIAL);
return super.getAll();
} }
} }
@@ -3,17 +3,14 @@ package info.bukova.isspst.services.requirement;
import info.bukova.isspst.Constants; import info.bukova.isspst.Constants;
import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.RequirementState; import info.bukova.isspst.data.RequirementState;
import info.bukova.isspst.data.Workgroup;
import java.util.Date;
import java.util.List;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostFilter; import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
public class ReqServicesServiceImpl extends RequirementServiceImpl implements RequirementService, RequirementBaseService<Requirement> public class ReqServicesServiceImpl extends RequirementServiceImpl implements RequirementService, RequirementBaseService<Requirement>
{ {
@Autowired @Autowired
@@ -38,10 +35,10 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
@PreAuthorize("hasPermission(this, 'PERM_READ')") @PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<Requirement> getMy() public List<Requirement> getMy()
{ {
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner and kind = :kind"); hqlFilter.setDataClass(Requirement.class);
q.setParameter("owner", getLoggedInUser()); hqlFilter.andFilter("kind = :kind");
q.setParameter("kind", Constants.REQ_TYPE_SERVICES); hqlFilter.setParam("kind", Constants.REQ_TYPE_SERVICES);
return q.list(); return super.getMy();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -51,11 +48,10 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_CENTRE_REQ')") @PostFilter("hasPermission(filterObject, 'PERM_SHOW_CENTRE_REQ')")
public List<Requirement> getCentreReq() public List<Requirement> getCentreReq()
{ {
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser()); hqlFilter.setDataClass(Requirement.class);
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c where c in (:wgList) and kind = :kind order by tr.numser"); hqlFilter.andFilter("kind = :kind");
q.setParameterList("wgList", wgList); hqlFilter.setParam("kind", Constants.REQ_TYPE_SERVICES);
q.setParameter("kind", Constants.REQ_TYPE_SERVICES); return super.getCentreReq();
return q.list();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -65,13 +61,10 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_WORKGROUP_REQ')") @PostFilter("hasPermission(filterObject, 'PERM_SHOW_WORKGROUP_REQ')")
public List<Requirement> getWorkgroupReq() public List<Requirement> getWorkgroupReq()
{ {
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser()); hqlFilter.setDataClass(Requirement.class);
Query q = dao.getQuery("select tr from " hqlFilter.andFilter("kind = :kind");
+ dao.getEntityName() hqlFilter.setParam("kind", Constants.REQ_TYPE_SERVICES);
+ " tr join fetch tr.ownedBy join tr.workgroup w where w in (:wgList) and kind = :kind order by tr.numser"); return super.getWorkgroupReq();
q.setParameterList("wgList", wgList);
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
return q.list();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -80,8 +73,9 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
@PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')") @PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')")
public List<Requirement> getAll() public List<Requirement> getAll()
{ {
Query q = dao.getQuery("from " + dao.getEntityName() + " as tr join fetch tr.ownedBy where kind = :kind order by tr.numser"); hqlFilter.setDataClass(Requirement.class);
q.setParameter("kind", Constants.REQ_TYPE_SERVICES); hqlFilter.andFilter("kind = :kind");
return q.list(); hqlFilter.setParam("kind", Constants.REQ_TYPE_SERVICES);
return super.getAll();
} }
} }
@@ -2,8 +2,10 @@ package info.bukova.isspst.services.requirement;
import info.bukova.isspst.data.RequirementBase; import info.bukova.isspst.data.RequirementBase;
import info.bukova.isspst.data.User; import info.bukova.isspst.data.User;
import info.bukova.isspst.data.Workflow;
import info.bukova.isspst.services.Service; import info.bukova.isspst.services.Service;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@@ -21,8 +23,11 @@ public interface RequirementBaseService<T extends RequirementBase> extends Servi
public void loadType(T data); public void loadType(T data);
public void loadWorkflow(T data); public void loadWorkflow(T data);
public void approve(T entity); public void approve(T entity);
public void approve(T entity, Date approveDate, byte[] signedPdf);
public boolean canApprove(T entity); public boolean canApprove(T entity);
public List<User> getNextApprover(T entity); public List<User> getNextApprover(T entity);
public boolean prepareSignData(T entity, Date approveDate);
public Workflow getNextWorkflow(T entity);
public List<T> getMy(); public List<T> getMy();

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