Subversion Repositories WebE

Compare Revisions

Last modification

Ignore whitespace Rev 33 → Rev 34

/trunk/src/struts.xml
8,11 → 8,11
<!-- User environment -->
<package name="user" namespace="/user" extends="hibernate-default">
<!-- Term management -->
<action name="termAddForm">
<action name="termAdd">
<result>/user/termAddForm.jsp</result>
</action>
 
<action name="doTermAdd" method="add"
<action name="termSave" method="save"
class="ch.ffhs.webE.action.TermAction">
<result name="success">/user/termAdd.jsp</result>
<result name="error">/user/termAddForm.jsp</result>
32,6 → 32,22
class="ch.ffhs.webE.action.TermAction">
<result name="success">/user/termAddForm.jsp</result>
</action>
 
<action name="relationshipAdd" method="add"
class="ch.ffhs.webE.action.RelationshipAction">
<result>/user/relationshipAddForm.jsp</result>
</action>
 
<action name="relationshipSave" method="save"
class="ch.ffhs.webE.action.RelationshipAction">
<result name="success">/user/relationshipAdd.jsp</result>
<result name="error">/user/relationshipAddForm.jsp</result>
</action>
 
<action name="relationshipList" method="list"
class="ch.ffhs.webE.action.RelationshipAction">
<result name="success">/user/relationshipList.jsp</result>
</action>
</package>
 
<!-- Admin environment -->
/trunk/src/ch/ffhs/webE/domain/Relationship.java
12,7 → 12,9
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
 
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
 
21,76 → 23,91
*/
@Entity
@Table(name = "relationship", catalog = "webengineering", uniqueConstraints = @UniqueConstraint(columnNames = {
"term_from", "term_to", "type" }))
public class Relationship implements java.io.Serializable {
"term_from", "term_to", "type_id" }))
public class Relationship implements java.io.Serializable
{
private int objectId;
 
private int objectId;
private Term termByTermTo;
private ObjectEntity object;
private RelationshipType relationshipType;
private Term termByTermFrom;
@Transient
private ObjectEntity object;
 
public Relationship() {
}
private Term termFrom;
private Term termTo;
private RelationshipType relationshipType;
 
public Relationship(Term termByTermTo, ObjectEntity object,
RelationshipType relationshipType, Term termByTermFrom) {
this.termByTermTo = termByTermTo;
this.object = object;
this.relationshipType = relationshipType;
this.termByTermFrom = termByTermFrom;
}
public Relationship()
{
}
 
@GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "object"))
@Id
@GeneratedValue(generator = "generator")
@Column(name = "object_id", unique = true, nullable = false)
public int getObjectId() {
return this.objectId;
}
public Relationship(Term termByTermTo, ObjectEntity object,
RelationshipType relationshipType, Term termByTermFrom)
{
this.termTo = termByTermTo;
this.object = object;
this.relationshipType = relationshipType;
this.termFrom = termByTermFrom;
}
 
public void setObjectId(int objectId) {
this.objectId = objectId;
}
@GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "object"))
@Id
@GeneratedValue(generator = "generator")
@Column(name = "object_id", unique = true, nullable = false)
public int getObjectId()
{
return this.objectId;
}
 
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "term_to", nullable = false)
public Term getTermByTermTo() {
return this.termByTermTo;
}
public void setObjectId(int objectId)
{
this.objectId = objectId;
}
 
public void setTermByTermTo(Term termByTermTo) {
this.termByTermTo = termByTermTo;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "term_to", nullable = false)
public Term getTermTo()
{
return this.termTo;
}
 
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public ObjectEntity getObject() {
return this.object;
}
public void setTermTo(Term termByTermTo)
{
this.termTo = termByTermTo;
}
 
public void setObject(ObjectEntity object) {
this.object = object;
}
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public ObjectEntity getObject()
{
return this.object;
}
 
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "type", nullable = false)
public RelationshipType getRelationshipType() {
return this.relationshipType;
}
public void setObject(ObjectEntity object)
{
this.object = object;
}
 
public void setRelationshipType(RelationshipType relationshipType) {
this.relationshipType = relationshipType;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "type_id", nullable = false)
public RelationshipType getRelationshipType()
{
return this.relationshipType;
}
 
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "term_from", nullable = false)
public Term getTermByTermFrom() {
return this.termByTermFrom;
}
public void setRelationshipType(RelationshipType relationshipType)
{
this.relationshipType = relationshipType;
}
 
public void setTermByTermFrom(Term termByTermFrom) {
this.termByTermFrom = termByTermFrom;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "term_from", nullable = false)
public Term getTermFrom()
{
return this.termFrom;
}
 
public void setTermFrom(Term termByTermFrom)
{
this.termFrom = termByTermFrom;
}
 
}
/trunk/src/ch/ffhs/webE/domain/RelationshipType.java
2,13 → 2,15
 
// Generated 19.12.2010 14:46:08 by Hibernate Tools 3.4.0.Beta1
 
import static javax.persistence.GenerationType.IDENTITY;
 
import java.util.HashSet;
import java.util.Set;
 
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
19,64 → 21,76
*/
@Entity
@Table(name = "relationship_type", catalog = "webengineering", uniqueConstraints = @UniqueConstraint(columnNames = "name_from"))
public class RelationshipType implements java.io.Serializable {
public class RelationshipType implements java.io.Serializable
{
 
private Integer relationshipId;
private String nameFrom;
private String nameTo;
private Set<Relationship> relationships = new HashSet<Relationship>(0);
private Integer id;
private String nameFrom;
private String nameTo;
private Set<Relationship> relationships = new HashSet<Relationship>(0);
 
public RelationshipType() {
}
public RelationshipType()
{
}
 
public RelationshipType(String nameFrom, String nameTo) {
this.nameFrom = nameFrom;
this.nameTo = nameTo;
}
public RelationshipType(String nameFrom, String nameTo)
{
this.nameFrom = nameFrom;
this.nameTo = nameTo;
}
 
public RelationshipType(String nameFrom, String nameTo,
Set<Relationship> relationships) {
this.nameFrom = nameFrom;
this.nameTo = nameTo;
this.relationships = relationships;
}
public RelationshipType(String nameFrom, String nameTo,
Set<Relationship> relationships)
{
this.nameFrom = nameFrom;
this.nameTo = nameTo;
this.relationships = relationships;
}
 
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "relationship_id", unique = true, nullable = false)
public Integer getRelationshipId() {
return this.relationshipId;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId()
{
return this.id;
}
 
public void setRelationshipId(Integer relationshipId) {
this.relationshipId = relationshipId;
}
public void setId(Integer id)
{
this.id = id;
}
 
@Column(name = "name_from", unique = true, nullable = false)
public String getNameFrom() {
return this.nameFrom;
}
@Column(name = "name_from", unique = true, nullable = false)
public String getNameFrom()
{
return this.nameFrom;
}
 
public void setNameFrom(String nameFrom) {
this.nameFrom = nameFrom;
}
public void setNameFrom(String nameFrom)
{
this.nameFrom = nameFrom;
}
 
@Column(name = "name_to", nullable = false)
public String getNameTo() {
return this.nameTo;
}
@Column(name = "name_to", nullable = false)
public String getNameTo()
{
return this.nameTo;
}
 
public void setNameTo(String nameTo) {
this.nameTo = nameTo;
}
public void setNameTo(String nameTo)
{
this.nameTo = nameTo;
}
 
@OneToMany(fetch = FetchType.LAZY, mappedBy = "relationshipType")
public Set<Relationship> getRelationships() {
return this.relationships;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "relationshipType")
public Set<Relationship> getRelationships()
{
return this.relationships;
}
 
public void setRelationships(Set<Relationship> relationships) {
this.relationships = relationships;
}
public void setRelationships(Set<Relationship> relationships)
{
this.relationships = relationships;
}
 
}
/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()
130,7 → 136,7
this.name = name;
}
 
@OneToMany(fetch = FetchType.LAZY, mappedBy = "termByTermTo")
@OneToMany(fetch = FetchType.LAZY, mappedBy = "termTo")
public Set<Relationship> getRelationshipsForTermTo()
{
return this.relationshipsForTermTo;
147,7 → 153,7
/**
* @return
*/
@OneToMany(fetch = FetchType.LAZY, mappedBy = "termByTermFrom")
@OneToMany(fetch = FetchType.LAZY, mappedBy = "termFrom")
public Set<Relationship> getRelationshipsForTermFrom()
{
return this.relationshipsForTermFrom;
/trunk/src/ch/ffhs/webE/domain/ObjectType.java
21,11 → 21,21
public class ObjectType implements java.io.Serializable
{
/**
* Version ID for serialization
*/
private static final long serialVersionUID = 1L;
 
/**
* ObjectEntity type ID for a term
*/
public static final int TERM = 1;
 
private int objectTypeId;
/**
* ObjectEntity type ID for a relationship
*/
public static final int RELATIONSHIP = 2;
 
private int id;
private String name;
private Set<ObjectEntity> objects = new HashSet<ObjectEntity>(0);
 
33,28 → 43,28
{
}
 
public ObjectType(int objectTypeId)
public ObjectType(int id)
{
this.objectTypeId = objectTypeId;
this.id = id;
}
 
public ObjectType(int objectTypeId, String name, Set<ObjectEntity> objects)
public ObjectType(int id, String name, Set<ObjectEntity> objects)
{
this.objectTypeId = objectTypeId;
this.id = id;
this.name = name;
this.objects = objects;
}
 
@Id
@Column(name = "object_type_id", unique = true, nullable = false)
public int getObjectTypeId()
@Column(name = "id", unique = true, nullable = false)
public int getId()
{
return this.objectTypeId;
return this.id;
}
 
public void setObjectTypeId(int objectTypeId)
public void setId(int objectTypeId)
{
this.objectTypeId = objectTypeId;
this.id = objectTypeId;
}
 
@Column(name = "name", unique = true, length = 45)
/trunk/src/ch/ffhs/webE/action/RelationshipAction.java
New file
0,0 → 1,254
package ch.ffhs.webE.action;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import org.apache.struts2.StrutsStatics;
 
import ch.ffhs.webE.dao.RelationshipDAOImpl;
import ch.ffhs.webE.dao.RelationshipTypeDAOImpl;
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.Relationship;
import ch.ffhs.webE.domain.RelationshipType;
import ch.ffhs.webE.domain.Term;
import ch.ffhs.webE.domain.User;
 
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
 
/**
* Implements actions applicable to relationship editing
*
* @author Thomas Lahn
*/
public class RelationshipAction extends ActionSupport implements
ModelDriven<Relationship>
{
private static final long serialVersionUID = 1L;
 
private List<RelationshipType> relationshipTypes = new ArrayList<RelationshipType>();
private final RelationshipTypeDAOImpl relationshipTypeDAO = new RelationshipTypeDAOImpl();
private List<Term> terms = new ArrayList<Term>();
private final TermDAOImpl termDAO = new TermDAOImpl();
private List<Relationship> relationshipList = new ArrayList<Relationship>();
private final RelationshipDAOImpl relationshipDAO = new RelationshipDAOImpl();
private final UserDAOImpl userDAO = new UserDAOImpl();
private Relationship relationship = new Relationship();
 
/**
* Session object
*/
Map<String, Object> session = ActionContext.getContext().getSession();
 
private final HttpServletRequest request = (HttpServletRequest) ActionContext
.getContext().get(StrutsStatics.HTTP_REQUEST);
 
/*
* (non-Javadoc)
*
* @see com.opensymphony.xwork2.ModelDriven#getModel()
*/
public Relationship getModel()
{
return this.relationship;
}
 
/**
* Prepares to add a relationship
*
* @return
*/
public String add()
{
this.setTerms(this.termDAO.getTerms());
this.setRelationshipTypes(this.relationshipTypeDAO.getRelTypes());
return Action.SUCCESS;
}
 
/**
* Executes the DB query to save the user
*
* @return {@link Action#SUCCESS}
*/
public String save()
{
this.relationship.setTermFrom(this.termDAO.getTermById(Integer
.parseInt(this.request.getParameter("term1"))));
this.relationship.setTermTo(this.termDAO.getTermById(Integer
.parseInt(this.request.getParameter("term2"))));
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"));
ObjectEntity obj = new ObjectEntity(user, new ObjectType(
ObjectType.RELATIONSHIP), user, null, new Date(), false, null, null,
this.relationship);
this.relationship.setObject(obj);
}
 
if (this.relationshipDAO.saveOrUpdate(this.relationship))
{
return Action.SUCCESS;
}
 
return Action.ERROR;
}
 
/**
* DB query for relationship list
*
* @return SUCCESS
*/
public String list()
{
this.relationshipList = this.relationshipDAO.listRelationships();
return Action.SUCCESS;
}
 
/**
* @return {@link Action#SUCCESS} if <var>id</var> > 0, {@link Action#ERROR}
* otherwise
*/
public String edit()
{
int id = this.getIdParameter();
 
if (id > 0)
{
this.relationship = this.relationshipDAO.getRelationshipById(id);
if (this.relationship != null)
{
return Action.SUCCESS;
}
}
 
return Action.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()
{
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
*
* @return String - either SUCCESS or ERROR constant
*/
public String delete()
{
 
int id = this.getIdParameter();
 
/* Check for malicious ID values */
if (id > 0)
{
this.relationshipDAO.deleteRelationship(id);
return Action.SUCCESS;
}
else
{
return Action.ERROR;
}
}
 
/*
* Standard getters and setters
*/
 
/**
* @return The relationship edited with this instance
*/
public Relationship getRelationship()
{
return this.relationship;
}
 
/**
* @param relationship
* The relationship edited with this instance
*/
public void setRelationship(Relationship relationship)
{
this.relationship = relationship;
}
 
/**
* @return The list of terms edited with this instance
*/
public List<Relationship> getRelationshipList()
{
return this.relationshipList;
}
 
/**
* @param relationshipList
* The list of terms edited with this instance
*/
public void setRelationshipList(List<Relationship> relationshipList)
{
this.relationshipList = relationshipList;
}
 
/**
* @return the relationshipTypes
*/
public List<RelationshipType> getRelationshipTypes()
{
return this.relationshipTypes;
}
 
/**
* @param relationshipTypes
* the relationshipTypes to set
*/
public void setRelationshipTypes(List<RelationshipType> relationshipTypes)
{
this.relationshipTypes = relationshipTypes;
}
 
/**
* @return the terms
*/
public List<Term> getTerms()
{
return this.terms;
}
 
/**
* @param terms
* the terms to set
*/
public void setTerms(List<Term> terms)
{
this.terms = terms;
}
}
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: src/ch/ffhs/webE/action/RelationshipTypeAction.java
===================================================================
--- src/ch/ffhs/webE/action/RelationshipTypeAction.java (revision 33)
+++ src/ch/ffhs/webE/action/RelationshipTypeAction.java (revision 34)
@@ -5,125 +5,126 @@
import javax.servlet.http.HttpServletRequest;
-import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.StrutsStatics;
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 RelationshipTypeDAO relTypeDAO = new RelationshipTypeDAOImpl();
+ private RelationshipType relType = new RelationshipType();
+ private List<RelationshipType> relTypeList = new ArrayList<RelationshipType>();
+ private final RelationshipTypeDAO relTypeDAO = new RelationshipTypeDAOImpl();
- @Override
- public RelationshipType getModel()
- {
- return relType;
- }
+ @Override
+ public RelationshipType getModel()
+ {
+ return this.relType;
+ }
- public String addOrUpdate()
- {
- relTypeDAO.saveOrUpdateRelType(relType);
- return SUCCESS;
- }
+ public String addOrUpdate()
+ {
+ this.relTypeDAO.saveOrUpdateRelType(this.relType);
+ return Action.SUCCESS;
+ }
- public String list()
+ public String list()
+ {
+ this.relTypeList = this.relTypeDAO.getRelTypes();
+ return Action.SUCCESS;
+ }
+
+ public String edit()
+ {
+ int id = this.getIdParameter();
+
+ if (id > 0)
{
- relTypeList = relTypeDAO.listRelationshipTypes();
- return SUCCESS;
+ this.relType = this.relTypeDAO.getRelTypeById(id);
+ return Action.SUCCESS;
}
-
- public String edit()
+ else
{
- int id = getIdParameter();
-
- if (id > 0)
- {
- relType = relTypeDAO.listRelTypeById(id);
- return SUCCESS;
- }
- else
- {
- return ERROR;
- }
+ return Action.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);
+ }
- int id = -1;
- try
- {
- id = Integer.parseInt(request.getParameter("id"));
- }
- catch (Exception e)
- {
- // TODO: Logging - wrong parameter set
- }
+ /**
+ * 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);
- return id;
+ int id = -1;
+ try
+ {
+ id = Integer.parseInt(request.getParameter("id"));
}
-
- /**
- * deletes a relationshipType, gets the ID from the id parameter that was
- * submitted
- *
- * @return String - either success or error
- */
- public String delete()
+ catch (Exception e)
{
- int id = getIdParameter();
-
- // Check for malicious ID values
- if (id > 0)
- {
- relTypeDAO.deleteRelationshipType(id);
- return SUCCESS;
- }
- else
- {
- return ERROR;
- }
+ // TODO: Logging - wrong parameter set
}
- /*
- * Getters and setters
- */
+ return id;
+ }
- public RelationshipType getRelType()
- {
- return relType;
- }
+ /**
+ * 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 void setRelType(RelationshipType relType)
+ // Check for malicious ID values
+ if (id > 0)
{
- this.relType = relType;
+ this.relTypeDAO.deleteRelationshipType(id);
+ return Action.SUCCESS;
}
-
- public List<RelationshipType> getRelTypeList()
+ else
{
- return relTypeList;
+ return Action.ERROR;
}
+ }
- public void setRelTypeList(List<RelationshipType> relTypeList)
- {
- this.relTypeList = 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;
+ }
}
\ No newline at end of file
/trunk/src/ch/ffhs/webE/action/TermAction.java
40,6 → 40,9
*/
Map<String, Object> session = ActionContext.getContext().getSession();
 
private final HttpServletRequest request = (HttpServletRequest) ActionContext
.getContext().get(StrutsStatics.HTTP_REQUEST);
 
/*
* (non-Javadoc)
*
55,13 → 58,18
*
* @return {@link Action#SUCCESS}
*/
public String add()
public String save()
{
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 (!"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);
}
 
if (this.termDAO.saveOrUpdate(this.term))
{
return Action.SUCCESS;
77,7 → 85,7
*/
public String list()
{
this.termList = this.termDAO.listTerm();
this.termList = this.termDAO.getTerms();
return Action.SUCCESS;
}
 
94,6 → 102,7
this.term = this.termDAO.getTermById(id);
if (this.term != null)
{
this.term.edit = true;
return Action.SUCCESS;
}
}
108,13 → 117,10
*/
private int getIdParameter()
{
HttpServletRequest request = (HttpServletRequest) ActionContext
.getContext().get(StrutsStatics.HTTP_REQUEST);
 
int id = -1;
try
{
id = Integer.parseInt(request.getParameter("id")); //$NON-NLS-1$
id = Integer.parseInt(this.request.getParameter("id")); //$NON-NLS-1$
}
catch (Exception e)
{
/trunk/src/ch/ffhs/webE/dao/RelationshipDAOImpl.java
New file
0,0 → 1,130
package ch.ffhs.webE.dao;
 
import java.util.ArrayList;
import java.util.List;
 
import org.hibernate.Session;
import org.hibernate.Transaction;
 
import ch.ffhs.webE.domain.Relationship;
 
import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget;
import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget;
 
/**
* Implements the Database Access Object for terms
*
* @author Thomas Lahn
*/
public class RelationshipDAOImpl
{
/**
* Database session
*/
@SessionTarget
Session session;
 
/**
* Database transaction
*/
@TransactionTarget
Transaction transaction;
 
/**
* Creates a list of all relationships
*
* @return an ArrayList with all the relationshops - in case of a problem, an
* empty list is returned
*/
@SuppressWarnings("unchecked")
public List<Relationship> listRelationships()
{
List<Relationship> relationship = null;
try
{
relationship = this.session.createQuery("from Relationship").list(); //$NON-NLS-1$
}
catch (Exception e)
{
e.printStackTrace();
}
 
/*
* If no relationship was checked, return an empty list to mitigate null
* pointer exceptions
*/
if (relationship == null)
{
relationship = new ArrayList<Relationship>();
}
 
return relationship;
}
 
/**
* Executes the query to save the relationship
*
* @param relationship
* Domain object to be saved
* @return <code>true</code> if successful, <code>false</code> otherwise
*/
public boolean saveOrUpdate(Relationship relationship)
{
try
{
relationship.setObjectId(relationship.getObjectId());
this.session.saveOrUpdate(relationship);
return true;
}
catch (Exception e)
{
this.transaction.rollback();
e.printStackTrace();
return false;
}
}
 
/**
* Delete a relationship
*
* @param id
* Relationship ID
*/
public void deleteRelationship(int id)
{
try
{
Relationship relationship = (Relationship) this.session.get(
Relationship.class, id);
this.session.delete(relationship);
}
catch (Exception e)
{
this.transaction.rollback();
e.printStackTrace();
}
}
 
/**
* Retrieves a relationship by ID
*
* @param id
* Term ID
* @return The relationship with this <var>id</var>
*/
public Relationship getRelationshipById(int id)
{
Relationship relationship = null;
 
try
{
relationship = (Relationship) this.session.get(Relationship.class, id);
}
catch (Exception e)
{
e.printStackTrace();
}
 
return relationship;
}
}
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: src/ch/ffhs/webE/dao/RelationshipTypeDAO.java
===================================================================
--- src/ch/ffhs/webE/dao/RelationshipTypeDAO.java (revision 33)
+++ src/ch/ffhs/webE/dao/RelationshipTypeDAO.java (revision 34)
@@ -6,11 +6,11 @@
public interface RelationshipTypeDAO {
- List<RelationshipType> listRelationshipTypes();
+ List<RelationshipType> getRelTypes();
boolean deleteRelationshipType(int relTypeID);
- RelationshipType listRelTypeById(int relTypeID);
+ RelationshipType getRelTypeById(int relTypeID);
boolean saveOrUpdateRelType(RelationshipType relType);
}
/trunk/src/ch/ffhs/webE/dao/RelationshipTypeDAOImpl.java
26,7 → 26,7
*/
@SuppressWarnings("unchecked")
@Override
public List<RelationshipType> listRelationshipTypes()
public List<RelationshipType> getRelTypes()
{
 
List<RelationshipType> relType = null;
100,7 → 100,7
* Used to get a relationship type by ID
*/
@Override
public RelationshipType listRelTypeById(int relTypeID)
public RelationshipType getRelTypeById(int relTypeID)
{
RelationshipType relType = null;
try
/trunk/src/ch/ffhs/webE/dao/TermDAO.java
14,7 → 14,7
/**
* @return
*/
List<Term> listTerm();
List<Term> getTerms();
 
/**
* Delete a term
/trunk/src/ch/ffhs/webE/dao/TermDAOImpl.java
31,13 → 31,13
Transaction transaction;
 
/**
* Creates a list of all terms
* Returns a list of all terms
*
* @return an ArrayList with all the users - in case of a problem, an empty
* @return an ArrayList with all the terms - in case of a problem, an empty
* list is returned
*/
@SuppressWarnings("unchecked")
public List<Term> listTerm()
public List<Term> getTerms()
{
List<Term> term = null;
try
/trunk/WebContent/admin/relTypeAddForm.jsp
8,11 → 8,11
<h1>Beziehungstyp hinzuf&uuml;gen</h1>
<p>Bitte geben Sie die Daten f&uuml;r den Beziehungstypen ein</p>
<s:form action="doRelTypeAdd">
<s:hidden name="relType.relationshipId" />
<s:hidden name="relType.id" />
<s:textfield name="relType.nameFrom" label="Name vom Ausgangspunkt (z.B. ist Vater von)" />
<s:textfield name="relType.nameTo" label="Name vom Zielpunkt (z.B. ist Sohn von)" />
<s:if test="relType.relationshipId != ''">
<s:if test="relType.id != ''">
<s:submit value="Edit" />
</s:if><s:else>
<s:submit value="Add" />
/trunk/WebContent/admin/relTypeList.jsp
25,13 → 25,13
<td><s:property value="nameTo" /></td>
<td><s:url id="editURL" action="editRelType">
<s:param name="id" value="%{relationshipId}"></s:param>
<s:param name="id" value="%{id}"></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="deleteRelType">
<s:param name="id" value="%{relationshipId}"></s:param>
<s:param name="id" value="%{id}"></s:param>
</s:url> <s:a href="%{deleteURL}">
<img src="${contextPath}/resources/icons/delete.png" alt="delete" />
</s:a></td>
/trunk/WebContent/user/nav.jsp
7,14 → 7,14
 
<li>Begriffe
<ul>
<li><a href="termAddForm">Hinzuf&uuml;gen</a></li>
<li><a href="termList">&Auml;ndern, L&ouml;schen</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="">Hinzuf&uuml;gen</a></li>
<li><a href="">&Auml;ndern, L&ouml;schen</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
7,7 → 7,11
<h1>
Begriff hinzuf&uuml;gen
</h1>
<s:form action="doTermAdd">
<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" />
/trunk/WebContent/user/userAdd.jsp
New file
0,0 → 1,17
<html>
<head>
<title>User added</title>
</head>
<body>
 
<h1>
User hinzugef&uuml;gt
</h1>
<p>
Der Benutzer wurde hinzugef&uuml;gt
</p>
<p>
TODO: Weiterleitung!!
</p>
</body>
</html>
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: WebContent/user/relationshipAdd.jsp
===================================================================
--- WebContent/user/relationshipAdd.jsp (revision 0)
+++ 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
/WebContent/user/relationshipAdd.jsp
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: WebContent/user/relationshipList.jsp
===================================================================
--- WebContent/user/relationshipList.jsp (revision 0)
+++ 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
/WebContent/user/relationshipList.jsp
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: WebContent/user/relationshipAddForm.jsp
===================================================================
--- WebContent/user/relationshipAddForm.jsp (revision 0)
+++ 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>
/WebContent/user/relationshipAddForm.jsp
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: WebContent/user/termList.jsp
===================================================================
--- WebContent/user/termList.jsp (revision 33)
+++ WebContent/user/termList.jsp (revision 34)
@@ -15,26 +15,12 @@
</s:if>
<s:else>
<table>
- <tr>
- <th>Begriff</th>
- </tr>
- <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="%{id}"></s:param>
- </s:url> <s:a href="%{deleteURL}">
- <img src="${contextPath}/resources/icons/delete.png" alt="delete" />
- </s:a></td>
- </tr>
- </s:iterator>
+ <s:iterator value="termList" status="stat">
+ <tr>
+ <td><s:property value="name" /></td>
+ </tr>
+ </s:iterator>
+ </tbody>
</table>
</s:else>
</body>
Index: docs/rdm.mwb
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream