Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c72ab99dc1 | ||
|
|
4dbe7c47f8 | ||
|
|
1aeff7f587 | ||
|
|
70a2e01fae | ||
|
|
fcb8db25fa | ||
|
|
740847e865 | ||
|
|
093d359df7 | ||
|
|
ea2708f303 | ||
|
|
9b2e2b3641 | ||
|
|
a8dc7f1306 | ||
|
|
7d4d693b2e | ||
|
|
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 | ||
|
|
4d74b0a3fe | ||
|
|
3b3e4b38e6 | ||
|
|
1164e11107 | ||
|
|
c2ca2e45ec | ||
|
|
c9a56887dc | ||
|
|
aaa89a2653 | ||
|
|
fbc7a02161 | ||
|
|
e5a8e0f0d9 | ||
|
|
0f169f8be9 | ||
|
|
b6d0546b48 | ||
|
|
a6799064f7 | ||
|
|
933f5e784b | ||
|
|
04dc8a5587 | ||
|
|
b63a2c3944 | ||
|
|
67629cf312 | ||
|
|
cdd2f81cad | ||
|
|
c292c3bcde | ||
|
|
9d202192ee | ||
|
|
93a463db69 | ||
|
|
3a5da06c48 | ||
|
|
76969a2baf | ||
|
|
4e6af2ceed | ||
|
|
ef431867e1 | ||
|
|
25c8405f03 | ||
|
|
ac90b0a2e3 | ||
|
|
9c5679af2c | ||
|
|
ceac59c8d3 | ||
|
|
5d9e6226d3 | ||
|
|
b470559cb7 | ||
|
|
9b8bfe2228 | ||
|
|
42deec695a | ||
|
|
e01e32f10c | ||
|
|
f13bc6e5c4 | ||
|
|
021d73bf48 | ||
|
|
340abb5269 | ||
|
|
724f6b3559 | ||
|
|
ecd3cf426b | ||
|
|
c6ebf8959b | ||
|
|
48d2c75d7b | ||
|
|
1d2810f78d | ||
|
|
c4f5671327 | ||
|
|
860c7227cd | ||
|
|
f94afbc3ed | ||
|
|
1df90a41c4 | ||
|
|
93e1ef1fd3 | ||
|
|
277ea0f993 | ||
|
|
884bc8267d | ||
|
|
678c140a94 | ||
|
|
566b408ddd | ||
|
|
9ec15943ed | ||
|
|
ecbc2be47c | ||
|
|
024f1321ad | ||
|
|
4e2b00a957 | ||
|
|
d9fd26bbad | ||
|
|
e461afd611 | ||
|
|
ea64e5a888 | ||
|
|
08532dcd02 | ||
|
|
ba99079a85 | ||
|
|
c04f74c5a2 | ||
|
|
a0447318e6 | ||
|
|
eed31fe6da | ||
|
|
8e33bb8ef7 | ||
|
|
61a4b3ba82 | ||
|
|
d37076cd27 | ||
|
|
ee2539000c | ||
|
|
780edd5678 | ||
|
|
e51955f86a | ||
|
|
26699fd3a9 | ||
|
|
0f02efbec3 | ||
|
|
ce17f5b626 | ||
|
|
2a6ce7e4d3 | ||
|
|
f4fe974931 | ||
|
|
537cc563ac | ||
|
|
b357d0a7ef | ||
|
|
100889d44a | ||
|
|
765c56f250 | ||
|
|
4cd2f5b5e6 | ||
|
|
6ff69c932c | ||
|
|
908b214a93 | ||
|
|
f5e69ce80d | ||
|
|
cd2214c7ef | ||
|
|
66133dce1a | ||
|
|
e9cd08c249 | ||
|
|
34f1bb86de | ||
|
|
ad2a861a7b | ||
|
|
cf6c523698 | ||
|
|
02311ae5dd | ||
|
|
b1818546c0 | ||
|
|
bc5a7a7c4c | ||
|
|
966c9033ef |
+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/[email protected]
|
||||
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/[email protected]
|
||||
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>
|
||||
<id>fdvsolution.public</id>
|
||||
<name>Dynamic Jasper</name>
|
||||
<url>http://archiva.fdvs.com.ar/repository/public1/</url>
|
||||
<url>http://nexus.fdvs.com.ar/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
@@ -224,7 +224,16 @@
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>4.3.0.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-search</artifactId>
|
||||
<version>4.4.6.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-ehcache</artifactId>
|
||||
<version>4.2.8.Final</version>
|
||||
</dependency>
|
||||
|
||||
<!-- ZK -->
|
||||
<dependency>
|
||||
@@ -345,6 +354,19 @@
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Text extractors -->
|
||||
<dependency>
|
||||
<groupId>org.apache.odftoolkit</groupId>
|
||||
<artifactId>simple-odf</artifactId>
|
||||
<version>0.7-incubating</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>3.11</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Test -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
@@ -390,6 +412,23 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
</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>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
@@ -6,33 +6,39 @@ import info.bukova.isspst.data.NumberSeries;
|
||||
import info.bukova.isspst.data.Permission;
|
||||
import info.bukova.isspst.data.RequirementType;
|
||||
import info.bukova.isspst.data.Role;
|
||||
import info.bukova.isspst.data.Season;
|
||||
import info.bukova.isspst.data.SettingsData;
|
||||
import info.bukova.isspst.data.User;
|
||||
import info.bukova.isspst.reporting.Report;
|
||||
import info.bukova.isspst.reporting.ReportMapping;
|
||||
import info.bukova.isspst.reporting.ReportType;
|
||||
import info.bukova.isspst.services.dbinfo.DbInfoService;
|
||||
import info.bukova.isspst.services.fulltext.FullTextService;
|
||||
import info.bukova.isspst.services.munits.MUnitService;
|
||||
import info.bukova.isspst.services.numberseries.NumberSeriesService;
|
||||
import info.bukova.isspst.services.requirement.RequirementTypeService;
|
||||
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.RoleService;
|
||||
import info.bukova.isspst.services.users.UserService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class AppInitListener implements ServletContextListener {
|
||||
|
||||
|
||||
private DbInfoService dbInfoService;
|
||||
private MUnitService mUnitsService;
|
||||
private RoleService roleService;
|
||||
private UserService userService;
|
||||
@@ -40,6 +46,8 @@ public class AppInitListener implements ServletContextListener {
|
||||
private NumberSeriesService nsService;
|
||||
private RequirementTypeService reqTypeService;
|
||||
private GlobalSettingsService gSettingsService;
|
||||
private FullTextService ftService;
|
||||
private SeasonService seasonService;
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
@@ -52,6 +60,7 @@ public class AppInitListener implements ServletContextListener {
|
||||
logger.info("Initializing database");
|
||||
|
||||
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(evt.getServletContext());
|
||||
dbInfoService = ctx.getBean(DbInfoService.class);
|
||||
mUnitsService = ctx.getBean(MUnitService.class);
|
||||
roleService = ctx.getBean(RoleService.class);
|
||||
userService = ctx.getBean(UserService.class);
|
||||
@@ -59,8 +68,11 @@ public class AppInitListener implements ServletContextListener {
|
||||
nsService =ctx.getBean(NumberSeriesService.class);
|
||||
gSettingsService = ctx.getBean(GlobalSettingsService.class);
|
||||
reqTypeService = ctx.getBean(RequirementTypeService.class);
|
||||
ftService = ctx.getBean(FullTextService.class);
|
||||
seasonService = ctx.getBean(SeasonService.class);
|
||||
|
||||
userService.grantAdmin();
|
||||
this.checkDbInfo();
|
||||
checkMUnits();
|
||||
checkRoles();
|
||||
checkUsers();
|
||||
@@ -69,11 +81,33 @@ public class AppInitListener implements ServletContextListener {
|
||||
this.checkNumberSeries();
|
||||
checkReqTypes();
|
||||
this.checkGlobalSettings();
|
||||
buildFulltext();
|
||||
userService.removeAccess();
|
||||
|
||||
loadModuleReports();
|
||||
}
|
||||
|
||||
private void buildFulltext() {
|
||||
ftService.reindex();
|
||||
}
|
||||
private void checkDbInfo()
|
||||
{
|
||||
List<User> userList = userService.getAll();
|
||||
|
||||
if (userList.isEmpty())
|
||||
{
|
||||
// Database is new/empty, column definition is anotated - set actual
|
||||
// database version
|
||||
dbInfoService.updateDatabaseVersion();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Existing database - try change structure and set actual database
|
||||
// version...
|
||||
dbInfoService.changeDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkMUnits()
|
||||
{
|
||||
List<MUnit> mUnits = mUnitsService.getAll();
|
||||
@@ -200,6 +234,9 @@ public class AppInitListener implements ServletContextListener {
|
||||
|
||||
private void checkPermissions() {
|
||||
for (Module m : Constants.MODULES) {
|
||||
if (!m.isDefaultPermissions()) {
|
||||
continue;
|
||||
}
|
||||
for (Permission p : Constants.DEF_PERMISSIONS) {
|
||||
if (permService.getPermissionByModule(m.getId(), p.getAuthority()) == null) {
|
||||
p.setModule(m.getId());
|
||||
@@ -255,28 +292,40 @@ public class AppInitListener implements ServletContextListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkNumberSeries()
|
||||
{
|
||||
NumberSeries ns = nsService.getNumberSerie(Constants.MOD_REQUIREMENTS);
|
||||
|
||||
if (ns == null)
|
||||
{
|
||||
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(Constants.MOD_REQUIREMENTS);
|
||||
ns.setPrefix("");
|
||||
ns.setModule(modId);
|
||||
ns.setPrefix(Constants.NUM_SERIES_PREFIX.get(modId));
|
||||
ns.setNumber(1);
|
||||
ns.setSeason(season);
|
||||
nsService.add(ns);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ns = nsService.getNumberSerie(Constants.MOD_ORDER);
|
||||
|
||||
if (ns == null)
|
||||
private void checkNumberSeries()
|
||||
{
|
||||
ns = new NumberSeries();
|
||||
ns.setModule(Constants.MOD_ORDER);
|
||||
ns.setPrefix("");
|
||||
ns.setNumber(1);
|
||||
nsService.add(ns);
|
||||
Season season;
|
||||
try {
|
||||
season = seasonService.getActive();
|
||||
} catch (SeasonException e) {
|
||||
season = null;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
for (Season s : seasonService.getAllSeasons()) {
|
||||
checkNumberSeriesForSeason(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.math.BigDecimal;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import static org.apache.commons.lang.StringUtils.strip;
|
||||
|
||||
public class BigDecimalUtils
|
||||
{
|
||||
@@ -23,6 +24,17 @@ public class BigDecimalUtils
|
||||
|
||||
String valueS = value.toPlainString();
|
||||
String searchS = search.toPlainString();
|
||||
|
||||
if (valueS.contains(".") || valueS.contains(",")) {
|
||||
valueS = strip(valueS, "0");
|
||||
valueS = strip(valueS, ".,");
|
||||
}
|
||||
|
||||
if (searchS.contains(".") || searchS.contains(",")) {
|
||||
searchS = strip(searchS, "0");
|
||||
searchS = strip(searchS, ".,");
|
||||
}
|
||||
|
||||
boolean result = (valueS.compareTo(searchS) == 0);
|
||||
|
||||
String s = "search='" + searchS + "', value='" + valueS + "', equal=" + (result ? "true" : "false");
|
||||
|
||||
@@ -1,13 +1,48 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import org.jfree.util.Log;
|
||||
|
||||
public class BooleanUtils
|
||||
{
|
||||
public static boolean isEqualByBoolean(Boolean b1, Boolean b2)
|
||||
private static final String TAG = BooleanUtils.class.getSimpleName();
|
||||
|
||||
public static boolean isEqualByBooleanValue(Boolean b1, Boolean b2)
|
||||
{
|
||||
boolean bool1 = ((b1 == null) ? false : b1.booleanValue());
|
||||
boolean bool2 = ((b2 == null) ? false : b2.booleanValue());
|
||||
boolean equals = (bool1 == bool2);
|
||||
return equals;
|
||||
}
|
||||
|
||||
public static boolean isEqualByBoolean(Boolean b1, Boolean b2)
|
||||
{
|
||||
if ((b1 == null) && (b2 == null))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ((b1 != null) && (b2 != null))
|
||||
{
|
||||
return (b1.booleanValue() == b2.booleanValue());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEqualFilterByBoolean(Boolean value, Boolean filterValue)
|
||||
{
|
||||
if (filterValue == null)
|
||||
{
|
||||
// Show all records
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
// Fuck!!! Tri-state data (null, false, true)... We need new solution for selecting ALL data
|
||||
Log.warn(TAG + "\nVelky Boolean v databazi... Pozor na filtrovani.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return (value.booleanValue() == filterValue.booleanValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import info.bukova.isspst.data.Order;
|
||||
import info.bukova.isspst.data.Permission;
|
||||
import info.bukova.isspst.data.PermissionType;
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
import info.bukova.isspst.data.RequirementType;
|
||||
import info.bukova.isspst.data.Role;
|
||||
import info.bukova.isspst.data.TripBill;
|
||||
import info.bukova.isspst.data.TripBillApproval;
|
||||
import info.bukova.isspst.data.TripRequirement;
|
||||
import info.bukova.isspst.reporting.Report;
|
||||
import info.bukova.isspst.reporting.ReportMapping;
|
||||
import info.bukova.isspst.services.addressbook.AdbService;
|
||||
import info.bukova.isspst.services.buildings.BuildingService;
|
||||
import info.bukova.isspst.services.fulltext.FullTextService;
|
||||
import info.bukova.isspst.services.invoicing.InvoicingService;
|
||||
import info.bukova.isspst.services.limits.LimitService;
|
||||
import info.bukova.isspst.services.munits.MUnitService;
|
||||
import info.bukova.isspst.services.orders.ApprovedService;
|
||||
import info.bukova.isspst.services.orders.OrderService;
|
||||
@@ -23,13 +24,20 @@ import info.bukova.isspst.services.reqsubjects.ServiceItemService;
|
||||
import info.bukova.isspst.services.requirement.RequirementService;
|
||||
import info.bukova.isspst.services.requirement.RequirementTypeService;
|
||||
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.users.RoleService;
|
||||
import info.bukova.isspst.services.users.UserService;
|
||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public final static long DB_VERSION = 6;
|
||||
|
||||
public final static String DEF_ADMIN = "admin";
|
||||
public final static String DEF_ADMIN_PASSWD = "admin";
|
||||
public final static String ROLE_USER = "ROLE_USER";
|
||||
@@ -79,6 +87,9 @@ public class Constants {
|
||||
public final static String MOD_APPROVED = "APPROVED";
|
||||
public final static String MOD_ORDER = "ORDER";
|
||||
public final static String MOD_INVOICING = "INVOICING";
|
||||
public final static String MOD_SEARCH = "SEARCH";
|
||||
public final static String MOD_SIGNEDDOCS = "SIGNEDDOCS";
|
||||
public final static String MOD_LIMITS = "LIMITS";
|
||||
public final static Module MODULES[] = {
|
||||
new Module(MOD_USERS, "Uživatelé", UserService.class),
|
||||
new Module(MOD_PERMISSIONS, "Práva", RoleService.class),
|
||||
@@ -94,7 +105,11 @@ public class Constants {
|
||||
new Module(MOD_TRIPBILL, "Cestovní příkazy", TripBillService.class),
|
||||
new Module(MOD_APPROVED, "Schválené položky požadavků", ApprovedService.class),
|
||||
new Module(MOD_ORDER, "Objednávky", OrderService.class),
|
||||
new Module(MOD_INVOICING, "Fakturace požadavků", InvoicingService.class) };
|
||||
new Module(MOD_INVOICING, "Fakturace požadavků", InvoicingService.class),
|
||||
new Module(MOD_SEARCH, "Fulltextové vyhledávání", FullTextService.class, true, false),
|
||||
new Module(MOD_SIGNEDDOCS, "Podepsané dokumenty", SignedDocumentService.class, true, false),
|
||||
new Module(MOD_LIMITS, "Limity komisi", LimitService.class),
|
||||
};
|
||||
|
||||
public final static String PERM_APPROVE = "PERM_APPROVE";
|
||||
public final static String PERM_SHOW_WORKGROUP_REQ = "PERM_SHOW_WORKGROUP_REQ";
|
||||
@@ -102,31 +117,60 @@ public class Constants {
|
||||
public final static String PERM_SHOW_ALL_REQ = "PERM_SHOW_ALL_REQ";
|
||||
public final static String PERM_EDIT_NEW = "PERM_EDIT_NEW";
|
||||
public final static String PERM_EDIT_OWN = "PERM_EDIT_OWN";
|
||||
public final static String PERM_DELETE_NEW = "PERM_DELETE_NEW";
|
||||
public final static String PERM_SEARCH = "PERM_SEARCH";
|
||||
public final static String PERM_PAY_BILL = "PERM_PAY_BILL";
|
||||
|
||||
public final static Permission SPECIAL_PERMISSIONS[] = {
|
||||
new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_REQUIREMENTS, PermissionType.GLOBAL),
|
||||
new Permission(PERM_DELETE_NEW, "Mazat neschválené", MOD_REQUIREMENTS, PermissionType.GLOBAL),
|
||||
new Permission(PERM_SHOW_WORKGROUP_REQ, "Zobrazení požadavků komise", MOD_REQUIREMENTS, PermissionType.WORKGROUP),
|
||||
new Permission(PERM_SHOW_CENTRE_REQ, "Zobrazení požadavků střediska", MOD_REQUIREMENTS, PermissionType.CENTRE),
|
||||
new Permission(PERM_SHOW_ALL_REQ, "Zobrazení všech požadavků", MOD_REQUIREMENTS, PermissionType.GLOBAL),
|
||||
new Permission(PERM_APPROVE, "Schválení", MOD_REQUIREMENTS, PermissionType.WORKGROUP),
|
||||
|
||||
new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL),
|
||||
new Permission(PERM_DELETE_NEW, "Mazat neschválené", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL),
|
||||
new Permission(PERM_SHOW_WORKGROUP_REQ, "Zobrazení požadavků komise", MOD_TRIPREQUIREMENTS, PermissionType.WORKGROUP),
|
||||
new Permission(PERM_SHOW_CENTRE_REQ, "Zobrazení požadavků střediska", MOD_TRIPREQUIREMENTS, PermissionType.CENTRE),
|
||||
new Permission(PERM_SHOW_ALL_REQ, "Zobrazení všech požadavků", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL),
|
||||
new Permission(PERM_APPROVE, "Schválení", MOD_TRIPREQUIREMENTS, PermissionType.WORKGROUP),
|
||||
|
||||
new Permission(PERM_SEARCH, "Vyhledávat", MOD_SEARCH, PermissionType.GLOBAL),
|
||||
new Permission(PERM_READ, "Číst", MOD_SIGNEDDOCS, PermissionType.GLOBAL),
|
||||
|
||||
new Permission(PERM_PAY_BILL, "Vyplacení SC", MOD_TRIPBILL, PermissionType.GLOBAL)
|
||||
};
|
||||
|
||||
public final static String DYNAMIC_REPORT_NAME = "Tabulková sestava";
|
||||
public final static ReportMapping REPORTS[] = {
|
||||
new ReportMapping(MOD_ADDRESSBOOK, new Report("Adresní karty", "address")),
|
||||
new ReportMapping(MOD_ADDRESSBOOK, new Report("Adresa", "address", false, true)),
|
||||
new ReportMapping(MOD_TRIPBILL, new Report("Žádost", "tripRequirement", false, true)),
|
||||
new ReportMapping(MOD_TRIPBILL, new Report("Vyúčtování", "tripBill", false, true)),
|
||||
new ReportMapping(MOD_ORDER, new Report("Objednávka", "order", true, true)),
|
||||
new ReportMapping(MOD_REQUIREMENTS, new Report("Požadavky", "requirements"))
|
||||
new ReportMapping(MOD_ADDRESSBOOK, new Report(1, false, "Adresní karty", "address")),
|
||||
new ReportMapping(MOD_ADDRESSBOOK, new Report(2, false, "Adresa", "address", false, true)),
|
||||
new ReportMapping(MOD_TRIPBILL, new Report(7, true, "Žádost o SC", "tripRequirementApp", false, true, "requirement")),
|
||||
new ReportMapping(MOD_TRIPBILL, new Report(4, true, "Vyúčtování", "tripBill", false, true, true)),
|
||||
new ReportMapping(MOD_ORDER, new Report(5, false, "Objednávka", "order", true, true)),
|
||||
new ReportMapping(MOD_REQUIREMENTS, new Report(6, false, "Požadavky", "requirements")),
|
||||
new ReportMapping(MOD_TRIPREQUIREMENTS, new Report(7, true, "Žádost o SC", "tripRequirementApp", false, true)),
|
||||
new ReportMapping(MOD_REQUIREMENTS, new Report(8, true, "Protokol o kontrole", "orderRequirement", false, true)),
|
||||
new ReportMapping(MOD_INVOICING, new Report(9, false, "Přehled o protokolech předběžné kontroly", "requirementProtocol")),
|
||||
new ReportMapping(MOD_TRIPREQUIREMENTS, new Report(10, true, "Přehled o protokolech předběžné kontroly", "tripRequirementProtocol"))
|
||||
};
|
||||
|
||||
public final static long TRIB_BILLS_REP_ID = 100;
|
||||
public final static long TRIB_BILLS_NP_REP_ID = 101;
|
||||
|
||||
// pokud je v agnde vic nez jedena podepisovaci sestava, musi se definovat ktera sestava nalezi jake entite
|
||||
public final static Map<Class<?>, Integer> SIGN_REPORT_MAP = Collections.unmodifiableMap(new HashMap<Class<?>, Integer>() {{
|
||||
put(TripBillApproval.class, 4);
|
||||
put(TripRequirement.class, 7);
|
||||
}});
|
||||
|
||||
// vychozi prefixy ciselnych rad. Pokud se prida agenda s vlastni ciselnou radou, je potreba zadefinovat vychozi prefix
|
||||
public final static Map<String, String> NUM_SERIES_PREFIX = Collections.unmodifiableMap(new HashMap<String, String>() {{
|
||||
put(MOD_REQUIREMENTS, "P");
|
||||
put(MOD_ORDER, "O");
|
||||
}});
|
||||
|
||||
public final static String REQTYPE_ORDER = "ORDER";
|
||||
public final static String REQTYPE_BUSINESSTRIP = "BUSINESSTRIP";
|
||||
public final static RequirementType REQTYPES[] = {
|
||||
@@ -141,5 +185,17 @@ public class Constants {
|
||||
public final static Map<Class<?>, String> URL_MAP = Collections.unmodifiableMap(new HashMap<Class<?>, String>() {{
|
||||
put(Requirement.class, "/main/orders/");
|
||||
put(TripRequirement.class, "/main/trips/requirements/");
|
||||
put(TripBillApproval.class, "/main/trips/bill/");
|
||||
put(Order.class, "/main/orders/created/");
|
||||
put(TripBill.class, "/main/trips/bill/");
|
||||
}} );
|
||||
|
||||
public final static int LEN_TEXT = 255;
|
||||
public final static int LEN_DESCRIPTION = 8192;
|
||||
public final static int LEN_RESULT_MESSAGE = 8192;
|
||||
|
||||
public final static String MAIL_URL_KEYWORD = "-url-";
|
||||
|
||||
public final static String KEY_SIGN_DATA = "SIGN_DATA";
|
||||
public final static String KEY_SIGN_GUID = "SIGN_GUID";
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
|
||||
public class DateTimeUtils
|
||||
{
|
||||
public static Date getDate(Date value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
public class DateTimeUtils {
|
||||
public static Date getDate(Date value) {
|
||||
if (value == null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -18,10 +17,18 @@ public class DateTimeUtils
|
||||
return DateUtils.truncate(value, Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
public static boolean isEqualByDate(Date d1, Date d2)
|
||||
{
|
||||
if (d1 != null && d2 != null)
|
||||
{
|
||||
public static int getYear(Date value) {
|
||||
if (value == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Calendar cal =Calendar.getInstance();
|
||||
cal.setTime(value);
|
||||
return cal.get(Calendar.YEAR);
|
||||
}
|
||||
|
||||
public static boolean isEqualByDate(Date d1, Date d2) {
|
||||
if (d1 != null && d2 != null) {
|
||||
d1 = DateTimeUtils.getDate(d1);
|
||||
d2 = DateTimeUtils.getDate(d2);
|
||||
boolean equals = (d1.compareTo(d2) == 0);
|
||||
@@ -31,27 +38,98 @@ public class DateTimeUtils
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEqualByDateForFilter(Date value, Date search)
|
||||
{
|
||||
if (search == null)
|
||||
{
|
||||
return true;
|
||||
public static boolean isEqualByYear(Date d1, Date d2) {
|
||||
if (d1 != null && d2 != null) {
|
||||
int year1 = DateTimeUtils.getYear(d1);
|
||||
int year2 = DateTimeUtils.getYear(d2);
|
||||
boolean equals = (year1 == year2);
|
||||
return equals;
|
||||
}
|
||||
else if (value != null)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
public static boolean isEqualByDateForFilter(Date value, Date search) {
|
||||
if (search == null) {
|
||||
return true;
|
||||
} else if (value != null) {
|
||||
return DateTimeUtils.isEqualByDate(value, search);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Date getCurrDateTime()
|
||||
{
|
||||
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()
|
||||
{
|
||||
public static Date getCurrDate() {
|
||||
return DateTimeUtils.getDate(DateTimeUtils.getCurrDateTime());
|
||||
}
|
||||
|
||||
public static Calendar getCalendarDelta(Date value, int calendarType, int delta) {
|
||||
if (value == null) {
|
||||
value = DateTimeUtils.getCurrDate();
|
||||
}
|
||||
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(value);
|
||||
int deltaValue = calendar.get(calendarType);
|
||||
calendar.set(calendarType, deltaValue + delta);
|
||||
return calendar;
|
||||
}
|
||||
|
||||
public static Calendar getCalendar(Date value) {
|
||||
if (value == null) {
|
||||
value = DateTimeUtils.getCurrDate();
|
||||
}
|
||||
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(value);
|
||||
return calendar;
|
||||
}
|
||||
|
||||
public static Date getDateDelta(Date value, int calendarType, int delta) {
|
||||
Calendar calendar = DateTimeUtils.getCalendarDelta(value, calendarType, delta);
|
||||
return calendar.getTime();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,26 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import info.bukova.isspst.reporting.Report;
|
||||
import info.bukova.isspst.services.AbstractService;
|
||||
import info.bukova.isspst.services.ModuleNotActiveException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*
|
||||
* Třída reprezentuje informace o modulu (agendě).
|
||||
*
|
||||
*/
|
||||
public class Module {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private Class<?> serviceClass;
|
||||
private List<Report> reports;
|
||||
private boolean defaultPermissions;
|
||||
private boolean active;
|
||||
|
||||
public Class<?> getServiceClass() {
|
||||
return serviceClass;
|
||||
@@ -20,11 +30,42 @@ public class Module {
|
||||
this.serviceClass = serviceClass;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id identifikátor modulu
|
||||
* @param name jméno zobrazované v aplikaci
|
||||
* @param serviceClass servisní třída
|
||||
*/
|
||||
public Module(String id, String name, Class<?> serviceClass) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.serviceClass = serviceClass;
|
||||
reports = new ArrayList<Report>();
|
||||
defaultPermissions = true;
|
||||
active = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id identifikátor modulu
|
||||
* @param name jméno zobrazované v aplikaci
|
||||
* @param serviceClass servisní třída
|
||||
* @param active příznak, jestli je modul aktivní
|
||||
*/
|
||||
public Module(String id, String name, Class<?> serviceClass, boolean active) {
|
||||
this(id, name, serviceClass);
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id identifikátor modulu
|
||||
* @param name jméno zobrazované v aplikaci
|
||||
* @param serviceClass servisní třída
|
||||
* @param active příznak, jestli je modul aktivní.
|
||||
* @param defaultPermissions příznak určující jestli modul kontroluje výchozí práva (čtení, zápis, modifikace, mazání)
|
||||
*/
|
||||
public Module(String id, String name, Class<?> serviceClass, boolean active, boolean defaultPermissions) {
|
||||
this(id, name, serviceClass, active);
|
||||
this.defaultPermissions = defaultPermissions;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
@@ -51,4 +92,33 @@ public class Module {
|
||||
this.reports.add(report);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pokud je true, modul kontroluje výchozí práva (čtení, zápis, modifikace, mazání). Má vliv
|
||||
* na generování formulářů v nastavení práv.
|
||||
*
|
||||
* @return výchozí práva. Default true
|
||||
*/
|
||||
public boolean isDefaultPermissions() {
|
||||
return defaultPermissions;
|
||||
}
|
||||
|
||||
public void setDefaultPermissions(boolean defaultPermissions) {
|
||||
this.defaultPermissions = defaultPermissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Určuje, zda je modul aktivní. Neaktivní moduly nejsou viditelné v UI. Při pokusu o přístup přímo přes URL
|
||||
* se generuje výjimka {@link ModuleNotActiveException}. Pokud servisní třída modulu nedědí z {@link AbstractService},
|
||||
* musí se implementovat kontrola aktivity do příslušné třídy.
|
||||
*
|
||||
* @return aktivita. Default true
|
||||
*/
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import info.bukova.isspst.data.DataModel;
|
||||
import info.bukova.isspst.services.Service;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ModuleUtils {
|
||||
|
||||
public static List<Module> getActiveModules() {
|
||||
List<Module> modules = new ArrayList<Module>();
|
||||
|
||||
for (Module m : Arrays.asList(Constants.MODULES)) {
|
||||
if (m.isActive()) {
|
||||
modules.add(m);
|
||||
}
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
||||
public static Module getModule(Class<?> serviceClass) {
|
||||
for (Module m : Constants.MODULES) {
|
||||
if (Arrays.asList(serviceClass.getInterfaces()).contains(m.getServiceClass())) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Module getModule(String id) {
|
||||
for (Module m : Constants.MODULES) {
|
||||
if (m.getId().equals(id)) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Module getModule(DataModel entity, ServletContext sc) {
|
||||
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
|
||||
for (Module m : Constants.MODULES) {
|
||||
Service<?> service;
|
||||
|
||||
try {
|
||||
service = (Service<?>) ctx.getBean(m.getServiceClass());
|
||||
} catch (NoSuchBeanDefinitionException e) {
|
||||
String[] beans = ctx.getBeanNamesForType(m.getServiceClass());
|
||||
|
||||
for (String s : beans) {
|
||||
service = (Service<?>) ctx.getBean(s);
|
||||
|
||||
if (service.getEntityClasses().contains(entity.getClass())) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
} catch (ClassCastException e) { //nestandardní moduly neřeší...
|
||||
continue;
|
||||
}
|
||||
|
||||
if (service.getEntityClasses().contains(entity.getClass())) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Service<?> getServiceInstance(Module m, ServletContext sc) {
|
||||
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
|
||||
|
||||
try {
|
||||
return (Service<?>) ctx.getBean(m.getServiceClass());
|
||||
} catch (NoSuchBeanDefinitionException e) {
|
||||
String[] beans = ctx.getBeanNamesForType(m.getServiceClass());
|
||||
return (Service<?>) ctx.getBean(beans[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isActive(String id) {
|
||||
return getModule(id).isActive();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class RegExUtils {
|
||||
public static List<String> getMatches(String input, String regEx, int group) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(input) && !StringUtils.isNullOrEmpty(regEx)) {
|
||||
Pattern pattern = Pattern.compile(regEx);
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
int groupCount = matcher.groupCount() + 1;
|
||||
|
||||
if ((groupCount >= 0) && (group < groupCount)) {
|
||||
while (matcher.find()) {
|
||||
String item = matcher.group(group);
|
||||
list.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<String> getMatches(String input, String regEx) {
|
||||
return RegExUtils.getMatches(input, regEx, 0);
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,10 @@ public class RequirementUrlResolver implements EntityUrlResolver {
|
||||
|
||||
Requirement req = (Requirement)entity;
|
||||
|
||||
if (req.getKind() == Constants.REQ_TYPE_MATERIAL) {
|
||||
return defaultUrl + Constants.URL_MAP.get(req) + "material/?select=" + String.valueOf(req.getId());
|
||||
if (req.getKind() != null && req.getKind() == Constants.REQ_TYPE_MATERIAL) {
|
||||
return defaultUrl + Constants.URL_MAP.get(req.getClass()) + "material/?select=" + String.valueOf(req.getId());
|
||||
} else {
|
||||
return defaultUrl + Constants.URL_MAP.get(req) + "services/?select=" + String.valueOf(req.getId());
|
||||