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.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<TripBillItem>();

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

@ -10,5 +10,6 @@ public interface SignedDocumentService extends Service<SignedDocument> {
SignedDocument getForEntity(DataModel entity);
SignedDocumentItem getItem(DataModel entity, long reportId);
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.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<SignedDocume
@Autowired
private ServletContext servletContext;
@Autowired
private ReportFileStorage signedDocStorage;
@LazyLoader("grid")
@Transactional
@ -71,5 +74,14 @@ public class SignedDocumentServiceImpl extends AbstractOwnedService<SignedDocume
super.add(document);
}
@Override
public void delFromApprove(SignedDocument document) {
super.delete(document);
for (SignedDocumentItem item : document.getItems()) {
signedDocStorage.removeFile(item);
}
}
}

Loading…
Cancel
Save