Skip to content

Fixed Query by example adding and editing broken#636

Merged
yingbull merged 3 commits into
develop/dogfishfrom
507-query-by-example-adding-or-editing-broken
Sep 26, 2025
Merged

Fixed Query by example adding and editing broken#636
yingbull merged 3 commits into
develop/dogfishfrom
507-query-by-example-adding-or-editing-broken

Conversation

@LiamStanziani

@LiamStanziani LiamStanziani commented Sep 24, 2025

Copy link
Copy Markdown
Collaborator

Query by example in the administration page had broken adding functionality (adding a new query favourite was only allowed once, after that it was overwritten), as well as it didn't lead to the edit page after adding. And the editing functionality didn't lead to the correct page for editing.

I also looked into making the code a bit simpler without breaking anything for better readability

Summary by Sourcery

Fix broken add and edit flows for query favorites and streamline related code and JSP

Bug Fixes:

  • Restore add-to-favorites functionality to allow multiple saves instead of overwriting
  • Redirect edit requests to the correct edit view and ensure proper favorite name selection
  • Reorder action logic to handle edit, delete, and add cases in the correct sequence
  • Update JSP to use form.submit() and retain date field values on refresh

Enhancements:

  • Simplify server-side action code for better readability
  • Remove unused JavaScript function from JSP

…button not opening the correct edit page to add the edits before favoriting, fixed the edit button not doing anything when clicked, fixed the delete reseting the page when clicked
@sourcery-ai

sourcery-ai Bot commented Sep 24, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Corrects multi-add and edit redirects for query favorites by refactoring action logic and cleans up the JSP by removing redundant scripts, standardizing form submission, and pre-filling date inputs.

Class diagram for updated RptByExamplesFavorite2Action logic

classDiagram
class RptByExamplesFavorite2Action {
  -String providerNo
  -String newQuery
  -String newName
  -String favoriteName
  -String query
  -String toDelete
  -String id
  +String execute()
  +void deleteQuery(String id)
  +void write2Database(String providerNo, String favoriteName, String queryWithEscapeChar)
}
class ReportByExamplesFavoriteDao {
  +List<ReportByExamplesFavorite> findByQuery(String query)
}
class RptByExampleQueryBeanHandler {
  +RptByExampleQueryBeanHandler(String providerNo)
}
RptByExamplesFavorite2Action --> ReportByExamplesFavoriteDao
RptByExamplesFavorite2Action --> RptByExampleQueryBeanHandler
Loading

File-Level Changes

Change Details Files
Fix broken add/edit logic and streamline RptByExamplesFavorite2Action flow
  • Reordered execution branches to handle edit before delete, returning 'edit' early
  • Consolidated database writes by moving write2Database into add-only branch
  • Added SQL escaping with StringUtils.defaultString to prevent nulls
  • Removed duplicate write2Database calls and simplified control flow
src/main/java/ca/openosp/openo/report/pageUtil/RptByExamplesFavorite2Action.java
Simplify JSP forms and enhance date input handling
  • Removed unused JavaScript submit function, switched to standard form.submit()
  • Updated onclick handler to use submit() directly
  • Pre-populated startDate and endDate fields with existing values
src/main/webapp/oscarReport/RptViewAllQueryByExamples.jsp

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

github-actions Bot commented Sep 24, 2025

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA c09f1c8.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@LiamStanziani LiamStanziani marked this pull request as ready for review September 24, 2025 21:00

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `src/main/webapp/oscarReport/RptViewAllQueryByExamples.jsp:106` </location>
<code_context>
                                     <input type="button"
                                         value="<fmt:setBundle basename="oscarResources"/><fmt:message key="oscarReport.RptByExample.MsgAddToFavorite"/>"
-                                         onclick="set('<c:out value="${escapedQuery}" escapeXml="true"/>'); submitFavouriteForm();" />
+                                        onclick="set('<c:out value="${escapedQuery}" escapeXml="true"/>'); submit();" />
                             </tr>
                         </c:forEach>
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Using submit() directly may cause issues if the button is not inside a form.

Make sure submit() is called on the intended form element to avoid issues, especially if multiple forms exist or the button is outside a form.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/main/webapp/oscarReport/RptViewAllQueryByExamples.jsp
@LiamStanziani LiamStanziani changed the title Query by example adding and editing broken Fixed Query by example adding and editing broken Sep 26, 2025
@yingbull yingbull merged commit a6bb36a into develop/dogfish Sep 26, 2025
14 of 15 checks passed
@yingbull yingbull deleted the 507-query-by-example-adding-or-editing-broken branch January 8, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding a new favourite query, or editing an exisiting query doesn't work in Admin panel - Reports - Query By Example

2 participants