Skip to content

Commit

Permalink
SAK-29405: Entity Providers for Course Management Entities
Browse files Browse the repository at this point in the history
Cmprovider provides a RESTful API for updating course management data.
It can be used as an alternative to csv upload or manually adding cm
data to the database. It's built using the entity broker system and can
be accessed at /direct.
  • Loading branch information
Christopher Schauer committed Jun 11, 2015
1 parent 0dee290 commit 2cc935a
Show file tree
Hide file tree
Showing 45 changed files with 2,175 additions and 0 deletions.
43 changes: 43 additions & 0 deletions cmprovider/api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<name>Course Management Provider API</name>
<parent>
<groupId>org.sakaiproject.cmprovider</groupId>
<artifactId>cmprovider-base</artifactId>
<version>11-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>org.sakaiproject.cmprovider</groupId>
<artifactId>cmprovider-api</artifactId>
<packaging>jar</packaging>
<properties>
<deploy.target>shared</deploy.target>
</properties>
<dependencies>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-kernel-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.kernel</groupId>
<artifactId>sakai-component-manager</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.entitybroker</groupId>
<artifactId>entitybroker-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.edu-services.course-management</groupId>
<artifactId>coursemanagement-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.edu-services.course-management</groupId>
<artifactId>coursemanagement-hibernate-impl</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
<build>
<resources/>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sakaiproject.cmprovider.api;

/**
* Entity provider for org.sakaiproject.coursemanagement.api.AcademicSession
*
* @author Christopher Schauer
*/
public interface AcademicSessionEntityProvider {
public final static String ENTITY_PREFIX = "cm-academic-session";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sakaiproject.cmprovider.api;

/**
* Entity provider for org.sakaiproject.coursemanagement.api.CanonicalCourse
*
* @author Christopher Schauer
*/
public interface CanonicalCourseEntityProvider {
public final static String ENTITY_PREFIX = "cm-canonical-course";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.sakaiproject.cmprovider.api;

import org.sakaiproject.entitybroker.entityprovider.capabilities.RESTful;
import org.sakaiproject.coursemanagement.api.exception.IdNotFoundException;

/**
* Interface for course management entity providers.
*
* @author Christopher Schauer
*/
public interface CmEntityProvider extends RESTful {
public Object get(String eid) throws IdNotFoundException;
public void create(Object entity);
public void update(Object entity);
public void delete(String eid);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sakaiproject.cmprovider.api;

/**
* Entity provider for org.sakaiproject.coursemanagement.api.CourseOffering
*
* @author Christopher Schauer
*/
public interface CourseOfferingEntityProvider {
public final static String ENTITY_PREFIX = "cm-course-offering";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sakaiproject.cmprovider.api;

/**
* Entity provider for org.sakaiproject.coursemanagement.api.CourseSet
*
* @author Christopher Schauer
*/
public interface CourseSetEntityProvider {
public final static String ENTITY_PREFIX = "cm-course-set";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sakaiproject.cmprovider.api;

/**
* Entity provider for org.sakaiproject.coursemanagement.api.Enrollment
*
* @author Christopher Schauer
*/
public interface EnrollmentEntityProvider {
public final static String ENTITY_PREFIX = "cm-enrollment";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sakaiproject.cmprovider.api;

/**
* Entity provider for org.sakaiproject.coursemanagement.api.EnrollmentSet
*
* @author Christopher Schauer
*/
public interface EnrollmentSetEntityProvider {
public final static String ENTITY_PREFIX = "cm-enrollment-set";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sakaiproject.cmprovider.api;

/**
* Entity provider for org.sakaiproject.coursemanagement.api.Meeting
*
* @author Christopher Schauer
*/
public interface MeetingEntityProvider {
public final static String ENTITY_PREFIX = "cm-meeting";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sakaiproject.cmprovider.api;

/**
* Entity provider for org.sakaiproject.coursemanagement.api.SectionCategory
*
* @author Christopher Schauer
*/
public interface SectionCategoryEntityProvider {
public final static String ENTITY_PREFIX = "cm-section-category";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sakaiproject.cmprovider.api;

/**
* Entity provider for org.sakaiproject.coursemanagement.api.Section
*
* @author Christopher Schauer
*/
public interface SectionEntityProvider {
public final static String ENTITY_PREFIX = "cm-section";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.sakaiproject.cmprovider.api.data;

import org.sakaiproject.cmprovider.api.data.annotations.After;
import org.sakaiproject.cmprovider.api.data.annotations.NotEmpty;
import org.sakaiproject.cmprovider.api.data.annotations.NotNull;
import org.sakaiproject.cmprovider.api.data.util.DateUtils;
import org.sakaiproject.coursemanagement.api.AcademicSession;

/**
* Represents an academic session.
* @see AcademicSession
*
* Example json:
*
* { "eid": "term1",
* "title": "Test Term",
* "description": "Test term created with cmprovider",
* "endDate": "2015-05-30",
* "startDate": "2015-01-01" }
*
* @author Christopher Schauer
*/
public class AcademicSessionData implements CmEntityData {
@NotEmpty public String eid;
@NotNull public String title = "";
@NotNull public String description = "";
public String startDate;
@After(field="startDate") public String endDate;

public String getId() { return eid; }

public AcademicSessionData() {}

public AcademicSessionData(AcademicSession session) {
eid = session.getEid();
title = session.getTitle();
description = session.getDescription();
startDate = DateUtils.dateToString(session.getStartDate());
endDate = DateUtils.dateToString(session.getEndDate());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.sakaiproject.cmprovider.api.data;

import org.sakaiproject.cmprovider.api.data.annotations.NotEmpty;
import org.sakaiproject.cmprovider.api.data.annotations.NotNull;
import org.sakaiproject.coursemanagement.api.CanonicalCourse;

/**
* Represents a canonical course.
* @see CanonicalCourse
*
* Example json:
*
* { "eid": "CS101",
* "title": "CS101",
* "description": "Introduction to computer science" }
*
* @author Christopher Schauer
*/
public class CanonicalCourseData implements CmEntityData {
@NotEmpty public String eid;
@NotNull public String title = "";
@NotNull public String description = "";

public String getId() { return eid; }

public CanonicalCourseData() {}

public CanonicalCourseData(CanonicalCourse course) {
eid = course.getEid();
title = course.getTitle();
description = course.getDescription();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.sakaiproject.cmprovider.api.data;

/**
* Interface for all course management data.
*
* Data classes are used to convert json to and from classes in org.sakaiproject.coursemanagement.api.
*
* public Object getSampleEntity() should return a class that implements CmEntityData.
*
* @author Christopher Schauer
*/
public interface CmEntityData {
public String getId();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.sakaiproject.cmprovider.api.data;

import org.sakaiproject.cmprovider.api.data.annotations.After;
import org.sakaiproject.cmprovider.api.data.annotations.NotEmpty;
import org.sakaiproject.cmprovider.api.data.annotations.NotNull;
import org.sakaiproject.cmprovider.api.data.util.DateUtils;
import org.sakaiproject.coursemanagement.api.CourseOffering;

/**
* Represents a course offering.
* @see CourseOffering
*
* Example json:
*
* { "eid": "term1.CS101",
* "title": "CS101 Term 1",
* "description": "Introduction to computer science",
* "academicSession": "term1",
* "canonicalCourse": "CS101",
* "status": "nostatus",
* "endDate": "2015-05-30",
* "startDate": "2015-01-01" }
*
* @author Christopher Schauer
*/
public class CourseOfferingData implements CmEntityData {
@NotEmpty public String eid;
@NotNull public String title = "";
@NotNull public String description = "";
@NotEmpty public String academicSession;
@NotEmpty public String canonicalCourse;
public String status;
public String startDate;
@After(field="startDate") public String endDate;

public String getId() { return eid; }

public CourseOfferingData() {}

public CourseOfferingData(CourseOffering course) {
eid = course.getEid();
title = course.getTitle();
description = course.getDescription();
status = course.getStatus();
academicSession = course.getAcademicSession().getEid();
canonicalCourse = course.getCanonicalCourseEid();
startDate = DateUtils.dateToString(course.getStartDate());
endDate = DateUtils.dateToString(course.getEndDate());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.sakaiproject.cmprovider.api.data;

import org.sakaiproject.cmprovider.api.data.annotations.NotEmpty;
import org.sakaiproject.cmprovider.api.data.annotations.NotNull;
import org.sakaiproject.coursemanagement.api.CourseSet;

/**
* Represents a Course Set.
* @see CourseSet
*
* Example json:
* { "eid": "cs",
* "title": "Computer Science",
* "description": "Computer Science",
* "category": "Department of Computer Science"
* }
*
* @author Christopher Schauer
*/
public class CourseSetData implements CmEntityData {

@NotEmpty public String eid;
@NotNull public String title = "";
@NotNull public String description = "";
@NotNull public String category = "";
public String parent;

public String getId() { return eid; }

public CourseSetData() {}

public CourseSetData(CourseSet set) {
eid = set.getEid();
title = set.getTitle();
description = set.getDescription();
category = set.getCategory();

if (set.getParent() != null) parent = set.getParent().getEid();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.sakaiproject.cmprovider.api.data;

import org.sakaiproject.cmprovider.api.data.annotations.NotEmpty;
import org.sakaiproject.cmprovider.api.data.util.DateUtils;
import org.sakaiproject.coursemanagement.api.Enrollment;

/**
* Represents an enrollment.
* @see Enrollment
*
* Example json:
*
* { "userId": "crs142",
* "enrollmentSet": "term1.CS101.1",
* "status": "true",
* "credits": "03:00:00",
* "gradingScheme": "noscheme" }
*
* @author Christopher Schauer
*/
public class EnrollmentData implements CmEntityData {
@NotEmpty public String userId;
@NotEmpty public String enrollmentSet;
@NotEmpty public String status;
@NotEmpty public String credits;
@NotEmpty public String gradingScheme;
public String dropDate;
public boolean dropped = false;

public String getId() { return userId + "," + enrollmentSet; }

public EnrollmentData() {}

public EnrollmentData(Enrollment enrollment, String enrollmentSetEid) {
userId = enrollment.getUserId();
enrollmentSet = enrollmentSetEid;
status = enrollment.getEnrollmentStatus();
credits = enrollment.getCredits();
gradingScheme = enrollment.getGradingScheme();
dropDate = DateUtils.dateToString(enrollment.getDropDate());
dropped = enrollment.isDropped();
}
}
Loading

0 comments on commit 2cc935a

Please sign in to comment.