diff --git a/src/main/java/info/bukova/isspst/Constants.java b/src/main/java/info/bukova/isspst/Constants.java index ec6af4c0..94b38297 100644 --- a/src/main/java/info/bukova/isspst/Constants.java +++ b/src/main/java/info/bukova/isspst/Constants.java @@ -7,6 +7,7 @@ import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.RequirementType; 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.ReportMapping; @@ -155,6 +156,7 @@ public class Constants { public final static Map, String> URL_MAP = Collections.unmodifiableMap(new HashMap, 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/"); }} ); diff --git a/src/main/java/info/bukova/isspst/TripBillAprovalUrlResolver.java b/src/main/java/info/bukova/isspst/TripBillAprovalUrlResolver.java new file mode 100644 index 00000000..9f0b57c3 --- /dev/null +++ b/src/main/java/info/bukova/isspst/TripBillAprovalUrlResolver.java @@ -0,0 +1,29 @@ +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"; + } +} diff --git a/src/main/java/info/bukova/isspst/data/TripBill.java b/src/main/java/info/bukova/isspst/data/TripBill.java index cc352b1b..ca8d698f 100644 --- a/src/main/java/info/bukova/isspst/data/TripBill.java +++ b/src/main/java/info/bukova/isspst/data/TripBill.java @@ -14,7 +14,6 @@ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.Table; @@ -60,7 +59,7 @@ public class TripBill extends BaseData implements EntityWithAttachment { @LazyCollection(LazyCollectionOption.TRUE) @IndexedEmbedded private List attachedFiles; - @ManyToOne(fetch = FetchType.EAGER) + @OneToOne(fetch = FetchType.EAGER) @JoinColumn(name = "APPROVAL_ID") private TripBillApproval approval; @Column(name = "SAVED") diff --git a/src/main/java/info/bukova/isspst/data/TripBillApproval.java b/src/main/java/info/bukova/isspst/data/TripBillApproval.java index bb1bd627..84388caa 100644 --- a/src/main/java/info/bukova/isspst/data/TripBillApproval.java +++ b/src/main/java/info/bukova/isspst/data/TripBillApproval.java @@ -1,6 +1,9 @@ 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; /** @@ -11,4 +14,15 @@ import javax.persistence.Table; @Table(name = "TRIP_BILL_APPROVAL") public class TripBillApproval extends RequirementBase { + @OneToOne(fetch = FetchType.EAGER) + @JoinColumn(name = "TRIPBILL_ID") + private TripBill bill; + + public TripBill getBill() { + return bill; + } + + public void setBill(TripBill bill) { + this.bill = bill; + } } diff --git a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java index fde257d6..e4b0d1f1 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java @@ -4,9 +4,11 @@ import info.bukova.isspst.Constants; import info.bukova.isspst.data.NumberSeries; import info.bukova.isspst.data.RequirementState; import info.bukova.isspst.data.TripBill; +import info.bukova.isspst.data.TripBillApproval; import info.bukova.isspst.data.TripRequirement; import info.bukova.isspst.data.User; import info.bukova.isspst.services.LazyLoader; +import info.bukova.isspst.services.tripbill.TripBillApprovalService; import info.bukova.isspst.services.tripbill.TripBillService; import info.bukova.isspst.services.workgroups.WorkgroupService; import org.hibernate.Hibernate; @@ -28,6 +30,8 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl { bills.add(this.bill); - if (bill.getApproval().getState() != RequirementState.APPROVED) { + if (bill.getApproval() != null && bill.getApproval().getState() != RequirementState.APPROVED) { isSelectedTad = true; selTab.put(bill.getId(), true); } else { @@ -83,7 +83,7 @@ public class TripBillSummaryVM extends RequirementSubpage { tripBillService.loadLazyData(b); bills.add(b); - if (!isSelectedTad && b.getApproval().getState() != RequirementState.APPROVED) { + if (!isSelectedTad && b.getApproval() != null && b.getApproval().getState() != RequirementState.APPROVED) { setBill(b); isSelectedTad = true; } else { diff --git a/src/main/webapp/WEB-INF/spring/mail-services.xml b/src/main/webapp/WEB-INF/spring/mail-services.xml index 7115106e..6d8f707b 100644 --- a/src/main/webapp/WEB-INF/spring/mail-services.xml +++ b/src/main/webapp/WEB-INF/spring/mail-services.xml @@ -36,12 +36,15 @@ + + +