Subversion Repositories WebE

Compare Revisions

Last modification

Ignore whitespace Rev 33 → Rev 34

/trunk/src/ch/ffhs/webE/dao/RelationshipTypeDAO.java
6,11 → 6,11
 
public interface RelationshipTypeDAO {
 
List<RelationshipType> listRelationshipTypes();
List<RelationshipType> getRelTypes();
 
boolean deleteRelationshipType(int relTypeID);
RelationshipType listRelTypeById(int relTypeID);
RelationshipType getRelTypeById(int relTypeID);
 
boolean saveOrUpdateRelType(RelationshipType relType);
}
/trunk/src/ch/ffhs/webE/dao/RelationshipDAOImpl.java
0,0 → 1,130
package ch.ffhs.webE.dao;
 
import java.util.ArrayList;
import java.util.List;
 
import org.hibernate.Session;
import org.hibernate.Transaction;
 
import ch.ffhs.webE.domain.Relationship;
 
import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget;
import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget;
 
/**
* Implements the Database Access Object for terms
*
* @author Thomas Lahn
*/
public class RelationshipDAOImpl
{
/**
* Database session
*/
@SessionTarget
Session session;
 
/**
* Database transaction
*/
@TransactionTarget
Transaction transaction;
 
/**
* Creates a list of all relationships
*
* @return an ArrayList with all the relationshops - in case of a problem, an
* empty list is returned
*/
@SuppressWarnings("unchecked")
public List<Relationship> listRelationships()
{
List<Relationship> relationship = null;
try
{
relationship = this.session.createQuery("from Relationship").list(); //$NON-NLS-1$
}
catch (Exception e)
{
e.printStackTrace();
}
 
/*
* If no relationship was checked, return an empty list to mitigate null
* pointer exceptions
*/
if (relationship == null)
{
relationship = new ArrayList<Relationship>();
}
 
return relationship;
}
 
/**
* Executes the query to save the relationship
*
* @param relationship
* Domain object to be saved
* @return <code>true</code> if successful, <code>false</code> otherwise
*/
public boolean saveOrUpdate(Relationship relationship)
{
try
{
relationship.setObjectId(relationship.getObjectId());
this.session.saveOrUpdate(relationship);
return true;
}
catch (Exception e)
{
this.transaction.rollback();
e.printStackTrace();
return false;
}
}
 
/**
* Delete a relationship
*
* @param id
* Relationship ID
*/
public void deleteRelationship(int id)
{
try
{
Relationship relationship = (Relationship) this.session.get(
Relationship.class, id);
this.session.delete(relationship);
}
catch (Exception e)
{
this.transaction.rollback();
e.printStackTrace();
}
}
 
/**
* Retrieves a relationship by ID
*
* @param id
* Term ID
* @return The relationship with this <var>id</var>
*/
public Relationship getRelationshipById(int id)
{
Relationship relationship = null;
 
try
{
relationship = (Relationship) this.session.get(Relationship.class, id);
}
catch (Exception e)
{
e.printStackTrace();
}
 
return relationship;
}
}
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: RelationshipTypeDAOImpl.java
===================================================================
--- RelationshipTypeDAOImpl.java (revision 33)
+++ RelationshipTypeDAOImpl.java (revision 34)
@@ -26,7 +26,7 @@
*/
@SuppressWarnings("unchecked")
@Override
- public List<RelationshipType> listRelationshipTypes()
+ public List<RelationshipType> getRelTypes()
{
List<RelationshipType> relType = null;
@@ -100,7 +100,7 @@
* Used to get a relationship type by ID
*/
@Override
- public RelationshipType listRelTypeById(int relTypeID)
+ public RelationshipType getRelTypeById(int relTypeID)
{
RelationshipType relType = null;
try
/trunk/src/ch/ffhs/webE/dao/TermDAO.java
14,7 → 14,7
/**
* @return
*/
List<Term> listTerm();
List<Term> getTerms();
 
/**
* Delete a term
/trunk/src/ch/ffhs/webE/dao/TermDAOImpl.java
31,13 → 31,13
Transaction transaction;
 
/**
* Creates a list of all terms
* Returns a list of all terms
*
* @return an ArrayList with all the users - in case of a problem, an empty
* @return an ArrayList with all the terms - in case of a problem, an empty
* list is returned
*/
@SuppressWarnings("unchecked")
public List<Term> listTerm()
public List<Term> getTerms()
{
List<Term> term = null;
try