forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-29405: Entity Providers for Course Management Entities
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
Showing
45 changed files
with
2,175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
10 changes: 10 additions & 0 deletions
10
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/AcademicSessionEntityProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
10 changes: 10 additions & 0 deletions
10
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/CanonicalCourseEntityProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
16 changes: 16 additions & 0 deletions
16
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/CmEntityProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
10 changes: 10 additions & 0 deletions
10
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/CourseOfferingEntityProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
10 changes: 10 additions & 0 deletions
10
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/CourseSetEntityProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
10 changes: 10 additions & 0 deletions
10
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/EnrollmentEntityProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
10 changes: 10 additions & 0 deletions
10
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/EnrollmentSetEntityProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
10 changes: 10 additions & 0 deletions
10
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/MeetingEntityProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
10 changes: 10 additions & 0 deletions
10
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/SectionCategoryEntityProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
10 changes: 10 additions & 0 deletions
10
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/SectionEntityProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
41 changes: 41 additions & 0 deletions
41
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/data/AcademicSessionData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/data/CanonicalCourseData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/data/CmEntityData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
50 changes: 50 additions & 0 deletions
50
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/data/CourseOfferingData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/data/CourseSetData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
cmprovider/api/src/java/org/sakaiproject/cmprovider/api/data/EnrollmentData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.