Skip to content

Commit

Permalink
SSP-3088 Fix EA Message and MapPlanStatus Hibernate Error
Browse files Browse the repository at this point in the history
  • Loading branch information
pspaude committed Jul 8, 2015
1 parent bba6d64 commit 55e0258
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
13 changes: 5 additions & 8 deletions src/main/java/org/jasig/ssp/dao/MapStatusReportDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.Collection;
import java.util.List;
import java.util.UUID;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
Expand All @@ -39,15 +38,15 @@
@Repository
public class MapStatusReportDao extends AbstractPersonAssocAuditableCrudDao<MapStatusReport> implements PersonAssocAuditableCrudDao<MapStatusReport> {



public MapStatusReportDao() {
super(MapStatusReport.class);
}

protected MapStatusReportDao(Class<MapStatusReport> persistentClass) {
super(MapStatusReport.class);
}


public void deleteAllOldReports() {
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
Expand All @@ -65,6 +64,7 @@ public void deleteAllOldReports() {
session.close();

}

@SuppressWarnings("unchecked")
public List<MapStatusReportSummaryDetail> getSummaryDetails() {
String detailsQuery = " select new org.jasig.ssp.transferobject.reports.MapStatusReportSummaryDetail(msr.planStatus,count(*)) from MapStatusReport msr group by msr.planStatus order by count(*) desc";
Expand All @@ -79,7 +79,6 @@ public List<MapStatusReportOwnerAndCoachInfo> getOwnersAndCoachesWithOffPlanStud

return createHqlQuery(detailsQuery).setString("planStatus", PlanStatus.OFF.name()).list();
}


@SuppressWarnings("unchecked")
public List<MapStatusReportPerson> getOffPlanPlansForOwner(Person owner) {
Expand Down Expand Up @@ -113,11 +112,12 @@ public List<MapStatusReportSubstitutionDetails> getAllSubstitutionDetailsForPers
return createHqlQuery(query).setEntity("person", person).list();
}

public void oldReportForStudent(UUID personId) {
public void deleteAllOldReportsForPerson(UUID personId) {
Collection<MapStatusReport> allForPersonId = getAllForPersonId(personId, null).getRows();
for (MapStatusReport mapStatusReport : allForPersonId) {
delete(mapStatusReport);
}
sessionFactory.getCurrentSession().flush();
}

@SuppressWarnings("unchecked")
Expand All @@ -138,7 +138,4 @@ public List<MapStatusReportPerson> getOffPlanPlansForWatcher(Person watcher) {
List<MapStatusReportPerson> result = query.setEntity("watcher", watcher).setString("planStatus", PlanStatus.OFF.name()).list();
return result;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ MapStatusReport evaluatePlan(Set<String> gradesSet,

List<MapStatusReportPerson> getOffPlanPlansForOwner(Person owner);

List<MapStatusReportCourseDetails> getAllCourseDetailsForPerson(
Person person);
List<MapStatusReportCourseDetails> getAllCourseDetailsForPerson(Person person);

List<MapStatusReportTermDetails> getAllTermDetailsForPerson(Person person);

List<MapStatusReportSubstitutionDetails> getAllSubstitutionDetailsForPerson(
Person person);
List<MapStatusReportSubstitutionDetails> getAllSubstitutionDetailsForPerson(Person person);

void oldReportForStudent(UUID personId);
void deleteAllOldReportsForStudent(UUID personId);

Boolean calculateStatusForStudent(UUID personId) throws ObjectNotFoundException, ValidationException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,14 +733,14 @@ public List<MapStatusReportSubstitutionDetails> getAllSubstitutionDetailsForPers
}

@Override
public void oldReportForStudent(UUID personId) {
dao.oldReportForStudent(personId);
public void deleteAllOldReportsForStudent(UUID personId) {
dao.deleteAllOldReportsForPerson(personId);
}

@Override
public Boolean calculateStatusForStudent(UUID personId) throws ObjectNotFoundException, ValidationException {
oldReportForStudent(personId);

deleteAllOldReportsForStudent(personId);
//Load up our configs
Set<String> gradesSet = getPassingGrades();
Set<String> additionalCriteriaSet = getAdditionalCriteria();
Expand Down Expand Up @@ -787,5 +787,4 @@ public List<MapStatusReportOwnerAndCoachInfo> getWatchersOffPlanStudent() {
public List<MapStatusReportPerson> getOffPlanPlansForWatcher(Person person) {
return dao.getOffPlanPlansForWatcher(person);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.mail.SendFailedException;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import java.util.Calendar;
import java.util.Date;
import java.util.UUID;
Expand Down Expand Up @@ -98,6 +96,7 @@ protected EarlyAlertService getService() {
return service;
}


// Overriding to specify full request path since we needed a custom create
// method
@Override
Expand Down Expand Up @@ -159,7 +158,7 @@ EarlyAlertTO create(@PathVariable @NotNull final UUID personId,
if (obj.getSendEmailToStudent() != null
&& Boolean.TRUE.equals(obj.getSendEmailToStudent())) {
try {
service.sendMessageToStudent(factory.from(earlyAlertTO));
service.sendMessageToStudent(service.get(earlyAlertTO.getId()));
} catch (final SendFailedException exc) {
LOGGER.error(
"Send message failed when creating a new early alert. Early Alert was created, but message was not succesfully sent to student.",
Expand Down Expand Up @@ -312,4 +311,4 @@ EarlyAlertTO create(@RequestParam final String studentId,
public String permissionBaseName() {
return "EARLY_ALERT";
}
}
}

0 comments on commit 55e0258

Please sign in to comment.