Subversion Repositories WebE

Compare Revisions

Last modification

Ignore whitespace Rev 34 → Rev 33

/trunk/src/ch/ffhs/webE/action/RelationshipAction.java
File deleted
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain
\ No newline at end of property
Index: TermAction.java
===================================================================
--- TermAction.java (revision 34)
+++ TermAction.java (revision 33)
@@ -40,9 +40,6 @@
*/
Map<String, Object> session = ActionContext.getContext().getSession();
- private final HttpServletRequest request = (HttpServletRequest) ActionContext
- .getContext().get(StrutsStatics.HTTP_REQUEST);
-
/*
* (non-Javadoc)
*
@@ -58,18 +55,13 @@
*
* @return {@link Action#SUCCESS}
*/
- public String save()
+ public String add()
{
- if (!"1".equals(this.request.getParameter("edit")))
- {
- 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);
- }
-
+ 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;
@@ -85,7 +77,7 @@
*/
public String list()
{
- this.termList = this.termDAO.getTerms();
+ this.termList = this.termDAO.listTerm();
return Action.SUCCESS;
}
@@ -102,7 +94,6 @@
this.term = this.termDAO.getTermById(id);
if (this.term != null)
{
- this.term.edit = true;
return Action.SUCCESS;
}
}
@@ -117,10 +108,13 @@
*/
private int getIdParameter()
{
+ HttpServletRequest request = (HttpServletRequest) ActionContext
+ .getContext().get(StrutsStatics.HTTP_REQUEST);
+
int id = -1;
try
{
- id = Integer.parseInt(this.request.getParameter("id")); //$NON-NLS-1$
+ id = Integer.parseInt(request.getParameter("id")); //$NON-NLS-1$
}
catch (Exception e)
{
/trunk/src/ch/ffhs/webE/action/RelationshipTypeAction.java
5,126 → 5,125
 
import javax.servlet.http.HttpServletRequest;
 
import org.apache.struts2.StrutsStatics;
import org.apache.struts2.ServletActionContext;
 
import ch.ffhs.webE.dao.RelationshipTypeDAO;
import ch.ffhs.webE.dao.RelationshipTypeDAOImpl;
import ch.ffhs.webE.domain.RelationshipType;
 
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
 
public class RelationshipTypeAction extends ActionSupport implements
ModelDriven<RelationshipType>
ModelDriven<RelationshipType>
{
 
private static final long serialVersionUID = -3644691864156792139L;
private static final long serialVersionUID = -3644691864156792139L;
 
private RelationshipType relType = new RelationshipType();
private List<RelationshipType> relTypeList = new ArrayList<RelationshipType>();
private final RelationshipTypeDAO relTypeDAO = new RelationshipTypeDAOImpl();
private RelationshipType relType = new RelationshipType();
private List<RelationshipType> relTypeList = new ArrayList<RelationshipType>();
private RelationshipTypeDAO relTypeDAO = new RelationshipTypeDAOImpl();
 
@Override
public RelationshipType getModel()
{
return this.relType;
}
@Override
public RelationshipType getModel()
{
return relType;
}
 
public String addOrUpdate()
{
this.relTypeDAO.saveOrUpdateRelType(this.relType);
return Action.SUCCESS;
}
public String addOrUpdate()
{
relTypeDAO.saveOrUpdateRelType(relType);
return SUCCESS;
}
 
public String list()
{
this.relTypeList = this.relTypeDAO.getRelTypes();
return Action.SUCCESS;
}
 
public String edit()
{
int id = this.getIdParameter();
 
if (id > 0)
public String list()
{
this.relType = this.relTypeDAO.getRelTypeById(id);
return Action.SUCCESS;
relTypeList = relTypeDAO.listRelationshipTypes();
return SUCCESS;
}
else
public String edit()
{
return Action.ERROR;
int id = getIdParameter();
 
if (id > 0)
{
relType = relTypeDAO.listRelTypeById(id);
return SUCCESS;
}
else
{
return ERROR;
}
}
}
/**
* Gets the ID Parameter for update / delete requests
*
* @return int from the ID request. If not set or wrong, it gives back -1
*/
private int getIdParameter()
{
HttpServletRequest request = (HttpServletRequest) ActionContext
.getContext().get(ServletActionContext.HTTP_REQUEST);
 
/**
* Gets the ID Parameter for update / delete requests
*
* @return int from the ID request. If not set or wrong, it gives back -1
*/
private int getIdParameter()
{
HttpServletRequest request = (HttpServletRequest) ActionContext
.getContext().get(StrutsStatics.HTTP_REQUEST);
int id = -1;
try
{
id = Integer.parseInt(request.getParameter("id"));
}
catch (Exception e)
{
// TODO: Logging - wrong parameter set
}
 
int id = -1;
try
{
id = Integer.parseInt(request.getParameter("id"));
return id;
}
catch (Exception e)
 
/**
* deletes a relationshipType, gets the ID from the id parameter that was
* submitted
*
* @return String - either success or error
*/
public String delete()
{
// TODO: Logging - wrong parameter set
int id = getIdParameter();
 
// Check for malicious ID values
if (id > 0)
{
relTypeDAO.deleteRelationshipType(id);
return SUCCESS;
}
else
{
return ERROR;
}
}
 
return id;
}
/*
* Getters and setters
*/
 
/**
* deletes a relationshipType, gets the ID from the id parameter that was
* submitted
*
* @return String - either success or error
*/
public String delete()
{
int id = this.getIdParameter();
public RelationshipType getRelType()
{
return relType;
}
 
// Check for malicious ID values
if (id > 0)
public void setRelType(RelationshipType relType)
{
this.relTypeDAO.deleteRelationshipType(id);
return Action.SUCCESS;
this.relType = relType;
}
else
 
public List<RelationshipType> getRelTypeList()
{
return Action.ERROR;
return relTypeList;
}
}
 
/*
* Getters and setters
*/
 
public RelationshipType getRelType()
{
return this.relType;
}
 
public void setRelType(RelationshipType relType)
{
this.relType = relType;
}
 
public List<RelationshipType> getRelTypeList()
{
return this.relTypeList;
}
 
public void setRelTypeList(List<RelationshipType> relTypeList)
{
this.relTypeList = relTypeList;
}
public void setRelTypeList(List<RelationshipType> relTypeList)
{
this.relTypeList = relTypeList;
}
}