-
-
Notifications
You must be signed in to change notification settings - Fork 974
SAK-48970 gradebook supports removal of data when a site is hard deleted #13694
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
Open
jkjanetschek
wants to merge
2
commits into
sakaiproject:master
Choose a base branch
from
jkjanetschek:SAK-48970
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+76
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5422,4 +5422,29 @@ public Long getMatchingUserGradebookItemId(String siteId, String userId, String | |||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
return null; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
/* | ||||||||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||||||||
public void hardDelete(String siteId) { | ||||||||||||||||||||||||||||||
if (isGradebookDefined(context)) { | ||||||||||||||||||||||||||||||
log.debug("Site " + context + " has been deleted. Removing associated gradebook data."); | ||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||
this.gradebookFrameworkService.deleteGradebook(context); | ||||||||||||||||||||||||||||||
} catch (final GradebookNotFoundException e) { | ||||||||||||||||||||||||||||||
log.debug("Couldnt find gradebook. Nothing to delete.", e); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
Comment on lines
+5425
to
+5439
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove
Suggested change
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
public void hardDeleteGradebook(String siteId) { | ||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||
if (gradingPersistenceManager.isGradebookDefined(siteId)) { | ||||||||||||||||||||||||||||||
deleteGradebook(siteId); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} catch (Exception e) { | ||||||||||||||||||||||||||||||
log.warn("Could not hardDelete gradebook for context {}", siteId); | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -27,6 +27,7 @@ | |||||||||||||
import org.springframework.transaction.annotation.Transactional; | ||||||||||||||
|
||||||||||||||
import org.sakaiproject.grading.api.model.Gradebook; | ||||||||||||||
import org.sakaiproject.grading.api.model.Spreadsheet; | ||||||||||||||
import org.sakaiproject.grading.api.repository.GradebookRepository; | ||||||||||||||
import org.sakaiproject.springframework.data.SpringCrudRepositoryImpl; | ||||||||||||||
|
||||||||||||||
|
@@ -53,4 +54,33 @@ public int deleteByUid(String uid) { | |||||||||||||
delete.where(cb.equal(gradebook.get("uid"), uid)); | ||||||||||||||
return session.createQuery(delete).executeUpdate(); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
@Transactional(readOnly = true) | ||||||||||||||
public boolean isGradebookDefined(final String gradebookUid) { | ||||||||||||||
/* | ||||||||||||||
return ((Long) sessionFactory.getCurrentSession().createCriteria(Gradebook.class) | ||||||||||||||
.add(Restrictions.eq("uid", gradebookUid)) | ||||||||||||||
.setProjection(Projections.rowCount()) | ||||||||||||||
.uniqueResult()) == 1L; | ||||||||||||||
*/ | ||||||||||||||
Comment on lines
+60
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove
Suggested change
|
||||||||||||||
Session session = sessionFactory.getCurrentSession(); | ||||||||||||||
CriteriaBuilder cb = session.getCriteriaBuilder(); | ||||||||||||||
CriteriaQuery<Gradebook> query = cb.createQuery(Gradebook.class); | ||||||||||||||
Root<Gradebook> gradebook = query.from(Gradebook.class); | ||||||||||||||
query.where(cb.equal(gradebook.get("uid"), gradebookUid)); | ||||||||||||||
return session.createQuery(query).uniqueResultOptional().isPresent(); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
@Transactional | ||||||||||||||
public int deleteSpreadsheetsForGradebook(final Long id) { | ||||||||||||||
Session session = sessionFactory.getCurrentSession(); | ||||||||||||||
CriteriaBuilder cb = session.getCriteriaBuilder(); | ||||||||||||||
CriteriaDelete<Spreadsheet> delete = cb.createCriteriaDelete(Spreadsheet.class); | ||||||||||||||
Root<Spreadsheet> spreadsheet = delete.from(Spreadsheet.class); | ||||||||||||||
delete.where(cb.equal(spreadsheet.get("gradebook").get("id"), id)); | ||||||||||||||
return session.createQuery(delete).executeUpdate(); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
|
||||||||||||||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what are spreadsheets?