diff --git a/src/main/java/info/bukova/isspst/services/AbstractOwnedService.java b/src/main/java/info/bukova/isspst/services/AbstractOwnedService.java index 9a6831cf..93e0a433 100644 --- a/src/main/java/info/bukova/isspst/services/AbstractOwnedService.java +++ b/src/main/java/info/bukova/isspst/services/AbstractOwnedService.java @@ -13,6 +13,7 @@ public class AbstractOwnedService extends AbstractServ @Override @Transactional public void add(T entity) { + validate(entity); entity.setCreated(new Date()); entity.setOwnedBy(getLoggedInUser()); dao.add(entity); @@ -24,6 +25,7 @@ public class AbstractOwnedService extends AbstractServ if (entity.getCreated() == null) { add(entity); } else { + validate(entity); entity.setModifiedBy(getLoggedInUser()); entity.setModified(new Date()); dao.modify(entity); diff --git a/src/main/java/info/bukova/isspst/services/AbstractService.java b/src/main/java/info/bukova/isspst/services/AbstractService.java index 4119d093..81b77371 100644 --- a/src/main/java/info/bukova/isspst/services/AbstractService.java +++ b/src/main/java/info/bukova/isspst/services/AbstractService.java @@ -28,6 +28,7 @@ public abstract class AbstractService implements Service @Override @Transactional public void add(T entity) { + validate(entity); entity.setCreated(new Date()); dao.add(entity); } @@ -38,6 +39,7 @@ public abstract class AbstractService implements Service if (entity.getCreated() == null) { add(entity); } else { + validate(entity); entity.setModified(new Date()); dao.modify(entity); } diff --git a/src/main/java/info/bukova/isspst/ui/FormViewModel.java b/src/main/java/info/bukova/isspst/ui/FormViewModel.java index c4bd0e8e..a3460c35 100644 --- a/src/main/java/info/bukova/isspst/ui/FormViewModel.java +++ b/src/main/java/info/bukova/isspst/ui/FormViewModel.java @@ -6,7 +6,6 @@ import info.bukova.isspst.services.ValidationException; import java.util.Map; -import org.springframework.dao.DataIntegrityViolationException; import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.ExecutionArgParam; @@ -46,7 +45,7 @@ public class FormViewModel { } Messagebox.show("Chyba validace", "Chyba", Messagebox.OK, Messagebox.ERROR); - } catch (DataIntegrityViolationException e) { + } catch (Exception e) { dataBean.setCreated(null); e.printStackTrace(); Messagebox.show("Chyba při ukládání záznamu", "Chyba", Messagebox.OK, Messagebox.ERROR);