Skip to content

Commit

Permalink
Merge pull request #4 from master-bob/2.9.x
Browse files Browse the repository at this point in the history
Revert "Sakai 11 compatibility changes"
  • Loading branch information
master-bob committed Feb 9, 2016
2 parents 8bd3720 + e1071e3 commit 2e4507d
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 61 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<artifactId>hibernate</artifactId>
</dependency>

<!-- Sakai dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ public interface AttendanceLogic {
*
* @param aE, the AttendanceEvent to update
* @param s, the Status to set the AttendanceRecords (if null, uses the default of the AttendanceSite)
* @return the success of the operation
*/
void updateAttendanceRecordsForEvent(AttendanceEvent aE, Status s);
boolean updateAttendanceRecordsForEvent(AttendanceEvent aE, Status s);

/**
* Update all AttendanceRecords where the user belongs to the supplied group for an AttendanceEvent
Expand All @@ -179,17 +180,19 @@ public interface AttendanceLogic {
* @param s, the Status to use (if null, use the Site's default status)
* @param groupId, only update the AttendanceRecords for members of the groupID (if null or empty calls
* {@link org.sakaiproject.attendance.logic.AttendanceLogic#updateAttendanceRecordsForEvent(AttendanceEvent, Status)})
* @return success of the operation
*/
void updateAttendanceRecordsForEvent(AttendanceEvent aE, Status s, String groupId);
boolean updateAttendanceRecordsForEvent(AttendanceEvent aE, Status s, String groupId);

/**
* Creates AttendanceRecords for an AttendanceEvent using a default Status for the provided Student IDs
*
* @param attendanceEvent, the AttendanceEvent
* @param defaultStatus, the status to use (if null use the site default)
* @param missingStudentIds, a List of UserIDs which need records
* @return the success of the operation
*/
void updateMissingRecordsForEvent(AttendanceEvent attendanceEvent, Status defaultStatus, List<String> missingStudentIds);
boolean updateMissingRecordsForEvent(AttendanceEvent attendanceEvent, Status defaultStatus, List<String> missingStudentIds);

/**
* Get statistics (total counts for each status) for an event
Expand Down
8 changes: 2 additions & 6 deletions impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<artifactId>spring</artifactId>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
Expand All @@ -68,7 +64,7 @@
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<artifactId>hibernate</artifactId>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ public interface AttendanceDao {
* @param aRs, a List of AttendanceRecords
* @return success of the operation
*/
void updateAttendanceRecords(List<AttendanceRecord> aRs);
boolean updateAttendanceRecords(List<AttendanceRecord> aRs);

/**
* Update a set of AttendanceStatuses
*
* @param attendanceStatusList, a List of AttendanceStatuses
* @return success of the operation
*/
void updateAttendanceStatuses(List<AttendanceStatus> attendanceStatusList);
boolean updateAttendanceStatuses(List<AttendanceStatus> attendanceStatusList);

/**
* Get a list of the active statuses in an Attendance Site
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,28 +216,26 @@ public boolean updateAttendanceRecord(AttendanceRecord aR) {
/**
* {@inheritDoc}
*/
public void updateAttendanceRecords(List<AttendanceRecord> aRs) {
for(AttendanceRecord aR : aRs) {
try {
getHibernateTemplate().saveOrUpdate(aR);
log.info("save attendanceRecord id: " + aR.getId());
} catch (Exception e) {
log.error("update attendanceRecords failed.", e);
}
public boolean updateAttendanceRecords(List<AttendanceRecord> aRs) {
try{
getHibernateTemplate().saveOrUpdateAll(aRs);
return true;
} catch (Exception e) {
log.error("update attendanceRecords failed.", e);
return false;
}
}

/**
* {@inheritDoc}
*/
public void updateAttendanceStatuses(List<AttendanceStatus> attendanceStatusList) {
for(AttendanceStatus aS : attendanceStatusList) {
try {
getHibernateTemplate().saveOrUpdate(aS);
log.info("AttendanceStatus saved, id: " + aS.getId());
} catch (Exception e) {
log.error("update attendanceStatuses failed.", e);
}
public boolean updateAttendanceStatuses(List<AttendanceStatus> attendanceStatusList) {
try{
getHibernateTemplate().saveOrUpdateAll(attendanceStatusList);
return true;
} catch (Exception e) {
log.error("update attendanceStatuses failed.", e);
return false;
}
}

Expand All @@ -255,7 +253,7 @@ public List<AttendanceStatus> getActiveStatusesForSite(final AttendanceSite atte
@Override
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query q = session.getNamedQuery(QUERY_GET_ACTIVE_ATTENDANCE_STATUSES_FOR_SITE);
q.setParameter(ATTENDANCE_SITE, attendanceSite, new ManyToOneType(null, "org.sakaiproject.attendance.model.AttendanceSite"));
q.setParameter(ATTENDANCE_SITE, attendanceSite, new ManyToOneType("org.sakaiproject.attendance.model.AttendanceSite"));
return q.list();
}
};
Expand All @@ -281,7 +279,7 @@ public List<AttendanceStatus> getAllStatusesForSite(final AttendanceSite attenda
@Override
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query q = session.getNamedQuery(QUERY_GET_ALL_ATTENDANCE_STATUSES_FOR_SITE);
q.setParameter(ATTENDANCE_SITE, attendanceSite, new ManyToOneType(null, "org.sakaiproject.attendance.model.AttendanceSite"));
q.setParameter(ATTENDANCE_SITE, attendanceSite, new ManyToOneType("org.sakaiproject.attendance.model.AttendanceSite"));
return q.list();
}
};
Expand Down Expand Up @@ -328,7 +326,7 @@ public AttendanceGrade getAttendanceGrade(final String userID, final AttendanceS
@Override
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query q = session.getNamedQuery(QUERY_GET_ATTENDANCE_GRADE);
q.setParameter(ATTENDANCE_SITE, aS, new ManyToOneType(null, "org.sakaiproject.attendance.model.AttendanceSite"));
q.setParameter(ATTENDANCE_SITE, aS, new ManyToOneType("org.sakaiproject.attendance.model.AttendanceSite"));
q.setParameter(USER_ID, userID, new StringType());
return q.uniqueResult();
}
Expand All @@ -355,7 +353,7 @@ public List<AttendanceGrade> getAttendanceGrades(final AttendanceSite aS) {
@Override
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query q = session.getNamedQuery(QUERY_GET_ATTENDANCE_GRADES_FOR_SITE);
q.setParameter(ATTENDANCE_SITE, aS, new ManyToOneType(null, "org.sakaiproject.attendance.model.AttendanceSite"));
q.setParameter(ATTENDANCE_SITE, aS, new ManyToOneType("org.sakaiproject.attendance.model.AttendanceSite"));
return q.list();
}
};
Expand Down Expand Up @@ -419,7 +417,7 @@ private List<AttendanceEvent> getEventsForAttendanceSiteHelper(final AttendanceS
@Override
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query q = session.getNamedQuery(QUERY_GET_ATTENDANCE_EVENTS_FOR_SITE);
q.setParameter(ATTENDANCE_SITE, aS, new ManyToOneType(null, "org.sakaiproject.attendance.model.AttendanceSite"));
q.setParameter(ATTENDANCE_SITE, aS, new ManyToOneType("org.sakaiproject.attendance.model.AttendanceSite"));
return q.list();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ public AttendanceSite getCurrentAttendanceSite() {
}
}

generateMissingAttendanceStatusesForSite(currentAttendanceSite);
currentAttendanceSite = getAttendanceSite(currentSiteID);
if(generateMissingAttendanceStatusesForSite(currentAttendanceSite)) {
currentAttendanceSite = getAttendanceSite(currentSiteID);
}

return currentAttendanceSite;
}
Expand Down Expand Up @@ -193,7 +194,7 @@ public boolean updateAttendanceRecord(AttendanceRecord aR) throws IllegalArgumen
/**
* {@inheritDoc}
*/
public void updateAttendanceRecordsForEvent(AttendanceEvent aE, Status s) {
public boolean updateAttendanceRecordsForEvent(AttendanceEvent aE, Status s) {
aE = getAttendanceEvent(aE.getId());
List<AttendanceRecord> records = new ArrayList<AttendanceRecord>(aE.getRecords());

Expand All @@ -205,15 +206,15 @@ public void updateAttendanceRecordsForEvent(AttendanceEvent aE, Status s) {
aR.setStatus(s);
}

dao.updateAttendanceRecords(records);
return dao.updateAttendanceRecords(records);
}

/**
* {@inheritDoc}
*/
public void updateAttendanceRecordsForEvent(AttendanceEvent aE, Status s, String groupId) {
public boolean updateAttendanceRecordsForEvent(AttendanceEvent aE, Status s, String groupId) {
if(groupId == null || groupId.isEmpty()) {
updateAttendanceRecordsForEvent(aE, s);
return updateAttendanceRecordsForEvent(aE, s);
} else {
aE = getAttendanceEvent(aE.getId());
List<AttendanceRecord> allRecords = new ArrayList<AttendanceRecord>(aE.getRecords());
Expand All @@ -237,14 +238,14 @@ public void updateAttendanceRecordsForEvent(AttendanceEvent aE, Status s, String
aR.setStatus(s);
}

dao.updateAttendanceRecords(recordsToUpdate);
return dao.updateAttendanceRecords(recordsToUpdate);
}
}

/**
* {@inheritDoc}
*/
public void updateMissingRecordsForEvent(AttendanceEvent attendanceEvent, Status defaultStatus, List<String> missingStudentIds) {
public boolean updateMissingRecordsForEvent(AttendanceEvent attendanceEvent, Status defaultStatus, List<String> missingStudentIds) {
List<AttendanceRecord> recordList = new ArrayList<AttendanceRecord>();

if(defaultStatus == null) {
Expand All @@ -258,8 +259,9 @@ public void updateMissingRecordsForEvent(AttendanceEvent attendanceEvent, Status
recordList.add(attendanceRecord);
}
}
dao.updateAttendanceRecords(recordList);
return dao.updateAttendanceRecords(recordList);
}
return false;
}

/**
Expand Down Expand Up @@ -495,7 +497,7 @@ private void generateStatsHelper(Map<Status, Integer> m, Status s, int base) {
}
}

private void generateMissingAttendanceStatusesForSite(AttendanceSite attendanceSite) {
private boolean generateMissingAttendanceStatusesForSite(AttendanceSite attendanceSite) {
Set<AttendanceStatus> currentAttendanceStatuses = attendanceSite.getAttendanceStatuses();
List<Status> previouslyCreatedStatuses = new ArrayList<Status>();
List<AttendanceStatus> statusesToBeAdded = new ArrayList<AttendanceStatus>();
Expand All @@ -521,7 +523,8 @@ private void generateMissingAttendanceStatusesForSite(AttendanceSite attendanceS
}
}

dao.updateAttendanceStatuses(statusesToBeAdded);
return statusesToBeAdded.isEmpty() || dao.updateAttendanceStatuses(statusesToBeAdded);

}

private int getNextSortOrder(List<AttendanceStatus> attendanceStatusList) {
Expand Down
10 changes: 6 additions & 4 deletions pack/src/webapp/WEB-INF/components.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

<!-- SakaiProxy -->
<bean id="org.sakaiproject.attendance.logic.SakaiProxy"
Expand Down Expand Up @@ -77,7 +78,8 @@
<!-- AttendanceGradebookProvider -->
<bean id="org.sakaiproject.attendance.api.AttendanceGradebookProvider"
class="org.sakaiproject.attendance.impl.AttendanceGradebookProviderImpl"
init-method="init">
init-method="init"
singleton="true">

<property name="attendanceLogic" ref="org.sakaiproject.attendance.logic.AttendanceLogic" />
<property name="sakaiProxy" ref="org.sakaiproject.attendance.logic.SakaiProxy" />
Expand Down
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>org.sakaiproject</groupId>
<artifactId>master</artifactId>
<version>11-SNAPSHOT</version>
<version>2.9.3</version>
<relativePath>../master/pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -96,17 +96,17 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${sakai.slf4j.version}</version>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${sakai.slf4j.version}</version>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${sakai.log4j.version}</version>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand All @@ -116,20 +116,20 @@
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${sakai.spring.version}</version>
<artifactId>spring</artifactId>
<version>2.5.6.SEC03</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>${sakai.ehcache.version}</version>
<version>1.7.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${sakai.commons.lang.version}</version>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ private void init() {
final Form<?> setAllForm = new Form<Void>("set-all-form"){
@Override
protected void onSubmit() {
attendanceLogic.updateAttendanceRecordsForEvent(attendanceEvent, setAllStatus.getModelObject(), selectedGroup);
String who = selectedGroup == null?"":" for " + sakaiProxy.getGroupTitleForCurrentSite(selectedGroup);
getSession().info("All attendance records " + who + " for " + attendanceEvent.getName() + " set to " + setAllStatus.getModelObject());
setResponsePage(new EventView(attendanceEvent, returnPage, selectedGroup));
if(attendanceLogic.updateAttendanceRecordsForEvent(attendanceEvent, setAllStatus.getModelObject(), selectedGroup)){
String who = selectedGroup == null?"":" for " + sakaiProxy.getGroupTitleForCurrentSite(selectedGroup);
getSession().info("All attendance records " + who + " for " + attendanceEvent.getName() + " set to " + setAllStatus.getModelObject());
setResponsePage(new EventView(attendanceEvent, returnPage, selectedGroup));
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion tool/src/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

<!-- Sakai Spring Listener -->
<listener>
<listener-class>org.sakaiproject.util.SakaiContextLoaderListener</listener-class>
<listener-class>org.sakaiproject.util.ContextLoaderListener</listener-class>
</listener>


Expand Down

0 comments on commit 2e4507d

Please sign in to comment.