* mainTemplate.jsp - Moved application name to back for better bookmarks * Terms.java - Added relationship links * Relationships: - Added term links * General: - Implemented history for term+relationship create and update (TODO: also for delete, using flag) - Removed unnecessary interfaces - Unifiorm method names in actions and DAO - Unified UI and actions (only one template for CRUD of an object) - Removed edit=false assignment in favor of redirection
/trunk/src/struts.xml |
---|
14,7 → 14,7 |
</action> |
<action name="saveTerm" method="save" |
class="ch.ffhs.webE.action.TermAction"> |
<result type="redirect">/user/listTerms</result> |
<result>/user/terms.jsp</result> |
</action> |
<action name="editTerm" method="edit" |
class="ch.ffhs.webE.action.TermAction"> |
52,50 → 52,60 |
<result>/admin/userAddForm.jsp</result> |
</action> |
<action name="listUsers" method="list" |
<action name="doUserAdd" method="addOrUpdate" |
class="ch.ffhs.webE.action.UserAction"> |
<result name="success">/admin/users.jsp</result> |
<result name="success">/admin/userAdd.jsp</result> |
</action> |
<action name="saveUser" method="save" |
<action name="userList" method="list" |
class="ch.ffhs.webE.action.UserAction"> |
<result type="redirect">/admin/listUsers</result> |
<result name="success">/admin/userList.jsp</result> |
</action> |
<action name="deleteUser" method="delete" |
class="ch.ffhs.webE.action.UserAction"> |
<result name="success" type="redirect">/admin/listUsers</result> |
<result name="success" type="redirect">/admin/userList</result> |
</action> |
<action name="editUser" method="edit" |
class="ch.ffhs.webE.action.UserAction"> |
<result name="success">/admin/users.jsp</result> |
<result name="success">/admin/userAddForm.jsp</result> |
</action> |
<!-- Relationship Type management --> |
<action name="listRelTypes" method="list" |
<action name="relTypeList" method="list" |
class="ch.ffhs.webE.action.RelationshipTypeAction"> |
<result name="success">/admin/relTypes.jsp</result> |
<result name="success">/admin/relTypeList.jsp</result> |
</action> |
<action name="relTypeAddForm"> |
<result>/admin/relTypeAddForm.jsp</result> |
</action> |
<action name="doRelTypeAdd" method="addOrUpdate" |
class="ch.ffhs.webE.action.RelationshipTypeAction"> |
<result name="success" type="redirect">/admin/listRelTypes</result> |
<result name="success" type="redirect">/admin/relTypeList</result> |
</action> |
<action name="deleteRelType" method="delete" |
class="ch.ffhs.webE.action.RelationshipTypeAction"> |
<result name="success" type="redirect">/admin/listRelTypes</result> |
<result name="success" type="redirect">/admin/relTypeList</result> |
</action> |
<action name="editRelType" method="edit" |
class="ch.ffhs.webE.action.RelationshipTypeAction"> |
<result name="success">/admin/relTypes.jsp</result> |
<result name="success">/admin/relTypeAddForm.jsp</result> |
<result name="error">/admin/adminError.jsp</result> |
</action> |
</package> |
<!-- Remaining environment of the session --> |
<package name="default" namespace="" extends="hibernate-default"> |
/trunk/src/ch/ffhs/webE/dao/RelationshipDAO.java |
---|
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: ch/ffhs/webE/dao/HistoryDAO.java |
=================================================================== |
--- ch/ffhs/webE/dao/HistoryDAO.java (revision 37) |
+++ ch/ffhs/webE/dao/HistoryDAO.java (nonexistent) |
@@ -1,88 +0,0 @@ |
-/** |
- * |
- */ |
-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.History; |
- |
-import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget; |
-import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget; |
- |
-/** |
- * @author pelinux |
- * |
- */ |
-public class HistoryDAO |
-{ |
- /** |
- * Database session |
- */ |
- @SessionTarget |
- Session session; |
- |
- /** |
- * Database transaction |
- */ |
- @TransactionTarget |
- Transaction transaction; |
- |
- /** |
- * Executes the query to save the history record |
- * |
- * @param history |
- * Domain object to be saved |
- * @return <code>true</code> if successful, <code>false</code> otherwise |
- */ |
- public boolean saveOrUpdate(History history) |
- { |
- try |
- { |
- history.setId(history.getId()); |
- this.session.saveOrUpdate(history); |
- return true; |
- } |
- catch (Exception e) |
- { |
- this.transaction.rollback(); |
- e.printStackTrace(); |
- return false; |
- } |
- } |
- |
- /** |
- * Returns a list of all terms |
- * |
- * @return an ArrayList with all the terms - in case of a problem, an empty |
- * list is returned |
- */ |
- @SuppressWarnings("unchecked") |
- public List<History> getList() |
- { |
- List<History> history = null; |
- try |
- { |
- history = this.session.createQuery("from History").list(); //$NON-NLS-1$ |
- } |
- catch (Exception e) |
- { |
- e.printStackTrace(); |
- } |
- |
- /* |
- * If no term was checked, return an empty list to mitigate null pointer |
- * exceptions |
- */ |
- if (history == null) |
- { |
- history = new ArrayList<History>(); |
- } |
- |
- return history; |
- } |
-} |
/ch/ffhs/webE/dao/HistoryDAO.java |
---|
Property changes: |
Deleted: svn:mime-type |
## -1 +0,0 ## |
-text/plain |
\ No newline at end of property |
Index: ch/ffhs/webE/dao/RelationshipDAOImpl.java |
=================================================================== |
--- ch/ffhs/webE/dao/RelationshipDAOImpl.java (nonexistent) |
+++ ch/ffhs/webE/dao/RelationshipDAOImpl.java (revision 35) |
@@ -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> getRelationshipList() |
+ { |
+ 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; |
+ } |
+} |
\ No newline at end of file |
/ch/ffhs/webE/dao/RelationshipDAOImpl.java |
---|
Property changes: |
Added: svn:mime-type |
## -0,0 +1 ## |
+text/plain |
\ No newline at end of property |
Index: ch/ffhs/webE/dao/RelationshipTypeDAO.java |
=================================================================== |
--- ch/ffhs/webE/dao/RelationshipTypeDAO.java (revision 37) |
+++ ch/ffhs/webE/dao/RelationshipTypeDAO.java (revision 35) |
@@ -1,130 +1,16 @@ |
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.RelationshipType; |
-import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget; |
-import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget; |
+public interface RelationshipTypeDAO { |
-/** |
- * Data Access Object class for {@link RelationshipType}s |
- * |
- * @author Thomas Lahn |
- */ |
-public class RelationshipTypeDAO |
-{ |
+ List<RelationshipType> getRelTypes(); |
- /** |
- * Hibernate session target |
- */ |
- @SessionTarget |
- Session session; |
+ boolean deleteRelationshipType(int relTypeID); |
- /** |
- * Hibernate transaction target |
- */ |
- @TransactionTarget |
- Transaction transaction; |
+ RelationshipType getRelTypeById(int relTypeID); |
- /** |
- * Gets a list of all the relationshipTypes in the database. |
- * |
- * @return List of all the users. In case of a problem, an empty list is |
- * returned. |
- */ |
- @SuppressWarnings("unchecked") |
- public List<RelationshipType> getList() |
- { |
- |
- List<RelationshipType> relType = null; |
- |
- try |
- { |
- relType = this.session.createQuery("from RelationshipType").list(); //$NON-NLS-1$ |
+ boolean saveOrUpdateRelType(RelationshipType relType); |
} |
- catch (Exception e) |
- { |
- // TODO: Logging |
- } |
- |
- if (relType == null) |
- { |
- relType = new ArrayList<RelationshipType>(); |
- } |
- |
- return relType; |
- } |
- |
- /** |
- * Saves or updates a relationship type |
- * |
- * @param relType |
- * A filled domain object |
- * @return Boolean indicating success or error in saving the relationshipType |
- */ |
- public boolean saveOrUpdate(RelationshipType relType) |
- { |
- try |
- { |
- this.session.saveOrUpdate(relType); |
- return true; |
- } |
- catch (Exception e) |
- { |
- this.transaction.rollback(); |
- return false; |
- // TODO: Logging |
- } |
- } |
- |
- /** |
- * Delete a relationship type |
- * |
- * @param relTypeId |
- * Relationship type ID |
- * @return boolean indicating success or error in the query execution |
- */ |
- public boolean delete(int relTypeId) |
- { |
- try |
- { |
- RelationshipType relType = (RelationshipType) this.session.get( |
- RelationshipType.class, relTypeId); |
- this.session.delete(relType); |
- return true; |
- } |
- catch (Exception e) |
- { |
- this.transaction.rollback(); |
- // TODO: Logging |
- return false; |
- } |
- } |
- |
- /** |
- * Used to get a relationship type by ID |
- * |
- * @param relTypeID |
- * @return |
- */ |
- public RelationshipType getById(int relTypeID) |
- { |
- RelationshipType relType = null; |
- try |
- { |
- relType = (RelationshipType) this.session.get(RelationshipType.class, |
- relTypeID); |
- } |
- catch (Exception e) |
- { |
- e.printStackTrace(); |
- // TODO: Logging |
- } |
- return relType; |
- } |
-} |
/trunk/src/ch/ffhs/webE/dao/RelationshipTypeDAOImpl.java |
---|
0,0 → 1,118 |
package ch.ffhs.webE.dao; |
import java.util.ArrayList; |
import java.util.List; |
import org.hibernate.Session; |
import org.hibernate.Transaction; |
import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget; |
import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget; |
import ch.ffhs.webE.domain.*; |
public class RelationshipTypeDAOImpl implements RelationshipTypeDAO |
{ |
@SessionTarget |
Session session; |
@TransactionTarget |
Transaction transaction; |
/** |
* Gets a list of all the relationshipTypes in the database. |
* |
* @return List of all the users. In case of a problem, an empty list is |
* returned. |
*/ |
@SuppressWarnings("unchecked") |
@Override |
public List<RelationshipType> getRelTypes() |
{ |
List<RelationshipType> relType = null; |
try |
{ |
relType = session.createQuery("from RelationshipType").list(); |
} |
catch (Exception e) |
{ |
// TODO: Logging |
} |
if (relType == null) |
{ |
relType = new ArrayList<RelationshipType>(); |
} |
return relType; |
} |
/** |
* used to save a relationship type |
* |
* @param RelationshipType |
* relType: A filled DAO |
* @return Boolean indicating success or error in saving the |
* relationshipType |
*/ |
@Override |
public boolean saveOrUpdateRelType(RelationshipType relType) |
{ |
try |
{ |
session.saveOrUpdate(relType); |
return true; |
} |
catch (Exception e) |
{ |
transaction.rollback(); |
return false; |
// TODO: Logging |
} |
} |
/** |
* Used to delete a relationship type. |
* |
* @param int RelationshipType ID |
* @return boolean indicating success or error in the query execution |
*/ |
@Override |
public boolean deleteRelationshipType(int relTypeID) |
{ |
try |
{ |
RelationshipType relType = (RelationshipType) session.get( |
RelationshipType.class, relTypeID); |
session.delete(relType); |
return true; |
} |
catch (Exception e) |
{ |
transaction.rollback(); |
// TODO: Logging |
return false; |
} |
} |
/** |
* Used to get a relationship type by ID |
*/ |
@Override |
public RelationshipType getRelTypeById(int relTypeID) |
{ |
RelationshipType relType = null; |
try |
{ |
relType = (RelationshipType) session.get(RelationshipType.class, |
relTypeID); |
} |
catch (Exception e) |
{ |
e.printStackTrace(); |
// TODO: Logging |
} |
return relType; |
} |
} |
Property changes: |
Added: svn:mime-type |
## -0,0 +1 ## |
+text/plain |
\ No newline at end of property |
Index: ch/ffhs/webE/dao/TermDAO.java |
=================================================================== |
--- ch/ffhs/webE/dao/TermDAO.java (revision 37) |
+++ ch/ffhs/webE/dao/TermDAO.java (revision 35) |
@@ -1,66 +1,37 @@ |
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.Term; |
-import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget; |
-import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget; |
- |
/** |
- * Implements the Database Access Object for terms |
+ * Defines methods all term DAO implementations must implement |
* |
- * @author Thomas Lahn |
+ * @author pelinux |
*/ |
-public class TermDAO |
+public interface TermDAO |
{ |
/** |
- * Database session |
+ * @return |
*/ |
- @SessionTarget |
- Session session; |
+ List<Term> getTerms(); |
/** |
- * Database transaction |
+ * Delete a term |
+ * |
+ * @param termId |
+ * Term ID |
*/ |
- @TransactionTarget |
- Transaction transaction; |
+ void deleteTerm(int termId); |
/** |
- * Returns a list of all terms |
+ * Retrieves a term by ID |
* |
- * @return an ArrayList with all the terms - in case of a problem, an empty |
- * list is returned |
+ * @param termId |
+ * @return |
*/ |
- @SuppressWarnings("unchecked") |
- public List<Term> getList() |
- { |
- List<Term> term = null; |
- try |
- { |
- term = this.session.createQuery("from Term").list(); //$NON-NLS-1$ |
- } |
- catch (Exception e) |
- { |
- e.printStackTrace(); |
- } |
+ Term getTermById(int termId); |
- /* |
- * If no term was checked, return an empty list to mitigate null pointer |
- * exceptions |
- */ |
- if (term == null) |
- { |
- term = new ArrayList<Term>(); |
- } |
- |
- return term; |
- } |
- |
/** |
* Executes the query to save the term |
* |
@@ -68,61 +39,5 @@ |
* Domain object to be saved |
* @return <code>true</code> if successful, <code>false</code> otherwise |
*/ |
- public boolean saveOrUpdate(Term term) |
- { |
- try |
- { |
- term.setObjectId(term.getObjectId()); |
- this.session.saveOrUpdate(term); |
- return true; |
+ boolean saveOrUpdate(Term term); |
} |
- catch (Exception e) |
- { |
- this.transaction.rollback(); |
- e.printStackTrace(); |
- return false; |
- } |
- } |
- |
- /** |
- * Delete a term |
- * |
- * @param termId |
- * Term ID |
- */ |
- public void delete(int termId) |
- { |
- try |
- { |
- Term term = (Term) this.session.get(Term.class, termId); |
- this.session.delete(term); |
- } |
- catch (Exception e) |
- { |
- this.transaction.rollback(); |
- e.printStackTrace(); |
- } |
- } |
- |
- /** |
- * Retrieves a term by ID |
- * |
- * @param termId |
- * @return |
- */ |
- public Term getById(int termId) |
- { |
- Term term = null; |
- |
- try |
- { |
- term = (Term) this.session.get(Term.class, termId); |
- } |
- catch (Exception e) |
- { |
- e.printStackTrace(); |
- } |
- |
- return term; |
- } |
-} |
\ No newline at end of file |
/trunk/src/ch/ffhs/webE/dao/TermDAOImpl.java |
---|
0,0 → 1,124 |
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.Term; |
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 TermDAOImpl implements TermDAO |
{ |
/** |
* Database session |
*/ |
@SessionTarget |
Session session; |
/** |
* Database transaction |
*/ |
@TransactionTarget |
Transaction transaction; |
/** |
* Returns a list of all terms |
* |
* @return an ArrayList with all the terms - in case of a problem, an empty |
* list is returned |
*/ |
@SuppressWarnings("unchecked") |
public List<Term> getTerms() |
{ |
List<Term> term = null; |
try |
{ |
term = this.session.createQuery("from Term").list(); //$NON-NLS-1$ |
} |
catch (Exception e) |
{ |
e.printStackTrace(); |
} |
/* |
* If no term was checked, return an empty list to mitigate null pointer |
* exceptions |
*/ |
if (term == null) |
{ |
term = new ArrayList<Term>(); |
} |
return term; |
} |
/* |
* (non-Javadoc) |
* |
* @see ch.ffhs.webE.dao.TermDAO#saveOrUpdate(ch.ffhs.webE.domain.Term) |
*/ |
public boolean saveOrUpdate(Term term) |
{ |
try |
{ |
term.setObjectId(term.getObjectId()); |
this.session.saveOrUpdate(term); |
return true; |
} |
catch (Exception e) |
{ |
this.transaction.rollback(); |
e.printStackTrace(); |
return false; |
} |
} |
/* |
* (non-Javadoc) |
* |
* @see ch.ffhs.webE.dao.TermDAO#deleteTerm(int) |
*/ |
public void deleteTerm(int termId) |
{ |
try |
{ |
Term term = (Term) this.session.get(Term.class, termId); |
this.session.delete(term); |
} |
catch (Exception e) |
{ |
this.transaction.rollback(); |
e.printStackTrace(); |
} |
} |
/* |
* (non-Javadoc) |
* |
* @see ch.ffhs.webE.dao.TermDAO#getTermById(int) |
*/ |
public Term getTermById(int termId) |
{ |
Term term = null; |
try |
{ |
term = (Term) this.session.get(Term.class, termId); |
} |
catch (Exception e) |
{ |
e.printStackTrace(); |
} |
return term; |
} |
} |
Property changes: |
Added: svn:mime-type |
## -0,0 +1 ## |
+text/plain |
\ No newline at end of property |
Index: ch/ffhs/webE/dao/UserDAOImpl.java |
=================================================================== |
--- ch/ffhs/webE/dao/UserDAOImpl.java (nonexistent) |
+++ ch/ffhs/webE/dao/UserDAOImpl.java (revision 35) |
@@ -0,0 +1,135 @@ |
+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.User; |
+ |
+import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget; |
+import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget; |
+ |
+public class UserDAOImpl implements UserDAO |
+{ |
+ |
+ @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 |
+ { |
+ user = this.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; |
+ } |
+ |
+ /** |
+ * Executes the query to save the user |
+ * |
+ * @param User |
+ * Domain object to be saved |
+ * @return void |
+ */ |
+ @Override |
+ public void saveOrUpdateUser(User user) |
+ { |
+ try |
+ { |
+ this.session.saveOrUpdate(user); |
+ } |
+ catch (Exception e) |
+ { |
+ this.transaction.rollback(); |
+ e.printStackTrace(); |
+ } |
+ } |
+ |
+ /** |
+ * Used to delete a user. |
+ * |
+ * @param int userId |
+ */ |
+ @Override |
+ public void deleteUser(int userId) |
+ { |
+ try |
+ { |
+ User user = (User) this.session.get(User.class, userId); |
+ this.session.delete(user); |
+ } |
+ catch (Exception e) |
+ { |
+ this.transaction.rollback(); |
+ e.printStackTrace(); |
+ } |
+ } |
+ |
+ /** |
+ * 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(); |
+ } |
+ 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 |
+ { |
+ user = (User) this.session.get(User.class, userId); |
+ } |
+ catch (Exception e) |
+ { |
+ e.printStackTrace(); |
+ } |
+ return user; |
+ } |
+} |
\ No newline at end of file |
/ch/ffhs/webE/dao/UserDAOImpl.java |
---|
Property changes: |
Added: svn:mime-type |
## -0,0 +1 ## |
+text/plain |
\ No newline at end of property |
Index: ch/ffhs/webE/dao/UserDAO.java |
=================================================================== |
--- ch/ffhs/webE/dao/UserDAO.java (revision 37) |
+++ ch/ffhs/webE/dao/UserDAO.java (revision 35) |
@@ -1,134 +1,19 @@ |
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.User; |
-import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget; |
-import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget; |
- |
-public class UserDAO |
+public interface UserDAO |
{ |
- @SessionTarget |
- Session session; |
- @TransactionTarget |
- Transaction transaction; |
+ List<User> listUser(); |
- /** |
- * 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") |
- public List<User> getList() |
- { |
- List<User> user = null; |
- try |
- { |
- user = this.session.createQuery("from User").list(); |
- } |
- catch (Exception e) |
- { |
- e.printStackTrace(); |
- } |
+ User searchUsername(String username); |
- // If no user was checked, return an empty list to mitigate null pointer |
- // exceptions |
- if (user == null) |
- { |
- user = new ArrayList<User>(); |
- } |
- return user; |
- } |
+ void deleteUser(int userId); |
- /** |
- * Executes the query to save the user |
- * |
- * @param user |
- * Domain object to be saved |
- * @return void |
- */ |
- public void saveOrUpdate(User user) |
- { |
- try |
- { |
- this.session.saveOrUpdate(user); |
- } |
- catch (Exception e) |
- { |
- this.transaction.rollback(); |
- e.printStackTrace(); |
- } |
- } |
+ User listUserById(int userId); |
- /** |
- * Used to delete a user. |
- * |
- * @param userId |
- */ |
- public void delete(int userId) |
- { |
- try |
- { |
- User user = (User) this.session.get(User.class, userId); |
- this.session.delete(user); |
+ void saveOrUpdateUser(User user); |
} |
- catch (Exception e) |
- { |
- this.transaction.rollback(); |
- e.printStackTrace(); |
- } |
- } |
- |
- /** |
- * 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 getByUsername(String username) |
- { |
- User user = null; |
- |
- // Exec query |
- try |
- { |
- user = (User) this.session |
- .createQuery("FROM User " + "WHERE username = :username") |
- .setParameter("username", username).uniqueResult(); |
- } |
- catch (Exception e) |
- { |
- // TODO: Log error |
- } |
- return user; |
- } |
- |
- /** |
- * Used to list a single user by Id. |
- * |
- * @param userId |
- * @return |
- */ |
- public User getById(int userId) |
- { |
- User user = null; |
- try |
- { |
- user = (User) this.session.get(User.class, userId); |
- } |
- catch (Exception e) |
- { |
- e.printStackTrace(); |
- } |
- return user; |
- } |
-} |
\ No newline at end of file |
/trunk/src/ch/ffhs/webE/domain/History.java |
---|
2,14 → 2,12 |
// Generated 19.12.2010 14:46:08 by Hibernate Tools 3.4.0.Beta1 |
import static javax.persistence.GenerationType.IDENTITY; |
import java.util.Date; |
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; |
22,14 → 20,9 |
*/ |
@Entity |
@Table(name = "history", catalog = "webengineering") |
public class History implements java.io.Serializable |
{ |
/** |
* Serialization version ID |
*/ |
private static final long serialVersionUID = 1L; |
public class History implements java.io.Serializable { |
private int id; |
private Integer id; |
private User user; |
private ActionType actionType; |
private ObjectEntity object; |
37,22 → 30,10 |
private String comment; |
private Date date; |
/** |
* |
*/ |
public History() |
{ |
public History() { |
} |
/** |
* @param user |
* @param actionType |
* @param object |
* @param date |
*/ |
public History(User user, ActionType actionType, ObjectEntity object, |
Date date) |
{ |
public History(User user, ActionType actionType, ObjectEntity object, Date date) { |
this.user = user; |
this.actionType = actionType; |
this.object = object; |
59,17 → 40,8 |
this.date = date; |
} |
/** |
* @param user |
* @param actionType |
* @param object |
* @param value |
* @param comment |
* @param date |
*/ |
public History(User user, ActionType actionType, ObjectEntity object, |
String value, String comment, Date date) |
{ |
String value, String comment, Date date) { |
this.user = user; |
this.actionType = actionType; |
this.object = object; |
78,128 → 50,72 |
this.date = date; |
} |
/** |
* @return |
*/ |
@Id |
@GeneratedValue(strategy = IDENTITY) |
@Column(name = "id", unique = true, nullable = false) |
public int getId() |
{ |
public Integer getId() { |
return this.id; |
} |
/** |
* @param id |
*/ |
public void setId(int id) |
{ |
public void setId(Integer id) { |
this.id = id; |
} |
/** |
* @return |
*/ |
@ManyToOne(fetch = FetchType.LAZY) |
@JoinColumn(name = "user_id", nullable = false) |
public User getUser() |
{ |
public User getUser() { |
return this.user; |
} |
/** |
* @param user |
*/ |
public void setUser(User user) |
{ |
public void setUser(User user) { |
this.user = user; |
} |
/** |
* @return |
*/ |
@ManyToOne(fetch = FetchType.LAZY) |
@JoinColumn(name = "action_type_id", nullable = false) |
public ActionType getActionType() |
{ |
public ActionType getActionType() { |
return this.actionType; |
} |
/** |
* @param actionType |
*/ |
public void setActionType(ActionType actionType) |
{ |
public void setActionType(ActionType actionType) { |
this.actionType = actionType; |
} |
/** |
* @return |
*/ |
@ManyToOne(fetch = FetchType.LAZY) |
@JoinColumn(name = "objects_id", nullable = false) |
public ObjectEntity getObject() |
{ |
public ObjectEntity getObject() { |
return this.object; |
} |
/** |
* @param object |
*/ |
public void setObject(ObjectEntity object) |
{ |
public void setObject(ObjectEntity object) { |
this.object = object; |
} |
/** |
* @return |
*/ |
@Column(name = "value", length = 45) |
public String getValue() |
{ |
public String getValue() { |
return this.value; |
} |
/** |
* @param value |
*/ |
public void setValue(String value) |
{ |
public void setValue(String value) { |
this.value = value; |
} |
/** |
* @return |
*/ |
@Column(name = "comment") |
public String getComment() |
{ |
public String getComment() { |
return this.comment; |
} |
/** |
* @param comment |
*/ |
public void setComment(String comment) |
{ |
public void setComment(String comment) { |
this.comment = comment; |
} |
/** |
* @return |
*/ |
@Temporal(TemporalType.TIMESTAMP) |
@Column(name = "date", nullable = false, length = 19) |
public Date getDate() |
{ |
public Date getDate() { |
return this.date; |
} |
/** |
* @param date |
*/ |
public void setDate(Date date) |
{ |
public void setDate(Date date) { |
this.date = date; |
} |
/trunk/src/ch/ffhs/webE/domain/ObjectEntity.java |
---|
22,8 → 22,6 |
import javax.persistence.Temporal; |
import javax.persistence.TemporalType; |
import org.hibernate.annotations.OrderBy; |
/** |
* ObjectEntity generated by hbm2java |
*/ |
45,7 → 43,7 |
private Date modified; |
private Boolean deleted; |
private Term term; |
private Set<History> history = new HashSet<History>(0); |
private Set<History> histories = new HashSet<History>(0); |
private Relationship relationship; |
/** |
76,7 → 74,7 |
* @param modified |
* @param deleted |
* @param term |
* @param history |
* @param histories |
* @param relationship |
*/ |
public ObjectEntity(User userByEditorId, ObjectType objectType, |
90,7 → 88,7 |
this.modified = modified; |
this.deleted = deleted; |
this.term = term; |
this.history = histories; |
this.histories = histories; |
this.relationship = relationship; |
} |
241,18 → 239,17 |
* @return |
*/ |
@OneToMany(fetch = FetchType.LAZY, mappedBy = "object") |
@OrderBy(clause = "date DESC") |
public Set<History> getHistory() |
public Set<History> getHistories() |
{ |
return this.history; |
return this.histories; |
} |
/** |
* @param history |
* @param histories |
*/ |
public void setHistory(Set<History> history) |
public void setHistories(Set<History> histories) |
{ |
this.history = history; |
this.histories = histories; |
} |
/** |
/trunk/src/ch/ffhs/webE/domain/ActionType.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; |
20,77 → 18,46 |
*/ |
@Entity |
@Table(name = "action_type", catalog = "webengineering") |
public class ActionType implements java.io.Serializable |
{ |
/** |
* History action ID for adding an item |
*/ |
public static final int ADD = 1; |
public class ActionType implements java.io.Serializable { |
/** |
* History action ID for renaming a term |
*/ |
public static final int RENAME = 2; |
/** |
* History action ID for modifying a relationship |
*/ |
public static final int MODIFY = 3; |
private int id; |
private Integer id; |
private String name; |
private Set<History> histories = new HashSet<History>(0); |
public ActionType() |
{ |
public ActionType() { |
} |
/** |
* @param id |
*/ |
public ActionType(int id) |
{ |
this.setId(id); |
public ActionType(String name, Set<History> histories) { |
this.name = name; |
this.histories = histories; |
} |
public ActionType(String name, Set<History> histories) |
{ |
this.setName(name); |
this.setHistories(histories); |
} |
@Id |
@GeneratedValue(strategy = IDENTITY) |
@Column(name = "id", unique = true, nullable = false) |
public int getId() |
{ |
public Integer getId() { |
return this.id; |
} |
public void setId(int id) |
{ |
public void setId(Integer id) { |
this.id = id; |
} |
@Column(name = "name", length = 45) |
public String getName() |
{ |
public String getName() { |
return this.name; |
} |
public void setName(String name) |
{ |
public void setName(String name) { |
this.name = name; |
} |
@OneToMany(fetch = FetchType.LAZY, mappedBy = "actionType") |
public Set<History> getHistories() |
{ |
public Set<History> getHistories() { |
return this.histories; |
} |
public void setHistories(Set<History> histories) |
{ |
public void setHistories(Set<History> histories) { |
this.histories = histories; |
} |
/trunk/src/ch/ffhs/webE/action/RelationshipAction.java |
---|
4,19 → 4,15 |
import java.util.Date; |
import java.util.List; |
import java.util.Map; |
import java.util.Set; |
import javax.servlet.http.HttpServletRequest; |
import org.apache.struts2.StrutsStatics; |
import ch.ffhs.webE.dao.HistoryDAO; |
import ch.ffhs.webE.dao.RelationshipDAO; |
import ch.ffhs.webE.dao.RelationshipTypeDAO; |
import ch.ffhs.webE.dao.TermDAO; |
import ch.ffhs.webE.dao.UserDAO; |
import ch.ffhs.webE.domain.ActionType; |
import ch.ffhs.webE.domain.History; |
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; |
40,27 → 36,15 |
private static final long serialVersionUID = 1L; |
private List<RelationshipType> relationshipTypes = new ArrayList<RelationshipType>(); |
private final RelationshipTypeDAO relationshipTypeDAO = new RelationshipTypeDAO(); |
private final RelationshipTypeDAOImpl relationshipTypeDAO = new RelationshipTypeDAOImpl(); |
private List<Term> terms = new ArrayList<Term>(); |
private final TermDAO termDAO = new TermDAO(); |
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(); |
/** |
* The term that was just saved (added, renamed) |
*/ |
private Relationship modifiedRelationship; |
private final RelationshipDAO relationshipDAO = new RelationshipDAO(); |
private final UserDAO userDAO = new UserDAO(); |
private Set<History> history; |
private final HistoryDAO historyDAO = new HistoryDAO(); |
/** |
* Session object |
*/ |
Map<String, Object> session = ActionContext.getContext().getSession(); |
80,6 → 64,11 |
private final HttpServletRequest request = (HttpServletRequest) ActionContext |
.getContext().get(StrutsStatics.HTTP_REQUEST); |
/** |
* The term that was just saved (added, renamed) |
*/ |
private Relationship modifiedRelationship; |
/* |
* (non-Javadoc) |
* |
97,9 → 86,9 |
*/ |
public String list() |
{ |
this.setTerms(this.termDAO.getList()); |
this.setRelationshipTypes(this.relationshipTypeDAO.getList()); |
this.setRelationshipList(this.relationshipDAO.getList()); |
this.setTerms(this.termDAO.getTerms()); |
this.setRelationshipTypes(this.relationshipTypeDAO.getRelTypes()); |
this.setRelationshipList(this.relationshipDAO.getRelationshipList()); |
return Action.SUCCESS; |
} |
110,51 → 99,31 |
*/ |
public String save() |
{ |
this.relationship.setTermFrom(this.termDAO.getById(Integer |
this.relationship.setTermFrom(this.termDAO.getTermById(Integer |
.parseInt(this.request.getParameter("term1")))); |
this.relationship.setTermTo(this.termDAO.getById(Integer |
this.relationship.setTermTo(this.termDAO.getTermById(Integer |
.parseInt(this.request.getParameter("term2")))); |
this.relationship.setRelationshipType(this.relationshipTypeDAO |
.getById(Integer.parseInt(this.request.getParameter("type")))); |
.getRelTypeById(Integer.parseInt(this.request.getParameter("type")))); |
User user = this.userDAO.getByUsername((String) this.session |
User user = this.userDAO.searchUsername((String) this.session |
.get("username")); |
Date now = new Date(); |
ObjectEntity obj; |
int action = 0; |
if ("false".equals(this.request.getParameter("edit"))) |
{ |
/* Add a new relationship */ |
obj = new ObjectEntity(user, new ObjectType(ObjectType.RELATIONSHIP), |
user, null, new Date(), false, null, null, this.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; |
action = ActionType.ADD; |
} |
else |
{ |
obj = new ObjectEntity(); |
obj.setId(this.relationship.getObjectId()); |
action = ActionType.MODIFY; |
} |
this.edit = false; |
String result = Action.SUCCESS; |
if (this.relationshipDAO.saveOrUpdate(this.relationship)) |
if (!this.relationshipDAO.saveOrUpdate(this.relationship)) |
{ |
String comment = this.request.getParameter("comment"); |
History historyRecord = new History(user, new ActionType(action), obj, |
"(" + this.relationship.getTermFrom().getName() + ") (" |
+ this.relationship.getRelationshipType().getNameFrom() + ") (" |
+ this.relationship.getTermTo().getName() + ")", comment, now); |
this.historyDAO.saveOrUpdate(historyRecord); |
} |
else |
{ |
result = Action.ERROR; |
} |
177,7 → 146,7 |
String result = Action.ERROR; |
if (id > 0) |
{ |
this.setRelationship(this.relationshipDAO.getById(id)); |
this.setRelationship(this.relationshipDAO.getRelationshipById(id)); |
if (this.getRelationship() != null) |
{ |
this.edit = true; |
204,7 → 173,7 |
String result = Action.SUCCESS; |
if (id > 0) |
{ |
this.relationshipDAO.delete(id); |
this.relationshipDAO.deleteRelationship(id); |
} |
else |
{ |
322,21 → 291,4 |
{ |
this.modifiedRelationship = modifiedRelationship; |
} |
/** |
* @return the history |
*/ |
public Set<History> getHistory() |
{ |
return this.history; |
} |
/** |
* @param history |
* the history to set |
*/ |
public void setHistory(Set<History> history) |
{ |
this.history = history; |
} |
} |
/trunk/src/ch/ffhs/webE/action/TermAction.java |
---|
4,17 → 4,13 |
import java.util.Date; |
import java.util.List; |
import java.util.Map; |
import java.util.Set; |
import javax.servlet.http.HttpServletRequest; |
import org.apache.struts2.StrutsStatics; |
import ch.ffhs.webE.dao.HistoryDAO; |
import ch.ffhs.webE.dao.TermDAO; |
import ch.ffhs.webE.dao.UserDAO; |
import ch.ffhs.webE.domain.ActionType; |
import ch.ffhs.webE.domain.History; |
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; |
36,8 → 32,8 |
private Term term = new Term(); |
private List<Term> termList = new ArrayList<Term>(); |
private final TermDAO termDAO = new TermDAO(); |
private final UserDAO userDAO = new UserDAO(); |
private final TermDAOImpl termDAO = new TermDAOImpl(); |
private final UserDAOImpl userDAO = new UserDAOImpl(); |
/** |
* Session object |
63,10 → 59,6 |
*/ |
public Term savedTerm; |
private final HistoryDAO historyDAO = new HistoryDAO(); |
private Set<History> history; |
/* |
* (non-Javadoc) |
* |
84,7 → 76,7 |
*/ |
public String list() |
{ |
this.termList = this.termDAO.getList(); |
this.termList = this.termDAO.getTerms(); |
return Action.SUCCESS; |
} |
95,41 → 87,24 |
*/ |
public String save() |
{ |
User user = this.userDAO.getByUsername((String) this.session |
User user = this.userDAO.searchUsername((String) this.session |
.get("username")); |
Date now = new Date(); |
ObjectEntity obj; |
int action = 0; |
if ("false".equals(this.request.getParameter("edit"))) |
{ |
/* Add a new term */ |
obj = new ObjectEntity(user, new ObjectType(ObjectType.TERM), user, null, |
now, false, this.term, null, null); |
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; |
action = ActionType.ADD; |
} |
else |
{ |
obj = new ObjectEntity(); |
obj.setId(this.term.getObjectId()); |
action = ActionType.RENAME; |
} |
this.edit = false; |
String result = Action.SUCCESS; |
if (this.termDAO.saveOrUpdate(this.term)) |
if (!this.termDAO.saveOrUpdate(this.term)) |
{ |
String comment = this.request.getParameter("comment"); |
History historyRecord = new History(user, new ActionType(action), obj, |
this.term.getName(), comment, now); |
this.historyDAO.saveOrUpdate(historyRecord); |
} |
else |
{ |
result = Action.ERROR; |
} |
152,7 → 127,7 |
String result = Action.ERROR; |
if (id > 0) |
{ |
this.term = this.termDAO.getById(id); |
this.term = this.termDAO.getTermById(id); |
if (this.term != null) |
{ |
this.edit = true; |
180,7 → 155,7 |
String result = Action.SUCCESS; |
if (id > 0) |
{ |
this.termDAO.delete(id); |
this.termDAO.deleteTerm(id); |
} |
else |
{ |
247,21 → 222,4 |
{ |
this.termList = termList; |
} |
/** |
* @return the histories |
*/ |
public Set<History> getHistories() |
{ |
return this.history; |
} |
/** |
* @param histories |
* the histories to set |
*/ |
public void setHistories(Set<History> histories) |
{ |
this.history = histories; |
} |
} |
/trunk/src/ch/ffhs/webE/action/RelationshipTypeAction.java |
---|
8,6 → 8,7 |
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; |
23,12 → 24,8 |
private RelationshipType relType = new RelationshipType(); |
private List<RelationshipType> relTypeList = new ArrayList<RelationshipType>(); |
private final RelationshipTypeDAO relTypeDAO = new RelationshipTypeDAO(); |
private final RelationshipTypeDAO relTypeDAO = new RelationshipTypeDAOImpl(); |
public boolean edit = false; |
public boolean added = false; |
public RelationshipType savedRelType; |
@Override |
public RelationshipType getModel() |
{ |
37,13 → 34,13 |
public String addOrUpdate() |
{ |
this.relTypeDAO.saveOrUpdate(this.relType); |
this.relTypeDAO.saveOrUpdateRelType(this.relType); |
return Action.SUCCESS; |
} |
public String list() |
{ |
this.relTypeList = this.relTypeDAO.getList(); |
this.relTypeList = this.relTypeDAO.getRelTypes(); |
return Action.SUCCESS; |
} |
51,18 → 48,16 |
{ |
int id = this.getIdParameter(); |
String result = Action.ERROR; |
if (id > 0) |
{ |
this.relType = this.relTypeDAO.getById(id); |
this.edit = true; |
result = Action.SUCCESS; |
this.relType = this.relTypeDAO.getRelTypeById(id); |
return Action.SUCCESS; |
} |
this.list(); |
return result; |
else |
{ |
return Action.ERROR; |
} |
} |
/** |
* Gets the ID Parameter for update / delete requests |
100,7 → 95,7 |
// Check for malicious ID values |
if (id > 0) |
{ |
this.relTypeDAO.delete(id); |
this.relTypeDAO.deleteRelationshipType(id); |
return Action.SUCCESS; |
} |
else |
/trunk/src/ch/ffhs/webE/action/LoginAction.java |
---|
2,7 → 2,7 |
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; |
15,7 → 15,7 |
private static final long serialVersionUID = 1799753056277211344L; |
private final User user = new User(); |
private final UserDAO userDAO = new UserDAO(); |
private final UserDAOImpl userDAO = new UserDAOImpl(); |
/* Form fields */ |
private String userName; |
84,7 → 84,7 |
public String verifyUser(String username, String password) |
{ |
// DB Query |
User u = this.userDAO.getByUsername(username); |
User u = this.userDAO.searchUsername(username); |
// User does not exist |
if (u == null) |
/trunk/src/ch/ffhs/webE/action/UserAction.java |
---|
7,7 → 7,7 |
import org.apache.struts2.StrutsStatics; |
import ch.ffhs.webE.dao.UserDAO; |
import ch.ffhs.webE.dao.UserDAOImpl; |
import ch.ffhs.webE.domain.User; |
import com.opensymphony.xwork2.Action; |
22,12 → 22,8 |
private User user = new User(); |
private List<User> userList = new ArrayList<User>(); |
private final UserDAO userDAO = new UserDAO(); |
private final UserDAOImpl userDAO = new UserDAOImpl(); |
public boolean edit = false; |
public boolean added = false; |
public User savedUser; |
@Override |
public User getModel() |
{ |
35,29 → 31,24 |
} |
/** |
* DB query for userList |
* Executes the DB query to save the user |
* |
* @return SUCCESS |
* @return |
*/ |
public String list() |
public String addOrUpdate() |
{ |
this.userList = this.userDAO.getList(); |
this.userDAO.saveOrUpdateUser(this.user); |
return Action.SUCCESS; |
} |
/** |
* Executes the DB query to save the user |
* DB query for userList |
* |
* @return |
* @return SUCCESS |
*/ |
public String save() |
public String list() |
{ |
this.userDAO.saveOrUpdate(this.user); |
this.savedUser = this.user; |
this.user = null; |
this.list(); |
this.userList = this.userDAO.listUser(); |
return Action.SUCCESS; |
} |
65,18 → 56,16 |
{ |
int id = this.getIdParameter(); |
String result = Action.ERROR; |
if (id > 0) |
{ |
this.user = this.userDAO.getById(id); |
this.edit = true; |
result = Action.SUCCESS; |
this.user = this.userDAO.listUserById(id); |
return Action.SUCCESS; |
} |
this.list(); |
return result; |
else |
{ |
return Action.ERROR; |
} |
} |
/** |
* Gets the ID Parameter for update / delete requests |
115,7 → 104,7 |
// Check for malicious ID values |
if (id > 0) |
{ |
this.userDAO.delete(id); |
this.userDAO.deleteUser(id); |
return Action.SUCCESS; |
} |
else |