Pokud se upraví požadavek, u kterého je podepsaný dokument, tak se dokument smaže a požadavek se nastaví jako nový.

closes #227
Verze_3.0
Josef Rokos 9 years ago
parent c0922921c5
commit b33f9f2e8a

@ -2,11 +2,13 @@ package info.bukova.isspst.data;
import info.bukova.isspst.Constants; import info.bukova.isspst.Constants;
import info.bukova.isspst.storage.EntityWithAttachment; import info.bukova.isspst.storage.EntityWithAttachment;
import org.hibernate.annotations.LazyCollection;
import java.math.BigDecimal; import org.hibernate.annotations.LazyCollectionOption;
import java.util.ArrayList; import org.hibernate.search.annotations.Analyze;
import java.util.Date; import org.hibernate.search.annotations.Field;
import java.util.List; 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.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
@ -16,14 +18,10 @@ import javax.persistence.JoinColumn;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import java.math.BigDecimal;
import org.hibernate.annotations.LazyCollection; import java.util.ArrayList;
import org.hibernate.annotations.LazyCollectionOption; import java.util.Date;
import org.hibernate.search.annotations.Analyze; import java.util.List;
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")
@ -66,7 +64,7 @@ public class TripBill extends BaseData implements EntityWithAttachment {
@JoinColumn(name = "APPROVAL_ID") @JoinColumn(name = "APPROVAL_ID")
private TripBillApproval approval; private TripBillApproval approval;
@Column(name = "SAVED") @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() { public TripBill() {
billItems = new ArrayList<TripBillItem>(); billItems = new ArrayList<TripBillItem>();

@ -533,4 +533,28 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
return report; 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);
}
} }

@ -10,5 +10,6 @@ public interface SignedDocumentService extends Service<SignedDocument> {
SignedDocument getForEntity(DataModel entity); SignedDocument getForEntity(DataModel entity);
SignedDocumentItem getItem(DataModel entity, long reportId); SignedDocumentItem getItem(DataModel entity, long reportId);
void addFromApprove(SignedDocument document); void addFromApprove(SignedDocument document);
void delFromApprove(SignedDocument document);
} }

@ -8,6 +8,7 @@ import info.bukova.isspst.data.SignedDocumentItem;
import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.storage.ReportFileStorage;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Query; import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -19,6 +20,8 @@ public class SignedDocumentServiceImpl extends AbstractOwnedService<SignedDocume
@Autowired @Autowired
private ServletContext servletContext; private ServletContext servletContext;
@Autowired
private ReportFileStorage signedDocStorage;
@LazyLoader("grid") @LazyLoader("grid")
@Transactional @Transactional
@ -71,5 +74,14 @@ public class SignedDocumentServiceImpl extends AbstractOwnedService<SignedDocume
super.add(document); super.add(document);
} }
@Override
public void delFromApprove(SignedDocument document) {
super.delete(document);
for (SignedDocumentItem item : document.getItems()) {
signedDocStorage.removeFile(item);
}
}
} }

Loading…
Cancel
Save