-
-
Notifications
You must be signed in to change notification settings - Fork 998
SAK-52251 Lessons Subpages of a Lessons are imported as pseudo-orphans #14304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
WalkthroughModified LessonBuilderEntityProducer.java to improve page hierarchy reconstruction during imports. Changes page creation to use null toolId initially, then reconstructs parent relationships and toolIds through multi-step processing passes that build calculated parent maps and apply them to imported pages. Changes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/service/LessonBuilderEntityProducer.java (1)
1739-1751: Consider adding cycle detection to the parent chain traversal.The
whileloop walks up the parent chain to find the top parent. While cycles should not exist in valid data, a defensive safeguard would prevent an infinite loop in case of corrupted data.🔎 Suggested defensive safeguard
// Calculate top parents by walking up the tree for (Long pageId : calculatedParentMap.keySet()) { Long currentPageId = pageId; Long topParent = null; + Set<Long> visited = new HashSet<>(); - while (calculatedParentMap.containsKey(currentPageId)) { + while (calculatedParentMap.containsKey(currentPageId) && !visited.contains(currentPageId)) { + visited.add(currentPageId); topParent = calculatedParentMap.get(currentPageId); currentPageId = topParent; } if (topParent != null) { calculatedTopParentMap.put(pageId, topParent); } }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/service/LessonBuilderEntityProducer.java(6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.java
📄 CodeRabbit inference engine (.cursor/rules/logging-rule.mdc)
**/*.java: Use SLF4J parameterized logging (logger.info("Value is: {}", value)) instead of string concatenation (logger.info("Value is: " + value))
Log messages and code comments should be in English. Log messages should never be translated.
**/*.java: Java: Never use local variable type inference (var). Always declare explicit types. Yes:Map<String, Integer> counts = new HashMap<>();No:var counts = new HashMap<String, Integer>();
When proposing Java code, spell out full types in local variable declarations,forloops, and try-with-resources
When editing Java, prefer clarity over brevity; avoid introducing language features that aren't widely used in the repo
Treat any PR or suggestion containing Javavaras non-compliant. Recommend replacing with explicit types before merge
**/*.java: Use Java 17 for trunk development (Java 11 was used for Sakai 22 and Sakai 23)
Do not use local variable type inference (var) in Java code. Always declare explicit types (e.g.,List<String> names = new ArrayList<>();notvar names = new ArrayList<String>();). Enforced by Checkstyle rule duringmvn validate
Files:
lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/service/LessonBuilderEntityProducer.java
🧠 Learnings (1)
📚 Learning: 2025-10-07T16:11:33.008Z
Learnt from: CR
Repo: sakaiproject/sakai PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-07T16:11:33.008Z
Learning: For new tools, prefer Spring MVC/Boot with Hibernate and ThymeLeaf; avoid RSF for new development and consider modernization when changing legacy tools
Applied to files:
lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/service/LessonBuilderEntityProducer.java
🧬 Code graph analysis (1)
lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/service/LessonBuilderEntityProducer.java (2)
kernel/api/src/main/java/org/sakaiproject/util/MergeConfig.java (1)
MergeConfig(31-41)kernel/api/src/main/java/org/sakaiproject/util/cover/LinkMigrationHelper.java (1)
LinkMigrationHelper(23-52)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: maven-build
- GitHub Check: maven-build
- GitHub Check: sakai-deploy
🔇 Additional comments (4)
lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/service/LessonBuilderEntityProducer.java (4)
101-134: Import additions are appropriate.The added imports support the new hierarchy reconstruction functionality:
SakaiLTIUtilfor LTI content handlingMergeConfigandLinkMigrationHelperfor merge operationsThese are all used within the file and follow proper organization.
1650-1651: Deferred parent relationship assignment is a reasonable approach.Creating pages with a placeholder
toolIdof "0" and setting parent relationships in a later pass allows proper hierarchy reconstruction after all pages are created. This is cleaner than trying to resolve relationships during initial creation.
1753-1792: Hierarchy update logic looks correct.The code properly:
- Iterates through the page map using old page IDs as keys
- Looks up calculated parent/topparent relationships
- Maps old IDs to new IDs via
pageMap- Updates and persists only when changes are needed
The logging at the end provides good visibility into the operation.
1970-1999: ToolId propagation logic is correct.The code properly propagates the
toolIdfrom top-level pages to their descendants. The checks at line 1986-1987 correctly handle:
- Null pages
- Top parent with null or placeholder "0" toolId
- Avoiding unnecessary updates when toolId already matches
Note: For very large imports, the two
getPage()calls per iteration (lines 1983-1984) could be optimized by caching pages from the earlier pass, but this is acceptable for typical import scenarios.
...er/tool/src/java/org/sakaiproject/lessonbuildertool/service/LessonBuilderEntityProducer.java
Show resolved
Hide resolved
|
Converted to draft: continues the work from #14300 |
https://sakaiproject.atlassian.net/browse/SAK-52251
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.