Added a delete() in collections DAO
NEW - bug 74: Remove empty collections automatically
https://www.argeo.org/bugzilla/show_bug.cgi?id=74
git-svn-id: https://svn.argeo.org/slc/trunk@1979
4cfe0d0a-d680-48aa-b62c-
e0a02a3f76cc
\r
import org.argeo.slc.test.TestRunDescriptor;\r
\r
+/** Performs complex business operations. */\r
public interface TestManagerService {\r
+ /** Performs operations related to the addition of a new test run. */\r
public void registerTestRunDescriptor(TestRunDescriptor testRunDescriptor);\r
\r
+ /** Adds a result in a collection based on their ids. */\r
public void addResultToCollection(String collectionId, String resultUuid);\r
\r
+ /** Removes a result from a collection based on their ids. */\r
public void removeResultFromCollection(String collectionId,\r
String resultUuid);\r
}\r
import org.argeo.slc.services.test.TestManagerService;\r
import org.argeo.slc.test.TestRunDescriptor;\r
\r
+/** Implementation of complex operations impacting the underlying data. */\r
public class TestManagerServiceImpl implements TestManagerService {\r
private Log log = LogFactory.getLog(getClass());\r
\r
treeTestResultCollectionDao.removeResultFromCollection(ttrc,\r
resultUuid);\r
}\r
+\r
+ // Delete collection if empty\r
+ // see https://www.argeo.org/bugzilla/show_bug.cgi?id=74\r
+ if (ttrc.getResults().size() == 0) {\r
+ treeTestResultCollectionDao.delete(ttrc);\r
+ }\r
}\r
\r
}\r
import org.springframework.orm.hibernate3.HibernateCallback;\r
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;\r
\r
+/** Hibernate implementation of collections DAO. */\r
public class TreeTestResultCollectionDaoHibernate extends HibernateDaoSupport\r
implements TreeTestResultCollectionDao {\r
\r
getHibernateTemplate().update(ttrCollection);\r
}\r
\r
+ public void delete(TreeTestResultCollection ttrCollection) {\r
+ getHibernateTemplate().delete(ttrCollection);\r
+ }\r
+\r
@SuppressWarnings("unchecked")\r
public SortedSet<TreeTestResultCollection> listCollections() {\r
return new TreeSet<TreeTestResultCollection>(getHibernateTemplate()\r
\r
public void update(TreeTestResultCollection ttrCollection);\r
\r
+ public void delete(TreeTestResultCollection ttrCollection);\r
+\r
public TreeTestResultCollection getTestResultCollection(String id);\r
\r
public SortedSet<TreeTestResultCollection> listCollections();\r