Compare commits

..

1 Commits

@ -1,79 +0,0 @@
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>
<id>fdvsolution.public</id>
<name>Dynamic Jasper</name>
<url>http://nexus.fdvs.com.ar/content/groups/public/</url>
<url>http://archiva.fdvs.com.ar/repository/public1/</url>
</repository>
</repositories>
@ -202,6 +202,12 @@
</dependency>
<!-- DB -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
@ -224,16 +230,7 @@
<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>
@ -354,19 +351,6 @@
<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>
@ -412,23 +396,6 @@
</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,39 +6,33 @@ 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;
@ -46,8 +40,6 @@ 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) {
@ -56,11 +48,10 @@ public class AppInitListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent evt) {
Logger logger = LoggerFactory.getLogger(AppInitListener.class);
/*Logger logger = LoggerFactory.getLogger(AppInitListener.class);
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);
@ -68,11 +59,8 @@ 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();
@ -81,31 +69,9 @@ 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();
}
loadModuleReports();*/
}
private void checkMUnits()
@ -234,9 +200,6 @@ 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());
@ -292,40 +255,28 @@ 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) {
private void checkNumberSeries()
{
NumberSeries ns = nsService.getNumberSerie(Constants.MOD_REQUIREMENTS);
if (ns == null)
{
ns = new NumberSeries();
ns.setModule(modId);
ns.setPrefix(Constants.NUM_SERIES_PREFIX.get(modId));
ns.setModule(Constants.MOD_REQUIREMENTS);
ns.setPrefix("");
ns.setNumber(1);
ns.setSeason(season);
nsService.add(ns);
}
}
}
private void checkNumberSeries()
{
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);
}
ns = nsService.getNumberSerie(Constants.MOD_ORDER);
for (Season s : seasonService.getAllSeasons()) {
checkNumberSeriesForSeason(s);
if (ns == null)
{
ns = new NumberSeries();
ns.setModule(Constants.MOD_ORDER);
ns.setPrefix("");
ns.setNumber(1);
nsService.add(ns);
}
}

@ -4,7 +4,6 @@ import java.math.BigDecimal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.commons.lang.StringUtils.strip;
public class BigDecimalUtils
{
@ -24,17 +23,6 @@ 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,48 +0,0 @@
package info.bukova.isspst;
import org.jfree.util.Log;
public class BooleanUtils
{
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());
}
}

@ -0,0 +1,78 @@
package info.bukova.isspst;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.hibernate.HibernateException;
import org.hibernate.service.UnknownUnwrapTypeException;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider;
public class ClientConnectionPrivider implements MultiTenantConnectionProvider {
/**
*
*/
private static final long serialVersionUID = 2142963179208004018L;
private DataSource dataSource;
public ClientConnectionPrivider(DataSource dataSource) {
this.dataSource = dataSource;
}
@SuppressWarnings("rawtypes")
@Override
public boolean isUnwrappableAs(Class unwrapType) {
return ConnectionProvider.class.equals( unwrapType ) || MultiTenantConnectionProvider.class.equals( unwrapType ) || ClientConnectionPrivider.class.isAssignableFrom( unwrapType );
}
@SuppressWarnings("unchecked")
@Override
public <T> T unwrap(Class<T> unwrapType) {
if ( isUnwrappableAs( unwrapType ) ) {
return (T) this;
}
else {
throw new UnknownUnwrapTypeException( unwrapType );
}
}
@Override
public Connection getAnyConnection() throws SQLException {
return dataSource.getConnection();
}
@Override
public void releaseAnyConnection(Connection connection) throws SQLException {
connection.close();
}
@Override
public Connection getConnection(String tenantIdentifier)
throws SQLException {
Connection con = getAnyConnection();
try {
con.createStatement().execute("SET schema '" + tenantIdentifier + "'");
} catch ( SQLException e ) {
throw new HibernateException("Could not alter JDBC connection to specified schema [" + tenantIdentifier + "]", e);
}
return con;
}
@Override
public void releaseConnection(String tenantIdentifier, Connection connection)
throws SQLException {
releaseAnyConnection(connection);
}
@Override
public boolean supportsAggressiveRelease() {
return false;
}
}

@ -0,0 +1,35 @@
package info.bukova.isspst;
import javax.servlet.http.HttpServletRequest;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.springframework.beans.factory.annotation.Autowired;
public class ClientResolver implements CurrentTenantIdentifierResolver {
@Autowired
private HttpServletRequest request;
private static final String TOP_DOMAIN = "localhost"; // Bude se tahat z konfigurace...
@Override
public String resolveCurrentTenantIdentifier() {
String hostName = request.getServerName();
String tenant = "";
if (hostName.contains(".")) {
tenant = hostName.substring(0, hostName.indexOf("." + TOP_DOMAIN));
}
if (tenant.isEmpty()) {
tenant = "public";
}
return tenant;
}
@Override
public boolean validateExistingCurrentSessions() {
return false;
}
}

@ -1,39 +0,0 @@
package info.bukova.isspst;
import info.bukova.isspst.data.DataModel;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
public class CommonUrlResolver implements EntityUrlResolver {
@Autowired
private HttpServletRequest request;
protected String defaultUrl;
public CommonUrlResolver() {
}
@Override
public String entityUrl(Object entity) {
if (defaultUrl == null) {
this.defaultUrl = request.getRequestURL().toString();
this.defaultUrl = defaultUrl.substring(0, defaultUrl.indexOf(request.getServletPath()));
}
if (!DataModel.class.isAssignableFrom(entity.getClass())) {
return defaultUrl + "/app";
}
String url = Constants.URL_MAP.get(entity.getClass());
if (url == null) {
return defaultUrl + "/app";
}
return defaultUrl + url + "?select=" + String.valueOf(((DataModel)entity).getId());
}
}

@ -1,43 +1,28 @@
package info.bukova.isspst;
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.approved.ApprovedService;
import info.bukova.isspst.services.approved.OrderService;
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;
import info.bukova.isspst.services.reqsubjects.MaterialService;
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 = 7;
public final static String DEF_ADMIN = "admin";
public final static String DEF_ADMIN_PASSWD = "admin";
public final static String ROLE_USER = "ROLE_USER";
@ -86,10 +71,6 @@ public class Constants {
public final static String MOD_TRIPBILL = "TRIPBILL";
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),
@ -104,12 +85,7 @@ public class Constants {
new Module(MOD_WORKFLOW, "Procesy schválení", RequirementTypeService.class),
new Module(MOD_TRIPBILL, "Cestovní příkazy", TripBillService.class),
new Module(MOD_APPROVED, "Schválené položky požadavků", ApprovedService.class),
new Module(MOD_ORDER, "Objednávky", OrderService.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),
};
new Module(MOD_ORDER, "Objednávky", OrderService.class) };
public final static String PERM_APPROVE = "PERM_APPROVE";
public final static String PERM_SHOW_WORKGROUP_REQ = "PERM_SHOW_WORKGROUP_REQ";
@ -117,60 +93,30 @@ 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(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"))
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))
};
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[] = {
@ -180,22 +126,4 @@ public class Constants {
public final static long REQ_TYPE_MATERIAL = 1;
public final static long REQ_TYPE_SERVICES = 2;
@SuppressWarnings("serial")
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,15 +1,16 @@
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;
}
@ -17,18 +18,10 @@ public class DateTimeUtils {
return DateUtils.truncate(value, Calendar.DAY_OF_MONTH);
}
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) {
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);
@ -38,98 +31,27 @@ public class DateTimeUtils {
return false;
}
public static boolean isEqualByYear(Date d1, Date d2) {
if (d1 != null && d2 != null) {
int year1 = DateTimeUtils.getYear(d1);
int year2 = DateTimeUtils.getYear(d2);
boolean equals = (year1 == year2);
return equals;
}
return false;
}
public static boolean isEqualByDateForFilter(Date value, Date search) {
if (search == null) {
public static boolean isEqualByDateForFilter(Date value, Date search)
{
if (search == null)
{
return true;
} else if (value != null) {
}
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() {
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,7 +0,0 @@
package info.bukova.isspst;
public interface EntityUrlResolver {
public String entityUrl(Object entity);
}

@ -1,26 +1,16 @@
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;
@ -30,42 +20,11 @@ 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() {
@ -92,33 +51,4 @@ 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;
}
}

@ -1,94 +0,0 @@
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();
}
}

@ -1,31 +0,0 @@
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);
}
}

@ -1,39 +0,0 @@
package info.bukova.isspst;
import info.bukova.isspst.data.Requirement;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
public class RequirementUrlResolver implements EntityUrlResolver {
private String defaultUrl;
@Autowired
private HttpServletRequest request;
public RequirementUrlResolver() {
}
@Override
public String entityUrl(Object entity) {
if (!(entity instanceof Requirement)) {
return defaultUrl + "/app";
}
if (defaultUrl == null) {
this.defaultUrl = request.getRequestURL().toString();
this.defaultUrl = defaultUrl.substring(0, defaultUrl.indexOf(request.getServletPath()));
}
Requirement req = (Requirement)entity;
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.getClass()) + "services/?select=" + String.valueOf(req.getId());
}
}
}

@ -5,7 +5,6 @@ import info.bukova.isspst.data.User;
import info.bukova.isspst.data.Workgroup;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -14,19 +13,16 @@ public class SessionData implements Serializable {
/**
*
*/
private static final long serialVersionUID = -764426911263559759L;
private static final long serialVersionUID = -764426911263559758L;
private List<Workgroup> userCentres;
private List<Workgroup> userOnlyCentres;
private List<Workgroup> userWorkgroups;
private User currentUser;
private Map<Integer, List<Role>> workgroupRoles;
private boolean loginFailed;
private Map<String, Object> properties;
public SessionData() {
loginFailed = false;
properties = new HashMap<String, Object>();
}
public List<Workgroup> getUserCentres() {
@ -69,19 +65,4 @@ public class SessionData implements Serializable {
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;
}
}

@ -1,25 +0,0 @@
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);
}
}

@ -1,28 +1,18 @@
package info.bukova.isspst;
import java.util.ArrayList;
import java.util.List;
import org.zkoss.util.resource.Labels;
public class StringUtils
{
public static boolean isNullOrEmpty(String str)
{
return ((str == null) || (str.isEmpty()));
}
public static boolean isNullOrTrimmedEmpty(String str)
{
return ((str == null) || (str.trim().isEmpty()));
}
public static String nullToEmptyString(String str)
private static String nullStr(String str)
{
return str == null ? "" : str;
}
private static String zeroToEmptyString(long i)
private static String not0ToStr(long i)
{
return i == 0 ? "" : String.valueOf(i);
}
@ -70,8 +60,8 @@ public class StringUtils
public static boolean isEqualForFilter(String value, String search)
{
value = StringUtils.nullToEmptyString(value).toLowerCase();
search = StringUtils.nullToEmptyString(search).toLowerCase();
value = StringUtils.nullStr(value).toLowerCase();
search = StringUtils.nullStr(search).toLowerCase();
if (search.isEmpty())
{
@ -83,8 +73,8 @@ public class StringUtils
public static boolean isIcEqualForFilter(long value, long search)
{
String compareValue = StringUtils.zeroToEmptyString(value);
String searchValue = StringUtils.zeroToEmptyString(search);
String compareValue = StringUtils.not0ToStr(value);
String searchValue = StringUtils.not0ToStr(search);
return compareValue.startsWith(searchValue);
}
@ -134,7 +124,7 @@ public class StringUtils
for (int i = 0; i < list.size(); i++)
{
String item = StringUtils.nullToEmptyString(list.get(i));
String item = StringUtils.nullStr(list.get(i));
result = StringUtils.addSeparator(result, separator);
result += item;
}
@ -148,7 +138,7 @@ public class StringUtils
for (int i = 0; i < list.size(); i++)
{
String item = StringUtils.nullToEmptyString(list.get(i));
String item = StringUtils.nullStr(list.get(i));
if (!item.isEmpty())
{
@ -159,47 +149,4 @@ public class StringUtils
return result;
}
public static List<String> split(String value, String separator)
{
String tmp = value;
List<String> list = new ArrayList<String>();
if (tmp != null)
{
if ((separator == null) || separator.isEmpty() || tmp.isEmpty())
{
list.add(tmp);
}
else
{
int separatorLength = separator.length();
while (!tmp.isEmpty())
{
String part = "";
int idx = tmp.indexOf(separator);
if (idx > -1)
{
part = tmp.substring(0, idx);
list.add(part);
tmp = tmp.substring(idx + separatorLength);
if (tmp.isEmpty())
{
list.add("");
}
}
else
{
list.add(tmp);
tmp = "";
}
}
}
}
return list;
}
}

@ -1,29 +0,0 @@
package info.bukova.isspst;
import info.bukova.isspst.data.TripBillApproval;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
/**
* @author Pepa Rokos
*/
public class TripBillAprovalUrlResolver implements EntityUrlResolver {
@Autowired
private HttpServletRequest request;
@Override
public String entityUrl(Object entity) {
String defUrl = request.getRequestURL().toString();
defUrl = defUrl.substring(0, defUrl.indexOf(request.getServletPath()));
if (entity instanceof TripBillApproval) {
String url = Constants.URL_MAP.get(entity.getClass());
return defUrl + url + "?select=" + String.valueOf(((TripBillApproval)entity).getId());
}
return defUrl + "/app";
}
}

@ -1,30 +0,0 @@
package info.bukova.isspst;
import java.util.HashMap;
import java.util.Map;
public class UrlResolverHolder {
private EntityUrlResolver commonResolver;
private Map<Class<?>, EntityUrlResolver> resolvers;
public UrlResolverHolder(EntityUrlResolver common) {
this.commonResolver = common;
resolvers = new HashMap<Class<?>, EntityUrlResolver>();
}
public void setResolvers(Map<Class<?>, EntityUrlResolver> resolvers) {
this.resolvers = resolvers;
}
public EntityUrlResolver resolverFor(Class<?> clazz) {
EntityUrlResolver res = resolvers.get(clazz);
if (res == null) {
return commonResolver;
}
return res;
}
}

@ -1,7 +0,0 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.DbInfo;
public interface DbInfoDao extends BaseDao<DbInfo>
{
}

@ -1,7 +0,0 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.Invoicing;
public interface InvoicingDao extends BaseDao<Invoicing> {
}

@ -1,10 +0,0 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.Limit;
/**
* @author Pepa Rokos
*/
public interface LimitDao extends BaseDao<Limit> {
}

@ -1,8 +0,0 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.RequirementItem;
public interface RequirementItemDao extends BaseDao<RequirementItem>
{
}

@ -1,10 +0,0 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.Season;
/**
* @author Pepa Rokos
*/
public interface SeasonDao extends BaseDao<Season> {
}

@ -1,7 +0,0 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.SignedDocument;
public interface SignedDocumentDao extends BaseDao<SignedDocument> {
}

@ -1,9 +0,0 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.TripBillApproval;
/**
* @author Pepa Rokos
*/
public interface TripBillApprovalDao extends BaseDao<TripBillApproval> {
}

@ -1,9 +0,0 @@
package info.bukova.isspst.dao.jpa;
import info.bukova.isspst.dao.DbInfoDao;
import info.bukova.isspst.data.DbInfo;
public class DbInfoDaoJPA extends BaseDaoJPA<DbInfo> implements DbInfoDao
{
}

@ -1,9 +0,0 @@
package info.bukova.isspst.dao.jpa;
import info.bukova.isspst.dao.InvoicingDao;
import info.bukova.isspst.data.Invoicing;
public class InvoicingDaoJPA extends BaseDaoJPA<Invoicing> implements InvoicingDao {
}

@ -1,11 +0,0 @@
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 {
}

@ -1,8 +0,0 @@
package info.bukova.isspst.dao.jpa;
import info.bukova.isspst.dao.RequirementItemDao;
import info.bukova.isspst.data.RequirementItem;
public class RequirementItemDaoJPA extends BaseDaoJPA<RequirementItem> implements RequirementItemDao
{
}

@ -1,11 +0,0 @@
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 {
}

@ -1,9 +0,0 @@
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,11 +0,0 @@
package info.bukova.isspst.dao.jpa;
import info.bukova.isspst.dao.TripBillApprovalDao;
import info.bukova.isspst.data.TripBillApproval;
/**
* @author Pepa Rokos
*/
public class TripBillApprovalDaoJPA extends BaseDaoJPA<TripBillApproval> implements TripBillApprovalDao {
}

@ -1,6 +1,5 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import info.bukova.isspst.StringUtils;
import java.util.ArrayList;
@ -46,7 +45,7 @@ public class Address extends BaseData
private String email;
@Column(name = "WEB")
private String web;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Column(name = "DESCRIPTION")
private String description;
@NotNull(message = "Zadejte firmu")

@ -7,18 +7,11 @@ import java.util.List;
import javax.persistence.Embeddable;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
@Embeddable
@Indexed
public class AddressEmb
{
private int id;
@Field(index = Index.YES, analyze = Analyze.YES)
private String company;
private String department;
private String contactName;

@ -1,9 +1,6 @@
package info.bukova.isspst.data;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.FetchType;
@ -13,10 +10,8 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.util.Date;
@MappedSuperclass
@Indexed
public abstract class BaseData implements OwnedDataModel {
@Id
@ -29,13 +24,9 @@ public abstract class BaseData implements OwnedDataModel {
private Date modified;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="OWNED_BY_ID")
@IndexedEmbedded
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private User ownedBy;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="MODIFIED_BY_ID")
@IndexedEmbedded
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private User modifiedBy;
@Transient
private boolean valid;

@ -1,7 +1,5 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import java.util.ArrayList;
import java.util.List;
@ -25,7 +23,7 @@ public class Building extends BaseData implements DataModel {
@Column(name = "NAME")
private String name;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Column(name = "DESCRIPTION")
private String description;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "building", orphanRemoval = true)

@ -1,28 +0,0 @@
package info.bukova.isspst.data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "DBINFO")
public class DbInfo extends BaseSimpleData
{
@Column(name = "VERSION")
private long version;
public DbInfo()
{
this.version = 0;
}
public long getVersion()
{
return version;
}
public void setVersion(long version)
{
this.version = version;
}
}

@ -1,97 +0,0 @@
package info.bukova.isspst.data;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author Pepa Rokos
*/
@Entity
@Table(name = "FILE_CONTENTS")
@Indexed
public class FileContent {
@Id
@Column(name = "ID")
@GeneratedValue
private int id;
@Column(name = "CONTENT")
@Type(type = "text")
@Field(index = Index.YES, analyze = Analyze.YES)
private String plainText;
@Column(name = "CONTENT_TYPE")
private String contentType;
@Column(name = "PATH_IN_FILESYSTEM")
private String pathInFilesystem;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPlainText() {
return plainText;
}
public void setPlainText(String content) {
this.plainText = content;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getPathInFilesystem() {
return pathInFilesystem;
}
public void setPathInFilesystem(String pathInFilesystem) {
this.pathInFilesystem = pathInFilesystem;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof FileContent)) return false;
FileContent that = (FileContent) o;
if (id != that.id) return false;
if (plainText != null ? !plainText.equals(that.plainText) : that.plainText != null) return false;
if (contentType != null ? !contentType.equals(that.contentType) : that.contentType != null) return false;
if (pathInFilesystem != null ? !pathInFilesystem.equals(that.pathInFilesystem) : that.pathInFilesystem != null)
return false;
return true;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + (plainText != null ? plainText.hashCode() : 0);
result = 31 * result + (contentType != null ? contentType.hashCode() : 0);
result = 31 * result + (pathInFilesystem != null ? pathInFilesystem.hashCode() : 0);
return result;
}
}

@ -1,152 +0,0 @@
package info.bukova.isspst.data;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "FILE_METAINFO")
@Indexed
public class FileMetainfo extends BaseData {
@Column(name = "FILE_NAME")
@Field(index = Index.YES, analyze = Analyze.YES)
private String fileName;
@Column(name = "MODULE_ID")
private String moduleId;
@Column(name = "RECORD_ID")
private int recordId;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "CONTENT_ID")
@Cascade(CascadeType.SAVE_UPDATE)
@IndexedEmbedded
private FileContent content;
@Column(name = "MD5")
private String md5;
@Column(name = "DESCRIPTION")
@Field(index = Index.YES, analyze = Analyze.YES)
private String description;
private void ensureContentExists() {
if (content == null) {
content = new FileContent();
}
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getPathInFilesystem() {
if (content != null) {
return content.getPathInFilesystem();
}
return null;
}
public void setPathInFilesystem(String pathInFilesystem) {
ensureContentExists();
content.setPathInFilesystem(pathInFilesystem);
}
public String getModuleId() {
return moduleId;
}
public void setModuleId(String moduleId) {
this.moduleId = moduleId;
}
public int getRecordId() {
return recordId;
}
public void setRecordId(int recordId) {
this.recordId = recordId;
}
public FileContent getContent() {
return content;
}
public void setContent(FileContent content) {
this.content = content;
}
public String getMd5() {
return md5;
}
public void setMd5(String md5) {
this.md5 = md5;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getContentType() {
if (content != null) {
return content.getContentType();
}
return null;
}
public void setContentType(String contentType) {
ensureContentExists();
content.setContentType(contentType);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof FileMetainfo)) return false;
FileMetainfo that = (FileMetainfo) o;
if (recordId != that.recordId) return false;
if (content != null ? !content.equals(that.content) : that.content != null) return false;
if (description != null ? !description.equals(that.description) : that.description != null) return false;
if (fileName != null ? !fileName.equals(that.fileName) : that.fileName != null) return false;
if (md5 != null ? !md5.equals(that.md5) : that.md5 != null) return false;
if (moduleId != null ? !moduleId.equals(that.moduleId) : that.moduleId != null) return false;
return true;
}
@Override
public int hashCode() {
int result = fileName != null ? fileName.hashCode() : 0;
result = 31 * result + (moduleId != null ? moduleId.hashCode() : 0);
result = 31 * result + recordId;
result = 31 * result + (content != null ? content.hashCode() : 0);
result = 31 * result + (md5 != null ? md5.hashCode() : 0);
result = 31 * result + (description != null ? description.hashCode() : 0);
return result;
}
}

@ -1,91 +0,0 @@
package info.bukova.isspst.data;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
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 java.math.BigDecimal;
import java.util.List;
@Entity
@Table(name = "INVOICING")
public class Invoicing extends BaseData implements Cloneable
{
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "REQUIREMENT_ID")
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
private Requirement requirement;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@LazyCollection(LazyCollectionOption.TRUE)
@JoinColumn(name = "INVOICING_ID")
private List<InvoicingItem> items;
@Column(name = "TOTAL_INVOICED", precision = 15, scale = 4)
private BigDecimal totalInvoiced;
@Column(name = "COMPLETED")
private boolean completed;
public Requirement getRequirement() {
return requirement;
}
public void setRequirement(Requirement requirement) {
this.requirement = requirement;
}
public List<InvoicingItem> getItems() {
return items;
}
public void setItems(List<InvoicingItem> items) {
this.items = items;
}
public BigDecimal getTotalInvoiced() {
return totalInvoiced;
}
public void setTotalInvoiced(BigDecimal totalInvoiced) {
this.totalInvoiced = totalInvoiced;
}
public boolean isCompleted()
{
return completed;
}
public void setCompleted(boolean completed)
{
this.completed = completed;
}
public String getInvoiceNumbers() {
String ret = "";
for (InvoicingItem invNum : items) {
if (!ret.isEmpty()) {
ret += ", ";
}
ret += invNum.getInvoiceNumber();
}
return ret;
}
@Override
public Object clone() throws CloneNotSupportedException
{
Invoicing cloned = (Invoicing) super.clone();
return cloned;
}
}

@ -1,87 +0,0 @@
package info.bukova.isspst.data;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "INVOICING_ITEM")
public class InvoicingItem {
@Id
@Column(name = "ID")
@GeneratedValue
private int id;
@Column(name = "INVOICE_DATE")
private Date invoiceDate;
@Column(name = "INVOICE_NUMBER")
private String invoiceNumber;
@Column(name = "AMOUNT", precision = 15, scale = 4)
private BigDecimal amount;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Date getInvoiceDate() {
return invoiceDate;
}
public void setInvoiceDate(Date invoiceDate) {
this.invoiceDate = invoiceDate;
}
public String getInvoiceNumber() {
return invoiceNumber;
}
public void setInvoiceNumber(String invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
@Override
public boolean equals(Object obj)
{
if (obj != null)
{
if (obj instanceof InvoicingItem)
{
InvoicingItem item = (InvoicingItem)obj;
int thisId = this.getId();
int itemId = item.getId();
boolean equalsId = (thisId == itemId);
if (equalsId && (thisId == 0))
{
return super.equals(obj);
}
return equalsId;
}
}
return false;
}
}

@ -1,8 +1,5 @@
package info.bukova.isspst.data;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
@ -14,7 +11,6 @@ import javax.persistence.Table;
@Entity
@Table(name = "JOBMAPPING")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class JobMapping {
@Id
@ -23,11 +19,9 @@ public class JobMapping {
private int id;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "MEMBER_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Member member;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "ROLE_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Role role;
public JobMapping() {

@ -1,7 +1,5 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import java.math.BigDecimal;
import java.util.Date;
@ -222,23 +220,6 @@ public class JoinedItem implements DataModel, FilterableRequirement
this.ownedBy = owner;
}
protected Boolean itemMaterial;
public boolean isItemMaterialReal()
{
return ((this.requirement != null) && (this.requirement.getKind() == Constants.REQ_TYPE_MATERIAL));
}
public Boolean getItemMaterial()
{
return this.itemMaterial;
}
public void setItemMaterial(Boolean value)
{
this.itemMaterial = value;
}
@Override
public boolean equals(Object obj)
{

@ -1,50 +0,0 @@
package info.bukova.isspst.data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.math.BigDecimal;
/**
* @author Pepa Rokos
*/
@Entity
@Table(name = "LIMITS")
public class Limit extends BaseData implements SeasonsAware {
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "WORKGROUP_ID")
private Workgroup workgroup;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
private Season season;
@Column(name = "REQ_LIMIT", precision = 15, scale = 4)
private BigDecimal limit;
public Workgroup getWorkgroup() {
return workgroup;
}
public void setWorkgroup(Workgroup workgroup) {
this.workgroup = workgroup;
}
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
public BigDecimal getLimit() {
return limit;
}
public void setLimit(BigDecimal limit) {
this.limit = limit;
}
}

@ -1,6 +1,5 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import info.bukova.isspst.StringUtils;
import javax.persistence.Column;
@ -14,7 +13,7 @@ public class MUnit extends BaseData
@Column(name = "NAME")
private String name;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Column(name = "DESCRIPTION")
private String description;
public String getName()

@ -1,6 +1,5 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import info.bukova.isspst.StringUtils;
import javax.persistence.Column;
@ -15,14 +14,11 @@ public class MUnitEmb
@Column(name = "MUNIT_NAME")
private String name;
@Column(name = "MUNIT_DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Column(name = "MUNIT_DESCRIPTION")
private String description;
public MUnitEmb()
{
// Embeddable object is loaded by hibernate like NULL, if all properties
// are NULL. So, we set ID.
this.id = 0;
}
public MUnitEmb(MUnit munit)

@ -1,9 +1,8 @@
package info.bukova.isspst.data;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -16,13 +15,12 @@ import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public abstract class Member implements DataModel {
@Id
@ -35,7 +33,6 @@ public abstract class Member implements DataModel {
@ManyToMany
@LazyCollection(LazyCollectionOption.TRUE)
@JoinTable(name="MEMBER_PARENT", joinColumns={@JoinColumn(name="MEMBER_ID")}, inverseJoinColumns={@JoinColumn(name="PARENT_ID")})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<Workgroup> parents;
@Transient
private boolean valid;

@ -2,8 +2,6 @@ package info.bukova.isspst.data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity
@ -19,10 +17,6 @@ public class NumberSeries extends BaseSimpleData
@Column(name = "NUMBER")
private int number;
@OneToOne
@JoinColumn(name = "SEASON_ID")
private Season season;
public String getCurrentNumber()
{
return String.format("%s%06d", this.getPrefix(), this.getNumber());
@ -57,12 +51,4 @@ public class NumberSeries extends BaseSimpleData
{
this.number = number;
}
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
}

@ -1,13 +1,9 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
@ -15,20 +11,15 @@ 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;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
@Entity
@Table(name = "ORDERS")
@Indexed
public class Order extends BaseData implements Cloneable, SeasonsAware
public class Order extends BaseData
{
@Column(name = "NUMSER")
@ -44,7 +35,7 @@ public class Order extends BaseData implements Cloneable, SeasonsAware
@AttributeOverride(name = "company", column = @Column(name = "SUPPLIER_COMPANY")),
@AttributeOverride(name = "contactName", column = @Column(name = "SUPPLIER_CONTACT_NAME")),
@AttributeOverride(name = "department", column = @Column(name = "SUPPLIER_DEPARTMENT")),
@AttributeOverride(name = "description", column = @Column(name = "SUPPLIER_DESCRIPTION", length = Constants.LEN_DESCRIPTION)),
@AttributeOverride(name = "description", column = @Column(name = "SUPPLIER_DESCRIPTION")),
@AttributeOverride(name = "dic", column = @Column(name = "SUPPLIER_DIC")),
@AttributeOverride(name = "email", column = @Column(name = "SUPPLIER_EMAIL")),
@AttributeOverride(name = "houseNumber", column = @Column(name = "SUPPLIER_HOUSENUMBER")),
@ -54,7 +45,6 @@ public class Order extends BaseData implements Cloneable, SeasonsAware
@AttributeOverride(name = "street", column = @Column(name = "SUPPLIER_STREET")),
@AttributeOverride(name = "web", column = @Column(name = "SUPPLIER_WEB")),
@AttributeOverride(name = "zipCode", column = @Column(name = "SUPPLIER_ZIP_CODE")) })
@IndexedEmbedded
private AddressEmb suplier;
@Embedded
@ -64,7 +54,7 @@ public class Order extends BaseData implements Cloneable, SeasonsAware
@AttributeOverride(name = "company", column = @Column(name = "INVOICE_COMPANY")),
@AttributeOverride(name = "contactName", column = @Column(name = "INVOICE_CONTACT_NAME")),
@AttributeOverride(name = "department", column = @Column(name = "INVOICE_DEPARTMENT")),
@AttributeOverride(name = "description", column = @Column(name = "INVOICE_DESCRIPTION", length = Constants.LEN_DESCRIPTION)),
@AttributeOverride(name = "description", column = @Column(name = "INVOICE_DESCRIPTION")),
@AttributeOverride(name = "dic", column = @Column(name = "INVOICE_DIC")),
@AttributeOverride(name = "email", column = @Column(name = "INVOICE_EMAIL")),
@AttributeOverride(name = "houseNumber", column = @Column(name = "INVOICE_HOUSENUMBER")),
@ -83,7 +73,7 @@ public class Order extends BaseData implements Cloneable, SeasonsAware
@AttributeOverride(name = "company", column = @Column(name = "DELIVERY_COMPANY")),
@AttributeOverride(name = "contactName", column = @Column(name = "DELIVERY_CONTACT_NAME")),
@AttributeOverride(name = "department", column = @Column(name = "DELIVERY_DEPARTMENT")),
@AttributeOverride(name = "description", column = @Column(name = "DELIVERY_DESCRIPTION", length = Constants.LEN_DESCRIPTION)),
@AttributeOverride(name = "description", column = @Column(name = "DELIVERY_DESCRIPTION")),
@AttributeOverride(name = "dic", column = @Column(name = "DELIVERY_DIC")),
@AttributeOverride(name = "email", column = @Column(name = "DELIVERY_EMAIL")),
@AttributeOverride(name = "houseNumber", column = @Column(name = "DELIVERY_HOUSENUMBER")),
@ -104,13 +94,11 @@ public class Order extends BaseData implements Cloneable, SeasonsAware
@Column(name = "DELIVERY_TYPE")
private String deliveryType;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Field(index = Index.YES, analyze = Analyze.YES)
@Column(name = "DESCRIPTION")
private String description;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "order", orphanRemoval = true)
@LazyCollection(LazyCollectionOption.TRUE)
@IndexedEmbedded
private List<OrderItem> items;
@Column(name = "TOTAL", precision = 15, scale = 4)
@ -122,14 +110,20 @@ public class Order extends BaseData implements Cloneable, SeasonsAware
@Column(name = "DELIVERED")
private boolean delivered;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
private Season season;
@Column(name = "INVOICED")
private boolean invoiced;
@Column(name = "INVOICE_NUMBER")
private String invoiceNumber;
@Column(name = "INVOICE_TOTAL", precision = 15, scale = 4)
private BigDecimal invoiceTotal;
public Order()
{
this.items = new ArrayList<OrderItem>();
this.total = BigDecimal.ZERO;
this.invoiceTotal = BigDecimal.ZERO;
}
public String getNumser()
@ -238,6 +232,26 @@ public class Order extends BaseData implements Cloneable, SeasonsAware
this.delivered = delivered;
}
public boolean isInvoiced()
{
return invoiced;
}
public void setInvoiced(boolean invoiced)
{
this.invoiced = invoiced;
}
public String getInvoiceNumber()
{
return invoiceNumber;
}
public void setInvoiceNumber(String invoiceNumber)
{
this.invoiceNumber = invoiceNumber;
}
public boolean isOrdered()
{
return ordered;
@ -268,37 +282,14 @@ public class Order extends BaseData implements Cloneable, SeasonsAware
this.total = total;
}
public boolean isIcludedRequirementItemFromAnotherOrder()
public BigDecimal getInvoiceTotal()
{
for (OrderItem oItem : this.getItems())
{
RequirementItem rItem = oItem.getReqItem();
if (rItem != null)
{
String orderNum = rItem.getOrderNum();
boolean isIncluded = ((orderNum != null) && !orderNum.isEmpty());
boolean isFromAnotherOrder = (isIncluded && !this.numser.equals(orderNum));
return isFromAnotherOrder;
}
return invoiceTotal;
}
return false;
}
@Override
public Object clone() throws CloneNotSupportedException
public void setInvoiceTotal(BigDecimal invoiceTotal)
{
Order cloned = (Order) super.clone();
cloned.setTotal(new BigDecimal(this.getTotal().toString()));
return cloned;
}
public Season getSeason() {
return season;
this.invoiceTotal = invoiceTotal;
}
public void setSeason(Season season) {
this.season = season;
}
}

@ -1,7 +1,5 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import java.math.BigDecimal;
import javax.persistence.Column;
@ -14,16 +12,9 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
@Entity
@Table(name = "ORDER_ITEM")
@Indexed
public class OrderItem
{
public class OrderItem {
@Id
@Column(name="ID")
@ -34,11 +25,9 @@ public class OrderItem
private String code;
@Column(name = "NAME")
@Field(index = Index.YES, analyze = Analyze.YES)
private String name;
@Column(name = "TEXTITEM")
@Field(index = Index.YES, analyze = Analyze.YES)
private String textItem;
@Column(name = "QUANTITY", precision=15, scale=4)
@ -53,8 +42,7 @@ public class OrderItem
@Column(name = "TOTAL", precision=15, scale=4)
private BigDecimal total;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Field(index = Index.YES, analyze = Analyze.YES)
@Column(name = "DESCRIPTION")
private String description;
@ManyToOne(fetch = FetchType.EAGER)
@ -65,13 +53,11 @@ public class OrderItem
@JoinColumn(name = "ORDER_ID")
private Order order;
public OrderItem()
{
public OrderItem() {
super();
}
public OrderItem(RequirementItem reqItem)
{
public OrderItem(RequirementItem reqItem) {
super();
this.reqItem = reqItem;
this.code = reqItem.getCode();
@ -84,113 +70,91 @@ public class OrderItem
this.description = reqItem.getDescription();
}
public int getId()
{
public int getId() {
return id;
}
public void setId(int id)
{
public void setId(int id) {
this.id = id;
}
public String getCode()
{
public String getCode() {
return code;
}
public void setCode(String code)
{
public void setCode(String code) {
this.code = code;
}
public String getName()
{
public String getName() {
return name;
}
public void setName(String name)
{
public void setName(String name) {
this.name = name;
}
public String getTextItem()
{
public String getTextItem() {
return textItem;
}
public void setTextItem(String textItem)
{
public void setTextItem(String textItem) {
this.textItem = textItem;
}
public BigDecimal getQuantity()
{
public BigDecimal getQuantity() {
return quantity;
}
public void setQuantity(BigDecimal quantity)
{
public void setQuantity(BigDecimal quantity) {
this.quantity = quantity;
}
public MUnitEmb getMunit()
{
public MUnitEmb getMunit() {
return munit;
}
public void setMunit(MUnitEmb munit)
{
public void setMunit(MUnitEmb munit) {
this.munit = munit;
}
public BigDecimal getUnitPrice()
{
public BigDecimal getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(BigDecimal unitPrice)
{
public void setUnitPrice(BigDecimal unitPrice) {
this.unitPrice = unitPrice;
}
public BigDecimal getTotal()
{
public BigDecimal getTotal() {
return total;
}
public void setTotal(BigDecimal total)
{
public void setTotal(BigDecimal total) {
this.total = total;
}
public String getDescription()
{
public String getDescription() {
return description;
}
public void setDescription(String description)
{
public void setDescription(String description) {
this.description = description;
}
public RequirementItem getReqItem()
{
public RequirementItem getReqItem() {
return reqItem;
}
public void setReqItem(RequirementItem reqItem)
{
public void setReqItem(RequirementItem reqItem) {
this.reqItem = reqItem;
}
public Order getOrder()
{
public Order getOrder() {
return order;
}
public void setOrder(Order order)
{
public void setOrder(Order order) {
this.order = order;
}

@ -1,19 +1,15 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.security.core.GrantedAuthority;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;
import org.springframework.security.core.GrantedAuthority;
@Entity
@Table(name="PERMISSION")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Permission extends BaseSimpleData implements GrantedAuthority {
/**
@ -23,7 +19,7 @@ public class Permission extends BaseSimpleData implements GrantedAuthority {
@Column(name="AUTHORITY")
private String authority;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Column(name="DESCRIPTION")
private String description;
@Column(name="MODULE")
private String module;

@ -1,7 +1,9 @@
package info.bukova.isspst.data;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@ -9,18 +11,12 @@ import javax.persistence.Entity;
import javax.persistence.FetchType;
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
@Table(name = "REQUIREMENT")
@Indexed
public class Requirement extends RequirementBase
{
@OneToMany(fetch = FetchType.LAZY, mappedBy = "requirement", cascade = CascadeType.ALL, orphanRemoval = true)
@IndexedEmbedded
@OneToMany(fetch = FetchType.EAGER, mappedBy = "requirement", cascade = CascadeType.ALL, orphanRemoval = true)
private List<RequirementItem> items;
@Column(name = "DELIVERYDATE")
@ -32,9 +28,6 @@ public class Requirement extends RequirementBase
@Column(name = "KIND")
private Long kind;
@Column(name = "PROJECT")
private Boolean project;
public Requirement()
{
this.setItems(new ArrayList<RequirementItem>());
@ -85,39 +78,4 @@ public class Requirement extends RequirementBase
{
this.kind = kind;
}
public Boolean getProject()
{
return project;
}
public void setProject(Boolean project)
{
this.project = project;
}
@Override
public boolean equals(Object obj)
{
if (obj != null)
{
if (obj instanceof Requirement)
{
Requirement item = (Requirement) obj;
int thisId = this.getId();
int itemId = item.getId();
boolean equalsId = (thisId == itemId);
if (equalsId && (thisId == 0))
{
return super.equals(obj);
}
return equalsId;
}
}
return false;
}
}

@ -1,14 +1,8 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@ -20,14 +14,12 @@ import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
@MappedSuperclass
@Indexed
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class RequirementBase extends BaseData implements FilterableRequirement, SeasonsAware {
public class RequirementBase extends BaseData implements FilterableRequirement {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TYPE_ID")
@ -37,20 +29,16 @@ public class RequirementBase extends BaseData implements FilterableRequirement,
@OrderBy("CENTRE, WORDER")
private List<Workflow> workflow;
@Column(name = "NUMSER", unique = true)
@Field(index = Index.YES, analyze = Analyze.YES)
private String numser;
@Column(name = "REQ_DATE")
private Date reqDate;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Field(index = Index.YES, analyze = Analyze.YES)
@Column(name = "DESCRIPTION")
private String description;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "CENTRE_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Workgroup centre;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "WORKGROUP_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Workgroup workgroup;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@LazyCollection(LazyCollectionOption.TRUE)
@ -59,12 +47,6 @@ public class RequirementBase extends BaseData implements FilterableRequirement,
@Column(name = "STATE")
@Enumerated(EnumType.ORDINAL)
private RequirementState state;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Season season;
@Column(name = "APPROVE_DATE")
private Date approveDate;
public RequirementBase() {
authorization = new ArrayList<AuthItem>();
@ -145,35 +127,4 @@ public class RequirementBase extends BaseData implements FilterableRequirement,
this.workflow = workflow;
}
public User getLastApprover() {
if (authorization.isEmpty()) {
return null;
}
return authorization.get(authorization.size() - 1).getApprover();
}
public Date getLastApproveDate() {
if (authorization.isEmpty()) {
return null;
}
return authorization.get(authorization.size() - 1).getAuthDate();
}
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
public Date getApproveDate() {
return approveDate;
}
public void setApproveDate(Date approveDate) {
this.approveDate = approveDate;
}
}

@ -1,7 +1,5 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import java.math.BigDecimal;
import javax.persistence.Column;
@ -14,15 +12,8 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
@Entity
@Table(name = "REQUIREMENT_ITEMS")
@Indexed
public class RequirementItem
{
@Id
@ -42,11 +33,9 @@ public class RequirementItem
private String code;
@Column(name = "NAME")
@Field(index = Index.YES, analyze = Analyze.YES)
private String name;
@Column(name = "TEXTITEM")
@Field(index = Index.YES, analyze = Analyze.YES)
private String textItem;
@Column(name = "QUANTITY", precision=15, scale=4)
@ -61,19 +50,12 @@ public class RequirementItem
@Column(name = "TOTAL", precision=15, scale=4)
private BigDecimal total;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Field(index = Index.YES, analyze = Analyze.YES)
@Column(name = "DESCRIPTION")
private String description;
@Column(name = "DELIVERED")
private Boolean delivered;
@Column(name = "ORDERNUM")
private String orderNum;
@Column(name = "PAID")
private Boolean paid;
public int getId()
{
return id;
@ -181,22 +163,7 @@ public class RequirementItem
{
RequirementItem item = (RequirementItem)obj;
int thisId = this.getId();
int itemId = item.getId();
boolean equalsId = (thisId == itemId);
if (equalsId && (thisId == 0))
{
// Při zadávání položek do gridu zatím nové položky nemají
// přiřazeno ID, takže se rozlišují podle reference
// Při hledání položky v seznamu nebo zjišťování indexu pak
// byly veškeré položky s ID = 0 a grid nevybíral aktivní
// položku správně, stejně tak nepřekresloval ani scrollbar
// a pod.
return super.equals(obj);
}
return equalsId;
return (this.getId() == item.getId());
}
}
@ -220,22 +187,4 @@ public class RequirementItem
public void setDelivered(Boolean delivered) {
this.delivered = delivered;
}
public String getOrderNum()
{
return orderNum;
}
public void setOrderNum(String orderNum)
{
this.orderNum = orderNum;
}
public Boolean getPaid() {
return paid;
}
public void setPaid(Boolean paid) {
this.paid = paid;
}
}

@ -1,7 +1,5 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import java.util.Date;
import javax.persistence.Column;
@ -44,9 +42,10 @@ public abstract class RequirementSubject implements OwnedDataModel {
private String code;
@Column(name = "NAME")
private String name;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Column(name = "DESCRIPTION")
private String description;
@NotEmpty(message = "{MaterialFormCodeConstr}")
public String getCode() {
return code;
@ -141,16 +140,7 @@ public abstract class RequirementSubject implements OwnedDataModel {
{
RequirementSubject item = (RequirementSubject) obj;
int thisId = this.getId();
int itemId = item.getId();
boolean equalsId = (thisId == itemId);
if (equalsId && (thisId == 0))
{
return super.equals(obj);
}
return equalsId;
return (this.getId() == item.getId());
}
}

@ -1,15 +1,13 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
@ -24,7 +22,7 @@ public class RequirementType extends BaseData {
@Column(name = "TYPE")
private String type;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Column(name = "DESCRIPTION")
private String description;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval=true)
@LazyCollection(LazyCollectionOption.FALSE)

@ -1,11 +1,7 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.springframework.security.core.GrantedAuthority;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -13,12 +9,13 @@ import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.springframework.security.core.GrantedAuthority;
@Entity
@Table(name="ROLE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Role extends BaseSimpleData implements GrantedAuthority, DataModel {
/**
@ -28,12 +25,11 @@ public class Role extends BaseSimpleData implements GrantedAuthority, DataModel
@Column(name="AUTHORITY", unique=true)
private String authority;
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Column(name="DESCRIPTION")
private String description;
@ManyToMany
@LazyCollection(LazyCollectionOption.FALSE)
@JoinTable(name="ROLE_PERMISSION", joinColumns={@JoinColumn(name="ROLE_ID")}, inverseJoinColumns={@JoinColumn(name="PERMISSION_ID")})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<Permission> permissions;
@Column(name = "WORKGROUP")
private boolean workgroup;

@ -1,83 +0,0 @@
package info.bukova.isspst.data;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
* @author Pepa Rokos
*/
@Entity
@Table(name = "SEASON")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Season extends BaseData {
@Column(name = "DESCRIPTION")
private String description;
@Column(name = "VALID_FROM")
private Date validFrom;
@Column(name = "VALID_TO")
private Date validTo;
@Column(name = "ACTIVE")
private boolean active;
public String getDescription() {
return description;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Season)) return false;
Season season = (Season) o;
if (getId() != season.getId()) return false;
if (active != season.active) return false;
if (description != null ? !description.equals(season.description) : season.description != null) return false;
if (validFrom != null ? !validFrom.equals(season.validFrom) : season.validFrom != null) return false;
if (validTo != null ? !validTo.equals(season.validTo) : season.validTo != null) return false;
return true;
}
@Override
public int hashCode() {
int result = description != null ? description.hashCode() : 0;
result = 31 * result + (validFrom != null ? validFrom.hashCode() : 0);
result = 31 * result + (validTo != null ? validTo.hashCode() : 0);
result = 31 * result + (active ? 1 : 0);
return result;
}
public void setDescription(String description) {
this.description = description;
}
public Date getValidFrom() {
return validFrom;
}
public void setValidFrom(Date validFrom) {
this.validFrom = validFrom;
}
public Date getValidTo() {
return validTo;
}
public void setValidTo(Date validTo) {
this.validTo = validTo;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
}

@ -1,8 +0,0 @@
package info.bukova.isspst.data;
/**
* @author Pepa Rokos
*/
public interface SeasonsAware {
public Season getSeason();
}

@ -14,8 +14,6 @@ public class SettingsData {
private MailMessage newReqTemplate;
private MailMessage authReqTemplate;
private MailMessage confReqTemplate;
private MailMessage confReqTripPassenger;
private MailMessage reqPassenger;
private Address mainAddress;
private List<Address> shippingAddrs;
private String bankName;
@ -24,14 +22,11 @@ public class SettingsData {
private List<Vehicle> vehicles;
private Map<Integer, BigDecimal[]> refunds;
private String stampFile;
private String logoFile;
public SettingsData() {
newReqTemplate = new MailMessage();
authReqTemplate = new MailMessage();
confReqTemplate = new MailMessage();
confReqTripPassenger = new MailMessage();
reqPassenger = new MailMessage();
mainAddress = new Address();
shippingAddrs = new ArrayList<Address>();
vehicles = new ArrayList<Vehicle>();
@ -145,29 +140,4 @@ public class SettingsData {
this.stampFile = stampFile;
}
public String getLogoFile()
{
return logoFile;
}
public void setLogoFile(String logoFile)
{
this.logoFile = logoFile;
}
public MailMessage getConfReqTripPassenger() {
return confReqTripPassenger;
}
public void setConfReqTripPassenger(MailMessage confReqTripPassenger) {
this.confReqTripPassenger = confReqTripPassenger;
}
public MailMessage getReqPassenger() {
return reqPassenger;
}
public void setReqPassenger(MailMessage reqPassenger) {
this.reqPassenger = reqPassenger;
}
}

@ -1,123 +0,0 @@
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);
}
}

@ -1,88 +0,0 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import info.bukova.isspst.reporting.Report;
import info.bukova.isspst.reporting.ReportMapping;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "SIGNED_DOCUMENTS_ITEMS")
public class SignedDocumentItem {
@Id
@Column(name = "ID")
@GeneratedValue
private int id;
@Column(name = "REPORT_ID")
private long reportId;
@Column(name = "REPORT_NAME", length = Constants.LEN_TEXT)
private String reportName;
@Column(name = "FILENAME", length = Constants.LEN_TEXT)
private String fileName;
@ManyToOne
@JoinColumn(name = "SIGNED_DOCUMENT_ID")
private SignedDocument signedDocument;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public long getReportId() {
return reportId;
}
public void setReportId(long reportId) {
this.reportId = reportId;
}
public String getReportName() {
return reportName;
}
public void setReportName(String reportName) {
this.reportName = reportName;
}
public String getActualReportName() {
for (ReportMapping rm : Constants.REPORTS) {
Report rep = rm.getReport();
if (this.reportId == rep.getReportId()) {
return rep.getName();
}
}
return reportName;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public SignedDocument getSignedDocument() {
return signedDocument;
}
public void setSignedDocument(SignedDocument signedDocument) {
this.signedDocument = signedDocument;
}
}

@ -1,50 +1,33 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import info.bukova.isspst.storage.EntityWithAttachment;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import 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.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;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
@Entity
@Table(name = "TRIP_BILL")
@Indexed
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class TripBill extends BaseData implements EntityWithAttachment, SeasonsAware {
public class TripBill extends BaseData {
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "REQUIREMENT_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private TripRequirement requirement;
@Column(name = "RESULT_MESSAGE_DATE")
private Date resultMessageDate;
@Column(name = "SIGN_DATE")
private Date signDate;
@Column(name = "RESULT_MESSAGE", length = Constants.LEN_RESULT_MESSAGE)
@Field(index = Index.YES, analyze = Analyze.YES)
private String resultMessage;
@Column(name = "FREE_MEALS")
private boolean freeMeals;
@Column(name = "FREE_HOUSING")
@ -61,27 +44,9 @@ public class TripBill extends BaseData implements EntityWithAttachment, SeasonsA
private BigDecimal downPayment;
@Column(name = "TOTAL", precision = 15, scale = 4)
private BigDecimal total;
@OneToMany(cascade = CascadeType.ALL)
@LazyCollection(LazyCollectionOption.TRUE)
@IndexedEmbedded
private List<FileMetainfo> attachedFiles;
@OneToOne(fetch = FetchType.EAGER, orphanRemoval = true)
@JoinColumn(name = "APPROVAL_ID")
private TripBillApproval approval;
@Column(name = "SAVED")
private Boolean saved; // Nastaveno na true, pokud uživatel udělá změnu- nepřenáší se pak částky od žadatele
@Column(name = "PAID")
private Boolean paid;
@Column(name = "PAID_DATE")
private Date paidDate;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Season season;
public TripBill() {
billItems = new ArrayList<TripBillItem>();
attachedFiles = new ArrayList<FileMetainfo>();
}
public TripRequirement getRequirement() {
@ -108,16 +73,6 @@ public class TripBill extends BaseData implements EntityWithAttachment, SeasonsA
this.signDate = signDate;
}
public String getResultMessage()
{
return resultMessage;
}
public void setResultMessage(String resultMessage)
{
this.resultMessage = resultMessage;
}
public boolean isFreeMeals() {
return freeMeals;
}
@ -166,62 +121,4 @@ public class TripBill extends BaseData implements EntityWithAttachment, SeasonsA
this.total = total;
}
public List<FileMetainfo> getAttachedFiles() {
return attachedFiles;
}
@Override
public void addAttachment(FileMetainfo metaInfo) {
attachedFiles.add(metaInfo);
}
@Override
public void removeAttachment(FileMetainfo metainfo) {
attachedFiles.remove(metainfo);
}
public void setAttachedFiles(List<FileMetainfo> attachedFiles) {
this.attachedFiles = attachedFiles;
}
public TripBillApproval getApproval() {
return approval;
}
public void setApproval(TripBillApproval approval) {
this.approval = approval;
}
public Boolean getSaved() {
return saved;
}
public void setSaved(Boolean saved) {
this.saved = saved;
}
public Boolean getPaid() {
return paid;
}
public void setPaid(Boolean paid) {
this.paid = paid;
}
public Date getPaidDate() {
return paidDate;
}
public void setPaidDate(Date paidDate) {
this.paidDate = paidDate;
}
@Override
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
}

@ -1,66 +0,0 @@
package info.bukova.isspst.data;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
* @author Pepa Rokos
*/
@Entity
@Table(name = "TRIP_BILL_APPROVAL")
public class TripBillApproval extends RequirementBase {
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "TRIPBILL_ID")
private TripBill bill;
@Transient
private boolean billForPassenger;
@Transient
private Date tripDate;
public boolean isBillForPassenger() {
return billForPassenger;
}
public void setBillForPassenger(boolean billForPassenger) {
this.billForPassenger = billForPassenger;
}
public Date getTripDate() {
return tripDate;
}
public void setTripDate(Date tripDate) {
this.tripDate = tripDate;
}
@Override
public String getNumser() {
if (bill == null) {
return "";
}
TripRequirement tr = bill.getRequirement();
if (tr == null) {
return "";
}
return tr.getNumser();
}
public TripBill getBill() {
return bill;
}
public void setBill(TripBill bill) {
this.bill = bill;
}
}

@ -1,6 +1,7 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
@ -8,8 +9,6 @@ import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;
@Entity
@Table(name = "TRIP_BILL_ITEMS")
@ -34,7 +33,7 @@ public class TripBillItem extends BaseData {
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "code", column = @Column(name = "BACK_VEHICLE_CODE")),
@AttributeOverride(name = "description", column = @Column(name = "BACK_VEHICLE_DESCRIPTION", length = Constants.LEN_DESCRIPTION))
@AttributeOverride(name = "description", column = @Column(name = "BACK_VEHICLE_DESCRIPTION"))
})
private Vehicle backVehicle;
@Column(name = "BEGIN_WORK")
@ -64,35 +63,6 @@ public class TripBillItem extends BaseData {
@Column(name = "ADJUSTED_TOTAL", precision = 15, scale = 4)
private BigDecimal adjustedTotal;
public TripBillItem() {
}
public TripBillItem(TripBillItem src) {
date = src.getDate();
to = src.getTo();
back = src.getBack();
toDeparture = src.getToDeparture();
toArrival = src.getToArrival();
backDeparture = src.getBackDeparture();
backArrival = src.getBackArrival();
toVehicle = src.getToVehicle();
backVehicle = src.getBackVehicle();
beginWork = src.getBeginWork();
endWork = src.getEndWork();
freeMealsCount = src.getFreeMealsCount();
distance = src.getDistance();
fuelConsumption = src.getFuelConsumption();
distanceAmount = src.getDistanceAmount();
fuelAmount = src.getFuelAmount();
carefare = src.getCarefare();
housing = src.getHousing();
meals = src.getMeals();
otherExpenses = src.getOtherExpenses();
total = src.getTotal();
adjustedTotal = src.getAdjustedTotal();
}
public Date getDate() {
return date;
}

@ -1,42 +1,32 @@
package info.bukova.isspst.data;
import info.bukova.isspst.storage.EntityWithAttachment;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import 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.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
@Entity
@Table(name = "TRIPREQUIREMENT")
@Indexed
public class TripRequirement extends RequirementBase implements EntityWithAttachment {
public class TripRequirement extends RequirementBase {
@Column(name = "TRIP_FROM")
@Field(index = Index.YES, analyze = Analyze.YES)
private String from;
@Column(name = "TRIP_TO")
@Field(index = Index.YES, analyze = Analyze.YES)
private String to;
@Column(name = "TRIP_DATE")
private Date tripDate;
@Column(name = "END")
@Column(name = "TRIP_END")
private String end;
@Column(name = "END_DATE")
private Date endDate;
@ -44,28 +34,16 @@ public class TripRequirement extends RequirementBase implements EntityWithAttach
@LazyCollection(LazyCollectionOption.TRUE)
@JoinTable(name="TRIPREQUIREMENT_PASSANGER", joinColumns={@JoinColumn(name="TRIPREQUIREMENT_ID")}, inverseJoinColumns={@JoinColumn(name="USER_ID")})
private List<User> passengers;
@Column(name = "FOREIGN_PERSONS")
@Field(index = Index.YES, analyze = Analyze.YES)
private String foreignPersons;
@Embedded
private Vehicle vehicle;
@Column(name = "REQUIRE_DOWN_PAYMENT")
private Boolean requireDownPayment;
@Column(name = "DOWN_PAYMENT", precision = 15, scale = 4)
private BigDecimal downPayment;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@LazyCollection(LazyCollectionOption.TRUE)
@IndexedEmbedded
private List<FileMetainfo> attachedFiles;
@Column(name = "BILL_FOR_PASSENGERS")
private Boolean billForPassengers;
public TripRequirement() {
this.setOwnedBy(new User());
passengers = new ArrayList<User>();
attachedFiles = new ArrayList<FileMetainfo>();
}
public String getFrom() {
@ -116,16 +94,6 @@ public class TripRequirement extends RequirementBase implements EntityWithAttach
this.passengers = passengers;
}
public String getForeignPersons()
{
return foreignPersons;
}
public void setForeignPersons(String foreignPersons)
{
this.foreignPersons = foreignPersons;
}
public Vehicle getVehicle() {
return vehicle;
}
@ -150,30 +118,4 @@ public class TripRequirement extends RequirementBase implements EntityWithAttach
this.downPayment = downPayment;
}
@Override
public List<FileMetainfo> getAttachedFiles() {
return attachedFiles;
}
public void setAttachedFiles(List<FileMetainfo> attachedFiles) {
this.attachedFiles = attachedFiles;
}
@Override
public void addAttachment(FileMetainfo metaInfo) {
attachedFiles.add(metaInfo);
}
@Override
public void removeAttachment(FileMetainfo metainfo) {
attachedFiles.remove(metainfo);
}
public Boolean getBillForPassengers() {
return billForPassengers;
}
public void setBillForPassengers(Boolean billForPassengers) {
this.billForPassengers = billForPassengers;
}
}

@ -1,13 +1,9 @@
package info.bukova.isspst.data;
import info.bukova.isspst.StringUtils;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Embedded;
@ -17,13 +13,11 @@ import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.List;
import org.springframework.security.core.userdetails.UserDetails;
@Entity
@Table(name="USER")
@Indexed
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Table(name="USER_LOGIN")
public class User extends Member implements UserDetails, DataModel {
/**
@ -38,10 +32,8 @@ public class User extends Member implements UserDetails, DataModel {
@Column(name="ENABLED")
private boolean enabled;
@Column(name="FIRST_NAME")
@Field(index = Index.YES, analyze = Analyze.YES)
private String firstName;
@Column(name="LAST_NAME")
@Field(index = Index.YES, analyze = Analyze.YES)
private String lastName;
@Column(name="PERSONAL_NUMBER")
private String personalNumber;
@ -51,7 +43,6 @@ public class User extends Member implements UserDetails, DataModel {
private boolean notify;
@ManyToMany(fetch=FetchType.EAGER)
@JoinTable(name="USER_ROLE", joinColumns={@JoinColumn(name="USER_ID")}, inverseJoinColumns={@JoinColumn(name="ROLE_ID")})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<Role> authorities;
@Column(name="SETTINGS", length=1048576)
private String settings;

@ -1,10 +1,5 @@
package info.bukova.isspst.data;
import info.bukova.isspst.StringUtils;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Embeddable;
@ -52,22 +47,4 @@ public class UsersAddress {
this.city = city;
}
public String toString() {
List<String> list = new ArrayList<String>();
list.add(this.street);
list.add(this.houseNumber);
final String s1 = StringUtils.joinNotEmpty(list, " ");
list.clear();
list.add(this.zipCode);
list.add(this.city);
final String s2 = StringUtils.joinNotEmpty(list, " ");
list.clear();
list.add(s1);
list.add(s2);
final String s = StringUtils.joinNotEmpty(list, ", ");
return s;
}
}

@ -1,7 +1,5 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import javax.persistence.Column;
import javax.persistence.Embeddable;
@ -10,7 +8,7 @@ public class Vehicle {
@Column(name = "VEHICLE_CODE")
private String code;
@Column(name = "VEHICLE_DESCRIPTION", length = Constants.LEN_DESCRIPTION)
@Column(name = "VEHICLE_DESCRIPTION")
private String description;
public String getCode() {

@ -1,14 +1,15 @@
package info.bukova.isspst.data;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.math.BigDecimal;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
@Entity
@Table(name = "WORKFLOW")
@ -24,8 +25,6 @@ public class Workflow extends BaseData {
private Integer wOrder;
@Column(name = "WLIMIT", precision=15, scale=4)
private BigDecimal limit;
@Column(name = "SIGNATURE")
private Boolean signature;
public Boolean getCentre() {
return centre;
@ -69,11 +68,4 @@ public class Workflow extends BaseData {
this.limit = limit;
}
public Boolean getSignature() {
return signature;
}
public void setSignature(Boolean signature) {
this.signature = signature;
}
}

@ -1,10 +1,11 @@
package info.bukova.isspst.data;
import info.bukova.isspst.StringUtils;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@ -16,14 +17,12 @@ import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
@Entity
@Table(name = "WORKGROUP")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Workgroup extends Member implements OwnedDataModel, Serializable {
/**
@ -38,7 +37,6 @@ public class Workgroup extends Member implements OwnedDataModel, Serializable {
@ManyToMany(cascade = {CascadeType.ALL})
@LazyCollection(LazyCollectionOption.TRUE)
@JoinTable(name="WORKGROUP_MEMBER", joinColumns={@JoinColumn(name="WORKGROUP_ID")}, inverseJoinColumns={@JoinColumn(name="JOBMAPPING_ID")})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<JobMapping> members;
@Column(name = "CENTRE")
private boolean centre;

@ -1,57 +0,0 @@
package info.bukova.isspst.filters;
import info.bukova.isspst.StringUtils;
import java.util.ArrayList;
import java.util.List;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listitem;
@SuppressWarnings("serial")
public class BooleanFilterListbox extends Listbox
{
class TristateBooleanListItem extends TristateBoolean
{
public TristateBooleanListItem(String text, int value)
{
this.setText(text);
this.setValue(value);
}
private String text;
public String getText()
{
return text;
}
public void setText(String text)
{
this.text = text;
}
}
public BooleanFilterListbox()
{
super();
List<TristateBooleanListItem> list = new ArrayList<TristateBooleanListItem>();
list.add(new TristateBooleanListItem(StringUtils.localize("LabelAll"), TristateBoolean.NULL));
list.add(new TristateBooleanListItem(StringUtils.localize("LabelNo"), TristateBoolean.FALSE));
list.add(new TristateBooleanListItem(StringUtils.localize("LabelYes"), TristateBoolean.TRUE));
for (int i = 0; i < list.size(); i++)
{
TristateBooleanListItem triStateItem = (TristateBooleanListItem) list.get(i);
this.appendItem(triStateItem.getText(), "");
Listitem item = this.getItemAtIndex(i);
item.setValue((TristateBoolean) triStateItem);
}
this.setSelectedIndex(0);
// this.setHflex("1");
this.setMold("select");
}
}

@ -1,76 +0,0 @@
package info.bukova.isspst.filters;
import info.bukova.isspst.DateTimeUtils;
import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.Invoicing;
import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.User;
import info.bukova.isspst.data.Workgroup;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
public class InvoicingFilter implements Filter<Invoicing>
{
private Invoicing condition;
public InvoicingFilter(Invoicing cond)
{
this.condition = cond;
}
private static class InvoicingMatcher extends TypeSafeMatcher<Invoicing>
{
private Invoicing condition;
public InvoicingMatcher(Invoicing cond)
{
this.condition = cond;
if (condition.getRequirement() == null) {
condition.setRequirement(new Requirement());
}
}
@Override
public void describeTo(Description desc)
{
desc.appendText("Invoicing matches");
}
@Override
public boolean matchesSafely(Invoicing item)
{
boolean foundNumser = StringUtils.isEqualForFilter(item.getRequirement().getNumser(), condition.getRequirement().getNumser());
boolean foundReqDate = DateTimeUtils.isEqualByDateForFilter(item.getRequirement().getReqDate(), condition.getRequirement().getReqDate());
boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getRequirement().getCentre(), condition.getRequirement().getCentre());
boolean foundWorkgroup = Workgroup.isEqualByWorkgroupForFilter(item.getRequirement().getWorkgroup(), condition.getRequirement().getWorkgroup());
boolean foundUser = User.isEqualByUserForFilter(item.getRequirement().getOwnedBy(), condition.getRequirement().getOwnedBy());
boolean foundDescription = StringUtils.isEqualForFilter(item.getRequirement().getDescription(), condition.getRequirement().getDescription());
return (foundNumser && foundReqDate && foundCenter && foundDescription && foundWorkgroup && foundUser);
}
@Factory
public static Matcher<Invoicing> matchBuilding(Invoicing building)
{
return new InvoicingMatcher(building);
}
}
@Override
public InvoicingMatcher matcher()
{
return new InvoicingMatcher(condition);
}
@Override
public String queryString()
{
return "";
}
}

@ -1,6 +1,5 @@
package info.bukova.isspst.filters;
import info.bukova.isspst.BooleanUtils;
import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.JoinedItem;
import info.bukova.isspst.data.MUnitEmb;
@ -43,7 +42,6 @@ public class JoinedItemFilter implements Filter<JoinedItem>
@Override
public boolean matchesSafely(JoinedItem item)
{
boolean foundItemMaterial = BooleanUtils.isEqualFilterByBoolean(item.isItemMaterialReal(), condition.getItemMaterial());
boolean foundCode = StringUtils.isEqualForFilter(item.getCode(), condition.getCode());
boolean foundName = StringUtils.isEqualForFilter(item.getName(), condition.getName());
boolean foundTextItem = StringUtils.isEqualForFilter(item.getTextItem(), condition.getTextItem());
@ -58,18 +56,7 @@ public class JoinedItemFilter implements Filter<JoinedItem>
boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getCentre(), condition.getCentre());
boolean foundOwner = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
return (foundItemMaterial
&& foundCode
&& foundName
&& foundTextItem
&& foundDescription
&& foundQuantity
&& foundUnitPrice
&& foundMUnit
&& foundTotal
&& foundWorkgroup
&& foundCenter
&& foundOwner && foundDescription);
return (foundCode && foundName && foundTextItem && foundDescription && foundQuantity && foundUnitPrice && foundMUnit && foundTotal && foundWorkgroup && foundCenter && foundOwner && foundDescription);
}
@Factory

@ -42,24 +42,27 @@ public class OrderFilter implements Filter<Order>
@Override
public boolean matchesSafely(Order item)
{
boolean foundOrdered = (item.isOrdered() == condition.isOrdered());
boolean foundNumSer = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser());
boolean foundOrderDate = DateTimeUtils.isEqualByDateForFilter(item.getOrderDate(), condition.getOrderDate());
boolean foundTotal = true;// BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(),
// condition.getTotal());
boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate());
boolean foundDeliveredDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveredDate(), condition.getDeliveredDate());
boolean foundInvoiceNumber = StringUtils.isEqualForFilter(item.getInvoiceNumber(), condition.getInvoiceNumber());
boolean foundInvoiceTotal = true;// BigDecimalUtils.isEqualByDecimalForFilter(item.getInvoiceTotal(),
// condition.getInvoiceTotal());
boolean foundSupplierAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getSuplier(), condition.getSuplier());
boolean foundDeliveryAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getDeliveryAddress(), condition.getDeliveryAddress());
boolean foundInvoiceAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getAddress(), condition.getAddress());
boolean foundOwnedBy = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
return (foundOrdered
&& foundNumSer
return (foundNumSer
&& foundOrderDate
&& foundTotal
&& foundDeliveryDate
&& foundDeliveredDate
&& foundInvoiceNumber
&& foundInvoiceTotal
&& foundSupplierAddr
&& foundDeliveryAddr
&& foundInvoiceAddr

@ -1,7 +1,5 @@
package info.bukova.isspst.filters;
import info.bukova.isspst.BigDecimalUtils;
import info.bukova.isspst.BooleanUtils;
import info.bukova.isspst.DateTimeUtils;
import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.Requirement;
@ -48,9 +46,7 @@ public class RequirementFilter implements Filter<Requirement>
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate());
boolean foundUser = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
boolean foundProject = BooleanUtils.isEqualByBooleanValue(item.getProject(), condition.getProject());
boolean foundSumTotal = BigDecimalUtils.isEqualByDecimalForFilter(item.getSumTotal(), condition.getSumTotal());
return (foundNumser && foundReqDate && foundCenter && foundDescription && foundDeliveryDate && foundUser && foundProject && foundSumTotal);
return (foundNumser && foundReqDate && foundCenter && foundDescription && foundDeliveryDate && foundUser);
}
@Factory

@ -1,64 +0,0 @@
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 "";
}
}

@ -1,82 +0,0 @@
package info.bukova.isspst.filters;
import info.bukova.isspst.BooleanUtils;
import info.bukova.isspst.DateTimeUtils;
import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.TripBillApproval;
import info.bukova.isspst.data.User;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
public class TripBillApprovalFilter implements Filter<TripBillApproval>
{
private TripBillApproval condition;
public TripBillApprovalFilter(TripBillApproval cond)
{
this.condition = cond;
}
private static class TripBillApprovalMatcher extends TypeSafeMatcher<TripBillApproval>
{
private TripBillApproval condition;
public TripBillApprovalMatcher(TripBillApproval cond)
{
this.condition = cond;
}
@Override
public void describeTo(Description desc)
{
desc.appendText("requirement matches");
}
@Override
public boolean matchesSafely(TripBillApproval item)
{
if (item.getBill() == null) {
return false;
}
boolean foundNumser = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser());
boolean foundReqDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getRequirement().getReqDate(), condition.getBill().getRequirement().getReqDate());
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
boolean foundFrom = StringUtils.isEqualForFilter(item.getBill().getRequirement().getFrom(), condition.getBill().getRequirement().getFrom());
boolean foundTo = StringUtils.isEqualForFilter(item.getBill().getRequirement().getTo(), condition.getBill().getRequirement().getTo());
boolean foundWorkgroup = (condition.getWorkgroup() == null ||(item.getWorkgroup() != null && item.getWorkgroup().equals(condition.getWorkgroup())));
boolean foundCentre = (condition.getCentre() == null || (item.getCentre() != null && item.getCentre().equals(condition.getCentre())));
boolean foundOwner = User.isEqualByUserForFilter(item.getBill().getOwnedBy(), condition.getBill().getOwnedBy());
boolean foundPaid = BooleanUtils.isEqualByBooleanValue(item.getBill().getPaid(), condition.getBill().getPaid());
boolean foundPaidDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getPaidDate(), condition.getBill().getPaidDate());
boolean foundPassenger = (item.getBill().getOwnedBy() != item.getBill().getRequirement().getOwnedBy()) == condition.isBillForPassenger();
boolean foundApproveDate = DateTimeUtils.isEqualByDateForFilter(item.getApproveDate(), condition.getApproveDate());
boolean foundTripDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getRequirement().getTripDate(), condition.getTripDate());
return foundNumser && foundReqDate && foundDescription && foundFrom && foundTo && foundWorkgroup && foundCentre && foundOwner && foundPaid
&& foundPaidDate && foundPassenger && foundApproveDate && foundTripDate;
}
@Factory
public static Matcher<TripBillApproval> matchTripRequirement(TripBillApproval building)
{
return new TripBillApprovalMatcher(building);
}
}
@Override
public TripBillApprovalMatcher matcher()
{
return new TripBillApprovalMatcher(condition);
}
@Override
public String queryString()
{
return "";
}
}

@ -3,7 +3,6 @@ package info.bukova.isspst.filters;
import info.bukova.isspst.DateTimeUtils;
import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.TripRequirement;
import info.bukova.isspst.data.User;
import org.hamcrest.Description;
import org.hamcrest.Factory;
@ -46,7 +45,7 @@ public class TripRequirementFilter implements Filter<TripRequirement>
boolean foundTo = StringUtils.isEqualForFilter(item.getTo(), condition.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.getOwnedBy(), condition.getOwnedBy());
boolean foundOwner = StringUtils.isEqualForFilter(item.getOwnedBy().getLastName(), condition.getOwnedBy().getLastName());
return foundNumser && foundReqDate && foundDescription && foundFrom && foundTo && foundWorkgroup && foundCentre && foundOwner;
}

@ -1,87 +0,0 @@
package info.bukova.isspst.filters;
import org.jfree.util.Log;
public class TristateBoolean
{
private static final String TAG = TristateBoolean.class.getSimpleName();
public static final int NULL = -1;
public static final int FALSE = 0;
public static final int TRUE = 1;
public static final int getValidValue(final int value)
{
if ((value != TristateBoolean.NULL) && (value != TristateBoolean.FALSE) && (value != TristateBoolean.TRUE))
{
Log.warn(TAG + "\nBad tristate boolean value.");
return TristateBoolean.NULL;
}
return value;
}
public TristateBoolean()
{
this.setValue(TristateBoolean.NULL);
}
public TristateBoolean(boolean value)
{
this.setValue(value ? TristateBoolean.TRUE : TristateBoolean.FALSE);
}
public TristateBoolean(int value)
{
this.setValue(value);
}
protected int value;
public int getValue()
{
return value;
}
public void setValue(int value)
{
this.value = TristateBoolean.getValidValue(value);
}
public Boolean getBoolean()
{
switch (this.value)
{
case TristateBoolean.FALSE:
return new Boolean(false);
case TristateBoolean.TRUE:
return new Boolean(true);
default:
return null;
}
}
@Override
public boolean equals(Object obj)
{
if (obj != null)
{
if (obj instanceof TristateBoolean)
{
TristateBoolean item = (TristateBoolean) obj;
int thisValue = this.getValue();
int itemValue = item.getValue();
return (thisValue == itemValue);
}
}
return false;
}
public boolean equals(int value)
{
return (this.getValue() == value);
}
}

@ -1,9 +1,5 @@
package info.bukova.isspst.mail;
import info.bukova.isspst.Constants;
import info.bukova.isspst.EntityUrlResolver;
import info.bukova.isspst.UrlResolverHolder;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@ -16,7 +12,6 @@ public class EntityMessageBuilder implements MessageBuilder {
private final static Logger logger = LoggerFactory.getLogger(EntityMessageBuilder.class);
private boolean html;
private UrlResolverHolder urlResolverHolder;
public void setHtml(boolean html) {
this.html = html;
@ -58,11 +53,7 @@ public class EntityMessageBuilder implements MessageBuilder {
for (String p : properties) {
try {
if (p.equals(Constants.MAIL_URL_KEYWORD)) {
ret = ret.replaceAll("\\[" + p + "\\]", getUrl(data));
} else {
ret = ret.replaceAll("\\[" + p + "\\]", BeanUtils.getProperty(data, p));
}
} catch (IllegalAccessException e) {
logger.error(e.getMessage());
} catch (InvocationTargetException e) {
@ -77,17 +68,4 @@ public class EntityMessageBuilder implements MessageBuilder {
return ret;
}
private String getUrl(Object data) {
if (urlResolverHolder == null) {
return "";
}
EntityUrlResolver res = urlResolverHolder.resolverFor(data.getClass());
return res.entityUrl(data);
}
public void setUrlResolverHolder(UrlResolverHolder urlResolverHolder) {
this.urlResolverHolder = urlResolverHolder;
}
}

@ -43,10 +43,6 @@ public class MailerWithAttachement implements Mailer {
}
}
if (message.getReplyTo() == null) {
message.setReplyTo(message.getFrom());
}
helper.setFrom(message.getFrom());
helper.setReplyTo(message.getReplyTo());
helper.setTo(message.getTo());
@ -67,7 +63,6 @@ public class MailerWithAttachement implements Mailer {
}
try {
sender.send(mimeMessage);
logger.info("Mail queued for send");
} catch (MailAuthenticationException e) {
logger.error("Authentication error");
} catch (MailSendException e) {

@ -1,7 +1,8 @@
package info.bukova.isspst.reporting;
import com.mysql.jdbc.StringUtils;
import info.bukova.isspst.data.Address;
import java.util.HashMap;
import java.util.Map;
import info.bukova.isspst.data.AuthItem;
import info.bukova.isspst.data.Order;
import info.bukova.isspst.data.TripBill;
@ -9,15 +10,10 @@ import info.bukova.isspst.data.User;
import info.bukova.isspst.data.UserSettingsData;
import info.bukova.isspst.services.requirement.TripRequirementService;
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.storage.FileStorage;
import net.sf.jasperreports.engine.JRParameter;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
public class ParamFiller {
@ -31,10 +27,6 @@ public class ParamFiller {
private TripRequirementService tripReqService;
@Autowired
private GlobalSettingsService settingService;
@Autowired
private TripBillApprovalService tripBillApprovalService;
@Autowired
private HttpServletRequest req;
public void fill() {
if (definition.getDataSet() == null || definition.getDataSet().isEmpty()) {
@ -53,7 +45,6 @@ public class ParamFiller {
if ((definition.getDataSet().get(0) instanceof TripBill)
&& definition.getReport().isSingleRecord()) {
if (userService.getUserSettings().getSignatureFile() != null
&& !userService.getUserSettings().getSignatureFile().isEmpty()) {
definition.setParam("P_USER_SIGNATURE", storage.serverPath(userService.getUserSettings().getSignatureFile()));
@ -61,34 +52,20 @@ public class ParamFiller {
TripBill tb = (TripBill)definition.getDataSet().get(0);
tripReqService.loadAuthItems(tb.getRequirement());
AuthItem lastAuth = tb.getRequirement().getAuthorization().get(tb.getRequirement().getAuthorization().size() - 1);
if (tb.getApproval() != null) {
tripBillApprovalService.loadAuthItems(tb.getApproval());
}
if (tb.getApproval() != null && tb.getApproval().getAuthorization() != null && !tb.getApproval().getAuthorization().isEmpty()) {
AuthItem lastButOneAuth = tb.getApproval().getAuthorization().get(0);
definition.setParam("P_PREV_APPROVE_DATE", lastButOneAuth.getAuthDate());
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()));
}
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())) {
if (approverSettings != null
&& approverSettings.getSignatureFile() != null
&& !approverSettings.getSignatureFile().isEmpty()) {
definition.setParam("P_APPROVER_SIGNATURE", storage.serverPath(approverSettings.getSignatureFile()));
}
}
}
if ((definition.getDataSet().get(0) instanceof Order)
&& definition.getReport().isSingleRecord()) {
@ -97,16 +74,6 @@ public class ParamFiller {
definition.setParam("P_STAMP", storage.serverPath(settingService.getSettings().getStampFile()));
}
}
definition.setParam("P_LOGO", storage.serverPath(settingService.getSettings().getLogoFile()));
definition.setParam(JRParameter.REPORT_LOCALE, req.getLocale());
Address mainAddress = settingService.getSettings().getMainAddress();
if (mainAddress != null) {
String addr = (StringUtils.isNullOrEmpty(mainAddress.getCompany()) ? "" : mainAddress.getCompany());
definition.setParam("P_MAIN_ADDRESS", addr);
}
}
}

@ -1,21 +1,18 @@
package info.bukova.isspst.reporting;
import info.bukova.isspst.SpringUtils;
import info.bukova.isspst.data.DataModel;
import info.bukova.isspst.data.SignedDocumentItem;
import info.bukova.isspst.services.signeddocs.SignedDocumentService;
import info.bukova.isspst.storage.ReportFileStorage;
import java.io.File;
import javax.servlet.ServletContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.JasperRunManager;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.util.JRLoader;
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")
public class PredefinedGenerator implements Generator {
@ -32,11 +29,6 @@ public class PredefinedGenerator implements Generator {
@Override
public byte[] generate() {
byte[] bytes = null;
SignedDocumentItem signedItem = getSignedDocument();
if (signedItem != null) {
return fromStorage(signedItem);
}
try {
JasperReport report = (JasperReport) JRLoader.loadObject(getReportFile());
@ -52,18 +44,6 @@ public class PredefinedGenerator implements Generator {
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() {
return new File(ctx.getRealPath("WEB-INF/reports") + "/" + definition.getReport().getJasperFile() + ".jasper");
}

@ -4,83 +4,48 @@ package info.bukova.isspst.reporting;
public class Report {
private ReportType type;
private long reportId;
private boolean signable;
private String name;
private String jasperFile;
private boolean hasSettings;
private boolean singleRecord;
private boolean hasCondition;
private String property;
public Report() {
this.reportId = 0;
this.signable = false;
hasSettings = false;
singleRecord = false;
hasCondition = false;
}
/**
* @param reportId
* @param signable
* @param name
* @param jasperFile
*/
public Report(long reportId, boolean signable, String name, String jasperFile) {
public Report(String name, String jasperFile) {
this();
this.type = ReportType.DEFINED;
this.reportId = reportId;
this.signable = signable;
this.name = name;
this.jasperFile = jasperFile;
}
/**
* @param reportId
* @param signable
* @param name
* @param jasperFile
* @param hasSettings
*/
public Report(long reportId, boolean signable, String name, String jasperFile, boolean hasSettings) {
this(reportId, signable, name, jasperFile);
public Report(String name, String jasperFile, boolean hasSettings) {
this(name, jasperFile);
this.hasSettings = hasSettings;
}
/**
* @param reportId
* @param signable
* @param name
* @param jasperFile
* @param hasSettings
* @param singleRecord
*/
public Report(long reportId, boolean signable, String name, String jasperFile, boolean hasSettings, boolean singleRecord) {
this(reportId, signable, name, jasperFile, hasSettings);
public Report(String name, String jasperFile, boolean hasSettings, boolean singleRecord) {
this(name, jasperFile, hasSettings);
this.singleRecord = singleRecord;
}
public Report(long reportId, boolean signable, String name, String jasperFile, boolean hasSettings, boolean singleRecord, String property) {
this(reportId, signable, name, jasperFile, hasSettings, singleRecord);
this.property = property;
}
/**
*
* @param reportId
* @param signable
* @param name
* @param jasperFile
* @param hasSettings
* @param singleRecord
* @param hasCondition
*/
public Report(long reportId, boolean signable, String name, String jasperFile, boolean hasSettings, boolean singleRecord, boolean hasCondition) {
this(reportId, signable, name, jasperFile, hasSettings, singleRecord);
this.hasCondition = hasCondition;
}
public ReportType getType() {
return type;
}
@ -121,35 +86,4 @@ public class Report {
this.singleRecord = singleRecord;
}
public boolean isHasCondition() {
return hasCondition;
}
public void setHasCondition(boolean hasCondition) {
this.hasCondition = hasCondition;
}
public long getReportId() {
return reportId;
}
public void setReportId(long reportId) {
this.reportId = reportId;
}
public boolean isSignable() {
return signable;
}
public void setSignable(boolean signable) {
this.signable = signable;
}
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
}

@ -1,17 +1,17 @@
package info.bukova.isspst.reporting;
import info.bukova.isspst.storage.ReportFileStorage;
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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
public class ReportController {
@ -21,8 +21,6 @@ public class ReportController {
private GeneratorFactory factory;
@Autowired
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 final static Logger logger = LoggerFactory.getLogger(ReportController.class);
@ -48,20 +46,13 @@ public class ReportController {
try {
os = response.getOutputStream();
if ((reportDefinition.getReport() == null || reportDefinition.getDataSet() == null) && reportDefinition.getSignedDocItem() == null) {
if (reportDefinition.getReport() == null || reportDefinition.getDataSet() == null) {
throw new ReportException("Definition is null");
}
byte[] data;
if (reportDefinition.getSignedDocItem() == null) {
paramFiller.fill();
Generator gen = factory.createGenerator(reportDefinition);
data = gen.generate();
} else {
data = reportFileStorage.fileData(reportDefinition.getSignedDocItem());
}
byte[] data = gen.generate();
response.setContentType(contentType);
response.setContentLength(data.length);
@ -73,9 +64,6 @@ public class ReportController {
} catch (ReportException e) {
logger.error("Report generation error: " + e.getMessage());
writeError(os, e);
} catch (Exception e) {
logger.error("Report generation error: " + e.getMessage());
writeError(os, e);
} finally {
if (os != null) {
try {

@ -1,6 +1,5 @@
package info.bukova.isspst.reporting;
import info.bukova.isspst.data.SignedDocumentItem;
import info.bukova.isspst.services.Service;
import java.io.Serializable;
@ -21,7 +20,6 @@ public class ReportDefinition implements Serializable {
private List<String> fieldsToPrint;
private String reportTitle;
private Service<Object> service;
private SignedDocumentItem signedDocItem;
public ReportDefinition() {
params = new HashMap<String, Object>();
@ -94,7 +92,6 @@ public class ReportDefinition implements Serializable {
reportTitle = "";
service = null;
params.clear();
signedDocItem = null;
}
public String getReportTitle() {
@ -113,11 +110,4 @@ public class ReportDefinition implements Serializable {
this.service = service;
}
public SignedDocumentItem getSignedDocItem() {
return signedDocItem;
}
public void setSignedDocItem(SignedDocumentItem signedDocItem) {
this.signedDocItem = signedDocItem;
}
}

@ -1,68 +0,0 @@
package info.bukova.isspst.reporting;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfFormField;
import com.lowagie.text.pdf.PdfName;
import net.sf.jasperreports.engine.JRGenericPrintElement;
import net.sf.jasperreports.engine.JRPropertiesMap;
import net.sf.jasperreports.engine.export.GenericElementHandler;
import net.sf.jasperreports.engine.export.GenericElementHandlerBundle;
import net.sf.jasperreports.engine.export.GenericElementPdfHandler;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.export.JRPdfExporterContext;
import net.sf.jasperreports.extensions.ExtensionsRegistry;
import net.sf.jasperreports.extensions.ExtensionsRegistryFactory;
import net.sf.jasperreports.extensions.SingletonExtensionRegistry;
/**
* @author Pepa Rokos
*/
public class SignaturePdfHandler implements GenericElementPdfHandler, GenericElementHandlerBundle, ExtensionsRegistryFactory {
@Override
public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) {
return new SingletonExtensionRegistry<GenericElementHandlerBundle>(GenericElementHandlerBundle.class, this);
}
@Override
public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element) {
//PdfFormField field = PdfFormField.createSignature(exporterContext.getPdfWriter());
PdfFormField field = PdfFormField.createTextField(exporterContext.getPdfWriter(), true, false, 255);
Object param = element.getParameterValue("index");
String index = param != null ? String.valueOf(param) : null;
if (index != null) {
field.setFieldName("signature-" + index);
} else {
field.setFieldName("signature");
}
field.put(PdfName.V, exporterContext.getPdfWriter().getPdfIndirectReference());
field.setFieldFlags(PdfFormField.FF_READ_ONLY);
field.setWidget(new Rectangle(element.getX(),
exporterContext.getExportedReport().getPageHeight() - element.getY(),
element.getX() + element.getWidth(),
exporterContext.getExportedReport().getPageHeight() - element.getY() - element.getHeight()), PdfName.HIGHLIGHT);
exporterContext.getPdfWriter().addAnnotation(field);
}
@Override
public boolean toExport(JRGenericPrintElement element) {
return true;
}
@Override
public String getNamespace() {
return "urn:sig:sig";
}
@Override
public GenericElementHandler getHandler(String elementName, String exporterKey) {
if (elementName.equals("signature") && exporterKey.equals(JRPdfExporter.PDF_EXPORTER_KEY)) {
return this;
}
return null;
}
}

@ -24,18 +24,12 @@ public abstract class AbstractRequirementEvaluator extends AbstractModuleEvaluat
return false;
}
if (targetDomainObject instanceof RequirementBase) {
RequirementBase req = (RequirementBase) targetDomainObject;
if (permission.equals(Constants.PERM_EDIT_NEW)) {
return req.getState() == RequirementState.NEW;
}
if (permission.equals(Constants.PERM_DELETE_NEW)) {
return req.getState() == RequirementState.NEW;
}
}
return true;
}

@ -1,306 +0,0 @@
package info.bukova.isspst.security;
import org.springframework.ldap.core.DirContextOperations;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.security.authentication.AccountExpiredException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.CredentialsExpiredException;
import org.springframework.security.authentication.DisabledException;
import org.springframework.security.authentication.LockedException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.ldap.SpringSecurityLdapTemplate;
import org.springframework.security.ldap.authentication.AbstractLdapAuthenticationProvider;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import javax.naming.AuthenticationException;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.OperationNotSupportedException;
import javax.naming.directory.DirContext;
import javax.naming.directory.SearchControls;
import javax.naming.ldap.InitialLdapContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Hashtable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class AdAuthenticationProvider extends AbstractLdapAuthenticationProvider{
private static final Pattern SUB_ERROR_CODE = Pattern.compile(".*data\\s([0-9a-f]{3,4}).*");
// Error codes
private static final int USERNAME_NOT_FOUND = 0x525;
private static final int INVALID_PASSWORD = 0x52e;
private static final int NOT_PERMITTED = 0x530;
private static final int PASSWORD_EXPIRED = 0x532;
private static final int ACCOUNT_DISABLED = 0x533;
private static final int ACCOUNT_EXPIRED = 0x701;
private static final int PASSWORD_NEEDS_RESET = 0x773;
private static final int ACCOUNT_LOCKED = 0x775;
private final String domain;
private final String rootDn;
private final String url;
private final String upnSuffix;
private boolean convertSubErrorCodesToExceptions;
// Only used to allow tests to substitute a mock LdapContext
ContextFactory contextFactory = new ContextFactory();
/**
* @param domain the domain for which authentication should take place
*/
// public ActiveDirectoryLdapAuthenticationProvider(String domain) {
// this (domain, null);
// }
/**
* @param domain the domain name (may be null or empty)
* @param url an LDAP url (or multiple URLs)
*/
public AdAuthenticationProvider(String domain, String upnSuffix, String url) {
Assert.isTrue(StringUtils.hasText(url), "Url cannot be empty");
this.domain = StringUtils.hasText(domain) ? domain.toLowerCase() : null;
//this.url = StringUtils.hasText(url) ? url : null;
this.url = url;
this.upnSuffix = upnSuffix;
rootDn = this.domain == null ? null : rootDnFromDomain(this.domain);
}
@Override
protected DirContextOperations doAuthentication(UsernamePasswordAuthenticationToken auth) {
String username = auth.getName();
String password = (String)auth.getCredentials();
DirContext ctx = bindAsUser(username, password);
try {
return searchForUser(ctx, username);
} catch (NamingException e) {
logger.error("Failed to locate directory entry for authenticated user: " + username, e);
throw badCredentials();
} finally {
LdapUtils.closeContext(ctx);
}
}
/**
* Creates the user authority list from the values of the {@code memberOf} attribute obtained from the user's
* Active Directory entry.
*/
@Override
protected Collection<? extends GrantedAuthority> loadUserAuthorities(DirContextOperations userData, String username, String password) {
String[] groups = userData.getStringAttributes("memberOf");
if (groups == null) {
logger.debug("No values for 'memberOf' attribute.");
return AuthorityUtils.NO_AUTHORITIES;
}
if (logger.isDebugEnabled()) {
logger.debug("'memberOf' attribute values: " + Arrays.asList(groups));
}
ArrayList<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(groups.length);
for (String group : groups) {
authorities.add(new SimpleGrantedAuthority(new DistinguishedName(group).removeLast().getValue()));
}
return authorities;
}
private DirContext bindAsUser(String username, String password) {
// TODO. add DNS lookup based on domain
final String bindUrl = url;
Hashtable<String,String> env = new Hashtable<String,String>();
env.put(Context.SECURITY_AUTHENTICATION, "simple");
String bindPrincipal = createBindPrincipal(username);
env.put(Context.SECURITY_PRINCIPAL, bindPrincipal);
env.put(Context.PROVIDER_URL, bindUrl);
env.put(Context.SECURITY_CREDENTIALS, password);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
try {
return contextFactory.createContext(env);
} catch (NamingException e) {
if ((e instanceof AuthenticationException) || (e instanceof OperationNotSupportedException)) {
handleBindException(bindPrincipal, e);
throw badCredentials();
} else {
throw LdapUtils.convertLdapException(e);
}
}
}
void handleBindException(String bindPrincipal, NamingException exception) {
if (logger.isDebugEnabled()) {
logger.debug("Authentication for " + bindPrincipal + " failed:" + exception);
}
int subErrorCode = parseSubErrorCode(exception.getMessage());
if (subErrorCode > 0) {
logger.info("Active Directory authentication failed: " + subCodeToLogMessage(subErrorCode));
if (convertSubErrorCodesToExceptions) {
raiseExceptionForErrorCode(subErrorCode);
}
} else {
logger.debug("Failed to locate AD-specific sub-error code in message");
}
}
int parseSubErrorCode(String message) {
Matcher m = SUB_ERROR_CODE.matcher(message);
if (m.matches()) {
return Integer.parseInt(m.group(1), 16);
}
return -1;
}
void raiseExceptionForErrorCode(int code) {
switch (code) {
case PASSWORD_EXPIRED:
throw new CredentialsExpiredException(messages.getMessage("LdapAuthenticationProvider.credentialsExpired",
"User credentials have expired"));
case ACCOUNT_DISABLED:
throw new DisabledException(messages.getMessage("LdapAuthenticationProvider.disabled",
"User is disabled"));
case ACCOUNT_EXPIRED:
throw new AccountExpiredException(messages.getMessage("LdapAuthenticationProvider.expired",
"User account has expired"));
case ACCOUNT_LOCKED:
throw new LockedException(messages.getMessage("LdapAuthenticationProvider.locked",
"User account is locked"));
}
}
String subCodeToLogMessage(int code) {
switch (code) {
case USERNAME_NOT_FOUND:
return "User was not found in directory";
case INVALID_PASSWORD:
return "Supplied password was invalid";
case NOT_PERMITTED:
return "User not permitted to logon at this time";
case PASSWORD_EXPIRED:
return "Password has expired";
case ACCOUNT_DISABLED:
return "Account is disabled";
case ACCOUNT_EXPIRED:
return "Account expired";
case PASSWORD_NEEDS_RESET:
return "User must reset password";
case ACCOUNT_LOCKED:
return "Account locked";
}
return "Unknown (error code " + Integer.toHexString(code) +")";
}
private BadCredentialsException badCredentials() {
return new BadCredentialsException(messages.getMessage(
"LdapAuthenticationProvider.badCredentials", "Bad credentials"));
}
private DirContextOperations searchForUser(DirContext ctx, String username) throws NamingException {
SearchControls searchCtls = new SearchControls();
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
String searchFilter = "(&(objectClass=user)(userPrincipalName={0}))";
final String bindPrincipal = createBindPrincipal(username);
final String searchDn = createSearchDn(username);
String searchRoot = rootDn != null ? rootDn : searchRootFromPrincipal(bindPrincipal);
DirContextOperations ctxOp;
try {
ctxOp = SpringSecurityLdapTemplate.searchForSingleEntryInternal(ctx, searchCtls, searchRoot, searchFilter,
new Object[]{searchDn});
if (ctxOp != null) {
return ctxOp;
}
} catch (Exception e) {
logger.warn("UPN " + searchDn + " not found. Falling back to search with domain UPN suffix.");
}
return SpringSecurityLdapTemplate.searchForSingleEntryInternal(ctx, searchCtls, searchRoot, searchFilter,
new Object[]{bindPrincipal});
}
private String searchRootFromPrincipal(String bindPrincipal) {
int atChar = bindPrincipal.lastIndexOf('@');
if (atChar < 0) {
logger.debug("User principal '" + bindPrincipal + "' does not contain the domain, and no domain has been configured");
throw badCredentials();
}
return rootDnFromDomain(bindPrincipal.substring(atChar+ 1, bindPrincipal.length()));
}
private String rootDnFromDomain(String domain) {
String[] tokens = StringUtils.tokenizeToStringArray(domain, ".");
StringBuilder root = new StringBuilder();
for (String token : tokens) {
if (root.length() > 0) {
root.append(',');
}
root.append("dc=").append(token);
}
return root.toString();
}
String createBindPrincipal(String username) {
if (domain == null || username.toLowerCase().endsWith(domain)) {
return username;
}
return username + "@" + domain;
}
String createSearchDn(String username) {
if (upnSuffix == null) {
return createBindPrincipal(username);
}
return username + "@" + upnSuffix;
}
/**
* By default, a failed authentication (LDAP error 49) will result in a {@code BadCredentialsException}.
* <p>
* If this property is set to {@code true}, the exception message from a failed bind attempt will be parsed
* for the AD-specific error code and a {@link CredentialsExpiredException}, {@link DisabledException},
* {@link AccountExpiredException} or {@link LockedException} will be thrown for the corresponding codes. All
* other codes will result in the default {@code BadCredentialsException}.
*
* @param convertSubErrorCodesToExceptions {@code true} to raise an exception based on the AD error code.
*/
public void setConvertSubErrorCodesToExceptions(boolean convertSubErrorCodesToExceptions) {
this.convertSubErrorCodesToExceptions = convertSubErrorCodesToExceptions;
}
static class ContextFactory {
DirContext createContext(Hashtable<?,?> env) throws NamingException {
return new InitialLdapContext(env, null);
}
}
}

@ -1,9 +0,0 @@
package info.bukova.isspst.security;
public enum AuthMethod {
DATABASE,
LDAP,
AD
}

@ -5,6 +5,9 @@ import info.bukova.isspst.data.User;
import info.bukova.isspst.services.users.LdapUserImporter;
import info.bukova.isspst.services.users.RoleService;
import info.bukova.isspst.services.users.UserService;
import java.util.Collection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ldap.core.DirContextOperations;
@ -12,8 +15,6 @@ import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.ldap.userdetails.LdapAuthoritiesPopulator;
import java.util.Collection;
public class AuthPopulator implements LdapAuthoritiesPopulator {
private UserService userService;
@ -22,15 +23,13 @@ public class AuthPopulator implements LdapAuthoritiesPopulator {
public AuthPopulator(UserService userService, RoleService roleService) {
this.userService = userService;
this.roleService = roleService;
userService.setAuthMethod(AuthMethod.LDAP);
}
@Override
public Collection<? extends GrantedAuthority> getGrantedAuthorities(
DirContextOperations userData, String login) {
User user;
User user = null;
try {
user = (User) userService.loadUserByUsername(login);
} catch (UsernameNotFoundException e) {

@ -7,6 +7,16 @@ import info.bukova.isspst.data.UserSettingsData;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.users.UserService;
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.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -14,14 +24,6 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
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 {
@Autowired
@ -43,7 +45,6 @@ public class LoginSuccessHandler extends SavedRequestAwareAuthenticationSuccessH
logger.info("User " + u.getUsername() + " logged in");
sessionData.setUserCentres(workgroupService.getUserCentres((User) auth.getPrincipal()));
sessionData.setUserOnlyCentres(workgroupService.getUserCentres((User) auth.getPrincipal(), true));
sessionData.setUserWorkgroups(workgroupService.getUserWorkgroups((User) auth.getPrincipal()));
workgroupService.loadParents(u);
sessionData.setCurrentUser(u);

@ -1,13 +1,11 @@
package info.bukova.isspst.security;
import info.bukova.isspst.Constants;
import info.bukova.isspst.Module;
import info.bukova.isspst.data.Permission;
import info.bukova.isspst.data.PermissionType;
import info.bukova.isspst.data.Role;
import info.bukova.isspst.data.User;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.Service;
import info.bukova.isspst.services.workgroups.WorkgroupService;
import java.util.List;
@ -41,31 +39,11 @@ public class WorkgroupAwareServiceEvaluator implements Evaluator {
}
User user = (User)authentication.getPrincipal();
String moduleId = "";
if (targetDomainObject instanceof Service<?>) {
Service<?> service = (Service<?>)targetDomainObject;
Module mod = service.getModule();
if (mod != null) {
moduleId = mod.getId();
}
}
// TODO - v master větvi je na toto pomocná třída
/*for (Module m : Constants.MODULES) {
if (m.getServiceClass() != null && m.getServiceClass().isAssignableFrom(targetDomainObject.getClass())) {
moduleId = m.getId();
break;
}
}*/
Permission appPermission = null;
for (Permission p : Constants.SPECIAL_PERMISSIONS) {
if (p.getAuthority().equals(permission)
&& p.getModule().equals(moduleId)) {
if (p.getAuthority().equals(permission)) {
appPermission = p;
break;
}
}
@ -88,8 +66,7 @@ public class WorkgroupAwareServiceEvaluator implements Evaluator {
for (Role r : wgRoles) {
for (Permission p : r.getPermissions()) {
if (p.getAuthority().equals(appPermission.getAuthority())
&& p.getModule().equals(appPermission.getModule())) {
if (p.getAuthority().equals(appPermission.getAuthority())) {
return true;
}
}

@ -1,7 +1,7 @@
package info.bukova.isspst.services;
import info.bukova.isspst.data.OwnedDataModel;
import info.bukova.isspst.data.User;
import java.util.Date;
import org.hibernate.NonUniqueResultException;
import org.hibernate.Query;
import org.springframework.security.access.prepost.PreAuthorize;
@ -9,7 +9,8 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import info.bukova.isspst.data.OwnedDataModel;
import info.bukova.isspst.data.User;
public class AbstractOwnedService<T extends OwnedDataModel> extends AbstractService<T> {
@ -31,7 +32,6 @@ public class AbstractOwnedService<T extends OwnedDataModel> extends AbstractServ
entity.setModifiedBy(getLoggedInUser());
entity.setModified(new Date());
dao.modify(entity);
maintainStorrage();
}
@Transactional

@ -1,7 +1,8 @@
package info.bukova.isspst.services;
import static ch.lambdaj.Lambda.filter;
import info.bukova.isspst.Constants;
import info.bukova.isspst.Module;
import info.bukova.isspst.ModuleUtils;
import info.bukova.isspst.SessionData;
import info.bukova.isspst.dao.BaseDao;
import info.bukova.isspst.dao.QueryDao;
@ -10,26 +11,23 @@ import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.filters.Filter;
import info.bukova.isspst.reporting.Report;
import info.bukova.isspst.services.numberseries.NumberSeriesService;
import info.bukova.isspst.storage.DocumentFileStorage;
import org.hibernate.NonUniqueResultException;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.GenericTypeResolver;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Set;
import static ch.lambdaj.Lambda.filter;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import org.hibernate.NonUniqueResultException;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
public abstract class AbstractService<T extends DataModel> implements Service<T> {
@ -38,29 +36,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
@Autowired
protected SessionData sessionData;
@Autowired
protected HqlDataFilter hqlFilter;
@Autowired
protected QueryDao queryDao;
private DocumentFileStorage documentFileStorage;
private NumberSeriesService numberSeriesService;
private Class<T> entityClass;
public AbstractService() {
entityClass = (Class<T>) GenericTypeResolver.resolveTypeArgument(getClass(), AbstractService.class);
}
@Override
public List<Class<?>> getEntityClasses() {
List<Class<?>> classes = new ArrayList<Class<?>>();
classes.add(entityClass);
return classes;
}
public void setDocumentFileStorage(DocumentFileStorage storage) {
this.documentFileStorage = storage;
}
public NumberSeriesService getNumberSeriesService()
{
@ -80,60 +59,6 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
return "";
}
public String getDeleteEntityPermission() {
return "";
}
protected void maintainStorrage() {
if (documentFileStorage != null) {
documentFileStorage.purge();
}
}
protected Query filterQuery(Query q) {
return filterQuery(q, null);
}
protected Query filterQuery(Query q, HqlDataFilter aditFilter) {
HqlDataFilter f = hqlFilter;
try {
if (((f.getWhere() == null || f.getWhere().isEmpty())
&& (f.getOrderBy() == null || f.getOrderBy().isEmpty()))
&& ((aditFilter.getWhere() == null || aditFilter.getWhere().isEmpty())
&& (aditFilter.getOrderBy() == null || aditFilter.getOrderBy().isEmpty()))) {
return q;
}
} catch (Exception e) {
f = new HqlDataFilter(); // pri volani mimo web request filtr z requestu neresime
}
boolean isAplicable = false;
if (f.getDataClass() != null) {
for (Class<?> clazz : getEntityClasses()) {
if (f.getDataClass().isAssignableFrom(clazz)) {
isAplicable = true;
}
}
}
String hql;
if (isAplicable) {
hql = HqlUtils.buildHql(q.getQueryString(), f);
} else {
hql = q.getQueryString();
}
hql = HqlUtils.addOrderBy(HqlUtils.addAndWhere(hql, aditFilter), aditFilter);
Query newQuery = dao.getQuery(hql);
if (isAplicable) {
HqlUtils.addParameters(newQuery, f);
}
HqlUtils.addParameters(newQuery, aditFilter);
return newQuery;
}
@Override
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
public final T create() {
@ -148,10 +73,6 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new IsspstException("DAO is null");
}
if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
validate(entity);
entity.setCreated(new Date());
dao.add(entity);
@ -165,31 +86,20 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new IsspstException("DAO is null");
}
if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
validate(entity);
entity.setModified(new Date());
dao.modify(entity);
maintainStorrage();
}
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_DELETE') or hasPermission(#entity, this.getDeleteEntityPermission())")
@PreAuthorize("hasPermission(this, 'PERM_DELETE')")
public void delete(T entity) {
if (dao == null) {
throw new IsspstException("DAO is null");
}
if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
dao.delete(entity);
maintainStorrage(); // poklidit přiložené soubory
}
@Override
@ -227,10 +137,6 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new IsspstException("DAO is null");
}
if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
return dao.getById(id);
}
@ -242,13 +148,7 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new IsspstException("DAO is null");
}
if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
Query q = dao.getQuery("from " + dao.getEntityName());
return filterQuery(q).list();
return dao.getAll();
}
@Override
@ -259,10 +159,6 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new IsspstException("DAO is null");
}
if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
return dao.execQuery(query);
}
@ -275,10 +171,6 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new IsspstException("DAO is null");
}
if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException();
}
try {
Query q = dao.getQuery(query);
return (T) q.uniqueResult();
@ -297,7 +189,13 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
@Override
public Module getModule() {
return ModuleUtils.getModule(this.getClass());
for (Module m : Constants.MODULES) {
if (Arrays.asList(this.getClass().getInterfaces()).contains(m.getServiceClass())) {
return m;
}
}
return null;
}
public List<Report> getReports() {
@ -336,10 +234,6 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
@Override
@Transactional
public void loadLazyData(String group, T entity) {
if (entity == null) {
return;
}
Method[] methods = this.getClass().getMethods();
for (Method m : methods) {
@ -362,9 +256,4 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
}
}
}
@Override
public boolean canPrintRecord(T entity) {
return true;
}
}

@ -1,87 +0,0 @@
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;
}
}

@ -1,90 +0,0 @@
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;
}
}

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

Loading…
Cancel
Save