Compare commits
59 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e4013f44ab | |||
| b95cac9ef1 | |||
| 5079d6d55a | |||
| a93c515bc0 | |||
| 1475babaa1 | |||
| b0fb32825b | |||
| 9d59b34900 | |||
| 47e90b4287 | |||
| b276746bac | |||
| f938403cea | |||
| b321b3e25f | |||
| cbb81657c8 | |||
| cd6b8c01dc | |||
| 012ad06358 | |||
| 88e9711154 | |||
| d2aa1cbd9a | |||
| 52cf63414b | |||
| f904e89946 | |||
| 5cae516cb6 | |||
| 6ac6d783fb | |||
| 67ff54d3f1 | |||
| 275e120021 | |||
| d20a72b336 | |||
| e24684bbd0 | |||
| 21bf006c19 | |||
| 970928bb4e | |||
| 369184940b | |||
| cc374a3bf1 | |||
| 66e0c427ac | |||
| 095089d020 | |||
| 84154ccbff | |||
| 1230959854 | |||
| 96154a6b98 | |||
| 14242fa41a | |||
| 67a99d8d78 | |||
| 768d3ee874 | |||
| cd6a6cf5a6 | |||
| d1ccaf530d | |||
| 10439b5001 | |||
| b33f9f2e8a | |||
| 07d0949bea | |||
| 2819cc125c | |||
| c0922921c5 | |||
| b70041bfff | |||
| b5ffa07644 | |||
| cccd8177fa | |||
| 6db416dd04 | |||
| 05faa87071 | |||
| 11e3a48b28 | |||
| d7999e78ca | |||
| d6cff454fd | |||
| 1d30f0d0c7 | |||
| 9fb1ef7601 | |||
| 312b62af7b | |||
| b0fedfa3f3 | |||
| dc0607c072 | |||
| 162cea6001 | |||
| 1164e11107 | |||
| c9a56887dc |
+79
@@ -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-----
|
||||||
@@ -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>
|
||||||
|
|
||||||
@@ -407,6 +407,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,6 +6,7 @@ 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;
|
||||||
@@ -17,6 +18,8 @@ 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;
|
||||||
@@ -29,6 +32,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
|
|||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
import javax.servlet.ServletContextListener;
|
import javax.servlet.ServletContextListener;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AppInitListener implements ServletContextListener {
|
public class AppInitListener implements ServletContextListener {
|
||||||
@@ -43,6 +47,7 @@ public class AppInitListener implements ServletContextListener {
|
|||||||
private RequirementTypeService reqTypeService;
|
private RequirementTypeService reqTypeService;
|
||||||
private GlobalSettingsService gSettingsService;
|
private GlobalSettingsService gSettingsService;
|
||||||
private FullTextService ftService;
|
private FullTextService ftService;
|
||||||
|
private SeasonService seasonService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void contextDestroyed(ServletContextEvent arg0) {
|
public void contextDestroyed(ServletContextEvent arg0) {
|
||||||
@@ -64,6 +69,7 @@ public class AppInitListener implements ServletContextListener {
|
|||||||
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);
|
ftService = ctx.getBean(FullTextService.class);
|
||||||
|
seasonService = ctx.getBean(SeasonService.class);
|
||||||
|
|
||||||
userService.grantAdmin();
|
userService.grantAdmin();
|
||||||
this.checkDbInfo();
|
this.checkDbInfo();
|
||||||
@@ -286,28 +292,40 @@ 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();
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
season.setDescription(String.valueOf(cal.get(Calendar.YEAR)));
|
||||||
|
season.setValidFrom(cal.getTime());
|
||||||
|
season.setActive(true);
|
||||||
|
seasonService.add(season);
|
||||||
|
}
|
||||||
|
|
||||||
if (ns == null)
|
for (Season s : seasonService.getAllSeasons()) {
|
||||||
{
|
checkNumberSeriesForSeason(s);
|
||||||
ns = new NumberSeries();
|
|
||||||
ns.setModule(Constants.MOD_ORDER);
|
|
||||||
ns.setPrefix("");
|
|
||||||
ns.setNumber(1);
|
|
||||||
nsService.add(ns);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ 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.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;
|
||||||
@@ -23,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;
|
||||||
@@ -34,7 +36,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class Constants {
|
public class Constants {
|
||||||
|
|
||||||
public final static long DB_VERSION = 5;
|
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";
|
||||||
@@ -86,6 +88,8 @@ public class Constants {
|
|||||||
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_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),
|
||||||
@@ -103,6 +107,8 @@ public class Constants {
|
|||||||
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_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";
|
||||||
@@ -113,6 +119,7 @@ public class Constants {
|
|||||||
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_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),
|
||||||
@@ -130,18 +137,37 @@ public class Constants {
|
|||||||
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_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, 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"))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 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";
|
||||||
public final static RequirementType REQTYPES[] = {
|
public final static RequirementType REQTYPES[] = {
|
||||||
@@ -156,7 +182,7 @@ 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/requirements/");
|
put(TripBillApproval.class, "/main/trips/bill/");
|
||||||
put(Order.class, "/main/orders/created/");
|
put(Order.class, "/main/orders/created/");
|
||||||
put(TripBill.class, "/main/trips/bill/");
|
put(TripBill.class, "/main/trips/bill/");
|
||||||
}} );
|
}} );
|
||||||
@@ -164,4 +190,9 @@ public class Constants {
|
|||||||
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 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
|
// Keep date - truncate time
|
||||||
return DateUtils.truncate(value, Calendar.DAY_OF_MONTH);
|
return DateUtils.truncate(value, Calendar.DAY_OF_MONTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEqualByDate(Date d1, Date d2)
|
public static int getYear(Date value) {
|
||||||
{
|
if (value == null) {
|
||||||
if (d1 != null && d2 != null)
|
return 0;
|
||||||
{
|
}
|
||||||
d1 = DateTimeUtils.getDate(d1);
|
|
||||||
d2 = DateTimeUtils.getDate(d2);
|
|
||||||
boolean equals = (d1.compareTo(d2) == 0);
|
|
||||||
return equals;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
Calendar cal =Calendar.getInstance();
|
||||||
}
|
cal.setTime(value);
|
||||||
|
return cal.get(Calendar.YEAR);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isEqualByDateForFilter(Date value, Date search)
|
public static boolean isEqualByDate(Date d1, Date d2) {
|
||||||
{
|
if (d1 != null && d2 != null) {
|
||||||
if (search == null)
|
d1 = DateTimeUtils.getDate(d1);
|
||||||
{
|
d2 = DateTimeUtils.getDate(d2);
|
||||||
return true;
|
boolean equals = (d1.compareTo(d2) == 0);
|
||||||
}
|
return equals;
|
||||||
else if (value != null)
|
}
|
||||||
{
|
|
||||||
return DateTimeUtils.isEqualByDate(value, search);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date getCurrDateTime()
|
public static boolean isEqualByYear(Date d1, Date d2) {
|
||||||
{
|
if (d1 != null && d2 != null) {
|
||||||
return new Date();
|
int year1 = DateTimeUtils.getYear(d1);
|
||||||
}
|
int year2 = DateTimeUtils.getYear(d2);
|
||||||
|
boolean equals = (year1 == year2);
|
||||||
|
return equals;
|
||||||
|
}
|
||||||
|
|
||||||
public static Date getCurrDate()
|
return false;
|
||||||
{
|
}
|
||||||
return DateTimeUtils.getDate(DateTimeUtils.getCurrDateTime());
|
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,5 +1,12 @@
|
|||||||
package info.bukova.isspst;
|
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.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -38,6 +45,48 @@ public class ModuleUtils {
|
|||||||
return null;
|
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) {
|
public static boolean isActive(String id) {
|
||||||
return getModule(id).isActive();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@ public class TripBillAprovalUrlResolver implements EntityUrlResolver {
|
|||||||
if (entity instanceof TripBillApproval) {
|
if (entity instanceof TripBillApproval) {
|
||||||
String url = Constants.URL_MAP.get(entity.getClass());
|
String url = Constants.URL_MAP.get(entity.getClass());
|
||||||
|
|
||||||
return defUrl + url + "?select=" + String.valueOf(((TripBillApproval)entity).getBill().getRequirement().getId());
|
return defUrl + url + "?select=" + String.valueOf(((TripBillApproval)entity).getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return defUrl + "/app";
|
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,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 {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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,17 +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 implements Cloneable
|
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)
|
||||||
@@ -69,6 +70,18 @@ public class Invoicing extends BaseData implements Cloneable
|
|||||||
this.completed = completed;
|
this.completed = completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getInvoiceNumbers() {
|
||||||
|
String ret = "";
|
||||||
|
for (InvoicingItem invNum : items) {
|
||||||
|
if (!ret.isEmpty()) {
|
||||||
|
ret += ", ";
|
||||||
|
}
|
||||||
|
ret += invNum.getInvoiceNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException
|
public Object clone() throws CloneNotSupportedException
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,21 +1,6 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
import info.bukova.isspst.Constants;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.persistence.AttributeOverride;
|
|
||||||
import javax.persistence.AttributeOverrides;
|
|
||||||
import javax.persistence.CascadeType;
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Embedded;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.OneToMany;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
import org.hibernate.annotations.LazyCollection;
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
import org.hibernate.annotations.LazyCollectionOption;
|
||||||
import org.hibernate.search.annotations.Analyze;
|
import org.hibernate.search.annotations.Analyze;
|
||||||
@@ -24,10 +9,26 @@ import org.hibernate.search.annotations.Index;
|
|||||||
import org.hibernate.search.annotations.Indexed;
|
import org.hibernate.search.annotations.Indexed;
|
||||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
import org.hibernate.search.annotations.IndexedEmbedded;
|
||||||
|
|
||||||
|
import javax.persistence.AttributeOverride;
|
||||||
|
import javax.persistence.AttributeOverrides;
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Embedded;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "ORDERS")
|
@Table(name = "ORDERS")
|
||||||
@Indexed
|
@Indexed
|
||||||
public class Order extends BaseData implements Cloneable
|
public class Order extends BaseData implements Cloneable, SeasonsAware
|
||||||
{
|
{
|
||||||
|
|
||||||
@Column(name = "NUMSER")
|
@Column(name = "NUMSER")
|
||||||
@@ -121,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>();
|
||||||
@@ -288,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
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.util.ArrayList;
|
import org.hibernate.annotations.LazyCollectionOption;
|
||||||
import java.util.Date;
|
import org.hibernate.search.annotations.Analyze;
|
||||||
import java.util.List;
|
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,17 +18,13 @@ 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;
|
||||||
import org.hibernate.search.annotations.Analyze;
|
|
||||||
import org.hibernate.search.annotations.Field;
|
|
||||||
import org.hibernate.search.annotations.Index;
|
|
||||||
import org.hibernate.search.annotations.Indexed;
|
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
@Indexed
|
@Indexed
|
||||||
public class RequirementBase extends BaseData implements FilterableRequirement {
|
public class RequirementBase extends BaseData implements FilterableRequirement, SeasonsAware {
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "TYPE_ID")
|
@JoinColumn(name = "TYPE_ID")
|
||||||
@@ -56,6 +54,9 @@ 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")
|
||||||
|
private Season season;
|
||||||
|
|
||||||
public RequirementBase() {
|
public RequirementBase() {
|
||||||
authorization = new ArrayList<AuthItem>();
|
authorization = new ArrayList<AuthItem>();
|
||||||
@@ -152,4 +153,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pepa Rokos
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "SEASON")
|
||||||
|
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();
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ public class SettingsData {
|
|||||||
private MailMessage authReqTemplate;
|
private MailMessage authReqTemplate;
|
||||||
private MailMessage confReqTemplate;
|
private MailMessage confReqTemplate;
|
||||||
private MailMessage confReqTripPassenger;
|
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;
|
||||||
@@ -30,6 +31,7 @@ public class SettingsData {
|
|||||||
authReqTemplate = new MailMessage();
|
authReqTemplate = new MailMessage();
|
||||||
confReqTemplate = new MailMessage();
|
confReqTemplate = new MailMessage();
|
||||||
confReqTripPassenger = 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>();
|
||||||
@@ -160,4 +162,12 @@ public class SettingsData {
|
|||||||
public void setConfReqTripPassenger(MailMessage confReqTripPassenger) {
|
public void setConfReqTripPassenger(MailMessage confReqTripPassenger) {
|
||||||
this.confReqTripPassenger = 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,21 +2,6 @@ package info.bukova.isspst.data;
|
|||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
import info.bukova.isspst.Constants;
|
||||||
import info.bukova.isspst.storage.EntityWithAttachment;
|
import info.bukova.isspst.storage.EntityWithAttachment;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.FetchType;
|
|
||||||
import javax.persistence.JoinColumn;
|
|
||||||
import javax.persistence.OneToMany;
|
|
||||||
import javax.persistence.OneToOne;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
import org.hibernate.annotations.LazyCollection;
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
import org.hibernate.annotations.LazyCollectionOption;
|
||||||
import org.hibernate.search.annotations.Analyze;
|
import org.hibernate.search.annotations.Analyze;
|
||||||
@@ -25,10 +10,24 @@ import org.hibernate.search.annotations.Index;
|
|||||||
import org.hibernate.search.annotations.Indexed;
|
import org.hibernate.search.annotations.Indexed;
|
||||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
import org.hibernate.search.annotations.IndexedEmbedded;
|
||||||
|
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "TRIP_BILL")
|
@Table(name = "TRIP_BILL")
|
||||||
@Indexed
|
@Indexed
|
||||||
public class TripBill extends BaseData implements EntityWithAttachment {
|
public class TripBill extends BaseData implements EntityWithAttachment, SeasonsAware {
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.EAGER)
|
@OneToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "REQUIREMENT_ID")
|
@JoinColumn(name = "REQUIREMENT_ID")
|
||||||
@@ -62,11 +61,18 @@ public class TripBill extends BaseData implements EntityWithAttachment {
|
|||||||
@LazyCollection(LazyCollectionOption.TRUE)
|
@LazyCollection(LazyCollectionOption.TRUE)
|
||||||
@IndexedEmbedded
|
@IndexedEmbedded
|
||||||
private List<FileMetainfo> attachedFiles;
|
private List<FileMetainfo> attachedFiles;
|
||||||
@OneToOne(fetch = FetchType.EAGER)
|
@OneToOne(fetch = FetchType.EAGER, orphanRemoval = true)
|
||||||
@JoinColumn(name = "APPROVAL_ID")
|
@JoinColumn(name = "APPROVAL_ID")
|
||||||
private TripBillApproval approval;
|
private TripBillApproval approval;
|
||||||
@Column(name = "SAVED")
|
@Column(name = "SAVED")
|
||||||
private Boolean 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")
|
||||||
|
private Season season;
|
||||||
|
|
||||||
public TripBill() {
|
public TripBill() {
|
||||||
billItems = new ArrayList<TripBillItem>();
|
billItems = new ArrayList<TripBillItem>();
|
||||||
@@ -188,4 +194,29 @@ public class TripBill extends BaseData implements EntityWithAttachment {
|
|||||||
public void setSaved(Boolean saved) {
|
public void setSaved(Boolean saved) {
|
||||||
this.saved = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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")
|
||||||
@@ -25,6 +24,8 @@ public class Workflow extends BaseData {
|
|||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,78 @@
|
|||||||
|
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());
|
||||||
|
return foundNumser && foundReqDate && foundDescription && foundFrom && foundTo && foundWorkgroup && foundCentre && foundOwner && foundPaid && foundPaidDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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,5 +1,6 @@
|
|||||||
package info.bukova.isspst.reporting;
|
package info.bukova.isspst.reporting;
|
||||||
|
|
||||||
|
import com.mysql.jdbc.StringUtils;
|
||||||
import info.bukova.isspst.data.Address;
|
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;
|
||||||
@@ -8,15 +9,15 @@ 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 java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import com.mysql.jdbc.StringUtils;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ParamFiller {
|
public class ParamFiller {
|
||||||
|
|
||||||
@@ -30,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()) {
|
||||||
@@ -57,25 +62,31 @@ 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 lastButOneAuth = tb.getRequirement().getAuthorization().get(0);
|
if (tb.getApproval() != null) {
|
||||||
definition.setParam("P_PREV_APPROVE_DATE", lastButOneAuth.getAuthDate());
|
tripBillApprovalService.loadAuthItems(tb.getApproval());
|
||||||
|
|
||||||
User lastButOneUser = lastButOneAuth.getApprover();
|
|
||||||
UserSettingsData prevApproverSettings = userService.getUserSettings(lastButOneUser);
|
|
||||||
|
|
||||||
if (prevApproverSettings != null && !StringUtils.isNullOrEmpty(prevApproverSettings.getSignatureFile())) {
|
|
||||||
definition.setParam("P_PREV_APPROVER_SIGNATURE", storage.serverPath(prevApproverSettings.getSignatureFile()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tb.getApproval() != null && tb.getApproval().getAuthorization() != null && !tb.getApproval().getAuthorization().isEmpty()) {
|
||||||
|
|
||||||
AuthItem lastAuth = tb.getRequirement().getAuthorization().get(tb.getRequirement().getAuthorization().size() - 1);
|
AuthItem lastButOneAuth = tb.getApproval().getAuthorization().get(0);
|
||||||
definition.setParam("P_APPROVE_DATE", lastAuth.getAuthDate());
|
definition.setParam("P_PREV_APPROVE_DATE", lastButOneAuth.getAuthDate());
|
||||||
|
|
||||||
User u = lastAuth.getApprover();
|
User lastButOneUser = lastButOneAuth.getApprover();
|
||||||
UserSettingsData approverSettings = userService.getUserSettings(u);
|
UserSettingsData prevApproverSettings = userService.getUserSettings(lastButOneUser);
|
||||||
|
|
||||||
if (approverSettings != null && !StringUtils.isNullOrEmpty(approverSettings.getSignatureFile())) {
|
if (prevApproverSettings != null && !StringUtils.isNullOrEmpty(prevApproverSettings.getSignatureFile())) {
|
||||||
definition.setParam("P_APPROVER_SIGNATURE", storage.serverPath(approverSettings.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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,6 +99,7 @@ public class ParamFiller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
definition.setParam("P_LOGO", storage.serverPath(settingService.getSettings().getLogoFile()));
|
definition.setParam("P_LOGO", storage.serverPath(settingService.getSettings().getLogoFile()));
|
||||||
|
definition.setParam(JRParameter.REPORT_LOCALE, req.getLocale());
|
||||||
|
|
||||||
Address mainAddress = settingService.getSettings().getMainAddress();
|
Address mainAddress = settingService.getSettings().getMainAddress();
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
||||||
@@ -29,6 +32,11 @@ 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());
|
||||||
@@ -44,6 +52,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,60 +4,80 @@ 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 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;
|
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 name
|
||||||
* @param jasperFile
|
* @param jasperFile
|
||||||
* @param hasSettings
|
* @param hasSettings
|
||||||
* @param singleRecord
|
* @param singleRecord
|
||||||
* @param hasCondition
|
* @param hasCondition
|
||||||
*/
|
*/
|
||||||
public Report(String name, String jasperFile, boolean hasSettings, boolean singleRecord, boolean hasCondition) {
|
public Report(long reportId, boolean signable, String name, String jasperFile, boolean hasSettings, boolean singleRecord, boolean hasCondition) {
|
||||||
this(name, jasperFile, hasSettings, singleRecord);
|
this(reportId, signable, name, jasperFile, hasSettings, singleRecord);
|
||||||
this.hasCondition = hasCondition;
|
this.hasCondition = hasCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,4 +128,28 @@ public class Report {
|
|||||||
public void setHasCondition(boolean hasCondition) {
|
public void setHasCondition(boolean hasCondition) {
|
||||||
this.hasCondition = 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import info.bukova.isspst.storage.DocumentFileStorage;
|
|||||||
import org.hibernate.NonUniqueResultException;
|
import org.hibernate.NonUniqueResultException;
|
||||||
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.core.GenericTypeResolver;
|
||||||
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;
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ 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;
|
||||||
@@ -36,12 +38,26 @@ 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 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) {
|
public void setDocumentFileStorage(DocumentFileStorage storage) {
|
||||||
this.documentFileStorage = storage;
|
this.documentFileStorage = storage;
|
||||||
}
|
}
|
||||||
@@ -74,6 +90,50 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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')")
|
||||||
public final T create() {
|
public final T create() {
|
||||||
@@ -186,7 +246,9 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
throw new ModuleNotActiveException();
|
throw new ModuleNotActiveException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.getAll();
|
Query q = dao.getQuery("from " + dao.getEntityName());
|
||||||
|
|
||||||
|
return filterQuery(q).list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,5 +23,6 @@ public interface Service<T> {
|
|||||||
public Module getModule();
|
public Module getModule();
|
||||||
public List<Report> getReports();
|
public List<Report> getReports();
|
||||||
public boolean canPrintRecord(T entity);
|
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()
|
||||||
@@ -142,6 +141,76 @@ public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfo
|
|||||||
sq.executeUpdate();
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package info.bukova.isspst.services.invoicing;
|
package info.bukova.isspst.services.invoicing;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -11,6 +13,8 @@ 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);
|
||||||
|
|
||||||
public void loadItems(Invoicing invoicing);
|
public void loadItems(Invoicing invoicing);
|
||||||
@@ -20,4 +24,14 @@ public interface InvoicingService extends Service<Invoicing> {
|
|||||||
public List<Invoicing> getPendingList();
|
public List<Invoicing> getPendingList();
|
||||||
|
|
||||||
public List<Invoicing> getArchiveList();
|
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;
|
||||||
@@ -92,4 +114,53 @@ public class InvoicingServiceImpl extends AbstractOwnedService<Invoicing> implem
|
|||||||
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");
|
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();
|
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");
|
||||||
|
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");
|
||||||
|
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");
|
||||||
|
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");
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-5
@@ -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")
|
||||||
|
|||||||
@@ -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,6 +2,7 @@ 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.Date;
|
||||||
@@ -22,9 +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);
|
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();
|
||||||
|
|
||||||
|
|||||||
+203
-18
@@ -1,23 +1,40 @@
|
|||||||
package info.bukova.isspst.services.requirement;
|
package info.bukova.isspst.services.requirement;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
import info.bukova.isspst.Constants;
|
||||||
|
import info.bukova.isspst.Module;
|
||||||
|
import info.bukova.isspst.ModuleUtils;
|
||||||
import info.bukova.isspst.data.AuthItem;
|
import info.bukova.isspst.data.AuthItem;
|
||||||
|
import info.bukova.isspst.data.DataModel;
|
||||||
import info.bukova.isspst.data.JobMapping;
|
import info.bukova.isspst.data.JobMapping;
|
||||||
import info.bukova.isspst.data.RequirementBase;
|
import info.bukova.isspst.data.RequirementBase;
|
||||||
import info.bukova.isspst.data.RequirementState;
|
import info.bukova.isspst.data.RequirementState;
|
||||||
import info.bukova.isspst.data.Role;
|
import info.bukova.isspst.data.Role;
|
||||||
import info.bukova.isspst.data.SettingsData;
|
import info.bukova.isspst.data.SettingsData;
|
||||||
|
import info.bukova.isspst.data.SignedDocument;
|
||||||
|
import info.bukova.isspst.data.SignedDocumentItem;
|
||||||
import info.bukova.isspst.data.User;
|
import info.bukova.isspst.data.User;
|
||||||
import info.bukova.isspst.data.Workflow;
|
import info.bukova.isspst.data.Workflow;
|
||||||
import info.bukova.isspst.data.Workgroup;
|
import info.bukova.isspst.data.Workgroup;
|
||||||
import info.bukova.isspst.mail.MailMessage;
|
import info.bukova.isspst.mail.MailMessage;
|
||||||
import info.bukova.isspst.mail.Mailer;
|
import info.bukova.isspst.mail.Mailer;
|
||||||
import info.bukova.isspst.mail.MessageBuilder;
|
import info.bukova.isspst.mail.MessageBuilder;
|
||||||
|
import info.bukova.isspst.reporting.Generator;
|
||||||
|
import info.bukova.isspst.reporting.GeneratorFactory;
|
||||||
|
import info.bukova.isspst.reporting.ParamFiller;
|
||||||
|
import info.bukova.isspst.reporting.Report;
|
||||||
|
import info.bukova.isspst.reporting.ReportDefinition;
|
||||||
import info.bukova.isspst.services.AbstractOwnedService;
|
import info.bukova.isspst.services.AbstractOwnedService;
|
||||||
|
import info.bukova.isspst.services.HqlDataFilter;
|
||||||
import info.bukova.isspst.services.LazyLoader;
|
import info.bukova.isspst.services.LazyLoader;
|
||||||
|
import info.bukova.isspst.services.Service;
|
||||||
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
||||||
|
import info.bukova.isspst.services.settings.SeasonService;
|
||||||
|
import info.bukova.isspst.services.signeddocs.SignedDocumentService;
|
||||||
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 info.bukova.isspst.signapi.SignData;
|
||||||
|
import info.bukova.isspst.storage.FileStorage;
|
||||||
|
import info.bukova.isspst.storage.ReportFileStorage;
|
||||||
import org.hibernate.LazyInitializationException;
|
import org.hibernate.LazyInitializationException;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -25,9 +42,11 @@ 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 javax.servlet.ServletContext;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Pepa Rokos
|
* @author Pepa Rokos
|
||||||
@@ -50,6 +69,23 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected WorkgroupService workgroupService;
|
protected WorkgroupService workgroupService;
|
||||||
|
@Autowired
|
||||||
|
private ReportDefinition reportDefinition;
|
||||||
|
@Autowired
|
||||||
|
private ParamFiller paramFiller;
|
||||||
|
@Autowired
|
||||||
|
private GeneratorFactory genFactory;
|
||||||
|
@Autowired
|
||||||
|
private ServletContext servletContext;
|
||||||
|
@Autowired
|
||||||
|
private FileStorage storage;
|
||||||
|
@Autowired
|
||||||
|
private SignedDocumentService signedDocumentService;
|
||||||
|
@Autowired
|
||||||
|
private ReportFileStorage signedDocStorage;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SeasonService seasonService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -58,7 +94,11 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
Workgroup reqWorkgroup = null;
|
Workgroup reqWorkgroup = null;
|
||||||
for (Workgroup w : workgroupService.getUserWorkgroups(getLoggedInUser())) {
|
for (Workgroup w : workgroupService.getUserWorkgroups(getLoggedInUser())) {
|
||||||
if (workgroupService.getMembers(entity.getCentre()).contains(w)) {
|
if (workgroupService.getMembers(entity.getCentre()).contains(w)) {
|
||||||
reqWorkgroup = w;
|
for (Role r : workgroupService.getUserWorkgroupRoles(w, getLoggedInUser())) {
|
||||||
|
if (r.getAuthority().equals(Constants.ROLE_USER)) {
|
||||||
|
reqWorkgroup = w;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +110,8 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
throw new AddRequirementException();
|
throw new AddRequirementException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entity.setSeason(seasonService.getActive());
|
||||||
|
|
||||||
this.addWorkflow(entity);
|
this.addWorkflow(entity);
|
||||||
entity.setNumser(this.getNumberSerie());
|
entity.setNumser(this.getNumberSerie());
|
||||||
|
|
||||||
@@ -100,7 +142,8 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void postAdd(T entity) {
|
protected void postAdd(T entity) {
|
||||||
if (canApprove(entity)) {
|
Workflow wf = getNextWorkflow(entity);
|
||||||
|
if (canApprove(entity) && (wf.getSignature() == null || !wf.getSignature())) {
|
||||||
approve(entity);
|
approve(entity);
|
||||||
} else {
|
} else {
|
||||||
this.sendToApprovers(entity);
|
this.sendToApprovers(entity);
|
||||||
@@ -119,6 +162,7 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
workflow.setLimit(w.getLimit());
|
workflow.setLimit(w.getLimit());
|
||||||
workflow.setOrder(w.getOrder());
|
workflow.setOrder(w.getOrder());
|
||||||
workflow.setRole(w.getRole());
|
workflow.setRole(w.getRole());
|
||||||
|
workflow.setSignature(w.getSignature());
|
||||||
entity.getWorkflow().add(workflow);
|
entity.getWorkflow().add(workflow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,7 +258,7 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void approve(T entity, User user, Date approveDate) {
|
protected void approve(T entity, User user, Date approveDate, byte[] signedPdf) {
|
||||||
T e = (T) dao.getById(entity.getId());
|
T e = (T) dao.getById(entity.getId());
|
||||||
|
|
||||||
if (e.getReqDate().getTime() > approveDate.getTime()) {
|
if (e.getReqDate().getTime() > approveDate.getTime()) {
|
||||||
@@ -246,6 +290,12 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
|
|
||||||
super.update(e);
|
super.update(e);
|
||||||
|
|
||||||
|
if (signedPdf != null) {
|
||||||
|
saveSignedDoc(e, signedPdf);
|
||||||
|
} else if (wf.getSignature() != null && wf.getSignature() && !signatureNotRequired(wf)) {
|
||||||
|
throw new ApproveException("ErrApproveMustBeSigned");
|
||||||
|
}
|
||||||
|
|
||||||
if (!autoApprove(e, approveDate)) {
|
if (!autoApprove(e, approveDate)) {
|
||||||
this.sendToApprovers(e);
|
this.sendToApprovers(e);
|
||||||
|
|
||||||
@@ -272,8 +322,17 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
postApprove(e);
|
postApprove(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check pro automatické schválení, kdy není třeba podepisovat- nadlimitní nákupy se neautorizují...
|
||||||
|
* @param wf Další krok schválení
|
||||||
|
* @return true pokud není potřeba podepisovat. Zde vrací vždy false, v případě potřeby nutno překrýt.
|
||||||
|
*/
|
||||||
|
protected boolean signatureNotRequired(Workflow wf) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected void approve(T entity, User user) {
|
protected void approve(T entity, User user) {
|
||||||
approve(entity, user, new Date());
|
approve(entity, user, new Date(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -286,8 +345,8 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize("this.canApprove(#entity)")
|
@PreAuthorize("this.canApprove(#entity)")
|
||||||
public void approve(T entity, Date approveDate) {
|
public void approve(T entity, Date approveDate, byte[] signedPdf) {
|
||||||
approve(entity, getLoggedInUser(), approveDate);
|
approve(entity, getLoggedInUser(), approveDate, signedPdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -310,6 +369,30 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void saveSignedDoc(T entity, byte[] signedPdf) {
|
||||||
|
DataModel reportEntity = entityForSignReport(entity);
|
||||||
|
SignedDocumentItem signedItem = signedDocumentService.getItem(entityForSignReport(entity), getSignReport(entity).getReportId());
|
||||||
|
|
||||||
|
if (signedItem == null) {
|
||||||
|
SignedDocument signDoc = new SignedDocument();
|
||||||
|
signDoc.setDescription(entity.getDescription());
|
||||||
|
signDoc.setNumser(entity.getNumser());
|
||||||
|
signDoc.setRecordId(reportEntity.getId());
|
||||||
|
signDoc.setModuleName(ModuleUtils.getModule(reportEntity, servletContext).getId());
|
||||||
|
signDoc.setSignDate(entity.getLastApproveDate());
|
||||||
|
|
||||||
|
SignedDocumentItem item = new SignedDocumentItem();
|
||||||
|
item.setReportId(reportDefinition.getReport().getReportId());
|
||||||
|
item.setReportName(reportDefinition.getReport().getName());
|
||||||
|
signDoc.addItem(item);
|
||||||
|
|
||||||
|
signedDocStorage.saveFile(signedPdf, item);
|
||||||
|
signedDocumentService.addFromApprove(signDoc);
|
||||||
|
} else {
|
||||||
|
signedDocStorage.saveFile(signedPdf, signedItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean canApprove(T entity) {
|
public boolean canApprove(T entity) {
|
||||||
@@ -321,7 +404,11 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Workflow getNextWorkflow(T e) {
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Workflow getNextWorkflow(T entity) {
|
||||||
|
T e = dao.getById(entity.getId());
|
||||||
|
|
||||||
AuthItem authItem = null;
|
AuthItem authItem = null;
|
||||||
if (e.getWorkflow() == null) {
|
if (e.getWorkflow() == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -357,9 +444,10 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
||||||
public List<T> getMy()
|
public List<T> getMy()
|
||||||
{
|
{
|
||||||
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner");
|
Query q = dao.getQuery("from " + dao.getEntityName());
|
||||||
q.setParameter("owner", getLoggedInUser());
|
HqlDataFilter f = new HqlDataFilter("ownedBy = :owner");
|
||||||
return q.list();
|
f.setParam("owner", getLoggedInUser());
|
||||||
|
return filterQuery(q, f).list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -370,9 +458,10 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
public List<T> getCentreReq()
|
public List<T> getCentreReq()
|
||||||
{
|
{
|
||||||
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser());
|
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser());
|
||||||
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c where c in (:wgList) order by tr.numser");
|
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c");
|
||||||
q.setParameterList("wgList", wgList);
|
HqlDataFilter f = new HqlDataFilter("c in (:wgList)", "tr.numser desc");
|
||||||
return q.list();
|
f.setParam("wgList", wgList);
|
||||||
|
return filterQuery(q, f).list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -383,9 +472,10 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
public List<T> getWorkgroupReq()
|
public List<T> getWorkgroupReq()
|
||||||
{
|
{
|
||||||
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser());
|
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser());
|
||||||
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.workgroup w where w in (:wgList) order by tr.numser");
|
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.workgroup w");
|
||||||
q.setParameterList("wgList", wgList);
|
HqlDataFilter f = new HqlDataFilter("w in (:wgList)", "tr.numser desc");
|
||||||
return q.list();
|
f.setParam("wgList", wgList);
|
||||||
|
return filterQuery(q, f).list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -394,8 +484,9 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
@PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')")
|
@PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')")
|
||||||
public List<T> getAll()
|
public List<T> getAll()
|
||||||
{
|
{
|
||||||
Query q = dao.getQuery("from " + dao.getEntityName() + " as tr join fetch tr.ownedBy order by tr.numser");
|
Query q = dao.getQuery("from " + dao.getEntityName() + " as tr join fetch tr.ownedBy");
|
||||||
return q.list();
|
HqlDataFilter f = new HqlDataFilter("", "tr.numser desc");
|
||||||
|
return filterQuery(q, f).list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -408,4 +499,98 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
return Constants.PERM_DELETE_NEW;
|
return Constants.PERM_DELETE_NEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public boolean prepareSignData(T entity, Date approveDate) {
|
||||||
|
SignData data = new SignData();
|
||||||
|
sessionData.setProperty(Constants.KEY_SIGN_DATA, data);
|
||||||
|
data.setSignGuid(UUID.randomUUID().toString());
|
||||||
|
sessionData.setProperty(Constants.KEY_SIGN_GUID, data.getSignGuid());
|
||||||
|
|
||||||
|
reportDefinition.clear();
|
||||||
|
reportDefinition.setSingleObject(entityForSignReport(entity));
|
||||||
|
|
||||||
|
Report report = getSignReport(entity);
|
||||||
|
|
||||||
|
if (report == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
reportDefinition.setReport(report);
|
||||||
|
Module module = ModuleUtils.getModule(entityForSignReport(entity), servletContext);
|
||||||
|
reportDefinition.setService((Service<Object>) ModuleUtils.getServiceInstance(module, servletContext));
|
||||||
|
|
||||||
|
paramFiller.fill();
|
||||||
|
Generator gen = genFactory.createGenerator(reportDefinition);
|
||||||
|
data.setPdfData(gen.generate());
|
||||||
|
data.setDescription(entity.getDescription());
|
||||||
|
data.setNumser(entity.getNumser());
|
||||||
|
data.setSignDate(approveDate);
|
||||||
|
data.setSigned(signedDocumentService.getItem(entityForSignReport(entity), report.getReportId()) != null);
|
||||||
|
|
||||||
|
if (getNextWorkflow(entity).getCentre()) { // viditelné podpisy lze pouze na urovni strediska
|
||||||
|
if (entity.getState() == RequirementState.NEW) {
|
||||||
|
data.setAreaId(1);
|
||||||
|
} else {
|
||||||
|
loadAuthItems(entity);
|
||||||
|
int wgCount = 0;
|
||||||
|
for (Workflow wf : entity.getWorkflow()) {
|
||||||
|
if (!wf.getCentre()) {
|
||||||
|
++wgCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.setAreaId(entity.getAuthorization().size() - wgCount + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userService.getUserSettings().getSignatureFile() != null) {
|
||||||
|
data.setSignImg(storage.fileData(userService.getUserSettings().getSignatureFile()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DataModel entityForSignReport(T entity) {
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Report getSignReport(T entity) {
|
||||||
|
Module module = ModuleUtils.getModule(entityForSignReport(entity), servletContext);
|
||||||
|
Report report = null;
|
||||||
|
int reportId = Constants.SIGN_REPORT_MAP.get(entity.getClass()) == null ? 0 : Constants.SIGN_REPORT_MAP.get(entity.getClass());
|
||||||
|
|
||||||
|
for (Report r : module.getReports()) {
|
||||||
|
if (r.isSignable()) {
|
||||||
|
if (reportId == 0) {
|
||||||
|
report = r;
|
||||||
|
break;
|
||||||
|
} else if (reportId == r.getReportId()) {
|
||||||
|
report = r;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
|
||||||
|
public void update(T entity) {
|
||||||
|
entity.getAuthorization().clear();
|
||||||
|
entity.setState(RequirementState.NEW);
|
||||||
|
signedDocumentService.deleteForEntity(entity);
|
||||||
|
|
||||||
|
super.update(entity);
|
||||||
|
sendToApprovers(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@PreAuthorize("hasPermission(this, 'PERM_DELETE') or hasPermission(#entity, this.getDeleteEntityPermission())")
|
||||||
|
public void delete(T entity) {
|
||||||
|
signedDocumentService.delFromApprove(signedDocumentService.getForEntity(entity));
|
||||||
|
super.delete(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package info.bukova.isspst.services.requirement;
|
|||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
import info.bukova.isspst.Constants;
|
||||||
import info.bukova.isspst.data.Invoicing;
|
import info.bukova.isspst.data.Invoicing;
|
||||||
|
import info.bukova.isspst.data.Limit;
|
||||||
import info.bukova.isspst.data.Requirement;
|
import info.bukova.isspst.data.Requirement;
|
||||||
import info.bukova.isspst.data.RequirementItem;
|
import info.bukova.isspst.data.RequirementItem;
|
||||||
import info.bukova.isspst.data.RequirementState;
|
import info.bukova.isspst.data.RequirementState;
|
||||||
@@ -10,9 +11,10 @@ import info.bukova.isspst.data.User;
|
|||||||
import info.bukova.isspst.data.Workflow;
|
import info.bukova.isspst.data.Workflow;
|
||||||
import info.bukova.isspst.services.LazyLoader;
|
import info.bukova.isspst.services.LazyLoader;
|
||||||
import info.bukova.isspst.services.invoicing.InvoicingService;
|
import info.bukova.isspst.services.invoicing.InvoicingService;
|
||||||
|
import info.bukova.isspst.services.limits.LimitService;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
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.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -33,6 +35,8 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requireme
|
|||||||
private RequirementTypeService reqTypeService;
|
private RequirementTypeService reqTypeService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private InvoicingService invoicingService;
|
private InvoicingService invoicingService;
|
||||||
|
@Autowired
|
||||||
|
private LimitService limitService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Requirement createEntity()
|
protected Requirement createEntity()
|
||||||
@@ -60,36 +64,45 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requireme
|
|||||||
if ((entity.getSumTotal() != null)
|
if ((entity.getSumTotal() != null)
|
||||||
&& (entity.getSumTotal().compareTo(nextWf.getLimit()) == -1))
|
&& (entity.getSumTotal().compareTo(nextWf.getLimit()) == -1))
|
||||||
{
|
{
|
||||||
approve(entity, approvers.get(0), approveDate);
|
approve(entity, approvers.get(0), approveDate, null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nadlimitní autorizovat bez podpisu
|
||||||
|
* @param wf Další krok schválení
|
||||||
|
* @return true, pokud má role nastavený limit- automatické schválení podlimitního požadavku
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean signatureNotRequired(Workflow wf) {
|
||||||
|
return wf.getLimit() != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canAdd(Requirement entity)
|
protected boolean canAdd(Requirement entity)
|
||||||
{
|
{
|
||||||
if (entity.getWorkgroup() != null && entity.getWorkgroup().getLimit() != null && entity.getWorkgroup().getLimit().compareTo(BigDecimal.ZERO) != 0)
|
if (entity.getWorkgroup() != null) {
|
||||||
{
|
Limit limit = limitService.getForWorkgroup(entity.getWorkgroup());
|
||||||
|
if (limit == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
BigDecimal total = invoicingService.totalInvoicedForWorkgroup(entity.getWorkgroup());
|
BigDecimal total = invoicingService.totalInvoicedForWorkgroup(entity.getWorkgroup());
|
||||||
|
|
||||||
if (total == null)
|
if (total == null) {
|
||||||
{
|
|
||||||
total = BigDecimal.ZERO;
|
total = BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
total = total.add(entity.getSumTotal());
|
total = total.add(entity.getSumTotal());
|
||||||
|
|
||||||
if (total.compareTo(entity.getWorkgroup().getLimit()) <= 0)
|
if (total.compareTo(limit.getLimit()) <= 0) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,11 +257,19 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requireme
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public BigDecimal getInvoicedAmount(Requirement req) {
|
public BigDecimal getInvoicedAmount(Requirement req) {
|
||||||
Query query = dao.getQuery("select invoice from Invoicing invoice join invoice.requirement rq where rq.id = :reqId");
|
Invoicing inv = invoicingService.getForRequirement(req);
|
||||||
query.setParameter("reqId", req.getId());
|
|
||||||
|
|
||||||
Invoicing inv = (Invoicing) query.uniqueResult();
|
|
||||||
|
|
||||||
return inv != null ? inv.getTotalInvoiced() : null;
|
return inv != null ? inv.getTotalInvoiced() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
|
||||||
|
public void update(Requirement entity) {
|
||||||
|
super.update(entity);
|
||||||
|
Invoicing inv = invoicingService.getForRequirement(entity);
|
||||||
|
|
||||||
|
if (inv != null) {
|
||||||
|
invoicingService.delete(inv);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+56
-18
@@ -57,8 +57,6 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
|
|||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
|
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
|
||||||
public void update(TripRequirement entity) {
|
public void update(TripRequirement entity) {
|
||||||
super.update(entity);
|
|
||||||
|
|
||||||
if (entity.getState() == RequirementState.APPROVED) {
|
if (entity.getState() == RequirementState.APPROVED) {
|
||||||
for (TripBill bill : getBills(entity)) {
|
for (TripBill bill : getBills(entity)) {
|
||||||
TripBill newBill = tripBillService.createTripBill(entity);
|
TripBill newBill = tripBillService.createTripBill(entity);
|
||||||
@@ -75,6 +73,23 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
|
|||||||
tripBillService.update(bill);
|
tripBillService.update(bill);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.update(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void postAdd(TripRequirement entity) {
|
||||||
|
super.postAdd(entity);
|
||||||
|
sendMailToPassengers(entity, settingsService.getSettings().getReqPassenger());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendMailToPassengers(TripRequirement entity, MailMessage messageTemplate) {
|
||||||
|
if (entity.getBillForPassengers() != null && !entity.getPassengers().isEmpty() && messageTemplate != null) {
|
||||||
|
MailMessage message = messageBuilder.buildMessage(messageTemplate, entity);
|
||||||
|
message.setFrom(userService.getCurrent().getEmail());
|
||||||
|
message.setTo(userService.getEmailsForSend(entity.getPassengers()));
|
||||||
|
mailer.send(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -126,32 +141,55 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void postApprove(TripRequirement entity) {
|
protected void postApprove(TripRequirement entity) {
|
||||||
if (entity.getState() == RequirementState.APPROVED) {
|
if (entity.getState() != RequirementState.APPROVED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TripBill> billList = getBills(entity);
|
||||||
|
boolean hasOwned = false;
|
||||||
|
|
||||||
|
for (TripBill tb : billList) {
|
||||||
|
if (tb.getOwnedBy().equals(entity.getOwnedBy())) {
|
||||||
|
hasOwned = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasOwned) {
|
||||||
TripBill bill = tripBillService.createTripBill(entity);
|
TripBill bill = tripBillService.createTripBill(entity);
|
||||||
tripBillService.add(bill);
|
tripBillService.add(bill);
|
||||||
bill.setOwnedBy(entity.getOwnedBy());
|
bill.setOwnedBy(entity.getOwnedBy());
|
||||||
tripBillService.update(bill);
|
tripBillService.update(bill);
|
||||||
|
}
|
||||||
|
|
||||||
if (entity.getBillForPassengers() != null && entity.getBillForPassengers()) {
|
if (entity.getBillForPassengers() != null && entity.getBillForPassengers()) {
|
||||||
for (User u : entity.getPassengers()) {
|
for (User u : entity.getPassengers()) {
|
||||||
if (!u.equals(entity.getOwnedBy())) {
|
if (canCreateBill(entity, u, billList)) {
|
||||||
TripBill passBill = tripBillService.createPassengersBill(entity);
|
TripBill passBill = tripBillService.createPassengersBill(entity);
|
||||||
tripBillService.add(passBill);
|
tripBillService.add(passBill);
|
||||||
passBill.setOwnedBy(u);
|
passBill.setOwnedBy(u);
|
||||||
tripBillService.update(passBill);
|
tripBillService.update(passBill);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entity.getPassengers().isEmpty() && settingsService.getSettings().getConfReqTripPassenger() != null) {
|
|
||||||
MailMessage message = messageBuilder.buildMessage(settingsService.getSettings().getConfReqTripPassenger(), entity);
|
|
||||||
message.setFrom(userService.getCurrent().getEmail());
|
|
||||||
message.setTo(userService.getEmailsForSend(entity.getPassengers()));
|
|
||||||
mailer.send(message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendMailToPassengers(entity, settingsService.getSettings().getConfReqTripPassenger());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canCreateBill(TripRequirement req, User owner, List<TripBill> bills) {
|
||||||
|
if (owner.equals(req.getOwnedBy())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (TripBill tb : bills) {
|
||||||
|
if (tb.getOwnedBy().equals(owner)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getNumberSerie() {
|
protected String getNumberSerie() {
|
||||||
String currentNumber = "";
|
String currentNumber = "";
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package info.bukova.isspst.services.settings;
|
||||||
|
|
||||||
|
import info.bukova.isspst.services.IsspstException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pepa Rokos
|
||||||
|
*/
|
||||||
|
public class SeasonException extends IsspstException {
|
||||||
|
|
||||||
|
SeasonException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
SeasonException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
setReason(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package info.bukova.isspst.services.settings;
|
||||||
|
|
||||||
|
import info.bukova.isspst.data.Season;
|
||||||
|
import info.bukova.isspst.services.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pepa Rokos
|
||||||
|
*/
|
||||||
|
public interface SeasonService extends Service<Season> {
|
||||||
|
Season addSeason();
|
||||||
|
Season getActive();
|
||||||
|
List<Season> getAllSeasons();
|
||||||
|
void setActive(Season season);
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package info.bukova.isspst.services.settings;
|
||||||
|
|
||||||
|
import info.bukova.isspst.StringUtils;
|
||||||
|
import info.bukova.isspst.data.NumberSeries;
|
||||||
|
import info.bukova.isspst.data.Season;
|
||||||
|
import info.bukova.isspst.services.AbstractOwnedService;
|
||||||
|
import info.bukova.isspst.services.numberseries.NumberSeriesService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pepa Rokos
|
||||||
|
*/
|
||||||
|
public class SeasonServiceImpl extends AbstractOwnedService<Season> implements SeasonService {
|
||||||
|
private Season activeSeason;
|
||||||
|
@Autowired
|
||||||
|
private NumberSeriesService numberSeriesService;
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public Season addSeason() {
|
||||||
|
Season season = new Season();
|
||||||
|
season.setDescription(StringUtils.localize("SeasonsNewSeason"));
|
||||||
|
season.setValidFrom(new Date());
|
||||||
|
season.setActive(true);
|
||||||
|
|
||||||
|
Season last = selectSingle("from Season where validTo Is Null");
|
||||||
|
add(season);
|
||||||
|
|
||||||
|
last.setValidTo(new Date());
|
||||||
|
last.setActive(false);
|
||||||
|
update(last);
|
||||||
|
|
||||||
|
|
||||||
|
activeSeason = null;
|
||||||
|
|
||||||
|
List<NumberSeries> numSeries = numberSeriesService.getSeriesForSeason(last);
|
||||||
|
for (NumberSeries ns: numSeries) {
|
||||||
|
String txt = ns.getPrefix().replaceAll("[0-9]+", "");
|
||||||
|
String numTxt = ns.getPrefix().replaceAll("[a-zA-Z]+", "");
|
||||||
|
|
||||||
|
int num = 0;
|
||||||
|
try {
|
||||||
|
num = Integer.valueOf(numTxt);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
String newPrefix = txt + String.valueOf(num + 1);
|
||||||
|
|
||||||
|
NumberSeries newNumSer = new NumberSeries();
|
||||||
|
newNumSer.setPrefix(newPrefix);
|
||||||
|
newNumSer.setModule(ns.getModule());
|
||||||
|
newNumSer.setNumber(1);
|
||||||
|
newNumSer.setSeason(season);
|
||||||
|
numberSeriesService.add(newNumSer);
|
||||||
|
}
|
||||||
|
return season;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public Season getActive() {
|
||||||
|
if (activeSeason == null) {
|
||||||
|
activeSeason = selectSingle("from Season where active = true");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activeSeason == null) {
|
||||||
|
throw new SeasonException("Active_season_not_set");
|
||||||
|
}
|
||||||
|
return activeSeason;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public List<Season> getAllSeasons() {
|
||||||
|
return getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void setActive(Season season) {
|
||||||
|
for (Season s: getAll()) {
|
||||||
|
s.setActive(false);
|
||||||
|
update(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
Season s = dao.getById(season.getId());
|
||||||
|
|
||||||
|
if (s == null) {
|
||||||
|
throw new SeasonException("Season_not_in_database");
|
||||||
|
}
|
||||||
|
|
||||||
|
s.setActive(true);
|
||||||
|
activeSeason = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package info.bukova.isspst.services.signeddocs;
|
||||||
|
|
||||||
|
import info.bukova.isspst.data.DataModel;
|
||||||
|
import info.bukova.isspst.data.Member;
|
||||||
|
import info.bukova.isspst.data.SignedDocument;
|
||||||
|
import info.bukova.isspst.data.SignedDocumentItem;
|
||||||
|
import info.bukova.isspst.services.Service;
|
||||||
|
import info.bukova.isspst.ui.signeddocs.SignedDocsTreeNode;
|
||||||
|
import org.zkoss.zul.TreeModel;
|
||||||
|
import org.zkoss.zul.TreeNode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface SignedDocumentService extends Service<SignedDocument> {
|
||||||
|
|
||||||
|
SignedDocument getForEntity(DataModel entity);
|
||||||
|
SignedDocumentItem getItem(DataModel entity, long reportId);
|
||||||
|
void addFromApprove(SignedDocument document);
|
||||||
|
void delFromApprove(SignedDocument document);
|
||||||
|
void deleteForEntity(DataModel entity);
|
||||||
|
|
||||||
|
public List<SignedDocument> getActualList();
|
||||||
|
public List<SignedDocument> getArchiveList();
|
||||||
|
public TreeModel<TreeNode<SignedDocumentItem>> getTree();
|
||||||
|
}
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
package info.bukova.isspst.services.signeddocs;
|
||||||
|
|
||||||
|
import info.bukova.isspst.DateTimeUtils;
|
||||||
|
import info.bukova.isspst.Module;
|
||||||
|
import info.bukova.isspst.ModuleUtils;
|
||||||
|
import info.bukova.isspst.data.DataModel;
|
||||||
|
import info.bukova.isspst.data.Member;
|
||||||
|
import info.bukova.isspst.data.SignedDocument;
|
||||||
|
import info.bukova.isspst.data.SignedDocumentItem;
|
||||||
|
import info.bukova.isspst.services.AbstractOwnedService;
|
||||||
|
import info.bukova.isspst.services.LazyLoader;
|
||||||
|
import info.bukova.isspst.storage.ReportFileStorage;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
|
import info.bukova.isspst.ui.signeddocs.SignedDocsTreeNode;
|
||||||
|
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 org.zkoss.zul.DefaultTreeModel;
|
||||||
|
import org.zkoss.zul.DefaultTreeNode;
|
||||||
|
import org.zkoss.zul.TreeModel;
|
||||||
|
import org.zkoss.zul.TreeNode;
|
||||||
|
|
||||||
|
public class SignedDocumentServiceImpl extends AbstractOwnedService<SignedDocument> implements SignedDocumentService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ServletContext servletContext;
|
||||||
|
@Autowired
|
||||||
|
private ReportFileStorage signedDocStorage;
|
||||||
|
|
||||||
|
@LazyLoader("grid")
|
||||||
|
@Transactional
|
||||||
|
public void lazyLoadItems(SignedDocument signedDocument) {
|
||||||
|
if (signedDocument == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SignedDocument sd = dao.getById(signedDocument.getId());
|
||||||
|
Hibernate.initialize(sd.getItems());
|
||||||
|
signedDocument.setItems(sd.getItems());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public SignedDocument getForEntity(DataModel entity) {
|
||||||
|
Module module = ModuleUtils.getModule(entity, servletContext);
|
||||||
|
|
||||||
|
if (module == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Query q = dao.getQuery("from SignedDocument where moduleName = :module and recordId = :record");
|
||||||
|
q.setParameter("module", module.getId());
|
||||||
|
q.setParameter("record", entity.getId());
|
||||||
|
|
||||||
|
return (SignedDocument) q.uniqueResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public SignedDocumentItem getItem(DataModel entity, long reportId) {
|
||||||
|
SignedDocument doc = getForEntity(entity);
|
||||||
|
|
||||||
|
if (doc == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SignedDocumentItem item : doc.getItems()) {
|
||||||
|
if (item.getReportId() == reportId) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addFromApprove(SignedDocument document) {
|
||||||
|
super.add(document);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delFromApprove(SignedDocument document) {
|
||||||
|
if (document == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.delete(document);
|
||||||
|
|
||||||
|
for (SignedDocumentItem item : document.getItems()) {
|
||||||
|
signedDocStorage.removeFile(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void deleteForEntity(DataModel entity) {
|
||||||
|
SignedDocument doc = getForEntity(entity);
|
||||||
|
if (doc != null) {
|
||||||
|
delFromApprove(doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Date getTresholdDate() {
|
||||||
|
Date date = DateTimeUtils.getDateDelta(DateTimeUtils.getCurrDate(), Calendar.MONTH, -6);
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
||||||
|
public List<SignedDocument> getActualList() {
|
||||||
|
Query q = dao.getQuery("from SignedDocument where signDate >= :refDate");
|
||||||
|
q.setParameter("refDate", this.getTresholdDate());
|
||||||
|
return q.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
||||||
|
public List<SignedDocument> getArchiveList() {
|
||||||
|
Query q = dao.getQuery("from SignedDocument where signDate < :refDate");
|
||||||
|
q.setParameter("refDate", this.getTresholdDate());
|
||||||
|
return q.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
||||||
|
public TreeModel<TreeNode<SignedDocumentItem>> getTree() {
|
||||||
|
Query q = queryDao.getQuery("select item "
|
||||||
|
+ "from SignedDocumentItem as item left join item.signedDocument as rec "
|
||||||
|
+ "order by rec.moduleName, rec.signDate desc, item.reportName, item.fileName "
|
||||||
|
);
|
||||||
|
List<SignedDocumentItem> list = q.list();
|
||||||
|
|
||||||
|
SignedDocumentItem lastItem = null;
|
||||||
|
SignedDocument lastRec = null;
|
||||||
|
List<SignedDocsTreeNode> agendaNameList = new LinkedList<SignedDocsTreeNode>();
|
||||||
|
List<SignedDocsTreeNode> signYearList = new LinkedList<SignedDocsTreeNode>();
|
||||||
|
List<SignedDocsTreeNode> signDateList = new LinkedList<SignedDocsTreeNode>();
|
||||||
|
List<SignedDocsTreeNode> filesList = null;
|
||||||
|
|
||||||
|
int documentsCount = list.size() - 1;
|
||||||
|
|
||||||
|
for (int i = 0; i <= documentsCount; i++) {
|
||||||
|
SignedDocumentItem item = list.get(i);
|
||||||
|
SignedDocument rec = item.getSignedDocument();
|
||||||
|
SignedDocsTreeNode itemNode = new SignedDocsTreeNode(item);
|
||||||
|
|
||||||
|
boolean isChangedAgendaName = ((i == 0)
|
||||||
|
|| (i == documentsCount)
|
||||||
|
|| !lastRec.getAgendaName().equals(rec.getAgendaName())
|
||||||
|
);
|
||||||
|
boolean isChangedSignYear = ((i == 0)
|
||||||
|
|| (i == documentsCount)
|
||||||
|
|| isChangedAgendaName
|
||||||
|
|| !DateTimeUtils.isEqualByYear(lastRec.getSignDate(), rec.getSignDate())
|
||||||
|
);
|
||||||
|
boolean isChangedSignDate = ((i == 0)
|
||||||
|
|| (i == documentsCount)
|
||||||
|
|| isChangedSignYear
|
||||||
|
|| !DateTimeUtils.isEqualByDate(lastRec.getSignDate(), rec.getSignDate())
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isChangedAgendaName || isChangedSignYear || isChangedSignDate) {
|
||||||
|
|
||||||
|
if (isChangedSignDate) {
|
||||||
|
if (i > 0) {
|
||||||
|
SignedDocsTreeNode signDateNode = new SignedDocsTreeNode((i == documentsCount ? item : lastItem), filesList);
|
||||||
|
signDateList.add(signDateNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
filesList = new LinkedList<SignedDocsTreeNode>();
|
||||||
|
filesList.add(itemNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isChangedSignYear) {
|
||||||
|
if (i > 0) {
|
||||||
|
SignedDocsTreeNode signYearNode = new SignedDocsTreeNode((i == documentsCount ? item : lastItem), signDateList);
|
||||||
|
signYearList.add(signYearNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
signDateList = new LinkedList<SignedDocsTreeNode>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isChangedAgendaName) {
|
||||||
|
if (i > 0) {
|
||||||
|
SignedDocsTreeNode agendaNode = new SignedDocsTreeNode((i == documentsCount ? item : lastItem), signYearList);
|
||||||
|
agendaNameList.add(agendaNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
signYearList = new LinkedList<SignedDocsTreeNode>();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
filesList.add(itemNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastItem = item;
|
||||||
|
lastRec = lastItem.getSignedDocument();
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(agendaNameList, new Comparator<SignedDocsTreeNode>() {
|
||||||
|
@Override
|
||||||
|
public int compare(SignedDocsTreeNode nodeL, SignedDocsTreeNode nodeR) {
|
||||||
|
if ((nodeL != null) && (nodeR != null)) {
|
||||||
|
SignedDocumentItem itemL = nodeL.getData();
|
||||||
|
SignedDocumentItem itemR = nodeR.getData();
|
||||||
|
|
||||||
|
if ((itemL != null) && (itemR != null)) {
|
||||||
|
SignedDocument recL = itemL.getSignedDocument();
|
||||||
|
SignedDocument recR = itemR.getSignedDocument();
|
||||||
|
|
||||||
|
if ((recL != null) && (recR != null)) {
|
||||||
|
String nameL = recL.getAgendaName();
|
||||||
|
String nameR = recR.getAgendaName();
|
||||||
|
|
||||||
|
if ((nameL != null) && (nameR != null)) {
|
||||||
|
return nameL.compareTo(nameR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
SignedDocsTreeNode root = new SignedDocsTreeNode(null, agendaNameList);
|
||||||
|
TreeModel<TreeNode<SignedDocumentItem>> tree = new DefaultTreeModel<SignedDocumentItem>(root);
|
||||||
|
return tree;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package info.bukova.isspst.services.tripbill;
|
||||||
|
|
||||||
|
import info.bukova.isspst.services.IsspstException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pepa Rokos
|
||||||
|
*/
|
||||||
|
public class PayException extends IsspstException {
|
||||||
|
|
||||||
|
public PayException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PayException(String message) {
|
||||||
|
super(message);
|
||||||
|
setReason(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,5 +10,6 @@ import info.bukova.isspst.services.requirement.RequirementBaseService;
|
|||||||
public interface TripBillApprovalService extends RequirementBaseService<TripBillApproval> {
|
public interface TripBillApprovalService extends RequirementBaseService<TripBillApproval> {
|
||||||
|
|
||||||
public TripBillApproval createApproval(TripBill bill);
|
public TripBillApproval createApproval(TripBill bill);
|
||||||
|
public void cancelApproval(TripBill bill);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+51
-3
@@ -1,20 +1,24 @@
|
|||||||
package info.bukova.isspst.services.tripbill;
|
package info.bukova.isspst.services.tripbill;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
import info.bukova.isspst.Constants;
|
||||||
|
import info.bukova.isspst.Module;
|
||||||
|
import info.bukova.isspst.ModuleUtils;
|
||||||
import info.bukova.isspst.StringUtils;
|
import info.bukova.isspst.StringUtils;
|
||||||
|
import info.bukova.isspst.data.DataModel;
|
||||||
import info.bukova.isspst.data.RequirementState;
|
import info.bukova.isspst.data.RequirementState;
|
||||||
import info.bukova.isspst.data.TripBill;
|
import info.bukova.isspst.data.TripBill;
|
||||||
import info.bukova.isspst.data.TripBillApproval;
|
import info.bukova.isspst.data.TripBillApproval;
|
||||||
import info.bukova.isspst.services.IsspstException;
|
import info.bukova.isspst.services.IsspstException;
|
||||||
import info.bukova.isspst.services.requirement.RequirementBaseServiceImpl;
|
import info.bukova.isspst.services.requirement.RequirementBaseServiceImpl;
|
||||||
import info.bukova.isspst.services.requirement.RequirementTypeService;
|
import info.bukova.isspst.services.requirement.RequirementTypeService;
|
||||||
|
import info.bukova.isspst.services.signeddocs.SignedDocumentService;
|
||||||
import java.util.Date;
|
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.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Pepa Rokos
|
* @author Pepa Rokos
|
||||||
*/
|
*/
|
||||||
@@ -22,6 +26,10 @@ public class TripBillApprovalServiceImpl extends RequirementBaseServiceImpl<Trip
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RequirementTypeService reqTypeService;
|
private RequirementTypeService reqTypeService;
|
||||||
|
@Autowired
|
||||||
|
private TripBillService tripBillService;
|
||||||
|
@Autowired
|
||||||
|
private SignedDocumentService signedDocumentService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TripBillApproval createApproval(TripBill bill) {
|
public TripBillApproval createApproval(TripBill bill) {
|
||||||
@@ -32,6 +40,7 @@ public class TripBillApprovalServiceImpl extends RequirementBaseServiceImpl<Trip
|
|||||||
TripBillApproval approval = new TripBillApproval();
|
TripBillApproval approval = new TripBillApproval();
|
||||||
approval.setCentre(bill.getRequirement().getCentre());
|
approval.setCentre(bill.getRequirement().getCentre());
|
||||||
approval.setWorkgroup(bill.getRequirement().getWorkgroup());
|
approval.setWorkgroup(bill.getRequirement().getWorkgroup());
|
||||||
|
approval.setSeason(bill.getSeason());
|
||||||
approval.setReqDate(new Date());
|
approval.setReqDate(new Date());
|
||||||
approval.setType(reqTypeService.getTypeById(Constants.REQTYPE_BUSINESSTRIP));
|
approval.setType(reqTypeService.getTypeById(Constants.REQTYPE_BUSINESSTRIP));
|
||||||
approval.setState(RequirementState.NEW);
|
approval.setState(RequirementState.NEW);
|
||||||
@@ -53,4 +62,43 @@ public class TripBillApprovalServiceImpl extends RequirementBaseServiceImpl<Trip
|
|||||||
|
|
||||||
postAdd(entity);
|
postAdd(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DataModel entityForSignReport(TripBillApproval entity) {
|
||||||
|
return entity.getBill();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@PreAuthorize("hasPermission(this, 'PERM_DELETE') or this.canApprove(#bill.approval)")
|
||||||
|
public void cancelApproval(TripBill bill) {
|
||||||
|
bill.setApproval(null);
|
||||||
|
signedDocumentService.deleteForEntity(bill);
|
||||||
|
tripBillService.update(bill);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Module getModule() {
|
||||||
|
return ModuleUtils.getModule(Constants.MOD_TRIPREQUIREMENTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@PreAuthorize("hasPermission(this, 'PERM_DELETE') or hasPermission(#entity, this.getDeleteEntityPermission())")
|
||||||
|
public void delete(TripBillApproval entity) {
|
||||||
|
TripBill bill = entity.getBill();
|
||||||
|
|
||||||
|
if (bill == null) {
|
||||||
|
Query q = queryDao.getQuery("FROM TripBill WHERE APPROVAL_ID = :appId");
|
||||||
|
q.setInteger("appId", entity.getId());
|
||||||
|
bill = (TripBill) q.uniqueResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bill != null) {
|
||||||
|
dao.delete(entity);
|
||||||
|
cancelApproval(bill);
|
||||||
|
} else {
|
||||||
|
super.delete(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import info.bukova.isspst.data.TripBill;
|
|||||||
import info.bukova.isspst.data.TripRequirement;
|
import info.bukova.isspst.data.TripRequirement;
|
||||||
import info.bukova.isspst.services.Service;
|
import info.bukova.isspst.services.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface TripBillService extends Service<TripBill> {
|
public interface TripBillService extends Service<TripBill> {
|
||||||
@@ -15,6 +16,7 @@ public interface TripBillService extends Service<TripBill> {
|
|||||||
public List<TripBill> getMy();
|
public List<TripBill> getMy();
|
||||||
public void loadOwner(TripBill bill);
|
public void loadOwner(TripBill bill);
|
||||||
public void loadPassengers(TripBill bill);
|
public void loadPassengers(TripBill bill);
|
||||||
|
public void setPaid(TripBill bill, Date date);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uloží vyúčtování a nastaví příznak přenosu vyúčtování od žadatele
|
* Uloží vyúčtování a nastaví příznak přenosu vyúčtování od žadatele
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import info.bukova.isspst.data.TripBill;
|
|||||||
import info.bukova.isspst.data.TripBillItem;
|
import info.bukova.isspst.data.TripBillItem;
|
||||||
import info.bukova.isspst.data.TripRequirement;
|
import info.bukova.isspst.data.TripRequirement;
|
||||||
import info.bukova.isspst.services.AbstractOwnedService;
|
import info.bukova.isspst.services.AbstractOwnedService;
|
||||||
|
import info.bukova.isspst.services.HqlDataFilter;
|
||||||
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 org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
@@ -23,6 +24,7 @@ import java.math.BigDecimal;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implements
|
public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implements
|
||||||
@@ -45,6 +47,7 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
|
|||||||
TripBill bill = new TripBill();
|
TripBill bill = new TripBill();
|
||||||
|
|
||||||
bill.setRequirement(requirement);
|
bill.setRequirement(requirement);
|
||||||
|
bill.setSeason(requirement.getSeason());
|
||||||
|
|
||||||
if (!passengers) {
|
if (!passengers) {
|
||||||
bill.setDownPayment(requirement.getDownPayment());
|
bill.setDownPayment(requirement.getDownPayment());
|
||||||
@@ -178,9 +181,10 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
|
|||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
||||||
public List<TripBill> getMy() {
|
public List<TripBill> getMy() {
|
||||||
Query q = dao.getQuery("from TripBill where ownedBy = :owner");
|
Query q = dao.getQuery("from TripBill");
|
||||||
q.setParameter("owner", getLoggedInUser());
|
HqlDataFilter f = new HqlDataFilter("ownedBy = :owner");
|
||||||
return q.list();
|
f.setParam("owner", getLoggedInUser());
|
||||||
|
return filterQuery(q, f).list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -212,6 +216,19 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
|
|||||||
bill.getRequirement().setPassengers(tr.getPassengers());
|
bill.getRequirement().setPassengers(tr.getPassengers());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@PreAuthorize("hasPermission(this, 'PERM_PAY_BILL')")
|
||||||
|
public void setPaid(TripBill bill, Date date) {
|
||||||
|
if (bill.getApproval() == null || bill.getApproval().getState() != RequirementState.APPROVED) {
|
||||||
|
throw new PayException("BillNotApproved");
|
||||||
|
}
|
||||||
|
|
||||||
|
bill.setPaid(true);
|
||||||
|
bill.setPaidDate(date);
|
||||||
|
super.update(bill);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
|
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
|
||||||
@@ -252,7 +269,9 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPrintRecord(TripBill entity) {
|
public boolean canPrintRecord(TripBill entity) {
|
||||||
if (entity.getApproval() != null && entity.getApproval().getState() == RequirementState.APPROVED) {
|
if (entity.getApproval() != null
|
||||||
|
&& entity.getApproval().getState() == RequirementState.APPROVED
|
||||||
|
&& (entity.getPaid() == null || !entity.getPaid())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ package info.bukova.isspst.services.users;
|
|||||||
import info.bukova.isspst.Constants;
|
import info.bukova.isspst.Constants;
|
||||||
import info.bukova.isspst.data.User;
|
import info.bukova.isspst.data.User;
|
||||||
import info.bukova.isspst.security.AuthMethod;
|
import info.bukova.isspst.security.AuthMethod;
|
||||||
|
|
||||||
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.DirContextAdapter;
|
import org.springframework.ldap.core.DirContextAdapter;
|
||||||
@@ -16,6 +13,8 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|||||||
import org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider;
|
import org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider;
|
||||||
import org.springframework.security.ldap.userdetails.UserDetailsContextMapper;
|
import org.springframework.security.ldap.userdetails.UserDetailsContextMapper;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapovač doménových uživatelů Active Directory na uživatele aplikace. Pokud uživatel není v aplikační databází,
|
* Mapovač doménových uživatelů Active Directory na uživatele aplikace. Pokud uživatel není v aplikační databází,
|
||||||
* importu je se tam pomoci {@link LdapUserImporter}. Tento objekt se předává do {@link ActiveDirectoryLdapAuthenticationProvider}.
|
* importu je se tam pomoci {@link LdapUserImporter}. Tento objekt se předává do {@link ActiveDirectoryLdapAuthenticationProvider}.
|
||||||
@@ -40,6 +39,7 @@ public class AdUserCtxMapper implements UserDetailsContextMapper {
|
|||||||
@Override
|
@Override
|
||||||
public UserDetails mapUserFromContext(DirContextOperations userData,
|
public UserDetails mapUserFromContext(DirContextOperations userData,
|
||||||
String username, Collection<? extends GrantedAuthority> authorities) {
|
String username, Collection<? extends GrantedAuthority> authorities) {
|
||||||
|
username = username.toLowerCase();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
User user = (User) userService.loadUserByUsername(username);
|
User user = (User) userService.loadUserByUsername(username);
|
||||||
|
|||||||
@@ -7,15 +7,7 @@ import info.bukova.isspst.data.UserSettingsData;
|
|||||||
import info.bukova.isspst.security.AuthMethod;
|
import info.bukova.isspst.security.AuthMethod;
|
||||||
import info.bukova.isspst.services.AbstractService;
|
import info.bukova.isspst.services.AbstractService;
|
||||||
import info.bukova.isspst.services.StringXmlMarshaller;
|
import info.bukova.isspst.services.StringXmlMarshaller;
|
||||||
//import info.bukova.isspst.services.LazyLoader;
|
|
||||||
|
|
||||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.exolab.castor.xml.Marshaller;
|
import org.exolab.castor.xml.Marshaller;
|
||||||
import org.exolab.castor.xml.Unmarshaller;
|
import org.exolab.castor.xml.Unmarshaller;
|
||||||
import org.hibernate.LazyInitializationException;
|
import org.hibernate.LazyInitializationException;
|
||||||
@@ -31,6 +23,13 @@ import org.springframework.security.core.userdetails.UserDetails;
|
|||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
//import info.bukova.isspst.services.LazyLoader;
|
||||||
|
|
||||||
public class UserServiceImpl extends AbstractService<User> implements UserService {
|
public class UserServiceImpl extends AbstractService<User> implements UserService {
|
||||||
|
|
||||||
private PasswordEncoder encoder;
|
private PasswordEncoder encoder;
|
||||||
@@ -220,6 +219,7 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public void delete(User entity) {
|
public void delete(User entity) {
|
||||||
workgroupService.loadParents(entity);
|
workgroupService.loadParents(entity);
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<User> getUsersForCombo() {
|
public List<User> getUsersForCombo() {
|
||||||
Query q = dao.getQuery("from User u order by u.lastName");
|
Query q = dao.getQuery("from User u where u.enabled = true order by u.lastName");
|
||||||
return q.list();
|
return q.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package info.bukova.isspst.services.workgroups;
|
package info.bukova.isspst.services.workgroups;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import info.bukova.isspst.data.JobMapping;
|
import info.bukova.isspst.data.JobMapping;
|
||||||
import info.bukova.isspst.data.Member;
|
import info.bukova.isspst.data.Member;
|
||||||
import info.bukova.isspst.data.Role;
|
import info.bukova.isspst.data.Role;
|
||||||
@@ -9,6 +7,8 @@ import info.bukova.isspst.data.User;
|
|||||||
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.util.List;
|
||||||
|
|
||||||
public interface WorkgroupService extends Service<Workgroup> {
|
public interface WorkgroupService extends Service<Workgroup> {
|
||||||
|
|
||||||
public void addMember(Workgroup workgroup, Member member, Role role);
|
public void addMember(Workgroup workgroup, Member member, Role role);
|
||||||
@@ -17,6 +17,7 @@ public interface WorkgroupService extends Service<Workgroup> {
|
|||||||
public List<Workgroup> getCentres();
|
public List<Workgroup> getCentres();
|
||||||
public boolean isMember(Workgroup workgroup, Member member);
|
public boolean isMember(Workgroup workgroup, Member member);
|
||||||
public List<Workgroup> getUserCentres(User user);
|
public List<Workgroup> getUserCentres(User user);
|
||||||
|
public List<Workgroup> getUserCentres(User user, boolean userOnly);
|
||||||
public List<Workgroup> getUserWorkgroups(User user);
|
public List<Workgroup> getUserWorkgroups(User user);
|
||||||
public List<Role> getUserWorkgroupRoles(Workgroup workgroup, User user);
|
public List<Role> getUserWorkgroupRoles(Workgroup workgroup, User user);
|
||||||
public List<Member> getMembers(Workgroup workgroup);
|
public List<Member> getMembers(Workgroup workgroup);
|
||||||
|
|||||||
@@ -8,15 +8,14 @@ import info.bukova.isspst.data.User;
|
|||||||
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 java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hibernate.LazyInitializationException;
|
import org.hibernate.LazyInitializationException;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
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.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class WorkgroupServiceImpl extends AbstractOwnedService<Workgroup> implements WorkgroupService {
|
public class WorkgroupServiceImpl extends AbstractOwnedService<Workgroup> implements WorkgroupService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -125,7 +124,7 @@ public class WorkgroupServiceImpl extends AbstractOwnedService<Workgroup> implem
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<Workgroup> getUserCentres(User user) {
|
public List<Workgroup> getUserCentres(User user) {
|
||||||
if (user.equals(getLoggedInUser()) && sessionData.getUserCentres() != null) {
|
/*if (user.equals(getLoggedInUser()) && sessionData.getUserCentres() != null) {
|
||||||
return sessionData.getUserCentres();
|
return sessionData.getUserCentres();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,6 +149,75 @@ public class WorkgroupServiceImpl extends AbstractOwnedService<Workgroup> implem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return centres;*/
|
||||||
|
return getUserCentres(user, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public List<Workgroup> getUserCentres(User user, boolean userOnly) {
|
||||||
|
if (!userOnly && user.equals(getLoggedInUser()) && sessionData.getUserCentres() != null) {
|
||||||
|
return sessionData.getUserCentres();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userOnly && user.equals(getLoggedInUser()) && sessionData.getUserOnlyCentres() != null) {
|
||||||
|
return sessionData.getUserOnlyCentres();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Workgroup> parents;
|
||||||
|
|
||||||
|
if (userOnly) {
|
||||||
|
parents = filterUserOnly(user, getParents(user));
|
||||||
|
} else {
|
||||||
|
parents = getParents(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parents == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Workgroup> centres = new ArrayList<Workgroup>();
|
||||||
|
for (Workgroup w : parents) {
|
||||||
|
if (w.isCentre()) {
|
||||||
|
centres.add(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Workgroup> workGroups;
|
||||||
|
|
||||||
|
if (userOnly) {
|
||||||
|
workGroups = filterUserOnly(user, getUserWorkgroups(user));
|
||||||
|
} else {
|
||||||
|
workGroups = getUserWorkgroups(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Workgroup w : workGroups) {
|
||||||
|
loadParents(w);
|
||||||
|
for (Workgroup centre : w.getParents()) {
|
||||||
|
if (!centres.contains(centre)) {
|
||||||
|
centres.add(centre);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return centres;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Workgroup> filterUserOnly(User user, List<Workgroup> wgList) {
|
||||||
|
List<Workgroup> centres = new ArrayList<Workgroup>();
|
||||||
|
|
||||||
|
for (Workgroup wg : wgList) {
|
||||||
|
List<Role> roles = getUserWorkgroupRoles(wg, user);
|
||||||
|
if (roles == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Role r : roles) {
|
||||||
|
if (r.getAuthority().equals(Constants.ROLE_USER)) {
|
||||||
|
centres.add(wg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return centres;
|
return centres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package info.bukova.isspst.signapi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pepa Rokos
|
||||||
|
*/
|
||||||
|
public interface JnlpGenerator {
|
||||||
|
|
||||||
|
public byte[] generate();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package info.bukova.isspst.signapi;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.Transformer;
|
||||||
|
import javax.xml.transform.TransformerConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import javax.xml.transform.TransformerFactory;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pepa Rokos
|
||||||
|
*/
|
||||||
|
public class JnlpGeneratorImpl implements JnlpGenerator {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HttpServletRequest request;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] generate() {
|
||||||
|
String sessionId;
|
||||||
|
|
||||||
|
if (request.getParameter("id") != null && !request.getParameter("id").isEmpty()) {
|
||||||
|
sessionId = request.getParameter("id");
|
||||||
|
} else {
|
||||||
|
sessionId = request.getSession().getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||||
|
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||||
|
|
||||||
|
Document document = docBuilder.newDocument();
|
||||||
|
Element root = document.createElement("jnlp");
|
||||||
|
root.setAttribute("spec", "1.0+");
|
||||||
|
|
||||||
|
String signerUrl = request.getRequestURL().toString();
|
||||||
|
signerUrl = signerUrl.substring(0, signerUrl.indexOf(request.getServletPath())) + "/api/sign";
|
||||||
|
|
||||||
|
root.setAttribute("codebase", signerUrl);
|
||||||
|
root.setAttribute("href", "signer.jnlp" + "?id=" + sessionId);
|
||||||
|
document.appendChild(root);
|
||||||
|
|
||||||
|
Element info = document.createElement("information");
|
||||||
|
Element title = document.createElement("title");
|
||||||
|
title.appendChild(document.createTextNode("Signer component"));
|
||||||
|
info.appendChild(title);
|
||||||
|
Element vendor = document.createElement("vendor");
|
||||||
|
vendor.appendChild(document.createTextNode("bukova.info"));
|
||||||
|
info.appendChild(vendor);
|
||||||
|
root.appendChild(info);
|
||||||
|
|
||||||
|
Element security = document.createElement("security");
|
||||||
|
security.appendChild(document.createElement("all-permissions"));
|
||||||
|
root.appendChild(security);
|
||||||
|
|
||||||
|
Element resources = document.createElement("resources");
|
||||||
|
resources.setAttribute("os", "Linux");
|
||||||
|
Element j2se = document.createElement("j2se");
|
||||||
|
j2se.setAttribute("version", "1.8+");
|
||||||
|
Element jar = document.createElement("jar");
|
||||||
|
jar.setAttribute("href", "pdfsigner.jar");
|
||||||
|
resources.appendChild(j2se);
|
||||||
|
resources.appendChild(jar);
|
||||||
|
root.appendChild(resources);
|
||||||
|
|
||||||
|
Element resourcesWin = document.createElement("resources");
|
||||||
|
resourcesWin.setAttribute("os", "Windows");
|
||||||
|
Element j2seWin = document.createElement("j2se");
|
||||||
|
j2seWin.setAttribute("version", "1.8+");
|
||||||
|
Element jarWin = document.createElement("jar");
|
||||||
|
jarWin.setAttribute("href", "pdfsignerWin.jar");
|
||||||
|
resourcesWin.appendChild(j2seWin);
|
||||||
|
|
||||||
|
resourcesWin.appendChild(jarWin);
|
||||||
|
root.appendChild(resourcesWin);
|
||||||
|
|
||||||
|
Element appDesc = document.createElement("application-desc");
|
||||||
|
appDesc.setAttribute("main-class", "info.bukova.pdfsigner.Main");
|
||||||
|
Element argUrl = document.createElement("argument");
|
||||||
|
argUrl.appendChild(document.createTextNode(signerUrl + "/data"));
|
||||||
|
appDesc.appendChild(argUrl);
|
||||||
|
Element argSession = document.createElement("argument");
|
||||||
|
argSession.appendChild(document.createTextNode(sessionId));
|
||||||
|
appDesc.appendChild(argSession);
|
||||||
|
root.appendChild(appDesc);
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(signerUrl);
|
||||||
|
System.out.println(request.getSession().getId());
|
||||||
|
|
||||||
|
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||||
|
Transformer transformer = transformerFactory.newTransformer();
|
||||||
|
DOMSource source = new DOMSource(document);
|
||||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
StreamResult result = new StreamResult(bos);
|
||||||
|
|
||||||
|
transformer.transform(source, result);
|
||||||
|
|
||||||
|
return bos.toByteArray();
|
||||||
|
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (TransformerConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (TransformerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package info.bukova.isspst.signapi;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pepa Rokos
|
||||||
|
*/
|
||||||
|
public class SignData implements Serializable {
|
||||||
|
|
||||||
|
private byte[] pdfData;
|
||||||
|
private byte[] signImg;
|
||||||
|
private int areaId;
|
||||||
|
private Date signDate;
|
||||||
|
private String description;
|
||||||
|
private String numser;
|
||||||
|
private boolean signed;
|
||||||
|
private String signGuid;
|
||||||
|
private boolean signSuccess;
|
||||||
|
|
||||||
|
public byte[] getPdfData() {
|
||||||
|
return pdfData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPdfData(byte[] pdfData) {
|
||||||
|
this.pdfData = pdfData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getSignDate() {
|
||||||
|
return signDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignDate(Date signDate) {
|
||||||
|
this.signDate = signDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 boolean isSigned() {
|
||||||
|
return signed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSigned(boolean signed) {
|
||||||
|
this.signed = signed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSignGuid() {
|
||||||
|
return signGuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignGuid(String signGuid) {
|
||||||
|
this.signGuid = signGuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSignSuccess() {
|
||||||
|
return signSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignSuccess(boolean signSuccess) {
|
||||||
|
this.signSuccess = signSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getSignImg() {
|
||||||
|
return signImg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignImg(byte[] signImg) {
|
||||||
|
this.signImg = signImg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAreaId() {
|
||||||
|
return areaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAreaId(int areaId) {
|
||||||
|
this.areaId = areaId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package info.bukova.isspst.signapi;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pepa Rokos
|
||||||
|
*/
|
||||||
|
public class SignUploadResponse implements Serializable {
|
||||||
|
|
||||||
|
private boolean ok;
|
||||||
|
private String errorMessage;
|
||||||
|
|
||||||
|
public boolean isOk() {
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOk(boolean ok) {
|
||||||
|
this.ok = ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorMessage() {
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorMessage(String errorMessage) {
|
||||||
|
this.errorMessage = errorMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
package info.bukova.isspst.signapi;
|
||||||
|
|
||||||
|
import info.bukova.isspst.Constants;
|
||||||
|
import info.bukova.isspst.SessionData;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pepa Rokos
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class SigningController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SessionData sessionData;
|
||||||
|
@Autowired
|
||||||
|
private JnlpGenerator jnlpGenerator;
|
||||||
|
@Autowired
|
||||||
|
private ServletContext context;
|
||||||
|
|
||||||
|
@RequestMapping(value="/sign/data", method= RequestMethod.GET)
|
||||||
|
public void dataForSign(HttpServletResponse response, HttpServletRequest request) {
|
||||||
|
SignData data = (SignData) sessionData.getProperty(Constants.KEY_SIGN_DATA);
|
||||||
|
ObjectOutputStream os = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
os = new ObjectOutputStream(response.getOutputStream());
|
||||||
|
response.setContentType("application/x-java-serialized-object");
|
||||||
|
os.writeObject(data);
|
||||||
|
os.flush();
|
||||||
|
os.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (os != null) {
|
||||||
|
try {
|
||||||
|
os.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/sign/data", method= RequestMethod.POST)
|
||||||
|
public void signedData(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
ObjectInputStream ois = null;
|
||||||
|
ObjectOutputStream os = null;
|
||||||
|
String error = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
ois = new ObjectInputStream(request.getInputStream());
|
||||||
|
SignData data = (SignData) ois.readObject();
|
||||||
|
sessionData.setProperty(Constants.KEY_SIGN_DATA, data);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
error = "IO error";
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
error = "Loading error";
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
SignUploadResponse resp = new SignUploadResponse();
|
||||||
|
|
||||||
|
if (error == null) {
|
||||||
|
resp.setOk(true);
|
||||||
|
} else {
|
||||||
|
resp.setOk(false);
|
||||||
|
resp.setErrorMessage(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
os = new ObjectOutputStream(response.getOutputStream());
|
||||||
|
response.setContentType("application/x-java-serialized-object");
|
||||||
|
os.writeObject(resp);
|
||||||
|
os.flush();
|
||||||
|
os.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/sign/signer.jnlp", method= RequestMethod.GET)
|
||||||
|
public void jnlp(HttpServletResponse response) {
|
||||||
|
byte[] data = jnlpGenerator.generate();
|
||||||
|
sendByte(response, data, "application/x-java-jnlp-file");
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/sign/pdfsigner.jar", method= RequestMethod.GET)
|
||||||
|
public void pdfsigner(HttpServletResponse response) {
|
||||||
|
sendJar(response, "Linux");
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/sign/pdfsignerWin.jar", method= RequestMethod.GET)
|
||||||
|
public void pdfsignerWin(HttpServletResponse response) {
|
||||||
|
sendJar(response, "Windows");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendJar(HttpServletResponse response, String os) {
|
||||||
|
File inputJar;
|
||||||
|
|
||||||
|
if (os.startsWith("Windows")) {
|
||||||
|
inputJar = new File(context.getRealPath("/WEB-INF/signer/PDFSignerWin.jar"));
|
||||||
|
} else {
|
||||||
|
inputJar = new File(context.getRealPath("/WEB-INF/signer/PDFSigner.jar"));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
byte[] data = new byte[(int) inputJar.length()];
|
||||||
|
FileInputStream is = new FileInputStream(inputJar);
|
||||||
|
is.read(data);
|
||||||
|
sendByte(response, data, "application/java-archive");
|
||||||
|
is.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendByte(HttpServletResponse response, byte[] data, String contentType) {
|
||||||
|
ServletOutputStream os = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
os = response.getOutputStream();
|
||||||
|
response.setContentType(contentType);
|
||||||
|
response.setContentLength(data.length);
|
||||||
|
os.write(data);
|
||||||
|
os.flush();
|
||||||
|
os.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,13 +1,170 @@
|
|||||||
package info.bukova.isspst.sort;
|
package info.bukova.isspst.sort;
|
||||||
|
|
||||||
import org.zkoss.zul.Listheader;
|
import info.bukova.isspst.StringUtils;
|
||||||
|
import org.apache.poi.hssf.usermodel.*;
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
import org.apache.poi.ss.usermodel.CellStyle;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.zkoss.zk.au.AuRequest;
|
||||||
|
import org.zkoss.zk.ui.Component;
|
||||||
|
import org.zkoss.zk.ui.event.*;
|
||||||
|
import org.zkoss.zul.*;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class CzechSortListheader extends Listheader {
|
public class CzechSortListheader extends Listheader {
|
||||||
|
static {
|
||||||
|
addClientEvent(CzechSortListheader.class, Events.ON_RIGHT_CLICK, CE_IMPORTANT | CE_NON_DEFERRABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onRightClick() {
|
||||||
|
Menupopup popup = new Menupopup();
|
||||||
|
popup.setPage(this.getPage());
|
||||||
|
popup.setWidth("250px");
|
||||||
|
this.setContext(popup);
|
||||||
|
|
||||||
|
Menuitem item = new Menuitem();
|
||||||
|
item.setLabel(StringUtils.localize("ExportToExcel"));
|
||||||
|
item.setImage("/img/excel-032.png");
|
||||||
|
item.setParent(popup);
|
||||||
|
|
||||||
|
item.addEventListener(Events.ON_CLICK, new EventListener() {
|
||||||
|
@Override
|
||||||
|
public void onEvent(org.zkoss.zk.ui.event.Event event) throws Exception {
|
||||||
|
Listbox listBox = getListbox();
|
||||||
|
|
||||||
|
if (listBox != null) {
|
||||||
|
HSSFWorkbook workBook = new HSSFWorkbook();
|
||||||
|
HSSFSheet workSheet = workBook.createSheet("export");
|
||||||
|
int rowNumber = 0;
|
||||||
|
Row excelRow = null;
|
||||||
|
Cell excelCell = null;
|
||||||
|
|
||||||
|
HSSFCellStyle cellStyle = workBook.createCellStyle();
|
||||||
|
HSSFFont defaultFont = cellStyle.getFont(workBook);
|
||||||
|
|
||||||
|
HSSFCellStyle cellStyleNumber = workBook.createCellStyle();
|
||||||
|
cellStyleNumber.setAlignment(CellStyle.ALIGN_RIGHT);
|
||||||
|
//http://www.roseindia.net/java/poi/setdataformat.shtml
|
||||||
|
//HSSFDataFormat dataNumberFormat = workBook.createDataFormat();
|
||||||
|
//cellStyleNumber.setDataFormat(dataNumberFormat.getFormat("# ##0,00"));
|
||||||
|
cellStyleNumber.setDataFormat((short)4);
|
||||||
|
|
||||||
|
HSSFCellStyle cellStyleDate = workBook.createCellStyle();
|
||||||
|
cellStyleDate.setAlignment(CellStyle.ALIGN_RIGHT);
|
||||||
|
//http://www.roseindia.net/java/poi/setdataformat.shtml
|
||||||
|
HSSFDataFormat dataDateFormat = workBook.createDataFormat();
|
||||||
|
cellStyleDate.setDataFormat(dataDateFormat.getFormat("DD. MM. YYYY"));
|
||||||
|
//cellStyleDate.setDataFormat((short) 15);
|
||||||
|
|
||||||
|
int totalCols = 0;
|
||||||
|
|
||||||
|
Listhead listHead = listBox.getListhead();
|
||||||
|
|
||||||
|
if (listHead != null) {
|
||||||
|
HSSFCellStyle cellStyleHeader = workBook.createCellStyle();
|
||||||
|
cellStyleHeader.setAlignment(CellStyle.ALIGN_CENTER);
|
||||||
|
HSSFFont font = workBook.createFont();
|
||||||
|
font.setFontName(defaultFont.getFontName());
|
||||||
|
font.setFontHeightInPoints(defaultFont.getFontHeightInPoints());
|
||||||
|
font.setBold(true);
|
||||||
|
cellStyleHeader.setFont(font);
|
||||||
|
|
||||||
|
excelRow = workSheet.createRow(rowNumber++);
|
||||||
|
List<Listheader> headerList = listHead.getChildren();
|
||||||
|
totalCols = headerList.size();
|
||||||
|
|
||||||
|
for (int i = 0; i < totalCols; i++) {
|
||||||
|
Listheader listHeader = headerList.get(i);
|
||||||
|
String label = listHeader.getLabel();
|
||||||
|
excelCell = excelRow.createCell(i);
|
||||||
|
excelCell.setCellStyle(cellStyleHeader);
|
||||||
|
excelCell.setCellValue(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Listitem> itemList = listBox.getItems();
|
||||||
|
|
||||||
|
for (int i = 0; i < itemList.size(); i++) {
|
||||||
|
Listitem item = itemList.get(i);
|
||||||
|
excelRow = workSheet.createRow(rowNumber++);
|
||||||
|
|
||||||
|
List<Listcell> cellList = item.getChildren();
|
||||||
|
|
||||||
|
for (int k=0; k < cellList.size(); k++) {
|
||||||
|
Listcell cell = cellList.get(k);
|
||||||
|
String label = cell.getLabel();
|
||||||
|
|
||||||
|
HSSFCellStyle cellStyleActual = cellStyle;
|
||||||
|
excelCell = excelRow.createCell(k);
|
||||||
|
|
||||||
|
if (label != null) {
|
||||||
|
if (label.isEmpty()) {
|
||||||
|
//List<Component> componentList = cell.getChildren();
|
||||||
|
Component component = cell.getFirstChild();
|
||||||
|
|
||||||
|
if (component != null) {
|
||||||
|
if (component instanceof Textbox) {
|
||||||
|
Textbox textBox = (Textbox) component;
|
||||||
|
label = textBox.getValue();
|
||||||
|
}
|
||||||
|
else if (component instanceof Button) {
|
||||||
|
Button button = (Button) component;
|
||||||
|
label = button.getLabel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (label.matches("^[+-]?[0-9]{1,3}(,?[0-9]{3})*(\\.[0-9]+)?$")) {
|
||||||
|
// english number -1,234.56 (change browser language)
|
||||||
|
label = label.replace(",", " ");
|
||||||
|
label = label.replace(".", ",");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (label.matches("^[+-]?[0-9]{1,3}([ \\xA0][0-9]{3})*([,][0-9]+)?$")) {
|
||||||
|
// czech number -1 234,56
|
||||||
|
cellStyleActual = cellStyleNumber;
|
||||||
|
}
|
||||||
|
else if (label.matches("[0-9]{1,2}[.][ \\xA0]?[0-9]{1,2}[.][ \\xA0]?[0-9]{4}")) {
|
||||||
|
// czech date
|
||||||
|
cellStyleActual = cellStyleDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
excelCell.setCellStyle(cellStyleActual);
|
||||||
|
excelCell.setCellValue(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < totalCols; i++) {
|
||||||
|
//int width = workSheet.getColumnWidth(i);
|
||||||
|
workSheet.autoSizeColumn(i);
|
||||||
|
int width = workSheet.getColumnWidth(i);
|
||||||
|
int maxWidth = 8000;
|
||||||
|
|
||||||
|
if (width > maxWidth) {
|
||||||
|
workSheet.setColumnWidth(i, maxWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
workBook.write(os);
|
||||||
|
Filedownload.save(os.toByteArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "temp" + Long.toString(System.nanoTime()) + ".xlsx");
|
||||||
|
// //Filedownload.save(tempFile, "application/vnd.ms-excel");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void service(AuRequest request, boolean everError) {
|
||||||
|
super.service(request, everError);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSort(String type) {
|
public void setSort(String type) {
|
||||||
|
|
||||||
if (type.startsWith("czech"))
|
if (type.startsWith("czech"))
|
||||||
{
|
{
|
||||||
// czech(propertyName)
|
// czech(propertyName)
|
||||||
@@ -21,5 +178,4 @@ public class CzechSortListheader extends Listheader {
|
|||||||
super.setSort(type);
|
super.setSort(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ public abstract class AbstractFileStorage<T> implements FileStorage<T> {
|
|||||||
os.flush();
|
os.flush();
|
||||||
os.close();
|
os.close();
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
throw new StorageException("File cannot be found: " + file.getName(), e.getCause());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
throw new StorageException("Cannot write file: " + file.getName(), e.getCause());
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (os != null) {
|
if (os != null) {
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ public class DocumentFileStorageImpl extends AbstractFileStorage<FileMetainfo> i
|
|||||||
this.rootPath = rootPath;
|
this.rootPath = rootPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRootPath() {
|
||||||
|
return this.rootPath;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveFile(byte[] data, FileMetainfo fileID) {
|
public void saveFile(byte[] data, FileMetainfo fileID) {
|
||||||
String fileName = generateFileName(fileID.getFileName());
|
String fileName = generateFileName(fileID.getFileName());
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.io.File;
|
|||||||
*/
|
*/
|
||||||
public interface FileStorage<T> {
|
public interface FileStorage<T> {
|
||||||
|
|
||||||
// public String getRootPath();
|
public String getRootPath();
|
||||||
public void saveFile(byte[] data, T fileID);
|
public void saveFile(byte[] data, T fileID);
|
||||||
public void saveFile(File file, T fileId);
|
public void saveFile(File file, T fileId);
|
||||||
public void removeFile(T fileID);
|
public void removeFile(T fileID);
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ public class LocalFileStorage extends AbstractFileStorage<String> {
|
|||||||
this.rootPath = rootPath;
|
this.rootPath = rootPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRootPath() {
|
||||||
|
return this.rootPath;
|
||||||
|
}
|
||||||
|
|
||||||
public void setContext(ServletContext ctx) {
|
public void setContext(ServletContext ctx) {
|
||||||
this.context = ctx;
|
this.context = ctx;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package info.bukova.isspst.storage;
|
||||||
|
|
||||||
|
import info.bukova.isspst.data.SignedDocumentItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pepa Rokos
|
||||||
|
*/
|
||||||
|
public interface ReportFileStorage extends FileStorage<SignedDocumentItem> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package info.bukova.isspst.storage;
|
||||||
|
|
||||||
|
import info.bukova.isspst.data.SignedDocumentItem;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pepa Rokos
|
||||||
|
*/
|
||||||
|
public class ReportFileStorageImpl extends AbstractFileStorage<SignedDocumentItem> implements ReportFileStorage {
|
||||||
|
|
||||||
|
private String rootPath;
|
||||||
|
|
||||||
|
public void setRootPath(String rootPath) {
|
||||||
|
this.rootPath = rootPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRootPath() {
|
||||||
|
return this.rootPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getFilePath(String fileName) {
|
||||||
|
return rootPath + "/" + fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveFile(byte[] data, SignedDocumentItem signedDocumentItem) {
|
||||||
|
String fileName = signedDocumentItem.getFileName();
|
||||||
|
|
||||||
|
if (fileName == null) {
|
||||||
|
fileName = UUID.randomUUID().toString() + ".pdf";
|
||||||
|
}
|
||||||
|
|
||||||
|
saveFileDataToPath(data, getFilePath(fileName));
|
||||||
|
signedDocumentItem.setFileName(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveFile(File file, SignedDocumentItem fileId) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeFile(SignedDocumentItem signedDocumentItem) {
|
||||||
|
removeFileByPath(getFilePath(signedDocumentItem.getFileName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void moveFile(String source, String destination) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createDirectory(String dir) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] fileData(SignedDocumentItem signedDocumentItem) {
|
||||||
|
return fileDataFromPath(getFilePath(signedDocumentItem.getFileName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File file(SignedDocumentItem signedDocumentItem) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dirExists(String path) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String serverPath(SignedDocumentItem signedDocumentItem) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package info.bukova.isspst.ui;
|
||||||
|
|
||||||
|
import org.zkoss.bind.annotation.Init;
|
||||||
|
|
||||||
|
public class BindingViewModel<T> extends DocumentViewModel {
|
||||||
|
|
||||||
|
private BindingForm<T> dataForm;
|
||||||
|
|
||||||
|
@Init
|
||||||
|
public void initBindingViewModel() {
|
||||||
|
super.initDocumentViewModel();
|
||||||
|
|
||||||
|
dataForm = new BindingForm<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BindingForm<T> getDataForm() {
|
||||||
|
return this.dataForm;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,10 +5,6 @@ import info.bukova.isspst.data.DataModel;
|
|||||||
import info.bukova.isspst.services.IsspstException;
|
import info.bukova.isspst.services.IsspstException;
|
||||||
import info.bukova.isspst.services.Service;
|
import info.bukova.isspst.services.Service;
|
||||||
import info.bukova.isspst.services.ValidationException;
|
import info.bukova.isspst.services.ValidationException;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.hibernate.exception.ConstraintViolationException;
|
import org.hibernate.exception.ConstraintViolationException;
|
||||||
import org.springframework.dao.DataIntegrityViolationException;
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
import org.springframework.security.access.AccessDeniedException;
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
@@ -20,28 +16,29 @@ import org.zkoss.bind.annotation.NotifyChange;
|
|||||||
import org.zkoss.zul.Messagebox;
|
import org.zkoss.zul.Messagebox;
|
||||||
import org.zkoss.zul.Window;
|
import org.zkoss.zul.Window;
|
||||||
|
|
||||||
public class FormViewModel<T extends DataModel> extends DocumentViewModel
|
import java.sql.SQLException;
|
||||||
{
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class FormViewModel<T extends DataModel> extends BindingViewModel<T>
|
||||||
|
{
|
||||||
private T dataBean;
|
private T dataBean;
|
||||||
private Map<String, String> errMessages;
|
private Map<String, String> errMessages;
|
||||||
private Service<T> service;
|
private Service<T> service;
|
||||||
private boolean newRec;
|
protected boolean newRec;
|
||||||
private ServiceConstraint<T> constraint;
|
private ServiceConstraint<T> constraint;
|
||||||
private BindingForm<T> dataForm;
|
|
||||||
|
|
||||||
@Init
|
@Init
|
||||||
public void initFormViewModel(@ExecutionArgParam("selected") T selected, @ExecutionArgParam("service") Service<T> service)
|
public void initFormViewModel(@ExecutionArgParam("selected") T selected, @ExecutionArgParam("service") Service<T> service)
|
||||||
{
|
{
|
||||||
super.initDocumentViewModel();
|
super.initBindingViewModel();
|
||||||
|
|
||||||
this.dataBean = selected;
|
this.dataBean = selected;
|
||||||
this.service = service;
|
this.service = service;
|
||||||
constraint = new ServiceConstraint<T>();
|
constraint = new ServiceConstraint<T>();
|
||||||
constraint.setDataBean(selected);
|
constraint.setDataBean(selected);
|
||||||
constraint.setService(service);
|
constraint.setService(service);
|
||||||
dataForm = new BindingForm<T>();
|
|
||||||
dataForm.setDataBean(selected);
|
this.getDataForm().setDataBean(selected);
|
||||||
|
|
||||||
if (selected.getId() == 0 && selected.getCreated() == null)
|
if (selected.getId() == 0 && selected.getCreated() == null)
|
||||||
{
|
{
|
||||||
@@ -186,9 +183,4 @@ public class FormViewModel<T extends DataModel> extends DocumentViewModel
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BindingForm<T> getDataForm() {
|
|
||||||
return dataForm;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,13 @@ package info.bukova.isspst.ui;
|
|||||||
|
|
||||||
import info.bukova.isspst.StringUtils;
|
import info.bukova.isspst.StringUtils;
|
||||||
import info.bukova.isspst.data.DataModel;
|
import info.bukova.isspst.data.DataModel;
|
||||||
|
import info.bukova.isspst.data.Season;
|
||||||
|
import info.bukova.isspst.data.SeasonsAware;
|
||||||
import info.bukova.isspst.filters.Filter;
|
import info.bukova.isspst.filters.Filter;
|
||||||
|
import info.bukova.isspst.services.HqlDataFilter;
|
||||||
import info.bukova.isspst.services.IsspstException;
|
import info.bukova.isspst.services.IsspstException;
|
||||||
import info.bukova.isspst.services.Service;
|
import info.bukova.isspst.services.Service;
|
||||||
|
import info.bukova.isspst.services.settings.SeasonService;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.dao.DataIntegrityViolationException;
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
@@ -24,9 +22,15 @@ import org.zkoss.bind.annotation.NotifyChange;
|
|||||||
import org.zkoss.zk.ui.Executions;
|
import org.zkoss.zk.ui.Executions;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||||
import org.zkoss.zul.Messagebox;
|
import org.zkoss.zul.Messagebox;
|
||||||
import org.zkoss.zul.Window;
|
import org.zkoss.zul.Window;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ListViewModel<T extends DataModel> extends DocumentViewModel
|
public class ListViewModel<T extends DataModel> extends DocumentViewModel
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -45,6 +49,13 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
|
|||||||
private boolean newRec = false;
|
private boolean newRec = false;
|
||||||
private boolean fullFill = false;
|
private boolean fullFill = false;
|
||||||
|
|
||||||
|
@WireVariable
|
||||||
|
private SeasonService seasonService;
|
||||||
|
private List<Season> seasons;
|
||||||
|
private Season selSeason;
|
||||||
|
@WireVariable
|
||||||
|
private HqlDataFilter hqlFilter;
|
||||||
|
|
||||||
protected Service<T> service;
|
protected Service<T> service;
|
||||||
protected Class<T> dataClass;
|
protected Class<T> dataClass;
|
||||||
protected String formZul;
|
protected String formZul;
|
||||||
@@ -54,6 +65,13 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
|
|||||||
public void initListViewModel()
|
public void initListViewModel()
|
||||||
{
|
{
|
||||||
super.initDocumentViewModel();
|
super.initDocumentViewModel();
|
||||||
|
seasons = seasonService.getAllSeasons();
|
||||||
|
|
||||||
|
Map<String, String[]> map = Executions.getCurrent().getParameterMap();
|
||||||
|
if (map.get("select") == null) {
|
||||||
|
selSeason = seasonService.getActive();
|
||||||
|
}
|
||||||
|
setHqlFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<T> getDataList() {
|
public List<T> getDataList() {
|
||||||
@@ -185,7 +203,6 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command
|
@Command
|
||||||
@NotifyChange({ "dataList", "dataBean" })
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
Messagebox.show(StringUtils.localize("DbReallyDelete"), StringUtils.localize("DbDeleteRecord"), Messagebox.YES
|
Messagebox.show(StringUtils.localize("DbReallyDelete"), StringUtils.localize("DbDeleteRecord"), Messagebox.YES
|
||||||
| Messagebox.NO, Messagebox.QUESTION,
|
| Messagebox.NO, Messagebox.QUESTION,
|
||||||
@@ -273,11 +290,12 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
|
|||||||
public void reload() {
|
public void reload() {
|
||||||
dataBean = null;
|
dataBean = null;
|
||||||
dataList.clear();
|
dataList.clear();
|
||||||
|
setHqlFilter();
|
||||||
loadFromDbSync();
|
loadFromDbSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command
|
@Command
|
||||||
@NotifyChange({"selIndex", "dataBean"})
|
@NotifyChange({"selIndex", "dataBean", "ableToDelete"})
|
||||||
public void afterRender() {
|
public void afterRender() {
|
||||||
if (editBean != null && !editBean.isValid()) {
|
if (editBean != null && !editBean.isValid()) {
|
||||||
return;
|
return;
|
||||||
@@ -305,6 +323,9 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
|
selSeason = null;
|
||||||
|
setHqlFilter();
|
||||||
|
dataList = getListFromService();
|
||||||
for (int i = 0; i < dataList.size(); i++) {
|
for (int i = 0; i < dataList.size(); i++) {
|
||||||
if (dataList.get(i).getId() == id) {
|
if (dataList.get(i).getId() == id) {
|
||||||
selIndex = i;
|
selIndex = i;
|
||||||
@@ -399,11 +420,61 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
|
|||||||
|
|
||||||
public boolean isAbleToDelete()
|
public boolean isAbleToDelete()
|
||||||
{
|
{
|
||||||
|
if (isSeasonFilter()
|
||||||
|
&&(!seasonService.getActive().equals(selSeason))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return this.isRecordSelected();
|
return this.isRecordSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAbleToAdd()
|
public boolean isAbleToAdd()
|
||||||
{
|
{
|
||||||
|
if (isSeasonFilter()
|
||||||
|
&&(!seasonService.getActive().equals(selSeason))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Season> getSeasons() {
|
||||||
|
return seasons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Season getSelSeason() {
|
||||||
|
return selSeason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelSeason(Season selSeason) {
|
||||||
|
this.selSeason = selSeason;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setHqlFilter() {
|
||||||
|
if (selSeason == null) {
|
||||||
|
hqlFilter.reset();
|
||||||
|
} else {
|
||||||
|
hqlFilter.setWhere("SEASON_ID = :season");
|
||||||
|
hqlFilter.setParam("season", selSeason.getId());
|
||||||
|
hqlFilter.setDataClass(SeasonsAware.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
@NotifyChange({"dataList", "ableToAdd", "selIndex", "dataBean", "ableToDelete"})
|
||||||
|
public void filterSeason() {
|
||||||
|
setHqlFilter();
|
||||||
|
dataList.clear();
|
||||||
|
loadFromDbSync();
|
||||||
|
dataBean = null;
|
||||||
|
selIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSeasonFilter() {
|
||||||
|
for (Class<?> clazz : service.getEntityClasses()) {
|
||||||
|
if (SeasonsAware.class.isAssignableFrom(clazz)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class MainMenu
|
|||||||
@Command
|
@Command
|
||||||
public void numSeries()
|
public void numSeries()
|
||||||
{
|
{
|
||||||
Window window = (Window) Executions.createComponents("/settings/numberSeries.zul", null, null);
|
Window window = (Window) Executions.createComponents("/settings/seasons.zul", null, null);
|
||||||
window.doModal();
|
window.doModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,12 @@ import info.bukova.isspst.data.Role;
|
|||||||
import info.bukova.isspst.data.User;
|
import info.bukova.isspst.data.User;
|
||||||
import info.bukova.isspst.data.Workgroup;
|
import info.bukova.isspst.data.Workgroup;
|
||||||
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.users.UserService;
|
import info.bukova.isspst.services.users.UserService;
|
||||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||||
import info.bukova.isspst.ui.DocumentViewModel;
|
import info.bukova.isspst.ui.DocumentViewModel;
|
||||||
|
import org.zkoss.bind.annotation.Init;
|
||||||
|
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -14,9 +17,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.zkoss.bind.annotation.Init;
|
|
||||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
|
||||||
|
|
||||||
public class DashBoardVM extends DocumentViewModel {
|
public class DashBoardVM extends DocumentViewModel {
|
||||||
|
|
||||||
@WireVariable
|
@WireVariable
|
||||||
@@ -25,9 +25,12 @@ public class DashBoardVM extends DocumentViewModel {
|
|||||||
private UserService userService;
|
private UserService userService;
|
||||||
@WireVariable
|
@WireVariable
|
||||||
private InvoicingService invoicingService;
|
private InvoicingService invoicingService;
|
||||||
|
@WireVariable
|
||||||
|
private LimitService limitService;
|
||||||
private User user;
|
private User user;
|
||||||
private Map<Workgroup, List<Role>> groupRoles;
|
private Map<Workgroup, List<Role>> groupRoles;
|
||||||
private Map<Workgroup, BigDecimal> workgroupSpent;
|
private Map<Workgroup, BigDecimal> workgroupSpent;
|
||||||
|
private Map<Workgroup, BigDecimal> workgroupLimit;
|
||||||
|
|
||||||
@Init(superclass = true)
|
@Init(superclass = true)
|
||||||
public void init() {
|
public void init() {
|
||||||
@@ -35,6 +38,7 @@ public class DashBoardVM extends DocumentViewModel {
|
|||||||
|
|
||||||
groupRoles = new HashMap<Workgroup, List<Role>>();
|
groupRoles = new HashMap<Workgroup, List<Role>>();
|
||||||
workgroupSpent = new HashMap<Workgroup, BigDecimal>();
|
workgroupSpent = new HashMap<Workgroup, BigDecimal>();
|
||||||
|
workgroupLimit = new HashMap<Workgroup, BigDecimal>();
|
||||||
|
|
||||||
List<Workgroup> wg = new ArrayList<Workgroup>();
|
List<Workgroup> wg = new ArrayList<Workgroup>();
|
||||||
if (workgroupService.getUserCentres(user) != null) {
|
if (workgroupService.getUserCentres(user) != null) {
|
||||||
@@ -48,6 +52,9 @@ public class DashBoardVM extends DocumentViewModel {
|
|||||||
List<Role> r = workgroupService.getUserWorkgroupRoles(w, user);
|
List<Role> r = workgroupService.getUserWorkgroupRoles(w, user);
|
||||||
groupRoles.put(w, r);
|
groupRoles.put(w, r);
|
||||||
workgroupSpent.put(w, invoicingService.totalInvoicedForWorkgroup(w));
|
workgroupSpent.put(w, invoicingService.totalInvoicedForWorkgroup(w));
|
||||||
|
if (limitService.getForWorkgroup(w) != null) {
|
||||||
|
workgroupLimit.put(w, limitService.getForWorkgroup(w).getLimit());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,4 +78,8 @@ public class DashBoardVM extends DocumentViewModel {
|
|||||||
return workgroupSpent;
|
return workgroupSpent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<Workgroup, BigDecimal> getWorkgroupLimit() {
|
||||||
|
return workgroupLimit;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package info.bukova.isspst.ui.limits;
|
||||||
|
|
||||||
|
import info.bukova.isspst.data.Limit;
|
||||||
|
import info.bukova.isspst.data.Workgroup;
|
||||||
|
import info.bukova.isspst.services.limits.LimitService;
|
||||||
|
import info.bukova.isspst.services.settings.SeasonService;
|
||||||
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||||
|
import info.bukova.isspst.ui.FormViewModel;
|
||||||
|
import org.zkoss.bind.annotation.Init;
|
||||||
|
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class LimitsForm extends FormViewModel<Limit> {
|
||||||
|
|
||||||
|
List<Workgroup> workgroups;
|
||||||
|
@WireVariable
|
||||||
|
WorkgroupService workgroupService;
|
||||||
|
@WireVariable
|
||||||
|
LimitService limitService;
|
||||||
|
@WireVariable
|
||||||
|
SeasonService seasonService;
|
||||||
|
|
||||||
|
@Init(superclass = true)
|
||||||
|
public void init() {
|
||||||
|
workgroups = workgroupService.getWorkgroups();
|
||||||
|
if (getDataBean().getWorkgroup() == null) {
|
||||||
|
List<Limit> limits = limitService.getForSeason(seasonService.getActive());
|
||||||
|
|
||||||
|
for (Limit l : limits) {
|
||||||
|
workgroups.remove(l.getWorkgroup());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Workgroup> getWorkgroups() {
|
||||||
|
return workgroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNewRec() {
|
||||||
|
return newRec;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
package info.bukova.isspst.ui.limits;
|
||||||
|
|
||||||
|
import info.bukova.isspst.StringUtils;
|
||||||
|
import info.bukova.isspst.data.Limit;
|
||||||
|
import info.bukova.isspst.data.Workgroup;
|
||||||
|
import info.bukova.isspst.services.invoicing.InvoicingService;
|
||||||
|
import info.bukova.isspst.services.limits.LimitService;
|
||||||
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||||
|
import info.bukova.isspst.ui.ListViewModel;
|
||||||
|
import org.jfree.chart.ChartFactory;
|
||||||
|
import org.jfree.chart.ChartUtilities;
|
||||||
|
import org.jfree.chart.JFreeChart;
|
||||||
|
import org.jfree.chart.plot.CategoryPlot;
|
||||||
|
import org.jfree.chart.plot.PlotOrientation;
|
||||||
|
import org.jfree.chart.renderer.category.BarRenderer3D;
|
||||||
|
import org.jfree.chart.title.LegendTitle;
|
||||||
|
import org.jfree.data.category.DefaultCategoryDataset;
|
||||||
|
import org.jfree.ui.RectangleEdge;
|
||||||
|
import org.zkoss.bind.annotation.GlobalCommand;
|
||||||
|
import org.zkoss.bind.annotation.Init;
|
||||||
|
import org.zkoss.bind.annotation.NotifyChange;
|
||||||
|
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.RenderedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class LimitsList extends ListViewModel<Limit> {
|
||||||
|
|
||||||
|
@WireVariable
|
||||||
|
private LimitService limitService;
|
||||||
|
@WireVariable
|
||||||
|
private InvoicingService invoicingService;
|
||||||
|
@WireVariable
|
||||||
|
private WorkgroupService workgroupService;
|
||||||
|
private Map<Limit, BigDecimal> spent;
|
||||||
|
private RenderedImage chart;
|
||||||
|
|
||||||
|
@Init(superclass = true)
|
||||||
|
public void init() {
|
||||||
|
service = limitService;
|
||||||
|
dataClass = Limit.class;
|
||||||
|
formZul = "limitForm.zul";
|
||||||
|
//dataFilter = new MUnitFilter(getFilterTemplate());
|
||||||
|
genSpent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Limit, BigDecimal> getSpent() {
|
||||||
|
if (spent != null && !getDataList().isEmpty()) {
|
||||||
|
for (Limit l : spent.keySet()) {
|
||||||
|
if (!l.getSeason().equals(getDataList().get(0).getSeason())) {
|
||||||
|
spent = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spent != null && spent.keySet().size() < getDataList().size()) {
|
||||||
|
spent = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spent != null) {
|
||||||
|
return spent;
|
||||||
|
}
|
||||||
|
|
||||||
|
spent = new HashMap<Limit, BigDecimal>();
|
||||||
|
for (Limit l : getDataList()) {
|
||||||
|
spent.put(l, invoicingService.totalInvoicedForWorkgroupAndSeason(l.getWorkgroup(), getSelSeason()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return spent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void genSpent() {
|
||||||
|
spent = new HashMap<Limit, BigDecimal>();
|
||||||
|
for (Limit l : getDataList()) {
|
||||||
|
spent.put(l, invoicingService.totalInvoicedForWorkgroupAndSeason(l.getWorkgroup(), getSelSeason()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void genCharts() {
|
||||||
|
DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
|
||||||
|
|
||||||
|
for (Workgroup wg : workgroupService.getWorkgroups()) {
|
||||||
|
Limit limit = null;
|
||||||
|
for (Limit l : getDataList()) {
|
||||||
|
if (l.getWorkgroup().equals(wg)) {
|
||||||
|
limit = l;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataSet.addValue(limit == null ? null : limit.getLimit(), StringUtils.localize("LimitsLimit"), wg.getFullName());
|
||||||
|
dataSet.addValue(invoicingService.totalInvoicedForWorkgroupAndSeason(wg, getSelSeason()), StringUtils.localize("LimitsSpent"), wg.getFullName());
|
||||||
|
}
|
||||||
|
|
||||||
|
JFreeChart jfChart = ChartFactory.createBarChart3D(StringUtils.localize("LimitsChartTitle"), StringUtils.localize("LimitsWorkgroup"),
|
||||||
|
StringUtils.localize("LimitsAmount"), dataSet, PlotOrientation.HORIZONTAL, true, false, false);
|
||||||
|
CategoryPlot plot = (CategoryPlot) jfChart.getPlot();
|
||||||
|
BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer();
|
||||||
|
renderer.setSeriesPaint(0, Color.GREEN);
|
||||||
|
renderer.setSeriesPaint(1, Color.RED);
|
||||||
|
|
||||||
|
LegendTitle legend = jfChart.getLegend();
|
||||||
|
legend.setPosition(RectangleEdge.RIGHT);
|
||||||
|
|
||||||
|
try {
|
||||||
|
chart = ImageIO.read(new ByteArrayInputStream(ChartUtilities.encodeAsPNG(jfChart.createBufferedImage(1000, 400))));
|
||||||
|
} catch (IOException e) {
|
||||||
|
chart = null;
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public RenderedImage getChart() {
|
||||||
|
genCharts();
|
||||||
|
return chart;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@GlobalCommand
|
||||||
|
@NotifyChange({ "dataList", "dataBean", "ableToDelete", "chart", "spent" })
|
||||||
|
public void refresh() {
|
||||||
|
genSpent();
|
||||||
|
super.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
package info.bukova.isspst.ui.mail;
|
package info.bukova.isspst.ui.mail;
|
||||||
|
|
||||||
import static ch.lambdaj.Lambda.filter;
|
|
||||||
import static ch.lambdaj.Lambda.having;
|
|
||||||
import static ch.lambdaj.Lambda.on;
|
|
||||||
import static org.hamcrest.Matchers.startsWith;
|
|
||||||
import info.bukova.isspst.data.Address;
|
import info.bukova.isspst.data.Address;
|
||||||
import info.bukova.isspst.data.Member;
|
import info.bukova.isspst.data.Member;
|
||||||
import info.bukova.isspst.data.User;
|
import info.bukova.isspst.data.User;
|
||||||
@@ -15,10 +11,6 @@ import info.bukova.isspst.reporting.ReportDefinition;
|
|||||||
import info.bukova.isspst.services.addressbook.AdbService;
|
import info.bukova.isspst.services.addressbook.AdbService;
|
||||||
import info.bukova.isspst.services.users.UserService;
|
import info.bukova.isspst.services.users.UserService;
|
||||||
import info.bukova.isspst.ui.DocumentViewModel;
|
import info.bukova.isspst.ui.DocumentViewModel;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.security.access.AccessDeniedException;
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
import org.zkoss.bind.annotation.BindingParam;
|
import org.zkoss.bind.annotation.BindingParam;
|
||||||
import org.zkoss.bind.annotation.Command;
|
import org.zkoss.bind.annotation.Command;
|
||||||
@@ -28,6 +20,14 @@ import org.zkoss.bind.annotation.NotifyChange;
|
|||||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||||
import org.zkoss.zul.Window;
|
import org.zkoss.zul.Window;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static ch.lambdaj.Lambda.filter;
|
||||||
|
import static ch.lambdaj.Lambda.having;
|
||||||
|
import static ch.lambdaj.Lambda.on;
|
||||||
|
import static org.hamcrest.Matchers.startsWith;
|
||||||
|
|
||||||
public class MailForm extends DocumentViewModel
|
public class MailForm extends DocumentViewModel
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public class MailForm extends DocumentViewModel
|
|||||||
addressbook = new ArrayList<Address>();
|
addressbook = new ArrayList<Address>();
|
||||||
}
|
}
|
||||||
|
|
||||||
users = userService.getAll();
|
users = userService.getUsersForCombo();
|
||||||
|
|
||||||
selectedAddresses = new ArrayList<Address>();
|
selectedAddresses = new ArrayList<Address>();
|
||||||
selectedUsers = new ArrayList<User>();
|
selectedUsers = new ArrayList<User>();
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
package info.bukova.isspst.ui.main;
|
package info.bukova.isspst.ui.main;
|
||||||
|
|
||||||
|
import info.bukova.isspst.Constants;
|
||||||
|
import info.bukova.isspst.SessionData;
|
||||||
import info.bukova.isspst.StringUtils;
|
import info.bukova.isspst.StringUtils;
|
||||||
import info.bukova.isspst.data.RequirementBase;
|
import info.bukova.isspst.data.RequirementBase;
|
||||||
import info.bukova.isspst.services.requirement.ApproveException;
|
import info.bukova.isspst.services.requirement.ApproveException;
|
||||||
import info.bukova.isspst.services.requirement.RequirementBaseService;
|
import info.bukova.isspst.services.requirement.RequirementBaseService;
|
||||||
|
import info.bukova.isspst.signapi.SignData;
|
||||||
import info.bukova.isspst.ui.ListViewModel;
|
import info.bukova.isspst.ui.ListViewModel;
|
||||||
import org.zkoss.bind.BindUtils;
|
import org.zkoss.bind.BindUtils;
|
||||||
import org.zkoss.bind.annotation.BindingParam;
|
import org.zkoss.bind.annotation.BindingParam;
|
||||||
import org.zkoss.bind.annotation.Command;
|
import org.zkoss.bind.annotation.Command;
|
||||||
import org.zkoss.bind.annotation.ExecutionArgParam;
|
import org.zkoss.bind.annotation.ExecutionArgParam;
|
||||||
import org.zkoss.bind.annotation.Init;
|
import org.zkoss.bind.annotation.Init;
|
||||||
|
import org.zkoss.bind.annotation.NotifyChange;
|
||||||
|
import org.zkoss.zk.ui.Executions;
|
||||||
|
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||||
import org.zkoss.zul.Messagebox;
|
import org.zkoss.zul.Messagebox;
|
||||||
import org.zkoss.zul.Window;
|
import org.zkoss.zul.Window;
|
||||||
|
|
||||||
@@ -24,6 +30,12 @@ public class ApproveDialogVM {
|
|||||||
private RequirementBase requirement;
|
private RequirementBase requirement;
|
||||||
private ListViewModel grid;
|
private ListViewModel grid;
|
||||||
private Date approveDate;
|
private Date approveDate;
|
||||||
|
@WireVariable
|
||||||
|
private SessionData sessionData;
|
||||||
|
private boolean signed;
|
||||||
|
private boolean signRequired;
|
||||||
|
private boolean timer;
|
||||||
|
private byte[] signedPdf;
|
||||||
|
|
||||||
public Date getApproveDate() {
|
public Date getApproveDate() {
|
||||||
return approveDate;
|
return approveDate;
|
||||||
@@ -41,12 +53,22 @@ public class ApproveDialogVM {
|
|||||||
this.requirement = requirement;
|
this.requirement = requirement;
|
||||||
this.grid = grid;
|
this.grid = grid;
|
||||||
this.approveDate = new Date();
|
this.approveDate = new Date();
|
||||||
|
|
||||||
|
if (service.getNextWorkflow(requirement).getSignature() != null
|
||||||
|
&& service.getNextWorkflow(requirement).getSignature()) {
|
||||||
|
this.signed = false;
|
||||||
|
this.signRequired = true;
|
||||||
|
} else {
|
||||||
|
this.signRequired = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.timer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command
|
@Command
|
||||||
public void approve(@BindingParam("window") Window window) {
|
public void approve(@BindingParam("window") Window window) {
|
||||||
try {
|
try {
|
||||||
service.approve(requirement, approveDate);
|
service.approve(requirement, approveDate, signedPdf);
|
||||||
BindUtils.postNotifyChange(null, null, grid, "dataBean");
|
BindUtils.postNotifyChange(null, null, grid, "dataBean");
|
||||||
BindUtils.postNotifyChange(null, null, grid, "canApprove");
|
BindUtils.postNotifyChange(null, null, grid, "canApprove");
|
||||||
BindUtils.postGlobalCommand(null, null, "reload", null);
|
BindUtils.postGlobalCommand(null, null, "reload", null);
|
||||||
@@ -57,4 +79,39 @@ public class ApproveDialogVM {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
@NotifyChange("timer")
|
||||||
|
public void signPdf() {
|
||||||
|
if (service.prepareSignData(requirement, approveDate)) {
|
||||||
|
timer = true;
|
||||||
|
Executions.getCurrent().sendRedirect("/api/sign/signer.jnlp", "signer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
@NotifyChange({"signed", "timer"})
|
||||||
|
public void onTimer() {
|
||||||
|
String guid = (String) sessionData.getProperty(Constants.KEY_SIGN_GUID);
|
||||||
|
SignData data = (SignData) sessionData.getProperty(Constants.KEY_SIGN_DATA);
|
||||||
|
|
||||||
|
if (guid.equals(data.getSignGuid()) && data.isSignSuccess()) {
|
||||||
|
signed = true;
|
||||||
|
timer = false;
|
||||||
|
signedPdf = data.getPdfData();
|
||||||
|
} else {
|
||||||
|
signed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSigned() {
|
||||||
|
return signed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTimer() {
|
||||||
|
return timer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSignRequired() {
|
||||||
|
return signRequired;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public class InvoicingList extends ListViewModel<Invoicing> {
|
|||||||
public void initInvoicing() {
|
public void initInvoicing() {
|
||||||
service = invoicingService;
|
service = invoicingService;
|
||||||
dataClass = Invoicing.class;
|
dataClass = Invoicing.class;
|
||||||
formZul = "invoicingForm.zul";
|
|
||||||
dataFilter = new InvoicingFilter(getFilterTemplate());
|
dataFilter = new InvoicingFilter(getFilterTemplate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package info.bukova.isspst.ui.main.invoicing;
|
||||||
|
|
||||||
|
import info.bukova.isspst.data.Invoicing;
|
||||||
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
|
import org.zkoss.bind.annotation.Init;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class InvoicingMaterialArchiveList extends InvoicingList {
|
||||||
|
|
||||||
|
@Init(superclass = true)
|
||||||
|
public void initInvoicingMaterialArchiveList()
|
||||||
|
{
|
||||||
|
formZul = "/main/invoicing/material/invHeadForm.zul";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Invoicing> getListFromService() {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return invoicingService.getMaterialArchiveList();
|
||||||
|
}
|
||||||
|
catch (AccessDeniedException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return new ArrayList<Invoicing>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package info.bukova.isspst.ui.main.invoicing;
|
||||||
|
|
||||||
|
import info.bukova.isspst.data.Invoicing;
|
||||||
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
|
import org.zkoss.bind.annotation.Init;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class InvoicingMaterialPendingList extends InvoicingList {
|
||||||
|
|
||||||
|
@Init(superclass = true)
|
||||||
|
public void initInvoicingMaterialPendingList()
|
||||||
|
{
|
||||||
|
formZul = "/main/invoicing/material/invHeadForm.zul";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Invoicing> getListFromService() {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return invoicingService.getMaterialPendingList();
|
||||||
|
}
|
||||||
|
catch (AccessDeniedException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return new ArrayList<Invoicing>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package info.bukova.isspst.ui.main.invoicing;
|
|
||||||
|
|
||||||
import info.bukova.isspst.data.Invoicing;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.security.access.AccessDeniedException;
|
|
||||||
import org.zkoss.bind.annotation.Init;
|
|
||||||
|
|
||||||
public class InvoicingPendingList extends InvoicingList
|
|
||||||
{
|
|
||||||
@Init(superclass = true)
|
|
||||||
public void initInvoicingPendingList()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<Invoicing> getListFromService()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return invoicingService.getPendingList();
|
|
||||||
}
|
|
||||||
catch (AccessDeniedException e)
|
|
||||||
{
|
|
||||||
// BindUtils.postGlobalCommand(null, null, "disableCentre", null);
|
|
||||||
// e.printStackTrace();
|
|
||||||
return new ArrayList<Invoicing>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package info.bukova.isspst.ui.main.invoicing;
|
||||||
|
|
||||||
|
import info.bukova.isspst.data.Invoicing;
|
||||||
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
|
import org.zkoss.bind.annotation.Init;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class InvoicingServicesArchiveList extends InvoicingList {
|
||||||
|
|
||||||
|
@Init(superclass = true)
|
||||||
|
public void initInvoicingServicesArchiveList()
|
||||||
|
{
|
||||||
|
formZul = "/main/invoicing/services/invHeadForm.zul";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Invoicing> getListFromService() {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return invoicingService.getServicesArchiveList();
|
||||||
|
}
|
||||||
|
catch (AccessDeniedException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return new ArrayList<Invoicing>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package info.bukova.isspst.ui.main.invoicing;
|
||||||
|
|
||||||
|
import info.bukova.isspst.data.Invoicing;
|
||||||
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
|
import org.zkoss.bind.annotation.Init;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class InvoicingServicesPendingList extends InvoicingList {
|
||||||
|
|
||||||
|
@Init(superclass = true)
|
||||||
|
public void initInvoicingServicesPendingList()
|
||||||
|
{
|
||||||
|
formZul = "/main/invoicing/services/invHeadForm.zul";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Invoicing> getListFromService() {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return invoicingService.getServicesPendingList();
|
||||||
|
}
|
||||||
|
catch (AccessDeniedException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return new ArrayList<Invoicing>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,10 +12,6 @@ import info.bukova.isspst.services.users.UserService;
|
|||||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||||
import info.bukova.isspst.ui.FormViewModel;
|
import info.bukova.isspst.ui.FormViewModel;
|
||||||
import info.bukova.isspst.validators.RequirementFormValidator;
|
import info.bukova.isspst.validators.RequirementFormValidator;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.zkoss.bind.BindUtils;
|
import org.zkoss.bind.BindUtils;
|
||||||
@@ -29,6 +25,10 @@ import org.zkoss.zk.ui.select.annotation.WireVariable;
|
|||||||
import org.zkoss.zul.Window;
|
import org.zkoss.zul.Window;
|
||||||
import org.zkoss.zul.impl.InputElement;
|
import org.zkoss.zul.impl.InputElement;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class RequirementForm extends FormViewModel<Requirement>
|
public class RequirementForm extends FormViewModel<Requirement>
|
||||||
{
|
{
|
||||||
private final static Logger log = LoggerFactory.getLogger(RequirementForm.class.getName());
|
private final static Logger log = LoggerFactory.getLogger(RequirementForm.class.getName());
|
||||||
@@ -112,7 +112,14 @@ public class RequirementForm extends FormViewModel<Requirement>
|
|||||||
this.setRequirementFormValidator(new RequirementFormValidator());
|
this.setRequirementFormValidator(new RequirementFormValidator());
|
||||||
this.setSyncItems(this.getDataBean().getItems());
|
this.setSyncItems(this.getDataBean().getItems());
|
||||||
requirementService.loadType(getDataBean());
|
requirementService.loadType(getDataBean());
|
||||||
this.centres = reqTypeService.filterCentres(getDataBean().getType(), workgroupService.getUserCentres(userService.getCurrent()));
|
|
||||||
|
if (isEditRec()) {
|
||||||
|
List<Workgroup> current = new ArrayList<Workgroup>();
|
||||||
|
current.add(getDataBean().getCentre());
|
||||||
|
this.centres = current;
|
||||||
|
} else {
|
||||||
|
this.centres = reqTypeService.filterCentres(getDataBean().getType(), workgroupService.getUserCentres(userService.getCurrent(), true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RequirementItem> getSyncItems()
|
public List<RequirementItem> getSyncItems()
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user