Skip to content

Commit

Permalink
Enable PostBoard again, make its models project-specific
Browse files Browse the repository at this point in the history
  • Loading branch information
fracture91 committed Feb 17, 2013
1 parent 0e90731 commit 61eb13f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Core/WPISuite/src/edu/wpi/cs/wpisuitetng/ManagerLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private ManagerLayer()
map.put("coreuser", new UserManager(data));
map.put("defecttrackerdefect", new DefectManager(data));
map.put("defecttrackercomment", new CommentManager(data));
// map.put("postboardpostboardmessage", new PostBoardEntityManager(data));
map.put("postboardpostboardmessage", new PostBoardEntityManager(data));

//add just your module to this list
String[] fullModuleList = {"core","defecttracker","postboard"};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import edu.wpi.cs.wpisuitetng.exceptions.NotFoundException;
import edu.wpi.cs.wpisuitetng.exceptions.WPISuiteException;
import edu.wpi.cs.wpisuitetng.modules.EntityManager;
import edu.wpi.cs.wpisuitetng.modules.Model;

/**
* This is the entity manager for the PostBoardMessage in the
Expand Down Expand Up @@ -48,7 +49,8 @@ public PostBoardMessage makeEntity(Session s, String content)
final PostBoardMessage newMessage = PostBoardMessage.fromJson(content);

// Save the message in the database if possible, otherwise throw an exception
if (!db.save(newMessage)) {
// We want the message to be associated with the project the user logged in to
if (!db.save(newMessage, s.getProject())) {
throw new WPISuiteException();
}

Expand All @@ -64,13 +66,6 @@ public PostBoardMessage makeEntity(Session s, String content)
@Override
public PostBoardMessage[] getEntity(Session s, String id)
throws NotFoundException, WPISuiteException {

// If no specific id was requested (as is always the case with this module)
// pass the request on to the getAll() method.
if(id == null || id.equals("")) {
return getAll(s);
}

// Throw an exception if an ID was specified, as this module does not support
// retrieving specific PostBoardMessages.
throw new WPISuiteException();
Expand All @@ -85,7 +80,8 @@ public PostBoardMessage[] getEntity(Session s, String id)
public PostBoardMessage[] getAll(Session s) throws WPISuiteException {
// Ask the database to retrieve all objects of the type PostBoardMessage.
// Passing a dummy PostBoardMessage lets the db know what type of object to retrieve
List<PostBoardMessage> messages = db.retrieveAll(new PostBoardMessage(null));
// Passing the project makes it only get messages from that project
List<Model> messages = db.retrieveAll(new PostBoardMessage(null), s.getProject());

// Return the list of messages as an array
return messages.toArray(new PostBoardMessage[0]);
Expand Down

0 comments on commit 61eb13f

Please sign in to comment.