Permalink
Browse files

Creator is now scraped from SpringSecurity when creating objects. Cre…

…ate and edit actionable works through the UI
  • Loading branch information...
ithunt committed Nov 6, 2011
1 parent 445ab81 commit 4ff7856070155a6f033bfbde6abd6e0692ae1118
@@ -4,13 +4,15 @@
import edu.rit.taskers.model.Actionable;
import edu.rit.taskers.model.Event;
import edu.rit.taskers.persistence.EventDao;
+import edu.rit.taskers.persistence.UserDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
+import java.security.Principal;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -29,6 +31,9 @@
@Autowired
private EventDao eventDao;
+ @Autowired
+ private UserDao userDao;
+
/**
* Fetch all events that belong to session space id
* @return Collection of events
@@ -107,10 +112,12 @@ public ModelAndView getCreateEventPage() {
* Create New Event from js function with form data parameters
*/
@RequestMapping(value="/new", method=RequestMethod.POST)
- public @ResponseBody String createNewEvent(@RequestParam(value="title") String eventName,
+ public @ResponseBody String createNewEvent(Principal principal,
+ @RequestParam(value="title") String eventName,
@RequestParam(value="targetdate") String targetDate,
@RequestParam(value="targettime") String targetTime,
- @RequestParam(value="description") String desc) {
+ @RequestParam(value="description") String desc,
+ @CookieValue("SPACE") int spaceId) {
if ( isEmpty( eventName ) ) {
return "Please specify a title.";
@@ -130,6 +137,9 @@ public ModelAndView getCreateEventPage() {
newEvent.setName( eventName ) ;
newEvent.setTargetDate( dateTimeResult );
newEvent.setDescription( desc );
+ newEvent.setSpaceId( spaceId );
+ newEvent.setCreator( userDao.findByUsername(principal.getName()).getPrimaryContact() );
+
UpdateEventCommand command = new UpdateEventCommand(newEvent, eventDao);
@@ -32,7 +32,10 @@
public String goHome(HttpServletResponse response, Model m, Principal principal) {
String username = principal.getName();
+ principal.getName();
+
Integer lastViewedId = userDao.findByUsername(username).getLastViewedSpace();
+
if (lastViewedId != null) {
response.addCookie(new Cookie("SPACE", lastViewedId + ""));
m.addAttribute("username", username);
@@ -4,13 +4,15 @@
import edu.rit.taskers.model.Actionable;
import edu.rit.taskers.model.Task;
import edu.rit.taskers.persistence.TaskDao;
+import edu.rit.taskers.persistence.UserDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
+import java.security.Principal;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -25,6 +27,9 @@
@Autowired
private TaskDao taskDao;
+ @Autowired
+ private UserDao userDao;
+
private static final Logger logger = LoggerFactory.getLogger(TaskController.class);
/**
@@ -105,10 +110,12 @@ public ModelAndView getCreateTaskPage() {
* Create New Task from js function with form data parameters
*/
@RequestMapping(value="/new", method=RequestMethod.POST)
- public @ResponseBody String createNewTask(@RequestParam(value="title") String taskName,
+ public @ResponseBody String createNewTask(Principal principal,
+ @RequestParam(value="title") String taskName,
@RequestParam(value="targetdate") String targetDate,
@RequestParam(value="priority") String priority,
- @RequestParam(value="description") String desc) {
+ @RequestParam(value="description") String desc,
+ @CookieValue("SPACE") int spaceId) {
try {
DateFormat df = new SimpleDateFormat(Actionable.ACTION_UI_DATEFORMAT);
@@ -124,6 +131,8 @@ public ModelAndView getCreateTaskPage() {
newTask.setTargetDate(df.parse(targetDate));
newTask.setPriority(priority);
newTask.setDescription(desc);
+ newTask.setSpaceId(spaceId);
+ newTask.setCreator( userDao.findByUsername(principal.getName()).getPrimaryContact() );
UpdateTaskCommand command = new UpdateTaskCommand(newTask, taskDao);
@@ -19,7 +19,7 @@
protected int id;
- //TODO space id
+ protected int spaceId;
protected Contact creator;
protected String name;
protected Date created;
@@ -44,6 +44,15 @@ public void setId(int id) {
this.id = id;
}
+ @Column(name = "SpaceID")
+ public int getSpaceId() {
+ return spaceId;
+ }
+
+ public void setSpaceId(int spaceId) {
+ this.spaceId = spaceId;
+ }
+
@Column(name="Name")
public String getName() {
return name;

0 comments on commit 4ff7856

Please sign in to comment.