1,15 → 1,20 |
package ch.ffhs.webE.action; |
|
import java.util.ArrayList; |
import java.util.Date; |
import java.util.List; |
import java.util.Map; |
|
import javax.servlet.http.HttpServletRequest; |
|
import org.apache.struts2.StrutsStatics; |
|
import ch.ffhs.webE.dao.TermDAO; |
import ch.ffhs.webE.dao.TermDAOImpl; |
import ch.ffhs.webE.dao.UserDAOImpl; |
import ch.ffhs.webE.domain.ObjectEntity; |
import ch.ffhs.webE.domain.ObjectType; |
import ch.ffhs.webE.domain.Term; |
import ch.ffhs.webE.domain.User; |
|
import com.opensymphony.xwork2.Action; |
import com.opensymphony.xwork2.ActionContext; |
23,12 → 28,18 |
*/ |
public class TermAction extends ActionSupport implements ModelDriven<Term> |
{ |
private static final long serialVersionUID = -6659925652584240539L; |
private static final long serialVersionUID = 1L; |
|
private Term term = new Term(); |
private List<Term> termList = new ArrayList<Term>(); |
private final TermDAO termDAO = new TermDAOImpl(); |
private final TermDAOImpl termDAO = new TermDAOImpl(); |
private final UserDAOImpl userDAO = new UserDAOImpl(); |
|
/** |
* Session object |
*/ |
Map<String, Object> session = ActionContext.getContext().getSession(); |
|
/* |
* (non-Javadoc) |
* |
44,14 → 55,23 |
* |
* @return {@link Action#SUCCESS} |
*/ |
public String addOrUpdate() |
public String add() |
{ |
this.termDAO.saveOrUpdate(this.term); |
return Action.SUCCESS; |
User user = this.userDAO.searchUsername((String) this.session |
.get("username")); |
ObjectEntity obj = new ObjectEntity(user, new ObjectType(ObjectType.TERM), |
user, null, new Date(), false, this.term, null, null); |
this.term.setObject(obj); |
if (this.termDAO.saveOrUpdate(this.term)) |
{ |
return Action.SUCCESS; |
} |
|
return Action.ERROR; |
} |
|
/** |
* DB query for userList |
* DB query for term list |
* |
* @return SUCCESS |
*/ |
71,13 → 91,14 |
|
if (id > 0) |
{ |
this.term = this.termDAO.listTermById(id); |
return Action.SUCCESS; |
this.term = this.termDAO.getTermById(id); |
if (this.term != null) |
{ |
return Action.SUCCESS; |
} |
} |
else |
{ |
return Action.ERROR; |
} |
|
return Action.ERROR; |
} |
|
/** |