Skip to content
Snippets Groups Projects
Commit cd11188c authored by felmer's avatar felmer
Browse files

OBP-37 allow null argument for project

SVN: 17727
parent d73de0cc
No related branches found
No related tags found
No related merge requests found
......@@ -33,17 +33,20 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE;
public interface IExperimentDAO extends IGenericDAO<ExperimentPE>
{
/**
* Lists all belonging to given <code>project</code>. Fetches also properties.
* Lists experiments of the specified project. Fetches also properties.
*
* @param projectOrNull If <code>null</code> all experiments are returned.
*/
public List<ExperimentPE> listExperimentsWithProperties(final ProjectPE project)
public List<ExperimentPE> listExperimentsWithProperties(final ProjectPE projectOrNull)
throws DataAccessException;
/**
* Lists all of given <code>type</code> belonging to given <code>project</code>. Fetches also
* properties.
* Lists experiments of specified type and specified project. Fetches also properties.
*
* @param projectOrNull If <code>null</code> all experiments of specified type are returned.
*/
public List<ExperimentPE> listExperimentsWithProperties(final ExperimentTypePE experimentType,
final ProjectPE project) throws DataAccessException;
final ProjectPE projectOrNull) throws DataAccessException;
/**
* Lists all registered experiments. Doesn't fetch properties.
......
......@@ -57,31 +57,32 @@ public class ExperimentDAO extends AbstractGenericEntityDAO<ExperimentPE> implem
super(sessionFactory, databaseInstance, ExperimentPE.class);
}
public List<ExperimentPE> listExperimentsWithProperties(final ProjectPE project)
public List<ExperimentPE> listExperimentsWithProperties(final ProjectPE projectOrNull)
throws DataAccessException
{
return listExperimentsWithProperties(null, project);
return listExperimentsWithProperties(null, projectOrNull);
}
public List<ExperimentPE> listExperimentsWithProperties(
final ExperimentTypePE experimentTypeOrNull, final ProjectPE project)
final ExperimentTypePE experimentTypeOrNull, final ProjectPE projectOrNull)
throws DataAccessException
{
assert project != null : "Unspecified project.";
final DetachedCriteria criteria = DetachedCriteria.forClass(getEntityClass());
if (experimentTypeOrNull != null)
{
criteria.add(Restrictions.eq("experimentType", experimentTypeOrNull));
}
criteria.add(Restrictions.eq("projectInternal", project));
if (projectOrNull != null)
{
criteria.add(Restrictions.eq("projectInternal", projectOrNull));
}
criteria.setFetchMode("experimentProperties", FetchMode.JOIN);
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
final List<ExperimentPE> list = cast(getHibernateTemplate().findByCriteria(criteria));
if (operationLog.isDebugEnabled())
{
operationLog.debug(String.format("%d experiments have been found for project '%s'%s.",
list.size(), project, (experimentTypeOrNull == null) ? ""
list.size(), projectOrNull, (experimentTypeOrNull == null) ? ""
: " and experiment type '" + experimentTypeOrNull + "'"));
}
return list;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment