* LoginAction.java
- Use UserDAOImpl type for better source lookup
* TermAction.ava
- Use obvious serialization version
- Implemented add()
* UserAction.java
- Use more obvious serialization version
* TermDAO.java
- Renamed listTermById() to getTermById()
- Added Javadoc
* TermDAOImpl.java
- Fixed "FROM term" bug (no SQL, case-sensitive)
- saveOrUpdate() now returns boolean (for TermAction)
* Term.java
- Now imports java.io.Serializable
- Added serialization version ID
- Use TermDAOImpl type for better source lookup
* struts.xml
- /doTermAdd now triggers add()
- Added basic Term actions
* user/nav.jsp
- Added /listTerm link to trigger user/termList.jsp
* user/termAddForm.jsp
- Now functional and reusable for Rename Term
* General:
- Clean-up:
+ Renamed Object to ObjectEntity
+ Source formatting
- Added javax.persistence and org.hibernate sources (for Javadoc)
- Added PDF documentation generated from OpenDocument Text| /trunk/src/ch/ffhs/webE/dao/TermDAO.java |
|---|
| 17,6 → 17,12 |
| List<Term> listTerm(); |
| /** |
| * @param termName |
| * @return |
| */ |
| Term searchTerm(String termName); |
| /** |
| * Delete a term |
| * |
| * @param termId |
| 25,12 → 31,10 |
| void deleteTerm(int termId); |
| /** |
| * Retrieves a term by ID |
| * |
| * @param termId |
| * @return |
| */ |
| Term getTermById(int termId); |
| Term listTermById(int termId); |
| /** |
| * Executes the query to save the term |
| 37,7 → 41,6 |
| * |
| * @param term |
| * Domain object to be saved |
| * @return <code>true</code> if successful, <code>false</code> otherwise |
| */ |
| boolean saveOrUpdate(Term term); |
| void saveOrUpdate(Term term); |
| } |
| /trunk/src/ch/ffhs/webE/dao/TermDAOImpl.java |
|---|
| 42,7 → 42,7 |
| List<Term> term = null; |
| try |
| { |
| term = this.session.createQuery("from Term").list(); //$NON-NLS-1$ |
| term = this.session.createQuery("FROM term").list(); //$NON-NLS-1$ |
| } |
| catch (Exception e) |
| { |
| 57,7 → 57,6 |
| { |
| term = new ArrayList<Term>(); |
| } |
| return term; |
| } |
| 66,19 → 65,16 |
| * |
| * @see ch.ffhs.webE.dao.TermDAO#saveOrUpdate(ch.ffhs.webE.domain.Term) |
| */ |
| public boolean saveOrUpdate(Term term) |
| public void saveOrUpdate(Term term) |
| { |
| try |
| { |
| term.setObjectId(term.getObjectId()); |
| this.session.saveOrUpdate(term); |
| return true; |
| } |
| catch (Exception e) |
| { |
| this.transaction.rollback(); |
| e.printStackTrace(); |
| return false; |
| } |
| } |
| 91,8 → 87,8 |
| { |
| try |
| { |
| Term term = (Term) this.session.get(Term.class, termId); |
| this.session.delete(term); |
| Term user = (Term) this.session.get(Term.class, termId); |
| this.session.delete(user); |
| } |
| catch (Exception e) |
| { |
| 101,17 → 97,43 |
| } |
| } |
| /* |
| * (non-Javadoc) |
| /** |
| * Returns a single user with this user name (used for login) |
| * |
| * @see ch.ffhs.webE.dao.TermDAO#getTermById(int) |
| * @param termName |
| * Term name |
| * @return User: Returns a user object if something is found. If not, null is |
| * returned |
| */ |
| public Term getTermById(int termId) |
| public Term searchTerm(String termName) |
| { |
| Term term = null; |
| /* Exec query */ |
| try |
| { |
| term = (Term) this.session |
| .createQuery("FROM User " + "WHERE username = :username") //$NON-NLS-1$ //$NON-NLS-2$ |
| .setParameter("username", termName).uniqueResult(); //$NON-NLS-1$ |
| } |
| catch (Exception e) |
| { |
| /* TODO: Log error */ |
| } |
| return term; |
| } |
| /** |
| * List a term by ID |
| * |
| * @param termId |
| * @return |
| */ |
| public Term listTermById(int termId) |
| { |
| Term term = null; |
| try |
| { |
| term = (Term) this.session.get(Term.class, termId); |
| } |
| catch (Exception e) |
| 118,7 → 140,6 |
| { |
| e.printStackTrace(); |
| } |
| return term; |
| } |
| } |
| /trunk/src/ch/ffhs/webE/dao/UserDAOImpl.java |
|---|
| 6,130 → 6,129 |
| import org.hibernate.Session; |
| import org.hibernate.Transaction; |
| import ch.ffhs.webE.domain.User; |
| import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget; |
| import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget; |
| import ch.ffhs.webE.domain.*; |
| public class UserDAOImpl implements UserDAO |
| { |
| @SessionTarget |
| Session session; |
| @TransactionTarget |
| Transaction transaction; |
| @SessionTarget |
| Session session; |
| @TransactionTarget |
| Transaction transaction; |
| /** |
| * Creates a list of all the registered users |
| * |
| * @return an ArrayList with all the users - in case of a problem, an empty |
| * list is returned |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public List<User> listUser() |
| { |
| List<User> user = null; |
| try |
| /** |
| * Creates a list of all the registered users |
| * |
| * @return an ArrayList with all the users - in case of a problem, an empty |
| * list is returned |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public List<User> listUser() |
| { |
| user = this.session.createQuery("from User").list(); |
| List<User> user = null; |
| try |
| { |
| user = session.createQuery("from User").list(); |
| } |
| catch (Exception e) |
| { |
| e.printStackTrace(); |
| } |
| // If no user was checked, return an empty list to mitigate null pointer |
| // exceptions |
| if (user == null) |
| { |
| user = new ArrayList<User>(); |
| } |
| return user; |
| } |
| catch (Exception e) |
| { |
| e.printStackTrace(); |
| } |
| // If no user was checked, return an empty list to mitigate null pointer |
| // exceptions |
| if (user == null) |
| /** |
| * Executes the query to save the user |
| * |
| * @param User |
| * Domain object to be saved |
| * @return void |
| */ |
| @Override |
| public void saveOrUpdateUser(User user) |
| { |
| user = new ArrayList<User>(); |
| try |
| { |
| session.saveOrUpdate(user); |
| } |
| catch (Exception e) |
| { |
| transaction.rollback(); |
| e.printStackTrace(); |
| } |
| } |
| return user; |
| } |
| /** |
| * Executes the query to save the user |
| * |
| * @param User |
| * Domain object to be saved |
| * @return void |
| */ |
| @Override |
| public void saveOrUpdateUser(User user) |
| { |
| try |
| /** |
| * Used to delete a user. |
| * |
| * @param int userId |
| */ |
| @Override |
| public void deleteUser(int userId) |
| { |
| this.session.saveOrUpdate(user); |
| try |
| { |
| User user = (User) session.get(User.class, userId); |
| session.delete(user); |
| } |
| catch (Exception e) |
| { |
| transaction.rollback(); |
| e.printStackTrace(); |
| } |
| } |
| catch (Exception e) |
| { |
| this.transaction.rollback(); |
| e.printStackTrace(); |
| } |
| } |
| /** |
| * Used to delete a user. |
| * |
| * @param int userId |
| */ |
| @Override |
| public void deleteUser(int userId) |
| { |
| try |
| /** |
| * Returns a single user with this user name (used for login) |
| * |
| * @param username |
| * : String - entire user name |
| * @return User: Returns a user object if something is found. If not, null |
| * is returned |
| */ |
| public User searchUsername(String username) |
| { |
| User user = (User) this.session.get(User.class, userId); |
| this.session.delete(user); |
| } |
| catch (Exception e) |
| { |
| this.transaction.rollback(); |
| e.printStackTrace(); |
| } |
| } |
| User user = null; |
| /** |
| * Returns a single user with this user name (used for login) |
| * |
| * @param username |
| * : String - entire user name |
| * @return User: Returns a user object if something is found. If not, null is |
| * returned |
| */ |
| public User searchUsername(String username) |
| { |
| User user = null; |
| // Exec query |
| try |
| { |
| user = (User) this.session |
| .createQuery("FROM User " + "WHERE username = :username") |
| .setParameter("username", username).uniqueResult(); |
| // Exec query |
| try |
| { |
| user = (User) session |
| .createQuery("FROM User " + "WHERE username = :username") |
| .setParameter("username", username).uniqueResult(); |
| } |
| catch (Exception e) |
| { |
| // TODO: Log error |
| } |
| return user; |
| } |
| catch (Exception e) |
| { |
| // TODO: Log error |
| } |
| return user; |
| } |
| /** |
| * Used to list a single user by Id. |
| */ |
| @Override |
| public User listUserById(int userId) |
| { |
| User user = null; |
| try |
| /** |
| * Used to list a single user by Id. |
| */ |
| @Override |
| public User listUserById(int userId) |
| { |
| user = (User) this.session.get(User.class, userId); |
| User user = null; |
| try |
| { |
| user = (User) session.get(User.class, userId); |
| } |
| catch (Exception e) |
| { |
| e.printStackTrace(); |
| } |
| return user; |
| } |
| catch (Exception e) |
| { |
| e.printStackTrace(); |
| } |
| return user; |
| } |
| } |
| /trunk/src/ch/ffhs/webE/action/TermAction.java |
|---|
| 1,20 → 1,15 |
| 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.TermDAO; |
| 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; |
| import ch.ffhs.webE.domain.User; |
| import com.opensymphony.xwork2.Action; |
| import com.opensymphony.xwork2.ActionContext; |
| 28,18 → 23,12 |
| */ |
| public class TermAction extends ActionSupport implements ModelDriven<Term> |
| { |
| private static final long serialVersionUID = 1L; |
| private static final long serialVersionUID = -6659925652584240539L; |
| private Term term = new Term(); |
| private List<Term> termList = new ArrayList<Term>(); |
| private final TermDAOImpl termDAO = new TermDAOImpl(); |
| private final UserDAOImpl userDAO = new UserDAOImpl(); |
| private final TermDAO termDAO = new TermDAOImpl(); |
| /** |
| * Session object |
| */ |
| Map<String, Object> session = ActionContext.getContext().getSession(); |
| /* |
| * (non-Javadoc) |
| * |
| 55,23 → 44,14 |
| * |
| * @return {@link Action#SUCCESS} |
| */ |
| public String add() |
| public String addOrUpdate() |
| { |
| 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; |
| } |
| return Action.ERROR; |
| this.termDAO.saveOrUpdate(this.term); |
| return Action.SUCCESS; |
| } |
| /** |
| * DB query for term list |
| * DB query for userList |
| * |
| * @return SUCCESS |
| */ |
| 91,14 → 71,13 |
| if (id > 0) |
| { |
| this.term = this.termDAO.getTermById(id); |
| if (this.term != null) |
| { |
| return Action.SUCCESS; |
| } |
| this.term = this.termDAO.listTermById(id); |
| return Action.SUCCESS; |
| } |
| return Action.ERROR; |
| else |
| { |
| return Action.ERROR; |
| } |
| } |
| /** |
| /trunk/src/ch/ffhs/webE/action/LoginAction.java |
|---|
| 2,10 → 2,10 |
| import java.util.Map; |
| import ch.ffhs.webE.dao.UserDAO; |
| import ch.ffhs.webE.dao.UserDAOImpl; |
| 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; |
| 13,125 → 13,115 |
| public class LoginAction extends ActionSupport implements ModelDriven<User> |
| { |
| private static final long serialVersionUID = 1799753056277211344L; |
| private final User user = new User(); |
| private final UserDAOImpl userDAO = new UserDAOImpl(); |
| private static final long serialVersionUID = 1799753056277211344L; |
| private User user = new User(); |
| private UserDAO userDAO = new UserDAOImpl(); |
| /* Form fields */ |
| private String userName; |
| private String pw; |
| // Form fields |
| private String userName; |
| private String pw; |
| /** |
| * JSP session object |
| */ |
| Map<String, Object> session = ActionContext.getContext().getSession(); |
| // Session Object |
| Map<String, Object> session = ActionContext.getContext().getSession(); |
| /** |
| * |
| */ |
| public LoginAction() |
| { |
| } |
| public LoginAction() |
| { |
| } |
| public String doLogin() |
| { |
| public String doLogin() |
| { |
| // If password or user name are empty, the login fails. |
| if ("".equals(this.getUserName()) || "".equals(this.getPw()) |
| || this.getUserName() == null || this.getPw() == null) |
| { |
| this.addFieldError("userName", "Falscher Username oder Passwort"); |
| return Action.ERROR; |
| // If password or user name are empty, the login fails. |
| if ("".equals(getUserName()) || "".equals(getPw()) |
| || getUserName() == null || getPw() == null) |
| { |
| addFieldError("userName", "Falscher Username oder Passwort"); |
| return ERROR; |
| } |
| String verifiedUser = verifyUser(getUserName(), getPw()); |
| if (verifiedUser.equals("failed")) |
| { |
| addFieldError("userName", "Falscher Username oder Passwort"); |
| return ERROR; |
| } |
| else |
| { |
| // Put user name, password into session |
| session.put("username", getUserName()); |
| session.put("pw", getPw()); |
| return verifiedUser; |
| } |
| } |
| String verifiedUser = this.verifyUser(this.getUserName(), this.getPw()); |
| if (verifiedUser.equals("failed")) |
| /** |
| * Logout ausführen. Zerstört die Daten in der Session |
| * @return String |
| */ |
| public String doLogout() |
| { |
| this.addFieldError("userName", "Falscher Username oder Passwort"); |
| return Action.ERROR; |
| //Kill Session content |
| ActionContext.getContext().getSession().clear(); |
| return SUCCESS; |
| } |
| else |
| /** |
| * Verify user credentials |
| * |
| * @param String |
| * username: User name |
| * @param String |
| * password: Password (hashed) |
| * @return |
| */ |
| public String verifyUser(String username, String password) |
| { |
| // DB Query |
| User u = userDAO.searchUsername(username); |
| // Put user name, password into session |
| this.session.put("username", this.getUserName()); |
| this.session.put("pw", this.getPw()); |
| return verifiedUser; |
| } |
| } |
| // User does not exist |
| if (u == null) |
| return ERROR; |
| /** |
| * Logout ausf�hren. Zerst�rt die Daten in der Session |
| * |
| * @return String |
| */ |
| public String doLogout() |
| { |
| // Kill Session content |
| ActionContext.getContext().getSession().clear(); |
| return Action.SUCCESS; |
| } |
| // User password does not match |
| if (!u.getPassword().equals(password)) |
| return ERROR; |
| /** |
| * Verify user credentials |
| * |
| * @param String |
| * username: User name |
| * @param String |
| * password: Password (hashed) |
| * @return |
| */ |
| public String verifyUser(String username, String password) |
| { |
| // DB Query |
| User u = this.userDAO.searchUsername(username); |
| // User credentials are fine, check for admin rights |
| if (u.isAdmin()) |
| { |
| return "admin"; |
| } |
| else |
| { |
| return "user"; |
| } |
| } |
| // User does not exist |
| if (u == null) |
| public String getUserName() |
| { |
| return Action.ERROR; |
| return userName; |
| } |
| // User password does not match |
| if (!u.getPassword().equals(password)) |
| public void setUserName(String userName) |
| { |
| return Action.ERROR; |
| this.userName = userName; |
| } |
| // User credentials are fine, check for admin rights |
| if (u.isAdmin()) |
| public String getPw() |
| { |
| return "admin"; |
| return pw; |
| } |
| else |
| public void setPw(String pw) |
| { |
| return "user"; |
| this.pw = pw; |
| } |
| } |
| public String getUserName() |
| { |
| return this.userName; |
| } |
| public void setUserName(String userName) |
| { |
| this.userName = userName; |
| } |
| public String getPw() |
| { |
| return this.pw; |
| } |
| public void setPw(String pw) |
| { |
| this.pw = pw; |
| } |
| @Override |
| public User getModel() |
| { |
| return this.user; |
| } |
| @Override |
| public User getModel() |
| { |
| return user; |
| } |
| } |
| /trunk/src/ch/ffhs/webE/action/UserAction.java |
|---|
| 5,135 → 5,135 |
| import javax.servlet.http.HttpServletRequest; |
| import org.apache.struts2.StrutsStatics; |
| import org.apache.struts2.ServletActionContext; |
| import ch.ffhs.webE.dao.UserDAOImpl; |
| 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; |
| import ch.ffhs.webE.dao.UserDAO; |
| import ch.ffhs.webE.dao.UserDAOImpl; |
| import ch.ffhs.webE.domain.User; |
| public class UserAction extends ActionSupport implements ModelDriven<User> |
| { |
| private static final long serialVersionUID = 1L; |
| private static final long serialVersionUID = -6659925652584240539L; |
| private User user = new User(); |
| private List<User> userList = new ArrayList<User>(); |
| private final UserDAOImpl userDAO = new UserDAOImpl(); |
| private User user = new User(); |
| private List<User> userList = new ArrayList<User>(); |
| private UserDAO userDAO = new UserDAOImpl(); |
| @Override |
| public User getModel() |
| { |
| return this.user; |
| } |
| @Override |
| public User getModel() |
| { |
| return user; |
| } |
| /** |
| * Executes the DB query to save the user |
| * |
| * @return |
| */ |
| public String addOrUpdate() |
| { |
| this.userDAO.saveOrUpdateUser(this.user); |
| return Action.SUCCESS; |
| } |
| /** |
| * DB query for userList |
| * |
| * @return SUCCESS |
| */ |
| public String list() |
| { |
| this.userList = this.userDAO.listUser(); |
| return Action.SUCCESS; |
| } |
| public String edit() |
| { |
| int id = this.getIdParameter(); |
| if (id > 0) |
| /** |
| * Executes the DB query to save the user |
| * |
| * @return |
| */ |
| public String addOrUpdate() |
| { |
| this.user = this.userDAO.listUserById(id); |
| return Action.SUCCESS; |
| userDAO.saveOrUpdateUser(user); |
| return SUCCESS; |
| } |
| else |
| /** |
| * DB query for userList |
| * |
| * @return SUCCESS |
| */ |
| public String list() |
| { |
| return Action.ERROR; |
| userList = userDAO.listUser(); |
| return SUCCESS; |
| } |
| } |
| /** |
| * 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); |
| public String edit() |
| { |
| int id = getIdParameter(); |
| int id = -1; |
| try |
| { |
| id = Integer.parseInt(request.getParameter("id")); |
| if (id > 0) |
| { |
| user = userDAO.listUserById(id); |
| return SUCCESS; |
| } |
| else |
| { |
| return ERROR; |
| } |
| } |
| catch (Exception e) |
| /** |
| * 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() |
| { |
| // TODO: Logging - wrong parameter set |
| 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 |
| } |
| return id; |
| } |
| 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() |
| { |
| /** |
| * 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 = getIdParameter(); |
| int id = this.getIdParameter(); |
| // Check for malicious ID values |
| if (id > 0) |
| { |
| userDAO.deleteUser(id); |
| return SUCCESS; |
| } |
| else |
| { |
| return ERROR; |
| } |
| } |
| // Check for malicious ID values |
| if (id > 0) |
| /* |
| * Standard getters and setters |
| */ |
| public User getUser() |
| { |
| this.userDAO.deleteUser(id); |
| return Action.SUCCESS; |
| return user; |
| } |
| else |
| public void setUser(User user) |
| { |
| return Action.ERROR; |
| this.user = user; |
| } |
| } |
| /* |
| * Standard getters and setters |
| */ |
| public List<User> getUserList() |
| { |
| return userList; |
| } |
| public User getUser() |
| { |
| return this.user; |
| } |
| public void setUser(User user) |
| { |
| this.user = user; |
| } |
| public List<User> getUserList() |
| { |
| return this.userList; |
| } |
| public void setUserList(List<User> userList) |
| { |
| this.userList = userList; |
| } |
| public void setUserList(List<User> userList) |
| { |
| this.userList = userList; |
| } |
| } |
| /trunk/src/ch/ffhs/webE/domain/ObjectEntity.java |
|---|
| File deleted |
| Property changes: |
| Deleted: svn:mime-type |
| ## -1 +0,0 ## |
| -text/plain |
| \ No newline at end of property |
| Index: ffhs/webE/domain/History.java |
| =================================================================== |
| --- ffhs/webE/domain/History.java (revision 33) |
| +++ ffhs/webE/domain/History.java (revision 32) |
| @@ -25,7 +25,7 @@ |
| private Integer id; |
| private User user; |
| private ActionType actionType; |
| - private ObjectEntity object; |
| + private Object object; |
| private String value; |
| private String comment; |
| private Date date; |
| @@ -33,7 +33,7 @@ |
| public History() { |
| } |
| - public History(User user, ActionType actionType, ObjectEntity object, Date date) { |
| + public History(User user, ActionType actionType, Object object, Date date) { |
| this.user = user; |
| this.actionType = actionType; |
| this.object = object; |
| @@ -40,7 +40,7 @@ |
| this.date = date; |
| } |
| - public History(User user, ActionType actionType, ObjectEntity object, |
| + public History(User user, ActionType actionType, Object object, |
| String value, String comment, Date date) { |
| this.user = user; |
| this.actionType = actionType; |
| @@ -83,11 +83,11 @@ |
| @ManyToOne(fetch = FetchType.LAZY) |
| @JoinColumn(name = "objects_id", nullable = false) |
| - public ObjectEntity getObject() { |
| + public Object getObject() { |
| return this.object; |
| } |
| - public void setObject(ObjectEntity object) { |
| + public void setObject(Object object) { |
| this.object = object; |
| } |
| /trunk/src/ch/ffhs/webE/domain/Relationship.java |
|---|
| 26,7 → 26,7 |
| private int objectId; |
| private Term termByTermTo; |
| private ObjectEntity object; |
| private Object object; |
| private RelationshipType relationshipType; |
| private Term termByTermFrom; |
| 33,7 → 33,7 |
| public Relationship() { |
| } |
| public Relationship(Term termByTermTo, ObjectEntity object, |
| public Relationship(Term termByTermTo, Object object, |
| RelationshipType relationshipType, Term termByTermFrom) { |
| this.termByTermTo = termByTermTo; |
| this.object = object; |
| 65,11 → 65,11 |
| @OneToOne(fetch = FetchType.LAZY) |
| @PrimaryKeyJoinColumn |
| public ObjectEntity getObject() { |
| public Object getObject() { |
| return this.object; |
| } |
| public void setObject(ObjectEntity object) { |
| public void setObject(Object object) { |
| this.object = object; |
| } |
| /trunk/src/ch/ffhs/webE/domain/Object.java |
|---|
| 0,0 → 1,160 |
| package ch.ffhs.webE.domain; |
| // Generated 19.12.2010 14:46:08 by Hibernate Tools 3.4.0.Beta1 |
| import java.util.Date; |
| 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.JoinColumn; |
| import javax.persistence.ManyToOne; |
| import javax.persistence.OneToMany; |
| import javax.persistence.OneToOne; |
| import javax.persistence.Table; |
| import javax.persistence.Temporal; |
| import javax.persistence.TemporalType; |
| /** |
| * Object generated by hbm2java |
| */ |
| @Entity |
| @Table(name = "object", catalog = "webengineering") |
| public class Object implements java.io.Serializable { |
| private Integer id; |
| private User userByEditorId; |
| private ObjectType objectType; |
| private User userByOwnerId; |
| private Date locked; |
| private Date modified; |
| private Boolean deleted; |
| private Term term; |
| private Set<History> histories = new HashSet<History>(0); |
| private Relationship relationship; |
| public Object() { |
| } |
| public Object(User userByEditorId, ObjectType objectType, User userByOwnerId) { |
| this.userByEditorId = userByEditorId; |
| this.objectType = objectType; |
| this.userByOwnerId = userByOwnerId; |
| } |
| public Object(User userByEditorId, ObjectType objectType, |
| User userByOwnerId, Date locked, Date modified, Boolean deleted, |
| Term term, Set<History> histories, Relationship relationship) { |
| this.userByEditorId = userByEditorId; |
| this.objectType = objectType; |
| this.userByOwnerId = userByOwnerId; |
| this.locked = locked; |
| this.modified = modified; |
| this.deleted = deleted; |
| this.term = term; |
| this.histories = histories; |
| this.relationship = relationship; |
| } |
| @Id |
| @GeneratedValue(strategy = IDENTITY) |
| @Column(name = "id", unique = true, nullable = false) |
| public Integer getId() { |
| return this.id; |
| } |
| public void setId(Integer id) { |
| this.id = id; |
| } |
| @ManyToOne(fetch = FetchType.LAZY) |
| @JoinColumn(name = "editor_id", nullable = false) |
| public User getUserByEditorId() { |
| return this.userByEditorId; |
| } |
| public void setUserByEditorId(User userByEditorId) { |
| this.userByEditorId = userByEditorId; |
| } |
| @ManyToOne(fetch = FetchType.LAZY) |
| @JoinColumn(name = "object_type_id", nullable = false) |
| public ObjectType getObjectType() { |
| return this.objectType; |
| } |
| public void setObjectType(ObjectType objectType) { |
| this.objectType = objectType; |
| } |
| @ManyToOne(fetch = FetchType.LAZY) |
| @JoinColumn(name = "owner_id", nullable = false) |
| public User getUserByOwnerId() { |
| return this.userByOwnerId; |
| } |
| public void setUserByOwnerId(User userByOwnerId) { |
| this.userByOwnerId = userByOwnerId; |
| } |
| @Temporal(TemporalType.TIMESTAMP) |
| @Column(name = "locked", length = 19) |
| public Date getLocked() { |
| return this.locked; |
| } |
| public void setLocked(Date locked) { |
| this.locked = locked; |
| } |
| @Temporal(TemporalType.TIMESTAMP) |
| @Column(name = "modified", length = 19) |
| public Date getModified() { |
| return this.modified; |
| } |
| public void setModified(Date modified) { |
| this.modified = modified; |
| } |
| @Column(name = "deleted") |
| public Boolean getDeleted() { |
| return this.deleted; |
| } |
| public void setDeleted(Boolean deleted) { |
| this.deleted = deleted; |
| } |
| @OneToOne(fetch = FetchType.LAZY, mappedBy = "object") |
| public Term getTerm() { |
| return this.term; |
| } |
| public void setTerm(Term term) { |
| this.term = term; |
| } |
| @OneToMany(fetch = FetchType.LAZY, mappedBy = "object") |
| public Set<History> getHistories() { |
| return this.histories; |
| } |
| public void setHistories(Set<History> histories) { |
| this.histories = histories; |
| } |
| @OneToOne(fetch = FetchType.LAZY, mappedBy = "object") |
| public Relationship getRelationship() { |
| return this.relationship; |
| } |
| public void setRelationship(Relationship relationship) { |
| this.relationship = relationship; |
| } |
| } |
| Property changes: |
| Added: svn:mime-type |
| ## -0,0 +1 ## |
| +text/plain |
| \ No newline at end of property |
| Index: ffhs/webE/domain/Term.java |
| =================================================================== |
| --- ffhs/webE/domain/Term.java (revision 33) |
| +++ ffhs/webE/domain/Term.java (revision 32) |
| @@ -2,11 +2,8 @@ |
| // Generated 19.12.2010 14:46:08 by Hibernate Tools 3.4.0.Beta1 |
| -import java.io.Serializable; |
| import java.util.HashSet; |
| import java.util.Set; |
| - |
| -import javax.persistence.CascadeType; |
| import javax.persistence.Column; |
| import javax.persistence.Entity; |
| import javax.persistence.FetchType; |
| @@ -16,9 +13,7 @@ |
| 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; |
| @@ -27,139 +22,81 @@ |
| */ |
| @Entity |
| @Table(name = "term", catalog = "webengineering", uniqueConstraints = @UniqueConstraint(columnNames = "name")) |
| -public class Term implements Serializable |
| -{ |
| - /** |
| - * Version ID for serialization |
| - */ |
| - private static final long serialVersionUID = 1L; |
| +public class Term implements java.io.Serializable { |
| - @Transient |
| - private int objectId; |
| + private int objectId; |
| + private Object object; |
| + private String name; |
| + private Set<Relationship> relationshipsForTermTo = new HashSet<Relationship>( |
| + 0); |
| + private Set<Relationship> relationshipsForTermFrom = new HashSet<Relationship>( |
| + 0); |
| - private ObjectEntity object; |
| - private String name; |
| - private Set<Relationship> relationshipsForTermTo = new HashSet<Relationship>( |
| - 0); |
| - private Set<Relationship> relationshipsForTermFrom = new HashSet<Relationship>( |
| - 0); |
| + public Term() { |
| + } |
| - /** |
| - * No-op constructor |
| - */ |
| - public Term() |
| - { |
| - } |
| + public Term(Object object) { |
| + this.object = object; |
| + } |
| - /** |
| - * @param object |
| - */ |
| - public Term(ObjectEntity object) |
| - { |
| - this.object = object; |
| - } |
| + public Term(Object object, String name, |
| + Set<Relationship> relationshipsForTermTo, |
| + Set<Relationship> relationshipsForTermFrom) { |
| + this.object = object; |
| + this.name = name; |
| + this.relationshipsForTermTo = relationshipsForTermTo; |
| + this.relationshipsForTermFrom = relationshipsForTermFrom; |
| + } |
| - /** |
| - * @param object |
| - * @param name |
| - * @param relationshipsForTermTo |
| - * @param relationshipsForTermFrom |
| - */ |
| - public Term(ObjectEntity object, String name, |
| - Set<Relationship> relationshipsForTermTo, |
| - Set<Relationship> relationshipsForTermFrom) |
| - { |
| - this.object = object; |
| - this.name = name; |
| - this.relationshipsForTermTo = relationshipsForTermTo; |
| - this.relationshipsForTermFrom = relationshipsForTermFrom; |
| - } |
| + @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; |
| + } |
| - /** |
| - * @return |
| - */ |
| - @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 void setObjectId(int objectId) { |
| + this.objectId = objectId; |
| + } |
| - /** |
| - * @param objectId |
| - */ |
| - public void setObjectId(int objectId) |
| - { |
| - this.objectId = objectId; |
| - } |
| + @OneToOne(fetch = FetchType.LAZY) |
| + @PrimaryKeyJoinColumn |
| + public Object getObject() { |
| + return this.object; |
| + } |
| - /** |
| - * @return ObjectEntity domain object |
| - */ |
| - @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) |
| - @PrimaryKeyJoinColumn |
| - public ObjectEntity getObject() |
| - { |
| - return this.object; |
| - } |
| + public void setObject(Object object) { |
| + this.object = object; |
| + } |
| - /** |
| - * @param object |
| - */ |
| - public void setObject(ObjectEntity object) |
| - { |
| - this.object = object; |
| - } |
| + @Column(name = "name", unique = true) |
| + public String getName() { |
| + return this.name; |
| + } |
| - /** |
| - * @return |
| - */ |
| - @Column(name = "name", unique = true) |
| - public String getName() |
| - { |
| - return this.name; |
| - } |
| + public void setName(String name) { |
| + this.name = name; |
| + } |
| - /** |
| - * @param name |
| - */ |
| - public void setName(String name) |
| - { |
| - this.name = name; |
| - } |
| + @OneToMany(fetch = FetchType.LAZY, mappedBy = "termByTermTo") |
| + public Set<Relationship> getRelationshipsForTermTo() { |
| + return this.relationshipsForTermTo; |
| + } |
| - @OneToMany(fetch = FetchType.LAZY, mappedBy = "termByTermTo") |
| - public Set<Relationship> getRelationshipsForTermTo() |
| - { |
| - return this.relationshipsForTermTo; |
| - } |
| + public void setRelationshipsForTermTo( |
| + Set<Relationship> relationshipsForTermTo) { |
| + this.relationshipsForTermTo = relationshipsForTermTo; |
| + } |
| - /** |
| - * @param relationshipsForTermTo |
| - */ |
| - public void setRelationshipsForTermTo(Set<Relationship> relationshipsForTermTo) |
| - { |
| - this.relationshipsForTermTo = relationshipsForTermTo; |
| - } |
| + @OneToMany(fetch = FetchType.LAZY, mappedBy = "termByTermFrom") |
| + public Set<Relationship> getRelationshipsForTermFrom() { |
| + return this.relationshipsForTermFrom; |
| + } |
| - /** |
| - * @return |
| - */ |
| - @OneToMany(fetch = FetchType.LAZY, mappedBy = "termByTermFrom") |
| - public Set<Relationship> getRelationshipsForTermFrom() |
| - { |
| - return this.relationshipsForTermFrom; |
| - } |
| + public void setRelationshipsForTermFrom( |
| + Set<Relationship> relationshipsForTermFrom) { |
| + this.relationshipsForTermFrom = relationshipsForTermFrom; |
| + } |
| - /** |
| - * @param relationshipsForTermFrom |
| - */ |
| - public void setRelationshipsForTermFrom( |
| - Set<Relationship> relationshipsForTermFrom) |
| - { |
| - this.relationshipsForTermFrom = relationshipsForTermFrom; |
| - } |
| - |
| } |
| /trunk/src/ch/ffhs/webE/domain/ObjectType.java |
|---|
| 4,7 → 4,6 |
| import java.util.HashSet; |
| import java.util.Set; |
| import javax.persistence.Column; |
| import javax.persistence.Entity; |
| import javax.persistence.FetchType; |
| 18,65 → 17,51 |
| */ |
| @Entity |
| @Table(name = "object_type", catalog = "webengineering", uniqueConstraints = @UniqueConstraint(columnNames = "name")) |
| public class ObjectType implements java.io.Serializable |
| { |
| /** |
| * ObjectEntity type ID for a term |
| */ |
| public static final int TERM = 1; |
| public class ObjectType implements java.io.Serializable { |
| private int objectTypeId; |
| private String name; |
| private Set<ObjectEntity> objects = new HashSet<ObjectEntity>(0); |
| private int objectTypeId; |
| private String name; |
| private Set<Object> objects = new HashSet<Object>(0); |
| public ObjectType() |
| { |
| } |
| public ObjectType() { |
| } |
| public ObjectType(int objectTypeId) |
| { |
| this.objectTypeId = objectTypeId; |
| } |
| public ObjectType(int objectTypeId) { |
| this.objectTypeId = objectTypeId; |
| } |
| public ObjectType(int objectTypeId, String name, Set<ObjectEntity> objects) |
| { |
| this.objectTypeId = objectTypeId; |
| this.name = name; |
| this.objects = objects; |
| } |
| public ObjectType(int objectTypeId, String name, Set<Object> objects) { |
| this.objectTypeId = objectTypeId; |
| this.name = name; |
| this.objects = objects; |
| } |
| @Id |
| @Column(name = "object_type_id", unique = true, nullable = false) |
| public int getObjectTypeId() |
| { |
| return this.objectTypeId; |
| } |
| @Id |
| @Column(name = "object_type_id", unique = true, nullable = false) |
| public int getObjectTypeId() { |
| return this.objectTypeId; |
| } |
| public void setObjectTypeId(int objectTypeId) |
| { |
| this.objectTypeId = objectTypeId; |
| } |
| public void setObjectTypeId(int objectTypeId) { |
| this.objectTypeId = objectTypeId; |
| } |
| @Column(name = "name", unique = true, length = 45) |
| public String getName() |
| { |
| return this.name; |
| } |
| @Column(name = "name", unique = true, length = 45) |
| public String getName() { |
| return this.name; |
| } |
| public void setName(String name) |
| { |
| this.name = name; |
| } |
| public void setName(String name) { |
| this.name = name; |
| } |
| @OneToMany(fetch = FetchType.LAZY, mappedBy = "objectType") |
| public Set<ObjectEntity> getObjects() |
| { |
| return this.objects; |
| } |
| @OneToMany(fetch = FetchType.LAZY, mappedBy = "objectType") |
| public Set<Object> getObjects() { |
| return this.objects; |
| } |
| public void setObjects(Set<ObjectEntity> objects) |
| { |
| this.objects = objects; |
| } |
| public void setObjects(Set<Object> objects) { |
| this.objects = objects; |
| } |
| } |
| /trunk/src/ch/ffhs/webE/domain/User.java |
|---|
| 2,15 → 2,13 |
| // 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; |
| 21,147 → 19,121 |
| */ |
| @Entity |
| @Table(name = "user", catalog = "webengineering", uniqueConstraints = @UniqueConstraint(columnNames = "username")) |
| public class User implements java.io.Serializable |
| { |
| /** |
| * Version ID for serialization |
| */ |
| private static final long serialVersionUID = 1L; |
| public class User implements java.io.Serializable { |
| private Integer id; |
| private String username; |
| private String password; |
| private String firstname; |
| private String lastname; |
| private boolean admin; |
| private Set<ObjectEntity> objectsForOwnerId = new HashSet<ObjectEntity>(0); |
| private Set<ObjectEntity> objectsForEditorId = new HashSet<ObjectEntity>(0); |
| private Set<History> histories = new HashSet<History>(0); |
| private Integer id; |
| private String username; |
| private String password; |
| private String firstname; |
| private String lastname; |
| private boolean admin; |
| private Set<Object> objectsForOwnerId = new HashSet<Object>(0); |
| private Set<Object> objectsForEditorId = new HashSet<Object>(0); |
| private Set<History> histories = new HashSet<History>(0); |
| public User() |
| { |
| } |
| public User() { |
| } |
| public User(String username, String password, boolean admin) |
| { |
| this.username = username; |
| this.password = password; |
| this.admin = admin; |
| } |
| public User(String username, String password, boolean admin) { |
| this.username = username; |
| this.password = password; |
| this.admin = admin; |
| } |
| public User(String username, String password, String firstname, |
| String lastname, boolean admin, Set<ObjectEntity> objectsForOwnerId, |
| Set<ObjectEntity> objectsForEditorId, Set<History> histories) |
| { |
| this.username = username; |
| this.password = password; |
| this.firstname = firstname; |
| this.lastname = lastname; |
| this.admin = admin; |
| this.objectsForOwnerId = objectsForOwnerId; |
| this.objectsForEditorId = objectsForEditorId; |
| this.histories = histories; |
| } |
| public User(String username, String password, String firstname, |
| String lastname, boolean admin, Set<Object> objectsForOwnerId, |
| Set<Object> objectsForEditorId, Set<History> histories) { |
| this.username = username; |
| this.password = password; |
| this.firstname = firstname; |
| this.lastname = lastname; |
| this.admin = admin; |
| this.objectsForOwnerId = objectsForOwnerId; |
| this.objectsForEditorId = objectsForEditorId; |
| this.histories = histories; |
| } |
| @Id |
| @GeneratedValue(strategy = IDENTITY) |
| @Column(name = "id", unique = true, nullable = false) |
| public Integer getId() |
| { |
| return this.id; |
| } |
| @Id |
| @GeneratedValue(strategy = IDENTITY) |
| @Column(name = "id", unique = true, nullable = false) |
| public Integer getId() { |
| return this.id; |
| } |
| public void setId(Integer id) |
| { |
| this.id = id; |
| } |
| public void setId(Integer id) { |
| this.id = id; |
| } |
| @Column(name = "username", unique = true, nullable = false) |
| public String getUsername() |
| { |
| return this.username; |
| } |
| @Column(name = "username", unique = true, nullable = false) |
| public String getUsername() { |
| return this.username; |
| } |
| public void setUsername(String username) |
| { |
| this.username = username; |
| } |
| public void setUsername(String username) { |
| this.username = username; |
| } |
| @Column(name = "password", nullable = false, length = 32) |
| public String getPassword() |
| { |
| return this.password; |
| } |
| @Column(name = "password", nullable = false, length = 32) |
| public String getPassword() { |
| return this.password; |
| } |
| public void setPassword(String password) |
| { |
| this.password = password; |
| } |
| public void setPassword(String password) { |
| this.password = password; |
| } |
| @Column(name = "firstname", length = 45) |
| public String getFirstname() |
| { |
| return this.firstname; |
| } |
| @Column(name = "firstname", length = 45) |
| public String getFirstname() { |
| return this.firstname; |
| } |
| public void setFirstname(String firstname) |
| { |
| this.firstname = firstname; |
| } |
| public void setFirstname(String firstname) { |
| this.firstname = firstname; |
| } |
| @Column(name = "lastname", length = 45) |
| public String getLastname() |
| { |
| return this.lastname; |
| } |
| @Column(name = "lastname", length = 45) |
| public String getLastname() { |
| return this.lastname; |
| } |
| public void setLastname(String lastname) |
| { |
| this.lastname = lastname; |
| } |
| public void setLastname(String lastname) { |
| this.lastname = lastname; |
| } |
| @Column(name = "admin", nullable = false) |
| public boolean isAdmin() |
| { |
| return this.admin; |
| } |
| @Column(name = "admin", nullable = false) |
| public boolean isAdmin() { |
| return this.admin; |
| } |
| public void setAdmin(boolean admin) |
| { |
| this.admin = admin; |
| } |
| public void setAdmin(boolean admin) { |
| this.admin = admin; |
| } |
| @OneToMany(fetch = FetchType.LAZY, mappedBy = "userByOwnerId") |
| public Set<ObjectEntity> getObjectsForOwnerId() |
| { |
| return this.objectsForOwnerId; |
| } |
| @OneToMany(fetch = FetchType.LAZY, mappedBy = "userByOwnerId") |
| public Set<Object> getObjectsForOwnerId() { |
| return this.objectsForOwnerId; |
| } |
| public void setObjectsForOwnerId(Set<ObjectEntity> objectsForOwnerId) |
| { |
| this.objectsForOwnerId = objectsForOwnerId; |
| } |
| public void setObjectsForOwnerId(Set<Object> objectsForOwnerId) { |
| this.objectsForOwnerId = objectsForOwnerId; |
| } |
| @OneToMany(fetch = FetchType.LAZY, mappedBy = "userByEditorId") |
| public Set<ObjectEntity> getObjectsForEditorId() |
| { |
| return this.objectsForEditorId; |
| } |
| @OneToMany(fetch = FetchType.LAZY, mappedBy = "userByEditorId") |
| public Set<Object> getObjectsForEditorId() { |
| return this.objectsForEditorId; |
| } |
| public void setObjectsForEditorId(Set<ObjectEntity> objectsForEditorId) |
| { |
| this.objectsForEditorId = objectsForEditorId; |
| } |
| public void setObjectsForEditorId(Set<Object> objectsForEditorId) { |
| this.objectsForEditorId = objectsForEditorId; |
| } |
| @OneToMany(fetch = FetchType.LAZY, mappedBy = "user") |
| public Set<History> getHistories() |
| { |
| return this.histories; |
| } |
| @OneToMany(fetch = FetchType.LAZY, mappedBy = "user") |
| public Set<History> getHistories() { |
| return this.histories; |
| } |
| public void setHistories(Set<History> histories) |
| { |
| this.histories = histories; |
| } |
| public void setHistories(Set<History> histories) { |
| this.histories = histories; |
| } |
| } |