Permalink
Browse files

flattened submission storage database structure to remove 'info' indi…

…rection
  • Loading branch information...
1 parent 6ff0fbf commit 987ec3d855b10f660076a669874de8e4ff1ad99a @jimdanz jimdanz committed Apr 19, 2012
Showing with 6 additions and 14 deletions.
  1. +6 −14 src/edu/harvard/cs262/grading/MongoSubmissionStorageService.java
@@ -36,18 +36,10 @@ public void storeSubmission(Submission submission) {
BasicDBObject doc = new BasicDBObject();
- doc.put("name", "MongoDB");
- doc.put("type", "database");
- doc.put("count", 1);
-
- BasicDBObject info = new BasicDBObject();
-
- info.put("studentID", submission.getStudent().studentID());
- info.put("assignmentID", submission.getAssignment().assignmentID());
- info.put("timestamp", submission.getTimeStamp());
- info.put("contents", submission.getContents());
-
- doc.put("info", info);
+ doc.put("studentID", submission.getStudent().studentID());
+ doc.put("assignmentID", submission.getAssignment().assignmentID());
+ doc.put("timestamp", submission.getTimeStamp());
+ doc.put("contents", submission.getContents());
coll.insert(doc);
}
@@ -93,15 +85,15 @@ public Submission getSubmission(Student student, Assignment assignment)
throws RemoteException {
BasicDBObject query = new BasicDBObject();
- query.put("assignmentID", assignment);
+ query.put("assignmentID", assignment.assignmentID());
DBCursor results = coll.find(query);
Set<Submission> submissions = new LinkedHashSet<Submission>();
for (DBObject result : results) {
Submission submission = new SubmissionImpl(
- (Student) result.get("studentID"),
+ new StudentImpl((Long) result.get("studentID")),
assignment,
(byte[]) result.get("contents"));
submissions.add(submission);

0 comments on commit 987ec3d

Please sign in to comment.