*/
protected Bug populateBug(Bug bug) {
BugManager bm = new BugManager();
ComponentManager cm = new ComponentManager();
PersonManager pm = new PersonManager();
Bug newBug;
if (bug.getId() == null) {
newBug = new Bug();
newBug.setOpenDate(new Date());
}
else {
newBug = bm.getBug((bug.getId()));
}
// Populate the fields from the bug on the form
newBug.setLongDescription( bug.getLongDescription() );
newBug.setPriority( bug.getPriority());
newBug.setShortDescription( bug.getShortDescription() );
newBug.setDueDate( bug.getDueDate() );
newBug.setPercentComplete( bug.getPercentComplete() );
// If it's a new bug, status isn't mandatory, so default it
if (bug.getStatus() == null) {
newBug.setStatus(Status.New);
}
else {
newBug.setStatus( bug.getStatus() );
}
// Link in the full component and person based on their IDs
newBug.setComponent( cm.getComponent(bug.getComponent().getId()) );
newBug.setOwner( pm.getPerson(bug.getOwner().getId()) );
return newBug;
}