This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Moved SQL related query into DAO class

  • Loading branch information...
aeng committed Jan 5, 2012
1 parent 7187294 commit 94396481efa146cf10de5339dbed6f31fae30959
@@ -20,13 +20,11 @@
*/
package org.zanata.action;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.faces.event.ValueChangeEvent;
-import javax.faces.model.SelectItem;
import javax.persistence.NoResultException;
import org.hibernate.Session;
@@ -39,12 +37,12 @@
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.log.Log;
import org.jboss.seam.security.management.JpaIdentityStore;
+import org.zanata.dao.ProjectDAO;
import org.zanata.model.HAccount;
import org.zanata.model.HIterationProject;
import org.zanata.model.HLocale;
import org.zanata.model.HPerson;
import org.zanata.model.HProjectIteration;
-import org.zanata.model.type.StatusType;
import org.zanata.service.LocaleService;
@Name("projectHome")
@@ -58,13 +56,19 @@
@In(required = false, value = JpaIdentityStore.AUTHENTICATED_USER)
HAccount authenticatedAccount;
+
@In(required = false)
Map<String, String> customizedItems;
+
@In(required = false)
private Boolean overrideLocales;
+
@In
LocaleService localeServiceImpl;
+ @In(create = true)
+ ProjectDAO projectDAO;
+
@Override
protected HIterationProject loadInstance()
{
@@ -131,22 +135,19 @@ public String persist()
return retValue;
}
- @SuppressWarnings("unchecked")
public List<HProjectIteration> getCurrentIterations()
{
- return getEntityManager().createQuery("from HProjectIteration t where t.project.slug = :projectSlug and t.status = :status").setParameter("projectSlug", slug).setParameter("status", StatusType.Current).getResultList();
+ return projectDAO.getCurrentIterations(slug);
}
- @SuppressWarnings("unchecked")
public List<HProjectIteration> getRetiredIterations()
{
- return getEntityManager().createQuery("from HProjectIteration t where t.project.slug = :projectSlug and t.status = :status").setParameter("projectSlug", slug).setParameter("status", StatusType.Retired).getResultList();
+ return projectDAO.getRetiredIterations(slug);
}
- @SuppressWarnings("unchecked")
public List<HProjectIteration> getObsoleteIterations()
{
- return getEntityManager().createQuery("from HProjectIteration t where t.project.slug = :projectSlug and t.status = :status").setParameter("projectSlug", slug).setParameter("status", StatusType.Obsolete).getResultList();
+ return projectDAO.getObsoleteIterations(slug);
}
public String cancel()
@@ -20,12 +20,10 @@
*/
package org.zanata.action;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.faces.event.ValueChangeEvent;
-import javax.faces.model.SelectItem;
import javax.persistence.EntityNotFoundException;
import javax.persistence.NoResultException;
@@ -40,7 +38,6 @@
import org.zanata.model.HIterationProject;
import org.zanata.model.HLocale;
import org.zanata.model.HProjectIteration;
-import org.zanata.model.type.StatusType;
import org.zanata.service.LocaleService;
@Name("projectIterationHome")
@@ -2,6 +2,9 @@
import java.util.List;
+import javax.persistence.NoResultException;
+
+import org.hibernate.NonUniqueResultException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Order;
@@ -12,6 +15,7 @@
import org.jboss.seam.annotations.Scope;
import org.zanata.model.HPerson;
import org.zanata.model.HProject;
+import org.zanata.model.HProjectIteration;
import org.zanata.model.type.StatusType;
@Name("projectDAO")
@@ -70,4 +74,22 @@ public int getProjectSize()
return 0;
return totalCount.intValue();
}
+
+ @SuppressWarnings("unchecked")
+ public List<HProjectIteration> getCurrentIterations(String slug)
+ {
+ return getSession().createQuery("from HProjectIteration t where t.project.slug = :projectSlug and t.status = :status").setParameter("projectSlug", slug).setParameter("status", StatusType.Current).list();
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<HProjectIteration> getRetiredIterations(String slug)
+ {
+ return getSession().createQuery("from HProjectIteration t where t.project.slug = :projectSlug and t.status = :status").setParameter("projectSlug", slug).setParameter("status", StatusType.Retired).list();
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<HProjectIteration> getObsoleteIterations(String slug)
+ {
+ return getSession().createQuery("from HProjectIteration t where t.project.slug = :projectSlug and t.status = :status").setParameter("projectSlug", slug).setParameter("status", StatusType.Obsolete).list();
+ }
}
@@ -229,5 +229,4 @@ public Long getTotalCountForIteration(Long iterationId)
}
return totalCount;
}
-
}

0 comments on commit 9439648

Please sign in to comment.