Bug 978925
| Summary: | Ticket Monster: generated Administration section does not perform deletion of Performances correctly | ||
|---|---|---|---|
| Product: | [Retired] JBoss Enterprise WFK Platform 2 | Reporter: | Vineet Reynolds <vpereira> |
| Component: | TicketMonster | Assignee: | Pete Muir <pmuir> |
| Status: | CLOSED INSUFFICIENT_DATA | QA Contact: | Tomas Repel <trepel> |
| Severity: | medium | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 2.3.0 | CC: | bsutter, mnovotny, ppenicka |
| Target Milestone: | --- | ||
| Target Release: | 2.4.0 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Known Issue | |
| Doc Text: |
The generated Administration section of the TicketMonster example does not contain the correct logic to delete Performances. Consequently, deleting Performances in the Administration section has no effect, or failures are encountered during the deletion.
To work around the issue, add the following methods to the PerformanceBean class:
public List<SectionAllocation> findSectionAllocationsByPerformance(Performance performance)
{
CriteriaQuery<SectionAllocation> criteria = this.entityManager
.getCriteriaBuilder().createQuery(SectionAllocation.class);
Root<SectionAllocation> from = criteria.from(SectionAllocation.class);
CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
Predicate performanceIsSame = builder.equal(from.get("performance"), performance);
return this.entityManager.createQuery(
criteria.select(from).where(performanceIsSame)).getResultList();
}
public List<Booking> findBookingsByPerformance(Performance performance)
{
CriteriaQuery<Booking> criteria = this.entityManager
.getCriteriaBuilder().createQuery(Booking.class);
Root<Booking> from = criteria.from(Booking.class);
CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
Predicate performanceIsSame = builder.equal(from.get("performance"), performance);
return this.entityManager.createQuery(
criteria.select(from).where(performanceIsSame)).getResultList();
}
Then replace the delete() method in the PerformanceBean class with the following method definition:
public String delete()
{
this.conversation.end();
try
{
Performance deletableEntity = findById(getId());
Show show = deletableEntity.getShow();
show.getPerformances().remove(deletableEntity);
deletableEntity.setShow(null);
this.entityManager.merge(show);
List<SectionAllocation> sectionAllocations = findSectionAllocationsByPerformance(deletableEntity);
for(SectionAllocation sectionAllocation: sectionAllocations)
{
this.entityManager.remove(sectionAllocation);
}
List<Booking> bookings = findBookingsByPerformance(deletableEntity);
for(Booking booking: bookings)
{
this.entityManager.remove(booking);
}
this.entityManager.remove(deletableEntity);
this.entityManager.flush();
return "search?faces-redirect=true";
}
catch (Exception e)
{
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(e.getMessage()));
return null;
}
}
After applying this workaround, Performances can be deleted in the Administration section successfully.
|
Story Points: | --- |
| Clone Of: | Environment: | ||
| Last Closed: | 2013-07-17 21:42:10 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
|
Description
Vineet Reynolds
2013-06-27 09:57:51 UTC
Migrated to JIRA |