Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 885e20a400 |
@@ -202,6 +202,12 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- DB -->
|
<!-- DB -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>postgresql</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
<version>9.1-901-1.jdbc4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
@@ -215,20 +221,16 @@
|
|||||||
|
|
||||||
<!-- Hibernate -->
|
<!-- Hibernate -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-core</artifactId>
|
<artifactId>hibernate-core</artifactId>
|
||||||
<version>4.2.8.Final</version>
|
<version>4.2.8.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-validator</artifactId>
|
<artifactId>hibernate-validator</artifactId>
|
||||||
<version>4.3.0.Final</version>
|
<version>4.3.0.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-search</artifactId>
|
|
||||||
<version>4.4.6.Final</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- ZK -->
|
<!-- ZK -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -349,19 +351,6 @@
|
|||||||
<version>2.4</version>
|
<version>2.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Text extractors -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.odftoolkit</groupId>
|
|
||||||
<artifactId>simple-odf</artifactId>
|
|
||||||
<version>0.7-incubating</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi-ooxml</artifactId>
|
|
||||||
<version>3.11</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Test -->
|
<!-- Test -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import info.bukova.isspst.data.User;
|
|||||||
import info.bukova.isspst.reporting.Report;
|
import info.bukova.isspst.reporting.Report;
|
||||||
import info.bukova.isspst.reporting.ReportMapping;
|
import info.bukova.isspst.reporting.ReportMapping;
|
||||||
import info.bukova.isspst.reporting.ReportType;
|
import info.bukova.isspst.reporting.ReportType;
|
||||||
import info.bukova.isspst.services.dbinfo.DbInfoService;
|
|
||||||
import info.bukova.isspst.services.fulltext.FullTextService;
|
|
||||||
import info.bukova.isspst.services.munits.MUnitService;
|
import info.bukova.isspst.services.munits.MUnitService;
|
||||||
import info.bukova.isspst.services.numberseries.NumberSeriesService;
|
import info.bukova.isspst.services.numberseries.NumberSeriesService;
|
||||||
import info.bukova.isspst.services.requirement.RequirementTypeService;
|
import info.bukova.isspst.services.requirement.RequirementTypeService;
|
||||||
@@ -20,21 +18,21 @@ import info.bukova.isspst.services.settings.GlobalSettingsService;
|
|||||||
import info.bukova.isspst.services.users.PermissionService;
|
import info.bukova.isspst.services.users.PermissionService;
|
||||||
import info.bukova.isspst.services.users.RoleService;
|
import info.bukova.isspst.services.users.RoleService;
|
||||||
import info.bukova.isspst.services.users.UserService;
|
import info.bukova.isspst.services.users.UserService;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContextEvent;
|
||||||
|
import javax.servlet.ServletContextListener;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||||
|
|
||||||
import javax.servlet.ServletContextEvent;
|
|
||||||
import javax.servlet.ServletContextListener;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class AppInitListener implements ServletContextListener {
|
public class AppInitListener implements ServletContextListener {
|
||||||
|
|
||||||
|
|
||||||
private DbInfoService dbInfoService;
|
|
||||||
private MUnitService mUnitsService;
|
private MUnitService mUnitsService;
|
||||||
private RoleService roleService;
|
private RoleService roleService;
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@@ -42,7 +40,6 @@ public class AppInitListener implements ServletContextListener {
|
|||||||
private NumberSeriesService nsService;
|
private NumberSeriesService nsService;
|
||||||
private RequirementTypeService reqTypeService;
|
private RequirementTypeService reqTypeService;
|
||||||
private GlobalSettingsService gSettingsService;
|
private GlobalSettingsService gSettingsService;
|
||||||
private FullTextService ftService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void contextDestroyed(ServletContextEvent arg0) {
|
public void contextDestroyed(ServletContextEvent arg0) {
|
||||||
@@ -51,11 +48,10 @@ public class AppInitListener implements ServletContextListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void contextInitialized(ServletContextEvent evt) {
|
public void contextInitialized(ServletContextEvent evt) {
|
||||||
Logger logger = LoggerFactory.getLogger(AppInitListener.class);
|
/*Logger logger = LoggerFactory.getLogger(AppInitListener.class);
|
||||||
logger.info("Initializing database");
|
logger.info("Initializing database");
|
||||||
|
|
||||||
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(evt.getServletContext());
|
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(evt.getServletContext());
|
||||||
dbInfoService = ctx.getBean(DbInfoService.class);
|
|
||||||
mUnitsService = ctx.getBean(MUnitService.class);
|
mUnitsService = ctx.getBean(MUnitService.class);
|
||||||
roleService = ctx.getBean(RoleService.class);
|
roleService = ctx.getBean(RoleService.class);
|
||||||
userService = ctx.getBean(UserService.class);
|
userService = ctx.getBean(UserService.class);
|
||||||
@@ -63,10 +59,8 @@ public class AppInitListener implements ServletContextListener {
|
|||||||
nsService =ctx.getBean(NumberSeriesService.class);
|
nsService =ctx.getBean(NumberSeriesService.class);
|
||||||
gSettingsService = ctx.getBean(GlobalSettingsService.class);
|
gSettingsService = ctx.getBean(GlobalSettingsService.class);
|
||||||
reqTypeService = ctx.getBean(RequirementTypeService.class);
|
reqTypeService = ctx.getBean(RequirementTypeService.class);
|
||||||
ftService = ctx.getBean(FullTextService.class);
|
|
||||||
|
|
||||||
userService.grantAdmin();
|
userService.grantAdmin();
|
||||||
this.checkDbInfo();
|
|
||||||
checkMUnits();
|
checkMUnits();
|
||||||
checkRoles();
|
checkRoles();
|
||||||
checkUsers();
|
checkUsers();
|
||||||
@@ -75,31 +69,9 @@ public class AppInitListener implements ServletContextListener {
|
|||||||
this.checkNumberSeries();
|
this.checkNumberSeries();
|
||||||
checkReqTypes();
|
checkReqTypes();
|
||||||
this.checkGlobalSettings();
|
this.checkGlobalSettings();
|
||||||
buildFulltext();
|
|
||||||
userService.removeAccess();
|
userService.removeAccess();
|
||||||
|
|
||||||
loadModuleReports();
|
loadModuleReports();*/
|
||||||
}
|
|
||||||
|
|
||||||
private void buildFulltext() {
|
|
||||||
ftService.reindex();
|
|
||||||
}
|
|
||||||
private void checkDbInfo()
|
|
||||||
{
|
|
||||||
List<User> userList = userService.getAll();
|
|
||||||
|
|
||||||
if (userList.isEmpty())
|
|
||||||
{
|
|
||||||
// Database is new/empty, column definition is anotated - set actual
|
|
||||||
// database version
|
|
||||||
dbInfoService.updateDatabaseVersion();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Existing database - try change structure and set actual database
|
|
||||||
// version...
|
|
||||||
dbInfoService.changeDatabase();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkMUnits()
|
private void checkMUnits()
|
||||||
@@ -228,9 +200,6 @@ public class AppInitListener implements ServletContextListener {
|
|||||||
|
|
||||||
private void checkPermissions() {
|
private void checkPermissions() {
|
||||||
for (Module m : Constants.MODULES) {
|
for (Module m : Constants.MODULES) {
|
||||||
if (!m.isDefaultPermissions()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (Permission p : Constants.DEF_PERMISSIONS) {
|
for (Permission p : Constants.DEF_PERMISSIONS) {
|
||||||
if (permService.getPermissionByModule(m.getId(), p.getAuthority()) == null) {
|
if (permService.getPermissionByModule(m.getId(), p.getAuthority()) == null) {
|
||||||
p.setModule(m.getId());
|
p.setModule(m.getId());
|
||||||
|
|||||||
@@ -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,23 +1,16 @@
|
|||||||
package info.bukova.isspst;
|
package info.bukova.isspst;
|
||||||
|
|
||||||
import info.bukova.isspst.data.Order;
|
|
||||||
import info.bukova.isspst.data.Permission;
|
import info.bukova.isspst.data.Permission;
|
||||||
import info.bukova.isspst.data.PermissionType;
|
import info.bukova.isspst.data.PermissionType;
|
||||||
import info.bukova.isspst.data.Requirement;
|
|
||||||
import info.bukova.isspst.data.RequirementType;
|
import info.bukova.isspst.data.RequirementType;
|
||||||
import info.bukova.isspst.data.Role;
|
import info.bukova.isspst.data.Role;
|
||||||
import info.bukova.isspst.data.TripBill;
|
|
||||||
import info.bukova.isspst.data.TripBillApproval;
|
|
||||||
import info.bukova.isspst.data.TripRequirement;
|
|
||||||
import info.bukova.isspst.reporting.Report;
|
import info.bukova.isspst.reporting.Report;
|
||||||
import info.bukova.isspst.reporting.ReportMapping;
|
import info.bukova.isspst.reporting.ReportMapping;
|
||||||
import info.bukova.isspst.services.addressbook.AdbService;
|
import info.bukova.isspst.services.addressbook.AdbService;
|
||||||
|
import info.bukova.isspst.services.approved.ApprovedService;
|
||||||
|
import info.bukova.isspst.services.approved.OrderService;
|
||||||
import info.bukova.isspst.services.buildings.BuildingService;
|
import info.bukova.isspst.services.buildings.BuildingService;
|
||||||
import info.bukova.isspst.services.fulltext.FullTextService;
|
|
||||||
import info.bukova.isspst.services.invoicing.InvoicingService;
|
|
||||||
import info.bukova.isspst.services.munits.MUnitService;
|
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.MaterialService;
|
||||||
import info.bukova.isspst.services.reqsubjects.ServiceItemService;
|
import info.bukova.isspst.services.reqsubjects.ServiceItemService;
|
||||||
import info.bukova.isspst.services.requirement.RequirementService;
|
import info.bukova.isspst.services.requirement.RequirementService;
|
||||||
@@ -28,14 +21,8 @@ import info.bukova.isspst.services.users.RoleService;
|
|||||||
import info.bukova.isspst.services.users.UserService;
|
import info.bukova.isspst.services.users.UserService;
|
||||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Constants {
|
public class Constants {
|
||||||
|
|
||||||
public final static long DB_VERSION = 5;
|
|
||||||
|
|
||||||
public final static String DEF_ADMIN = "admin";
|
public final static String DEF_ADMIN = "admin";
|
||||||
public final static String DEF_ADMIN_PASSWD = "admin";
|
public final static String DEF_ADMIN_PASSWD = "admin";
|
||||||
public final static String ROLE_USER = "ROLE_USER";
|
public final static String ROLE_USER = "ROLE_USER";
|
||||||
@@ -84,8 +71,6 @@ public class Constants {
|
|||||||
public final static String MOD_TRIPBILL = "TRIPBILL";
|
public final static String MOD_TRIPBILL = "TRIPBILL";
|
||||||
public final static String MOD_APPROVED = "APPROVED";
|
public final static String MOD_APPROVED = "APPROVED";
|
||||||
public final static String MOD_ORDER = "ORDER";
|
public final static String MOD_ORDER = "ORDER";
|
||||||
public final static String MOD_INVOICING = "INVOICING";
|
|
||||||
public final static String MOD_SEARCH = "SEARCH";
|
|
||||||
public final static Module MODULES[] = {
|
public final static Module MODULES[] = {
|
||||||
new Module(MOD_USERS, "Uživatelé", UserService.class),
|
new Module(MOD_USERS, "Uživatelé", UserService.class),
|
||||||
new Module(MOD_PERMISSIONS, "Práva", RoleService.class),
|
new Module(MOD_PERMISSIONS, "Práva", RoleService.class),
|
||||||
@@ -100,10 +85,7 @@ public class Constants {
|
|||||||
new Module(MOD_WORKFLOW, "Procesy schválení", RequirementTypeService.class),
|
new Module(MOD_WORKFLOW, "Procesy schválení", RequirementTypeService.class),
|
||||||
new Module(MOD_TRIPBILL, "Cestovní příkazy", TripBillService.class),
|
new Module(MOD_TRIPBILL, "Cestovní příkazy", TripBillService.class),
|
||||||
new Module(MOD_APPROVED, "Schválené položky požadavků", ApprovedService.class),
|
new Module(MOD_APPROVED, "Schválené položky požadavků", ApprovedService.class),
|
||||||
new Module(MOD_ORDER, "Objednávky", OrderService.class),
|
new Module(MOD_ORDER, "Objednávky", OrderService.class) };
|
||||||
new Module(MOD_INVOICING, "Fakturace požadavků", InvoicingService.class),
|
|
||||||
new Module(MOD_SEARCH, "Fulltextové vyhledávání", FullTextService.class, true, false),
|
|
||||||
};
|
|
||||||
|
|
||||||
public final static String PERM_APPROVE = "PERM_APPROVE";
|
public final static String PERM_APPROVE = "PERM_APPROVE";
|
||||||
public final static String PERM_SHOW_WORKGROUP_REQ = "PERM_SHOW_WORKGROUP_REQ";
|
public final static String PERM_SHOW_WORKGROUP_REQ = "PERM_SHOW_WORKGROUP_REQ";
|
||||||
@@ -111,25 +93,19 @@ public class Constants {
|
|||||||
public final static String PERM_SHOW_ALL_REQ = "PERM_SHOW_ALL_REQ";
|
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_NEW = "PERM_EDIT_NEW";
|
||||||
public final static String PERM_EDIT_OWN = "PERM_EDIT_OWN";
|
public final static String PERM_EDIT_OWN = "PERM_EDIT_OWN";
|
||||||
public final static String PERM_DELETE_NEW = "PERM_DELETE_NEW";
|
|
||||||
public final static String PERM_SEARCH = "PERM_SEARCH";
|
|
||||||
|
|
||||||
public final static Permission SPECIAL_PERMISSIONS[] = {
|
public final static Permission SPECIAL_PERMISSIONS[] = {
|
||||||
new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_REQUIREMENTS, PermissionType.GLOBAL),
|
new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_REQUIREMENTS, PermissionType.GLOBAL),
|
||||||
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_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_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_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_APPROVE, "Schválení", MOD_REQUIREMENTS, PermissionType.WORKGROUP),
|
||||||
|
|
||||||
new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL),
|
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_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_CENTRE_REQ, "Zobrazení požadavků střediska", MOD_TRIPREQUIREMENTS, PermissionType.CENTRE),
|
||||||
new Permission(PERM_SHOW_ALL_REQ, "Zobrazení všech požadavků", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL),
|
new Permission(PERM_SHOW_ALL_REQ, "Zobrazení všech požadavků", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL),
|
||||||
new Permission(PERM_APPROVE, "Schválení", MOD_TRIPREQUIREMENTS, PermissionType.WORKGROUP),
|
new Permission(PERM_APPROVE, "Schválení", MOD_TRIPREQUIREMENTS, PermissionType.WORKGROUP),
|
||||||
|
|
||||||
new Permission(PERM_SEARCH, "Vyhledávat", MOD_SEARCH, PermissionType.GLOBAL),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public final static String DYNAMIC_REPORT_NAME = "Tabulková sestava";
|
public final static String DYNAMIC_REPORT_NAME = "Tabulková sestava";
|
||||||
@@ -137,9 +113,8 @@ public class Constants {
|
|||||||
new ReportMapping(MOD_ADDRESSBOOK, new Report("Adresní karty", "address")),
|
new ReportMapping(MOD_ADDRESSBOOK, new Report("Adresní karty", "address")),
|
||||||
new ReportMapping(MOD_ADDRESSBOOK, new Report("Adresa", "address", false, true)),
|
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("Žádost", "tripRequirement", false, true)),
|
||||||
new ReportMapping(MOD_TRIPBILL, new Report("Vyúčtování", "tripBill", false, true, true)),
|
new ReportMapping(MOD_TRIPBILL, new Report("Vyúčtování", "tripBill", false, true)),
|
||||||
new ReportMapping(MOD_ORDER, new Report("Objednávka", "order", true, true)),
|
new ReportMapping(MOD_ORDER, new Report("Objednávka", "order", true, true))
|
||||||
new ReportMapping(MOD_REQUIREMENTS, new Report("Požadavky", "requirements"))
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public final static String REQTYPE_ORDER = "ORDER";
|
public final static String REQTYPE_ORDER = "ORDER";
|
||||||
@@ -151,17 +126,4 @@ public class Constants {
|
|||||||
|
|
||||||
public final static long REQ_TYPE_MATERIAL = 1;
|
public final static long REQ_TYPE_MATERIAL = 1;
|
||||||
public final static long REQ_TYPE_SERVICES = 2;
|
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/requirements/");
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package info.bukova.isspst;
|
|
||||||
|
|
||||||
public interface EntityUrlResolver {
|
|
||||||
|
|
||||||
public String entityUrl(Object entity);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,26 +1,16 @@
|
|||||||
package info.bukova.isspst;
|
package info.bukova.isspst;
|
||||||
|
|
||||||
import info.bukova.isspst.reporting.Report;
|
import info.bukova.isspst.reporting.Report;
|
||||||
import info.bukova.isspst.services.AbstractService;
|
|
||||||
import info.bukova.isspst.services.ModuleNotActiveException;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*
|
|
||||||
* Třída reprezentuje informace o modulu (agendě).
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class Module {
|
public class Module {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String name;
|
private String name;
|
||||||
private Class<?> serviceClass;
|
private Class<?> serviceClass;
|
||||||
private List<Report> reports;
|
private List<Report> reports;
|
||||||
private boolean defaultPermissions;
|
|
||||||
private boolean active;
|
|
||||||
|
|
||||||
public Class<?> getServiceClass() {
|
public Class<?> getServiceClass() {
|
||||||
return serviceClass;
|
return serviceClass;
|
||||||
@@ -30,42 +20,11 @@ public class Module {
|
|||||||
this.serviceClass = serviceClass;
|
this.serviceClass = serviceClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param id identifikátor modulu
|
|
||||||
* @param name jméno zobrazované v aplikaci
|
|
||||||
* @param serviceClass servisní třída
|
|
||||||
*/
|
|
||||||
public Module(String id, String name, Class<?> serviceClass) {
|
public Module(String id, String name, Class<?> serviceClass) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.serviceClass = serviceClass;
|
this.serviceClass = serviceClass;
|
||||||
reports = new ArrayList<Report>();
|
reports = new ArrayList<Report>();
|
||||||
defaultPermissions = true;
|
|
||||||
active = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param id identifikátor modulu
|
|
||||||
* @param name jméno zobrazované v aplikaci
|
|
||||||
* @param serviceClass servisní třída
|
|
||||||
* @param active příznak, jestli je modul aktivní
|
|
||||||
*/
|
|
||||||
public Module(String id, String name, Class<?> serviceClass, boolean active) {
|
|
||||||
this(id, name, serviceClass);
|
|
||||||
this.active = active;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param id identifikátor modulu
|
|
||||||
* @param name jméno zobrazované v aplikaci
|
|
||||||
* @param serviceClass servisní třída
|
|
||||||
* @param active příznak, jestli je modul aktivní.
|
|
||||||
* @param defaultPermissions příznak určující jestli modul kontroluje výchozí práva (čtení, zápis, modifikace, mazání)
|
|
||||||
*/
|
|
||||||
public Module(String id, String name, Class<?> serviceClass, boolean active, boolean defaultPermissions) {
|
|
||||||
this(id, name, serviceClass, active);
|
|
||||||
this.defaultPermissions = defaultPermissions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
@@ -92,33 +51,4 @@ public class Module {
|
|||||||
this.reports.add(report);
|
this.reports.add(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Pokud je true, modul kontroluje výchozí práva (čtení, zápis, modifikace, mazání). Má vliv
|
|
||||||
* na generování formulářů v nastavení práv.
|
|
||||||
*
|
|
||||||
* @return výchozí práva. Default true
|
|
||||||
*/
|
|
||||||
public boolean isDefaultPermissions() {
|
|
||||||
return defaultPermissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultPermissions(boolean defaultPermissions) {
|
|
||||||
this.defaultPermissions = defaultPermissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Určuje, zda je modul aktivní. Neaktivní moduly nejsou viditelné v UI. Při pokusu o přístup přímo přes URL
|
|
||||||
* se generuje výjimka {@link ModuleNotActiveException}. Pokud servisní třída modulu nedědí z {@link AbstractService},
|
|
||||||
* musí se implementovat kontrola aktivity do příslušné třídy.
|
|
||||||
*
|
|
||||||
* @return aktivita. Default true
|
|
||||||
*/
|
|
||||||
public boolean isActive() {
|
|
||||||
return active;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActive(boolean active) {
|
|
||||||
this.active = active;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
package info.bukova.isspst;
|
|
||||||
|
|
||||||
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 boolean isActive(String id) {
|
|
||||||
return getModule(id).isActive();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,28 +1,18 @@
|
|||||||
package info.bukova.isspst;
|
package info.bukova.isspst;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.zkoss.util.resource.Labels;
|
import org.zkoss.util.resource.Labels;
|
||||||
|
|
||||||
public class StringUtils
|
public class StringUtils
|
||||||
{
|
{
|
||||||
public static boolean isNullOrEmpty(String str)
|
|
||||||
{
|
|
||||||
return ((str == null) || (str.isEmpty()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isNullOrTrimmedEmpty(String str)
|
private static String nullStr(String str)
|
||||||
{
|
|
||||||
return ((str == null) || (str.trim().isEmpty()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String nullToEmptyString(String str)
|
|
||||||
{
|
{
|
||||||
return str == null ? "" : str;
|
return str == null ? "" : str;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String zeroToEmptyString(long i)
|
private static String not0ToStr(long i)
|
||||||
{
|
{
|
||||||
return i == 0 ? "" : String.valueOf(i);
|
return i == 0 ? "" : String.valueOf(i);
|
||||||
}
|
}
|
||||||
@@ -70,8 +60,8 @@ public class StringUtils
|
|||||||
|
|
||||||
public static boolean isEqualForFilter(String value, String search)
|
public static boolean isEqualForFilter(String value, String search)
|
||||||
{
|
{
|
||||||
value = StringUtils.nullToEmptyString(value).toLowerCase();
|
value = StringUtils.nullStr(value).toLowerCase();
|
||||||
search = StringUtils.nullToEmptyString(search).toLowerCase();
|
search = StringUtils.nullStr(search).toLowerCase();
|
||||||
|
|
||||||
if (search.isEmpty())
|
if (search.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -83,8 +73,8 @@ public class StringUtils
|
|||||||
|
|
||||||
public static boolean isIcEqualForFilter(long value, long search)
|
public static boolean isIcEqualForFilter(long value, long search)
|
||||||
{
|
{
|
||||||
String compareValue = StringUtils.zeroToEmptyString(value);
|
String compareValue = StringUtils.not0ToStr(value);
|
||||||
String searchValue = StringUtils.zeroToEmptyString(search);
|
String searchValue = StringUtils.not0ToStr(search);
|
||||||
return compareValue.startsWith(searchValue);
|
return compareValue.startsWith(searchValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +124,7 @@ public class StringUtils
|
|||||||
|
|
||||||
for (int i = 0; i < list.size(); i++)
|
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 = StringUtils.addSeparator(result, separator);
|
||||||
result += item;
|
result += item;
|
||||||
}
|
}
|
||||||
@@ -148,7 +138,7 @@ public class StringUtils
|
|||||||
|
|
||||||
for (int i = 0; i < list.size(); i++)
|
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())
|
if (!item.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -159,47 +149,4 @@ public class StringUtils
|
|||||||
|
|
||||||
return result;
|
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).getBill().getRequirement().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,8 +0,0 @@
|
|||||||
package info.bukova.isspst.dao;
|
|
||||||
|
|
||||||
import info.bukova.isspst.data.RequirementItem;
|
|
||||||
|
|
||||||
public interface RequirementItemDao extends BaseDao<RequirementItem>
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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,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.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;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
import info.bukova.isspst.StringUtils;
|
import info.bukova.isspst.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -46,7 +45,7 @@ public class Address extends BaseData
|
|||||||
private String email;
|
private String email;
|
||||||
@Column(name = "WEB")
|
@Column(name = "WEB")
|
||||||
private String web;
|
private String web;
|
||||||
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
@Column(name = "DESCRIPTION")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@NotNull(message = "Zadejte firmu")
|
@NotNull(message = "Zadejte firmu")
|
||||||
|
|||||||
@@ -7,18 +7,11 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.persistence.Embeddable;
|
import javax.persistence.Embeddable;
|
||||||
|
|
||||||
import org.hibernate.search.annotations.Analyze;
|
|
||||||
import org.hibernate.search.annotations.Field;
|
|
||||||
import org.hibernate.search.annotations.Index;
|
|
||||||
import org.hibernate.search.annotations.Indexed;
|
|
||||||
|
|
||||||
@Embeddable
|
@Embeddable
|
||||||
@Indexed
|
|
||||||
public class AddressEmb
|
public class AddressEmb
|
||||||
{
|
{
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String company;
|
private String company;
|
||||||
private String department;
|
private String department;
|
||||||
private String contactName;
|
private String contactName;
|
||||||
|
|||||||
@@ -11,11 +11,7 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
import org.hibernate.search.annotations.Indexed;
|
|
||||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
@Indexed
|
|
||||||
public abstract class BaseData implements OwnedDataModel {
|
public abstract class BaseData implements OwnedDataModel {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@@ -28,11 +24,9 @@ public abstract class BaseData implements OwnedDataModel {
|
|||||||
private Date modified;
|
private Date modified;
|
||||||
@ManyToOne(fetch=FetchType.LAZY)
|
@ManyToOne(fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name="OWNED_BY_ID")
|
@JoinColumn(name="OWNED_BY_ID")
|
||||||
@IndexedEmbedded
|
|
||||||
private User ownedBy;
|
private User ownedBy;
|
||||||
@ManyToOne(fetch=FetchType.LAZY)
|
@ManyToOne(fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name="MODIFIED_BY_ID")
|
@JoinColumn(name="MODIFIED_BY_ID")
|
||||||
@IndexedEmbedded
|
|
||||||
private User modifiedBy;
|
private User modifiedBy;
|
||||||
@Transient
|
@Transient
|
||||||
private boolean valid;
|
private boolean valid;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -25,7 +23,7 @@ public class Building extends BaseData implements DataModel {
|
|||||||
@Column(name = "NAME")
|
@Column(name = "NAME")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
@Column(name = "DESCRIPTION")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "building", orphanRemoval = true)
|
@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,78 +0,0 @@
|
|||||||
package info.bukova.isspst.data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.FetchType;
|
|
||||||
import javax.persistence.JoinColumn;
|
|
||||||
import javax.persistence.OneToMany;
|
|
||||||
import javax.persistence.OneToOne;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "INVOICING")
|
|
||||||
public class Invoicing extends BaseData implements Cloneable
|
|
||||||
{
|
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
|
|
||||||
@JoinColumn(name = "REQUIREMENT_ID")
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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,7 +1,5 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -222,23 +220,6 @@ public class JoinedItem implements DataModel, FilterableRequirement
|
|||||||
this.ownedBy = owner;
|
this.ownedBy = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Boolean itemMaterial;
|
|
||||||
|
|
||||||
public boolean isItemMaterialReal()
|
|
||||||
{
|
|
||||||
return ((this.requirement != null) && (this.requirement.getKind() == Constants.REQ_TYPE_MATERIAL));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getItemMaterial()
|
|
||||||
{
|
|
||||||
return this.itemMaterial;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItemMaterial(Boolean value)
|
|
||||||
{
|
|
||||||
this.itemMaterial = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
import info.bukova.isspst.StringUtils;
|
import info.bukova.isspst.StringUtils;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@@ -14,7 +13,7 @@ public class MUnit extends BaseData
|
|||||||
@Column(name = "NAME")
|
@Column(name = "NAME")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
@Column(name = "DESCRIPTION")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
import info.bukova.isspst.StringUtils;
|
import info.bukova.isspst.StringUtils;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@@ -15,14 +14,11 @@ public class MUnitEmb
|
|||||||
@Column(name = "MUNIT_NAME")
|
@Column(name = "MUNIT_NAME")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Column(name = "MUNIT_DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
@Column(name = "MUNIT_DESCRIPTION")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
public MUnitEmb()
|
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)
|
public MUnitEmb(MUnit munit)
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -18,16 +16,10 @@ import javax.persistence.Table;
|
|||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
import org.hibernate.annotations.LazyCollection;
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
import org.hibernate.annotations.LazyCollectionOption;
|
||||||
import org.hibernate.search.annotations.Analyze;
|
|
||||||
import org.hibernate.search.annotations.Field;
|
|
||||||
import org.hibernate.search.annotations.Index;
|
|
||||||
import org.hibernate.search.annotations.Indexed;
|
|
||||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "ORDERS")
|
@Table(name = "ORDERS")
|
||||||
@Indexed
|
public class Order extends BaseData
|
||||||
public class Order extends BaseData implements Cloneable
|
|
||||||
{
|
{
|
||||||
|
|
||||||
@Column(name = "NUMSER")
|
@Column(name = "NUMSER")
|
||||||
@@ -43,7 +35,7 @@ public class Order extends BaseData implements Cloneable
|
|||||||
@AttributeOverride(name = "company", column = @Column(name = "SUPPLIER_COMPANY")),
|
@AttributeOverride(name = "company", column = @Column(name = "SUPPLIER_COMPANY")),
|
||||||
@AttributeOverride(name = "contactName", column = @Column(name = "SUPPLIER_CONTACT_NAME")),
|
@AttributeOverride(name = "contactName", column = @Column(name = "SUPPLIER_CONTACT_NAME")),
|
||||||
@AttributeOverride(name = "department", column = @Column(name = "SUPPLIER_DEPARTMENT")),
|
@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 = "dic", column = @Column(name = "SUPPLIER_DIC")),
|
||||||
@AttributeOverride(name = "email", column = @Column(name = "SUPPLIER_EMAIL")),
|
@AttributeOverride(name = "email", column = @Column(name = "SUPPLIER_EMAIL")),
|
||||||
@AttributeOverride(name = "houseNumber", column = @Column(name = "SUPPLIER_HOUSENUMBER")),
|
@AttributeOverride(name = "houseNumber", column = @Column(name = "SUPPLIER_HOUSENUMBER")),
|
||||||
@@ -53,7 +45,6 @@ public class Order extends BaseData implements Cloneable
|
|||||||
@AttributeOverride(name = "street", column = @Column(name = "SUPPLIER_STREET")),
|
@AttributeOverride(name = "street", column = @Column(name = "SUPPLIER_STREET")),
|
||||||
@AttributeOverride(name = "web", column = @Column(name = "SUPPLIER_WEB")),
|
@AttributeOverride(name = "web", column = @Column(name = "SUPPLIER_WEB")),
|
||||||
@AttributeOverride(name = "zipCode", column = @Column(name = "SUPPLIER_ZIP_CODE")) })
|
@AttributeOverride(name = "zipCode", column = @Column(name = "SUPPLIER_ZIP_CODE")) })
|
||||||
@IndexedEmbedded
|
|
||||||
private AddressEmb suplier;
|
private AddressEmb suplier;
|
||||||
|
|
||||||
@Embedded
|
@Embedded
|
||||||
@@ -63,7 +54,7 @@ public class Order extends BaseData implements Cloneable
|
|||||||
@AttributeOverride(name = "company", column = @Column(name = "INVOICE_COMPANY")),
|
@AttributeOverride(name = "company", column = @Column(name = "INVOICE_COMPANY")),
|
||||||
@AttributeOverride(name = "contactName", column = @Column(name = "INVOICE_CONTACT_NAME")),
|
@AttributeOverride(name = "contactName", column = @Column(name = "INVOICE_CONTACT_NAME")),
|
||||||
@AttributeOverride(name = "department", column = @Column(name = "INVOICE_DEPARTMENT")),
|
@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 = "dic", column = @Column(name = "INVOICE_DIC")),
|
||||||
@AttributeOverride(name = "email", column = @Column(name = "INVOICE_EMAIL")),
|
@AttributeOverride(name = "email", column = @Column(name = "INVOICE_EMAIL")),
|
||||||
@AttributeOverride(name = "houseNumber", column = @Column(name = "INVOICE_HOUSENUMBER")),
|
@AttributeOverride(name = "houseNumber", column = @Column(name = "INVOICE_HOUSENUMBER")),
|
||||||
@@ -82,7 +73,7 @@ public class Order extends BaseData implements Cloneable
|
|||||||
@AttributeOverride(name = "company", column = @Column(name = "DELIVERY_COMPANY")),
|
@AttributeOverride(name = "company", column = @Column(name = "DELIVERY_COMPANY")),
|
||||||
@AttributeOverride(name = "contactName", column = @Column(name = "DELIVERY_CONTACT_NAME")),
|
@AttributeOverride(name = "contactName", column = @Column(name = "DELIVERY_CONTACT_NAME")),
|
||||||
@AttributeOverride(name = "department", column = @Column(name = "DELIVERY_DEPARTMENT")),
|
@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 = "dic", column = @Column(name = "DELIVERY_DIC")),
|
||||||
@AttributeOverride(name = "email", column = @Column(name = "DELIVERY_EMAIL")),
|
@AttributeOverride(name = "email", column = @Column(name = "DELIVERY_EMAIL")),
|
||||||
@AttributeOverride(name = "houseNumber", column = @Column(name = "DELIVERY_HOUSENUMBER")),
|
@AttributeOverride(name = "houseNumber", column = @Column(name = "DELIVERY_HOUSENUMBER")),
|
||||||
@@ -103,13 +94,11 @@ public class Order extends BaseData implements Cloneable
|
|||||||
@Column(name = "DELIVERY_TYPE")
|
@Column(name = "DELIVERY_TYPE")
|
||||||
private String deliveryType;
|
private String deliveryType;
|
||||||
|
|
||||||
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
@Column(name = "DESCRIPTION")
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "order", orphanRemoval = true)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "order", orphanRemoval = true)
|
||||||
@LazyCollection(LazyCollectionOption.TRUE)
|
@LazyCollection(LazyCollectionOption.TRUE)
|
||||||
@IndexedEmbedded
|
|
||||||
private List<OrderItem> items;
|
private List<OrderItem> items;
|
||||||
|
|
||||||
@Column(name = "TOTAL", precision = 15, scale = 4)
|
@Column(name = "TOTAL", precision = 15, scale = 4)
|
||||||
@@ -121,10 +110,20 @@ public class Order extends BaseData implements Cloneable
|
|||||||
@Column(name = "DELIVERED")
|
@Column(name = "DELIVERED")
|
||||||
private boolean delivered;
|
private boolean delivered;
|
||||||
|
|
||||||
|
@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()
|
public Order()
|
||||||
{
|
{
|
||||||
this.items = new ArrayList<OrderItem>();
|
this.items = new ArrayList<OrderItem>();
|
||||||
this.total = BigDecimal.ZERO;
|
this.total = BigDecimal.ZERO;
|
||||||
|
this.invoiceTotal = BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNumser()
|
public String getNumser()
|
||||||
@@ -233,6 +232,26 @@ public class Order extends BaseData implements Cloneable
|
|||||||
this.delivered = delivered;
|
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()
|
public boolean isOrdered()
|
||||||
{
|
{
|
||||||
return ordered;
|
return ordered;
|
||||||
@@ -263,29 +282,14 @@ public class Order extends BaseData implements Cloneable
|
|||||||
this.total = total;
|
this.total = total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIcludedRequirementItemFromAnotherOrder()
|
public BigDecimal getInvoiceTotal()
|
||||||
{
|
{
|
||||||
for (OrderItem oItem : this.getItems())
|
return invoiceTotal;
|
||||||
{
|
|
||||||
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 false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setInvoiceTotal(BigDecimal invoiceTotal)
|
||||||
public Object clone() throws CloneNotSupportedException
|
|
||||||
{
|
{
|
||||||
Order cloned = (Order) super.clone();
|
this.invoiceTotal = invoiceTotal;
|
||||||
cloned.setTotal(new BigDecimal(this.getTotal().toString()));
|
|
||||||
return cloned;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@@ -14,47 +12,37 @@ import javax.persistence.JoinColumn;
|
|||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.search.annotations.Analyze;
|
|
||||||
import org.hibernate.search.annotations.Field;
|
|
||||||
import org.hibernate.search.annotations.Index;
|
|
||||||
import org.hibernate.search.annotations.Indexed;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "ORDER_ITEM")
|
@Table(name = "ORDER_ITEM")
|
||||||
@Indexed
|
public class OrderItem {
|
||||||
public class OrderItem
|
|
||||||
{
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "ID")
|
@Column(name="ID")
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
@Column(name = "CODE")
|
@Column(name = "CODE")
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
@Column(name = "NAME")
|
@Column(name = "NAME")
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Column(name = "TEXTITEM")
|
@Column(name = "TEXTITEM")
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String textItem;
|
private String textItem;
|
||||||
|
|
||||||
@Column(name = "QUANTITY", precision = 15, scale = 4)
|
@Column(name = "QUANTITY", precision=15, scale=4)
|
||||||
private BigDecimal quantity;
|
private BigDecimal quantity;
|
||||||
|
|
||||||
@Embedded
|
@Embedded
|
||||||
private MUnitEmb munit;
|
private MUnitEmb munit;
|
||||||
|
|
||||||
@Column(name = "UNITPRICE", precision = 15, scale = 4)
|
@Column(name = "UNITPRICE", precision=15, scale=4)
|
||||||
private BigDecimal unitPrice;
|
private BigDecimal unitPrice;
|
||||||
|
|
||||||
@Column(name = "TOTAL", precision = 15, scale = 4)
|
@Column(name = "TOTAL", precision=15, scale=4)
|
||||||
private BigDecimal total;
|
private BigDecimal total;
|
||||||
|
|
||||||
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
@Column(name = "DESCRIPTION")
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@@ -65,13 +53,11 @@ public class OrderItem
|
|||||||
@JoinColumn(name = "ORDER_ID")
|
@JoinColumn(name = "ORDER_ID")
|
||||||
private Order order;
|
private Order order;
|
||||||
|
|
||||||
public OrderItem()
|
public OrderItem() {
|
||||||
{
|
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderItem(RequirementItem reqItem)
|
public OrderItem(RequirementItem reqItem) {
|
||||||
{
|
|
||||||
super();
|
super();
|
||||||
this.reqItem = reqItem;
|
this.reqItem = reqItem;
|
||||||
this.code = reqItem.getCode();
|
this.code = reqItem.getCode();
|
||||||
@@ -84,113 +70,91 @@ public class OrderItem
|
|||||||
this.description = reqItem.getDescription();
|
this.description = reqItem.getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId()
|
public int getId() {
|
||||||
{
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(int id)
|
public void setId(int id) {
|
||||||
{
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCode()
|
public String getCode() {
|
||||||
{
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCode(String code)
|
public void setCode(String code) {
|
||||||
{
|
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name)
|
public void setName(String name) {
|
||||||
{
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTextItem()
|
public String getTextItem() {
|
||||||
{
|
|
||||||
return textItem;
|
return textItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextItem(String textItem)
|
public void setTextItem(String textItem) {
|
||||||
{
|
|
||||||
this.textItem = textItem;
|
this.textItem = textItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getQuantity()
|
public BigDecimal getQuantity() {
|
||||||
{
|
|
||||||
return quantity;
|
return quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setQuantity(BigDecimal quantity)
|
public void setQuantity(BigDecimal quantity) {
|
||||||
{
|
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MUnitEmb getMunit()
|
public MUnitEmb getMunit() {
|
||||||
{
|
|
||||||
return munit;
|
return munit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMunit(MUnitEmb munit)
|
public void setMunit(MUnitEmb munit) {
|
||||||
{
|
|
||||||
this.munit = munit;
|
this.munit = munit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getUnitPrice()
|
public BigDecimal getUnitPrice() {
|
||||||
{
|
|
||||||
return unitPrice;
|
return unitPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUnitPrice(BigDecimal unitPrice)
|
public void setUnitPrice(BigDecimal unitPrice) {
|
||||||
{
|
|
||||||
this.unitPrice = unitPrice;
|
this.unitPrice = unitPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getTotal()
|
public BigDecimal getTotal() {
|
||||||
{
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTotal(BigDecimal total)
|
public void setTotal(BigDecimal total) {
|
||||||
{
|
|
||||||
this.total = total;
|
this.total = total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription() {
|
||||||
{
|
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description)
|
public void setDescription(String description) {
|
||||||
{
|
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RequirementItem getReqItem()
|
public RequirementItem getReqItem() {
|
||||||
{
|
|
||||||
return reqItem;
|
return reqItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReqItem(RequirementItem reqItem)
|
public void setReqItem(RequirementItem reqItem) {
|
||||||
{
|
|
||||||
this.reqItem = reqItem;
|
this.reqItem = reqItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Order getOrder()
|
public Order getOrder() {
|
||||||
{
|
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrder(Order order)
|
public void setOrder(Order order) {
|
||||||
{
|
|
||||||
this.order = order;
|
this.order = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EnumType;
|
import javax.persistence.EnumType;
|
||||||
@@ -21,7 +19,7 @@ public class Permission extends BaseSimpleData implements GrantedAuthority {
|
|||||||
|
|
||||||
@Column(name="AUTHORITY")
|
@Column(name="AUTHORITY")
|
||||||
private String authority;
|
private String authority;
|
||||||
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
@Column(name="DESCRIPTION")
|
||||||
private String description;
|
private String description;
|
||||||
@Column(name="MODULE")
|
@Column(name="MODULE")
|
||||||
private String module;
|
private String module;
|
||||||
|
|||||||
@@ -12,16 +12,11 @@ import javax.persistence.FetchType;
|
|||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.search.annotations.Indexed;
|
|
||||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "REQUIREMENT")
|
@Table(name = "REQUIREMENT")
|
||||||
@Indexed
|
|
||||||
public class Requirement extends RequirementBase
|
public class Requirement extends RequirementBase
|
||||||
{
|
{
|
||||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "requirement", cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(fetch = FetchType.EAGER, mappedBy = "requirement", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
@IndexedEmbedded
|
|
||||||
private List<RequirementItem> items;
|
private List<RequirementItem> items;
|
||||||
|
|
||||||
@Column(name = "DELIVERYDATE")
|
@Column(name = "DELIVERYDATE")
|
||||||
@@ -33,9 +28,6 @@ public class Requirement extends RequirementBase
|
|||||||
@Column(name = "KIND")
|
@Column(name = "KIND")
|
||||||
private Long kind;
|
private Long kind;
|
||||||
|
|
||||||
@Column(name = "PROJECT")
|
|
||||||
private Boolean project;
|
|
||||||
|
|
||||||
public Requirement()
|
public Requirement()
|
||||||
{
|
{
|
||||||
this.setItems(new ArrayList<RequirementItem>());
|
this.setItems(new ArrayList<RequirementItem>());
|
||||||
@@ -86,39 +78,4 @@ public class Requirement extends RequirementBase
|
|||||||
{
|
{
|
||||||
this.kind = kind;
|
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,7 +1,5 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -19,13 +17,8 @@ import javax.persistence.OrderBy;
|
|||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
import org.hibernate.annotations.LazyCollection;
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
import org.hibernate.annotations.LazyCollectionOption;
|
||||||
import org.hibernate.search.annotations.Analyze;
|
|
||||||
import org.hibernate.search.annotations.Field;
|
|
||||||
import org.hibernate.search.annotations.Index;
|
|
||||||
import org.hibernate.search.annotations.Indexed;
|
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
@Indexed
|
|
||||||
public class RequirementBase extends BaseData implements FilterableRequirement {
|
public class RequirementBase extends BaseData implements FilterableRequirement {
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@@ -36,12 +29,10 @@ public class RequirementBase extends BaseData implements FilterableRequirement {
|
|||||||
@OrderBy("CENTRE, WORDER")
|
@OrderBy("CENTRE, WORDER")
|
||||||
private List<Workflow> workflow;
|
private List<Workflow> workflow;
|
||||||
@Column(name = "NUMSER", unique = true)
|
@Column(name = "NUMSER", unique = true)
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String numser;
|
private String numser;
|
||||||
@Column(name = "REQ_DATE")
|
@Column(name = "REQ_DATE")
|
||||||
private Date reqDate;
|
private Date reqDate;
|
||||||
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
@Column(name = "DESCRIPTION")
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String description;
|
private String description;
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "CENTRE_ID")
|
@JoinColumn(name = "CENTRE_ID")
|
||||||
@@ -136,20 +127,4 @@ public class RequirementBase extends BaseData implements FilterableRequirement {
|
|||||||
this.workflow = workflow;
|
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@@ -14,15 +12,8 @@ import javax.persistence.JoinColumn;
|
|||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.search.annotations.Analyze;
|
|
||||||
import org.hibernate.search.annotations.Field;
|
|
||||||
import org.hibernate.search.annotations.Index;
|
|
||||||
import org.hibernate.search.annotations.Indexed;
|
|
||||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "REQUIREMENT_ITEMS")
|
@Table(name = "REQUIREMENT_ITEMS")
|
||||||
@Indexed
|
|
||||||
public class RequirementItem
|
public class RequirementItem
|
||||||
{
|
{
|
||||||
@Id
|
@Id
|
||||||
@@ -42,11 +33,9 @@ public class RequirementItem
|
|||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
@Column(name = "NAME")
|
@Column(name = "NAME")
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Column(name = "TEXTITEM")
|
@Column(name = "TEXTITEM")
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String textItem;
|
private String textItem;
|
||||||
|
|
||||||
@Column(name = "QUANTITY", precision=15, scale=4)
|
@Column(name = "QUANTITY", precision=15, scale=4)
|
||||||
@@ -61,19 +50,12 @@ public class RequirementItem
|
|||||||
@Column(name = "TOTAL", precision=15, scale=4)
|
@Column(name = "TOTAL", precision=15, scale=4)
|
||||||
private BigDecimal total;
|
private BigDecimal total;
|
||||||
|
|
||||||
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
@Column(name = "DESCRIPTION")
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Column(name = "DELIVERED")
|
@Column(name = "DELIVERED")
|
||||||
private Boolean delivered;
|
private Boolean delivered;
|
||||||
|
|
||||||
@Column(name = "ORDERNUM")
|
|
||||||
private String orderNum;
|
|
||||||
|
|
||||||
@Column(name = "PAID")
|
|
||||||
private Boolean paid;
|
|
||||||
|
|
||||||
public int getId()
|
public int getId()
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
@@ -181,22 +163,7 @@ public class RequirementItem
|
|||||||
{
|
{
|
||||||
RequirementItem item = (RequirementItem)obj;
|
RequirementItem item = (RequirementItem)obj;
|
||||||
|
|
||||||
int thisId = this.getId();
|
return (this.getId() == item.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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,22 +187,4 @@ public class RequirementItem
|
|||||||
public void setDelivered(Boolean delivered) {
|
public void setDelivered(Boolean delivered) {
|
||||||
this.delivered = 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;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@@ -44,9 +42,10 @@ public abstract class RequirementSubject implements OwnedDataModel {
|
|||||||
private String code;
|
private String code;
|
||||||
@Column(name = "NAME")
|
@Column(name = "NAME")
|
||||||
private String name;
|
private String name;
|
||||||
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
@Column(name = "DESCRIPTION")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
|
||||||
@NotEmpty(message = "{MaterialFormCodeConstr}")
|
@NotEmpty(message = "{MaterialFormCodeConstr}")
|
||||||
public String getCode() {
|
public String getCode() {
|
||||||
return code;
|
return code;
|
||||||
@@ -141,16 +140,7 @@ public abstract class RequirementSubject implements OwnedDataModel {
|
|||||||
{
|
{
|
||||||
RequirementSubject item = (RequirementSubject) obj;
|
RequirementSubject item = (RequirementSubject) obj;
|
||||||
|
|
||||||
int thisId = this.getId();
|
return (this.getId() == item.getId());
|
||||||
int itemId = item.getId();
|
|
||||||
boolean equalsId = (thisId == itemId);
|
|
||||||
|
|
||||||
if (equalsId && (thisId == 0))
|
|
||||||
{
|
|
||||||
return super.equals(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return equalsId;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.JoinColumn;
|
|
||||||
import javax.persistence.JoinTable;
|
import javax.persistence.JoinTable;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.OrderBy;
|
import javax.persistence.OrderBy;
|
||||||
@@ -24,7 +22,7 @@ public class RequirementType extends BaseData {
|
|||||||
|
|
||||||
@Column(name = "TYPE")
|
@Column(name = "TYPE")
|
||||||
private String type;
|
private String type;
|
||||||
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
@Column(name = "DESCRIPTION")
|
||||||
private String description;
|
private String description;
|
||||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval=true)
|
@OneToMany(cascade = CascadeType.ALL, orphanRemoval=true)
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@LazyCollection(LazyCollectionOption.FALSE)
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -27,7 +25,7 @@ public class Role extends BaseSimpleData implements GrantedAuthority, DataModel
|
|||||||
|
|
||||||
@Column(name="AUTHORITY", unique=true)
|
@Column(name="AUTHORITY", unique=true)
|
||||||
private String authority;
|
private String authority;
|
||||||
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
@Column(name="DESCRIPTION")
|
||||||
private String description;
|
private String description;
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@LazyCollection(LazyCollectionOption.FALSE)
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ public class SettingsData {
|
|||||||
private MailMessage newReqTemplate;
|
private MailMessage newReqTemplate;
|
||||||
private MailMessage authReqTemplate;
|
private MailMessage authReqTemplate;
|
||||||
private MailMessage confReqTemplate;
|
private MailMessage confReqTemplate;
|
||||||
private MailMessage confReqTripPassenger;
|
|
||||||
private MailMessage reqPassenger;
|
|
||||||
private Address mainAddress;
|
private Address mainAddress;
|
||||||
private List<Address> shippingAddrs;
|
private List<Address> shippingAddrs;
|
||||||
private String bankName;
|
private String bankName;
|
||||||
@@ -24,14 +22,11 @@ public class SettingsData {
|
|||||||
private List<Vehicle> vehicles;
|
private List<Vehicle> vehicles;
|
||||||
private Map<Integer, BigDecimal[]> refunds;
|
private Map<Integer, BigDecimal[]> refunds;
|
||||||
private String stampFile;
|
private String stampFile;
|
||||||
private String logoFile;
|
|
||||||
|
|
||||||
public SettingsData() {
|
public SettingsData() {
|
||||||
newReqTemplate = new MailMessage();
|
newReqTemplate = new MailMessage();
|
||||||
authReqTemplate = new MailMessage();
|
authReqTemplate = new MailMessage();
|
||||||
confReqTemplate = new MailMessage();
|
confReqTemplate = new MailMessage();
|
||||||
confReqTripPassenger = new MailMessage();
|
|
||||||
reqPassenger = new MailMessage();
|
|
||||||
mainAddress = new Address();
|
mainAddress = new Address();
|
||||||
shippingAddrs = new ArrayList<Address>();
|
shippingAddrs = new ArrayList<Address>();
|
||||||
vehicles = new ArrayList<Vehicle>();
|
vehicles = new ArrayList<Vehicle>();
|
||||||
@@ -145,29 +140,4 @@ public class SettingsData {
|
|||||||
this.stampFile = stampFile;
|
this.stampFile = stampFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLogoFile()
|
|
||||||
{
|
|
||||||
return logoFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLogoFile(String logoFile)
|
|
||||||
{
|
|
||||||
this.logoFile = logoFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MailMessage getConfReqTripPassenger() {
|
|
||||||
return confReqTripPassenger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConfReqTripPassenger(MailMessage confReqTripPassenger) {
|
|
||||||
this.confReqTripPassenger = confReqTripPassenger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MailMessage getReqPassenger() {
|
|
||||||
return reqPassenger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReqPassenger(MailMessage reqPassenger) {
|
|
||||||
this.reqPassenger = reqPassenger;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
import info.bukova.isspst.storage.EntityWithAttachment;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -19,16 +16,10 @@ import javax.persistence.Table;
|
|||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
import org.hibernate.annotations.LazyCollection;
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
import org.hibernate.annotations.LazyCollectionOption;
|
||||||
import org.hibernate.search.annotations.Analyze;
|
|
||||||
import org.hibernate.search.annotations.Field;
|
|
||||||
import org.hibernate.search.annotations.Index;
|
|
||||||
import org.hibernate.search.annotations.Indexed;
|
|
||||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "TRIP_BILL")
|
@Table(name = "TRIP_BILL")
|
||||||
@Indexed
|
public class TripBill extends BaseData {
|
||||||
public class TripBill extends BaseData implements EntityWithAttachment {
|
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.EAGER)
|
@OneToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "REQUIREMENT_ID")
|
@JoinColumn(name = "REQUIREMENT_ID")
|
||||||
@@ -37,11 +28,6 @@ public class TripBill extends BaseData implements EntityWithAttachment {
|
|||||||
private Date resultMessageDate;
|
private Date resultMessageDate;
|
||||||
@Column(name = "SIGN_DATE")
|
@Column(name = "SIGN_DATE")
|
||||||
private Date signDate;
|
private Date signDate;
|
||||||
|
|
||||||
@Column(name = "RESULT_MESSAGE", length = Constants.LEN_RESULT_MESSAGE)
|
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String resultMessage;
|
|
||||||
|
|
||||||
@Column(name = "FREE_MEALS")
|
@Column(name = "FREE_MEALS")
|
||||||
private boolean freeMeals;
|
private boolean freeMeals;
|
||||||
@Column(name = "FREE_HOUSING")
|
@Column(name = "FREE_HOUSING")
|
||||||
@@ -58,19 +44,9 @@ public class TripBill extends BaseData implements EntityWithAttachment {
|
|||||||
private BigDecimal downPayment;
|
private BigDecimal downPayment;
|
||||||
@Column(name = "TOTAL", precision = 15, scale = 4)
|
@Column(name = "TOTAL", precision = 15, scale = 4)
|
||||||
private BigDecimal total;
|
private BigDecimal total;
|
||||||
@OneToMany(cascade = CascadeType.ALL)
|
|
||||||
@LazyCollection(LazyCollectionOption.TRUE)
|
|
||||||
@IndexedEmbedded
|
|
||||||
private List<FileMetainfo> attachedFiles;
|
|
||||||
@OneToOne(fetch = FetchType.EAGER)
|
|
||||||
@JoinColumn(name = "APPROVAL_ID")
|
|
||||||
private TripBillApproval approval;
|
|
||||||
@Column(name = "SAVED")
|
|
||||||
private Boolean saved;
|
|
||||||
|
|
||||||
public TripBill() {
|
public TripBill() {
|
||||||
billItems = new ArrayList<TripBillItem>();
|
billItems = new ArrayList<TripBillItem>();
|
||||||
attachedFiles = new ArrayList<FileMetainfo>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TripRequirement getRequirement() {
|
public TripRequirement getRequirement() {
|
||||||
@@ -97,16 +73,6 @@ public class TripBill extends BaseData implements EntityWithAttachment {
|
|||||||
this.signDate = signDate;
|
this.signDate = signDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResultMessage()
|
|
||||||
{
|
|
||||||
return resultMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResultMessage(String resultMessage)
|
|
||||||
{
|
|
||||||
this.resultMessage = resultMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFreeMeals() {
|
public boolean isFreeMeals() {
|
||||||
return freeMeals;
|
return freeMeals;
|
||||||
}
|
}
|
||||||
@@ -155,37 +121,4 @@ public class TripBill extends BaseData implements EntityWithAttachment {
|
|||||||
this.total = total;
|
this.total = total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FileMetainfo> getAttachedFiles() {
|
|
||||||
return attachedFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addAttachment(FileMetainfo metaInfo) {
|
|
||||||
attachedFiles.add(metaInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeAttachment(FileMetainfo metainfo) {
|
|
||||||
attachedFiles.remove(metainfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAttachedFiles(List<FileMetainfo> attachedFiles) {
|
|
||||||
this.attachedFiles = attachedFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TripBillApproval getApproval() {
|
|
||||||
return approval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApproval(TripBillApproval approval) {
|
|
||||||
this.approval = approval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getSaved() {
|
|
||||||
return saved;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSaved(Boolean saved) {
|
|
||||||
this.saved = saved;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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;
|
|
||||||
|
|
||||||
@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;
|
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.AttributeOverride;
|
||||||
import javax.persistence.AttributeOverrides;
|
import javax.persistence.AttributeOverrides;
|
||||||
@@ -8,8 +9,6 @@ import javax.persistence.Column;
|
|||||||
import javax.persistence.Embedded;
|
import javax.persistence.Embedded;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "TRIP_BILL_ITEMS")
|
@Table(name = "TRIP_BILL_ITEMS")
|
||||||
@@ -34,7 +33,7 @@ public class TripBillItem extends BaseData {
|
|||||||
@Embedded
|
@Embedded
|
||||||
@AttributeOverrides({
|
@AttributeOverrides({
|
||||||
@AttributeOverride(name = "code", column = @Column(name = "BACK_VEHICLE_CODE")),
|
@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;
|
private Vehicle backVehicle;
|
||||||
@Column(name = "BEGIN_WORK")
|
@Column(name = "BEGIN_WORK")
|
||||||
@@ -64,35 +63,6 @@ public class TripBillItem extends BaseData {
|
|||||||
@Column(name = "ADJUSTED_TOTAL", precision = 15, scale = 4)
|
@Column(name = "ADJUSTED_TOTAL", precision = 15, scale = 4)
|
||||||
private BigDecimal adjustedTotal;
|
private BigDecimal adjustedTotal;
|
||||||
|
|
||||||
public TripBillItem() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public TripBillItem(TripBillItem src) {
|
|
||||||
date = src.getDate();
|
|
||||||
to = src.getTo();
|
|
||||||
back = src.getBack();
|
|
||||||
toDeparture = src.getToDeparture();
|
|
||||||
toArrival = src.getToArrival();
|
|
||||||
backDeparture = src.getBackDeparture();
|
|
||||||
backArrival = src.getBackArrival();
|
|
||||||
toVehicle = src.getToVehicle();
|
|
||||||
backVehicle = src.getBackVehicle();
|
|
||||||
beginWork = src.getBeginWork();
|
|
||||||
endWork = src.getEndWork();
|
|
||||||
freeMealsCount = src.getFreeMealsCount();
|
|
||||||
distance = src.getDistance();
|
|
||||||
fuelConsumption = src.getFuelConsumption();
|
|
||||||
distanceAmount = src.getDistanceAmount();
|
|
||||||
fuelAmount = src.getFuelAmount();
|
|
||||||
carefare = src.getCarefare();
|
|
||||||
housing = src.getHousing();
|
|
||||||
meals = src.getMeals();
|
|
||||||
otherExpenses = src.getOtherExpenses();
|
|
||||||
total = src.getTotal();
|
|
||||||
adjustedTotal = src.getAdjustedTotal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getDate() {
|
public Date getDate() {
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,32 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.storage.EntityWithAttachment;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Embedded;
|
import javax.persistence.Embedded;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.JoinTable;
|
import javax.persistence.JoinTable;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.OneToMany;
|
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
import org.hibernate.annotations.LazyCollection;
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
import org.hibernate.annotations.LazyCollectionOption;
|
||||||
import org.hibernate.search.annotations.Analyze;
|
|
||||||
import org.hibernate.search.annotations.Field;
|
|
||||||
import org.hibernate.search.annotations.Index;
|
|
||||||
import org.hibernate.search.annotations.Indexed;
|
|
||||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "TRIPREQUIREMENT")
|
@Table(name = "TRIPREQUIREMENT")
|
||||||
@Indexed
|
public class TripRequirement extends RequirementBase {
|
||||||
public class TripRequirement extends RequirementBase implements EntityWithAttachment {
|
|
||||||
|
|
||||||
@Column(name = "TRIP_FROM")
|
@Column(name = "TRIP_FROM")
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String from;
|
private String from;
|
||||||
@Column(name = "TRIP_TO")
|
@Column(name = "TRIP_TO")
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String to;
|
private String to;
|
||||||
@Column(name = "TRIP_DATE")
|
@Column(name = "TRIP_DATE")
|
||||||
private Date tripDate;
|
private Date tripDate;
|
||||||
@Column(name = "END")
|
@Column(name = "TRIP_END")
|
||||||
private String end;
|
private String end;
|
||||||
@Column(name = "END_DATE")
|
@Column(name = "END_DATE")
|
||||||
private Date endDate;
|
private Date endDate;
|
||||||
@@ -46,28 +34,16 @@ public class TripRequirement extends RequirementBase implements EntityWithAttach
|
|||||||
@LazyCollection(LazyCollectionOption.TRUE)
|
@LazyCollection(LazyCollectionOption.TRUE)
|
||||||
@JoinTable(name="TRIPREQUIREMENT_PASSANGER", joinColumns={@JoinColumn(name="TRIPREQUIREMENT_ID")}, inverseJoinColumns={@JoinColumn(name="USER_ID")})
|
@JoinTable(name="TRIPREQUIREMENT_PASSANGER", joinColumns={@JoinColumn(name="TRIPREQUIREMENT_ID")}, inverseJoinColumns={@JoinColumn(name="USER_ID")})
|
||||||
private List<User> passengers;
|
private List<User> passengers;
|
||||||
|
|
||||||
@Column(name = "FOREIGN_PERSONS")
|
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String foreignPersons;
|
|
||||||
|
|
||||||
@Embedded
|
@Embedded
|
||||||
private Vehicle vehicle;
|
private Vehicle vehicle;
|
||||||
@Column(name = "REQUIRE_DOWN_PAYMENT")
|
@Column(name = "REQUIRE_DOWN_PAYMENT")
|
||||||
private Boolean requireDownPayment;
|
private Boolean requireDownPayment;
|
||||||
@Column(name = "DOWN_PAYMENT", precision = 15, scale = 4)
|
@Column(name = "DOWN_PAYMENT", precision = 15, scale = 4)
|
||||||
private BigDecimal downPayment;
|
private BigDecimal downPayment;
|
||||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
@LazyCollection(LazyCollectionOption.TRUE)
|
|
||||||
@IndexedEmbedded
|
|
||||||
private List<FileMetainfo> attachedFiles;
|
|
||||||
@Column(name = "BILL_FOR_PASSENGERS")
|
|
||||||
private Boolean billForPassengers;
|
|
||||||
|
|
||||||
public TripRequirement() {
|
public TripRequirement() {
|
||||||
this.setOwnedBy(new User());
|
this.setOwnedBy(new User());
|
||||||
passengers = new ArrayList<User>();
|
passengers = new ArrayList<User>();
|
||||||
attachedFiles = new ArrayList<FileMetainfo>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFrom() {
|
public String getFrom() {
|
||||||
@@ -118,16 +94,6 @@ public class TripRequirement extends RequirementBase implements EntityWithAttach
|
|||||||
this.passengers = passengers;
|
this.passengers = passengers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getForeignPersons()
|
|
||||||
{
|
|
||||||
return foreignPersons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setForeignPersons(String foreignPersons)
|
|
||||||
{
|
|
||||||
this.foreignPersons = foreignPersons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vehicle getVehicle() {
|
public Vehicle getVehicle() {
|
||||||
return vehicle;
|
return vehicle;
|
||||||
}
|
}
|
||||||
@@ -152,30 +118,4 @@ public class TripRequirement extends RequirementBase implements EntityWithAttach
|
|||||||
this.downPayment = downPayment;
|
this.downPayment = downPayment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<FileMetainfo> getAttachedFiles() {
|
|
||||||
return attachedFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAttachedFiles(List<FileMetainfo> attachedFiles) {
|
|
||||||
this.attachedFiles = attachedFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addAttachment(FileMetainfo metaInfo) {
|
|
||||||
attachedFiles.add(metaInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeAttachment(FileMetainfo metainfo) {
|
|
||||||
attachedFiles.remove(metainfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getBillForPassengers() {
|
|
||||||
return billForPassengers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBillForPassengers(Boolean billForPassengers) {
|
|
||||||
this.billForPassengers = billForPassengers;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,10 @@ import javax.persistence.JoinTable;
|
|||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.search.annotations.Analyze;
|
|
||||||
import org.hibernate.search.annotations.Field;
|
|
||||||
import org.hibernate.search.annotations.Index;
|
|
||||||
import org.hibernate.search.annotations.Indexed;
|
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="USER")
|
@Table(name="USER_LOGIN")
|
||||||
@Indexed
|
|
||||||
public class User extends Member implements UserDetails, DataModel {
|
public class User extends Member implements UserDetails, DataModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,10 +32,8 @@ public class User extends Member implements UserDetails, DataModel {
|
|||||||
@Column(name="ENABLED")
|
@Column(name="ENABLED")
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
@Column(name="FIRST_NAME")
|
@Column(name="FIRST_NAME")
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String firstName;
|
private String firstName;
|
||||||
@Column(name="LAST_NAME")
|
@Column(name="LAST_NAME")
|
||||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
|
||||||
private String lastName;
|
private String lastName;
|
||||||
@Column(name="PERSONAL_NUMBER")
|
@Column(name="PERSONAL_NUMBER")
|
||||||
private String personalNumber;
|
private String personalNumber;
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.StringUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Embeddable;
|
import javax.persistence.Embeddable;
|
||||||
|
|
||||||
@@ -52,22 +47,4 @@ public class UsersAddress {
|
|||||||
this.city = city;
|
this.city = city;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
List<String> list = new ArrayList<String>();
|
|
||||||
list.add(this.street);
|
|
||||||
list.add(this.houseNumber);
|
|
||||||
final String s1 = StringUtils.joinNotEmpty(list, " ");
|
|
||||||
|
|
||||||
list.clear();
|
|
||||||
list.add(this.zipCode);
|
|
||||||
list.add(this.city);
|
|
||||||
final String s2 = StringUtils.joinNotEmpty(list, " ");
|
|
||||||
|
|
||||||
list.clear();
|
|
||||||
list.add(s1);
|
|
||||||
list.add(s2);
|
|
||||||
final String s = StringUtils.joinNotEmpty(list, ", ");
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Embeddable;
|
import javax.persistence.Embeddable;
|
||||||
|
|
||||||
@@ -10,7 +8,7 @@ public class Vehicle {
|
|||||||
|
|
||||||
@Column(name = "VEHICLE_CODE")
|
@Column(name = "VEHICLE_CODE")
|
||||||
private String code;
|
private String code;
|
||||||
@Column(name = "VEHICLE_DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
@Column(name = "VEHICLE_DESCRIPTION")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
public String getCode() {
|
public String getCode() {
|
||||||
|
|||||||
@@ -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;
|
package info.bukova.isspst.filters;
|
||||||
|
|
||||||
import info.bukova.isspst.BooleanUtils;
|
|
||||||
import info.bukova.isspst.StringUtils;
|
import info.bukova.isspst.StringUtils;
|
||||||
import info.bukova.isspst.data.JoinedItem;
|
import info.bukova.isspst.data.JoinedItem;
|
||||||
import info.bukova.isspst.data.MUnitEmb;
|
import info.bukova.isspst.data.MUnitEmb;
|
||||||
@@ -43,7 +42,6 @@ public class JoinedItemFilter implements Filter<JoinedItem>
|
|||||||
@Override
|
@Override
|
||||||
public boolean matchesSafely(JoinedItem item)
|
public boolean matchesSafely(JoinedItem item)
|
||||||
{
|
{
|
||||||
boolean foundItemMaterial = BooleanUtils.isEqualFilterByBoolean(item.isItemMaterialReal(), condition.getItemMaterial());
|
|
||||||
boolean foundCode = StringUtils.isEqualForFilter(item.getCode(), condition.getCode());
|
boolean foundCode = StringUtils.isEqualForFilter(item.getCode(), condition.getCode());
|
||||||
boolean foundName = StringUtils.isEqualForFilter(item.getName(), condition.getName());
|
boolean foundName = StringUtils.isEqualForFilter(item.getName(), condition.getName());
|
||||||
boolean foundTextItem = StringUtils.isEqualForFilter(item.getTextItem(), condition.getTextItem());
|
boolean foundTextItem = StringUtils.isEqualForFilter(item.getTextItem(), condition.getTextItem());
|
||||||
@@ -58,18 +56,7 @@ public class JoinedItemFilter implements Filter<JoinedItem>
|
|||||||
boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getCentre(), condition.getCentre());
|
boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getCentre(), condition.getCentre());
|
||||||
boolean foundOwner = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
|
boolean foundOwner = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
|
||||||
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
||||||
return (foundItemMaterial
|
return (foundCode && foundName && foundTextItem && foundDescription && foundQuantity && foundUnitPrice && foundMUnit && foundTotal && foundWorkgroup && foundCenter && foundOwner && foundDescription);
|
||||||
&& foundCode
|
|
||||||
&& foundName
|
|
||||||
&& foundTextItem
|
|
||||||
&& foundDescription
|
|
||||||
&& foundQuantity
|
|
||||||
&& foundUnitPrice
|
|
||||||
&& foundMUnit
|
|
||||||
&& foundTotal
|
|
||||||
&& foundWorkgroup
|
|
||||||
&& foundCenter
|
|
||||||
&& foundOwner && foundDescription);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Factory
|
@Factory
|
||||||
|
|||||||
@@ -42,24 +42,27 @@ public class OrderFilter implements Filter<Order>
|
|||||||
@Override
|
@Override
|
||||||
public boolean matchesSafely(Order item)
|
public boolean matchesSafely(Order item)
|
||||||
{
|
{
|
||||||
boolean foundOrdered = (item.isOrdered() == condition.isOrdered());
|
|
||||||
boolean foundNumSer = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser());
|
boolean foundNumSer = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser());
|
||||||
boolean foundOrderDate = DateTimeUtils.isEqualByDateForFilter(item.getOrderDate(), condition.getOrderDate());
|
boolean foundOrderDate = DateTimeUtils.isEqualByDateForFilter(item.getOrderDate(), condition.getOrderDate());
|
||||||
boolean foundTotal = true;// BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(),
|
boolean foundTotal = true;// BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(),
|
||||||
// condition.getTotal());
|
// condition.getTotal());
|
||||||
boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate());
|
boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate());
|
||||||
boolean foundDeliveredDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveredDate(), condition.getDeliveredDate());
|
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 foundSupplierAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getSuplier(), condition.getSuplier());
|
||||||
boolean foundDeliveryAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getDeliveryAddress(), condition.getDeliveryAddress());
|
boolean foundDeliveryAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getDeliveryAddress(), condition.getDeliveryAddress());
|
||||||
boolean foundInvoiceAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getAddress(), condition.getAddress());
|
boolean foundInvoiceAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getAddress(), condition.getAddress());
|
||||||
boolean foundOwnedBy = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
|
boolean foundOwnedBy = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
|
||||||
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
||||||
return (foundOrdered
|
return (foundNumSer
|
||||||
&& foundNumSer
|
|
||||||
&& foundOrderDate
|
&& foundOrderDate
|
||||||
&& foundTotal
|
&& foundTotal
|
||||||
&& foundDeliveryDate
|
&& foundDeliveryDate
|
||||||
&& foundDeliveredDate
|
&& foundDeliveredDate
|
||||||
|
&& foundInvoiceNumber
|
||||||
|
&& foundInvoiceTotal
|
||||||
&& foundSupplierAddr
|
&& foundSupplierAddr
|
||||||
&& foundDeliveryAddr
|
&& foundDeliveryAddr
|
||||||
&& foundInvoiceAddr
|
&& foundInvoiceAddr
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package info.bukova.isspst.filters;
|
package info.bukova.isspst.filters;
|
||||||
|
|
||||||
import info.bukova.isspst.BooleanUtils;
|
|
||||||
import info.bukova.isspst.DateTimeUtils;
|
import info.bukova.isspst.DateTimeUtils;
|
||||||
import info.bukova.isspst.StringUtils;
|
import info.bukova.isspst.StringUtils;
|
||||||
import info.bukova.isspst.data.Requirement;
|
import info.bukova.isspst.data.Requirement;
|
||||||
@@ -47,8 +46,7 @@ public class RequirementFilter implements Filter<Requirement>
|
|||||||
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
||||||
boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate());
|
boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate());
|
||||||
boolean foundUser = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
|
boolean foundUser = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
|
||||||
boolean foundProject = BooleanUtils.isEqualByBooleanValue(item.getProject(), condition.getProject());
|
return (foundNumser && foundReqDate && foundCenter && foundDescription && foundDeliveryDate && foundUser);
|
||||||
return (foundNumser && foundReqDate && foundCenter && foundDescription && foundDeliveryDate && foundUser && foundProject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Factory
|
@Factory
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package info.bukova.isspst.filters;
|
|||||||
import info.bukova.isspst.DateTimeUtils;
|
import info.bukova.isspst.DateTimeUtils;
|
||||||
import info.bukova.isspst.StringUtils;
|
import info.bukova.isspst.StringUtils;
|
||||||
import info.bukova.isspst.data.TripRequirement;
|
import info.bukova.isspst.data.TripRequirement;
|
||||||
import info.bukova.isspst.data.User;
|
|
||||||
|
|
||||||
import org.hamcrest.Description;
|
import org.hamcrest.Description;
|
||||||
import org.hamcrest.Factory;
|
import org.hamcrest.Factory;
|
||||||
@@ -46,7 +45,7 @@ public class TripRequirementFilter implements Filter<TripRequirement>
|
|||||||
boolean foundTo = StringUtils.isEqualForFilter(item.getTo(), condition.getTo());
|
boolean foundTo = StringUtils.isEqualForFilter(item.getTo(), condition.getTo());
|
||||||
boolean foundWorkgroup = (condition.getWorkgroup() == null ||(item.getWorkgroup() != null && item.getWorkgroup().equals(condition.getWorkgroup())));
|
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 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;
|
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,8 +1,5 @@
|
|||||||
package info.bukova.isspst.mail;
|
package info.bukova.isspst.mail;
|
||||||
|
|
||||||
import info.bukova.isspst.EntityUrlResolver;
|
|
||||||
import info.bukova.isspst.UrlResolverHolder;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,7 +12,6 @@ public class EntityMessageBuilder implements MessageBuilder {
|
|||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(EntityMessageBuilder.class);
|
private final static Logger logger = LoggerFactory.getLogger(EntityMessageBuilder.class);
|
||||||
private boolean html;
|
private boolean html;
|
||||||
private UrlResolverHolder urlResolverHolder;
|
|
||||||
|
|
||||||
public void setHtml(boolean html) {
|
public void setHtml(boolean html) {
|
||||||
this.html = html;
|
this.html = html;
|
||||||
@@ -57,11 +53,7 @@ public class EntityMessageBuilder implements MessageBuilder {
|
|||||||
|
|
||||||
for (String p : properties) {
|
for (String p : properties) {
|
||||||
try {
|
try {
|
||||||
if (p.equals("-url-")) {
|
ret = ret.replaceAll("\\[" + p + "\\]", BeanUtils.getProperty(data, p));
|
||||||
ret = ret.replaceAll("\\[" + p + "\\]", getUrl(data));
|
|
||||||
} else {
|
|
||||||
ret = ret.replaceAll("\\[" + p + "\\]", BeanUtils.getProperty(data, p));
|
|
||||||
}
|
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
@@ -76,17 +68,4 @@ public class EntityMessageBuilder implements MessageBuilder {
|
|||||||
return ret;
|
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.setFrom(message.getFrom());
|
||||||
helper.setReplyTo(message.getReplyTo());
|
helper.setReplyTo(message.getReplyTo());
|
||||||
helper.setTo(message.getTo());
|
helper.setTo(message.getTo());
|
||||||
@@ -67,7 +63,6 @@ public class MailerWithAttachement implements Mailer {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
sender.send(mimeMessage);
|
sender.send(mimeMessage);
|
||||||
logger.info("Mail queued for send");
|
|
||||||
} catch (MailAuthenticationException e) {
|
} catch (MailAuthenticationException e) {
|
||||||
logger.error("Authentication error");
|
logger.error("Authentication error");
|
||||||
} catch (MailSendException e) {
|
} catch (MailSendException e) {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package info.bukova.isspst.reporting;
|
package info.bukova.isspst.reporting;
|
||||||
|
|
||||||
import com.mysql.jdbc.StringUtils;
|
import java.util.HashMap;
|
||||||
import info.bukova.isspst.data.Address;
|
import java.util.Map;
|
||||||
|
|
||||||
import info.bukova.isspst.data.AuthItem;
|
import info.bukova.isspst.data.AuthItem;
|
||||||
import info.bukova.isspst.data.Order;
|
import info.bukova.isspst.data.Order;
|
||||||
import info.bukova.isspst.data.TripBill;
|
import info.bukova.isspst.data.TripBill;
|
||||||
@@ -9,13 +10,10 @@ import info.bukova.isspst.data.User;
|
|||||||
import info.bukova.isspst.data.UserSettingsData;
|
import info.bukova.isspst.data.UserSettingsData;
|
||||||
import info.bukova.isspst.services.requirement.TripRequirementService;
|
import info.bukova.isspst.services.requirement.TripRequirementService;
|
||||||
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
||||||
import info.bukova.isspst.services.tripbill.TripBillApprovalService;
|
|
||||||
import info.bukova.isspst.services.users.UserService;
|
import info.bukova.isspst.services.users.UserService;
|
||||||
import info.bukova.isspst.storage.FileStorage;
|
import info.bukova.isspst.storage.FileStorage;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ParamFiller {
|
public class ParamFiller {
|
||||||
|
|
||||||
@@ -29,8 +27,6 @@ public class ParamFiller {
|
|||||||
private TripRequirementService tripReqService;
|
private TripRequirementService tripReqService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private GlobalSettingsService settingService;
|
private GlobalSettingsService settingService;
|
||||||
@Autowired
|
|
||||||
private TripBillApprovalService tripBillApprovalService;
|
|
||||||
|
|
||||||
public void fill() {
|
public void fill() {
|
||||||
if (definition.getDataSet() == null || definition.getDataSet().isEmpty()) {
|
if (definition.getDataSet() == null || definition.getDataSet().isEmpty()) {
|
||||||
@@ -49,7 +45,6 @@ public class ParamFiller {
|
|||||||
|
|
||||||
if ((definition.getDataSet().get(0) instanceof TripBill)
|
if ((definition.getDataSet().get(0) instanceof TripBill)
|
||||||
&& definition.getReport().isSingleRecord()) {
|
&& definition.getReport().isSingleRecord()) {
|
||||||
|
|
||||||
if (userService.getUserSettings().getSignatureFile() != null
|
if (userService.getUserSettings().getSignatureFile() != null
|
||||||
&& !userService.getUserSettings().getSignatureFile().isEmpty()) {
|
&& !userService.getUserSettings().getSignatureFile().isEmpty()) {
|
||||||
definition.setParam("P_USER_SIGNATURE", storage.serverPath(userService.getUserSettings().getSignatureFile()));
|
definition.setParam("P_USER_SIGNATURE", storage.serverPath(userService.getUserSettings().getSignatureFile()));
|
||||||
@@ -57,32 +52,18 @@ public class ParamFiller {
|
|||||||
|
|
||||||
TripBill tb = (TripBill)definition.getDataSet().get(0);
|
TripBill tb = (TripBill)definition.getDataSet().get(0);
|
||||||
tripReqService.loadAuthItems(tb.getRequirement());
|
tripReqService.loadAuthItems(tb.getRequirement());
|
||||||
|
AuthItem lastAuth = tb.getRequirement().getAuthorization().get(tb.getRequirement().getAuthorization().size() - 1);
|
||||||
|
|
||||||
if (tb.getApproval() != null) {
|
definition.setParam("P_APPROVE_DATE", lastAuth.getAuthDate());
|
||||||
tripBillApprovalService.loadAuthItems(tb.getApproval());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tb.getApproval() != null && tb.getApproval().getAuthorization() != null && !tb.getApproval().getAuthorization().isEmpty()) {
|
User u = lastAuth.getApprover();
|
||||||
|
|
||||||
AuthItem lastButOneAuth = tb.getApproval().getAuthorization().get(0);
|
UserSettingsData approverSettings = userService.getUserSettings(u);
|
||||||
definition.setParam("P_PREV_APPROVE_DATE", lastButOneAuth.getAuthDate());
|
|
||||||
|
|
||||||
User lastButOneUser = lastButOneAuth.getApprover();
|
if (approverSettings != null
|
||||||
UserSettingsData prevApproverSettings = userService.getUserSettings(lastButOneUser);
|
&& approverSettings.getSignatureFile() != null
|
||||||
|
&& !approverSettings.getSignatureFile().isEmpty()) {
|
||||||
if (prevApproverSettings != null && !StringUtils.isNullOrEmpty(prevApproverSettings.getSignatureFile())) {
|
definition.setParam("P_APPROVER_SIGNATURE", storage.serverPath(approverSettings.getSignatureFile()));
|
||||||
definition.setParam("P_PREV_APPROVER_SIGNATURE", storage.serverPath(prevApproverSettings.getSignatureFile()));
|
|
||||||
}
|
|
||||||
|
|
||||||
AuthItem lastAuth = tb.getApproval().getAuthorization().get(tb.getRequirement().getAuthorization().size() - 1);
|
|
||||||
definition.setParam("P_APPROVE_DATE", lastAuth.getAuthDate());
|
|
||||||
|
|
||||||
User u = lastAuth.getApprover();
|
|
||||||
UserSettingsData approverSettings = userService.getUserSettings(u);
|
|
||||||
|
|
||||||
if (approverSettings != null && !StringUtils.isNullOrEmpty(approverSettings.getSignatureFile())) {
|
|
||||||
definition.setParam("P_APPROVER_SIGNATURE", storage.serverPath(approverSettings.getSignatureFile()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,15 +74,6 @@ public class ParamFiller {
|
|||||||
definition.setParam("P_STAMP", storage.serverPath(settingService.getSettings().getStampFile()));
|
definition.setParam("P_STAMP", storage.serverPath(settingService.getSettings().getStampFile()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
definition.setParam("P_LOGO", storage.serverPath(settingService.getSettings().getLogoFile()));
|
|
||||||
|
|
||||||
Address mainAddress = settingService.getSettings().getMainAddress();
|
|
||||||
|
|
||||||
if (mainAddress != null) {
|
|
||||||
String addr = (StringUtils.isNullOrEmpty(mainAddress.getCompany()) ? "" : mainAddress.getCompany());
|
|
||||||
definition.setParam("P_MAIN_ADDRESS", addr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,10 @@ public class Report {
|
|||||||
private String jasperFile;
|
private String jasperFile;
|
||||||
private boolean hasSettings;
|
private boolean hasSettings;
|
||||||
private boolean singleRecord;
|
private boolean singleRecord;
|
||||||
private boolean hasCondition;
|
|
||||||
|
|
||||||
public Report() {
|
public Report() {
|
||||||
hasSettings = false;
|
hasSettings = false;
|
||||||
singleRecord = false;
|
singleRecord = false;
|
||||||
hasCondition = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,19 +46,6 @@ public class Report {
|
|||||||
this.singleRecord = singleRecord;
|
this.singleRecord = singleRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @param jasperFile
|
|
||||||
* @param hasSettings
|
|
||||||
* @param singleRecord
|
|
||||||
* @param hasCondition
|
|
||||||
*/
|
|
||||||
public Report(String name, String jasperFile, boolean hasSettings, boolean singleRecord, boolean hasCondition) {
|
|
||||||
this(name, jasperFile, hasSettings, singleRecord);
|
|
||||||
this.hasCondition = hasCondition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReportType getType() {
|
public ReportType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -101,11 +86,4 @@ public class Report {
|
|||||||
this.singleRecord = singleRecord;
|
this.singleRecord = singleRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHasCondition() {
|
|
||||||
return hasCondition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHasCondition(boolean hasCondition) {
|
|
||||||
this.hasCondition = hasCondition;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,16 +24,10 @@ public abstract class AbstractRequirementEvaluator extends AbstractModuleEvaluat
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetDomainObject instanceof RequirementBase) {
|
RequirementBase req = (RequirementBase) targetDomainObject;
|
||||||
RequirementBase req = (RequirementBase) targetDomainObject;
|
|
||||||
|
|
||||||
if (permission.equals(Constants.PERM_EDIT_NEW)) {
|
if (permission.equals(Constants.PERM_EDIT_NEW)) {
|
||||||
return req.getState() == RequirementState.NEW;
|
return req.getState() == RequirementState.NEW;
|
||||||
}
|
|
||||||
|
|
||||||
if (permission.equals(Constants.PERM_DELETE_NEW)) {
|
|
||||||
return req.getState() == RequirementState.NEW;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
package info.bukova.isspst.security;
|
|
||||||
|
|
||||||
public enum AuthMethod {
|
|
||||||
|
|
||||||
DATABASE,
|
|
||||||
LDAP,
|
|
||||||
AD
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -23,7 +23,6 @@ public class AuthPopulator implements LdapAuthoritiesPopulator {
|
|||||||
public AuthPopulator(UserService userService, RoleService roleService) {
|
public AuthPopulator(UserService userService, RoleService roleService) {
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.roleService = roleService;
|
this.roleService = roleService;
|
||||||
userService.setAuthMethod(AuthMethod.LDAP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package info.bukova.isspst.security;
|
package info.bukova.isspst.security;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
import info.bukova.isspst.Constants;
|
||||||
import info.bukova.isspst.Module;
|
|
||||||
import info.bukova.isspst.data.Permission;
|
import info.bukova.isspst.data.Permission;
|
||||||
import info.bukova.isspst.data.PermissionType;
|
import info.bukova.isspst.data.PermissionType;
|
||||||
import info.bukova.isspst.data.Role;
|
import info.bukova.isspst.data.Role;
|
||||||
import info.bukova.isspst.data.User;
|
import info.bukova.isspst.data.User;
|
||||||
import info.bukova.isspst.data.Workgroup;
|
import info.bukova.isspst.data.Workgroup;
|
||||||
import info.bukova.isspst.services.Service;
|
|
||||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -41,31 +39,11 @@ public class WorkgroupAwareServiceEvaluator implements Evaluator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
User user = (User)authentication.getPrincipal();
|
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;
|
Permission appPermission = null;
|
||||||
for (Permission p : Constants.SPECIAL_PERMISSIONS) {
|
for (Permission p : Constants.SPECIAL_PERMISSIONS) {
|
||||||
if (p.getAuthority().equals(permission)
|
if (p.getAuthority().equals(permission)) {
|
||||||
&& p.getModule().equals(moduleId)) {
|
|
||||||
appPermission = p;
|
appPermission = p;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,8 +66,7 @@ public class WorkgroupAwareServiceEvaluator implements Evaluator {
|
|||||||
|
|
||||||
for (Role r : wgRoles) {
|
for (Role r : wgRoles) {
|
||||||
for (Permission p : r.getPermissions()) {
|
for (Permission p : r.getPermissions()) {
|
||||||
if (p.getAuthority().equals(appPermission.getAuthority())
|
if (p.getAuthority().equals(appPermission.getAuthority())) {
|
||||||
&& p.getModule().equals(appPermission.getModule())) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package info.bukova.isspst.services;
|
package info.bukova.isspst.services;
|
||||||
|
|
||||||
import info.bukova.isspst.data.OwnedDataModel;
|
import java.util.Date;
|
||||||
import info.bukova.isspst.data.User;
|
|
||||||
import org.hibernate.NonUniqueResultException;
|
import org.hibernate.NonUniqueResultException;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@@ -9,7 +9,8 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
|||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Date;
|
import info.bukova.isspst.data.OwnedDataModel;
|
||||||
|
import info.bukova.isspst.data.User;
|
||||||
|
|
||||||
public class AbstractOwnedService<T extends OwnedDataModel> extends AbstractService<T> {
|
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.setModifiedBy(getLoggedInUser());
|
||||||
entity.setModified(new Date());
|
entity.setModified(new Date());
|
||||||
dao.modify(entity);
|
dao.modify(entity);
|
||||||
maintainStorrage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package info.bukova.isspst.services;
|
package info.bukova.isspst.services;
|
||||||
|
|
||||||
|
import static ch.lambdaj.Lambda.filter;
|
||||||
|
import info.bukova.isspst.Constants;
|
||||||
import info.bukova.isspst.Module;
|
import info.bukova.isspst.Module;
|
||||||
import info.bukova.isspst.ModuleUtils;
|
|
||||||
import info.bukova.isspst.SessionData;
|
import info.bukova.isspst.SessionData;
|
||||||
import info.bukova.isspst.dao.BaseDao;
|
import info.bukova.isspst.dao.BaseDao;
|
||||||
import info.bukova.isspst.dao.QueryDao;
|
import info.bukova.isspst.dao.QueryDao;
|
||||||
@@ -10,15 +11,7 @@ import info.bukova.isspst.data.NumberSeries;
|
|||||||
import info.bukova.isspst.filters.Filter;
|
import info.bukova.isspst.filters.Filter;
|
||||||
import info.bukova.isspst.reporting.Report;
|
import info.bukova.isspst.reporting.Report;
|
||||||
import info.bukova.isspst.services.numberseries.NumberSeriesService;
|
import info.bukova.isspst.services.numberseries.NumberSeriesService;
|
||||||
import info.bukova.isspst.storage.DocumentFileStorage;
|
|
||||||
import org.hibernate.NonUniqueResultException;
|
|
||||||
import org.hibernate.Query;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import javax.validation.ConstraintViolation;
|
|
||||||
import javax.validation.Validator;
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@@ -27,7 +20,14 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
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> {
|
public abstract class AbstractService<T extends DataModel> implements Service<T> {
|
||||||
|
|
||||||
@@ -37,15 +37,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
protected SessionData sessionData;
|
protected SessionData sessionData;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected QueryDao queryDao;
|
protected QueryDao queryDao;
|
||||||
private DocumentFileStorage documentFileStorage;
|
|
||||||
|
|
||||||
private NumberSeriesService numberSeriesService;
|
private NumberSeriesService numberSeriesService;
|
||||||
|
|
||||||
|
|
||||||
public void setDocumentFileStorage(DocumentFileStorage storage) {
|
|
||||||
this.documentFileStorage = storage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NumberSeriesService getNumberSeriesService()
|
public NumberSeriesService getNumberSeriesService()
|
||||||
{
|
{
|
||||||
return numberSeriesService;
|
return numberSeriesService;
|
||||||
@@ -64,16 +59,6 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDeleteEntityPermission() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void maintainStorrage() {
|
|
||||||
if (documentFileStorage != null) {
|
|
||||||
documentFileStorage.purge();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
|
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
|
||||||
public final T create() {
|
public final T create() {
|
||||||
@@ -88,10 +73,6 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
throw new IsspstException("DAO is null");
|
throw new IsspstException("DAO is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getModule() != null && !getModule().isActive()) {
|
|
||||||
throw new ModuleNotActiveException();
|
|
||||||
}
|
|
||||||
|
|
||||||
validate(entity);
|
validate(entity);
|
||||||
entity.setCreated(new Date());
|
entity.setCreated(new Date());
|
||||||
dao.add(entity);
|
dao.add(entity);
|
||||||
@@ -105,31 +86,20 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
throw new IsspstException("DAO is null");
|
throw new IsspstException("DAO is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getModule() != null && !getModule().isActive()) {
|
|
||||||
throw new ModuleNotActiveException();
|
|
||||||
}
|
|
||||||
|
|
||||||
validate(entity);
|
validate(entity);
|
||||||
entity.setModified(new Date());
|
entity.setModified(new Date());
|
||||||
dao.modify(entity);
|
dao.modify(entity);
|
||||||
maintainStorrage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_DELETE') or hasPermission(#entity, this.getDeleteEntityPermission())")
|
@PreAuthorize("hasPermission(this, 'PERM_DELETE')")
|
||||||
public void delete(T entity) {
|
public void delete(T entity) {
|
||||||
if (dao == null) {
|
if (dao == null) {
|
||||||
throw new IsspstException("DAO is null");
|
throw new IsspstException("DAO is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getModule() != null && !getModule().isActive()) {
|
|
||||||
throw new ModuleNotActiveException();
|
|
||||||
}
|
|
||||||
|
|
||||||
dao.delete(entity);
|
dao.delete(entity);
|
||||||
|
|
||||||
maintainStorrage(); // poklidit přiložené soubory
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -167,10 +137,6 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
throw new IsspstException("DAO is null");
|
throw new IsspstException("DAO is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getModule() != null && !getModule().isActive()) {
|
|
||||||
throw new ModuleNotActiveException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.getById(id);
|
return dao.getById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,10 +148,6 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
throw new IsspstException("DAO is null");
|
throw new IsspstException("DAO is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getModule() != null && !getModule().isActive()) {
|
|
||||||
throw new ModuleNotActiveException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.getAll();
|
return dao.getAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,10 +159,6 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
throw new IsspstException("DAO is null");
|
throw new IsspstException("DAO is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getModule() != null && !getModule().isActive()) {
|
|
||||||
throw new ModuleNotActiveException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return dao.execQuery(query);
|
return dao.execQuery(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,10 +171,6 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
throw new IsspstException("DAO is null");
|
throw new IsspstException("DAO is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getModule() != null && !getModule().isActive()) {
|
|
||||||
throw new ModuleNotActiveException();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Query q = dao.getQuery(query);
|
Query q = dao.getQuery(query);
|
||||||
return (T) q.uniqueResult();
|
return (T) q.uniqueResult();
|
||||||
@@ -235,7 +189,13 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Module getModule() {
|
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() {
|
public List<Report> getReports() {
|
||||||
@@ -274,10 +234,6 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void loadLazyData(String group, T entity) {
|
public void loadLazyData(String group, T entity) {
|
||||||
if (entity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Method[] methods = this.getClass().getMethods();
|
Method[] methods = this.getClass().getMethods();
|
||||||
|
|
||||||
for (Method m : methods) {
|
for (Method m : methods) {
|
||||||
@@ -300,9 +256,4 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPrintRecord(T entity) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package info.bukova.isspst.services;
|
|
||||||
|
|
||||||
public class ModuleNotActiveException extends IsspstException {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -1219763294556500698L;
|
|
||||||
|
|
||||||
public ModuleNotActiveException() {
|
|
||||||
super("Module deactivated");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -22,6 +22,5 @@ public interface Service<T> {
|
|||||||
public List<T> filterList(List<T> sourceList, Filter<T> filter);
|
public List<T> filterList(List<T> sourceList, Filter<T> filter);
|
||||||
public Module getModule();
|
public Module getModule();
|
||||||
public List<Report> getReports();
|
public List<Report> getReports();
|
||||||
public boolean canPrintRecord(T entity);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package info.bukova.isspst.services.orders;
|
package info.bukova.isspst.services.approved;
|
||||||
|
|
||||||
import info.bukova.isspst.data.JoinedItem;
|
import info.bukova.isspst.data.JoinedItem;
|
||||||
import info.bukova.isspst.services.Service;
|
import info.bukova.isspst.services.Service;
|
||||||
+3
-35
@@ -1,13 +1,9 @@
|
|||||||
package info.bukova.isspst.services.orders;
|
package info.bukova.isspst.services.approved;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
import info.bukova.isspst.Module;
|
|
||||||
import info.bukova.isspst.data.JoinedItem;
|
import info.bukova.isspst.data.JoinedItem;
|
||||||
import info.bukova.isspst.data.RequirementItem;
|
import info.bukova.isspst.data.RequirementItem;
|
||||||
import info.bukova.isspst.data.RequirementState;
|
import info.bukova.isspst.data.RequirementState;
|
||||||
import info.bukova.isspst.data.Workgroup;
|
import info.bukova.isspst.data.Workgroup;
|
||||||
import info.bukova.isspst.reporting.Report;
|
|
||||||
import info.bukova.isspst.reporting.ReportType;
|
|
||||||
import info.bukova.isspst.services.AbstractService;
|
import info.bukova.isspst.services.AbstractService;
|
||||||
import info.bukova.isspst.services.users.UserService;
|
import info.bukova.isspst.services.users.UserService;
|
||||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||||
@@ -38,13 +34,8 @@ public class ApprovedServiceImpl extends AbstractService<JoinedItem> implements
|
|||||||
public List<JoinedItem> getAll()
|
public List<JoinedItem> getAll()
|
||||||
{
|
{
|
||||||
List<Workgroup> wgList = workgroupService.getUserCentres(userService.getCurrent());
|
List<Workgroup> wgList = workgroupService.getUserCentres(userService.getCurrent());
|
||||||
Query q = queryDao.getQuery("select item "
|
Query q = queryDao
|
||||||
+ "from RequirementItem item left join item.requirement rq join rq.centre c "
|
.getQuery("select item from RequirementItem item left join item.requirement rq join rq.centre c where rq.kind is not null and rq.state = :state and c in (:wgList)");
|
||||||
+ "where rq.kind is not null "
|
|
||||||
+ "and rq.state = :state "
|
|
||||||
+ "and (rq.project Is Null or rq.project = false) "
|
|
||||||
+ "and c in (:wgList) "
|
|
||||||
+ "and (item.orderNum Is Null or item.orderNum = '')");
|
|
||||||
q.setParameterList("wgList", wgList);
|
q.setParameterList("wgList", wgList);
|
||||||
q.setParameter("state", RequirementState.APPROVED);
|
q.setParameter("state", RequirementState.APPROVED);
|
||||||
List<JoinedItem> items = new ArrayList<JoinedItem>();
|
List<JoinedItem> items = new ArrayList<JoinedItem>();
|
||||||
@@ -59,27 +50,4 @@ public class ApprovedServiceImpl extends AbstractService<JoinedItem> implements
|
|||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Module getModule() {
|
|
||||||
for (Module m : Constants.MODULES) {
|
|
||||||
if (m.getId() == Constants.MOD_REQUIREMENTS) {
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Report> getReports() {
|
|
||||||
Report rep = new Report();
|
|
||||||
rep.setType(ReportType.DYNAMIC);
|
|
||||||
rep.setName(Constants.DYNAMIC_REPORT_NAME);
|
|
||||||
|
|
||||||
List<Report> ret = new ArrayList<Report>();
|
|
||||||
ret.add(rep);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+1
-4
@@ -1,4 +1,4 @@
|
|||||||
package info.bukova.isspst.services.orders;
|
package info.bukova.isspst.services.approved;
|
||||||
|
|
||||||
import info.bukova.isspst.data.JoinedItem;
|
import info.bukova.isspst.data.JoinedItem;
|
||||||
import info.bukova.isspst.data.Order;
|
import info.bukova.isspst.data.Order;
|
||||||
@@ -22,7 +22,4 @@ public interface OrderService extends Service<Order> {
|
|||||||
|
|
||||||
public BigDecimal calcSumTotalFromItems(List<OrderItem> items);
|
public BigDecimal calcSumTotalFromItems(List<OrderItem> items);
|
||||||
|
|
||||||
public void addApprovedItems(Order order, boolean orderedChanged);
|
|
||||||
|
|
||||||
public void updateApprovedItems(Order order, boolean orderedChanged);
|
|
||||||
}
|
}
|
||||||
+4
-65
@@ -1,11 +1,9 @@
|
|||||||
package info.bukova.isspst.services.orders;
|
package info.bukova.isspst.services.approved;
|
||||||
|
|
||||||
import info.bukova.isspst.dao.RequirementItemDao;
|
|
||||||
import info.bukova.isspst.data.AddressEmb;
|
import info.bukova.isspst.data.AddressEmb;
|
||||||
import info.bukova.isspst.data.JoinedItem;
|
import info.bukova.isspst.data.JoinedItem;
|
||||||
import info.bukova.isspst.data.Order;
|
import info.bukova.isspst.data.Order;
|
||||||
import info.bukova.isspst.data.OrderItem;
|
import info.bukova.isspst.data.OrderItem;
|
||||||
import info.bukova.isspst.data.RequirementItem;
|
|
||||||
import info.bukova.isspst.data.Workgroup;
|
import info.bukova.isspst.data.Workgroup;
|
||||||
import info.bukova.isspst.services.AbstractOwnedService;
|
import info.bukova.isspst.services.AbstractOwnedService;
|
||||||
import info.bukova.isspst.services.LazyLoader;
|
import info.bukova.isspst.services.LazyLoader;
|
||||||
@@ -26,9 +24,6 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
|
|||||||
@Autowired
|
@Autowired
|
||||||
private GlobalSettingsService globalSettings;
|
private GlobalSettingsService globalSettings;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RequirementItemDao requirementItemDao;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
|
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
|
||||||
public Order createOrder(List<JoinedItem> items) {
|
public Order createOrder(List<JoinedItem> items) {
|
||||||
@@ -52,13 +47,10 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public BigDecimal totalOrderedForWorkgroup(Workgroup workgroup)
|
public BigDecimal totalOrderedForWorkgroup(Workgroup workgroup) {
|
||||||
{
|
Query q = dao.getQuery("select sum(oi.total) from OrderItem oi join oi.reqItem ri join ri.requirement rq join rq.workgroup w where ri.delivered = true and w = :workgroup");
|
||||||
Query q = dao.getQuery("select sum(oi.total) "
|
|
||||||
+ "from OrderItem oi join oi.reqItem ri join ri.requirement rq join rq.workgroup w "
|
|
||||||
+ "where (ri.orderNum is not null or ri.orderNum = '') and w = :workgroup ");
|
|
||||||
q.setParameter("workgroup", workgroup);
|
q.setParameter("workgroup", workgroup);
|
||||||
return (BigDecimal) q.uniqueResult();
|
return (BigDecimal)q.uniqueResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -179,57 +171,4 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
|
|||||||
|
|
||||||
return sumTotal;
|
return sumTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setApprovedItems(Order order, boolean orderedChanged)
|
|
||||||
{
|
|
||||||
if (orderedChanged)
|
|
||||||
{
|
|
||||||
for (OrderItem item : order.getItems())
|
|
||||||
{
|
|
||||||
RequirementItem rItem = item.getReqItem();
|
|
||||||
|
|
||||||
if (rItem != null)
|
|
||||||
{
|
|
||||||
rItem.setOrderNum(order.isOrdered() ? order.getNumser() : null);
|
|
||||||
requirementItemDao.modify(rItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
|
|
||||||
public void addApprovedItems(Order order, boolean orderedChanged)
|
|
||||||
{
|
|
||||||
this.add(order);
|
|
||||||
this.setApprovedItems(order, orderedChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
|
|
||||||
public void updateApprovedItems(Order order, boolean orderedChanged)
|
|
||||||
{
|
|
||||||
this.setApprovedItems(order, orderedChanged);
|
|
||||||
super.update(order);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_DELETE') or hasPermission(#entity, this.getDeleteEntityPermission())")
|
|
||||||
public void delete(Order order) {
|
|
||||||
for (OrderItem item : order.getItems())
|
|
||||||
{
|
|
||||||
RequirementItem rItem = item.getReqItem();
|
|
||||||
|
|
||||||
if (rItem != null)
|
|
||||||
{
|
|
||||||
rItem.setOrderNum(null);
|
|
||||||
requirementItemDao.modify(rItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
super.delete(order);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package info.bukova.isspst.services.dbinfo;
|
|
||||||
|
|
||||||
import info.bukova.isspst.data.DbInfo;
|
|
||||||
import info.bukova.isspst.services.Service;
|
|
||||||
|
|
||||||
public interface DbInfoService extends Service<DbInfo>
|
|
||||||
{
|
|
||||||
public void changeDatabase();
|
|
||||||
|
|
||||||
public void updateDatabaseVersion();
|
|
||||||
}
|
|
||||||
@@ -1,157 +0,0 @@
|
|||||||
package info.bukova.isspst.services.dbinfo;
|
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
|
||||||
import info.bukova.isspst.data.DbInfo;
|
|
||||||
import info.bukova.isspst.services.AbstractService;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hibernate.SQLQuery;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfoService
|
|
||||||
{
|
|
||||||
private DbInfo getDbInfo()
|
|
||||||
{
|
|
||||||
DbInfo dbInfo = null;
|
|
||||||
|
|
||||||
List<DbInfo> list = this.getAll();
|
|
||||||
|
|
||||||
if (list.isEmpty())
|
|
||||||
{
|
|
||||||
dbInfo = new DbInfo();
|
|
||||||
this.add(dbInfo);
|
|
||||||
list = this.getAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (DbInfo item : list)
|
|
||||||
{
|
|
||||||
dbInfo = item;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dbInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void changeDatabase()
|
|
||||||
{
|
|
||||||
class Str2Str
|
|
||||||
{
|
|
||||||
private String key;
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
public Str2Str(String key, String value)
|
|
||||||
{
|
|
||||||
this.key = key;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKey()
|
|
||||||
{
|
|
||||||
return this.key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue()
|
|
||||||
{
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// String source = UserCountUtils.encryptUserCount(1000);
|
|
||||||
// long users = UserCountUtils.decryptUserCount(source);
|
|
||||||
|
|
||||||
long dbVersion = this.getDbInfo().getVersion();
|
|
||||||
|
|
||||||
if (Constants.DB_VERSION > dbVersion)
|
|
||||||
{
|
|
||||||
SQLQuery sq = null;
|
|
||||||
String sql = "";
|
|
||||||
|
|
||||||
if (dbVersion < 1)
|
|
||||||
{
|
|
||||||
List<Str2Str> tables = new ArrayList<Str2Str>();
|
|
||||||
|
|
||||||
tables.add(new Str2Str("ADDRESS", "DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("BUILDING", "DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("MATERIAL", "DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("MUNIT", "DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("ORDERS", "DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("ORDER_ITEM", "DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("PERMISSION", "DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("REQUIREMENT", "DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("REQUIREMENTTYPE", "DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("REQUIREMENT_ITEMS", "DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("ROLE", "DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("SERVICE", "DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("TRIPREQUIREMENT", "DESCRIPTION"));
|
|
||||||
|
|
||||||
tables.add(new Str2Str("MATERIAL", "MUNIT_DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("ORDERS", "INVOICE_DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("ORDERS", "DELIVERY_DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("ORDERS", "SUPPLIER_DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("ORDER_ITEM", "MUNIT_DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("REQUIREMENT_ITEMS", "MUNIT_DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("TRIPREQUIREMENT", "VEHICLE_DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("TRIP_BILL_ITEMS", "BACK_VEHICLE_DESCRIPTION"));
|
|
||||||
tables.add(new Str2Str("TRIP_BILL_ITEMS", "VEHICLE_DESCRIPTION"));
|
|
||||||
|
|
||||||
for (Str2Str item : tables)
|
|
||||||
{
|
|
||||||
sql = "ALTER TABLE " + item.getKey() + " MODIFY " + item.getValue() + " VARCHAR(" + String.valueOf(Constants.LEN_DESCRIPTION) + ")";
|
|
||||||
sq = this.dao.getSession().createSQLQuery(sql);
|
|
||||||
sq.executeUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dbVersion < 2)
|
|
||||||
{
|
|
||||||
List<String> tables = new ArrayList<String>();
|
|
||||||
|
|
||||||
tables.add("MATERIAL");
|
|
||||||
tables.add("ORDER_ITEM");
|
|
||||||
tables.add("REQUIREMENT_ITEMS");
|
|
||||||
|
|
||||||
for (String item : tables)
|
|
||||||
{
|
|
||||||
sql = "UPDATE " + item + " SET MUNIT_ID = 0 WHERE (MUNIT_ID Is NULL) ";
|
|
||||||
sq = this.dao.getSession().createSQLQuery(sql);
|
|
||||||
sq.executeUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dbVersion < 3)
|
|
||||||
{
|
|
||||||
sql = "UPDATE INVOICING SET COMPLETED = false WHERE (COMPLETED Is NULL) ";
|
|
||||||
sq = this.dao.getSession().createSQLQuery(sql);
|
|
||||||
sq.executeUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dbVersion < 4)
|
|
||||||
{
|
|
||||||
sql = "UPDATE TRIP_BILL SET RESULT_MESSAGE = 'Zpráva z pracovní cesty' WHERE (RESULT_MESSAGE Is NULL) ";
|
|
||||||
sq = this.dao.getSession().createSQLQuery(sql);
|
|
||||||
sq.executeUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dbVersion < 5) {
|
|
||||||
sql = "ALTER TABLE TRIP_BILL MODIFY RESULT_MESSAGE VARCHAR(" + String.valueOf(Constants.LEN_RESULT_MESSAGE) + ")";
|
|
||||||
sq = this.dao.getSession().createSQLQuery(sql);
|
|
||||||
sq.executeUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateDatabaseVersion();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void updateDatabaseVersion()
|
|
||||||
{
|
|
||||||
DbInfo dbInfo = this.getDbInfo();
|
|
||||||
dbInfo.setVersion(Constants.DB_VERSION);
|
|
||||||
this.update(dbInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package info.bukova.isspst.services.fulltext;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*/
|
|
||||||
public abstract class AbstractExtractor implements Extractor {
|
|
||||||
|
|
||||||
public String extract(byte[] data) {
|
|
||||||
return extract(new ByteArrayInputStream(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package info.bukova.isspst.services.fulltext;
|
|
||||||
|
|
||||||
import org.apache.poi.POIXMLTextExtractor;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*/
|
|
||||||
public abstract class AbstractOfficeExtractor extends AbstractExtractor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String extract(InputStream is) throws ExtractorException {
|
|
||||||
try {
|
|
||||||
POIXMLTextExtractor extractor = createExtractor(is);
|
|
||||||
return extractor.getText();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new ExtractorException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract POIXMLTextExtractor createExtractor(InputStream is) throws IOException;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package info.bukova.isspst.services.fulltext;
|
|
||||||
|
|
||||||
import org.apache.poi.POIXMLTextExtractor;
|
|
||||||
import org.apache.poi.xssf.extractor.XSSFExcelExtractor;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*/
|
|
||||||
public class ExcelExtractor extends AbstractOfficeExtractor implements Extractor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected POIXMLTextExtractor createExtractor(InputStream is) throws IOException {
|
|
||||||
return new XSSFExcelExtractor(new XSSFWorkbook(is));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package info.bukova.isspst.services.fulltext;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*
|
|
||||||
* Rozhraní extractoru čistého textu z formátů Office a PDF
|
|
||||||
*/
|
|
||||||
public interface Extractor {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extrahuje text z předaného pole bytů
|
|
||||||
*
|
|
||||||
* @param data zdrajová data
|
|
||||||
* @return čistý text
|
|
||||||
* @throws ExtractorException
|
|
||||||
*/
|
|
||||||
public String extract(byte[] data) throws ExtractorException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extrahuje text z předaného InputStream objektu
|
|
||||||
*
|
|
||||||
* @param is zdrojový InputStream
|
|
||||||
* @return čistý text
|
|
||||||
* @throws ExtractorException
|
|
||||||
*/
|
|
||||||
public String extract(InputStream is) throws ExtractorException;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package info.bukova.isspst.services.fulltext;
|
|
||||||
|
|
||||||
import info.bukova.isspst.services.IsspstException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*
|
|
||||||
* Výjimka extrakce textu
|
|
||||||
*/
|
|
||||||
public class ExtractorException extends IsspstException {
|
|
||||||
|
|
||||||
public ExtractorException(Throwable cause) {
|
|
||||||
super("Extractor exception: ", cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package info.bukova.isspst.services.fulltext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*
|
|
||||||
* Factory pro konkrétní extractor
|
|
||||||
*/
|
|
||||||
public class ExtractorFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Vytvoří extractor podle předaného content typu
|
|
||||||
*
|
|
||||||
* @param contentType
|
|
||||||
* @return Extractor
|
|
||||||
*/
|
|
||||||
public static Extractor createExtractor(String contentType) {
|
|
||||||
if (contentType.equals("application/vnd.oasis.opendocument.text")
|
|
||||||
|| contentType.equals("application/vnd.oasis.opendocument.spreadsheet")
|
|
||||||
|| contentType.equals("application/vnd.oasis.opendocument.presentation")) {
|
|
||||||
return new OdfExtractor();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contentType.equals("application/vnd.openxmlformats-officedocument.wordprocessingml.document")) {
|
|
||||||
return new WordExtractor();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contentType.equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) {
|
|
||||||
return new ExcelExtractor();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contentType.equals("application/vnd.openxmlformats-officedocument.presentationml.slideshow")) {
|
|
||||||
return new PowerPointExtractor();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contentType.equals("application/pdf")) {
|
|
||||||
return new PdfExtractor();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package info.bukova.isspst.services.fulltext;
|
|
||||||
|
|
||||||
import org.hibernate.search.annotations.Field;
|
|
||||||
import org.hibernate.search.annotations.Indexed;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*
|
|
||||||
* Rozhraní služby fulltextového vyhledávání
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface FullTextService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Přegeneruje fulltextový index.
|
|
||||||
*/
|
|
||||||
public void reindex();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Vyhledává entity zadané třídy. Třída entity musí být anotovaná {@link Indexed}
|
|
||||||
*
|
|
||||||
* @param entityClass třída entity k vyhledání
|
|
||||||
* @param fields property entity kde se bude vyhledávat. Musí být anotované {@link Field}
|
|
||||||
* @param word vyhledávaný výraz
|
|
||||||
* @return list odpovídajících entit
|
|
||||||
*/
|
|
||||||
public List<?> search(Class<?> entityClass, String[] fields, String word);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Globální vyhledávání ve všech entitách, jejichš třídy jsou anotované {@link Indexed} a
|
|
||||||
* property {@link Field}
|
|
||||||
*
|
|
||||||
* @param word vyhledávaný výraz
|
|
||||||
* @return list odpovídajících entit
|
|
||||||
*/
|
|
||||||
public List<?> globalSearch(String word);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,154 +0,0 @@
|
|||||||
package info.bukova.isspst.services.fulltext;
|
|
||||||
|
|
||||||
import info.bukova.isspst.ModuleUtils;
|
|
||||||
import info.bukova.isspst.dao.QueryDao;
|
|
||||||
import info.bukova.isspst.data.BaseData;
|
|
||||||
import info.bukova.isspst.data.User;
|
|
||||||
import info.bukova.isspst.services.ModuleNotActiveException;
|
|
||||||
import info.bukova.isspst.sort.ReflectionTools;
|
|
||||||
import org.apache.lucene.search.Query;
|
|
||||||
import org.apache.lucene.search.Sort;
|
|
||||||
import org.hibernate.Hibernate;
|
|
||||||
import org.hibernate.search.FullTextQuery;
|
|
||||||
import org.hibernate.search.FullTextSession;
|
|
||||||
import org.hibernate.search.Search;
|
|
||||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
|
||||||
import org.hibernate.search.query.dsl.QueryBuilder;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class FullTextServiceImpl implements FullTextService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private QueryDao queryDao;
|
|
||||||
private List<Class<?>> classesForSearch;
|
|
||||||
private Map<Class<?>, String[]> fields;
|
|
||||||
private List<Class<?>> nestedClasses;
|
|
||||||
|
|
||||||
public FullTextServiceImpl() {
|
|
||||||
nestedClasses = new ArrayList<Class<?>>();
|
|
||||||
nestedClasses.add(User.class);
|
|
||||||
nestedClasses.add(BaseData.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void reindex() {
|
|
||||||
Logger logger = LoggerFactory.getLogger(FullTextServiceImpl.class);
|
|
||||||
logger.info("Indexing database for fulltext search");
|
|
||||||
FullTextSession ftSession = Search.getFullTextSession(queryDao.getSession());
|
|
||||||
ftSession.createIndexer().start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_SEARCH')")
|
|
||||||
public List<?> search(Class<?> entityClass, String[] fields, String word) {
|
|
||||||
checkActivity();
|
|
||||||
FullTextSession session = Search.getFullTextSession(queryDao.getSession());
|
|
||||||
QueryBuilder qb = session.getSearchFactory().buildQueryBuilder().forEntity(entityClass).get();
|
|
||||||
|
|
||||||
Query luceneQuery = qb.keyword().onFields(fields).matching(word).createQuery();
|
|
||||||
FullTextQuery hiberQuery = session.createFullTextQuery(luceneQuery, entityClass);
|
|
||||||
hiberQuery.setSort(Sort.RELEVANCE);
|
|
||||||
|
|
||||||
return hiberQuery.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_SEARCH')")
|
|
||||||
public List<?> globalSearch(String word) {
|
|
||||||
checkActivity();
|
|
||||||
List<Object> result = new ArrayList<Object>();
|
|
||||||
|
|
||||||
for (Class<?> clazz : classesForSearch()) {
|
|
||||||
result.addAll(search(clazz, fields.get(clazz), word));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Object o : result) {
|
|
||||||
BaseData data = (BaseData) o;
|
|
||||||
Hibernate.initialize(data.getModifiedBy());
|
|
||||||
Hibernate.initialize(data.getOwnedBy());
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkActivity() {
|
|
||||||
if (!ModuleUtils.getModule(this.getClass()).isActive()) {
|
|
||||||
throw new ModuleNotActiveException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Class<?>> classesForSearch() {
|
|
||||||
if (classesForSearch != null) {
|
|
||||||
return classesForSearch;
|
|
||||||
}
|
|
||||||
|
|
||||||
classesForSearch = new ArrayList<Class<?>>();
|
|
||||||
fields = new HashMap<Class<?>, String[]>();
|
|
||||||
FullTextSession session = Search.getFullTextSession(queryDao.getSession());
|
|
||||||
|
|
||||||
for (Class<?> clazz : session.getSearchFactory().getIndexedTypes()) {
|
|
||||||
if (nestedClasses.contains(clazz)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
classesForSearch.add(clazz);
|
|
||||||
fields.put(clazz, fields(clazz, ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
return classesForSearch;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] fields(Class<?> clazz, String prefix) {
|
|
||||||
List<String> res = new ArrayList<String>();
|
|
||||||
|
|
||||||
for (Field field : ReflectionTools.getFields(clazz)) {
|
|
||||||
for (Annotation a : field.getDeclaredAnnotations()) {
|
|
||||||
if (a instanceof org.hibernate.search.annotations.Field) {
|
|
||||||
res.add(prefix + field.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (a instanceof IndexedEmbedded) {
|
|
||||||
Class<?> fieldClass;
|
|
||||||
|
|
||||||
fieldClass = field.getType();
|
|
||||||
if (fieldClass.isAssignableFrom(List.class)) {
|
|
||||||
ParameterizedType type = (ParameterizedType) field.getGenericType();
|
|
||||||
Type[] types = type.getActualTypeArguments();
|
|
||||||
if (types.length == 1) {
|
|
||||||
fieldClass = (Class<?>)types[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
classesForSearch.remove(fieldClass);
|
|
||||||
fields.remove(fieldClass);
|
|
||||||
nestedClasses.add(fieldClass);
|
|
||||||
|
|
||||||
String nestedPrefix = prefix + field.getName() + ".";
|
|
||||||
res.addAll(Arrays.asList(fields(fieldClass, nestedPrefix)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String resArray[] = new String[res.size()];
|
|
||||||
resArray = res.toArray(resArray);
|
|
||||||
return resArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package info.bukova.isspst.services.fulltext;
|
|
||||||
|
|
||||||
import org.odftoolkit.simple.Document;
|
|
||||||
import org.odftoolkit.simple.common.TextExtractor;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*/
|
|
||||||
public class OdfExtractor extends AbstractExtractor implements Extractor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String extract(InputStream is) throws ExtractorException {
|
|
||||||
try {
|
|
||||||
Document odfDocument = Document.loadDocument(is);
|
|
||||||
TextExtractor extractor = TextExtractor.newOdfTextExtractor(odfDocument.getContentRoot());
|
|
||||||
|
|
||||||
return extractor.getText();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new ExtractorException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package info.bukova.isspst.services.fulltext;
|
|
||||||
|
|
||||||
import com.lowagie.text.pdf.PdfReader;
|
|
||||||
import com.lowagie.text.pdf.parser.PdfTextExtractor;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*/
|
|
||||||
public class PdfExtractor extends AbstractExtractor implements Extractor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String extract(InputStream is) throws ExtractorException {
|
|
||||||
try {
|
|
||||||
PdfReader reader = new PdfReader(is);
|
|
||||||
PdfTextExtractor extractor = new PdfTextExtractor(reader);
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
for (int i = 1; i <= reader.getNumberOfPages(); i++) {
|
|
||||||
sb.append(extractor.getTextFromPage(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new ExtractorException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package info.bukova.isspst.services.fulltext;
|
|
||||||
|
|
||||||
import org.apache.poi.POIXMLTextExtractor;
|
|
||||||
import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
|
|
||||||
import org.apache.poi.xslf.usermodel.XMLSlideShow;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*/
|
|
||||||
public class PowerPointExtractor extends AbstractOfficeExtractor implements Extractor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected POIXMLTextExtractor createExtractor(InputStream is) throws IOException {
|
|
||||||
return new XSLFPowerPointExtractor(new XMLSlideShow(is));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package info.bukova.isspst.services.fulltext;
|
|
||||||
|
|
||||||
import org.apache.poi.POIXMLTextExtractor;
|
|
||||||
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
|
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*/
|
|
||||||
public class WordExtractor extends AbstractOfficeExtractor implements Extractor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected POIXMLTextExtractor createExtractor(InputStream is) throws IOException {
|
|
||||||
return new XWPFWordExtractor(new XWPFDocument(is));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package info.bukova.isspst.services.invoicing;
|
|
||||||
|
|
||||||
import info.bukova.isspst.data.Invoicing;
|
|
||||||
import info.bukova.isspst.data.Workgroup;
|
|
||||||
import info.bukova.isspst.services.Service;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface InvoicingService extends Service<Invoicing> {
|
|
||||||
|
|
||||||
public BigDecimal totalInvoicedForWorkgroup(Workgroup workgroup);
|
|
||||||
|
|
||||||
public void loadReqItems(Invoicing invoicing);
|
|
||||||
|
|
||||||
public void loadItems(Invoicing invoicing);
|
|
||||||
|
|
||||||
public void calculate(Invoicing invoicing);
|
|
||||||
|
|
||||||
public List<Invoicing> getPendingList();
|
|
||||||
|
|
||||||
public List<Invoicing> getArchiveList();
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
package info.bukova.isspst.services.invoicing;
|
|
||||||
|
|
||||||
import info.bukova.isspst.data.Invoicing;
|
|
||||||
import info.bukova.isspst.data.InvoicingItem;
|
|
||||||
import info.bukova.isspst.data.Workgroup;
|
|
||||||
import info.bukova.isspst.services.AbstractOwnedService;
|
|
||||||
import info.bukova.isspst.services.LazyLoader;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hibernate.Hibernate;
|
|
||||||
import org.hibernate.Query;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
public class InvoicingServiceImpl extends AbstractOwnedService<Invoicing> implements
|
|
||||||
InvoicingService {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public BigDecimal totalInvoicedForWorkgroup(Workgroup workgroup) {
|
|
||||||
Query q = dao.getQuery("select sum(inv.totalInvoiced) "
|
|
||||||
+ "from Invoicing inv join inv.requirement rq join rq.workgroup w "
|
|
||||||
+ "where w = :workgroup ");
|
|
||||||
q.setParameter("workgroup", workgroup);
|
|
||||||
return (BigDecimal) q.uniqueResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@LazyLoader("form")
|
|
||||||
public void loadReqItems(Invoicing invoicing) {
|
|
||||||
Invoicing inv = getById(invoicing.getId());
|
|
||||||
Hibernate.initialize(inv.getRequirement().getItems());
|
|
||||||
invoicing.getRequirement().setItems(inv.getRequirement().getItems());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@LazyLoader({"form", "grid"})
|
|
||||||
public void loadItems(Invoicing invoicing) {
|
|
||||||
Invoicing inv = getById(invoicing.getId());
|
|
||||||
Hibernate.initialize(inv.getItems());
|
|
||||||
invoicing.setItems(inv.getItems());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void calculate(Invoicing invoicing) {
|
|
||||||
BigDecimal total = BigDecimal.ZERO;
|
|
||||||
|
|
||||||
for (InvoicingItem item : invoicing.getItems()) {
|
|
||||||
total = total.add(item.getAmount());
|
|
||||||
}
|
|
||||||
|
|
||||||
invoicing.setTotalInvoiced(total);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
|
||||||
public List<Invoicing> getAll() {
|
|
||||||
Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy order by rq.numser");
|
|
||||||
return q.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@LazyLoader("form")
|
|
||||||
public void loadOwnedBy(Invoicing invoice) {
|
|
||||||
Invoicing inv = getById(invoice.getId());
|
|
||||||
Hibernate.initialize(inv.getRequirement().getOwnedBy());
|
|
||||||
invoice.getRequirement().setOwnedBy(inv.getRequirement().getOwnedBy());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
|
||||||
public List<Invoicing> getPendingList()
|
|
||||||
{
|
|
||||||
Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed Is Null or inv.completed = false) order by rq.numser");
|
|
||||||
return q.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
|
||||||
public List<Invoicing> getArchiveList()
|
|
||||||
{
|
|
||||||
Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where inv.completed = true order by rq.numser");
|
|
||||||
return q.list();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package info.bukova.isspst.services.requirement;
|
|
||||||
|
|
||||||
import info.bukova.isspst.services.IsspstException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*/
|
|
||||||
public class ApproveException extends IsspstException {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -3794779381621324848L;
|
|
||||||
|
|
||||||
public ApproveException() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApproveException(String message) {
|
|
||||||
super(message);
|
|
||||||
this.setReason(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -38,8 +38,9 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
|
|||||||
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
||||||
public List<Requirement> getMy()
|
public List<Requirement> getMy()
|
||||||
{
|
{
|
||||||
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner and kind = :kind");
|
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner and state != :state and kind = :kind");
|
||||||
q.setParameter("owner", getLoggedInUser());
|
q.setParameter("owner", getLoggedInUser());
|
||||||
|
q.setParameter("state", RequirementState.APPROVED);
|
||||||
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
|
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
|
||||||
return q.list();
|
return q.list();
|
||||||
}
|
}
|
||||||
@@ -52,8 +53,9 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
|
|||||||
public List<Requirement> getCentreReq()
|
public List<Requirement> getCentreReq()
|
||||||
{
|
{
|
||||||
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser());
|
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser());
|
||||||
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c where c in (:wgList) and kind = :kind order by tr.numser");
|
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c where tr.state != :state and c in (:wgList) and kind = :kind order by tr.numser");
|
||||||
q.setParameterList("wgList", wgList);
|
q.setParameterList("wgList", wgList);
|
||||||
|
q.setParameter("state", RequirementState.APPROVED);
|
||||||
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
|
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
|
||||||
return q.list();
|
return q.list();
|
||||||
}
|
}
|
||||||
@@ -68,8 +70,9 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
|
|||||||
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser());
|
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser());
|
||||||
Query q = dao.getQuery("select tr from "
|
Query q = dao.getQuery("select tr from "
|
||||||
+ dao.getEntityName()
|
+ dao.getEntityName()
|
||||||
+ " tr join fetch tr.ownedBy join tr.workgroup w where w in (:wgList) and kind = :kind order by tr.numser");
|
+ " tr join fetch tr.ownedBy join tr.workgroup w where tr.state != :state and w in (:wgList) and kind = :kind order by tr.numser");
|
||||||
q.setParameterList("wgList", wgList);
|
q.setParameterList("wgList", wgList);
|
||||||
|
q.setParameter("state", RequirementState.APPROVED);
|
||||||
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
|
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
|
||||||
return q.list();
|
return q.list();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,9 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
|
|||||||
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
||||||
public List<Requirement> getMy()
|
public List<Requirement> getMy()
|
||||||
{
|
{
|
||||||
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner and kind = :kind");
|
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner and state != :state and kind = :kind");
|
||||||
q.setParameter("owner", getLoggedInUser());
|
q.setParameter("owner", getLoggedInUser());
|
||||||
|
q.setParameter("state", RequirementState.APPROVED);
|
||||||
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
|
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
|
||||||
return q.list();
|
return q.list();
|
||||||
}
|
}
|
||||||
@@ -52,8 +53,9 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
|
|||||||
public List<Requirement> getCentreReq()
|
public List<Requirement> getCentreReq()
|
||||||
{
|
{
|
||||||
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser());
|
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser());
|
||||||
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c where c in (:wgList) and kind = :kind order by tr.numser");
|
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c where tr.state != :state and c in (:wgList) and kind = :kind order by tr.numser");
|
||||||
q.setParameterList("wgList", wgList);
|
q.setParameterList("wgList", wgList);
|
||||||
|
q.setParameter("state", RequirementState.APPROVED);
|
||||||
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
|
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
|
||||||
return q.list();
|
return q.list();
|
||||||
}
|
}
|
||||||
@@ -68,8 +70,9 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
|
|||||||
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser());
|
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser());
|
||||||
Query q = dao.getQuery("select tr from "
|
Query q = dao.getQuery("select tr from "
|
||||||
+ dao.getEntityName()
|
+ dao.getEntityName()
|
||||||
+ " tr join fetch tr.ownedBy join tr.workgroup w where w in (:wgList) and kind = :kind order by tr.numser");
|
+ " tr join fetch tr.ownedBy join tr.workgroup w where tr.state != :state and w in (:wgList) and kind = :kind order by tr.numser");
|
||||||
q.setParameterList("wgList", wgList);
|
q.setParameterList("wgList", wgList);
|
||||||
|
q.setParameter("state", RequirementState.APPROVED);
|
||||||
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
|
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
|
||||||
return q.list();
|
return q.list();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,8 @@ import info.bukova.isspst.data.RequirementBase;
|
|||||||
import info.bukova.isspst.data.User;
|
import info.bukova.isspst.data.User;
|
||||||
import info.bukova.isspst.services.Service;
|
import info.bukova.isspst.services.Service;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
* @author Franta Přibyl
|
|
||||||
*
|
|
||||||
* Základní rozhraní všech požadavků.
|
|
||||||
*
|
|
||||||
* @param <T> Třída požadavku.
|
|
||||||
*/
|
|
||||||
public interface RequirementBaseService<T extends RequirementBase> extends Service<T>
|
public interface RequirementBaseService<T extends RequirementBase> extends Service<T>
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -22,7 +13,6 @@ public interface RequirementBaseService<T extends RequirementBase> extends Servi
|
|||||||
public void loadType(T data);
|
public void loadType(T data);
|
||||||
public void loadWorkflow(T data);
|
public void loadWorkflow(T data);
|
||||||
public void approve(T entity);
|
public void approve(T entity);
|
||||||
public void approve(T entity, Date approveDate);
|
|
||||||
public boolean canApprove(T entity);
|
public boolean canApprove(T entity);
|
||||||
public List<User> getNextApprover(T entity);
|
public List<User> getNextApprover(T entity);
|
||||||
|
|
||||||
|
|||||||
+18
-70
@@ -18,6 +18,11 @@ import info.bukova.isspst.services.LazyLoader;
|
|||||||
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
||||||
import info.bukova.isspst.services.users.UserService;
|
import info.bukova.isspst.services.users.UserService;
|
||||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.LazyInitializationException;
|
import org.hibernate.LazyInitializationException;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -25,18 +30,6 @@ import org.springframework.security.access.prepost.PostFilter;
|
|||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
* @author Franta Přibyl
|
|
||||||
*
|
|
||||||
* Abstraktní bázová třída všech požadavků
|
|
||||||
*
|
|
||||||
* @param <T> Třída požadavku
|
|
||||||
*/
|
|
||||||
public abstract class RequirementBaseServiceImpl<T extends RequirementBase> extends
|
public abstract class RequirementBaseServiceImpl<T extends RequirementBase> extends
|
||||||
AbstractOwnedService<T> implements RequirementBaseService<T> {
|
AbstractOwnedService<T> implements RequirementBaseService<T> {
|
||||||
|
|
||||||
@@ -75,7 +68,7 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
|
|
||||||
super.add(entity);
|
super.add(entity);
|
||||||
|
|
||||||
this.postAdd(entity);
|
this.sendToApprovers(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkEnable() {
|
private void checkEnable() {
|
||||||
@@ -99,14 +92,6 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void postAdd(T entity) {
|
|
||||||
if (canApprove(entity)) {
|
|
||||||
approve(entity);
|
|
||||||
} else {
|
|
||||||
this.sendToApprovers(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addWorkflow(T entity) {
|
protected void addWorkflow(T entity) {
|
||||||
if (entity.getType() == null) {
|
if (entity.getType() == null) {
|
||||||
return;
|
return;
|
||||||
@@ -214,17 +199,9 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void approve(T entity, User user, Date approveDate) {
|
protected void approve(T entity, User user) {
|
||||||
T e = (T) dao.getById(entity.getId());
|
T e = (T) dao.getById(entity.getId());
|
||||||
|
|
||||||
if (e.getReqDate().getTime() > approveDate.getTime()) {
|
|
||||||
throw new ApproveException("ErrApproveBeforeRequirement");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.getLastApproveDate() != null && e.getLastApproveDate().getTime() > approveDate.getTime()) {
|
|
||||||
throw new ApproveException("ErrAppreveBeforeLastApprove");
|
|
||||||
}
|
|
||||||
|
|
||||||
Workflow wf = getNextWorkflow(e);
|
Workflow wf = getNextWorkflow(e);
|
||||||
if (wf == null) {
|
if (wf == null) {
|
||||||
return;
|
return;
|
||||||
@@ -234,7 +211,7 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
AuthItem auth = new AuthItem();
|
AuthItem auth = new AuthItem();
|
||||||
auth.setApprover(user);
|
auth.setApprover(user);
|
||||||
auth.setRole(role);
|
auth.setRole(role);
|
||||||
auth.setAuthDate(approveDate);
|
auth.setAuthDate(new Date());
|
||||||
|
|
||||||
e.getAuthorization().add(auth);
|
e.getAuthorization().add(auth);
|
||||||
|
|
||||||
@@ -243,10 +220,12 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
} else {
|
} else {
|
||||||
e.setState(RequirementState.PARTIALLY);
|
e.setState(RequirementState.PARTIALLY);
|
||||||
}
|
}
|
||||||
|
entity.setState(e.getState());
|
||||||
|
entity.getAuthorization().add(auth);
|
||||||
|
|
||||||
super.update(e);
|
super.update(e);
|
||||||
|
|
||||||
if (!autoApprove(e, approveDate)) {
|
if (!autoApprove(entity)) {
|
||||||
this.sendToApprovers(e);
|
this.sendToApprovers(e);
|
||||||
|
|
||||||
SettingsData settings = settingsService.getSettings();
|
SettingsData settings = settingsService.getSettings();
|
||||||
@@ -268,12 +247,6 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
postApprove(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void approve(T entity, User user) {
|
|
||||||
approve(entity, user, new Date());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -283,33 +256,10 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
approve(entity, getLoggedInUser());
|
approve(entity, getLoggedInUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected boolean autoApprove(T entity) {
|
||||||
@Transactional
|
|
||||||
@PreAuthorize("this.canApprove(#entity)")
|
|
||||||
public void approve(T entity, Date approveDate) {
|
|
||||||
approve(entity, getLoggedInUser(), approveDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Volá se z metody approve pro automatické schválení dalším schvalovatelem v pořadí. Metoda z báze nedělá nic.
|
|
||||||
*
|
|
||||||
* @param entity Požadavek
|
|
||||||
* @param approveDate
|
|
||||||
* @return true pokud se provedlo automatické schválení.
|
|
||||||
*/
|
|
||||||
protected boolean autoApprove(T entity, Date approveDate) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Činnost prováděná po schválení požadavku (i dílčím schválení).
|
|
||||||
*
|
|
||||||
* @param entity Požadavek
|
|
||||||
*/
|
|
||||||
protected void postApprove(T entity) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean canApprove(T entity) {
|
public boolean canApprove(T entity) {
|
||||||
@@ -357,8 +307,9 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
||||||
public List<T> getMy()
|
public List<T> getMy()
|
||||||
{
|
{
|
||||||
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner");
|
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner and state != :state");
|
||||||
q.setParameter("owner", getLoggedInUser());
|
q.setParameter("owner", getLoggedInUser());
|
||||||
|
q.setParameter("state", RequirementState.APPROVED);
|
||||||
return q.list();
|
return q.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,8 +321,9 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
public List<T> getCentreReq()
|
public List<T> getCentreReq()
|
||||||
{
|
{
|
||||||
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser());
|
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser());
|
||||||
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c where c in (:wgList) order by tr.numser");
|
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c where tr.state != :state and c in (:wgList) order by tr.numser");
|
||||||
q.setParameterList("wgList", wgList);
|
q.setParameterList("wgList", wgList);
|
||||||
|
q.setParameter("state", RequirementState.APPROVED);
|
||||||
return q.list();
|
return q.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,8 +335,9 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
public List<T> getWorkgroupReq()
|
public List<T> getWorkgroupReq()
|
||||||
{
|
{
|
||||||
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser());
|
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser());
|
||||||
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.workgroup w where w in (:wgList) order by tr.numser");
|
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.workgroup w where tr.state != :state and w in (:wgList) order by tr.numser");
|
||||||
q.setParameterList("wgList", wgList);
|
q.setParameterList("wgList", wgList);
|
||||||
|
q.setParameter("state", RequirementState.APPROVED);
|
||||||
return q.list();
|
return q.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,9 +356,4 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
|||||||
return Constants.PERM_EDIT_NEW;
|
return Constants.PERM_EDIT_NEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDeleteEntityPermission() {
|
|
||||||
return Constants.PERM_DELETE_NEW;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,19 +6,10 @@ import info.bukova.isspst.data.RequirementItem;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
* @author Franta Přibyl
|
|
||||||
*
|
|
||||||
* Základní rozhraní požadavků na služby a materiál.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface RequirementService extends RequirementBaseService<Requirement>
|
public interface RequirementService extends RequirementBaseService<Requirement>
|
||||||
{
|
{
|
||||||
public void loadGroups(Requirement req);
|
public void loadGroups(Requirement req);
|
||||||
|
|
||||||
public void loadItems(Requirement req);
|
|
||||||
|
|
||||||
public BigDecimal calcTotalFromItem(RequirementItem item);
|
public BigDecimal calcTotalFromItem(RequirementItem item);
|
||||||
|
|
||||||
public RequirementItem calcTotalInItem(RequirementItem item);
|
public RequirementItem calcTotalInItem(RequirementItem item);
|
||||||
@@ -26,6 +17,4 @@ public interface RequirementService extends RequirementBaseService<Requirement>
|
|||||||
public RequirementItem calcItemValuesFromItemTotal(RequirementItem item);
|
public RequirementItem calcItemValuesFromItemTotal(RequirementItem item);
|
||||||
|
|
||||||
public BigDecimal calcSumTotalFromItems(List<RequirementItem> items);
|
public BigDecimal calcSumTotalFromItems(List<RequirementItem> items);
|
||||||
|
|
||||||
public BigDecimal getInvoicedAmount(Requirement req);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package info.bukova.isspst.services.requirement;
|
package info.bukova.isspst.services.requirement;
|
||||||
|
|
||||||
import info.bukova.isspst.Constants;
|
import info.bukova.isspst.Constants;
|
||||||
import info.bukova.isspst.data.Invoicing;
|
|
||||||
import info.bukova.isspst.data.Requirement;
|
import info.bukova.isspst.data.Requirement;
|
||||||
import info.bukova.isspst.data.RequirementItem;
|
import info.bukova.isspst.data.RequirementItem;
|
||||||
import info.bukova.isspst.data.RequirementState;
|
import info.bukova.isspst.data.RequirementState;
|
||||||
@@ -9,30 +8,22 @@ import info.bukova.isspst.data.RequirementSubject;
|
|||||||
import info.bukova.isspst.data.User;
|
import info.bukova.isspst.data.User;
|
||||||
import info.bukova.isspst.data.Workflow;
|
import info.bukova.isspst.data.Workflow;
|
||||||
import info.bukova.isspst.services.LazyLoader;
|
import info.bukova.isspst.services.LazyLoader;
|
||||||
import info.bukova.isspst.services.invoicing.InvoicingService;
|
import info.bukova.isspst.services.approved.OrderService;
|
||||||
import org.hibernate.Hibernate;
|
|
||||||
import org.hibernate.Query;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
* @author Pepa Rokos
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
* @author Franta Přibyl
|
|
||||||
*
|
|
||||||
* Bázová třída požadavků na materiál a služby.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requirement> implements RequirementService, RequirementBaseService<Requirement>
|
public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requirement> implements RequirementService, RequirementBaseService<Requirement>
|
||||||
{
|
{
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RequirementTypeService reqTypeService;
|
private RequirementTypeService reqTypeService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private InvoicingService invoicingService;
|
private OrderService orderService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Requirement createEntity()
|
protected Requirement createEntity()
|
||||||
@@ -47,7 +38,7 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requireme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean autoApprove(Requirement entity, Date approveDate)
|
protected boolean autoApprove(Requirement entity)
|
||||||
{
|
{
|
||||||
List<User> approvers = this.getNextApprover(entity);
|
List<User> approvers = this.getNextApprover(entity);
|
||||||
Workflow nextWf = this.getNextWorkflow(entity);
|
Workflow nextWf = this.getNextWorkflow(entity);
|
||||||
@@ -57,10 +48,9 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requireme
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((entity.getSumTotal() != null)
|
if (entity.getSumTotal().compareTo(nextWf.getLimit()) == -1)
|
||||||
&& (entity.getSumTotal().compareTo(nextWf.getLimit()) == -1))
|
|
||||||
{
|
{
|
||||||
approve(entity, approvers.get(0), approveDate);
|
approve(entity, approvers.get(0));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +63,7 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requireme
|
|||||||
if (entity.getWorkgroup() != null && entity.getWorkgroup().getLimit() != null && entity.getWorkgroup().getLimit().compareTo(BigDecimal.ZERO) != 0)
|
if (entity.getWorkgroup() != null && entity.getWorkgroup().getLimit() != null && entity.getWorkgroup().getLimit().compareTo(BigDecimal.ZERO) != 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
BigDecimal total = invoicingService.totalInvoicedForWorkgroup(entity.getWorkgroup());
|
BigDecimal total = orderService.totalOrderedForWorkgroup(entity.getWorkgroup());
|
||||||
|
|
||||||
if (total == null)
|
if (total == null)
|
||||||
{
|
{
|
||||||
@@ -146,19 +136,6 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requireme
|
|||||||
req.setItems(items);
|
req.setItems(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@LazyLoader("form")
|
|
||||||
public void loadItems(Requirement req) {
|
|
||||||
if (req == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Requirement r = getById(req.getId());
|
|
||||||
Hibernate.initialize(r.getItems());
|
|
||||||
req.setItems(r.getItems());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal calcTotalFromItem(RequirementItem item)
|
public BigDecimal calcTotalFromItem(RequirementItem item)
|
||||||
{
|
{
|
||||||
@@ -231,24 +208,4 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requireme
|
|||||||
|
|
||||||
return sumTotal;
|
return sumTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void postApprove(Requirement entity) {
|
|
||||||
if (entity.getState() == RequirementState.APPROVED) {
|
|
||||||
Invoicing inv = new Invoicing();
|
|
||||||
inv.setRequirement(entity);
|
|
||||||
invoicingService.add(inv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public BigDecimal getInvoicedAmount(Requirement req) {
|
|
||||||
Query query = dao.getQuery("select invoice from Invoicing invoice join invoice.requirement rq where rq.id = :reqId");
|
|
||||||
query.setParameter("reqId", req.getId());
|
|
||||||
|
|
||||||
Invoicing inv = (Invoicing) query.uniqueResult();
|
|
||||||
|
|
||||||
return inv != null ? inv.getTotalInvoiced() : null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,10 @@
|
|||||||
package info.bukova.isspst.services.requirement;
|
package info.bukova.isspst.services.requirement;
|
||||||
|
|
||||||
import info.bukova.isspst.data.TripBill;
|
|
||||||
import info.bukova.isspst.data.TripRequirement;
|
import info.bukova.isspst.data.TripRequirement;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface TripRequirementService extends RequirementBaseService<TripRequirement>
|
public interface TripRequirementService extends RequirementBaseService<TripRequirement>
|
||||||
{
|
{
|
||||||
|
|
||||||
public void loadPassangers(TripRequirement entity);
|
public void loadPassangers(TripRequirement entity);
|
||||||
|
|
||||||
public TripBill getTripBill(TripRequirement requirement);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Vrátí seznam vyúčtování, která josu vázána k požadavku
|
|
||||||
*
|
|
||||||
* @param entity požadavek
|
|
||||||
* @return seznam vyúčtování
|
|
||||||
*/
|
|
||||||
public List<TripBill> getBills(TripRequirement entity);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-104
@@ -4,44 +4,27 @@ import info.bukova.isspst.Constants;
|
|||||||
import info.bukova.isspst.data.NumberSeries;
|
import info.bukova.isspst.data.NumberSeries;
|
||||||
import info.bukova.isspst.data.RequirementState;
|
import info.bukova.isspst.data.RequirementState;
|
||||||
import info.bukova.isspst.data.TripBill;
|
import info.bukova.isspst.data.TripBill;
|
||||||
import info.bukova.isspst.data.TripBillApproval;
|
|
||||||
import info.bukova.isspst.data.TripRequirement;
|
import info.bukova.isspst.data.TripRequirement;
|
||||||
import info.bukova.isspst.data.User;
|
|
||||||
import info.bukova.isspst.mail.MailMessage;
|
|
||||||
import info.bukova.isspst.mail.Mailer;
|
|
||||||
import info.bukova.isspst.mail.MessageBuilder;
|
|
||||||
import info.bukova.isspst.services.LazyLoader;
|
import info.bukova.isspst.services.LazyLoader;
|
||||||
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
|
||||||
import info.bukova.isspst.services.tripbill.TripBillApprovalService;
|
|
||||||
import info.bukova.isspst.services.tripbill.TripBillService;
|
import info.bukova.isspst.services.tripbill.TripBillService;
|
||||||
import info.bukova.isspst.services.users.UserService;
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||||
import org.hibernate.Hibernate;
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.hibernate.LazyInitializationException;
|
import org.hibernate.LazyInitializationException;
|
||||||
import org.hibernate.Query;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripRequirement>
|
public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripRequirement>
|
||||||
implements TripRequirementService, RequirementBaseService<TripRequirement> {
|
implements TripRequirementService, RequirementBaseService<TripRequirement> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RequirementTypeService reqTypeService;
|
private RequirementTypeService reqTypeService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private WorkgroupService workgroupService;
|
||||||
|
@Autowired
|
||||||
private TripBillService tripBillService;
|
private TripBillService tripBillService;
|
||||||
@Autowired
|
|
||||||
private TripBillApprovalService tripBillApprovalService;
|
|
||||||
@Autowired
|
|
||||||
private Mailer mailer;
|
|
||||||
@Autowired
|
|
||||||
private MessageBuilder messageBuilder;
|
|
||||||
@Autowired
|
|
||||||
private GlobalSettingsService settingsService;
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TripRequirement createEntity() {
|
protected TripRequirement createEntity() {
|
||||||
@@ -53,45 +36,6 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
|
|||||||
return tr;
|
return tr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
|
|
||||||
public void update(TripRequirement entity) {
|
|
||||||
super.update(entity);
|
|
||||||
|
|
||||||
if (entity.getState() == RequirementState.APPROVED) {
|
|
||||||
for (TripBill bill : getBills(entity)) {
|
|
||||||
TripBill newBill = tripBillService.createTripBill(entity);
|
|
||||||
bill.getBillItems().clear();
|
|
||||||
bill.getBillItems().addAll(newBill.getBillItems());
|
|
||||||
TripBillApproval approval = bill.getApproval();
|
|
||||||
|
|
||||||
if (approval != null) {
|
|
||||||
tripBillApprovalService.delete(approval);
|
|
||||||
}
|
|
||||||
|
|
||||||
bill.setApproval(null);
|
|
||||||
tripBillService.calculate(bill);
|
|
||||||
tripBillService.update(bill);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void postAdd(TripRequirement entity) {
|
|
||||||
super.postAdd(entity);
|
|
||||||
sendMailToPassengers(entity, settingsService.getSettings().getReqPassenger());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendMailToPassengers(TripRequirement entity, MailMessage messageTemplate) {
|
|
||||||
if (entity.getBillForPassengers() != null && !entity.getPassengers().isEmpty() && messageTemplate != null) {
|
|
||||||
MailMessage message = messageBuilder.buildMessage(messageTemplate, entity);
|
|
||||||
message.setFrom(userService.getCurrent().getEmail());
|
|
||||||
message.setTo(userService.getEmailsForSend(entity.getPassengers()));
|
|
||||||
mailer.send(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@LazyLoader("form")
|
@LazyLoader("form")
|
||||||
@@ -111,54 +55,15 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public TripBill getTripBill(TripRequirement requirement) {
|
@PreAuthorize("this.canApprove(#entity)")
|
||||||
Query q = dao.getQuery("from TripBill tb where tb.requirement = :req");
|
public void approve(TripRequirement entity) {
|
||||||
q.setParameter("req", requirement);
|
super.approve(entity);
|
||||||
List<TripBill> result = q.list();
|
|
||||||
|
|
||||||
if (result.size() > 0) {
|
|
||||||
return result.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public List<TripBill> getBills(TripRequirement entity) {
|
|
||||||
Query q = queryDao.getQuery("from TripBill bill where bill.requirement = :req");
|
|
||||||
q.setParameter("req", entity);
|
|
||||||
return q.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@LazyLoader("form")
|
|
||||||
public void loadAttachments(TripRequirement entity) {
|
|
||||||
TripRequirement e = dao.getById(entity.getId());
|
|
||||||
Hibernate.initialize(e.getAttachedFiles());
|
|
||||||
entity.setAttachedFiles(e.getAttachedFiles());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void postApprove(TripRequirement entity) {
|
|
||||||
if (entity.getState() == RequirementState.APPROVED) {
|
if (entity.getState() == RequirementState.APPROVED) {
|
||||||
TripBill bill = tripBillService.createTripBill(entity);
|
TripBill bill = tripBillService.createTripBill(entity);
|
||||||
tripBillService.add(bill);
|
tripBillService.add(bill);
|
||||||
bill.setOwnedBy(entity.getOwnedBy());
|
bill.setOwnedBy(entity.getOwnedBy());
|
||||||
tripBillService.update(bill);
|
tripBillService.update(bill);
|
||||||
|
|
||||||
if (entity.getBillForPassengers() != null && entity.getBillForPassengers()) {
|
|
||||||
for (User u : entity.getPassengers()) {
|
|
||||||
if (!u.equals(entity.getOwnedBy())) {
|
|
||||||
TripBill passBill = tripBillService.createPassengersBill(entity);
|
|
||||||
tripBillService.add(passBill);
|
|
||||||
passBill.setOwnedBy(u);
|
|
||||||
tripBillService.update(passBill);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sendMailToPassengers(entity, settingsService.getSettings().getConfReqTripPassenger());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package info.bukova.isspst.services.tripbill;
|
|
||||||
|
|
||||||
import info.bukova.isspst.data.TripBill;
|
|
||||||
import info.bukova.isspst.data.TripBillApproval;
|
|
||||||
import info.bukova.isspst.services.requirement.RequirementBaseService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Pepa Rokos
|
|
||||||
*/
|
|
||||||
public interface TripBillApprovalService extends RequirementBaseService<TripBillApproval> {
|
|
||||||
|
|
||||||
public TripBillApproval createApproval(TripBill bill);
|
|
||||||
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user