Subversion Repositories WebE

Compare Revisions

Last modification

Ignore whitespace Rev 37 → Rev 36

/trunk/src/ch/ffhs/webE/action/TermAction.java
4,17 → 4,13
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.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.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;
36,8 → 32,8
 
private Term term = new Term();
private List<Term> termList = new ArrayList<Term>();
private final TermDAO termDAO = new TermDAO();
private final UserDAO userDAO = new UserDAO();
private final TermDAOImpl termDAO = new TermDAOImpl();
private final UserDAOImpl userDAO = new UserDAOImpl();
 
/**
* Session object
63,10 → 59,6
*/
public Term savedTerm;
 
private final HistoryDAO historyDAO = new HistoryDAO();
 
private Set<History> history;
 
/*
* (non-Javadoc)
*
84,7 → 76,7
*/
public String list()
{
this.termList = this.termDAO.getList();
this.termList = this.termDAO.getTerms();
return Action.SUCCESS;
}
 
95,41 → 87,24
*/
public String save()
{
User user = this.userDAO.getByUsername((String) this.session
User user = this.userDAO.searchUsername((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 */
obj = new ObjectEntity(user, new ObjectType(ObjectType.TERM), user, null,
now, false, this.term, null, null);
 
ObjectEntity obj = new ObjectEntity(user,
new ObjectType(ObjectType.TERM), user, null, new Date(), 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;
}
 
152,7 → 127,7
String result = Action.ERROR;
if (id > 0)
{
this.term = this.termDAO.getById(id);
this.term = this.termDAO.getTermById(id);
if (this.term != null)
{
this.edit = true;
180,7 → 155,7
String result = Action.SUCCESS;
if (id > 0)
{
this.termDAO.delete(id);
this.termDAO.deleteTerm(id);
}
else
{
247,21 → 222,4
{
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;
}
}