Skip to content

Commit

Permalink
Merge pull request sakaiproject#576 from txstate-etc/SAK-29432
Browse files Browse the repository at this point in the history
SAK-29432 Add dropDate field to Enrollment
  • Loading branch information
ottenhoff committed Jun 8, 2015
2 parents fccb246 + d97cfd6 commit 07091be
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,20 @@ public EnrollmentSet createEnrollmentSet(String eid, String title, String descri
public Enrollment addOrUpdateEnrollment(String userId, String enrollmentSetEid,
String enrollmentStatus, String credits, String gradingScheme);

/**
* Adds an Enrollment to an EnrollmentSet. If the user is already enrolled in the
* EnrollmentSet, the Enrollment record is updated for the user.
*
* @param userId
* @param enrollmentSetEid
* @param enrollmentStatus
* @param credits
* @param gradingScheme
* @param dropDate
*/
public Enrollment addOrUpdateEnrollment(String userId, String enrollmentSetEid,
String enrollmentStatus, String credits, String gradingScheme, Date dropDate);

/**
* Removes an Enrollment from an EnrollmentSet by setting the Enrollment to
* dropped=true.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

package org.sakaiproject.coursemanagement.api;

import java.util.Date;

/**
* The official relationship of a student to something that gets a final grade
* (or equivalent).
Expand All @@ -46,4 +48,6 @@ public interface Enrollment {
public boolean isDropped();
public void setDropped(boolean dropped);

public Date getDropDate();
public void setDropDate(Date dropDate);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<property name="credits" column="CREDITS" type="string" not-null="true" />
<property name="gradingScheme" column="GRADING_SCHEME" type="string" not-null="true" />
<property name="dropped" column="DROPPED" type="boolean" />
<property name="dropDate" type="date" column="DROP_DATE" />

<many-to-one name="enrollmentSet" column="ENROLLMENT_SET" unique-key="CM_ENR" index="CM_ENR_ENR_SET_IDX" class="org.sakaiproject.coursemanagement.impl.EnrollmentSetCmImpl" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.sakaiproject.coursemanagement.impl;

import java.io.Serializable;
import java.util.Date;

import org.sakaiproject.coursemanagement.api.Enrollment;
import org.sakaiproject.coursemanagement.api.EnrollmentSet;
Expand All @@ -36,15 +37,21 @@ public class EnrollmentCmImpl extends AbstractPersistentCourseManagementObjectCm
private String credits;
private String gradingScheme;
private boolean dropped;
private Date dropDate;

public EnrollmentCmImpl() {}

public EnrollmentCmImpl(String userId, EnrollmentSet enrollmentSet, String enrollmentStatus, String credits, String gradingScheme) {
this(userId, enrollmentSet, enrollmentStatus, credits, gradingScheme, null);
}

public EnrollmentCmImpl(String userId, EnrollmentSet enrollmentSet, String enrollmentStatus, String credits, String gradingScheme, Date dropDate) {
this.userId = userId;
this.enrollmentSet = enrollmentSet;
this.enrollmentStatus = enrollmentStatus;
this.credits = credits;
this.gradingScheme = gradingScheme;
this.dropDate = dropDate;
}

public String getUserId() {
Expand Down Expand Up @@ -88,4 +95,12 @@ public boolean isDropped() {
public void setDropped(boolean dropped) {
this.dropped = dropped;
}

public Date getDropDate() {
return dropDate;
}

public void setDropDate(Date dropDate) {
this.dropDate = dropDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,18 @@ public void updateEnrollmentSet(EnrollmentSet enrollmentSet) {
}

public Enrollment addOrUpdateEnrollment(String userId, String enrollmentSetEid, String enrollmentStatus, String credits, String gradingScheme) {
return addOrUpdateEnrollment(userId, enrollmentSetEid, enrollmentStatus, credits, gradingScheme, null);
}

public Enrollment addOrUpdateEnrollment(String userId, String enrollmentSetEid, String enrollmentStatus, String credits, String gradingScheme, Date dropDate) {
EnrollmentCmImpl enrollment = null;

List enrollments = getHibernateTemplate().findByNamedQueryAndNamedParam("findEnrollment",
new String[] {"enrollmentSetEid", "userId"},
new Object[] {enrollmentSetEid, userId});
if(enrollments.isEmpty()) {
EnrollmentSet enrollmentSet = (EnrollmentSet)getObjectByEid(enrollmentSetEid, EnrollmentSetCmImpl.class.getName());
enrollment = new EnrollmentCmImpl(userId, enrollmentSet, enrollmentStatus, credits, gradingScheme);
enrollment = new EnrollmentCmImpl(userId, enrollmentSet, enrollmentStatus, credits, gradingScheme, dropDate);
enrollment.setCreatedBy(authn.getUserEid());
enrollment.setCreatedDate(new Date());
getHibernateTemplate().save(enrollment);
Expand All @@ -317,6 +321,7 @@ public Enrollment addOrUpdateEnrollment(String userId, String enrollmentSetEid,
enrollment.setCredits(credits);
enrollment.setGradingScheme(gradingScheme);
enrollment.setDropped(false);
enrollment.setDropDate(dropDate);

enrollment.setLastModifiedBy(authn.getUserEid());
enrollment.setLastModifiedDate(new Date());
Expand Down
3 changes: 3 additions & 0 deletions reference/docs/conversion/sakai_11_mysql_conversion.sql
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,6 @@ INSERT INTO SAKAI_REALM_RL_FN VALUES((select REALM_KEY from SAKAI_REALM where RE
INSERT INTO SAKAI_REALM_RL_FN VALUES((select REALM_KEY from SAKAI_REALM where REALM_ID = '!site.roles'), (select ROLE_KEY from SAKAI_REALM_ROLE where ROLE_NAME = '.auth'), (select FUNCTION_KEY from SAKAI_REALM_FUNCTION where FUNCTION_NAME = 'mail.read'));
INSERT INTO SAKAI_REALM_RL_FN VALUES((select REALM_KEY from SAKAI_REALM where REALM_ID = '!site.roles'), (select ROLE_KEY from SAKAI_REALM_ROLE where ROLE_NAME = '.auth'), (select FUNCTION_KEY from SAKAI_REALM_FUNCTION where FUNCTION_NAME = 'rwiki.read'));
INSERT INTO SAKAI_REALM_RL_FN VALUES((select REALM_KEY from SAKAI_REALM where REALM_ID = '!site.roles'), (select ROLE_KEY from SAKAI_REALM_ROLE where ROLE_NAME = '.auth'), (select FUNCTION_KEY from SAKAI_REALM_FUNCTION where FUNCTION_NAME = 'site.visit'));

-- SAK-29432 Add dropDate field to Enrollment
ALTER TABLE CM_ENROLLMENT_T ADD COLUMN DROP_DATE DATE;
3 changes: 3 additions & 0 deletions reference/docs/conversion/sakai_11_oracle_conversion.sql
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,6 @@ INSERT INTO SAKAI_REALM_RL_FN VALUES((select REALM_KEY from SAKAI_REALM where RE
INSERT INTO SAKAI_REALM_RL_FN VALUES((select REALM_KEY from SAKAI_REALM where REALM_ID = '!site.roles'), (select ROLE_KEY from SAKAI_REALM_ROLE where ROLE_NAME = '.auth'), (select FUNCTION_KEY from SAKAI_REALM_FUNCTION where FUNCTION_NAME = 'mail.read'));
INSERT INTO SAKAI_REALM_RL_FN VALUES((select REALM_KEY from SAKAI_REALM where REALM_ID = '!site.roles'), (select ROLE_KEY from SAKAI_REALM_ROLE where ROLE_NAME = '.auth'), (select FUNCTION_KEY from SAKAI_REALM_FUNCTION where FUNCTION_NAME = 'rwiki.read'));
INSERT INTO SAKAI_REALM_RL_FN VALUES((select REALM_KEY from SAKAI_REALM where REALM_ID = '!site.roles'), (select ROLE_KEY from SAKAI_REALM_ROLE where ROLE_NAME = '.auth'), (select FUNCTION_KEY from SAKAI_REALM_FUNCTION where FUNCTION_NAME = 'site.visit'));

-- SAK-29432 Add dropDate field to Enrollment
ALTER TABLE CM_ENROLLMENT_T ADD COLUMN DROP_DATE DATE;

0 comments on commit 07091be

Please sign in to comment.