* 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/ch/ffhs/webE/dao/TermDAOImpl.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: RelationshipTypeDAOImpl.java |
=================================================================== |
--- RelationshipTypeDAOImpl.java (revision 35) |
+++ RelationshipTypeDAOImpl.java (nonexistent) |
@@ -1,118 +0,0 @@ |
-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; |
- } |
-} |
/RelationshipTypeDAOImpl.java |
---|
Property changes: |
Deleted: svn:mime-type |
## -1 +0,0 ## |
-text/plain |
\ No newline at end of property |
Index: UserDAOImpl.java |
=================================================================== |
--- UserDAOImpl.java (revision 35) |
+++ UserDAOImpl.java (nonexistent) |
@@ -1,135 +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.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 |
/UserDAOImpl.java |
---|
Property changes: |
Deleted: svn:mime-type |
## -1 +0,0 ## |
-text/plain |
\ No newline at end of property |
Index: RelationshipDAOImpl.java |
=================================================================== |
--- RelationshipDAOImpl.java (revision 35) |
+++ RelationshipDAOImpl.java (nonexistent) |
@@ -1,130 +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.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 |
/RelationshipDAOImpl.java |
---|
Property changes: |
Deleted: svn:mime-type |
## -1 +0,0 ## |
-text/plain |
\ No newline at end of property |
Index: UserDAO.java |
=================================================================== |
--- UserDAO.java (revision 35) |
+++ UserDAO.java (revision 37) |
@@ -1,19 +1,134 @@ |
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; |
-public interface UserDAO |
+import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget; |
+import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget; |
+ |
+public class UserDAO |
{ |
- List<User> listUser(); |
+ @SessionTarget |
+ Session session; |
+ @TransactionTarget |
+ Transaction transaction; |
- User searchUsername(String username); |
+ /** |
+ * 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(); |
+ } |
- void deleteUser(int userId); |
+ // If no user was checked, return an empty list to mitigate null pointer |
+ // exceptions |
+ if (user == null) |
+ { |
+ user = new ArrayList<User>(); |
+ } |
+ return user; |
+ } |
- User listUserById(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(); |
+ } |
+ } |
- void saveOrUpdateUser(User user); |
-} |
+ /** |
+ * 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); |
+ } |
+ 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/dao/HistoryDAO.java |
---|
0,0 → 1,88 |
/** |
* |
*/ |
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; |
} |
} |
Property changes: |
Added: svn:mime-type |
## -0,0 +1 ## |
+text/plain |
\ No newline at end of property |
Index: RelationshipDAO.java |
=================================================================== |
--- RelationshipDAO.java (nonexistent) |
+++ RelationshipDAO.java (revision 37) |
@@ -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 RelationshipDAO |
+{ |
+ /** |
+ * 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> getList() |
+ { |
+ 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 delete(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 getById(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 |
/RelationshipDAO.java |
---|
Property changes: |
Added: svn:mime-type |
## -0,0 +1 ## |
+text/plain |
\ No newline at end of property |
Index: RelationshipTypeDAO.java |
=================================================================== |
--- RelationshipTypeDAO.java (revision 35) |
+++ RelationshipTypeDAO.java (revision 37) |
@@ -1,16 +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.RelationshipType; |
-public interface RelationshipTypeDAO { |
+import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget; |
+import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget; |
- List<RelationshipType> getRelTypes(); |
+/** |
+ * Data Access Object class for {@link RelationshipType}s |
+ * |
+ * @author Thomas Lahn |
+ */ |
+public class RelationshipTypeDAO |
+{ |
- boolean deleteRelationshipType(int relTypeID); |
- |
- RelationshipType getRelTypeById(int relTypeID); |
+ /** |
+ * Hibernate session target |
+ */ |
+ @SessionTarget |
+ Session session; |
- boolean saveOrUpdateRelType(RelationshipType relType); |
+ /** |
+ * Hibernate transaction target |
+ */ |
+ @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") |
+ public List<RelationshipType> getList() |
+ { |
+ |
+ List<RelationshipType> relType = null; |
+ |
+ try |
+ { |
+ relType = this.session.createQuery("from RelationshipType").list(); //$NON-NLS-1$ |
+ } |
+ 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/TermDAO.java |
---|
1,28 → 1,108 |
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; |
/** |
* Defines methods all term DAO implementations must implement |
* Implements the Database Access Object for terms |
* |
* @author pelinux |
* @author Thomas Lahn |
*/ |
public interface TermDAO |
public class TermDAO |
{ |
/** |
* @return |
* Database session |
*/ |
List<Term> getTerms(); |
@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> getList() |
{ |
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; |
} |
/** |
* Executes the query to save the term |
* |
* @param term |
* 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; |
} |
catch (Exception e) |
{ |
this.transaction.rollback(); |
e.printStackTrace(); |
return false; |
} |
} |
/** |
* Delete a term |
* |
* @param termId |
* Term ID |
*/ |
void deleteTerm(int termId); |
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 |
30,14 → 110,19 |
* @param termId |
* @return |
*/ |
Term getTermById(int termId); |
public Term getById(int termId) |
{ |
Term term = null; |
/** |
* Executes the query to save the term |
* |
* @param term |
* Domain object to be saved |
* @return <code>true</code> if successful, <code>false</code> otherwise |
*/ |
boolean saveOrUpdate(Term term); |
} |
try |
{ |
term = (Term) this.session.get(Term.class, termId); |
} |
catch (Exception e) |
{ |
e.printStackTrace(); |
} |
return term; |
} |
} |