diff --git a/src/main/java/info/bukova/isspst/data/TripBill.java b/src/main/java/info/bukova/isspst/data/TripBill.java index b44ded85..a819d286 100644 --- a/src/main/java/info/bukova/isspst/data/TripBill.java +++ b/src/main/java/info/bukova/isspst/data/TripBill.java @@ -2,11 +2,13 @@ package info.bukova.isspst.data; import info.bukova.isspst.Constants; import info.bukova.isspst.storage.EntityWithAttachment; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; +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.CascadeType; import javax.persistence.Column; @@ -16,14 +18,10 @@ 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; -import org.hibernate.search.annotations.Analyze; -import org.hibernate.search.annotations.Field; -import org.hibernate.search.annotations.Index; -import org.hibernate.search.annotations.Indexed; -import org.hibernate.search.annotations.IndexedEmbedded; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; @Entity @Table(name = "TRIP_BILL") @@ -66,7 +64,7 @@ public class TripBill extends BaseData implements EntityWithAttachment { @JoinColumn(name = "APPROVAL_ID") private TripBillApproval approval; @Column(name = "SAVED") - private Boolean saved; + private Boolean saved; // Nastaveno na true, pokud uživatel udělá změnu- nepřenáší se pak částky od žadatele public TripBill() { billItems = new ArrayList(); diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java index 753e344a..60f89199 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java @@ -533,4 +533,28 @@ public abstract class RequirementBaseServiceImpl exte return report; } + + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())") + public void update(T entity) { + entity.getAuthorization().clear(); + entity.setState(RequirementState.NEW); + + SignedDocument doc = signedDocumentService.getForEntity(entity); + if (doc != null) { + signedDocumentService.delFromApprove(doc); + } + + super.update(entity); + sendToApprovers(entity); + } + + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_DELETE') or hasPermission(#entity, this.getDeleteEntityPermission())") + public void delete(T entity) { + signedDocumentService.delFromApprove(signedDocumentService.getForEntity(entity)); + super.delete(entity); + } } diff --git a/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentService.java b/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentService.java index f3beaf3e..7341ec15 100644 --- a/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentService.java +++ b/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentService.java @@ -10,5 +10,6 @@ public interface SignedDocumentService extends Service { SignedDocument getForEntity(DataModel entity); SignedDocumentItem getItem(DataModel entity, long reportId); void addFromApprove(SignedDocument document); + void delFromApprove(SignedDocument document); } diff --git a/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java b/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java index 6550ade3..4a6c0f86 100644 --- a/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java @@ -8,6 +8,7 @@ import info.bukova.isspst.data.SignedDocumentItem; import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.LazyLoader; +import info.bukova.isspst.storage.ReportFileStorage; import org.hibernate.Hibernate; import org.hibernate.Query; import org.springframework.beans.factory.annotation.Autowired; @@ -19,6 +20,8 @@ public class SignedDocumentServiceImpl extends AbstractOwnedService