Skip to content

Commit

Permalink
SAK-45851 Hibernate5 deprecated: Query.setBoolean( => setParameter (s…
Browse files Browse the repository at this point in the history
  • Loading branch information
axxter99 authored Jul 23, 2021
1 parent 35aff5b commit 2b1ec69
Showing 1 changed file with 47 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import lombok.extern.slf4j.Slf4j;
import org.hibernate.Hibernate;
import org.hibernate.query.Query;
import org.hibernate.type.BooleanType;
import org.sakaiproject.authz.api.SecurityService;
import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.content.api.ContentResource;
Expand Down Expand Up @@ -276,8 +277,8 @@ public PublishedEvaluationModel preparePublishedEvaluationModel(

public Set preparePublishedMetaDataSet(PublishedAssessmentData p,
Set metaDataSet) {
HashSet h = new HashSet();
Iterator i = metaDataSet.iterator();
Set<PublishedMetaData> h = new HashSet<>();
Iterator<AssessmentMetaData> i = metaDataSet.iterator();
while (i.hasNext()) {
AssessmentMetaData metaData = (AssessmentMetaData) i.next();
PublishedMetaData publishedMetaData = new PublishedMetaData(p,
Expand All @@ -288,8 +289,8 @@ public Set preparePublishedMetaDataSet(PublishedAssessmentData p,
}

public Set preparePublishedSecuredIPSet(PublishedAssessmentData p, Set ipSet) {
HashSet h = new HashSet();
Iterator i = ipSet.iterator();
Set<PublishedSecuredIPAddress> h = new HashSet<>();
Iterator<SecuredIPAddress> i = ipSet.iterator();
while (i.hasNext()) {
SecuredIPAddress ip = (SecuredIPAddress) i.next();
PublishedSecuredIPAddress publishedIP = new PublishedSecuredIPAddress(
Expand All @@ -302,9 +303,9 @@ public Set preparePublishedSecuredIPSet(PublishedAssessmentData p, Set ipSet) {
public Set preparePublishedSectionSet(
PublishedAssessmentData publishedAssessment, Set sectionSet,
String protocol) {
log.debug("**published section size = " + sectionSet.size());
HashSet h = new HashSet();
Iterator i = sectionSet.iterator();
log.debug("**published section size = {}", sectionSet.size());
Set<PublishedSectionData> h = new HashSet<>();
Iterator<SectionData> i = sectionSet.iterator();
while (i.hasNext()) {
SectionData section = (SectionData) i.next();

Expand Down Expand Up @@ -337,8 +338,8 @@ public Set preparePublishedSectionSet(

public Set preparePublishedSectionMetaDataSet(
PublishedSectionData publishedSection, Set metaDataSet) {
HashSet h = new HashSet();
Iterator n = metaDataSet.iterator();
Set<PublishedSectionMetaData> h = new HashSet<>();
Iterator<SectionMetaData> n = metaDataSet.iterator();
while (n.hasNext()) {
SectionMetaData sectionMetaData = (SectionMetaData) n.next();
PublishedSectionMetaData publishedSectionMetaData = new PublishedSectionMetaData(
Expand All @@ -351,9 +352,9 @@ public Set preparePublishedSectionMetaDataSet(

public Set preparePublishedItemSet(PublishedSectionData publishedSection,
Set itemSet, String protocol) {
log.debug("**published item size = " + itemSet.size());
HashSet h = new HashSet();
Iterator j = itemSet.iterator();
log.debug("**published item size = {}", itemSet.size());
Set<PublishedItemData> h = new HashSet<>();
Iterator<ItemData> j = itemSet.iterator();
while (j.hasNext()) {
ItemData item = (ItemData) j.next();
PublishedItemData publishedItem = new PublishedItemData(
Expand Down Expand Up @@ -393,12 +394,12 @@ public Set preparePublishedItemSet(PublishedSectionData publishedSection,

public Set preparePublishedItemTextSet(PublishedItemData publishedItem,
Set itemTextSet, String protocol) {
log.debug("**published item text size = " + itemTextSet.size());
HashSet h = new HashSet();
Iterator k = itemTextSet.iterator();
log.debug("**published item text size = {}", itemTextSet.size());
Set<PublishedItemText> h = new HashSet<>();
Iterator<ItemText> k = itemTextSet.iterator();
while (k.hasNext()) {
ItemText itemText = (ItemText) k.next();
log.debug("**item text id =" + itemText.getId());
log.debug("**item text id = {}", itemText.getId());
PublishedItemText publishedItemText = new PublishedItemText(
publishedItem, itemText.getSequence(), itemText.getText(),
null);
Expand All @@ -417,8 +418,8 @@ public Set preparePublishedItemTextSet(PublishedItemData publishedItem,

public Set preparePublishedItemMetaDataSet(PublishedItemData publishedItem,
Set itemMetaDataSet) {
HashSet h = new HashSet();
Iterator n = itemMetaDataSet.iterator();
Set<PublishedItemMetaData> h = new HashSet<>();
Iterator<ItemMetaData> n = itemMetaDataSet.iterator();
while (n.hasNext()) {
ItemMetaData itemMetaData = (ItemMetaData) n.next();
// The itemMetaData.getEntry() is actually the pending/core part id.
Expand All @@ -438,8 +439,8 @@ public Set preparePublishedItemMetaDataSet(PublishedItemData publishedItem,

public Set preparePublishedItemFeedbackSet(PublishedItemData publishedItem,
Set itemFeedbackSet) {
HashSet h = new HashSet();
Iterator o = itemFeedbackSet.iterator();
Set<PublishedItemFeedback> h = new HashSet<>();
Iterator<ItemFeedback> o = itemFeedbackSet.iterator();
while (o.hasNext()) {
ItemFeedback itemFeedback = (ItemFeedback) o.next();
PublishedItemFeedback publishedItemFeedback = new PublishedItemFeedback(
Expand All @@ -453,8 +454,8 @@ public Set preparePublishedItemFeedbackSet(PublishedItemData publishedItem,
public Set preparePublishedItemAttachmentSet(
PublishedItemData publishedItem, Set itemAttachmentSet,
String protocol) {
HashSet h = new HashSet();
Iterator o = itemAttachmentSet.iterator();
Set<PublishedItemAttachment> h = new HashSet<>();
Iterator<ItemAttachment> o = itemAttachmentSet.iterator();
while (o.hasNext()) {
ItemAttachment itemAttachment = (ItemAttachment) o.next();
try {
Expand Down Expand Up @@ -486,8 +487,8 @@ public Set preparePublishedItemAttachmentSet(

public Set preparePublishedItemTagSet(PublishedItemData publishedItem,
Set itemTagSet) {
HashSet h = new HashSet();
Iterator n = itemTagSet.iterator();
Set<PublishedItemTag> h = new HashSet<>();
Iterator<ItemTag> n = itemTagSet.iterator();
while (n.hasNext()) {
ItemTag itemTag = (ItemTag) n.next();
PublishedItemTag publishedItemTag = new PublishedItemTag(publishedItem,
Expand All @@ -501,8 +502,8 @@ public Set preparePublishedItemTagSet(PublishedItemData publishedItem,
public Set preparePublishedItemTextAttachmentSet(
PublishedItemText publishedItemText, Set itemTextAttachmentSet,
String protocol) {
HashSet h = new HashSet();
Iterator o = itemTextAttachmentSet.iterator();
Set<PublishedItemTextAttachment> h = new HashSet<>();
Iterator<ItemTextAttachment> o = itemTextAttachmentSet.iterator();
while (o.hasNext()) {
ItemTextAttachment itemTextAttachment = (ItemTextAttachment) o.next();
try {
Expand Down Expand Up @@ -546,8 +547,8 @@ public String getRelativePath(String url, String protocol) {
public Set preparePublishedSectionAttachmentSet(
PublishedSectionData publishedSection, Set sectionAttachmentSet,
String protocol) {
HashSet h = new HashSet();
Iterator o = sectionAttachmentSet.iterator();
Set<PublishedSectionAttachment> h = new HashSet<>();
Iterator<SectionAttachment> o = sectionAttachmentSet.iterator();
while (o.hasNext()) {
SectionAttachment sectionAttachment = (SectionAttachment) o.next();
try {
Expand Down Expand Up @@ -582,8 +583,8 @@ public Set preparePublishedSectionAttachmentSet(
public Set preparePublishedAssessmentAttachmentSet(
PublishedAssessmentData publishedAssessment,
Set assessmentAttachmentSet, String protocol) {
HashSet h = new HashSet();
Iterator o = assessmentAttachmentSet.iterator();
Set<PublishedAssessmentAttachment> h = new HashSet<>();
Iterator<AssessmentAttachment> o = assessmentAttachmentSet.iterator();
while (o.hasNext()) {
AssessmentAttachment assessmentAttachment = (AssessmentAttachment) o
.next();
Expand Down Expand Up @@ -619,9 +620,9 @@ public Set preparePublishedAssessmentAttachmentSet(

public Set preparePublishedAnswerSet(PublishedItemText publishedItemText,
Set answerSet) {
log.debug("**published answer size = " + answerSet.size());
HashSet h = new HashSet();
Iterator l = answerSet.iterator();
log.debug("**published answer size = {}", answerSet.size());
Set<PublishedAnswer> h = new HashSet<>();
Iterator<Answer> l = answerSet.iterator();
while (l.hasNext()) {
Answer answer = (Answer) l.next();
PublishedAnswer publishedAnswer = new PublishedAnswer(
Expand All @@ -640,8 +641,8 @@ public Set preparePublishedAnswerSet(PublishedItemText publishedItemText,

public Set preparePublishedAnswerFeedbackSet(
PublishedAnswer publishedAnswer, Set answerFeedbackSet) {
HashSet h = new HashSet();
Iterator m = answerFeedbackSet.iterator();
Set<PublishedAnswerFeedback> h = new HashSet<>();
Iterator<AnswerFeedback> m = answerFeedbackSet.iterator();
while (m.hasNext()) {
AnswerFeedback answerFeedback = (AnswerFeedback) m.next();
PublishedAnswerFeedback publishedAnswerFeedback = new PublishedAnswerFeedback(
Expand Down Expand Up @@ -952,7 +953,7 @@ public List<AssessmentGradingData> getNumberOfSubmissionsOfAllAssessmentsByAgent
"from AssessmentGradingData as a where a.agentId = :agent and a.forGrade= :forgrade and a.status > :status " +
"group by a.publishedAssessmentId")
.setParameter("agent", agentId)
.setBoolean("forgrade", true)
.setParameter("forgrade", true, BooleanType.INSTANCE)
.setParameter("status", AssessmentGradingData.REMOVED)
.list();
return getHibernateTemplate().execute(hcb);
Expand All @@ -973,7 +974,7 @@ public List<AssessmentGradingData> getNumberOfSubmissionsOfAllAssessmentsByAgent
+ " and az.functionId=:functionId and az.qualifierId=a.publishedAssessmentId"
+ " group by a.publishedAssessmentId");
q.setParameter("agentId", agentId);
q.setBoolean("forGrade", true);
q.setParameter("forGrade", true, BooleanType.INSTANCE);
q.setParameter("status", AssessmentGradingData.REMOVED);
q.setParameter("siteId", siteId);
q.setParameterList("groupIds", groupIds);
Expand All @@ -993,7 +994,7 @@ public List<AssessmentGradingData> getNumberOfSubmissionsOfAllAssessmentsByAgent
+ " and az.functionId=:functionId and az.qualifierId=a.publishedAssessmentId"
+ " group by a.publishedAssessmentId");
q.setParameter("agentId", agentId);
q.setBoolean("forGrade", true);
q.setParameter("forGrade", true, BooleanType.INSTANCE);
q.setParameter("status", AssessmentGradingData.REMOVED);
q.setParameter("siteId", siteId);
q.setParameter("functionId", "TAKE_PUBLISHED_ASSESSMENT");
Expand Down Expand Up @@ -1481,7 +1482,7 @@ public List<AssessmentGradingData> getBasicInfoOfLastSubmittedAssessments(final

final HibernateCallback<List<AssessmentGradingData>> hcb = session -> {
Query q = session.createQuery(query);
q.setBoolean("forgrade", true);
q.setParameter("forgrade", true, BooleanType.INSTANCE);
q.setParameter("agent", agentId);
q.setParameter("status", AssessmentGradingData.REMOVED);
return q.list();
Expand Down Expand Up @@ -1536,7 +1537,7 @@ public Map<Long, Integer> getTotalSubmissionPerAssessment(String agentId, String
public Integer getTotalSubmissionForEachAssessment(final Long publishedAssessmentId) {
final HibernateCallback<List<Number>> hcb = session -> session
.createQuery("select count(a) from AssessmentGradingData a where a.forGrade = :forgrade and a.publishedAssessmentId = :id and a.status > :status")
.setBoolean("forgrade", true)
.setParameter("forgrade", true, BooleanType.INSTANCE)
.setParameter("id", publishedAssessmentId)
.setParameter("status", AssessmentGradingData.REMOVED)
.list();
Expand All @@ -1548,7 +1549,7 @@ public Integer getTotalSubmissionForEachAssessment(final Long publishedAssessmen
public Integer getTotalSubmission(final String agentId, final Long publishedAssessmentId) {
final HibernateCallback<List<Number>> hcb = session -> session
.createQuery("select count(a) from AssessmentGradingData a where a.forGrade = :forgrade and a.agentId = :agent and a.publishedAssessmentId = :id and a.status > :status")
.setBoolean("forgrade", true)
.setParameter("forgrade", true, BooleanType.INSTANCE)
.setParameter("agent", agentId)
.setParameter("id", publishedAssessmentId)
.setParameter("status", AssessmentGradingData.REMOVED)
Expand Down Expand Up @@ -1937,7 +1938,7 @@ public List<AssessmentGradingData> getBasicInfoOfLastOrHighestOrAverageSubmitted

final HibernateCallback<List<AssessmentGradingData>> hcb_last = session -> {
Query q = session.createQuery(hql + order_last);
q.setBoolean("forGrade", true);
q.setParameter("forGrade", true, BooleanType.INSTANCE);
q.setParameter("status", AssessmentGradingData.REMOVED);
q.setParameter("agentId", agentId);
q.setParameter("siteId", siteId);
Expand All @@ -1953,7 +1954,7 @@ public List<AssessmentGradingData> getBasicInfoOfLastOrHighestOrAverageSubmitted

final HibernateCallback<List<AssessmentGradingData>> hcb_highest = session -> {
Query q = session.createQuery(hql + order_highest);
q.setBoolean("forGrade", true);
q.setParameter("forGrade", true, BooleanType.INSTANCE);
q.setParameter("status", AssessmentGradingData.REMOVED);
q.setParameter("agentId", agentId);
q.setParameter("siteId", siteId);
Expand Down Expand Up @@ -1984,7 +1985,7 @@ public List<AssessmentGradingData> getBasicInfoOfLastOrHighestOrAverageSubmitted

final HibernateCallback<List<AssessmentGradingData>> hcb_last = session -> {
Query q = session.createQuery(hql + order_last);
q.setBoolean("forGrade", true);
q.setParameter("forGrade", true, BooleanType.INSTANCE);
q.setParameter("status", AssessmentGradingData.REMOVED);
q.setParameter("agentId", agentId);
q.setParameter("siteId", siteId);
Expand All @@ -1997,7 +1998,7 @@ public List<AssessmentGradingData> getBasicInfoOfLastOrHighestOrAverageSubmitted

final HibernateCallback<List<AssessmentGradingData>> hcb_highest = session -> {
Query q = session.createQuery(hql + order_highest);
q.setBoolean("forGrade", true);
q.setParameter("forGrade", true, BooleanType.INSTANCE);
q.setParameter("status", AssessmentGradingData.REMOVED);
q.setParameter("agentId", agentId);
q.setParameter("siteId", siteId);
Expand Down Expand Up @@ -2600,7 +2601,7 @@ public List<AssessmentGradingData> getAllAssessmentsGradingDataByAgentAndSiteId(
"and az.agentIdString=:siteId " +
"and az.functionId=:functionId and az.qualifierId=a.publishedAssessmentId")
.setParameter("agentId", agentId)
.setBoolean("forGrade", true)
.setParameter("forGrade", true, BooleanType.INSTANCE)
.setParameter("status", AssessmentGradingData.REMOVED)
.setParameter("siteId", siteId)
.setParameter("functionId", "OWN_PUBLISHED_ASSESSMENT")
Expand Down

0 comments on commit 2b1ec69

Please sign in to comment.