-
-
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,7 @@ public interface GradebookRepository extends SpringCrudRepository<Gradebook, Lon | |
|
||
Optional<Gradebook> findByUid(String uid); | ||
int deleteByUid(String uid); | ||
|
||
public boolean isGradebookDefined(final String gradebookUid); | ||
public int deleteSpreadsheetsForGradebook(final Long id); | ||
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. what are spreadsheets? |
||
} |
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
|
||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} |
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(); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
|
||||||||||||||
} |
Uh oh!
There was an error while loading. Please reload this page.