Subversion Repositories WebE

Compare Revisions

Last modification

Ignore whitespace Rev 31 → Rev 30

/trunk/src/ch/ffhs/webE/action/TermAction.java
File deleted
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain
\ No newline at end of property
Index: webE/dao/TermDAOImpl.java
===================================================================
--- webE/dao/TermDAOImpl.java (revision 31)
+++ webE/dao/TermDAOImpl.java (nonexistent)
@@ -1,145 +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.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;
-
- /**
- * Creates a list of all terms
- *
- * @return an ArrayList with all the users - in case of a problem, an empty
- * list is returned
- */
- @SuppressWarnings("unchecked")
- public List<Term> listTerm()
- {
- 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 void saveOrUpdate(Term term)
- {
- try
- {
- this.session.saveOrUpdate(term);
- }
- catch (Exception e)
- {
- this.transaction.rollback();
- e.printStackTrace();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ch.ffhs.webE.dao.TermDAO#deleteTerm(int)
- */
- public void deleteTerm(int termId)
- {
- try
- {
- Term user = (Term) this.session.get(Term.class, termId);
- this.session.delete(user);
- }
- catch (Exception e)
- {
- this.transaction.rollback();
- e.printStackTrace();
- }
- }
-
- /**
- * Returns a single user with this user name (used for login)
- *
- * @param termName
- * Term name
- * @return User: Returns a user object if something is found. If not, null is
- * returned
- */
- 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)
- {
- e.printStackTrace();
- }
- return term;
- }
-}
\ No newline at end of file
/webE/dao/TermDAOImpl.java
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain
\ No newline at end of property
Index: webE/dao/TermDAO.java
===================================================================
--- webE/dao/TermDAO.java (revision 31)
+++ webE/dao/TermDAO.java (nonexistent)
@@ -1,46 +0,0 @@
-package ch.ffhs.webE.dao;
-
-import java.util.List;
-
-import ch.ffhs.webE.domain.Term;
-
-/**
- * Defines methods all term DAO implementations must implement
- *
- * @author pelinux
- */
-public interface TermDAO
-{
- /**
- * @return
- */
- List<Term> listTerm();
-
- /**
- * @param termName
- * @return
- */
- Term searchTerm(String termName);
-
- /**
- * Delete a term
- *
- * @param termId
- * Term ID
- */
- void deleteTerm(int termId);
-
- /**
- * @param termId
- * @return
- */
- Term listTermById(int termId);
-
- /**
- * Executes the query to save the term
- *
- * @param term
- * Domain object to be saved
- */
- void saveOrUpdate(Term term);
-}
/webE/dao/TermDAO.java
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain
\ No newline at end of property