Subversion Repositories WebE

Compare Revisions

Last modification

Ignore whitespace Rev 36 → Rev 37

/trunk/src/ch/ffhs/webE/action/TermAction.java
4,13 → 4,17
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.servlet.http.HttpServletRequest;
 
import org.apache.struts2.StrutsStatics;
 
import ch.ffhs.webE.dao.TermDAOImpl;
import ch.ffhs.webE.dao.UserDAOImpl;
import ch.ffhs.webE.dao.HistoryDAO;
import ch.ffhs.webE.dao.TermDAO;
import ch.ffhs.webE.dao.UserDAO;
import ch.ffhs.webE.domain.ActionType;
import ch.ffhs.webE.domain.History;
import ch.ffhs.webE.domain.ObjectEntity;
import ch.ffhs.webE.domain.ObjectType;
import ch.ffhs.webE.domain.Term;
32,8 → 36,8
 
private Term term = new Term();
private List<Term> termList = new ArrayList<Term>();
private final TermDAOImpl termDAO = new TermDAOImpl();
private final UserDAOImpl userDAO = new UserDAOImpl();
private final TermDAO termDAO = new TermDAO();
private final UserDAO userDAO = new UserDAO();
 
/**
* Session object
59,6 → 63,10
*/
public Term savedTerm;
 
private final HistoryDAO historyDAO = new HistoryDAO();
 
private Set<History> history;
 
/*
* (non-Javadoc)
*
76,7 → 84,7
*/
public String list()
{
this.termList = this.termDAO.getTerms();
this.termList = this.termDAO.getList();
return Action.SUCCESS;
}
 
87,24 → 95,41
*/
public String save()
{
User user = this.userDAO.searchUsername((String) this.session
User user = this.userDAO.getByUsername((String) this.session
.get("username"));
Date now = new Date();
ObjectEntity obj;
 
int action = 0;
if ("false".equals(this.request.getParameter("edit")))
{
/* Add a new term */
ObjectEntity obj = new ObjectEntity(user,
new ObjectType(ObjectType.TERM), user, null, new Date(), false,
this.term, null, null);
obj = new ObjectEntity(user, new ObjectType(ObjectType.TERM), user, null,
now, false, this.term, null, null);
 
this.term.setObject(obj);
this.added = true;
action = ActionType.ADD;
}
else
{
obj = new ObjectEntity();
obj.setId(this.term.getObjectId());
action = ActionType.RENAME;
}
 
this.edit = false;
 
String result = Action.SUCCESS;
if (!this.termDAO.saveOrUpdate(this.term))
if (this.termDAO.saveOrUpdate(this.term))
{
String comment = this.request.getParameter("comment");
 
History historyRecord = new History(user, new ActionType(action), obj,
this.term.getName(), comment, now);
 
this.historyDAO.saveOrUpdate(historyRecord);
}
else
{
result = Action.ERROR;
}
 
127,7 → 152,7
String result = Action.ERROR;
if (id > 0)
{
this.term = this.termDAO.getTermById(id);
this.term = this.termDAO.getById(id);
if (this.term != null)
{
this.edit = true;
155,7 → 180,7
String result = Action.SUCCESS;
if (id > 0)
{
this.termDAO.deleteTerm(id);
this.termDAO.delete(id);
}
else
{
222,4 → 247,21
{
this.termList = termList;
}
 
/**
* @return the histories
*/
public Set<History> getHistories()
{
return this.history;
}
 
/**
* @param histories
* the histories to set
*/
public void setHistories(Set<History> histories)
{
this.history = histories;
}
}