Subversion Repositories WebE

Compare Revisions

Last modification

Regard whitespace Rev 35 → Rev 34

/trunk/src/struts.xml
7,40 → 7,46
 
<!-- User environment -->
<package name="user" namespace="/user" extends="hibernate-default">
<!-- Terms management -->
<action name="listTerms" method="list"
class="ch.ffhs.webE.action.TermAction">
<result name="success">/user/terms.jsp</result>
<!-- Term management -->
<action name="termAdd">
<result>/user/termAddForm.jsp</result>
</action>
<action name="saveTerm" method="save"
 
<action name="termSave" method="save"
class="ch.ffhs.webE.action.TermAction">
<result>/user/terms.jsp</result>
<result name="success">/user/termAdd.jsp</result>
<result name="error">/user/termAddForm.jsp</result>
</action>
<action name="editTerm" method="edit"
 
<action name="termList" method="list"
class="ch.ffhs.webE.action.TermAction">
<result>/user/terms.jsp</result>
<result name="success">/user/termList.jsp</result>
</action>
 
<action name="deleteTerm" method="delete"
class="ch.ffhs.webE.action.TermAction">
<result>/user/terms.jsp</result>
<result name="success" type="redirect">/user/termList</result>
</action>
 
<!-- Relationships management -->
<action name="listRelationships" method="list"
class="ch.ffhs.webE.action.RelationshipAction">
<result name="success">/user/relationships.jsp</result>
<action name="editTerm" method="edit"
class="ch.ffhs.webE.action.TermAction">
<result name="success">/user/termAddForm.jsp</result>
</action>
<action name="saveRelationship" method="save"
 
<action name="relationshipAdd" method="add"
class="ch.ffhs.webE.action.RelationshipAction">
<result>/user/relationships.jsp</result>
<result>/user/relationshipAddForm.jsp</result>
</action>
<action name="editRelationship" method="edit"
 
<action name="relationshipSave" method="save"
class="ch.ffhs.webE.action.RelationshipAction">
<result>/user/relationships.jsp</result>
<result name="success">/user/relationshipAdd.jsp</result>
<result name="error">/user/relationshipAddForm.jsp</result>
</action>
<action name="deleteRelationship" method="delete"
 
<action name="relationshipList" method="list"
class="ch.ffhs.webE.action.RelationshipAction">
<result>/user/relationships.jsp</result>
<result name="success">/user/relationshipList.jsp</result>
</action>
</package>
 
/trunk/src/ch/ffhs/webE/dao/RelationshipDAOImpl.java
37,7 → 37,7
* empty list is returned
*/
@SuppressWarnings("unchecked")
public List<Relationship> getRelationshipList()
public List<Relationship> listRelationships()
{
List<Relationship> relationship = null;
try
/trunk/src/ch/ffhs/webE/domain/Term.java
45,6 → 45,12
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/src/ch/ffhs/webE/action/RelationshipAction.java
49,26 → 49,9
*/
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)
*
80,20 → 63,19
}
 
/**
* DB query for relationship list
* Prepares to add a relationship
*
* @return SUCCESS
* @return
*/
public String list()
public String add()
{
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 relationship
* Executes the DB query to save the user
*
* @return {@link Action#SUCCESS}
*/
106,33 → 88,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")))
{
/* 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;
}
 
this.edit = false;
 
String result = Action.SUCCESS;
if (!this.relationshipDAO.saveOrUpdate(this.relationship))
if (this.relationshipDAO.saveOrUpdate(this.relationship))
{
result = Action.ERROR;
return Action.SUCCESS;
}
 
this.setModifiedRelationship(this.relationship);
this.setRelationship(null);
return Action.ERROR;
}
 
this.list();
 
return result;
/**
* DB query for relationship list
*
* @return SUCCESS
*/
public String list()
{
this.relationshipList = this.relationshipDAO.listRelationships();
return Action.SUCCESS;
}
 
/**
143,22 → 125,38
{
int id = this.getIdParameter();
 
String result = Action.ERROR;
if (id > 0)
{
this.setRelationship(this.relationshipDAO.getRelationshipById(id));
if (this.getRelationship() != null)
this.relationship = this.relationshipDAO.getRelationshipById(id);
if (this.relationship != null)
{
this.edit = true;
result = Action.SUCCESS;
return Action.SUCCESS;
}
}
 
this.list();
return Action.ERROR;
}
 
return result;
/**
* 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;
}
 
/**
* deletes a user, gets the ID from the "id" parameter that was submitted with
* the HTTP request
167,46 → 165,25
*/
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
{
result = Action.ERROR;
return Action.ERROR;
}
 
this.list();
 
return result;
}
 
/**
* Gets the ID Parameter for update / delete requests
*
* @return int from the ID request. If not set or wrong, it gives back -1
/*
* Standard getters and setters
*/
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
*/
274,21 → 251,4
{
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/action/TermAction.java
40,25 → 40,9
*/
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)
*
70,17 → 54,6
}
 
/**
* 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}
87,33 → 60,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")))
{
/* 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;
}
 
this.edit = false;
 
String result = Action.SUCCESS;
if (!this.termDAO.saveOrUpdate(this.term))
if (this.termDAO.saveOrUpdate(this.term))
{
result = Action.ERROR;
return Action.SUCCESS;
}
 
this.savedTerm = this.term;
this.term = null;
return Action.ERROR;
}
 
this.list();
 
return result;
/**
* DB query for term list
*
* @return SUCCESS
*/
public String list()
{
this.termList = this.termDAO.getTerms();
return Action.SUCCESS;
}
 
/**
124,24 → 97,41
{
int id = this.getIdParameter();
 
String result = Action.ERROR;
if (id > 0)
{
this.term = this.termDAO.getTermById(id);
if (this.term != null)
{
this.edit = true;
result = Action.SUCCESS;
this.term.edit = true;
return Action.SUCCESS;
}
}
 
this.list();
return Action.ERROR;
}
 
return result;
/**
* 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;
}
 
/**
* deletes a term, gets the ID from the "id" parameter that was submitted with
* deletes a user, gets the ID from the "id" parameter that was submitted with
* the HTTP request
*
* @return String - either SUCCESS or ERROR constant
152,43 → 142,21
int id = this.getIdParameter();
 
/* Check for malicious ID values */
String result = Action.SUCCESS;
if (id > 0)
{
this.termDAO.deleteTerm(id);
return Action.SUCCESS;
}
else
{
result = Action.ERROR;
return Action.ERROR;
}
 
this.list();
 
return result;
}
 
/**
* Gets the ID Parameter for update / delete requests
*
* @return int from the ID request. If not set or wrong, it gives back -1
/*
* Standard getters and setters
*/
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/WebContent/user/relationships.jsp
File deleted
\ No newline at end of file
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain
\ No newline at end of property
Index: trunk/WebContent/user/terms.jsp
===================================================================
--- trunk/WebContent/user/terms.jsp (revision 35)
+++ trunk/WebContent/user/terms.jsp (nonexistent)
@@ -1,75 +0,0 @@
-<%@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>
\ No newline at end of file
/trunk/WebContent/user/terms.jsp
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain
\ No newline at end of property
Index: trunk/WebContent/user/nav.jsp
===================================================================
--- trunk/WebContent/user/nav.jsp (revision 35)
+++ trunk/WebContent/user/nav.jsp (revision 34)
@@ -1,13 +1,20 @@
<div id="navigation">
<ul>
+ <li>Ontologie
+ <ul>
+ <li><a href="">Ansehen</a></li>
+ </ul></li>
+
<li>Begriffe
<ul>
- <li><a href="listTerms">Anzeigen/Bearbeiten</a></li>
+ <li><a href="termAdd">Hinzuf&uuml;gen</a></li>
+ <li><a href="termList">Anzeigen<!-- &Auml;ndern, L&ouml;schen --></a></li>
</ul></li>
<li>Beziehungen
<ul>
- <li><a href="listRelationships">Anzeigen/Bearbeiten</a></li>
+ <li><a href="relationshipAdd">Hinzuf&uuml;gen</a></li>
+ <li><a href="relationshipList">&Auml;ndern, L&ouml;schen</a></li>
</ul></li>
<li>User-Settings
/trunk/WebContent/user/termAddForm.jsp
0,0 → 1,23
<%@taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<title>Begriff <s:if test="term.name != ''">umbenennen</s:if><s:else>hinzuf&uuml;gen</s:else></title>
</head>
<body>
<h1>
Begriff hinzuf&uuml;gen
</h1>
<s:form action="termSave">
<s:if test="term.edit">
<s:hidden name="edit" value="1" />
</s:if>
<s:hidden name="term.objectId" />
<s:textfield name="term.name" label="Name" />
<s:if test="term.name != ''">
<s:submit value="Umbenennen" />
</s:if><s:else>
<s:submit value="Hinzufügen" />
</s:else>
</s:form>
</body>
</html>
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: trunk/WebContent/user/relationshipAdd.jsp
===================================================================
--- trunk/WebContent/user/relationshipAdd.jsp (nonexistent)
+++ trunk/WebContent/user/relationshipAdd.jsp (revision 34)
@@ -0,0 +1,17 @@
+<html>
+<head>
+<title>Relationship added</title>
+</head>
+<body>
+
+ <h1>
+ Beziehung hinzugef&uuml;gt
+ </h1>
+ <p>
+ Die Beziehung wurde hinzugef&uuml;gt
+ </p>
+ <p>
+ TODO: Weiterleitung!!
+ </p>
+</body>
+</html>
\ No newline at end of file
/trunk/WebContent/user/relationshipAdd.jsp
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: trunk/WebContent/user/relationshipList.jsp
===================================================================
--- trunk/WebContent/user/relationshipList.jsp (nonexistent)
+++ trunk/WebContent/user/relationshipList.jsp (revision 34)
@@ -0,0 +1,47 @@
+<%@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>
+ <title>Beziehung bearbeiten/l&ouml;schen</title>
+ </head>
+ <body>
+
+ <h1>Liste der Beziehungen</h1>
+
+ <s:if test="relationshipList.size() == 0">
+ <p>Keine Beziehung definiert</p>
+ </s:if>
+ <s:else>
+ <table>
+ <thead>
+ <th>Begriff 1</th>
+ <th>Beziehung</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>
\ No newline at end of file
/trunk/WebContent/user/relationshipList.jsp
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: trunk/WebContent/user/relationshipAddForm.jsp
===================================================================
--- trunk/WebContent/user/relationshipAddForm.jsp (nonexistent)
+++ trunk/WebContent/user/relationshipAddForm.jsp (revision 34)
@@ -0,0 +1,18 @@
+<%@taglib uri="/struts-tags" prefix="s"%>
+<html>
+ <head>
+ <title>Beziehung hinzuf&uuml;gen</title>
+ </head>
+ <body>
+ <h1>
+ Beziehung hinzuf&uuml;gen
+ </h1>
+ <s:form action="relationshipSave">
+ <s:hidden name="relationship.objectId" />
+ <s:select name="term1" list="terms" listKey="objectId" listValue="name" label="Begriff 1"/>
+ <s:select name="type" list="relationshipTypes" listKey="id" listValue="nameFrom" label="Beziehungstyp"/>
+ <s:select name="term2" list="terms" listKey="objectId" listValue="name" label="Begriff 2"/>
+ <s:submit value="Hinzufügen" />
+ </s:form>
+ </body>
+</html>
/trunk/WebContent/user/relationshipAddForm.jsp
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: trunk/WebContent/user/termList.jsp
===================================================================
--- trunk/WebContent/user/termList.jsp (nonexistent)
+++ trunk/WebContent/user/termList.jsp (revision 34)
@@ -0,0 +1,27 @@
+<%@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>
+ <title>Begriff bearbeiten/l&ouml;schen</title>
+ </head>
+ <body>
+
+ <h1>Liste der Begriffe</h1>
+
+ <s:if test="termList.size() == 0">
+ <p>Keine Begriffe eingegeben</p>
+ </s:if>
+ <s:else>
+ <table>
+ <s:iterator value="termList" status="stat">
+ <tr>
+ <td><s:property value="name" /></td>
+ </tr>
+ </s:iterator>
+ </tbody>
+ </table>
+ </s:else>
+ </body>
+</html>
\ No newline at end of file
/trunk/WebContent/user/termList.jsp
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: trunk/WebContent/user/termAdd.jsp
===================================================================
--- trunk/WebContent/user/termAdd.jsp (nonexistent)
+++ trunk/WebContent/user/termAdd.jsp (revision 34)
@@ -0,0 +1,17 @@
+<html>
+<head>
+<title>Term added</title>
+</head>
+<body>
+
+ <h1>
+ Begriff hinzugef&uuml;gt
+ </h1>
+ <p>
+ Der Begriff wurde hinzugef&uuml;gt
+ </p>
+ <p>
+ TODO: Weiterleitung!!
+ </p>
+</body>
+</html>
\ No newline at end of file
/trunk/WebContent/user/termAdd.jsp
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property