Subversion Repositories WebE

Compare Revisions

Last modification

Ignore whitespace Rev 34 → Rev 35

/trunk/src/struts.xml
7,46 → 7,40
 
<!-- User environment -->
<package name="user" namespace="/user" extends="hibernate-default">
<!-- Term management -->
<action name="termAdd">
<result>/user/termAddForm.jsp</result>
<!-- Terms management -->
<action name="listTerms" method="list"
class="ch.ffhs.webE.action.TermAction">
<result name="success">/user/terms.jsp</result>
</action>
 
<action name="termSave" method="save"
<action name="saveTerm" method="save"
class="ch.ffhs.webE.action.TermAction">
<result name="success">/user/termAdd.jsp</result>
<result name="error">/user/termAddForm.jsp</result>
<result>/user/terms.jsp</result>
</action>
 
<action name="termList" method="list"
<action name="editTerm" method="edit"
class="ch.ffhs.webE.action.TermAction">
<result name="success">/user/termList.jsp</result>
<result>/user/terms.jsp</result>
</action>
 
<action name="deleteTerm" method="delete"
class="ch.ffhs.webE.action.TermAction">
<result name="success" type="redirect">/user/termList</result>
<result>/user/terms.jsp</result>
</action>
 
<action name="editTerm" method="edit"
class="ch.ffhs.webE.action.TermAction">
<result name="success">/user/termAddForm.jsp</result>
<!-- Relationships management -->
<action name="listRelationships" method="list"
class="ch.ffhs.webE.action.RelationshipAction">
<result name="success">/user/relationships.jsp</result>
</action>
 
<action name="relationshipAdd" method="add"
<action name="saveRelationship" method="save"
class="ch.ffhs.webE.action.RelationshipAction">
<result>/user/relationshipAddForm.jsp</result>
<result>/user/relationships.jsp</result>
</action>
 
<action name="relationshipSave" method="save"
<action name="editRelationship" method="edit"
class="ch.ffhs.webE.action.RelationshipAction">
<result name="success">/user/relationshipAdd.jsp</result>
<result name="error">/user/relationshipAddForm.jsp</result>
<result>/user/relationships.jsp</result>
</action>
 
<action name="relationshipList" method="list"
<action name="deleteRelationship" method="delete"
class="ch.ffhs.webE.action.RelationshipAction">
<result name="success">/user/relationshipList.jsp</result>
<result>/user/relationships.jsp</result>
</action>
</package>
 
/trunk/src/ch/ffhs/webE/action/TermAction.java
40,9 → 40,25
*/
Map<String, Object> session = ActionContext.getContext().getSession();
 
/**
* @var <code>true</code> if the term is edited/renamed, <code>false</code>
* otherwise
*/
public boolean edit = false;
 
/**
* @var <code>true</code> if a term was added, <code>false</code> otherwise
*/
public boolean added = false;
 
private final HttpServletRequest request = (HttpServletRequest) ActionContext
.getContext().get(StrutsStatics.HTTP_REQUEST);
 
/**
* The term that was just saved (added, renamed)
*/
public Term savedTerm;
 
/*
* (non-Javadoc)
*
54,6 → 70,17
}
 
/**
* DB query for term list
*
* @return SUCCESS
*/
public String list()
{
this.termList = this.termDAO.getTerms();
return Action.SUCCESS;
}
 
/**
* Executes the DB query to save the user
*
* @return {@link Action#SUCCESS}
60,33 → 87,33
*/
public String save()
{
if (!"1".equals(this.request.getParameter("edit")))
User user = this.userDAO.searchUsername((String) this.session
.get("username"));
 
if ("false".equals(this.request.getParameter("edit")))
{
User user = this.userDAO.searchUsername((String) this.session
.get("username"));
/* Add a new term */
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;
}
 
if (this.termDAO.saveOrUpdate(this.term))
this.edit = false;
 
String result = Action.SUCCESS;
if (!this.termDAO.saveOrUpdate(this.term))
{
return Action.SUCCESS;
result = Action.ERROR;
}
 
return Action.ERROR;
}
this.savedTerm = this.term;
this.term = null;
 
/**
* DB query for term list
*
* @return SUCCESS
*/
public String list()
{
this.termList = this.termDAO.getTerms();
return Action.SUCCESS;
this.list();
 
return result;
}
 
/**
97,41 → 124,24
{
int id = this.getIdParameter();
 
String result = Action.ERROR;
if (id > 0)
{
this.term = this.termDAO.getTermById(id);
if (this.term != null)
{
this.term.edit = true;
return Action.SUCCESS;
this.edit = true;
result = Action.SUCCESS;
}
}
 
return Action.ERROR;
}
this.list();
 
/**
* 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()
{
int id = -1;
try
{
id = Integer.parseInt(this.request.getParameter("id")); //$NON-NLS-1$
}
catch (Exception e)
{
/* TODO: Logging - wrong parameter set */
}
 
return id;
return result;
}
 
/**
* deletes a user, gets the ID from the "id" parameter that was submitted with
* deletes a term, gets the ID from the "id" parameter that was submitted with
* the HTTP request
*
* @return String - either SUCCESS or ERROR constant
142,21 → 152,43
int id = this.getIdParameter();
 
/* Check for malicious ID values */
String result = Action.SUCCESS;
if (id > 0)
{
this.termDAO.deleteTerm(id);
return Action.SUCCESS;
}
else
{
return Action.ERROR;
result = Action.ERROR;
}
 
this.list();
 
return result;
}
 
/*
* Standard getters and setters
/**
* 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()
{
int id = -1;
try
{
id = Integer.parseInt(this.request.getParameter("id")); //$NON-NLS-1$
}
catch (Exception e)
{
/* TODO: Logging - wrong parameter set */
}
 
return id;
}
 
/* Standard getters and setters */
 
/**
* @return The term edited with this instance
*/
/trunk/src/ch/ffhs/webE/action/RelationshipAction.java
49,9 → 49,26
*/
Map<String, Object> session = ActionContext.getContext().getSession();
 
/**
* @var <code>true</code> if the relationship is to be edited/renamed,
* <code>false</code> otherwise
*/
public boolean edit = false;
 
/**
* @var <code>true</code> if a relationship was added, <code>false</code>
* otherwise
*/
public boolean added = false;
 
private final HttpServletRequest request = (HttpServletRequest) ActionContext
.getContext().get(StrutsStatics.HTTP_REQUEST);
 
/**
* The term that was just saved (added, renamed)
*/
private Relationship modifiedRelationship;
 
/*
* (non-Javadoc)
*
63,19 → 80,20
}
 
/**
* Prepares to add a relationship
* DB query for relationship list
*
* @return
* @return SUCCESS
*/
public String add()
public String list()
{
this.setTerms(this.termDAO.getTerms());
this.setRelationshipTypes(this.relationshipTypeDAO.getRelTypes());
this.setRelationshipList(this.relationshipDAO.getRelationshipList());
return Action.SUCCESS;
}
 
/**
* Executes the DB query to save the user
* Executes the DB query to save the relationship
*
* @return {@link Action#SUCCESS}
*/
88,33 → 106,33
this.relationship.setRelationshipType(this.relationshipTypeDAO
.getRelTypeById(Integer.parseInt(this.request.getParameter("type"))));
 
if (!"1".equals(this.request.getParameter("edit")))
User user = this.userDAO.searchUsername((String) this.session
.get("username"));
 
if ("false".equals(this.request.getParameter("edit")))
{
User user = this.userDAO.searchUsername((String) this.session
.get("username"));
/* Add a new relationship */
ObjectEntity obj = new ObjectEntity(user, new ObjectType(
ObjectType.RELATIONSHIP), user, null, new Date(), false, null, null,
this.relationship);
this.relationship.setObject(obj);
this.added = true;
}
 
if (this.relationshipDAO.saveOrUpdate(this.relationship))
this.edit = false;
 
String result = Action.SUCCESS;
if (!this.relationshipDAO.saveOrUpdate(this.relationship))
{
return Action.SUCCESS;
result = Action.ERROR;
}
 
return Action.ERROR;
}
this.setModifiedRelationship(this.relationship);
this.setRelationship(null);
 
/**
* DB query for relationship list
*
* @return SUCCESS
*/
public String list()
{
this.relationshipList = this.relationshipDAO.listRelationships();
return Action.SUCCESS;
this.list();
 
return result;
}
 
/**
125,36 → 143,20
{
int id = this.getIdParameter();
 
String result = Action.ERROR;
if (id > 0)
{
this.relationship = this.relationshipDAO.getRelationshipById(id);
if (this.relationship != null)
this.setRelationship(this.relationshipDAO.getRelationshipById(id));
if (this.getRelationship() != null)
{
return Action.SUCCESS;
this.edit = true;
result = Action.SUCCESS;
}
}
 
return Action.ERROR;
}
this.list();
 
/**
* 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()
{
int id = -1;
try
{
id = Integer.parseInt(this.request.getParameter("id")); //$NON-NLS-1$
}
catch (Exception e)
{
/* TODO: Logging - wrong parameter set */
}
 
return id;
return result;
}
 
/**
165,25 → 167,46
*/
public String delete()
{
 
int id = this.getIdParameter();
 
/* Check for malicious ID values */
String result = Action.SUCCESS;
if (id > 0)
{
this.relationshipDAO.deleteRelationship(id);
return Action.SUCCESS;
}
else
{
return Action.ERROR;
result = Action.ERROR;
}
 
this.list();
 
return result;
}
 
/*
* Standard getters and setters
/**
* 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()
{
int id = -1;
try
{
id = Integer.parseInt(this.request.getParameter("id")); //$NON-NLS-1$
}
catch (Exception e)
{
/* TODO: Logging - wrong parameter set */
}
 
return id;
}
 
/* Standard getters and setters */
 
/**
* @return The relationship edited with this instance
*/
251,4 → 274,21
{
this.terms = terms;
}
 
/**
* @return the modifiedRelationship
*/
public Relationship getModifiedRelationship()
{
return this.modifiedRelationship;
}
 
/**
* @param modifiedRelationship
* the modifiedRelationship to set
*/
public void setModifiedRelationship(Relationship modifiedRelationship)
{
this.modifiedRelationship = modifiedRelationship;
}
}
/trunk/src/ch/ffhs/webE/dao/RelationshipDAOImpl.java
37,7 → 37,7
* empty list is returned
*/
@SuppressWarnings("unchecked")
public List<Relationship> listRelationships()
public List<Relationship> getRelationshipList()
{
List<Relationship> relationship = null;
try
/trunk/src/ch/ffhs/webE/domain/Term.java
45,12 → 45,6
0);
 
/**
* @var <code>true</code> if the term is edited/renamed, <code>false</code>
* otherwise
*/
public boolean edit = false;
 
/**
* No-op constructor
*/
public Term()
/trunk/WebContent/user/relationshipAdd.jsp
File deleted
\ No newline at end of file
/trunk/WebContent/user/relationshipList.jsp
File deleted
\ No newline at end of file
/trunk/WebContent/user/relationshipAddForm.jsp
File deleted
/trunk/WebContent/user/termAdd.jsp
File deleted
\ No newline at end of file
/trunk/WebContent/user/termList.jsp
File deleted
\ No newline at end of file
/trunk/WebContent/user/termAddForm.jsp
File deleted
/trunk/WebContent/user/terms.jsp
New file
0,0 → 1,75
<%@taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}" />
 
<html>
<head>
<s:if test="edit">
<title>Begriff bearbeiten</title>
</s:if>
<s:else>
<title>Begriffe anzeigen/bearbeiten</title>
</s:else>
</head>
<body>
<s:if test="edit">
<h1>Begriff bearbeiten</h1>
</s:if>
<s:else>
<h1>Begriffe anzeigen/bearbeiten</h1>
</s:else>
<s:if test="added">
<p>Der Begriff <b><s:text name="savedTerm.name"/></b> wurde hinzugef&uuml;gt.</p>
</s:if>
<s:if test="edit">
<h2>Dieser Begriff</h2>
</s:if>
<s:else>
<h2>Neuer Begriff</h2>
</s:else>
 
<s:form action="saveTerm">
<s:hidden name="edit" />
<s:hidden name="term.objectId" />
<s:textfield name="term.name" label="Name" />
<s:if test="edit">
<s:submit type="button"><img src="${contextPath}/resources/icons/tick.png" alt="" />
Umbenennen</s:submit>
</s:if>
<s:else>
<s:submit type="button"><img src="${contextPath}/resources/icons/add.png" alt="" />
Hinzuf&uuml;gen
</s:submit>
</s:else>
</s:form>
<s:if test="termList.size() == 0">
<p>Keine Begriffe eingegeben</p>
</s:if>
<s:else>
<h2>Gespeicherte Begriffe</h2>
<table>
<s:iterator value="termList" status="stat">
<tr>
<td><s:property value="name" /></td>
<td><s:url id="editURL" action="editTerm">
<s:param name="id" value="%{objectId}"></s:param>
</s:url> <s:a href="%{editURL}">
<img src="${contextPath}/resources/icons/page_white_edit.png" alt="edit" />
</s:a></td>
<td><s:url id="deleteURL" action="deleteTerm">
<s:param name="id" value="%{objectId}"></s:param>
</s:url> <s:a href="%{deleteURL}">
<img src="${contextPath}/resources/icons/delete.png" alt="delete" />
</s:a></td>
</tr>
</s:iterator>
</tbody>
</table>
</s:else>
</body>
</html>
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: WebContent/user/nav.jsp
===================================================================
--- WebContent/user/nav.jsp (revision 34)
+++ WebContent/user/nav.jsp (revision 35)
@@ -1,20 +1,13 @@
<div id="navigation">
<ul>
- <li>Ontologie
- <ul>
- <li><a href="">Ansehen</a></li>
- </ul></li>
-
<li>Begriffe
<ul>
- <li><a href="termAdd">Hinzuf&uuml;gen</a></li>
- <li><a href="termList">Anzeigen<!-- &Auml;ndern, L&ouml;schen --></a></li>
+ <li><a href="listTerms">Anzeigen/Bearbeiten</a></li>
</ul></li>
<li>Beziehungen
<ul>
- <li><a href="relationshipAdd">Hinzuf&uuml;gen</a></li>
- <li><a href="relationshipList">&Auml;ndern, L&ouml;schen</a></li>
+ <li><a href="listRelationships">Anzeigen/Bearbeiten</a></li>
</ul></li>
<li>User-Settings
/trunk/WebContent/user/relationships.jsp
New file
0,0 → 1,93
<%@taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}" />
 
<html>
<head>
<s:if test="edit">
<title>Beziehung bearbeiten</title>
</s:if>
<s:else>
<title>Beziehungen anzeigen/bearbeiten</title>
</s:else>
</head>
<body>
<s:if test="edit">
<h1>Beziehung bearbeiten</h1>
</s:if>
<s:else>
<h1>Beziehungen anzeigen/bearbeiten</h1>
</s:else>
<s:if test="added">
<p>
Die Beziehung <b>&quot;<s:text name="modifiedRelationship.termFrom.name"/>&quot;
&quot;<s:text name="modifiedRelationship.relationshipType.nameFrom"/>&quot;
&quot;<s:text name="modifiedRelationship.termTo.name"/>&quot;</b>
wurde hinzugef&uuml;gt.
</p>
</s:if>
<s:if test="edit">
<h2>Diese Beziehung</h2>
</s:if>
<s:else>
<h2>Neue Beziehung</h2>
</s:else>
<s:form action="saveRelationship">
<s:hidden name="edit" />
<s:hidden name="relationship.objectId" />
<s:select name="term1" list="terms" listKey="objectId" listValue="name"
label="Begriff 1" value="relationship.termFrom.objectId" />
<s:select name="type" list="relationshipTypes" listKey="id" listValue="nameFrom"
label="Beziehungstyp" value="relationship.relationshipType.id"/>
<s:select name="term2" list="terms" listKey="objectId" listValue="name"
label="Begriff 2" value="relationship.termTo.objectId"/>
<s:if test="edit">
<s:submit type="button"><img src="${contextPath}/resources/icons/tick.png" alt="" />
&Auml;nderungen speichern</s:submit>
</s:if>
<s:else>
<s:submit type="button"><img src="${contextPath}/resources/icons/add.png" alt="" />
Hinzuf&uuml;gen</s:submit>
</s:else>
</s:form>
<h2>Definierte Beziehungen</h2>
<s:if test="relationshipList.size() == 0">
<p>Keine Beziehungen definiert</p>
</s:if>
<s:else>
<table>
<thead>
<th>Begriff 1</th>
<th>Beziehungstyp</th>
<th>Begriff 2</th>
</thead>
<tbody>
<s:iterator value="relationshipList" status="stat">
<tr>
<td><s:property value="termFrom.name" /></td>
<td><s:property value="relationshipType.nameFrom" /></td>
<td><s:property value="termTo.name" /></td>
<td><s:url id="editURL" action="editRelationship">
<s:param name="id" value="%{objectId}"></s:param>
</s:url> <s:a href="%{editURL}">
<img src="${contextPath}/resources/icons/page_white_edit.png" alt="edit" />
</s:a></td>
<td><s:url id="deleteURL" action="deleteRelationship">
<s:param name="id" value="%{objectId}"></s:param>
</s:url> <s:a href="%{deleteURL}">
<img src="${contextPath}/resources/icons/delete.png" alt="delete" />
</s:a></td>
</tr>
</s:iterator>
</tbody>
</table>
</s:else>
</body>
</html>
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property